source
stringclasses
1 value
repo
stringlengths
5
63
repo_url
stringlengths
24
82
path
stringlengths
5
167
language
stringclasses
1 value
license
stringclasses
5 values
stars
int64
10
51.4k
ref
stringclasses
23 values
size_bytes
int64
200
258k
text
stringlengths
137
258k
github
paulspringett/csv_shaper
https://github.com/paulspringett/csv_shaper
spec/csv_shaper_spec.rb
Ruby
mit
222
main
776
require 'spec_helper' describe CsvShaper::Shaper do it "should return a version" do expect(CsvShaper::VERSION).to be_kind_of(String) end it "should raise an exception when passing a non-enumarble to rows" do csv = CsvShaper::Shaper.new expect { csv.rows :name }.to raise_exception(ArgumentE...
github
paulspringett/csv_shaper
https://github.com/paulspringett/csv_shaper
spec/csv_shaper_template_spec.rb
Ruby
mit
222
main
1,033
require 'spec_helper' require "csv_shaper_template" describe CsvShaperTemplate do it "should allow configuration via #config method" do csv_string = CsvShaperTemplate.encode(double('context')) do |csv| csv.config.write_headers = false csv.config.col_sep = ';' csv.headers :name, :age, :gender ...
github
paulspringett/csv_shaper
https://github.com/paulspringett/csv_shaper
spec/header_spec.rb
Ruby
mit
222
main
1,698
require 'spec_helper' require 'fixtures/user' describe CsvShaper::Header do before(:each) do config = double(:config, options: { header_inflector: :humanize }) allow(CsvShaper::Shaper).to receive(:config) { config } end it "should accept and store a list of symbols" do header = CsvShaper::Header.ne...
github
paulspringett/csv_shaper
https://github.com/paulspringett/csv_shaper
spec/config_spec.rb
Ruby
mit
222
main
1,931
require 'spec_helper' describe CsvShaper::Config do let(:config) { CsvShaper::Config.new do |c| c.write_headers = false c.col_sep = "\t" c.header_inflector = :titleize end } it "should assign options to config" do expect(config.options).to eq({ write_headers: false, col_sep: "\t", ...
github
paulspringett/csv_shaper
https://github.com/paulspringett/csv_shaper
spec/encoder_spec.rb
Ruby
mit
222
main
1,506
require 'spec_helper' require 'fixtures/user' describe CsvShaper::Encoder do let(:user) { User.new(name: 'Paul', age: 27, gender: 'Male') } let(:config) { CsvShaper::Config.new do |c| c.write_headers = true end } it "should raise an exception if the headers are missing" do expect { Cs...
github
paulspringett/csv_shaper
https://github.com/paulspringett/csv_shaper
spec/row_spec.rb
Ruby
mit
222
main
1,624
require 'spec_helper' require 'fixtures/user' describe CsvShaper::Row do let(:user) { User.new(name: 'Paul', age: 27, gender: 'Male') } it "should assign a model" do row = CsvShaper::Row.new user do |csv, user| # ... end expect(row.model).to eq user end it "should assign a model's attribut...
github
just-the-docs/just-the-docs-template
https://github.com/just-the-docs/just-the-docs-template
Gemfile
Ruby
mit
222
main
288
source 'https://rubygems.org' gem "jekyll", "~> 4.4.1" # installed by `gem jekyll` # gem "webrick" # required when using Ruby >= 3 and Jekyll <= 4.2.2 gem "just-the-docs", "0.12.0" # pinned to the current release # gem "just-the-docs" # always download the latest release
github
ankane/fastText-ruby
https://github.com/ankane/fastText-ruby
fasttext.gemspec
Ruby
mit
222
master
708
require_relative "lib/fasttext/version" Gem::Specification.new do |spec| spec.name = "fasttext" spec.version = FastText::VERSION spec.summary = "Efficient text classification and representation learning for Ruby" spec.homepage = "https://github.com/ankane/fastText-ruby" spec.license...
github
ankane/fastText-ruby
https://github.com/ankane/fastText-ruby
Rakefile
Ruby
mit
222
master
676
require "bundler/gem_tasks" require "rake/testtask" require "rake/extensiontask" require "ruby_memcheck" test_config = lambda do |t| t.pattern = "test/**/*_test.rb" end Rake::TestTask.new(&test_config) namespace :test do RubyMemcheck::TestTask.new(:valgrind, &test_config) end task default: :test Rake::Extension...
github
ankane/fastText-ruby
https://github.com/ankane/fastText-ruby
ext/fasttext/extconf.rb
Ruby
mit
222
master
565
require "mkmf-rice" # -march=native not supported with ARM Mac default_optflags = RbConfig::CONFIG["host_os"] =~ /darwin/i && RbConfig::CONFIG["host_cpu"] =~ /arm|aarch64/i ? "" : "-march=native" # -pthread and -O3 set by default $CXXFLAGS << " -std=c++17 $(optflags) -funroll-loops " << with_config("optflags", default...
github
ankane/fastText-ruby
https://github.com/ankane/fastText-ruby
test/classifier_test.rb
Ruby
mit
222
master
3,691
require_relative "test_helper" class ClassifierTest < Minitest::Test def test_works x = [ "This is the first document", "Hello, this is the second document", "Hello, and this is the third one", "Is this the first document?" ] y = ["ham", "spam", "spam", "ham"] model = FastTex...
github
ankane/fastText-ruby
https://github.com/ankane/fastText-ruby
test/vectorizer_test.rb
Ruby
mit
222
master
742
require_relative "test_helper" class VectorizerTest < Minitest::Test def test_works x = [ "this is a test" ] model = FastText::Vectorizer.new model.fit(x) assert model.nearest_neighbors("asparagus") assert model.analogies("berlin", "germany", "france") end def test_input_file ...
github
ankane/fastText-ruby
https://github.com/ankane/fastText-ruby
lib/fasttext.rb
Ruby
mit
222
master
903
# ext require "fasttext/ext" # stdlib require "tempfile" # modules require_relative "fasttext/model" require_relative "fasttext/classifier" require_relative "fasttext/vectorizer" require_relative "fasttext/version" module FastText class Error < StandardError; end class << self def load_model(path) m =...
github
ankane/fastText-ruby
https://github.com/ankane/fastText-ruby
lib/fasttext/model.rb
Ruby
mit
222
master
1,238
module FastText class Model def initialize(**options) @options = options end def dimension m.dimension end def quantized? m.quantized? end def save_model(path) m.save_model(path) end def words(include_freq: false) words, freqs = m.words if in...
github
ankane/fastText-ruby
https://github.com/ankane/fastText-ruby
lib/fasttext/classifier.rb
Ruby
mit
222
master
2,549
module FastText class Classifier < Model DEFAULT_OPTIONS = { lr: 0.1, lr_update_rate: 100, dim: 100, ws: 5, epoch: 5, min_count: 1, min_count_label: 0, neg: 5, word_ngrams: 1, loss: "softmax", model: "supervised", bucket: 2000000, minn:...
github
ankane/fastText-ruby
https://github.com/ankane/fastText-ruby
lib/fasttext/vectorizer.rb
Ruby
mit
222
master
1,446
module FastText class Vectorizer < Model DEFAULT_OPTIONS = { lr: 0.5, lr_update_rate: 100, dim: 100, ws: 5, epoch: 5, min_count: 1, min_count_label: 0, neg: 5, word_ngrams: 1, loss: "ns", model: "skipgram", bucket: 2000000, minn: 3, ...
github
ninoseki/miteru
https://github.com/ninoseki/miteru
miteru.gemspec
Ruby
mit
222
master
2,849
# frozen_string_literal: true lib = File.expand_path("lib", __dir__) $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) require "miteru/version" Gem::Specification.new do |spec| spec.name = "miteru" spec.version = Miteru::VERSION spec.authors = ["Manabu Niseki"] spec.email = ["manabu.niseki@gmail.com"] ...
github
ninoseki/miteru
https://github.com/ninoseki/miteru
spec/kit_spec.rb
Ruby
mit
222
master
1,736
# frozen_string_literal: true RSpec.describe Miteru::Kit do include_context "with fake HTTP server" let!(:base_url) { server.base_url } let!(:extname) { ".zip" } let!(:filename) { "test#{extname}" } let!(:link) { "/has_kit/#{filename}" } subject(:kit) { described_class.new(base_url + link, source: "dummy...
github
ninoseki/miteru
https://github.com/ninoseki/miteru
spec/crawler_spec.rb
Ruby
mit
222
master
388
# frozen_string_literal: true RSpec.describe Miteru::Crawler do include_context "with fake HTTP server" include_context "with mocked logger" subject(:crawler) { described_class.new } let!(:website) { Miteru::Website.new("#{server.base_url}/has_kit", source: "dummy") } describe "#call" do it do ex...
github
ninoseki/miteru
https://github.com/ninoseki/miteru
spec/website_spec.rb
Ruby
mit
222
master
677
# frozen_string_literal: true RSpec.describe Miteru::Website do include_context "with fake HTTP server" let!(:url) { "#{server.base_url}/has_kit" } subject(:website) { described_class.new(url, source: "dummy") } describe "#title" do it do expect(website.title).to be_a(String) end end desc...
github
ninoseki/miteru
https://github.com/ninoseki/miteru
spec/spec_helper.rb
Ruby
mit
222
master
2,157
# frozen_string_literal: true require "bundler/setup" require "simplecov" require "vcr" def ci_env? # CI=true in GitHub Actions ENV["CI"] end # setup simplecov formatter for coveralls class InceptionFormatter def format(result) Coveralls::SimpleCov::Formatter.new.format(result) end end def formatter ...
github
ninoseki/miteru
https://github.com/ninoseki/miteru
spec/orchestrator_spec.rb
Ruby
mit
222
master
545
# frozen_string_literal: true class DummyFeed < Miteru::Feeds::Base def initialize(base_url = "http://example.com") super end def urls ["http://example.com"] * 10 end end RSpec.describe Miteru::Orchestrator do include_context "with mocked logger" subject(:orchestrator) { described_class.new } ...
github
ninoseki/miteru
https://github.com/ninoseki/miteru
spec/cli_spec.rb
Ruby
mit
222
master
222
# frozen_string_literal: true RSpec.describe Miteru::CLI::App do subject { described_class.new } describe ".exit_on_failure?" do it do expect(described_class.exit_on_failure?).to eq(true) end end end
github
ninoseki/miteru
https://github.com/ninoseki/miteru
spec/downloader_spec.rb
Ruby
mit
222
master
561
# frozen_string_literal: true RSpec.describe Miteru::Downloader do include_context "with fake HTTP server" include_context "with mocked logger" let!(:url) { "#{server.base_url}/has_kit" } let!(:kit) { Miteru::Kit.new("#{url}/test.zip", source: "dummy") } describe "#call" do before do kit.valid? ...
github
ninoseki/miteru
https://github.com/ninoseki/miteru
spec/feeds/feed_spec.rb
Ruby
mit
222
master
1,083
# frozen_string_literal: true RSpec.describe Miteru::Feeds::Base do subject(:feed) { described_class.new("http://127.0.0.1") } describe "#decomposed_urls" do context "with a URL without path" do before { allow(feed).to receive(:urls).and_return(["http://127.0.0.1"]) } it do expect(subject...
github
ninoseki/miteru
https://github.com/ninoseki/miteru
spec/support/shared_contexts/fake_http_server_context.rb
Ruby
mit
222
master
1,061
# frozen_string_literal: true require "capybara" class FakeHTTP extend Forwardable attr_reader :req def initialize(env) @req = Rack::Request.new(env) end def_delegators :req, :path_info def call case path_info when "/has_kit" ["200", {"Content-Type" => "text/html"}, [File.read(File.e...
github
ninoseki/miteru
https://github.com/ninoseki/miteru
spec/support/shared_contexts/mocked_logger_context.rb
Ruby
mit
222
master
475
# frozen_string_literal: true RSpec.shared_context "with mocked logger" do let(:sio) { StringIO.new } let(:logger) do SemanticLogger.sync! SemanticLogger.default_level = :info SemanticLogger.add_appender(io: sio, formatter: :color) SemanticLogger["Miteru"] end let(:logger_output) do Seman...
github
ninoseki/miteru
https://github.com/ninoseki/miteru
lib/miteru.rb
Ruby
mit
222
master
2,789
# frozen_string_literal: true # Core standard libraries require "cgi" require "json" require "uri" require "uuidtools" # Core 3rd party libraries require "colorize" require "memo_wise" require "semantic_logger" require "sentry-ruby" require "dry/files" require "dry/monads" # Load .env require "dotenv/load" # Activ...
github
ninoseki/miteru
https://github.com/ninoseki/miteru
lib/miteru/service.rb
Ruby
mit
222
master
1,000
# frozen_string_literal: true module Miteru # # Base class for services # class Service include Dry::Monads[:result, :try] def call(*args, **kwargs) raise NotImplementedError, "You must implement #{self.class}##{__method__}" end def result(...) Try[StandardError] { call(...) }.to_...
github
ninoseki/miteru
https://github.com/ninoseki/miteru
lib/miteru/cache.rb
Ruby
mit
222
master
764
require "redis" module Miteru class Cache < Service # @return [String] attr_reader :url # # @param [String] url # def initialize(url) super() @url = url end # # @param [String] key # @param [String] value # @param [Integer. nil] ex # def set(key, valu...
github
ninoseki/miteru
https://github.com/ninoseki/miteru
lib/miteru/website.rb
Ruby
mit
222
master
2,026
# frozen_string_literal: true require "oga" module Miteru class Website < Service include Concerns::UrlTruncatable # @return [String] attr_reader :url # @return [String] attr_reader :source # # @param [String] url # @param [String] source # def initialize(url, source:) ...
github
ninoseki/miteru
https://github.com/ninoseki/miteru
lib/miteru/mixin.rb
Ruby
mit
222
master
394
# frozen_string_literal: true module Miteru module Mixins module URL IGNORE_EXTENSIONS = %w[.htm .html .php .asp .aspx .exe .txt].freeze # # Validate extension of a URL # # @param [String] url # # @return [Boolean] # def invalid_extension?(url) IGNOR...
github
ninoseki/miteru
https://github.com/ninoseki/miteru
lib/miteru/config.rb
Ruby
mit
222
master
3,677
# frozen_string_literal: true require "anyway_config" module Miteru class Config < Anyway::Config config_name :miteru env_prefix "" attr_config( auto_download: false, database_url: URI("sqlite3:miteru.db"), directory_traveling: false, download_to: "/tmp", file_max_size: 10...
github
ninoseki/miteru
https://github.com/ninoseki/miteru
lib/miteru/downloader.rb
Ruby
mit
222
master
1,565
# frozen_string_literal: true require "digest" require "fileutils" require "down/http" module Miteru class Downloader < Service prepend MemoWise # @return [String] attr_reader :base_dir # @return [Miteru::Kit] attr_reader :kit # # <Description> # # @param [Miteru::Kit] kit ...
github
ninoseki/miteru
https://github.com/ninoseki/miteru
lib/miteru/crawler.rb
Ruby
mit
222
master
1,641
# frozen_string_literal: true require "colorize" module Miteru class Crawler < Service # # @param [Miteru::Website] website # def call(website) Try[OpenSSL::SSL::SSLError, ::HTTP::Error, Addressable::URI::InvalidURIError] do log_message = "Website:#{website.defanged_truncated_url}" ...
github
ninoseki/miteru
https://github.com/ninoseki/miteru
lib/miteru/orchestrator.rb
Ruby
mit
222
master
1,318
# frozen_string_literal: true module Miteru class Orchestrator < Service def call logger.info("#{non_cached_websites.length} websites loaded in total.") if verbose? array_of_args = non_cached_websites.map { |website| [website.url, website.source] } Jobs::CrawleJob.perform_bulk(array_of_args, ba...
github
ninoseki/miteru
https://github.com/ninoseki/miteru
lib/miteru/database.rb
Ruby
mit
222
master
1,951
# frozen_string_literal: true class V2Schema < ActiveRecord::Migration[8.0] def change create_table :records, if_not_exists: true do |t| t.string :sha256, null: false, index: {unique: true} t.string :hostname, null: false t.json :headers, null: false t.text :filename, null: false t....
github
ninoseki/miteru
https://github.com/ninoseki/miteru
lib/miteru/http.rb
Ruby
mit
222
master
1,199
# frozen_string_literal: true require "http" module Miteru module HTTP # # Better error handling feature # class BetterError < ::HTTP::Feature def wrap_response(response) return response if response.status.success? raise StatusError.new( "Unsuccessful response code r...
github
ninoseki/miteru
https://github.com/ninoseki/miteru
lib/miteru/kit.rb
Ruby
mit
222
master
2,419
# frozen_string_literal: true module Miteru class Kit < Service include Concerns::UrlTruncatable # @return [String] attr_reader :url # @return [String] attr_reader :source # @return [Integer, nil] attr_reader :status # @return [Integer, nil] attr_reader :content_length # ...
github
ninoseki/miteru
https://github.com/ninoseki/miteru
lib/miteru/errors.rb
Ruby
mit
222
master
636
# frozen_string_literal: true require "http" module Miteru class Error < StandardError; end class FileSizeError < Error; end class DownloadError < Error; end class UniquenessError < Error; end class StatusError < ::HTTP::Error # @return [Integer] attr_reader :status_code # @return [String, ...
github
ninoseki/miteru
https://github.com/ninoseki/miteru
lib/miteru/record.rb
Ruby
mit
222
master
976
# frozen_string_literal: true module Miteru class Record < ActiveRecord::Base class << self # # @param [String] sha256 # # @return [Boolean] true if it is unique. Otherwise false. # def unique_sha256?(sha256) !where(sha256:).exists? end # # Create a ...
github
ninoseki/miteru
https://github.com/ninoseki/miteru
lib/miteru/sidekiq/jobs.rb
Ruby
mit
222
master
785
# frozen_string_literal: true require "sidekiq" require "timeout" module Miteru module Jobs class CrawleJob include Sidekiq::Job include Concerns::DatabaseConnectable # # @param [String] url # @param [String] source # def perform(url, source) website = Miteru::...
github
ninoseki/miteru
https://github.com/ninoseki/miteru
lib/miteru/sidekiq/application.rb
Ruby
mit
222
master
392
# frozen_string_literal: true require "sidekiq" require "miteru/sidekiq/jobs" Sidekiq.configure_server do |config| config.redis = {url: Miteru.config.sidekiq_redis_url.to_s} config.default_job_options = { retry: Miteru.config.sidekiq_job_retry, expires_in: 0.second } end Sidekiq.configure_client do |c...
github
ninoseki/miteru
https://github.com/ninoseki/miteru
lib/miteru/web/application.rb
Ruby
mit
222
master
860
# frozen_string_literal: true # Rack require "rack" require "rack/session" require "rackup" require "rack/handler/puma" # Sidekiq require "sidekiq/web" module Miteru module Web class App class << self def instance Rack::Builder.new do use Rack::Session::Cookie, secret: Secu...
github
ninoseki/miteru
https://github.com/ninoseki/miteru
lib/miteru/feeds/tweetfeed.rb
Ruby
mit
222
master
306
# frozen_string_literal: true module Miteru class Feeds class TweetFeed < Base def initialize(base_url = "https://api.tweetfeed.live") super end def urls data = get_json("/v1/today/url") data.filter_map { |item| item["value"] } end end end end
github
ninoseki/miteru
https://github.com/ninoseki/miteru
lib/miteru/feeds/urlscan.rb
Ruby
mit
222
master
1,412
# frozen_string_literal: true module Miteru class Feeds class UrlScan < Base # # @param [String] base_url # def initialize(base_url = "https://urlscan.io") super @headers = {"api-key": api_key} end def urls search_with_pagination.flat_map do |json| ...
github
ninoseki/miteru
https://github.com/ninoseki/miteru
lib/miteru/feeds/phishing_database.rb
Ruby
mit
222
master
399
# frozen_string_literal: true module Miteru class Feeds class PhishingDatabase < Base def initialize(base_url = "https://raw.githubusercontent.com") super end def urls text.lines.map(&:chomp) end private def text get("/mitchellkrogza/Phishing.Databas...
github
ninoseki/miteru
https://github.com/ninoseki/miteru
lib/miteru/feeds/base.rb
Ruby
mit
222
master
2,943
# frozen_string_literal: true module Miteru class Feeds class Base < Service IGNORE_EXTENSIONS = %w[.htm .html .php .asp .aspx .exe .txt].freeze # @return [String] attr_reader :base_url # @return [Hash] attr_reader :headers # # @param [String] base_url # d...
github
ninoseki/miteru
https://github.com/ninoseki/miteru
lib/miteru/feeds/ayashige.rb
Ruby
mit
222
master
370
# frozen_string_literal: true module Miteru class Feeds class Ayashige < Base def initialize(base_url = "https://ayashige.herokuapp.com") super end def urls json.map { |item| item["fqdn"] }.map { |fqdn| "https://#{fqdn}" } end private def json get_js...
github
ninoseki/miteru
https://github.com/ninoseki/miteru
lib/miteru/feeds/urlscan_pro.rb
Ruby
mit
222
master
1,072
# frozen_string_literal: true module Miteru class Feeds class UrlScanPro < Base # # @param [String] base_url # def initialize(base_url = "https://urlscan.io") super @headers = {"api-key": api_key} end def urls iterate.flat_map do |res| (res[...
github
ninoseki/miteru
https://github.com/ninoseki/miteru
lib/miteru/notifiers/urlscan.rb
Ruby
mit
222
master
1,003
# frozen_string_literal: true module Miteru module Notifiers class UrlScan < Base # # @param [Miteru::Kit] kit # def call(kit) return unless callable? submit(kit.decoded_url, source: kit.source) end def callable? !Miteru.config.urlscan_api_key.nil? ...
github
ninoseki/miteru
https://github.com/ninoseki/miteru
lib/miteru/notifiers/slack.rb
Ruby
mit
222
master
1,913
# frozen_string_literal: true require "slack-notifier" module Miteru module Notifiers class SlackAttachment # @return [String] attr_reader :url def initialize(url) @url = url end def to_a [ { text:, fallback: "VT & urlscan.io link...
github
ninoseki/miteru
https://github.com/ninoseki/miteru
lib/miteru/notifiers/base.rb
Ruby
mit
222
master
437
# frozen_string_literal: true module Miteru module Notifiers class Base < Service def call(kit) raise NotImplementedError end def callable? raise NotImplementedError end def name @name ||= self.class.to_s.split("::").last end class << self ...
github
ninoseki/miteru
https://github.com/ninoseki/miteru
lib/miteru/cli/application.rb
Ruby
mit
222
master
490
# frozen_string_literal: true require "thor" require "thor/hollaback" require "miteru/cli/base" require "miteru/cli/database" require "miteru/commands/main" require "miteru/commands/sidekiq" require "miteru/commands/web" module Miteru module CLI # # Main CLI class # class App < Base include ...
github
ninoseki/miteru
https://github.com/ninoseki/miteru
lib/miteru/cli/base.rb
Ruby
mit
222
master
230
# frozen_string_literal: true module Miteru module CLI # # Base class for Thor classes # class Base < Thor class << self def exit_on_failure? true end end end end end
github
ninoseki/miteru
https://github.com/ninoseki/miteru
lib/miteru/commands/web.rb
Ruby
mit
222
master
1,293
# frozen_string_literal: true module Miteru module Commands # # Web sub-commands # module Web class << self def included(thor) thor.class_eval do desc "web", "Start the web app" method_option :port, type: :numeric, default: 9292, desc: "Port to listen o...
github
ninoseki/miteru
https://github.com/ninoseki/miteru
lib/miteru/commands/main.rb
Ruby
mit
222
master
1,242
# frozen_string_literal: true module Miteru module Commands module Main class << self def included(thor) thor.class_eval do include Concerns::DatabaseConnectable method_option :auto_download, type: :boolean, default: false, desc: "Enable or disable a...
github
ninoseki/miteru
https://github.com/ninoseki/miteru
lib/miteru/commands/sidekiq.rb
Ruby
mit
222
master
962
# frozen_string_literal: true module Miteru module Commands # # Sidekiq sub-commands # module Sidekiq class << self def included(thor) thor.class_eval do desc "sidekiq", "Start Sidekiq" method_option :env, type: :string, default: "production", desc: "En...
github
ninoseki/miteru
https://github.com/ninoseki/miteru
lib/miteru/commands/database.rb
Ruby
mit
222
master
599
# frozen_string_literal: true module Miteru module Commands module Database class << self def included(thor) thor.class_eval do include Concerns::DatabaseConnectable desc "migrate", "Migrate DB schemas" around :with_db_connection method_opt...
github
ninoseki/miteru
https://github.com/ninoseki/miteru
lib/miteru/concerns/url_truncatable.rb
Ruby
mit
222
master
480
# frozen_string_literal: true module Miteru module Concerns module UrlTruncatable extend ActiveSupport::Concern def decoded_url @decoded_url ||= URI.decode_www_form_component(url) end # # @return [String] # def truncated_url @truncated_url ||= decoded_u...
github
ninoseki/miteru
https://github.com/ninoseki/miteru
lib/miteru/concerns/database_connectable.rb
Ruby
mit
222
master
287
# frozen_string_literal: true module Miteru module Concerns # # Database connectable concern # module DatabaseConnectable extend ActiveSupport::Concern def with_db_connection(&block) Database.with_db_connection(&block) end end end end
github
ninoseki/miteru
https://github.com/ninoseki/miteru
lib/miteru/concerns/error_unwrappable.rb
Ruby
mit
222
master
732
# frozen_string_literal: true module Miteru module Concerns # # Error unwrappable concern # module ErrorUnwrappable extend ActiveSupport::Concern def unwrap_error(err) return err unless err.is_a?(Dry::Monads::UnwrapError) # NOTE: UnwrapError's receiver can be either of: ...
github
bdurand/seamless_database_pool
https://github.com/bdurand/seamless_database_pool
seamless_database_pool.gemspec
Ruby
mit
222
master
1,139
Gem::Specification.new do |spec| spec.name = "seamless_database_pool" spec.version = File.read(File.expand_path("../VERSION", __FILE__)).chomp spec.authors = ["Brian Durand"] spec.email = ["bbdurand@gmail.com"] spec.description = %q{Add support for master/slave database database...
github
bdurand/seamless_database_pool
https://github.com/bdurand/seamless_database_pool
Rakefile
Ruby
mit
222
master
1,840
require 'rubygems' require 'rake' require 'yaml' require "bundler/gem_tasks" desc 'Default: run unit tests.' task :default => :test begin require 'rspec' require 'rspec/core/rake_task' desc 'Run the unit tests' RSpec::Core::RakeTask.new(:test) namespace :test do desc "Run all tests including for all ...
github
bdurand/seamless_database_pool
https://github.com/bdurand/seamless_database_pool
spec/seamless_database_pool_adapter_spec.rb
Ruby
mit
222
master
18,981
require 'spec_helper' module SeamlessDatabasePool class MockConnection < ActiveRecord::ConnectionAdapters::AbstractAdapter def initialize (name) @name = name end def inspect "#{@name} connection" end def reconnect! sleep(0.1) end def active? true ...
github
bdurand/seamless_database_pool
https://github.com/bdurand/seamless_database_pool
spec/seamless_database_pool_spec.rb
Ruby
mit
222
master
7,857
require 'spec_helper' describe "SeamlessDatabasePool" do before(:each) do SeamlessDatabasePool.clear_read_only_connection end after(:each) do SeamlessDatabasePool.clear_read_only_connection end it "should use the master connection by default" do connection = double(:connection, :master_con...
github
bdurand/seamless_database_pool
https://github.com/bdurand/seamless_database_pool
spec/connection_adapters_spec.rb
Ruby
mit
222
master
10,383
require 'spec_helper' require 'active_record/connection_adapters/read_only_adapter' describe "Test connection adapters" do if SeamlessDatabasePool::TestModel.database_configs.empty? puts "No adapters specified for testing. Specify the adapters with TEST_ADAPTERS variable" else SeamlessDatabasePool::TestMod...
github
bdurand/seamless_database_pool
https://github.com/bdurand/seamless_database_pool
spec/controller_filter_spec.rb
Ruby
mit
222
master
4,150
require 'spec_helper' describe "SeamlessDatabasePool::ControllerFilter" do module SeamlessDatabasePool class TestApplicationController attr_reader :session def initialize(session) @session = session end def process(action, *args) send action end def redirec...
github
bdurand/seamless_database_pool
https://github.com/bdurand/seamless_database_pool
spec/spec_helper.rb
Ruby
mit
222
master
1,075
require 'rubygems' active_record_version = ENV["ACTIVE_RECORD_VERSION"] || [">= 2.2.2"] active_record_version = [active_record_version] unless active_record_version.is_a?(Array) gem 'activerecord', *active_record_version require 'active_record' puts "Testing Against ActiveRecord #{ActiveRecord::VERSION::STRING}" if d...
github
bdurand/seamless_database_pool
https://github.com/bdurand/seamless_database_pool
spec/test_model.rb
Ruby
mit
222
master
1,844
module SeamlessDatabasePool class TestModel < ActiveRecord::Base self.abstract_class = true class << self def database_configs adapters = ENV['TEST_ADAPTERS'].blank? ? [] : ENV['TEST_ADAPTERS'].split(/\s+/) configs = {} YAML.load_file(File.expand_path("../database.yml", __FI...
github
bdurand/seamless_database_pool
https://github.com/bdurand/seamless_database_pool
spec/connection_statistics_spec.rb
Ruby
mit
222
master
2,685
require 'spec_helper' describe SeamlessDatabasePool::ConnectionStatistics do module SeamlessDatabasePool class ConnectionStatisticsTester def insert (sql, name = nil) "INSERT #{sql}/#{name}" end def update (sql, name = nil) execute(sql) "UPDATE #{sql}/#{name}" end...
github
bdurand/seamless_database_pool
https://github.com/bdurand/seamless_database_pool
spec/test_adapter/active_record/connection_adapters/read_only_adapter.rb
Ruby
mit
222
master
1,746
module ActiveRecord class Base def self.read_only_connection(config) real_adapter = config.delete("real_adapter") connection = send("#{real_adapter}_connection", config.merge("adapter" => real_adapter)) ConnectionAdapters::ReadOnlyAdapter.new(connection) end end module ConnectionAdapt...
github
bdurand/seamless_database_pool
https://github.com/bdurand/seamless_database_pool
lib/seamless_database_pool.rb
Ruby
mit
222
master
6,903
require File.join(File.dirname(__FILE__), 'seamless_database_pool', 'connection_statistics.rb') require File.join(File.dirname(__FILE__), 'seamless_database_pool', 'controller_filter.rb') require File.join(File.dirname(__FILE__), 'active_record', 'connection_adapters', 'seamless_database_pool_adapter.rb') require File....
github
bdurand/seamless_database_pool
https://github.com/bdurand/seamless_database_pool
lib/seamless_database_pool/arel_compiler.rb
Ruby
mit
222
master
1,089
module Arel module SqlCompiler # Hook into arel to use the compiler used by the master connection. class Seamless_Database_PoolCompiler < GenericCompiler def self.new(relation) @compiler_classes ||= {} master_adapter = relation.engine.connection.master_connection.adapter_name com...
github
bdurand/seamless_database_pool
https://github.com/bdurand/seamless_database_pool
lib/seamless_database_pool/connection_statistics.rb
Ruby
mit
222
master
1,356
module SeamlessDatabasePool # This module is included for testing. Mix it into each of your database pool connections # and it will keep track of how often each connection calls update, insert, execute, # or select. module ConnectionStatistics # Get the connection statistics def connection_statistics ...
github
bdurand/seamless_database_pool
https://github.com/bdurand/seamless_database_pool
lib/seamless_database_pool/railtie.rb
Ruby
mit
222
master
525
module SeamlessDatabasePool class Railtie < ::Rails::Railtie rake_tasks do namespace :db do task :load_config do # Override seamless_database_pool configuration so db:* rake tasks work as expected. module DatabaseConfiguration def configurations Seamless...
github
bdurand/seamless_database_pool
https://github.com/bdurand/seamless_database_pool
lib/seamless_database_pool/controller_filter.rb
Ruby
mit
222
master
4,750
module SeamlessDatabasePool # This module provides a simple method of declaring which read pool connection type should # be used for various ActionController actions. To use it, you must first mix it into # you controller and then call use_database_pool to configure the connection types. Generally # you should ...
github
bdurand/seamless_database_pool
https://github.com/bdurand/seamless_database_pool
lib/active_record/connection_adapters/seamless_database_pool_adapter.rb
Ruby
mit
222
master
14,625
module ActiveRecord class Base class << self def seamless_database_pool_connection(config) pool_weights = {} config = config.with_indifferent_access default_config = {:pool_weight => 1}.merge(config.merge(:adapter => config[:pool_adapter])).with_indifferent_access default_co...
github
twe4ked/rspec-nc
https://github.com/twe4ked/rspec-nc
Rakefile
Ruby
mit
221
master
264
#!/usr/bin/env rake require 'bundler/gem_tasks' require 'rspec/core/rake_task' RSpec::Core::RakeTask.new(:spec) do |t| t.rspec_opts = "--format=#{ENV['FORMATTER']}" if ENV['FORMATTER'] t.rspec_opts = '--color' t.verbose = false end task :default => :spec
github
twe4ked/rspec-nc
https://github.com/twe4ked/rspec-nc
rspec-nc.gemspec
Ruby
mit
221
master
677
# -*- encoding: utf-8 -*- Gem::Specification.new do |gem| gem.name = 'rspec-nc' gem.version = '0.3.0' gem.authors = ['Odin Dutton'] gem.email = ['odindutton@gmail.com'] gem.description = 'https://github.com/twe4ked/rspec-nc' gem.summary = "RSpec formatter for Mountain Lion's Notification Center" gem.homep...
github
twe4ked/rspec-nc
https://github.com/twe4ked/rspec-nc
lib/nc.rb
Ruby
mit
221
master
800
require 'rspec/core/formatters/base_formatter' require 'terminal-notifier' class Nc < RSpec::Core::Formatters::BaseFormatter SUCCESS_EMOJI = "\u2705" FAILURE_EMOJI = "\u26D4" RSpec::Core::Formatters.register self, :dump_summary def dump_summary(notification) body = "Finished in #{notification.formatted_d...
github
twe4ked/rspec-nc
https://github.com/twe4ked/rspec-nc
lib/nc_first_fail.rb
Ruby
mit
221
master
477
require 'nc' class NcFirstFail < Nc RSpec::Core::Formatters.register self, :example_failed def example_failed(notification) example = notification.example body = "#{example.metadata[:full_description]}\n#{example.exception}" title = "#{FAILURE_EMOJI} #{directory_name}: Failure" unless @failed ...
github
twe4ked/rspec-nc
https://github.com/twe4ked/rspec-nc
spec/nc_spec.rb
Ruby
mit
221
master
1,335
require 'nc' RSpec.describe Nc do let(:formatter) { Nc.new(StringIO.new) } let(:current_dir) { File.basename(File.expand_path '.') } context 'with failing examples' do let(:notification) do instance_double(RSpec::Core::Notifications::SummaryNotification, formatted_duration: '0.0001 seconds', ...
github
twe4ked/rspec-nc
https://github.com/twe4ked/rspec-nc
spec/nc_first_fail_spec.rb
Ruby
mit
221
master
1,395
require 'nc_first_fail' describe NcFirstFail do let(:formatter) { NcFirstFail.new(StringIO.new) } let(:current_dir) { File.basename(File.expand_path '.') } let(:failure_count) { 1 } let(:summary_notification) do instance_double(RSpec::Core::Notifications::SummaryNotification, formatted_duration: '0.0...
github
twe4ked/rspec-nc
https://github.com/twe4ked/rspec-nc
spec/test.rb
Ruby
mit
221
master
350
# This test isn't part of the actual suite it's to manually test the formatters. require 'nc' RSpec.describe 'to test the gem' do it 'passes' do expect(0).to eq 0 end it 'fails' do expect(1).to eq 2 end it 'fails again' do expect(3).to eq 4 end it 'pending' do pending 'for a reason' ...
github
twe4ked/rspec-nc
https://github.com/twe4ked/rspec-nc
spec/nc_fail_spec.rb
Ruby
mit
221
master
743
require 'nc_fail' describe NcFail do let(:formatter) { NcFail.new(StringIO.new) } let(:notification) do instance_double(RSpec::Core::Notifications::SummaryNotification, formatted_duration: double, totals_line: double, failure_count: failure_count, ) end context 'with failing examples...
github
robbyrussell/rubyurl
https://github.com/robbyrussell/rubyurl
config/deploy.rb
Ruby
mit
221
main
1,349
# Required for using Mongrel with Capistrano2 # gem install palmtree require 'palmtree/recipes/mongrel_cluster' ######################################################################## # Rails Boxcar - Capistrano Deployment Recipe # Configuration #####################################################################...
github
robbyrussell/rubyurl
https://github.com/robbyrussell/rubyurl
config/environment.rb
Ruby
mit
221
main
2,574
# Be sure to restart your web server when you modify this file. # Uncomment below to force Rails into production mode when # you don't control web/app server and can't set it the proper way # ENV['RAILS_ENV'] ||= 'production' # Specifies gem version of Rails to use when vendor/rails is not present RAILS_GEM_VERSION ...
github
robbyrussell/rubyurl
https://github.com/robbyrussell/rubyurl
config/routes.rb
Ruby
mit
221
main
1,380
ActionController::Routing::Routes.draw do |map| # The priority is based upon order of creation: first created -> highest priority. # Sample of regular route: # map.connect 'products/:id', :controller => 'catalog', :action => 'view' # Keep in mind you can assign values other than :controller and :action # ...
github
robbyrussell/rubyurl
https://github.com/robbyrussell/rubyurl
config/environments/production.rb
Ruby
mit
221
main
799
# Settings specified here will take precedence over those in config/environment.rb # The production environment is meant for finished, "live" apps. # Code is not reloaded between requests config.cache_classes = true # Use a different logger for distributed setups # config.logger = SyslogLogger.new # Full error repor...
github
robbyrussell/rubyurl
https://github.com/robbyrussell/rubyurl
config/environments/test.rb
Ruby
mit
221
main
890
# Settings specified here will take precedence over those in config/environment.rb # The test environment is used exclusively to run your application's # test suite. You never need to work with it otherwise. Remember that # your test database is "scratch space" for the test suite and is wiped # and recreated between...
github
robbyrussell/rubyurl
https://github.com/robbyrussell/rubyurl
config/environments/development.rb
Ruby
mit
221
main
848
# Settings specified here will take precedence over those in config/environment.rb # In the development environment your application's code is reloaded on # every request. This slows down response time but is perfect for development # since you don't have to restart the webserver when you make code changes. config.ca...
github
robbyrussell/rubyurl
https://github.com/robbyrussell/rubyurl
app/helpers/application_helper.rb
Ruby
mit
221
main
1,017
# Methods added to this helper will be available to all templates in the application. module ApplicationHelper def clippy(text, bgcolor='#FFFFFF') html = <<-EOF <object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="80" height="60" id="clippy" > <...
github
robbyrussell/rubyurl
https://github.com/robbyrussell/rubyurl
app/controllers/application.rb
Ruby
mit
221
main
492
# Filters added to this controller apply to all controllers in the application. # Likewise, all the methods added will be available for all controllers. class ApplicationController < ActionController::Base # Pick a unique cookie name to distinguish our session data from others' session :session_key => '_rubyurl_2....
github
robbyrussell/rubyurl
https://github.com/robbyrussell/rubyurl
app/controllers/links_controller.rb
Ruby
mit
221
main
894
class LinksController < ApplicationController def index redirect_to '/home' end def home @link = Link.new render :action => 'index' end def create website_url = params.include?(:website_url) ? params[:website_url] : params[:link][:website_url] @link = Link.find_or_create_by_website_...
github
robbyrussell/rubyurl
https://github.com/robbyrussell/rubyurl
app/controllers/api/links_controller.rb
Ruby
mit
221
main
779
class Api::LinksController < Api::BaseController def create if params[:website_url].blank? website_url = params[:link][:website_url] else website_url = params[:website_url] end @link = Link.find_or_create_by_website_url( website_url ) @link.ip_address = request.remote_ip if @link.n...
github
robbyrussell/rubyurl
https://github.com/robbyrussell/rubyurl
app/models/link.rb
Ruby
mit
221
main
1,918
require 'domainatrix' class Link < ActiveRecord::Base TOKEN_LENGTH = 4 has_many :visits has_many :spam_visits, :class_name => 'Visit', :conditions => ["flagged = 'spam'"] validates_presence_of :website_url, :ip_address validates_uniqueness_of :website_url, :token validates_format_of :website_url, :with =...
github
robbyrussell/rubyurl
https://github.com/robbyrussell/rubyurl
spec/spec_helper.rb
Ruby
mit
221
main
1,741
# This file is copied to ~/spec when you run 'ruby script/generate rspec' # from the project root directory. ENV["RAILS_ENV"] = "test" require File.expand_path(File.dirname(__FILE__) + "/../config/environment") require 'spec' require 'spec/rails' Spec::Runner.configure do |config| # If you're not using ActiveRecord ...
github
robbyrussell/rubyurl
https://github.com/robbyrussell/rubyurl
spec/views/links/index_view_spec.rb
Ruby
mit
221
main
1,094
require File.dirname(__FILE__) + '/../../spec_helper' describe "links/index" do before(:each) do render 'links/index' end it "should display Create a RubyURL in a h1 tag" do response.should have_tag('label', 'Create a RubyURL') end it "should display a text input field for the user to paste their u...
github
robbyrussell/rubyurl
https://github.com/robbyrussell/rubyurl
spec/controllers/links_controller_spec.rb
Ruby
mit
221
main
1,958
require File.dirname(__FILE__) + '/../spec_helper' describe LinksController, "index action" do controller_name :links it "should redirect to the home action" do get :index response.should redirect_to( :action => 'home' ) end end describe LinksController, "home action" do controller_name :links ...