repo stringlengths 5 92 | file_url stringlengths 80 287 | file_path stringlengths 5 197 | content stringlengths 0 32.8k | language stringclasses 1
value | license stringclasses 7
values | commit_sha stringlengths 40 40 | retrieved_at stringdate 2026-01-04 15:37:27 2026-01-04 17:58:21 | truncated bool 2
classes |
|---|---|---|---|---|---|---|---|---|
typhoeus/typhoeus | https://github.com/typhoeus/typhoeus/blob/2c834013e6fbfb757f76e8f8ba9466c2b3108fae/lib/typhoeus/hydra/runnable.rb | lib/typhoeus/hydra/runnable.rb | module Typhoeus
class Hydra
# This module contains logic to run a hydra.
module Runnable
# Start the hydra run.
#
# @example Start hydra run.
# hydra.run
#
# @return [ Symbol ] Return value from multi.perform.
def run
dequeue_many
multi.perform
... | ruby | MIT | 2c834013e6fbfb757f76e8f8ba9466c2b3108fae | 2026-01-04T15:47:13.347692Z | false |
typhoeus/typhoeus | https://github.com/typhoeus/typhoeus/blob/2c834013e6fbfb757f76e8f8ba9466c2b3108fae/lib/typhoeus/hydra/block_connection.rb | lib/typhoeus/hydra/block_connection.rb | module Typhoeus
class Hydra
# This module handles the blocked connection request mode on
# the hydra side, where only stubbed requests
# are allowed.
# Connection blocking needs to be turned on:
# Typhoeus.configure do |config|
# config.block_connection = true
# end
#
# Wh... | ruby | MIT | 2c834013e6fbfb757f76e8f8ba9466c2b3108fae | 2026-01-04T15:47:13.347692Z | false |
typhoeus/typhoeus | https://github.com/typhoeus/typhoeus/blob/2c834013e6fbfb757f76e8f8ba9466c2b3108fae/lib/typhoeus/hydra/before.rb | lib/typhoeus/hydra/before.rb | module Typhoeus
class Hydra
# This module provides a way to hook into before
# a request gets queued in hydra. This is very powerful
# and you should be careful because when you accidently
# return a falsy value the request won't be executed.
#
# @api private
module Before
# Overrr... | ruby | MIT | 2c834013e6fbfb757f76e8f8ba9466c2b3108fae | 2026-01-04T15:47:13.347692Z | false |
typhoeus/typhoeus | https://github.com/typhoeus/typhoeus/blob/2c834013e6fbfb757f76e8f8ba9466c2b3108fae/lib/typhoeus/hydra/memoizable.rb | lib/typhoeus/hydra/memoizable.rb | module Typhoeus
class Hydra
# This module handles the GET request memoization
# on the hydra side. Memoization needs to be turned
# on:
# Typhoeus.configure do |config|
# config.memoize = true
# end
#
# @api private
module Memoizable
# Return the memory.
#
... | ruby | MIT | 2c834013e6fbfb757f76e8f8ba9466c2b3108fae | 2026-01-04T15:47:13.347692Z | false |
typhoeus/typhoeus | https://github.com/typhoeus/typhoeus/blob/2c834013e6fbfb757f76e8f8ba9466c2b3108fae/lib/typhoeus/hydra/addable.rb | lib/typhoeus/hydra/addable.rb | module Typhoeus
class Hydra
# This module handles the request adding on
# hydra.
#
# @api private
module Addable
# Adds request to multi.
#
# @example Add request.
# hydra.add(request)
#
# @param [ Typhoeus::Request ] request to add.
#
# @return ... | ruby | MIT | 2c834013e6fbfb757f76e8f8ba9466c2b3108fae | 2026-01-04T15:47:13.347692Z | false |
typhoeus/typhoeus | https://github.com/typhoeus/typhoeus/blob/2c834013e6fbfb757f76e8f8ba9466c2b3108fae/lib/typhoeus/hydra/cacheable.rb | lib/typhoeus/hydra/cacheable.rb | module Typhoeus
class Hydra
module Cacheable
def add(request)
if request.cacheable? && response = request.cached_response
response.cached = true
request.finish(response)
dequeue
else
super
end
end
end
end
end
| ruby | MIT | 2c834013e6fbfb757f76e8f8ba9466c2b3108fae | 2026-01-04T15:47:13.347692Z | false |
typhoeus/typhoeus | https://github.com/typhoeus/typhoeus/blob/2c834013e6fbfb757f76e8f8ba9466c2b3108fae/lib/typhoeus/hydra/queueable.rb | lib/typhoeus/hydra/queueable.rb | module Typhoeus
class Hydra
# This module handles the request queueing on
# hydra.
#
# @api private
module Queueable
# Return the queued requests.
#
# @example Return queued requests.
# hydra.queued_requests
#
# @return [ Array<Typhoeus::Request> ] The queue... | ruby | MIT | 2c834013e6fbfb757f76e8f8ba9466c2b3108fae | 2026-01-04T15:47:13.347692Z | false |
typhoeus/typhoeus | https://github.com/typhoeus/typhoeus/blob/2c834013e6fbfb757f76e8f8ba9466c2b3108fae/lib/typhoeus/hydra/stubbable.rb | lib/typhoeus/hydra/stubbable.rb | module Typhoeus
class Hydra
# This module handles stubbing on the hydra side.
# It plays well with the block_connection configuration,
# which raises when you make a request which is not stubbed.
#
# @api private
module Stubbable
# Override add in order to check for matching expecation... | ruby | MIT | 2c834013e6fbfb757f76e8f8ba9466c2b3108fae | 2026-01-04T15:47:13.347692Z | false |
typhoeus/typhoeus | https://github.com/typhoeus/typhoeus/blob/2c834013e6fbfb757f76e8f8ba9466c2b3108fae/lib/typhoeus/adapters/faraday.rb | lib/typhoeus/adapters/faraday.rb | require 'faraday'
module Faraday # :nodoc:
class Adapter # :nodoc:
# Adapter to use Faraday with Typhoeus.
#
# @example Use Typhoeus.
# require 'faraday'
# require 'typhoeus'
# require 'typhoeus/adapters/faraday'
#
# conn = Faraday.new(url: "www.example.com") do |faraday|
... | ruby | MIT | 2c834013e6fbfb757f76e8f8ba9466c2b3108fae | 2026-01-04T15:47:13.347692Z | false |
typhoeus/typhoeus | https://github.com/typhoeus/typhoeus/blob/2c834013e6fbfb757f76e8f8ba9466c2b3108fae/lib/typhoeus/response/informations.rb | lib/typhoeus/response/informations.rb | module Typhoeus
class Response
# This module contains logic about informations
# on a response.
module Informations
# Return libcurls return value.
#
# @example Get return_code.
# response.return_code
#
# @return [ Symbol ] The return_code.
def return_code
... | ruby | MIT | 2c834013e6fbfb757f76e8f8ba9466c2b3108fae | 2026-01-04T15:47:13.347692Z | false |
typhoeus/typhoeus | https://github.com/typhoeus/typhoeus/blob/2c834013e6fbfb757f76e8f8ba9466c2b3108fae/lib/typhoeus/response/cacheable.rb | lib/typhoeus/response/cacheable.rb | module Typhoeus
class Response
module Cacheable
# Set the cache status, if we got response from cache
# it will have cached? == true
attr_writer :cached
def cached?
defined?(@cached) ? !!@cached : false
end
end
end
end
| ruby | MIT | 2c834013e6fbfb757f76e8f8ba9466c2b3108fae | 2026-01-04T15:47:13.347692Z | false |
typhoeus/typhoeus | https://github.com/typhoeus/typhoeus/blob/2c834013e6fbfb757f76e8f8ba9466c2b3108fae/lib/typhoeus/response/header.rb | lib/typhoeus/response/header.rb | require 'delegate'
module Typhoeus
class Response
# This class represents the response header.
# It can be accessed like a hash.
# Values can be strings (normal case) or arrays of strings (for duplicates headers)
#
# @api private
class Header < DelegateClass(Hash)
# Create a new heade... | ruby | MIT | 2c834013e6fbfb757f76e8f8ba9466c2b3108fae | 2026-01-04T15:47:13.347692Z | false |
typhoeus/typhoeus | https://github.com/typhoeus/typhoeus/blob/2c834013e6fbfb757f76e8f8ba9466c2b3108fae/lib/typhoeus/response/status.rb | lib/typhoeus/response/status.rb | module Typhoeus
class Response
# This module contains logic about the http
# status.
module Status
# Return the status message if present.
#
# @example Return status message.
# reesponse.status_message
#
# @return [ String ] The message.
def status_message
... | ruby | MIT | 2c834013e6fbfb757f76e8f8ba9466c2b3108fae | 2026-01-04T15:47:13.347692Z | false |
typhoeus/typhoeus | https://github.com/typhoeus/typhoeus/blob/2c834013e6fbfb757f76e8f8ba9466c2b3108fae/lib/typhoeus/request/actions.rb | lib/typhoeus/request/actions.rb | module Typhoeus
class Request
# Module containing logic about shortcuts to
# http methods. Like
# Typhoeus.get("www.example.com")
module Actions
# Make a get request.
#
# @example Make get request.
# Typhoeus.get("www.example.com")
#
# @param (see Typhoeus::Re... | ruby | MIT | 2c834013e6fbfb757f76e8f8ba9466c2b3108fae | 2026-01-04T15:47:13.347692Z | false |
typhoeus/typhoeus | https://github.com/typhoeus/typhoeus/blob/2c834013e6fbfb757f76e8f8ba9466c2b3108fae/lib/typhoeus/request/block_connection.rb | lib/typhoeus/request/block_connection.rb | module Typhoeus
class Request
# This module handles the blocked connection request mode on
# the request side, where only stubbed requests
# are allowed.
# Connection blocking needs to be turned on:
# Typhoeus.configure do |config|
# config.block_connection = true
# end
#
... | ruby | MIT | 2c834013e6fbfb757f76e8f8ba9466c2b3108fae | 2026-01-04T15:47:13.347692Z | false |
typhoeus/typhoeus | https://github.com/typhoeus/typhoeus/blob/2c834013e6fbfb757f76e8f8ba9466c2b3108fae/lib/typhoeus/request/responseable.rb | lib/typhoeus/request/responseable.rb | module Typhoeus
class Request
# This module contains logic for having a response
# getter and setter.
module Responseable
# Set the response.
#
# @example Set response.
# request.response = response
#
# @param [ Response ] value The response to set.
def respons... | ruby | MIT | 2c834013e6fbfb757f76e8f8ba9466c2b3108fae | 2026-01-04T15:47:13.347692Z | false |
typhoeus/typhoeus | https://github.com/typhoeus/typhoeus/blob/2c834013e6fbfb757f76e8f8ba9466c2b3108fae/lib/typhoeus/request/operations.rb | lib/typhoeus/request/operations.rb | module Typhoeus
class Request
# This module contains everything what is necessary
# to make a single request.
module Operations
# Run a request.
#
# @example Run a request.
# Typhoeus::Request.new("www.example.com").run
#
# @return [ Response ] The response.
de... | ruby | MIT | 2c834013e6fbfb757f76e8f8ba9466c2b3108fae | 2026-01-04T15:47:13.347692Z | false |
typhoeus/typhoeus | https://github.com/typhoeus/typhoeus/blob/2c834013e6fbfb757f76e8f8ba9466c2b3108fae/lib/typhoeus/request/before.rb | lib/typhoeus/request/before.rb | module Typhoeus
class Request
# This module provides a way to hook into before
# a request runs. This is very powerful
# and you should be careful because when you accidently
# return a falsy value the request won't be executed.
#
# @api private
module Before
# Overrride run in ord... | ruby | MIT | 2c834013e6fbfb757f76e8f8ba9466c2b3108fae | 2026-01-04T15:47:13.347692Z | false |
typhoeus/typhoeus | https://github.com/typhoeus/typhoeus/blob/2c834013e6fbfb757f76e8f8ba9466c2b3108fae/lib/typhoeus/request/callbacks.rb | lib/typhoeus/request/callbacks.rb | module Typhoeus
class Request
# This module contains the logic for the response callbacks.
#
# You can set multiple callbacks, which are then executed
# in the same order.
#
# request.on_complete { |response| p 1 }
# request.on_complete { |response| p 2 }
# request.execute_callb... | ruby | MIT | 2c834013e6fbfb757f76e8f8ba9466c2b3108fae | 2026-01-04T15:47:13.347692Z | false |
typhoeus/typhoeus | https://github.com/typhoeus/typhoeus/blob/2c834013e6fbfb757f76e8f8ba9466c2b3108fae/lib/typhoeus/request/memoizable.rb | lib/typhoeus/request/memoizable.rb | module Typhoeus
class Request
# This module handles the GET request memoization
# on the request side. Memoization needs to be turned
# on:
# Typhoeus.configure do |config|
# config.memoize = true
# end
#
# @api private
module Memoizable
# Override response setter a... | ruby | MIT | 2c834013e6fbfb757f76e8f8ba9466c2b3108fae | 2026-01-04T15:47:13.347692Z | false |
typhoeus/typhoeus | https://github.com/typhoeus/typhoeus/blob/2c834013e6fbfb757f76e8f8ba9466c2b3108fae/lib/typhoeus/request/marshal.rb | lib/typhoeus/request/marshal.rb | module Typhoeus
class Request
# This module contains custom serializer.
module Marshal
# Return the important data needed to serialize this Request, except the
# request callbacks and `hydra`, since they cannot be marshalled.
def marshal_dump
unmarshallable = %w(@on_complete @on_su... | ruby | MIT | 2c834013e6fbfb757f76e8f8ba9466c2b3108fae | 2026-01-04T15:47:13.347692Z | false |
typhoeus/typhoeus | https://github.com/typhoeus/typhoeus/blob/2c834013e6fbfb757f76e8f8ba9466c2b3108fae/lib/typhoeus/request/cacheable.rb | lib/typhoeus/request/cacheable.rb | module Typhoeus
class Request
module Cacheable
def response=(response)
cache.set(self, response) if cacheable? && !response.cached?
super
end
def cacheable?
cache
end
def run
if response = cached_response
response.cached = true
fi... | ruby | MIT | 2c834013e6fbfb757f76e8f8ba9466c2b3108fae | 2026-01-04T15:47:13.347692Z | false |
typhoeus/typhoeus | https://github.com/typhoeus/typhoeus/blob/2c834013e6fbfb757f76e8f8ba9466c2b3108fae/lib/typhoeus/request/stubbable.rb | lib/typhoeus/request/stubbable.rb | module Typhoeus
class Request
# This module handles stubbing on the request side.
# It plays well with the block_connection configuration,
# which raises when you make a request which is not stubbed.
#
# @api private
module Stubbable
# Override run in order to check for matching expect... | ruby | MIT | 2c834013e6fbfb757f76e8f8ba9466c2b3108fae | 2026-01-04T15:47:13.347692Z | false |
typhoeus/typhoeus | https://github.com/typhoeus/typhoeus/blob/2c834013e6fbfb757f76e8f8ba9466c2b3108fae/lib/typhoeus/request/streamable.rb | lib/typhoeus/request/streamable.rb | module Typhoeus
class Request
# This module contians the logic for response streaming.
module Streamable
# Set on_body callback.
#
# This callback will be called each time a portion of the body is read from the socket.
# Setting an on_body callback will cause the response body to be ... | ruby | MIT | 2c834013e6fbfb757f76e8f8ba9466c2b3108fae | 2026-01-04T15:47:13.347692Z | false |
zdennis/activerecord-import | https://github.com/zdennis/activerecord-import/blob/d3d3f8a130ed8c31b6ea487a18f264b3a9288dd3/benchmarks/benchmark.rb | benchmarks/benchmark.rb | # 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... | ruby | MIT | d3d3f8a130ed8c31b6ea487a18f264b3a9288dd3 | 2026-01-04T15:47:04.039287Z | false |
zdennis/activerecord-import | https://github.com/zdennis/activerecord-import/blob/d3d3f8a130ed8c31b6ea487a18f264b3a9288dd3/benchmarks/models/test_innodb.rb | benchmarks/models/test_innodb.rb | # frozen_string_literal: true
class TestInnoDb < ActiveRecord::Base
self.table_name = 'test_innodb'
end
| ruby | MIT | d3d3f8a130ed8c31b6ea487a18f264b3a9288dd3 | 2026-01-04T15:47:04.039287Z | false |
zdennis/activerecord-import | https://github.com/zdennis/activerecord-import/blob/d3d3f8a130ed8c31b6ea487a18f264b3a9288dd3/benchmarks/models/test_myisam.rb | benchmarks/models/test_myisam.rb | # frozen_string_literal: true
class TestMyISAM < ActiveRecord::Base
self.table_name = 'test_myisam'
end
| ruby | MIT | d3d3f8a130ed8c31b6ea487a18f264b3a9288dd3 | 2026-01-04T15:47:04.039287Z | false |
zdennis/activerecord-import | https://github.com/zdennis/activerecord-import/blob/d3d3f8a130ed8c31b6ea487a18f264b3a9288dd3/benchmarks/models/test_memory.rb | benchmarks/models/test_memory.rb | # frozen_string_literal: true
class TestMemory < ActiveRecord::Base
self.table_name = 'test_memory'
end
| ruby | MIT | d3d3f8a130ed8c31b6ea487a18f264b3a9288dd3 | 2026-01-04T15:47:04.039287Z | false |
zdennis/activerecord-import | https://github.com/zdennis/activerecord-import/blob/d3d3f8a130ed8c31b6ea487a18f264b3a9288dd3/benchmarks/lib/output_to_csv.rb | benchmarks/lib/output_to_csv.rb | # 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 |... | ruby | MIT | d3d3f8a130ed8c31b6ea487a18f264b3a9288dd3 | 2026-01-04T15:47:04.039287Z | false |
zdennis/activerecord-import | https://github.com/zdennis/activerecord-import/blob/d3d3f8a130ed8c31b6ea487a18f264b3a9288dd3/benchmarks/lib/float.rb | benchmarks/lib/float.rb | # 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
| ruby | MIT | d3d3f8a130ed8c31b6ea487a18f264b3a9288dd3 | 2026-01-04T15:47:04.039287Z | false |
zdennis/activerecord-import | https://github.com/zdennis/activerecord-import/blob/d3d3f8a130ed8c31b6ea487a18f264b3a9288dd3/benchmarks/lib/cli_parser.rb | benchmarks/lib/cli_parser.rb | # 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:... | ruby | MIT | d3d3f8a130ed8c31b6ea487a18f264b3a9288dd3 | 2026-01-04T15:47:04.039287Z | false |
zdennis/activerecord-import | https://github.com/zdennis/activerecord-import/blob/d3d3f8a130ed8c31b6ea487a18f264b3a9288dd3/benchmarks/lib/mysql2_benchmark.rb | benchmarks/lib/mysql2_benchmark.rb | # 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... | ruby | MIT | d3d3f8a130ed8c31b6ea487a18f264b3a9288dd3 | 2026-01-04T15:47:04.039287Z | false |
zdennis/activerecord-import | https://github.com/zdennis/activerecord-import/blob/d3d3f8a130ed8c31b6ea487a18f264b3a9288dd3/benchmarks/lib/output_to_html.rb | benchmarks/lib/output_to_html.rb | # 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... | ruby | MIT | d3d3f8a130ed8c31b6ea487a18f264b3a9288dd3 | 2026-01-04T15:47:04.039287Z | false |
zdennis/activerecord-import | https://github.com/zdennis/activerecord-import/blob/d3d3f8a130ed8c31b6ea487a18f264b3a9288dd3/benchmarks/lib/base.rb | benchmarks/lib/base.rb | # 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
... | ruby | MIT | d3d3f8a130ed8c31b6ea487a18f264b3a9288dd3 | 2026-01-04T15:47:04.039287Z | false |
zdennis/activerecord-import | https://github.com/zdennis/activerecord-import/blob/d3d3f8a130ed8c31b6ea487a18f264b3a9288dd3/benchmarks/schema/mysql2_schema.rb | benchmarks/schema/mysql2_schema.rb | # 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, :... | ruby | MIT | d3d3f8a130ed8c31b6ea487a18f264b3a9288dd3 | 2026-01-04T15:47:04.039287Z | false |
zdennis/activerecord-import | https://github.com/zdennis/activerecord-import/blob/d3d3f8a130ed8c31b6ea487a18f264b3a9288dd3/test/synchronize_test.rb | test/synchronize_test.rb | # 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|
... | ruby | MIT | d3d3f8a130ed8c31b6ea487a18f264b3a9288dd3 | 2026-01-04T15:47:04.039287Z | false |
zdennis/activerecord-import | https://github.com/zdennis/activerecord-import/blob/d3d3f8a130ed8c31b6ea487a18f264b3a9288dd3/test/value_sets_bytes_parser_test.rb | test/value_sets_bytes_parser_test.rb | # 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 }
... | ruby | MIT | d3d3f8a130ed8c31b6ea487a18f264b3a9288dd3 | 2026-01-04T15:47:04.039287Z | false |
zdennis/activerecord-import | https://github.com/zdennis/activerecord-import/blob/d3d3f8a130ed8c31b6ea487a18f264b3a9288dd3/test/value_sets_records_parser_test.rb | test/value_sets_records_parser_test.rb | # 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... | ruby | MIT | d3d3f8a130ed8c31b6ea487a18f264b3a9288dd3 | 2026-01-04T15:47:04.039287Z | false |
zdennis/activerecord-import | https://github.com/zdennis/activerecord-import/blob/d3d3f8a130ed8c31b6ea487a18f264b3a9288dd3/test/test_helper.rb | test/test_helper.rb | # 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... | ruby | MIT | d3d3f8a130ed8c31b6ea487a18f264b3a9288dd3 | 2026-01-04T15:47:04.039287Z | false |
zdennis/activerecord-import | https://github.com/zdennis/activerecord-import/blob/d3d3f8a130ed8c31b6ea487a18f264b3a9288dd3/test/import_test.rb | test/import_test.rb | # 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... | ruby | MIT | d3d3f8a130ed8c31b6ea487a18f264b3a9288dd3 | 2026-01-04T15:47:04.039287Z | true |
zdennis/activerecord-import | https://github.com/zdennis/activerecord-import/blob/d3d3f8a130ed8c31b6ea487a18f264b3a9288dd3/test/jdbcmysql/import_test.rb | test/jdbcmysql/import_test.rb | # 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
| ruby | MIT | d3d3f8a130ed8c31b6ea487a18f264b3a9288dd3 | 2026-01-04T15:47:04.039287Z | false |
zdennis/activerecord-import | https://github.com/zdennis/activerecord-import/blob/d3d3f8a130ed8c31b6ea487a18f264b3a9288dd3/test/postgresql_proxy/import_test.rb | test/postgresql_proxy/import_test.rb | # 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
| ruby | MIT | d3d3f8a130ed8c31b6ea487a18f264b3a9288dd3 | 2026-01-04T15:47:04.039287Z | false |
zdennis/activerecord-import | https://github.com/zdennis/activerecord-import/blob/d3d3f8a130ed8c31b6ea487a18f264b3a9288dd3/test/postgis/import_test.rb | test/postgis/import_test.rb | # 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... | ruby | MIT | d3d3f8a130ed8c31b6ea487a18f264b3a9288dd3 | 2026-01-04T15:47:04.039287Z | false |
zdennis/activerecord-import | https://github.com/zdennis/activerecord-import/blob/d3d3f8a130ed8c31b6ea487a18f264b3a9288dd3/test/support/assertions.rb | test/support/assertions.rb | # 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
... | ruby | MIT | d3d3f8a130ed8c31b6ea487a18f264b3a9288dd3 | 2026-01-04T15:47:04.039287Z | false |
zdennis/activerecord-import | https://github.com/zdennis/activerecord-import/blob/d3d3f8a130ed8c31b6ea487a18f264b3a9288dd3/test/support/generate.rb | test/support/generate.rb | # 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... | ruby | MIT | d3d3f8a130ed8c31b6ea487a18f264b3a9288dd3 | 2026-01-04T15:47:04.039287Z | false |
zdennis/activerecord-import | https://github.com/zdennis/activerecord-import/blob/d3d3f8a130ed8c31b6ea487a18f264b3a9288dd3/test/support/factories.rb | test/support/factories.rb | # 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... | ruby | MIT | d3d3f8a130ed8c31b6ea487a18f264b3a9288dd3 | 2026-01-04T15:47:04.039287Z | false |
zdennis/activerecord-import | https://github.com/zdennis/activerecord-import/blob/d3d3f8a130ed8c31b6ea487a18f264b3a9288dd3/test/support/postgresql/import_examples.rb | test/support/postgresql/import_examples.rb | # 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... | ruby | MIT | d3d3f8a130ed8c31b6ea487a18f264b3a9288dd3 | 2026-01-04T15:47:04.039287Z | false |
zdennis/activerecord-import | https://github.com/zdennis/activerecord-import/blob/d3d3f8a130ed8c31b6ea487a18f264b3a9288dd3/test/support/active_support/test_case_extensions.rb | test/support/active_support/test_case_extensions.rb | # 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)
... | ruby | MIT | d3d3f8a130ed8c31b6ea487a18f264b3a9288dd3 | 2026-01-04T15:47:04.039287Z | false |
zdennis/activerecord-import | https://github.com/zdennis/activerecord-import/blob/d3d3f8a130ed8c31b6ea487a18f264b3a9288dd3/test/support/mysql/import_examples.rb | test/support/mysql/import_examples.rb | # 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_... | ruby | MIT | d3d3f8a130ed8c31b6ea487a18f264b3a9288dd3 | 2026-01-04T15:47:04.039287Z | false |
zdennis/activerecord-import | https://github.com/zdennis/activerecord-import/blob/d3d3f8a130ed8c31b6ea487a18f264b3a9288dd3/test/support/sqlite3/import_examples.rb | test/support/sqlite3/import_examples.rb | # 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... | ruby | MIT | d3d3f8a130ed8c31b6ea487a18f264b3a9288dd3 | 2026-01-04T15:47:04.039287Z | false |
zdennis/activerecord-import | https://github.com/zdennis/activerecord-import/blob/d3d3f8a130ed8c31b6ea487a18f264b3a9288dd3/test/support/shared_examples/recursive_import.rb | test/support/shared_examples/recursive_import.rb | # 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... | ruby | MIT | d3d3f8a130ed8c31b6ea487a18f264b3a9288dd3 | 2026-01-04T15:47:04.039287Z | false |
zdennis/activerecord-import | https://github.com/zdennis/activerecord-import/blob/d3d3f8a130ed8c31b6ea487a18f264b3a9288dd3/test/support/shared_examples/on_duplicate_key_update.rb | test/support/shared_examples/on_duplicate_key_update.rb | # 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... | ruby | MIT | d3d3f8a130ed8c31b6ea487a18f264b3a9288dd3 | 2026-01-04T15:47:04.039287Z | false |
zdennis/activerecord-import | https://github.com/zdennis/activerecord-import/blob/d3d3f8a130ed8c31b6ea487a18f264b3a9288dd3/test/support/shared_examples/on_duplicate_key_ignore.rb | test/support/shared_examples/on_duplicate_key_ignore.rb | # 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... | ruby | MIT | d3d3f8a130ed8c31b6ea487a18f264b3a9288dd3 | 2026-01-04T15:47:04.039287Z | false |
zdennis/activerecord-import | https://github.com/zdennis/activerecord-import/blob/d3d3f8a130ed8c31b6ea487a18f264b3a9288dd3/test/support/shared_examples/affected_rows.rb | test/support/shared_examples/affected_rows.rb | # 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 = ... | ruby | MIT | d3d3f8a130ed8c31b6ea487a18f264b3a9288dd3 | 2026-01-04T15:47:04.039287Z | false |
zdennis/activerecord-import | https://github.com/zdennis/activerecord-import/blob/d3d3f8a130ed8c31b6ea487a18f264b3a9288dd3/test/jdbcpostgresql/import_test.rb | test/jdbcpostgresql/import_test.rb | # 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
| ruby | MIT | d3d3f8a130ed8c31b6ea487a18f264b3a9288dd3 | 2026-01-04T15:47:04.039287Z | false |
zdennis/activerecord-import | https://github.com/zdennis/activerecord-import/blob/d3d3f8a130ed8c31b6ea487a18f264b3a9288dd3/test/postgresql/import_test.rb | test/postgresql/import_test.rb | # 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
| ruby | MIT | d3d3f8a130ed8c31b6ea487a18f264b3a9288dd3 | 2026-01-04T15:47:04.039287Z | false |
zdennis/activerecord-import | https://github.com/zdennis/activerecord-import/blob/d3d3f8a130ed8c31b6ea487a18f264b3a9288dd3/test/trilogy_proxy/import_test.rb | test/trilogy_proxy/import_test.rb | # 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
| ruby | MIT | d3d3f8a130ed8c31b6ea487a18f264b3a9288dd3 | 2026-01-04T15:47:04.039287Z | false |
zdennis/activerecord-import | https://github.com/zdennis/activerecord-import/blob/d3d3f8a130ed8c31b6ea487a18f264b3a9288dd3/test/mysql2_makara/import_test.rb | test/mysql2_makara/import_test.rb | # 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
| ruby | MIT | d3d3f8a130ed8c31b6ea487a18f264b3a9288dd3 | 2026-01-04T15:47:04.039287Z | false |
zdennis/activerecord-import | https://github.com/zdennis/activerecord-import/blob/d3d3f8a130ed8c31b6ea487a18f264b3a9288dd3/test/mysql2_proxy/import_test.rb | test/mysql2_proxy/import_test.rb | # 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
| ruby | MIT | d3d3f8a130ed8c31b6ea487a18f264b3a9288dd3 | 2026-01-04T15:47:04.039287Z | false |
zdennis/activerecord-import | https://github.com/zdennis/activerecord-import/blob/d3d3f8a130ed8c31b6ea487a18f264b3a9288dd3/test/makara_postgis/import_test.rb | test/makara_postgis/import_test.rb | # 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... | ruby | MIT | d3d3f8a130ed8c31b6ea487a18f264b3a9288dd3 | 2026-01-04T15:47:04.039287Z | false |
zdennis/activerecord-import | https://github.com/zdennis/activerecord-import/blob/d3d3f8a130ed8c31b6ea487a18f264b3a9288dd3/test/janus_trilogy/import_test.rb | test/janus_trilogy/import_test.rb | # 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
| ruby | MIT | d3d3f8a130ed8c31b6ea487a18f264b3a9288dd3 | 2026-01-04T15:47:04.039287Z | false |
zdennis/activerecord-import | https://github.com/zdennis/activerecord-import/blob/d3d3f8a130ed8c31b6ea487a18f264b3a9288dd3/test/models/tag.rb | test/models/tag.rb | # 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... | ruby | MIT | d3d3f8a130ed8c31b6ea487a18f264b3a9288dd3 | 2026-01-04T15:47:04.039287Z | false |
zdennis/activerecord-import | https://github.com/zdennis/activerecord-import/blob/d3d3f8a130ed8c31b6ea487a18f264b3a9288dd3/test/models/book.rb | test/models/book.rb | # 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... | ruby | MIT | d3d3f8a130ed8c31b6ea487a18f264b3a9288dd3 | 2026-01-04T15:47:04.039287Z | false |
zdennis/activerecord-import | https://github.com/zdennis/activerecord-import/blob/d3d3f8a130ed8c31b6ea487a18f264b3a9288dd3/test/models/vendor.rb | test/models/vendor.rb | # 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
| ruby | MIT | d3d3f8a130ed8c31b6ea487a18f264b3a9288dd3 | 2026-01-04T15:47:04.039287Z | false |
zdennis/activerecord-import | https://github.com/zdennis/activerecord-import/blob/d3d3f8a130ed8c31b6ea487a18f264b3a9288dd3/test/models/chapter.rb | test/models/chapter.rb | # frozen_string_literal: true
class Chapter < ActiveRecord::Base
belongs_to :book, inverse_of: :chapters
validates :title, presence: true
end
| ruby | MIT | d3d3f8a130ed8c31b6ea487a18f264b3a9288dd3 | 2026-01-04T15:47:04.039287Z | false |
zdennis/activerecord-import | https://github.com/zdennis/activerecord-import/blob/d3d3f8a130ed8c31b6ea487a18f264b3a9288dd3/test/models/order.rb | test/models/order.rb | # 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... | ruby | MIT | d3d3f8a130ed8c31b6ea487a18f264b3a9288dd3 | 2026-01-04T15:47:04.039287Z | false |
zdennis/activerecord-import | https://github.com/zdennis/activerecord-import/blob/d3d3f8a130ed8c31b6ea487a18f264b3a9288dd3/test/models/card.rb | test/models/card.rb | # frozen_string_literal: true
class Card < ActiveRecord::Base
belongs_to :deck, polymorphic: true
end
| ruby | MIT | d3d3f8a130ed8c31b6ea487a18f264b3a9288dd3 | 2026-01-04T15:47:04.039287Z | false |
zdennis/activerecord-import | https://github.com/zdennis/activerecord-import/blob/d3d3f8a130ed8c31b6ea487a18f264b3a9288dd3/test/models/group.rb | test/models/group.rb | # frozen_string_literal: true
class Group < ActiveRecord::Base
self.table_name = 'group'
end
| ruby | MIT | d3d3f8a130ed8c31b6ea487a18f264b3a9288dd3 | 2026-01-04T15:47:04.039287Z | false |
zdennis/activerecord-import | https://github.com/zdennis/activerecord-import/blob/d3d3f8a130ed8c31b6ea487a18f264b3a9288dd3/test/models/promotion.rb | test/models/promotion.rb | # frozen_string_literal: true
class Promotion < ActiveRecord::Base
self.primary_key = :promotion_id
end
| ruby | MIT | d3d3f8a130ed8c31b6ea487a18f264b3a9288dd3 | 2026-01-04T15:47:04.039287Z | false |
zdennis/activerecord-import | https://github.com/zdennis/activerecord-import/blob/d3d3f8a130ed8c31b6ea487a18f264b3a9288dd3/test/models/customer.rb | test/models/customer.rb | # 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... | ruby | MIT | d3d3f8a130ed8c31b6ea487a18f264b3a9288dd3 | 2026-01-04T15:47:04.039287Z | false |
zdennis/activerecord-import | https://github.com/zdennis/activerecord-import/blob/d3d3f8a130ed8c31b6ea487a18f264b3a9288dd3/test/models/topic.rb | test/models/topic.rb | # 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... | ruby | MIT | d3d3f8a130ed8c31b6ea487a18f264b3a9288dd3 | 2026-01-04T15:47:04.039287Z | false |
zdennis/activerecord-import | https://github.com/zdennis/activerecord-import/blob/d3d3f8a130ed8c31b6ea487a18f264b3a9288dd3/test/models/account.rb | test/models/account.rb | # frozen_string_literal: true
class Account < ActiveRecord::Base
self.locking_column = :lock
end
| ruby | MIT | d3d3f8a130ed8c31b6ea487a18f264b3a9288dd3 | 2026-01-04T15:47:04.039287Z | false |
zdennis/activerecord-import | https://github.com/zdennis/activerecord-import/blob/d3d3f8a130ed8c31b6ea487a18f264b3a9288dd3/test/models/composite_chapter.rb | test/models/composite_chapter.rb | # 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... | ruby | MIT | d3d3f8a130ed8c31b6ea487a18f264b3a9288dd3 | 2026-01-04T15:47:04.039287Z | false |
zdennis/activerecord-import | https://github.com/zdennis/activerecord-import/blob/d3d3f8a130ed8c31b6ea487a18f264b3a9288dd3/test/models/animal.rb | test/models/animal.rb | # 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
| ruby | MIT | d3d3f8a130ed8c31b6ea487a18f264b3a9288dd3 | 2026-01-04T15:47:04.039287Z | false |
zdennis/activerecord-import | https://github.com/zdennis/activerecord-import/blob/d3d3f8a130ed8c31b6ea487a18f264b3a9288dd3/test/models/end_note.rb | test/models/end_note.rb | # frozen_string_literal: true
class EndNote < ActiveRecord::Base
belongs_to :book, inverse_of: :end_notes
validates :note, presence: true
end
| ruby | MIT | d3d3f8a130ed8c31b6ea487a18f264b3a9288dd3 | 2026-01-04T15:47:04.039287Z | false |
zdennis/activerecord-import | https://github.com/zdennis/activerecord-import/blob/d3d3f8a130ed8c31b6ea487a18f264b3a9288dd3/test/models/alarm.rb | test/models/alarm.rb | # frozen_string_literal: true
class Alarm < ActiveRecord::Base
end
| ruby | MIT | d3d3f8a130ed8c31b6ea487a18f264b3a9288dd3 | 2026-01-04T15:47:04.039287Z | false |
zdennis/activerecord-import | https://github.com/zdennis/activerecord-import/blob/d3d3f8a130ed8c31b6ea487a18f264b3a9288dd3/test/models/playing_card.rb | test/models/playing_card.rb | # frozen_string_literal: true
class PlayingCard < ActiveRecord::Base
end
| ruby | MIT | d3d3f8a130ed8c31b6ea487a18f264b3a9288dd3 | 2026-01-04T15:47:04.039287Z | false |
zdennis/activerecord-import | https://github.com/zdennis/activerecord-import/blob/d3d3f8a130ed8c31b6ea487a18f264b3a9288dd3/test/models/discount.rb | test/models/discount.rb | # frozen_string_literal: true
class Discount < ActiveRecord::Base
belongs_to :discountable, polymorphic: true
end
| ruby | MIT | d3d3f8a130ed8c31b6ea487a18f264b3a9288dd3 | 2026-01-04T15:47:04.039287Z | false |
zdennis/activerecord-import | https://github.com/zdennis/activerecord-import/blob/d3d3f8a130ed8c31b6ea487a18f264b3a9288dd3/test/models/author.rb | test/models/author.rb | # 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
| ruby | MIT | d3d3f8a130ed8c31b6ea487a18f264b3a9288dd3 | 2026-01-04T15:47:04.039287Z | false |
zdennis/activerecord-import | https://github.com/zdennis/activerecord-import/blob/d3d3f8a130ed8c31b6ea487a18f264b3a9288dd3/test/models/composite_book.rb | test/models/composite_book.rb | # 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,
... | ruby | MIT | d3d3f8a130ed8c31b6ea487a18f264b3a9288dd3 | 2026-01-04T15:47:04.039287Z | false |
zdennis/activerecord-import | https://github.com/zdennis/activerecord-import/blob/d3d3f8a130ed8c31b6ea487a18f264b3a9288dd3/test/models/bike_maker.rb | test/models/bike_maker.rb | # frozen_string_literal: true
module Bike
def self.table_name_prefix
'bike_'
end
class Maker < ActiveRecord::Base
end
end
| ruby | MIT | d3d3f8a130ed8c31b6ea487a18f264b3a9288dd3 | 2026-01-04T15:47:04.039287Z | false |
zdennis/activerecord-import | https://github.com/zdennis/activerecord-import/blob/d3d3f8a130ed8c31b6ea487a18f264b3a9288dd3/test/models/dictionary.rb | test/models/dictionary.rb | # frozen_string_literal: true
require_relative 'book'
class Dictionary < Book
end
| ruby | MIT | d3d3f8a130ed8c31b6ea487a18f264b3a9288dd3 | 2026-01-04T15:47:04.039287Z | false |
zdennis/activerecord-import | https://github.com/zdennis/activerecord-import/blob/d3d3f8a130ed8c31b6ea487a18f264b3a9288dd3/test/models/user_token.rb | test/models/user_token.rb | # frozen_string_literal: true
class UserToken < ActiveRecord::Base
belongs_to :user, primary_key: :name, foreign_key: :user_name
validates :user, presence: true
end
| ruby | MIT | d3d3f8a130ed8c31b6ea487a18f264b3a9288dd3 | 2026-01-04T15:47:04.039287Z | false |
zdennis/activerecord-import | https://github.com/zdennis/activerecord-import/blob/d3d3f8a130ed8c31b6ea487a18f264b3a9288dd3/test/models/car.rb | test/models/car.rb | # frozen_string_literal: true
class Car < ActiveRecord::Base
self.primary_key = :Name
end
| ruby | MIT | d3d3f8a130ed8c31b6ea487a18f264b3a9288dd3 | 2026-01-04T15:47:04.039287Z | false |
zdennis/activerecord-import | https://github.com/zdennis/activerecord-import/blob/d3d3f8a130ed8c31b6ea487a18f264b3a9288dd3/test/models/question.rb | test/models/question.rb | # frozen_string_literal: true
class Question < ActiveRecord::Base
has_one :rule
end
| ruby | MIT | d3d3f8a130ed8c31b6ea487a18f264b3a9288dd3 | 2026-01-04T15:47:04.039287Z | false |
zdennis/activerecord-import | https://github.com/zdennis/activerecord-import/blob/d3d3f8a130ed8c31b6ea487a18f264b3a9288dd3/test/models/widget.rb | test/models/widget.rb | # 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'].... | ruby | MIT | d3d3f8a130ed8c31b6ea487a18f264b3a9288dd3 | 2026-01-04T15:47:04.039287Z | false |
zdennis/activerecord-import | https://github.com/zdennis/activerecord-import/blob/d3d3f8a130ed8c31b6ea487a18f264b3a9288dd3/test/models/rule.rb | test/models/rule.rb | # frozen_string_literal: true
class Rule < ActiveRecord::Base
belongs_to :question
end
| ruby | MIT | d3d3f8a130ed8c31b6ea487a18f264b3a9288dd3 | 2026-01-04T15:47:04.039287Z | false |
zdennis/activerecord-import | https://github.com/zdennis/activerecord-import/blob/d3d3f8a130ed8c31b6ea487a18f264b3a9288dd3/test/models/deck.rb | test/models/deck.rb | # frozen_string_literal: true
class Deck < ActiveRecord::Base
has_many :cards
def self.polymorphic_name
"PlayingCard"
end
end
| ruby | MIT | d3d3f8a130ed8c31b6ea487a18f264b3a9288dd3 | 2026-01-04T15:47:04.039287Z | false |
zdennis/activerecord-import | https://github.com/zdennis/activerecord-import/blob/d3d3f8a130ed8c31b6ea487a18f264b3a9288dd3/test/models/tag_alias.rb | test/models/tag_alias.rb | # 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... | ruby | MIT | d3d3f8a130ed8c31b6ea487a18f264b3a9288dd3 | 2026-01-04T15:47:04.039287Z | false |
zdennis/activerecord-import | https://github.com/zdennis/activerecord-import/blob/d3d3f8a130ed8c31b6ea487a18f264b3a9288dd3/test/models/user.rb | test/models/user.rb | # frozen_string_literal: true
class User < ActiveRecord::Base
has_many :user_tokens, primary_key: :name, foreign_key: :user_name
end
| ruby | MIT | d3d3f8a130ed8c31b6ea487a18f264b3a9288dd3 | 2026-01-04T15:47:04.039287Z | false |
zdennis/activerecord-import | https://github.com/zdennis/activerecord-import/blob/d3d3f8a130ed8c31b6ea487a18f264b3a9288dd3/test/sqlite3/import_test.rb | test/sqlite3/import_test.rb | # 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
| ruby | MIT | d3d3f8a130ed8c31b6ea487a18f264b3a9288dd3 | 2026-01-04T15:47:04.039287Z | false |
zdennis/activerecord-import | https://github.com/zdennis/activerecord-import/blob/d3d3f8a130ed8c31b6ea487a18f264b3a9288dd3/test/janus_mysql2/import_test.rb | test/janus_mysql2/import_test.rb | # 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
| ruby | MIT | d3d3f8a130ed8c31b6ea487a18f264b3a9288dd3 | 2026-01-04T15:47:04.039287Z | false |
zdennis/activerecord-import | https://github.com/zdennis/activerecord-import/blob/d3d3f8a130ed8c31b6ea487a18f264b3a9288dd3/test/mysqlspatial2/import_test.rb | test/mysqlspatial2/import_test.rb | # 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
| ruby | MIT | d3d3f8a130ed8c31b6ea487a18f264b3a9288dd3 | 2026-01-04T15:47:04.039287Z | false |
zdennis/activerecord-import | https://github.com/zdennis/activerecord-import/blob/d3d3f8a130ed8c31b6ea487a18f264b3a9288dd3/test/jdbcsqlite3/import_test.rb | test/jdbcsqlite3/import_test.rb | # 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
| ruby | MIT | d3d3f8a130ed8c31b6ea487a18f264b3a9288dd3 | 2026-01-04T15:47:04.039287Z | false |
zdennis/activerecord-import | https://github.com/zdennis/activerecord-import/blob/d3d3f8a130ed8c31b6ea487a18f264b3a9288dd3/test/mysql2/import_test.rb | test/mysql2/import_test.rb | # 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
| ruby | MIT | d3d3f8a130ed8c31b6ea487a18f264b3a9288dd3 | 2026-01-04T15:47:04.039287Z | false |
zdennis/activerecord-import | https://github.com/zdennis/activerecord-import/blob/d3d3f8a130ed8c31b6ea487a18f264b3a9288dd3/test/adapters/mysql2_proxy.rb | test/adapters/mysql2_proxy.rb | # frozen_string_literal: true
ENV["ARE_DB"] = "mysql2"
| ruby | MIT | d3d3f8a130ed8c31b6ea487a18f264b3a9288dd3 | 2026-01-04T15:47:04.039287Z | false |
zdennis/activerecord-import | https://github.com/zdennis/activerecord-import/blob/d3d3f8a130ed8c31b6ea487a18f264b3a9288dd3/test/adapters/makara_postgis.rb | test/adapters/makara_postgis.rb | # frozen_string_literal: true
ENV["ARE_DB"] = "postgis"
| ruby | MIT | d3d3f8a130ed8c31b6ea487a18f264b3a9288dd3 | 2026-01-04T15:47:04.039287Z | false |
zdennis/activerecord-import | https://github.com/zdennis/activerecord-import/blob/d3d3f8a130ed8c31b6ea487a18f264b3a9288dd3/test/adapters/jdbcpostgresql.rb | test/adapters/jdbcpostgresql.rb | # frozen_string_literal: true
ENV["ARE_DB"] = "jdbcpostgresql"
| ruby | MIT | d3d3f8a130ed8c31b6ea487a18f264b3a9288dd3 | 2026-01-04T15:47:04.039287Z | false |
zdennis/activerecord-import | https://github.com/zdennis/activerecord-import/blob/d3d3f8a130ed8c31b6ea487a18f264b3a9288dd3/test/adapters/spatialite.rb | test/adapters/spatialite.rb | # frozen_string_literal: true
ENV["ARE_DB"] = "spatialite"
| ruby | MIT | d3d3f8a130ed8c31b6ea487a18f264b3a9288dd3 | 2026-01-04T15:47:04.039287Z | false |
zdennis/activerecord-import | https://github.com/zdennis/activerecord-import/blob/d3d3f8a130ed8c31b6ea487a18f264b3a9288dd3/test/adapters/jdbcsqlite3.rb | test/adapters/jdbcsqlite3.rb | # frozen_string_literal: true
ENV["ARE_DB"] = "jdbcsqlite3"
| ruby | MIT | d3d3f8a130ed8c31b6ea487a18f264b3a9288dd3 | 2026-01-04T15:47:04.039287Z | false |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.