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
flyerhzm/rails_best_practices
https://github.com/flyerhzm/rails_best_practices
spec/rails_best_practices/reviews/remove_unused_methods_in_models_review_spec.rb
Ruby
mit
4,169
main
24,512
# frozen_string_literal: true require 'spec_helper' module RailsBestPractices module Reviews describe RemoveUnusedMethodsInModelsReview do let(:runner) do Core::Runner.new( prepares: Prepares::ModelPrepare.new, reviews: described_class.new('except_methods' => ['*#set_cache']) ) ...
github
flyerhzm/rails_best_practices
https://github.com/flyerhzm/rails_best_practices
spec/rails_best_practices/reviews/not_use_default_route_review_spec.rb
Ruby
mit
4,169
main
1,395
# frozen_string_literal: true require 'spec_helper' module RailsBestPractices module Reviews describe NotUseDefaultRouteReview do let(:runner) { Core::Runner.new(reviews: described_class.new) } it 'does not use default route' do content = <<-EOF RailsBestpracticesCom::Application.ro...
github
flyerhzm/rails_best_practices
https://github.com/flyerhzm/rails_best_practices
spec/rails_best_practices/reviews/always_add_db_index_review_spec.rb
Ruby
mit
4,169
main
11,935
# frozen_string_literal: true require 'spec_helper' module RailsBestPractices module Reviews describe AlwaysAddDbIndexReview do let(:runner) { Core::Runner.new(reviews: described_class.new) } it 'alwayses add db index' do content = <<-EOF ActiveRecord::Schema.define(version: 2010060...
github
flyerhzm/rails_best_practices
https://github.com/flyerhzm/rails_best_practices
spec/rails_best_practices/lexicals/remove_trailing_whitespace_check_spec.rb
Ruby
mit
4,169
main
1,744
# frozen_string_literal: true require 'spec_helper' module RailsBestPractices module Lexicals describe RemoveTrailingWhitespaceCheck do let(:runner) { Core::Runner.new(lexicals: described_class.new) } it 'removes trailing whitespace' do content = <<-EOF class User < ActiveRecord::Ba...
github
flyerhzm/rails_best_practices
https://github.com/flyerhzm/rails_best_practices
spec/rails_best_practices/lexicals/remove_tab_check_spec.rb
Ruby
mit
4,169
main
1,677
# frozen_string_literal: true require 'spec_helper' module RailsBestPractices module Lexicals describe RemoveTabCheck do let(:runner) { Core::Runner.new(lexicals: described_class.new) } it 'removes tab' do content = <<-EOF class User < ActiveRecord::Base has_many :projects...
github
flyerhzm/rails_best_practices
https://github.com/flyerhzm/rails_best_practices
spec/rails_best_practices/lexicals/long_line_check_spec.rb
Ruby
mit
4,169
main
2,455
# frozen_string_literal: true require 'spec_helper' module RailsBestPractices module Lexicals describe LongLineCheck do it 'finds long lines' do runner = Core::Runner.new(lexicals: described_class.new) content = <<~EOF class User < ActiveRecord::Base # 81 Chars ...
github
flyerhzm/rails_best_practices
https://github.com/flyerhzm/rails_best_practices
spec/rails_best_practices/prepares/helper_prepare_spec.rb
Ruby
mit
4,169
main
1,334
# frozen_string_literal: true require 'spec_helper' module RailsBestPractices module Prepares describe HelperPrepare do let(:runner) { Core::Runner.new(prepares: described_class.new) } context 'methods' do it 'parses helper methods' do content = <<-EOF module PostsHelper...
github
flyerhzm/rails_best_practices
https://github.com/flyerhzm/rails_best_practices
spec/rails_best_practices/prepares/route_prepare_spec.rb
Ruby
mit
4,169
main
19,163
# frozen_string_literal: true require 'spec_helper' module RailsBestPractices module Prepares describe RoutePrepare do let(:runner) { Core::Runner.new(prepares: described_class.new) } context 'resources' do it 'adds resources route' do content = <<-EOF RailsBestPractices...
github
flyerhzm/rails_best_practices
https://github.com/flyerhzm/rails_best_practices
spec/rails_best_practices/prepares/config_prepare_spec.rb
Ruby
mit
4,169
main
703
# frozen_string_literal: true require 'spec_helper' module RailsBestPractices module Prepares describe ConfigPrepare do let(:runner) { Core::Runner.new(prepares: described_class.new) } context 'configs' do it 'parses configs' do content = <<-EOF module RailsBestPractices...
github
flyerhzm/rails_best_practices
https://github.com/flyerhzm/rails_best_practices
spec/rails_best_practices/prepares/model_prepare_spec.rb
Ruby
mit
4,169
main
16,148
# frozen_string_literal: true require 'spec_helper' module RailsBestPractices module Prepares describe ModelPrepare do let(:runner) { Core::Runner.new(prepares: described_class.new) } context 'models' do it 'class_name with modules ::' do content = <<-EOF class Blog::Pos...
github
flyerhzm/rails_best_practices
https://github.com/flyerhzm/rails_best_practices
spec/rails_best_practices/prepares/initializer_prepare_spec.rb
Ruby
mit
4,169
main
1,050
# frozen_string_literal: true require 'spec_helper' module RailsBestPractices module Prepares describe InitializerPrepare do let(:runner) { Core::Runner.new(prepares: described_class.new) } context 'initializers' do it 'sets include_forbidden_attributes_protection config' do conte...
github
flyerhzm/rails_best_practices
https://github.com/flyerhzm/rails_best_practices
spec/rails_best_practices/prepares/schema_prepare_spec.rb
Ruby
mit
4,169
main
1,395
# frozen_string_literal: true require 'spec_helper' module RailsBestPractices module Prepares describe SchemaPrepare do let(:runner) { Core::Runner.new(prepares: described_class.new) } it 'parses model attributes' do content = <<-EOF ActiveRecord::Schema.define(version: 201103191721...
github
flyerhzm/rails_best_practices
https://github.com/flyerhzm/rails_best_practices
spec/rails_best_practices/prepares/gemfile_prepare_spec.rb
Ruby
mit
4,169
main
972
# frozen_string_literal: true require 'spec_helper' module RailsBestPractices module Prepares describe GemfilePrepare do let(:runner) { Core::Runner.new(prepares: described_class.new) } context 'gemfile' do it 'parses gems' do content = <<~EOF GEM remote:...
github
flyerhzm/rails_best_practices
https://github.com/flyerhzm/rails_best_practices
spec/rails_best_practices/prepares/mailer_prepare_spec.rb
Ruby
mit
4,169
main
495
# frozen_string_literal: true require 'spec_helper' module RailsBestPractices module Prepares describe MailerPrepare do let(:runner) { Core::Runner.new(prepares: described_class.new) } it 'parses mailer names' do content = <<-EOF class ProjectMailer < ActionMailer::Base end ...
github
flyerhzm/rails_best_practices
https://github.com/flyerhzm/rails_best_practices
spec/rails_best_practices/prepares/controller_prepare_spec.rb
Ruby
mit
4,169
main
5,693
# frozen_string_literal: true require 'spec_helper' module RailsBestPractices module Prepares describe ControllerPrepare do let(:runner) { Core::Runner.new(prepares: [described_class.new, HelperPrepare.new]) } context 'methods' do it 'parses controller methods' do content = <<-EOF...
github
zdennis/activerecord-import
https://github.com/zdennis/activerecord-import
Rakefile
Ruby
mit
4,139
master
1,715
# frozen_string_literal: true require "bundler" Bundler.setup require 'rake' require 'rake/testtask' namespace :display do task :notice do puts puts "To run tests you must supply the adapter, see rake -T for more information." puts end end task default: ["display:notice"] ADAPTERS = %w( mysql2 m...
github
zdennis/activerecord-import
https://github.com/zdennis/activerecord-import
activerecord-import.gemspec
Ruby
mit
4,139
master
952
# frozen_string_literal: true require File.expand_path('../lib/activerecord-import/version', __FILE__) Gem::Specification.new do |gem| gem.authors = ["Zach Dennis"] gem.email = ["zach.dennis@gmail.com"] gem.summary = "Bulk insert extension for ActiveRecord" gem.description = "A library f...
github
zdennis/activerecord-import
https://github.com/zdennis/activerecord-import
Gemfile
Ruby
mit
4,139
master
1,986
# frozen_string_literal: true source 'https://rubygems.org' gemspec version = ENV['AR_VERSION'].to_f mysql2_version = '0.4.0' mysql2_version = '0.5.0' if version >= 6.1 mysql2_version = '0.5.6' if version >= 8.0 sqlite3_version = '1.3.0' sqlite3_version = '1.4.0' if version >= 6.0 sqlite3_version = '2.2.0' if versi...
github
zdennis/activerecord-import
https://github.com/zdennis/activerecord-import
test/synchronize_test.rb
Ruby
mit
4,139
master
1,977
# frozen_string_literal: true require File.expand_path('../test_helper', __FILE__) describe ".synchronize" do let(:topics) { Generate(3, :topics) } let(:titles) { %w(one two three) } setup do # update records outside of ActiveRecord knowing about it Topic.connection_pool.with_connection do |conn| ...
github
zdennis/activerecord-import
https://github.com/zdennis/activerecord-import
test/value_sets_records_parser_test.rb
Ruby
mit
4,139
master
1,146
# frozen_string_literal: true require File.expand_path("#{File.dirname(__FILE__)}/test_helper") require 'activerecord-import/value_sets_parser' describe "ActiveRecord::Import::ValueSetsRecordsParser" do context "#parse - computing insert value sets" do let(:parser) { ActiveRecord::Import::ValueSetsRecordsParse...
github
zdennis/activerecord-import
https://github.com/zdennis/activerecord-import
test/import_test.rb
Ruby
mit
4,139
master
34,763
# frozen_string_literal: true require File.expand_path('../test_helper', __FILE__) describe "#import" do it "should return the number of inserts performed" do # see ActiveRecord::ConnectionAdapters::AbstractAdapter test for more specifics assert_difference "Topic.count", +10 do result = Topic.import B...
github
zdennis/activerecord-import
https://github.com/zdennis/activerecord-import
test/test_helper.rb
Ruby
mit
4,139
master
2,566
# frozen_string_literal: true require 'pathname' require 'rake' require 'logger' test_dir = Pathname.new File.dirname(__FILE__) $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib')) $LOAD_PATH.unshift(File.dirname(__FILE__)) require "fileutils" ENV["RAILS_ENV"] = "test" require "bundler" Bundler.setup...
github
zdennis/activerecord-import
https://github.com/zdennis/activerecord-import
test/value_sets_bytes_parser_test.rb
Ruby
mit
4,139
master
4,153
# frozen_string_literal: true require File.expand_path("#{File.dirname(__FILE__)}/test_helper") require 'activerecord-import/value_sets_parser' describe ActiveRecord::Import::ValueSetsBytesParser do context "#parse - computing insert value sets" do let(:parser) { ActiveRecord::Import::ValueSetsBytesParser } ...
github
zdennis/activerecord-import
https://github.com/zdennis/activerecord-import
test/makara_postgis/import_test.rb
Ruby
mit
4,139
master
385
# frozen_string_literal: true require File.expand_path("#{File.dirname(__FILE__)}/../test_helper") require File.expand_path("#{File.dirname(__FILE__)}/../support/postgresql/import_examples") should_support_postgresql_import_functionality if ActiveRecord::Base.connection_pool.with_connection(&:supports_on_duplicate_k...
github
zdennis/activerecord-import
https://github.com/zdennis/activerecord-import
test/jdbcsqlite3/import_test.rb
Ruby
mit
4,139
master
234
# frozen_string_literal: true require File.expand_path("#{File.dirname(__FILE__)}/../test_helper") require File.expand_path("#{File.dirname(__FILE__)}/../support/sqlite3/import_examples") should_support_sqlite3_import_functionality
github
zdennis/activerecord-import
https://github.com/zdennis/activerecord-import
test/jdbcmysql/import_test.rb
Ruby
mit
4,139
master
306
# frozen_string_literal: true require File.expand_path("#{File.dirname(__FILE__)}/../test_helper") require File.expand_path("#{File.dirname(__FILE__)}/../support/assertions") require File.expand_path("#{File.dirname(__FILE__)}/../support/mysql/import_examples") should_support_mysql_import_functionality
github
zdennis/activerecord-import
https://github.com/zdennis/activerecord-import
test/trilogy_proxy/import_test.rb
Ruby
mit
4,139
master
230
# frozen_string_literal: true require File.expand_path("#{File.dirname(__FILE__)}/../test_helper") require File.expand_path("#{File.dirname(__FILE__)}/../support/mysql/import_examples") should_support_mysql_import_functionality
github
zdennis/activerecord-import
https://github.com/zdennis/activerecord-import
test/postgresql_proxy/import_test.rb
Ruby
mit
4,139
master
240
# frozen_string_literal: true require File.expand_path("#{File.dirname(__FILE__)}/../test_helper") require File.expand_path("#{File.dirname(__FILE__)}/../support/postgresql/import_examples") should_support_postgresql_import_functionality
github
zdennis/activerecord-import
https://github.com/zdennis/activerecord-import
test/janus_mysql2/import_test.rb
Ruby
mit
4,139
master
307
# frozen_string_literal: true require File.expand_path("#{File.dirname(__FILE__)}/../test_helper") require File.expand_path("#{File.dirname(__FILE__)}/../support/assertions") require File.expand_path("#{File.dirname(__FILE__)}/../support/mysql/import_examples") should_support_mysql_import_functionality
github
zdennis/activerecord-import
https://github.com/zdennis/activerecord-import
test/adapters/trilogy.rb
Ruby
mit
4,139
master
248
# frozen_string_literal: true require 'logger' ENV["ARE_DB"] = "trilogy" if ENV['AR_VERSION'].to_f <= 7.0 require "activerecord-trilogy-adapter" require "trilogy_adapter/connection" ActiveRecord::Base.extend TrilogyAdapter::Connection end
github
zdennis/activerecord-import
https://github.com/zdennis/activerecord-import
test/support/factories.rb
Ruby
mit
4,139
master
1,539
# frozen_string_literal: true FactoryBot.define do sequence(:book_title) { |n| "Book #{n}" } sequence(:chapter_title) { |n| "Chapter #{n}" } sequence(:end_note) { |n| "Endnote #{n}" } factory :group do sequence(:order) { |n| "Order #{n}" } end factory :invalid_topic, class: "Topic" do sequence(:t...
github
zdennis/activerecord-import
https://github.com/zdennis/activerecord-import
test/support/generate.rb
Ruby
mit
4,139
master
913
# frozen_string_literal: true class ActiveSupport::TestCase def Build(*args) # rubocop:disable Naming/MethodName n = args.shift if args.first.is_a?(Numeric) factory = args.shift factory_bot_args = args.shift || {} if n [].tap do |collection| n.times.each { collection << FactoryBot.buil...
github
zdennis/activerecord-import
https://github.com/zdennis/activerecord-import
test/support/assertions.rb
Ruby
mit
4,139
master
2,863
# frozen_string_literal: true class ActiveSupport::TestCase module ImportAssertions def self.extended(klass) klass.instance_eval do assertion(:should_not_update_created_at_on_timestamp_columns) do Timecop.freeze Chronic.parse("5 minutes from now") do perform_import ...
github
zdennis/activerecord-import
https://github.com/zdennis/activerecord-import
test/support/postgresql/import_examples.rb
Ruby
mit
4,139
master
22,537
# frozen_string_literal: true def should_support_postgresql_import_functionality should_support_recursive_import if ActiveRecord::Base.connection_pool.with_connection(&:supports_on_duplicate_key_update?) should_support_postgresql_upsert_functionality end describe "#supports_imports?" do it "should su...
github
zdennis/activerecord-import
https://github.com/zdennis/activerecord-import
test/support/active_support/test_case_extensions.rb
Ruby
mit
4,139
master
1,811
# frozen_string_literal: true class ActiveSupport::TestCase include ActiveRecord::TestFixtures self.use_transactional_tests = true class << self def requires_active_record_version(version_string, &blk) return unless Gem::Dependency.new('', version_string).match?('', ActiveRecord::VERSION::STRING) ...
github
zdennis/activerecord-import
https://github.com/zdennis/activerecord-import
test/support/sqlite3/import_examples.rb
Ruby
mit
4,139
master
9,775
# frozen_string_literal: true def should_support_sqlite3_import_functionality if ActiveRecord::Base.connection_pool.with_connection(&:supports_on_duplicate_key_update?) should_support_sqlite_upsert_functionality end describe "#supports_imports?" do it "should support import" do assert ActiveRecord...
github
zdennis/activerecord-import
https://github.com/zdennis/activerecord-import
test/support/mysql/import_examples.rb
Ruby
mit
4,139
master
4,041
# frozen_string_literal: true def should_support_mysql_import_functionality # Forcefully disable strict mode for this session. ActiveRecord::Base.connection_pool.with_connection { |conn| conn.execute "set sql_mode='STRICT_ALL_TABLES'" } should_support_basic_on_duplicate_key_update should_support_on_duplicate_...
github
zdennis/activerecord-import
https://github.com/zdennis/activerecord-import
test/support/shared_examples/recursive_import.rb
Ruby
mit
4,139
master
12,106
# frozen_string_literal: true def should_support_recursive_import describe "importing objects with associations" do let(:new_topics) { Build(num_topics, :topic_with_book) } let(:new_topics_with_invalid_chapter) do chapter = new_topics.first.books.first.chapters.first chapter.title = nil new...
github
zdennis/activerecord-import
https://github.com/zdennis/activerecord-import
test/support/shared_examples/affected_rows.rb
Ruby
mit
4,139
master
2,353
# frozen_string_literal: true def should_support_affected_rows describe "#import" do extend ActiveSupport::TestCase::ImportAssertions context "with affected_rows tracking" do it "should return correct affected_rows count for basic import" do topics = Build(2, :topics) initial_count = ...
github
zdennis/activerecord-import
https://github.com/zdennis/activerecord-import
test/support/shared_examples/on_duplicate_key_update.rb
Ruby
mit
4,139
master
16,742
# frozen_string_literal: true def should_support_basic_on_duplicate_key_update describe "#import" do extend ActiveSupport::TestCase::ImportAssertions macro(:perform_import) { raise "supply your own #perform_import in a context below" } macro(:updated_topic) { Topic.find(@topic.id) } context "with l...
github
zdennis/activerecord-import
https://github.com/zdennis/activerecord-import
test/support/shared_examples/on_duplicate_key_ignore.rb
Ruby
mit
4,139
master
1,605
# frozen_string_literal: true def should_support_on_duplicate_key_ignore describe "#import" do extend ActiveSupport::TestCase::ImportAssertions let(:topic) { Topic.create!(title: "Book", author_name: "John Doe") } let(:topics) { [topic] } context "with :on_duplicate_key_ignore" do it "should s...
github
zdennis/activerecord-import
https://github.com/zdennis/activerecord-import
test/models/topic.rb
Ruby
mit
4,139
master
1,011
# frozen_string_literal: true class Topic < ActiveRecord::Base if ENV['AR_VERSION'].to_f >= 6.0 self.ignored_columns = [:priority] end alias_attribute :name, :title validates_presence_of :author_name validates :title, numericality: { only_integer: true }, on: :context_test validates :title, uniqueness...
github
zdennis/activerecord-import
https://github.com/zdennis/activerecord-import
test/models/vendor.rb
Ruby
mit
4,139
master
231
# frozen_string_literal: true class Vendor < ActiveRecord::Base store :preferences, accessors: [:color], coder: JSON store_accessor :data, :size store_accessor :config, :contact store_accessor :settings, :charge_code end
github
zdennis/activerecord-import
https://github.com/zdennis/activerecord-import
test/models/tag.rb
Ruby
mit
4,139
master
429
# frozen_string_literal: true class Tag < ActiveRecord::Base if ENV['AR_VERSION'].to_f <= 7.0 self.primary_keys = :tag_id, :publisher_id unless ENV["SKIP_COMPOSITE_PK"] else self.primary_key = [:tag_id, :publisher_id] unless ENV["SKIP_COMPOSITE_PK"] end self.primary_key = [:tag_id, :publisher_id] unles...
github
zdennis/activerecord-import
https://github.com/zdennis/activerecord-import
test/models/widget.rb
Ruby
mit
4,139
master
603
# frozen_string_literal: true class CustomCoder def load(value) if value.nil? {} else YAML.load(value) end end def dump(value) YAML.dump(value) end end class Widget < ActiveRecord::Base self.primary_key = :w_id default_scope -> { where(active: true) } if ENV['AR_VERSION']....
github
zdennis/activerecord-import
https://github.com/zdennis/activerecord-import
test/models/author.rb
Ruby
mit
4,139
master
320
# frozen_string_literal: true class Author < ActiveRecord::Base if ENV['AR_VERSION'].to_f >= 8.0 has_many :composite_books, foreign_key: [:id, :author_id], inverse_of: :author elsif ENV['AR_VERSION'].to_f >= 7.1 has_many :composite_books, query_constraints: [:id, :author_id], inverse_of: :author end end
github
zdennis/activerecord-import
https://github.com/zdennis/activerecord-import
test/models/composite_chapter.rb
Ruby
mit
4,139
master
485
# frozen_string_literal: true class CompositeChapter < ActiveRecord::Base if ENV['AR_VERSION'].to_f >= 8.0 belongs_to :composite_book, inverse_of: :composite_chapters, foreign_key: [:composite_book_id, :author_id] elsif ENV['AR_VERSION'].to_f >= 7.1 belongs_to :composite_boo...
github
zdennis/activerecord-import
https://github.com/zdennis/activerecord-import
test/models/book.rb
Ruby
mit
4,139
master
617
# frozen_string_literal: true class Book < ActiveRecord::Base belongs_to :topic, inverse_of: :books if ENV['AR_VERSION'].to_f <= 7.0 || ENV['AR_VERSION'].to_f >= 8.0 belongs_to :tag, foreign_key: [:tag_id, :parent_id] unless ENV["SKIP_COMPOSITE_PK"] else belongs_to :tag, query_constraints: [:tag_id, :par...
github
zdennis/activerecord-import
https://github.com/zdennis/activerecord-import
test/models/customer.rb
Ruby
mit
4,139
master
533
# frozen_string_literal: true class Customer < ActiveRecord::Base unless ENV["SKIP_COMPOSITE_PK"] if ENV['AR_VERSION'].to_f <= 7.0 || ENV['AR_VERSION'].to_f >= 8.0 has_many :orders, inverse_of: :customer, primary_key: %i(account_id id), foreign_key: %i(account_i...
github
zdennis/activerecord-import
https://github.com/zdennis/activerecord-import
test/models/composite_book.rb
Ruby
mit
4,139
master
586
# frozen_string_literal: true class CompositeBook < ActiveRecord::Base self.primary_key = %i[id author_id] belongs_to :author if ENV['AR_VERSION'].to_f <= 7.0 || ENV['AR_VERSION'].to_f >= 8.0 unless ENV["SKIP_COMPOSITE_PK"] has_many :composite_chapters, inverse_of: :composite_book, ...
github
zdennis/activerecord-import
https://github.com/zdennis/activerecord-import
test/models/animal.rb
Ruby
mit
4,139
master
202
# frozen_string_literal: true class Animal < ActiveRecord::Base after_initialize :validate_name_presence, if: :new_record? def validate_name_presence raise ArgumentError if name.nil? end end
github
zdennis/activerecord-import
https://github.com/zdennis/activerecord-import
test/models/tag_alias.rb
Ruby
mit
4,139
master
352
# frozen_string_literal: true class TagAlias < ActiveRecord::Base unless ENV["SKIP_COMPOSITE_PK"] if ENV['AR_VERSION'].to_f <= 7.0 || ENV['AR_VERSION'].to_f >= 8.0 belongs_to :tag, foreign_key: [:tag_id, :parent_id], required: true else belongs_to :tag, query_constraints: [:tag_id, :parent_id], r...
github
zdennis/activerecord-import
https://github.com/zdennis/activerecord-import
test/models/order.rb
Ruby
mit
4,139
master
545
# frozen_string_literal: true class Order < ActiveRecord::Base unless ENV["SKIP_COMPOSITE_PK"] if ENV['AR_VERSION'].to_f <= 7.0 || ENV['AR_VERSION'].to_f >= 8.0 belongs_to :customer, inverse_of: :orders, primary_key: %i(account_id id), foreign_key: %i(acco...
github
zdennis/activerecord-import
https://github.com/zdennis/activerecord-import
test/schema/version.rb
Ruby
mit
4,139
master
304
# frozen_string_literal: true class SchemaInfo < ActiveRecord::Base if respond_to?(:table_name=) self.table_name = 'schema_info' else # this is becoming deprecated in ActiveRecord but not all adapters supported it # at this time set_table_name 'schema_info' end VERSION = 12 end
github
zdennis/activerecord-import
https://github.com/zdennis/activerecord-import
test/schema/postgresql_schema.rb
Ruby
mit
4,139
master
2,576
# frozen_string_literal: true ActiveRecord::Schema.define do execute('CREATE extension IF NOT EXISTS "hstore";') execute('CREATE extension IF NOT EXISTS "pgcrypto";') execute('CREATE extension IF NOT EXISTS "uuid-ossp";') # create ENUM if it does not exist yet begin execute('CREATE TYPE vendor_type AS E...
github
zdennis/activerecord-import
https://github.com/zdennis/activerecord-import
test/schema/generic_schema.rb
Ruby
mit
4,139
master
5,673
# frozen_string_literal: true ActiveRecord::Schema.define do create_table :schema_info, force: :cascade do |t| t.integer :version end add_index :schema_info, :version, unique: true SchemaInfo.create version: SchemaInfo::VERSION create_table :group, force: :cascade do |t| t.string :order t.times...
github
zdennis/activerecord-import
https://github.com/zdennis/activerecord-import
test/schema/sqlite3_schema.rb
Ruby
mit
4,139
master
456
# frozen_string_literal: true ActiveRecord::Schema.define do create_table :alarms, force: true do |t| t.column :device_id, :integer, null: false t.column :alarm_type, :integer, null: false t.column :status, :integer, null: false t.column :metadata, :text t.column :secret_key, :binary t.dateti...
github
zdennis/activerecord-import
https://github.com/zdennis/activerecord-import
test/schema/mysql2_schema.rb
Ruby
mit
4,139
master
647
# frozen_string_literal: true ActiveRecord::Schema.define do create_table :books, force: :cascade do |t| t.string :title, null: false t.virtual :upper_title, type: :string, as: "upper(`title`)" if t.respond_to?(:virtual) t.string :publisher, null: false, default: 'Default Publisher' t.string :author_...
github
zdennis/activerecord-import
https://github.com/zdennis/activerecord-import
benchmarks/benchmark.rb
Ruby
mit
4,139
master
2,191
# frozen_string_literal: true require 'pathname' require "fileutils" require "active_record" require "active_record/base" benchmark_dir = File.dirname(__FILE__) $LOAD_PATH.unshift('.') # Get the gem into the load path $LOAD_PATH.unshift(File.join(benchmark_dir, '..', 'lib')) # Load the benchmark files Dir[File.joi...
github
zdennis/activerecord-import
https://github.com/zdennis/activerecord-import
benchmarks/schema/mysql2_schema.rb
Ruby
mit
4,139
master
545
# frozen_string_literal: true ActiveRecord::Schema.define do create_table :test_myisam, options: 'ENGINE=MyISAM', force: true do |t| t.column :my_name, :string, null: false t.column :description, :string end create_table :test_innodb, options: 'ENGINE=InnoDb', force: true do |t| t.column :my_name, :...
github
zdennis/activerecord-import
https://github.com/zdennis/activerecord-import
benchmarks/lib/base.rb
Ruby
mit
4,139
master
4,761
# frozen_string_literal: true class BenchmarkBase attr_reader :results # The main benchmark method dispatcher. This dispatches the benchmarks # to actual benchmark_xxxx methods. # # == PARAMETERS # * table_types - an array of table types to benchmark # * num - the number of record insertions to test ...
github
zdennis/activerecord-import
https://github.com/zdennis/activerecord-import
benchmarks/lib/output_to_html.rb
Ruby
mit
4,139
master
1,686
# frozen_string_literal: true require 'erb' module OutputToHTML TEMPLATE_HEADER = <<"EOT" <div> All times are rounded to the nearest thousandth for display purposes. Speedups next to each time are computed before any rounding occurs. Also, all speedup calculations are computed by comparing a given time ag...
github
zdennis/activerecord-import
https://github.com/zdennis/activerecord-import
benchmarks/lib/float.rb
Ruby
mit
4,139
master
313
# frozen_string_literal: true # Taken from http://www.programmingishard.com/posts/show/128 # Posted by rbates class Float def round_to(x) (self * 10**x).round.to_f / 10**x end def ceil_to(x) (self * 10**x).ceil.to_f / 10**x end def floor_to(x) (self * 10**x).floor.to_f / 10**x end end
github
zdennis/activerecord-import
https://github.com/zdennis/activerecord-import
benchmarks/lib/mysql2_benchmark.rb
Ruby
mit
4,139
master
636
# frozen_string_literal: true class Mysql2Benchmark < BenchmarkBase def benchmark_all( array_of_cols_and_vals ) methods = self.methods.find_all { |m| m =~ /benchmark_/ } methods.delete_if { |m| m =~ /benchmark_(all|model)/ } methods.each { |method| send( method, array_of_cols_and_vals ) } end def be...
github
zdennis/activerecord-import
https://github.com/zdennis/activerecord-import
benchmarks/lib/output_to_csv.rb
Ruby
mit
4,139
master
487
# frozen_string_literal: true require 'csv' module OutputToCSV def self.output_results( filename, results ) CSV.open( filename, 'w' ) do |csv| # Iterate over each result set, which contains many results results.each do |result_set| columns = [] times = [] result_set.each do |...
github
zdennis/activerecord-import
https://github.com/zdennis/activerecord-import
benchmarks/lib/cli_parser.rb
Ruby
mit
4,139
master
3,509
# frozen_string_literal: true require 'optparse' # # == PARAMETERS # * a - database adapter. ie: mysql, postgresql, oracle, etc. # * n - number of objects to test with. ie: 1, 100, 1000, etc. # * t - the table types to test. ie: myisam, innodb, memory, temporary, etc. # module BenchmarkOptionParser BANNER = "Usage:...
github
zdennis/activerecord-import
https://github.com/zdennis/activerecord-import
lib/activerecord-import/base.rb
Ruby
mit
4,139
master
1,420
# frozen_string_literal: true require "pathname" require "active_record" require "active_record/version" module ActiveRecord::Import ADAPTER_PATH = "activerecord-import/active_record/adapters" def self.base_adapter(adapter) case adapter when 'mysql2_makara' then 'mysql2' when 'mysql2spatial' then 'my...
github
zdennis/activerecord-import
https://github.com/zdennis/activerecord-import
lib/activerecord-import/value_sets_parser.rb
Ruby
mit
4,139
master
2,033
# frozen_string_literal: true require 'active_support/core_ext/array' module ActiveRecord::Import class ValueSetTooLargeError < StandardError attr_reader :size def initialize(msg = "Value set exceeds max size", size = 0) @size = size super(msg) end end class ValueSetsBytesParser at...
github
zdennis/activerecord-import
https://github.com/zdennis/activerecord-import
lib/activerecord-import/import.rb
Ruby
mit
4,139
master
48,719
# frozen_string_literal: true module ActiveRecord::Import::ConnectionAdapters; end module ActiveRecord::Import # :nodoc: Result = Struct.new(:failed_instances, :num_inserts, :ids, :results, :affected_rows) module ImportSupport # :nodoc: def supports_import? # :nodoc: true end end module OnDupl...
github
zdennis/activerecord-import
https://github.com/zdennis/activerecord-import
lib/activerecord-import/synchronize.rb
Ruby
mit
4,139
master
2,898
# frozen_string_literal: true module ActiveRecord # :nodoc: class Base # :nodoc: # Synchronizes the passed in ActiveRecord instances with data # from the database. This is like calling reload on an individual # ActiveRecord instance but it is intended for use on multiple instances. # # This uses ...
github
zdennis/activerecord-import
https://github.com/zdennis/activerecord-import
lib/activerecord-import/adapters/sqlite3_proxy_adapter.rb
Ruby
mit
4,139
master
311
# frozen_string_literal: true require "activerecord-import/adapters/sqlite3_adapter" require "activerecord-import/adapters/active_record_proxy_adapter" module ActiveRecord::Import::SQLite3ProxyAdapter include ActiveRecord::Import::SQLite3Adapter include ActiveRecord::Import::ActiveRecordProxyAdapter end
github
zdennis/activerecord-import
https://github.com/zdennis/activerecord-import
lib/activerecord-import/adapters/postgresql_proxy_adapter.rb
Ruby
mit
4,139
master
320
# frozen_string_literal: true require "activerecord-import/adapters/postgresql_adapter" require "activerecord-import/adapters/active_record_proxy_adapter" module ActiveRecord::Import::PostgreSQLProxyAdapter include ActiveRecord::Import::PostgreSQLAdapter include ActiveRecord::Import::ActiveRecordProxyAdapter end
github
zdennis/activerecord-import
https://github.com/zdennis/activerecord-import
lib/activerecord-import/adapters/mysql2_proxy_adapter.rb
Ruby
mit
4,139
master
308
# frozen_string_literal: true require "activerecord-import/adapters/mysql2_adapter" require "activerecord-import/adapters/active_record_proxy_adapter" module ActiveRecord::Import::Mysql2ProxyAdapter include ActiveRecord::Import::Mysql2Adapter include ActiveRecord::Import::ActiveRecordProxyAdapter end
github
zdennis/activerecord-import
https://github.com/zdennis/activerecord-import
lib/activerecord-import/adapters/abstract_adapter.rb
Ruby
mit
4,139
master
2,366
# frozen_string_literal: true module ActiveRecord::Import::AbstractAdapter module InstanceMethods def next_value_for_sequence(sequence_name) %(#{sequence_name}.nextval) end def insert_many( sql, values, _options = {}, *args ) # :nodoc: number_of_inserts = 1 base_sql, post_sql = case s...
github
zdennis/activerecord-import
https://github.com/zdennis/activerecord-import
lib/activerecord-import/adapters/active_record_proxy_adapter.rb
Ruby
mit
4,139
master
521
# frozen_string_literal: true module ActiveRecord::Import::ActiveRecordProxyAdapter def insert_many(*args, **kwargs, &block) sticking_to_primary { super(*args, **kwargs, &block) } end def insert(*args, **kwargs, &block) sticking_to_primary { super(*args, **kwargs, &block) } end def sticking_to_prim...
github
zdennis/activerecord-import
https://github.com/zdennis/activerecord-import
lib/activerecord-import/adapters/mysql_adapter.rb
Ruby
mit
4,139
master
5,334
# frozen_string_literal: true module ActiveRecord::Import::MysqlAdapter include ActiveRecord::Import::ImportSupport include ActiveRecord::Import::OnDuplicateKeyUpdateSupport NO_MAX_PACKET = 0 QUERY_OVERHEAD = 8 # This was shown to be true for MySQL, but it's not clear where the overhead is from. # +sql+ ca...
github
zdennis/activerecord-import
https://github.com/zdennis/activerecord-import
lib/activerecord-import/adapters/postgresql_adapter.rb
Ruby
mit
4,139
master
8,039
# frozen_string_literal: true module ActiveRecord::Import::PostgreSQLAdapter include ActiveRecord::Import::ImportSupport include ActiveRecord::Import::OnDuplicateKeyUpdateSupport MIN_VERSION_FOR_UPSERT = 90_500 def insert_many( sql, values, options = {}, *args ) # :nodoc: number_of_inserts = 1 return...
github
zdennis/activerecord-import
https://github.com/zdennis/activerecord-import
lib/activerecord-import/adapters/trilogy_proxy_adapter.rb
Ruby
mit
4,139
master
311
# frozen_string_literal: true require "activerecord-import/adapters/trilogy_adapter" require "activerecord-import/adapters/active_record_proxy_adapter" module ActiveRecord::Import::TrilogyProxyAdapter include ActiveRecord::Import::TrilogyAdapter include ActiveRecord::Import::ActiveRecordProxyAdapter end
github
zdennis/activerecord-import
https://github.com/zdennis/activerecord-import
lib/activerecord-import/adapters/sqlite3_adapter.rb
Ruby
mit
4,139
master
6,266
# frozen_string_literal: true module ActiveRecord::Import::SQLite3Adapter include ActiveRecord::Import::ImportSupport include ActiveRecord::Import::OnDuplicateKeyUpdateSupport MIN_VERSION_FOR_IMPORT = "3.7.11" MIN_VERSION_FOR_UPSERT = "3.24.0" SQLITE_LIMIT_COMPOUND_SELECT = 500 # Override our conformance...
github
zdennis/activerecord-import
https://github.com/zdennis/activerecord-import
lib/activerecord-import/active_record/adapters/jdbcsqlite3_adapter.rb
Ruby
mit
4,139
master
253
# frozen_string_literal: true require "active_record/connection_adapters/sqlite3_adapter" require "activerecord-import/adapters/sqlite3_adapter" class ActiveRecord::ConnectionAdapters::SQLite3Adapter include ActiveRecord::Import::SQLite3Adapter end
github
zdennis/activerecord-import
https://github.com/zdennis/activerecord-import
lib/activerecord-import/active_record/adapters/jdbcpostgresql_adapter.rb
Ruby
mit
4,139
master
265
# frozen_string_literal: true require "active_record/connection_adapters/postgresql_adapter" require "activerecord-import/adapters/postgresql_adapter" class ActiveRecord::ConnectionAdapters::PostgreSQLAdapter include ActiveRecord::Import::PostgreSQLAdapter end
github
zdennis/activerecord-import
https://github.com/zdennis/activerecord-import
lib/activerecord-import/active_record/adapters/abstract_adapter.rb
Ruby
mit
4,139
master
279
# frozen_string_literal: true require "activerecord-import/adapters/abstract_adapter" module ActiveRecord # :nodoc: module ConnectionAdapters # :nodoc: class AbstractAdapter # :nodoc: include ActiveRecord::Import::AbstractAdapter::InstanceMethods end end end
github
zdennis/activerecord-import
https://github.com/zdennis/activerecord-import
lib/activerecord-import/active_record/adapters/trilogy_proxy_adapter.rb
Ruby
mit
4,139
master
291
# frozen_string_literal: true require "active_record/connection_adapters/trilogy_proxy_adapter" require "activerecord-import/adapters/trilogy_proxy_adapter" ActiveSupport.on_load(:active_record_trilogyproxyadapter) do |klass| klass.include(ActiveRecord::Import::TrilogyProxyAdapter) end
github
zdennis/activerecord-import
https://github.com/zdennis/activerecord-import
lib/activerecord-import/active_record/adapters/trilogy_adapter.rb
Ruby
mit
4,139
master
253
# frozen_string_literal: true require "active_record/connection_adapters/trilogy_adapter" require "activerecord-import/adapters/trilogy_adapter" class ActiveRecord::ConnectionAdapters::TrilogyAdapter include ActiveRecord::Import::TrilogyAdapter end
github
zdennis/activerecord-import
https://github.com/zdennis/activerecord-import
lib/activerecord-import/active_record/adapters/postgresql_proxy_adapter.rb
Ruby
mit
4,139
master
303
# frozen_string_literal: true require "active_record/connection_adapters/postgresql_proxy_adapter" require "activerecord-import/adapters/postgresql_proxy_adapter" ActiveSupport.on_load(:active_record_postgresqlproxyadapter) do |klass| klass.include(ActiveRecord::Import::PostgreSQLProxyAdapter) end
github
zdennis/activerecord-import
https://github.com/zdennis/activerecord-import
lib/activerecord-import/active_record/adapters/sqlite3_proxy_adapter.rb
Ruby
mit
4,139
master
291
# frozen_string_literal: true require "active_record/connection_adapters/sqlite3_proxy_adapter" require "activerecord-import/adapters/sqlite3_proxy_adapter" ActiveSupport.on_load(:active_record_sqlite3proxyadapter) do |klass| klass.include(ActiveRecord::Import::SQLite3ProxyAdapter) end
github
zdennis/activerecord-import
https://github.com/zdennis/activerecord-import
lib/activerecord-import/active_record/adapters/seamless_database_pool_adapter.rb
Ruby
mit
4,139
master
310
# frozen_string_literal: true require "seamless_database_pool" require "active_record/connection_adapters/seamless_database_pool_adapter" require "activerecord-import/adapters/mysql_adapter" class ActiveRecord::ConnectionAdapters::SeamlessDatabasePoolAdapter include ActiveRecord::Import::MysqlAdapter end
github
zdennis/activerecord-import
https://github.com/zdennis/activerecord-import
lib/activerecord-import/active_record/adapters/jdbcmysql_adapter.rb
Ruby
mit
4,139
master
249
# frozen_string_literal: true require "active_record/connection_adapters/mysql2_adapter" require "activerecord-import/adapters/mysql2_adapter" class ActiveRecord::ConnectionAdapters::Mysql2Adapter include ActiveRecord::Import::Mysql2Adapter end
github
zdennis/activerecord-import
https://github.com/zdennis/activerecord-import
lib/activerecord-import/active_record/adapters/mysql2_proxy_adapter.rb
Ruby
mit
4,139
master
287
# frozen_string_literal: true require "active_record/connection_adapters/mysql2_proxy_adapter" require "activerecord-import/adapters/mysql2_proxy_adapter" ActiveSupport.on_load(:active_record_mysql2proxyadapter) do |klass| klass.include(ActiveRecord::Import::Mysql2ProxyAdapter) end
github
typhoeus/typhoeus
https://github.com/typhoeus/typhoeus
Gemfile
Ruby
mit
4,132
master
453
# frozen_string_literal: true source "https://rubygems.org" gemspec gem "json" gem "rake" group :development, :test do gem "rspec", "~> 3.0" gem "sinatra", "~> 1.3" gem "faraday", ">= 0.9", "< 2.0" gem "dalli", "~> 2.0" gem "webrick" gem "logger" gem "ostruct" gem "redis", "~> 3.0" if RUBY_PLA...
github
typhoeus/typhoeus
https://github.com/typhoeus/typhoeus
typhoeus.gemspec
Ruby
mit
4,132
master
1,419
# frozen_string_literal: true lib = File.expand_path('../lib/', __FILE__) $:.unshift lib unless $:.include?(lib) require 'typhoeus/version' Gem::Specification.new do |s| s.name = "typhoeus" s.version = Typhoeus::VERSION s.platform = Gem::Platform::RUBY s.authors = ["David Balatero", "Pa...
github
typhoeus/typhoeus
https://github.com/typhoeus/typhoeus
Guardfile
Ruby
mit
4,132
master
266
# frozen_string_literal: true # vim:set filetype=ruby: guard( "rspec", all_after_pass: false, cli: "--fail-fast --tty --format documentation --colour") do watch(%r{^spec/.+_spec\.rb$}) watch(%r{^lib/(.+)\.rb$}) { |match| "spec/#{match[1]}_spec.rb" } end
github
typhoeus/typhoeus
https://github.com/typhoeus/typhoeus
Rakefile
Ruby
mit
4,132
master
839
# frozen_string_literal: true require "bundler" Bundler.setup require "rake" require "rspec/core/rake_task" $LOAD_PATH.unshift File.expand_path("../lib", __FILE__) require "typhoeus/version" task :gem => :build task :build do system "gem build typhoeus.gemspec" end task :install => :build do system "gem install...
github
typhoeus/typhoeus
https://github.com/typhoeus/typhoeus
perf/vs_nethttp.rb
Ruby
mit
4,132
master
1,433
# frozen_string_literal: true require 'typhoeus' require 'net/http' require 'open-uri' require 'benchmark' URL = "http://localhost:300" hydra = Typhoeus::Hydra.new(max_concurrency: 3) if defined? require_relative require_relative '../spec/support/localhost_server.rb' require_relative '../spec/support/server.rb' ...
github
typhoeus/typhoeus
https://github.com/typhoeus/typhoeus
perf/profile.rb
Ruby
mit
4,132
master
288
# frozen_string_literal: true require 'typhoeus' require 'ruby-prof' calls = 50 base_url = "http://127.0.0.1:3000/" RubyProf.start calls.times do |i| Typhoeus::Request.get(base_url+i.to_s) end result = RubyProf.stop printer = RubyProf::FlatPrinter.new(result) printer.print(STDOUT)
github
typhoeus/typhoeus
https://github.com/typhoeus/typhoeus
lib/typhoeus.rb
Ruby
mit
4,132
master
3,919
# frozen_string_literal: true require 'digest/sha2' require 'ethon' require 'typhoeus/config' require 'typhoeus/easy_factory' require 'typhoeus/errors' require 'typhoeus/expectation' require 'typhoeus/hydra' require 'typhoeus/pool' require 'typhoeus/request' require 'typhoeus/response' require 'typhoeus/version' # I...
github
typhoeus/typhoeus
https://github.com/typhoeus/typhoeus
lib/rack/typhoeus/middleware/params_decoder.rb
Ruby
mit
4,132
master
1,640
# frozen_string_literal: true require 'rack/typhoeus/middleware/params_decoder/helper' module Rack module Typhoeus module Middleware # This Rack middleware takes care of the proper deserialization of # the nested params encoded by Typhoeus. # # @example Require the railtie when using Ra...
github
typhoeus/typhoeus
https://github.com/typhoeus/typhoeus
lib/rack/typhoeus/middleware/params_decoder/helper.rb
Ruby
mit
4,132
master
2,237
# frozen_string_literal: true module Rack module Typhoeus module Middleware class ParamsDecoder module Helper # Recursively decodes Typhoeus encoded arrays in given Hash. # # @example Use directly in a Rails controller. # class ApplicationController ...
github
typhoeus/typhoeus
https://github.com/typhoeus/typhoeus
lib/typhoeus/pool.rb
Ruby
mit
4,132
master
1,620
# frozen_string_literal: true require 'thread' module Typhoeus # The easy pool stores already initialized # easy handles for future use. This is useful # because creating them is expensive. # # @api private module Pool @mutex = Mutex.new @pid = Process.pid # Releases easy into the pool. The ...
github
typhoeus/typhoeus
https://github.com/typhoeus/typhoeus
lib/typhoeus/errors.rb
Ruby
mit
4,132
master
209
# frozen_string_literal: true require 'typhoeus/errors/typhoeus_error' require 'typhoeus/errors/no_stub' module Typhoeus # This namespace contains all errors raised by Typhoeus. module Errors end end