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
que-rb/que
https://github.com/que-rb/que/blob/caa8b25cdd9da7fa74d27532ad6acf0a8c23f115/spec/que/active_record/connection_spec.rb
spec/que/active_record/connection_spec.rb
# frozen_string_literal: true require 'spec_helper' if defined?(::ActiveRecord) describe Que::ActiveRecord::Connection do it "should use Rails.application.executor.wrap, if it exists, when checking out connections" do # This is a hacky spec, but it's better than requiring Rails. called = false ...
ruby
MIT
caa8b25cdd9da7fa74d27532ad6acf0a8c23f115
2026-01-04T15:56:36.969030Z
false
que-rb/que
https://github.com/que-rb/que/blob/caa8b25cdd9da7fa74d27532ad6acf0a8c23f115/spec/que/active_job/extensions.job_extensions_spec.rb
spec/que/active_job/extensions.job_extensions_spec.rb
# frozen_string_literal: true require 'spec_helper' if defined?(::ActiveJob) describe Que::ActiveJob::JobExtensions do describe "when used with a non-Que job queue" do before do class ApplicationJob < ActiveJob::Base include Que::ActiveJob::JobExtensions end class TestJo...
ruby
MIT
caa8b25cdd9da7fa74d27532ad6acf0a8c23f115
2026-01-04T15:56:36.969030Z
false
que-rb/que
https://github.com/que-rb/que/blob/caa8b25cdd9da7fa74d27532ad6acf0a8c23f115/spec/que/active_job/extensions_spec.rb
spec/que/active_job/extensions_spec.rb
# frozen_string_literal: true require 'spec_helper' if defined?(::ActiveJob) describe "running jobs via ActiveJob" do before do class TestJobClass < ActiveJob::Base def perform(*args, **kwargs) $args = args $kwargs = kwargs end end end after do Obje...
ruby
MIT
caa8b25cdd9da7fa74d27532ad6acf0a8c23f115
2026-01-04T15:56:36.969030Z
false
que-rb/que
https://github.com/que-rb/que/blob/caa8b25cdd9da7fa74d27532ad6acf0a8c23f115/lib/que.rb
lib/que.rb
# frozen_string_literal: true require 'forwardable' require 'socket' # For Socket.gethostname module Que CURRENT_HOSTNAME = Socket.gethostname.freeze DEFAULT_QUEUE = 'default'.freeze TIME_REGEX = /\A\d{4}\-\d{2}\-\d{2}T\d{2}:\d{2}:\d{2}.\d{6}Z\z/ CONFIG_MUTEX = Mutex.new MAXIMUM_PRIORITY = 3276...
ruby
MIT
caa8b25cdd9da7fa74d27532ad6acf0a8c23f115
2026-01-04T15:56:36.969030Z
false
que-rb/que
https://github.com/que-rb/que/blob/caa8b25cdd9da7fa74d27532ad6acf0a8c23f115/lib/que/version.rb
lib/que/version.rb
# frozen_string_literal: true module Que VERSION = '2.4.1' def self.job_schema_version 2 end end
ruby
MIT
caa8b25cdd9da7fa74d27532ad6acf0a8c23f115
2026-01-04T15:56:36.969030Z
false
que-rb/que
https://github.com/que-rb/que/blob/caa8b25cdd9da7fa74d27532ad6acf0a8c23f115/lib/que/command_line_interface.rb
lib/que/command_line_interface.rb
# frozen_string_literal: true require 'optparse' require 'logger' require 'uri' module Que module CommandLineInterface # Have a sensible default require file for Rails. RAILS_ENVIRONMENT_FILE = './config/environment.rb' class << self # Need to rely on dependency injection a bit to make this metho...
ruby
MIT
caa8b25cdd9da7fa74d27532ad6acf0a8c23f115
2026-01-04T15:56:36.969030Z
false
que-rb/que
https://github.com/que-rb/que/blob/caa8b25cdd9da7fa74d27532ad6acf0a8c23f115/lib/que/locker.rb
lib/que/locker.rb
# frozen_string_literal: true # The Locker class encapsulates a thread that is listening/polling for new # jobs in the DB, locking them, passing their primary keys to workers, then # cleaning up by unlocking them once the workers are done. require 'set' module Que class << self attr_accessor :locker end L...
ruby
MIT
caa8b25cdd9da7fa74d27532ad6acf0a8c23f115
2026-01-04T15:56:36.969030Z
false
que-rb/que
https://github.com/que-rb/que/blob/caa8b25cdd9da7fa74d27532ad6acf0a8c23f115/lib/que/poller.rb
lib/que/poller.rb
# frozen_string_literal: true module Que class Poller # The following SQL statement locks a batch of jobs using a Postgres # recursive CTE [1]. # # As noted by the Postgres documentation, it may be slightly easier to # think about this expression as iteration rather than recursion, despite # ...
ruby
MIT
caa8b25cdd9da7fa74d27532ad6acf0a8c23f115
2026-01-04T15:56:36.969030Z
false
que-rb/que
https://github.com/que-rb/que/blob/caa8b25cdd9da7fa74d27532ad6acf0a8c23f115/lib/que/job_buffer.rb
lib/que/job_buffer.rb
# frozen_string_literal: true # A sized thread-safe queue that holds ordered job sort_keys. Supports blocking # while waiting for a job to become available, only returning jobs over a # minimum priority, and stopping gracefully. module Que class JobBuffer attr_reader :maximum_size, :priority_queues # Since...
ruby
MIT
caa8b25cdd9da7fa74d27532ad6acf0a8c23f115
2026-01-04T15:56:36.969030Z
false
que-rb/que
https://github.com/que-rb/que/blob/caa8b25cdd9da7fa74d27532ad6acf0a8c23f115/lib/que/metajob.rb
lib/que/metajob.rb
# frozen_string_literal: true # A thin wrapper around a job's data that lets us do things like sort easily and # make sure that run_at is in the format we want. module Que class Metajob SORT_KEYS = [:priority, :run_at, :id].freeze attr_reader :job def initialize(job) set_job(job) end de...
ruby
MIT
caa8b25cdd9da7fa74d27532ad6acf0a8c23f115
2026-01-04T15:56:36.969030Z
false
que-rb/que
https://github.com/que-rb/que/blob/caa8b25cdd9da7fa74d27532ad6acf0a8c23f115/lib/que/result_queue.rb
lib/que/result_queue.rb
# frozen_string_literal: true # A thread-safe queue that holds ids for jobs that have been worked. Allows # appending single/retrieving all ids in a thread-safe fashion. module Que class ResultQueue def initialize @array = [] @mutex = Mutex.new end def push(item) sync { @array.push(it...
ruby
MIT
caa8b25cdd9da7fa74d27532ad6acf0a8c23f115
2026-01-04T15:56:36.969030Z
false
que-rb/que
https://github.com/que-rb/que/blob/caa8b25cdd9da7fa74d27532ad6acf0a8c23f115/lib/que/connection_pool.rb
lib/que/connection_pool.rb
# frozen_string_literal: true # A wrapper around whatever connection pool we're using. Mainly just asserts # that the source connection pool is reentrant and thread-safe. module Que class ConnectionPool def initialize(&block) @connection_proc = block @checked_out = Set.new @mutex ...
ruby
MIT
caa8b25cdd9da7fa74d27532ad6acf0a8c23f115
2026-01-04T15:56:36.969030Z
false
que-rb/que
https://github.com/que-rb/que/blob/caa8b25cdd9da7fa74d27532ad6acf0a8c23f115/lib/que/connection.rb
lib/que/connection.rb
# frozen_string_literal: true # A simple wrapper class around connections that basically just improves the # query API a bit. Currently, our connection pool wrapper discards these # connection wrappers once the connection is returned to the source connection # pool, so this class isn't currently suitable for storing d...
ruby
MIT
caa8b25cdd9da7fa74d27532ad6acf0a8c23f115
2026-01-04T15:56:36.969030Z
false
que-rb/que
https://github.com/que-rb/que/blob/caa8b25cdd9da7fa74d27532ad6acf0a8c23f115/lib/que/migrations.rb
lib/que/migrations.rb
# frozen_string_literal: true module Que module Migrations # In order to ship a schema change, add the relevant up and down sql files # to the migrations directory, and bump the version here. CURRENT_VERSION = 7 class << self def migrate!(version:) Que.transaction do current ...
ruby
MIT
caa8b25cdd9da7fa74d27532ad6acf0a8c23f115
2026-01-04T15:56:36.969030Z
false
que-rb/que
https://github.com/que-rb/que/blob/caa8b25cdd9da7fa74d27532ad6acf0a8c23f115/lib/que/job_methods.rb
lib/que/job_methods.rb
# frozen_string_literal: true module Que SQL[:finish_job] = %{ UPDATE public.que_jobs SET finished_at = now() WHERE id = $1::bigint } SQL[:expire_job] = %{ UPDATE public.que_jobs SET error_count = error_count + 1, expired_at = now() WHERE id = $1::bigint ...
ruby
MIT
caa8b25cdd9da7fa74d27532ad6acf0a8c23f115
2026-01-04T15:56:36.969030Z
false
que-rb/que
https://github.com/que-rb/que/blob/caa8b25cdd9da7fa74d27532ad6acf0a8c23f115/lib/que/worker.rb
lib/que/worker.rb
# frozen_string_literal: true # Workers wrap threads which continuously pull job pks from JobBuffer objects, # fetch and work those jobs, and export relevant data to ResultQueues. require 'set' module Que class Worker attr_reader :thread, :priority VALID_LOG_LEVELS = [:debug, :info, :warn, :error, :fatal,...
ruby
MIT
caa8b25cdd9da7fa74d27532ad6acf0a8c23f115
2026-01-04T15:56:36.969030Z
false
que-rb/que
https://github.com/que-rb/que/blob/caa8b25cdd9da7fa74d27532ad6acf0a8c23f115/lib/que/job.rb
lib/que/job.rb
# frozen_string_literal: true # The class that jobs should generally inherit from. module Que class Job include JobMethods MAXIMUM_TAGS_COUNT = 5 MAXIMUM_TAG_LENGTH = 100 SQL[:insert_job] = %{ INSERT INTO public.que_jobs (queue, priority, run_at, job_class, args, kwargs, data...
ruby
MIT
caa8b25cdd9da7fa74d27532ad6acf0a8c23f115
2026-01-04T15:56:36.969030Z
false
que-rb/que
https://github.com/que-rb/que/blob/caa8b25cdd9da7fa74d27532ad6acf0a8c23f115/lib/que/listener.rb
lib/que/listener.rb
# frozen_string_literal: true module Que class Listener MESSAGE_FORMATS = {} attr_reader :connection, :channel def initialize(connection:, channel: nil) @connection = connection @channel = channel || "que_listener_#{connection.backend_pid}" Que.internal_log :listener_instantiate, ...
ruby
MIT
caa8b25cdd9da7fa74d27532ad6acf0a8c23f115
2026-01-04T15:56:36.969030Z
false
que-rb/que
https://github.com/que-rb/que/blob/caa8b25cdd9da7fa74d27532ad6acf0a8c23f115/lib/que/rails/railtie.rb
lib/que/rails/railtie.rb
# frozen_string_literal: true module Que module Rails class Railtie < ::Rails::Railtie config.que = Que Que.logger = proc { ::Rails.logger } Que.connection = ::ActiveRecord if defined? ::ActiveRecord end end end
ruby
MIT
caa8b25cdd9da7fa74d27532ad6acf0a8c23f115
2026-01-04T15:56:36.969030Z
false
que-rb/que
https://github.com/que-rb/que/blob/caa8b25cdd9da7fa74d27532ad6acf0a8c23f115/lib/que/sequel/model.rb
lib/que/sequel/model.rb
# frozen_string_literal: true ::Sequel.extension :pg_json_ops module Que module Sequel QUALIFIED_TABLE = ::Sequel.qualify(:public, :que_jobs) class Model < ::Sequel::Model(QUALIFIED_TABLE) dataset_module do conditions = { errored: QUALIFIED_TABLE[:error_count] > 0, expir...
ruby
MIT
caa8b25cdd9da7fa74d27532ad6acf0a8c23f115
2026-01-04T15:56:36.969030Z
false
que-rb/que
https://github.com/que-rb/que/blob/caa8b25cdd9da7fa74d27532ad6acf0a8c23f115/lib/que/utils/error_notification.rb
lib/que/utils/error_notification.rb
# frozen_string_literal: true module Que module Utils module ErrorNotification attr_accessor :error_notifier def notify_error(*args) Que.internal_log(:error_notification_attempted) do {args: args.inspect} end if notifier = error_notifier arity = notifier....
ruby
MIT
caa8b25cdd9da7fa74d27532ad6acf0a8c23f115
2026-01-04T15:56:36.969030Z
false
que-rb/que
https://github.com/que-rb/que/blob/caa8b25cdd9da7fa74d27532ad6acf0a8c23f115/lib/que/utils/constantization.rb
lib/que/utils/constantization.rb
# frozen_string_literal: true module Que module Utils module Constantization def constantize(string) Que.assert String, string if string.respond_to?(:constantize) string.constantize else names = string.split('::') names.reject!(&:empty?) name...
ruby
MIT
caa8b25cdd9da7fa74d27532ad6acf0a8c23f115
2026-01-04T15:56:36.969030Z
false
que-rb/que
https://github.com/que-rb/que/blob/caa8b25cdd9da7fa74d27532ad6acf0a8c23f115/lib/que/utils/assertions.rb
lib/que/utils/assertions.rb
# frozen_string_literal: true # Assertion helpers. Que has a fair amount of internal state, and there's no # telling what users will try to throw at it, so for ease of debugging issues it # makes sense to sanity-check frequently. module Que module Utils module Assertions class AssertionFailed < Error; end...
ruby
MIT
caa8b25cdd9da7fa74d27532ad6acf0a8c23f115
2026-01-04T15:56:36.969030Z
false
que-rb/que
https://github.com/que-rb/que/blob/caa8b25cdd9da7fa74d27532ad6acf0a8c23f115/lib/que/utils/middleware.rb
lib/que/utils/middleware.rb
# frozen_string_literal: true # Logic for middleware to wrap jobs. module Que module Utils module Middleware TYPES = [ :job, :sql, ].freeze TYPES.each do |type| module_eval <<-CODE def #{type}_middleware @#{type}_middleware ||= [] end ...
ruby
MIT
caa8b25cdd9da7fa74d27532ad6acf0a8c23f115
2026-01-04T15:56:36.969030Z
false
que-rb/que
https://github.com/que-rb/que/blob/caa8b25cdd9da7fa74d27532ad6acf0a8c23f115/lib/que/utils/ruby2_keywords.rb
lib/que/utils/ruby2_keywords.rb
# frozen_string_literal: true # Temporary module allowing ruby2 keyword args to be extracted from an *args splat # Allows us to ensure consistent behaviour when running on ruby 2 vs ruby 3 # We can remove this if/when we drop support for ruby 2 require 'json' module Que module Utils module Ruby2Keywords ...
ruby
MIT
caa8b25cdd9da7fa74d27532ad6acf0a8c23f115
2026-01-04T15:56:36.969030Z
false
que-rb/que
https://github.com/que-rb/que/blob/caa8b25cdd9da7fa74d27532ad6acf0a8c23f115/lib/que/utils/logging.rb
lib/que/utils/logging.rb
# frozen_string_literal: true # Tools for logging from Que. module Que module Utils module Logging attr_accessor :logger, :internal_logger attr_writer :log_formatter def log(event:, level: :info, **extra) data = _default_log_data data[:event] = Que.assert(Symbol, event) ...
ruby
MIT
caa8b25cdd9da7fa74d27532ad6acf0a8c23f115
2026-01-04T15:56:36.969030Z
false
que-rb/que
https://github.com/que-rb/que/blob/caa8b25cdd9da7fa74d27532ad6acf0a8c23f115/lib/que/utils/queue_management.rb
lib/que/utils/queue_management.rb
# frozen_string_literal: true # Tools for managing the contents/state of the queue. module Que module Utils module QueueManagement def clear! execute "DELETE FROM que_jobs" end # Very old migrations may use Que.create! and Que.drop!, which just # created and dropped the initial ...
ruby
MIT
caa8b25cdd9da7fa74d27532ad6acf0a8c23f115
2026-01-04T15:56:36.969030Z
false
que-rb/que
https://github.com/que-rb/que/blob/caa8b25cdd9da7fa74d27532ad6acf0a8c23f115/lib/que/utils/freeze.rb
lib/que/utils/freeze.rb
# frozen_string_literal: true # Helper method for recursively freezing a data structure. module Que module Utils module Freeze def recursively_freeze(thing) case thing when Array thing.each { |e| recursively_freeze(e) } when Hash thing.each { |k, v| recursively_...
ruby
MIT
caa8b25cdd9da7fa74d27532ad6acf0a8c23f115
2026-01-04T15:56:36.969030Z
false
que-rb/que
https://github.com/que-rb/que/blob/caa8b25cdd9da7fa74d27532ad6acf0a8c23f115/lib/que/utils/introspection.rb
lib/que/utils/introspection.rb
# frozen_string_literal: true # Tools for introspecting the state of the job queue. module Que module Utils module Introspection SQL[:job_stats] = %{ SELECT job_class, count(*) AS count, count(locks.id) AS count_working, ...
ruby
MIT
caa8b25cdd9da7fa74d27532ad6acf0a8c23f115
2026-01-04T15:56:36.969030Z
false
que-rb/que
https://github.com/que-rb/que/blob/caa8b25cdd9da7fa74d27532ad6acf0a8c23f115/lib/que/utils/transactions.rb
lib/que/utils/transactions.rb
# frozen_string_literal: true # A helper method to manage transactions, used mainly by the migration system. # It's available for general use, but if you're using an ORM that provides its # own transaction helper, be sure to use that instead, or the two may interfere # with one another. module Que module Utils ...
ruby
MIT
caa8b25cdd9da7fa74d27532ad6acf0a8c23f115
2026-01-04T15:56:36.969030Z
false
que-rb/que
https://github.com/que-rb/que/blob/caa8b25cdd9da7fa74d27532ad6acf0a8c23f115/lib/que/utils/json_serialization.rb
lib/que/utils/json_serialization.rb
# frozen_string_literal: true # Logic for serializing to/from JSON. We assume that the standard library's JSON # module is good enough for our purposes. require 'json' module Que module Utils module JSONSerialization def serialize_json(object) JSON.dump(object) end def deserialize_js...
ruby
MIT
caa8b25cdd9da7fa74d27532ad6acf0a8c23f115
2026-01-04T15:56:36.969030Z
false
que-rb/que
https://github.com/que-rb/que/blob/caa8b25cdd9da7fa74d27532ad6acf0a8c23f115/lib/que/active_record/connection.rb
lib/que/active_record/connection.rb
# frozen_string_literal: true module Que module ActiveRecord module Connection class << self private # Check out a PG::Connection object from ActiveRecord's pool. def checkout wrap_in_rails_executor do ::ActiveRecord::Base.connection_pool.with_connection do |c...
ruby
MIT
caa8b25cdd9da7fa74d27532ad6acf0a8c23f115
2026-01-04T15:56:36.969030Z
false
que-rb/que
https://github.com/que-rb/que/blob/caa8b25cdd9da7fa74d27532ad6acf0a8c23f115/lib/que/active_record/model.rb
lib/que/active_record/model.rb
# frozen_string_literal: true module Que module ActiveRecord class Model < ::ActiveRecord::Base self.table_name = 'public.que_jobs' t = arel_table scope :errored, -> { where(t[:error_count].gt(0)) } scope :not_errored, -> { where(t[:error_count].eq(0)) } scope :expired, -...
ruby
MIT
caa8b25cdd9da7fa74d27532ad6acf0a8c23f115
2026-01-04T15:56:36.969030Z
false
que-rb/que
https://github.com/que-rb/que/blob/caa8b25cdd9da7fa74d27532ad6acf0a8c23f115/lib/que/active_job/extensions.rb
lib/que/active_job/extensions.rb
# frozen_string_literal: true module Que module ActiveJob # A module that devs can include into their ApplicationJob classes to get # access to Que-like job behavior. module JobExtensions include JobMethods def run(*args) raise Error, "Job class #{self.class} didn't define a run() me...
ruby
MIT
caa8b25cdd9da7fa74d27532ad6acf0a8c23f115
2026-01-04T15:56:36.969030Z
false
brianmario/mysql2
https://github.com/brianmario/mysql2/blob/b009d7e114729cbae5bef069a1033dd78acf7745/support/ruby_enc_to_mysql.rb
support/ruby_enc_to_mysql.rb
mysql_to_rb = { "big5" => "Big5", "dec8" => nil, "cp850" => "CP850", "hp8" => nil, "koi8r" => "KOI8-R", "latin1" => "ISO-8859-1", "latin2" => "ISO-8859-2", "swe7" => nil, "ascii" => "US-ASCII", "ujis" => "eucJP-ms", "sjis" => "Shift_JIS", "hebrew" => "ISO-...
ruby
MIT
b009d7e114729cbae5bef069a1033dd78acf7745
2026-01-04T15:56:41.499629Z
false
brianmario/mysql2
https://github.com/brianmario/mysql2/blob/b009d7e114729cbae5bef069a1033dd78acf7745/support/mysql_enc_to_ruby.rb
support/mysql_enc_to_ruby.rb
$LOAD_PATH.unshift File.expand_path('../../lib', __FILE__) require 'mysql2' user, pass, host, port = ENV.values_at('user', 'pass', 'host', 'port') mysql_to_rb = { "big5" => "Big5", "dec8" => "NULL", "cp850" => "CP850", "hp8" => "NULL", "koi8r" => "KOI8-R", "latin1" => "ISO-8859-1", ...
ruby
MIT
b009d7e114729cbae5bef069a1033dd78acf7745
2026-01-04T15:56:41.499629Z
false
brianmario/mysql2
https://github.com/brianmario/mysql2/blob/b009d7e114729cbae5bef069a1033dd78acf7745/benchmark/active_record.rb
benchmark/active_record.rb
$LOAD_PATH.unshift File.expand_path(File.dirname(__FILE__) + '/../lib') require 'rubygems' require 'benchmark/ips' require 'active_record' ActiveRecord::Base.default_timezone = :local ActiveRecord::Base.time_zone_aware_attributes = true opts = { database: 'test' } class TestModel < ActiveRecord::Base self.table_n...
ruby
MIT
b009d7e114729cbae5bef069a1033dd78acf7745
2026-01-04T15:56:41.499629Z
false
brianmario/mysql2
https://github.com/brianmario/mysql2/blob/b009d7e114729cbae5bef069a1033dd78acf7745/benchmark/allocations.rb
benchmark/allocations.rb
$LOAD_PATH.unshift File.expand_path(File.dirname(__FILE__) + '/../lib') require 'rubygems' require 'active_record' ActiveRecord::Base.default_timezone = :local ActiveRecord::Base.time_zone_aware_attributes = true class TestModel < ActiveRecord::Base self.table_name = 'mysql2_test' end def bench_allocations(featur...
ruby
MIT
b009d7e114729cbae5bef069a1033dd78acf7745
2026-01-04T15:56:41.499629Z
false
brianmario/mysql2
https://github.com/brianmario/mysql2/blob/b009d7e114729cbae5bef069a1033dd78acf7745/benchmark/sequel.rb
benchmark/sequel.rb
$LOAD_PATH.unshift File.expand_path(File.dirname(__FILE__) + '/../lib') require 'rubygems' require 'benchmark/ips' require 'mysql2' require 'sequel' require 'sequel/adapters/do' mysql2_opts = "mysql2://root@localhost/test" mysql_opts = "mysql://root@localhost/test" do_mysql_opts = "do:mysql://root@localhost/test" cl...
ruby
MIT
b009d7e114729cbae5bef069a1033dd78acf7745
2026-01-04T15:56:41.499629Z
false
brianmario/mysql2
https://github.com/brianmario/mysql2/blob/b009d7e114729cbae5bef069a1033dd78acf7745/benchmark/query_with_mysql_casting.rb
benchmark/query_with_mysql_casting.rb
$LOAD_PATH.unshift File.expand_path(File.dirname(__FILE__) + '/../lib') require 'rubygems' require 'benchmark/ips' require 'mysql' require 'mysql2' require 'do_mysql' database = 'test' sql = "SELECT * FROM mysql2_test LIMIT 100" class Mysql include Enumerable end def mysql_cast(type, value) case type when Mys...
ruby
MIT
b009d7e114729cbae5bef069a1033dd78acf7745
2026-01-04T15:56:41.499629Z
false
brianmario/mysql2
https://github.com/brianmario/mysql2/blob/b009d7e114729cbae5bef069a1033dd78acf7745/benchmark/active_record_threaded.rb
benchmark/active_record_threaded.rb
$LOAD_PATH.unshift File.expand_path(File.dirname(__FILE__) + '/../lib') require 'rubygems' require 'benchmark/ips' require 'active_record' number_of_threads = 25 opts = { database: 'test', pool: number_of_threads } Benchmark.ips do |x| %w[mysql mysql2].each do |adapter| ActiveRecord::Base.establish_connection(...
ruby
MIT
b009d7e114729cbae5bef069a1033dd78acf7745
2026-01-04T15:56:41.499629Z
false
brianmario/mysql2
https://github.com/brianmario/mysql2/blob/b009d7e114729cbae5bef069a1033dd78acf7745/benchmark/escape.rb
benchmark/escape.rb
$LOAD_PATH.unshift File.expand_path(File.dirname(__FILE__) + '/../lib') require 'rubygems' require 'benchmark/ips' require 'mysql' require 'mysql2' require 'do_mysql' def run_escape_benchmarks(str) Benchmark.ips do |x| mysql = Mysql.new("localhost", "root") x.report "Mysql #{str.inspect}" do mysql.qu...
ruby
MIT
b009d7e114729cbae5bef069a1033dd78acf7745
2026-01-04T15:56:41.499629Z
false
brianmario/mysql2
https://github.com/brianmario/mysql2/blob/b009d7e114729cbae5bef069a1033dd78acf7745/benchmark/setup_db.rb
benchmark/setup_db.rb
$LOAD_PATH.unshift File.expand_path(File.dirname(__FILE__) + '/../lib') # This script is for generating psudo-random data into a single table consisting of nearly every # data type MySQL 5.1 supports. # # It's meant to be used with the query.rb benchmark script (or others in the future) require 'mysql2' require 'ruby...
ruby
MIT
b009d7e114729cbae5bef069a1033dd78acf7745
2026-01-04T15:56:41.499629Z
false
brianmario/mysql2
https://github.com/brianmario/mysql2/blob/b009d7e114729cbae5bef069a1033dd78acf7745/benchmark/query_without_mysql_casting.rb
benchmark/query_without_mysql_casting.rb
$LOAD_PATH.unshift File.expand_path(File.dirname(__FILE__) + '/../lib') require 'rubygems' require 'benchmark/ips' require 'mysql' require 'mysql2' require 'do_mysql' database = 'test' sql = "SELECT * FROM mysql2_test LIMIT 100" debug = ENV['DEBUG'] Benchmark.ips do |x| mysql2 = Mysql2::Client.new(host: "localhos...
ruby
MIT
b009d7e114729cbae5bef069a1033dd78acf7745
2026-01-04T15:56:41.499629Z
false
brianmario/mysql2
https://github.com/brianmario/mysql2/blob/b009d7e114729cbae5bef069a1033dd78acf7745/ext/mysql2/extconf.rb
ext/mysql2/extconf.rb
require 'mkmf' require 'English' ### Some helper functions def asplode(lib) if RUBY_PLATFORM =~ /mingw|mswin/ abort "-----\n#{lib} is missing. Check your installation of MySQL or Connector/C, and try again.\n-----" elsif RUBY_PLATFORM =~ /darwin/ abort "-----\n#{lib} is missing. You may need to 'brew inst...
ruby
MIT
b009d7e114729cbae5bef069a1033dd78acf7745
2026-01-04T15:56:41.499629Z
false
brianmario/mysql2
https://github.com/brianmario/mysql2/blob/b009d7e114729cbae5bef069a1033dd78acf7745/spec/spec_helper.rb
spec/spec_helper.rb
require 'rspec' require 'mysql2' require 'timeout' require 'yaml' require 'fiber' DatabaseCredentials = YAML.load_file('spec/configuration.yml') if GC.respond_to?(:verify_compaction_references) # This method was added in Ruby 3.0.0. Calling it this way asks the GC to # move objects around, helping to find object ...
ruby
MIT
b009d7e114729cbae5bef069a1033dd78acf7745
2026-01-04T15:56:41.499629Z
false
brianmario/mysql2
https://github.com/brianmario/mysql2/blob/b009d7e114729cbae5bef069a1033dd78acf7745/spec/mysql2/result_spec.rb
spec/mysql2/result_spec.rb
require 'spec_helper' RSpec.describe Mysql2::Result do before(:example) do @result = @client.query "SELECT 1" end it "should raise a TypeError exception when it doesn't wrap a result set" do expect { Mysql2::Result.new }.to raise_error(TypeError) expect { Mysql2::Result.allocate }.to raise_error(Typ...
ruby
MIT
b009d7e114729cbae5bef069a1033dd78acf7745
2026-01-04T15:56:41.499629Z
false
brianmario/mysql2
https://github.com/brianmario/mysql2/blob/b009d7e114729cbae5bef069a1033dd78acf7745/spec/mysql2/statement_spec.rb
spec/mysql2/statement_spec.rb
require './spec/spec_helper' RSpec.describe Mysql2::Statement do # rubocop:disable Metrics/BlockLength before(:example) do @client = new_client(encoding: "utf8") end let(:performance_schema_enabled) do performance_schema = @client.query "SHOW VARIABLES LIKE 'performance_schema'" performance_schema.a...
ruby
MIT
b009d7e114729cbae5bef069a1033dd78acf7745
2026-01-04T15:56:41.499629Z
false
brianmario/mysql2
https://github.com/brianmario/mysql2/blob/b009d7e114729cbae5bef069a1033dd78acf7745/spec/mysql2/client_spec.rb
spec/mysql2/client_spec.rb
require 'spec_helper' RSpec.describe Mysql2::Client do # rubocop:disable Metrics/BlockLength let(:performance_schema_enabled) do performance_schema = @client.query "SHOW VARIABLES LIKE 'performance_schema'" performance_schema.any? { |x| x['Value'] == 'ON' } end context "using defaults file" do let(:...
ruby
MIT
b009d7e114729cbae5bef069a1033dd78acf7745
2026-01-04T15:56:41.499629Z
true
brianmario/mysql2
https://github.com/brianmario/mysql2/blob/b009d7e114729cbae5bef069a1033dd78acf7745/spec/mysql2/error_spec.rb
spec/mysql2/error_spec.rb
require 'spec_helper' RSpec.describe Mysql2::Error do let(:error) do begin @client.query("HAHAHA") rescue Mysql2::Error => e error = e end error end it "responds to error_number and sql_state, with aliases" do expect(error).to respond_to(:error_number) expect(error).to respo...
ruby
MIT
b009d7e114729cbae5bef069a1033dd78acf7745
2026-01-04T15:56:41.499629Z
false
brianmario/mysql2
https://github.com/brianmario/mysql2/blob/b009d7e114729cbae5bef069a1033dd78acf7745/spec/em/em_spec.rb
spec/em/em_spec.rb
require 'spec_helper' begin require 'eventmachine' require 'mysql2/em' RSpec.describe Mysql2::EM::Client do it "should support async queries" do results = [] EM.run do client1 = Mysql2::EM::Client.new DatabaseCredentials['root'] defer1 = client1.query "SELECT sleep(0.1) as first_q...
ruby
MIT
b009d7e114729cbae5bef069a1033dd78acf7745
2026-01-04T15:56:41.499629Z
false
brianmario/mysql2
https://github.com/brianmario/mysql2/blob/b009d7e114729cbae5bef069a1033dd78acf7745/examples/threaded.rb
examples/threaded.rb
$LOAD_PATH.unshift 'lib' require 'mysql2' require 'timeout' # Should never exceed worst case 3.5 secs across all 20 threads Timeout.timeout(3.5) do Array.new(20) do Thread.new do overhead = rand(3) puts ">> thread #{Thread.current.object_id} query, #{overhead} sec overhead" # 3 second overhead ...
ruby
MIT
b009d7e114729cbae5bef069a1033dd78acf7745
2026-01-04T15:56:41.499629Z
false
brianmario/mysql2
https://github.com/brianmario/mysql2/blob/b009d7e114729cbae5bef069a1033dd78acf7745/examples/eventmachine.rb
examples/eventmachine.rb
$LOAD_PATH.unshift 'lib' require 'rubygems' require 'eventmachine' require 'mysql2/em' EM.run do client1 = Mysql2::EM::Client.new defer1 = client1.query "SELECT sleep(3) as first_query" defer1.callback do |result| puts "Result: #{result.to_a.inspect}" end client2 = Mysql2::EM::Client.new defer2 = cli...
ruby
MIT
b009d7e114729cbae5bef069a1033dd78acf7745
2026-01-04T15:56:41.499629Z
false
brianmario/mysql2
https://github.com/brianmario/mysql2/blob/b009d7e114729cbae5bef069a1033dd78acf7745/lib/mysql2.rb
lib/mysql2.rb
require 'date' require 'bigdecimal' # Load libmysql.dll before requiring mysql2/mysql2.so # This gives a chance to be flexible about the load path # Or to bomb out with a clear error message instead of a linker crash if RUBY_PLATFORM =~ /mswin|mingw/ dll_path = if ENV['RUBY_MYSQL2_LIBMYSQL_DLL'] # If this enviro...
ruby
MIT
b009d7e114729cbae5bef069a1033dd78acf7745
2026-01-04T15:56:41.499629Z
false
brianmario/mysql2
https://github.com/brianmario/mysql2/blob/b009d7e114729cbae5bef069a1033dd78acf7745/lib/mysql2/version.rb
lib/mysql2/version.rb
module Mysql2 VERSION = "0.5.7".freeze end
ruby
MIT
b009d7e114729cbae5bef069a1033dd78acf7745
2026-01-04T15:56:41.499629Z
false
brianmario/mysql2
https://github.com/brianmario/mysql2/blob/b009d7e114729cbae5bef069a1033dd78acf7745/lib/mysql2/em.rb
lib/mysql2/em.rb
require 'eventmachine' require 'mysql2' module Mysql2 module EM class Client < ::Mysql2::Client module Watcher def initialize(client, deferable) @client = client @deferable = deferable @is_watching = true end def notify_readable detach ...
ruby
MIT
b009d7e114729cbae5bef069a1033dd78acf7745
2026-01-04T15:56:41.499629Z
false
brianmario/mysql2
https://github.com/brianmario/mysql2/blob/b009d7e114729cbae5bef069a1033dd78acf7745/lib/mysql2/field.rb
lib/mysql2/field.rb
module Mysql2 Field = Struct.new(:name, :type) end
ruby
MIT
b009d7e114729cbae5bef069a1033dd78acf7745
2026-01-04T15:56:41.499629Z
false
brianmario/mysql2
https://github.com/brianmario/mysql2/blob/b009d7e114729cbae5bef069a1033dd78acf7745/lib/mysql2/result.rb
lib/mysql2/result.rb
module Mysql2 class Result attr_reader :server_flags include Enumerable end end
ruby
MIT
b009d7e114729cbae5bef069a1033dd78acf7745
2026-01-04T15:56:41.499629Z
false
brianmario/mysql2
https://github.com/brianmario/mysql2/blob/b009d7e114729cbae5bef069a1033dd78acf7745/lib/mysql2/console.rb
lib/mysql2/console.rb
# Loaded by script/console. Land helpers here. Pry.config.prompt = lambda do |context, *| "[mysql2] #{context}> " end
ruby
MIT
b009d7e114729cbae5bef069a1033dd78acf7745
2026-01-04T15:56:41.499629Z
false
brianmario/mysql2
https://github.com/brianmario/mysql2/blob/b009d7e114729cbae5bef069a1033dd78acf7745/lib/mysql2/statement.rb
lib/mysql2/statement.rb
module Mysql2 class Statement def execute(*args, **kwargs) Thread.handle_interrupt(::Mysql2::Util::TIMEOUT_ERROR_NEVER) do _execute(*args, **kwargs) end end end end
ruby
MIT
b009d7e114729cbae5bef069a1033dd78acf7745
2026-01-04T15:56:41.499629Z
false
brianmario/mysql2
https://github.com/brianmario/mysql2/blob/b009d7e114729cbae5bef069a1033dd78acf7745/lib/mysql2/client.rb
lib/mysql2/client.rb
module Mysql2 class Client attr_reader :query_options, :read_timeout def self.default_query_options @default_query_options ||= { as: :hash, # the type of object you want each row back as; also supports :array (an array of values) async: false, # don't wa...
ruby
MIT
b009d7e114729cbae5bef069a1033dd78acf7745
2026-01-04T15:56:41.499629Z
false
brianmario/mysql2
https://github.com/brianmario/mysql2/blob/b009d7e114729cbae5bef069a1033dd78acf7745/lib/mysql2/error.rb
lib/mysql2/error.rb
module Mysql2 class Error < StandardError ENCODE_OPTS = { undef: :replace, invalid: :replace, replace: '?'.freeze, }.freeze ConnectionError = Class.new(Error) TimeoutError = Class.new(Error) CODES = { 1205 => TimeoutError, # ER_LOCK_WAIT_TIMEOUT 1044 => ConnectionE...
ruby
MIT
b009d7e114729cbae5bef069a1033dd78acf7745
2026-01-04T15:56:41.499629Z
false
cerebris/jsonapi-resources
https://github.com/cerebris/jsonapi-resources/blob/e92afc690f5c53da6f4fa5e91ca72a50873390be/test/test_helper.rb
test/test_helper.rb
require 'simplecov' require 'database_cleaner' # To run tests with coverage: # COVERAGE=true bundle exec rake test # To test on a specific rails version use this: # export RAILS_VERSION=5.2.4.4; bundle update; bundle exec rake test # export RAILS_VERSION=6.0.3.4; bundle update; bundle exec rake test # export RAILS_VE...
ruby
MIT
e92afc690f5c53da6f4fa5e91ca72a50873390be
2026-01-04T15:56:22.334252Z
false
cerebris/jsonapi-resources
https://github.com/cerebris/jsonapi-resources/blob/e92afc690f5c53da6f4fa5e91ca72a50873390be/test/integration/sti_fields_test.rb
test/integration/sti_fields_test.rb
require File.expand_path("../../test_helper", __FILE__) class StiFieldsTest < ActionDispatch::IntegrationTest def test_index_fields_when_resource_does_not_match_relationship get "/posts", params: { filter: { id: "1,2" }, include: "author", fields: { pos...
ruby
MIT
e92afc690f5c53da6f4fa5e91ca72a50873390be
2026-01-04T15:56:22.334252Z
false
cerebris/jsonapi-resources
https://github.com/cerebris/jsonapi-resources/blob/e92afc690f5c53da6f4fa5e91ca72a50873390be/test/integration/requests/request_test.rb
test/integration/requests/request_test.rb
require File.expand_path('../../../test_helper', __FILE__) class RequestTest < ActionDispatch::IntegrationTest def setup DatabaseCleaner.start JSONAPI.configuration.json_key_format = :underscored_key JSONAPI.configuration.route_format = :underscored_route Api::V2::BookResource.paginator :offset $...
ruby
MIT
e92afc690f5c53da6f4fa5e91ca72a50873390be
2026-01-04T15:56:22.334252Z
true
cerebris/jsonapi-resources
https://github.com/cerebris/jsonapi-resources/blob/e92afc690f5c53da6f4fa5e91ca72a50873390be/test/integration/requests/namespaced_model_test.rb
test/integration/requests/namespaced_model_test.rb
require File.expand_path('../../../test_helper', __FILE__) class NamedspacedModelTest < ActionDispatch::IntegrationTest def setup JSONAPI.configuration.json_key_format = :underscored_key end def test_get_flat_posts assert_cacheable_jsonapi_get '/flat_posts' assert_equal "flat_posts", json_response["...
ruby
MIT
e92afc690f5c53da6f4fa5e91ca72a50873390be
2026-01-04T15:56:22.334252Z
false
cerebris/jsonapi-resources
https://github.com/cerebris/jsonapi-resources/blob/e92afc690f5c53da6f4fa5e91ca72a50873390be/test/integration/routes/routes_test.rb
test/integration/routes/routes_test.rb
require File.expand_path('../../../test_helper', __FILE__) class RoutesTest < ActionDispatch::IntegrationTest # def test_dump_routes # r = {} # # Rails.application.routes.routes.each do |route| # r[route.path.spec.right.left.to_s] ||= {routes: {}} # r[route.path.spec.right.left.to_s][:routes][...
ruby
MIT
e92afc690f5c53da6f4fa5e91ca72a50873390be
2026-01-04T15:56:22.334252Z
false
cerebris/jsonapi-resources
https://github.com/cerebris/jsonapi-resources/blob/e92afc690f5c53da6f4fa5e91ca72a50873390be/test/helpers/assertions.rb
test/helpers/assertions.rb
module Helpers module Assertions def assert_hash_equals(exp, act, msg = nil) msg = message(msg, '') { diff exp, act } assert(matches_hash?(exp, act, {exact: true}), msg) end def assert_array_equals(exp, act, msg = nil) msg = message(msg, '') { diff exp, act } assert(matches_array?...
ruby
MIT
e92afc690f5c53da6f4fa5e91ca72a50873390be
2026-01-04T15:56:22.334252Z
false
cerebris/jsonapi-resources
https://github.com/cerebris/jsonapi-resources/blob/e92afc690f5c53da6f4fa5e91ca72a50873390be/test/helpers/configuration_helpers.rb
test/helpers/configuration_helpers.rb
module Helpers module ConfigurationHelpers def with_jsonapi_config(new_config_options) original_config = JSONAPI.configuration.dup # TODO should be a deep dup begin new_config_options.each do |k, v| JSONAPI.configuration.send(:"#{k}=", v) end return yield ensure...
ruby
MIT
e92afc690f5c53da6f4fa5e91ca72a50873390be
2026-01-04T15:56:22.334252Z
false
cerebris/jsonapi-resources
https://github.com/cerebris/jsonapi-resources/blob/e92afc690f5c53da6f4fa5e91ca72a50873390be/test/helpers/value_matchers_test.rb
test/helpers/value_matchers_test.rb
require File.expand_path('../../test_helper', __FILE__) class ValueMatchersTest < ActionController::TestCase def test_matches_value_any assert(matches_value?(:any, 'a')) assert(matches_value?(:any, nil)) end def test_matches_value_not_nil assert(matches_value?(:not_nil, 'a')) refute(matches_val...
ruby
MIT
e92afc690f5c53da6f4fa5e91ca72a50873390be
2026-01-04T15:56:22.334252Z
false
cerebris/jsonapi-resources
https://github.com/cerebris/jsonapi-resources/blob/e92afc690f5c53da6f4fa5e91ca72a50873390be/test/helpers/functional_helpers.rb
test/helpers/functional_helpers.rb
module Helpers module FunctionalHelpers # from http://jamieonsoftware.com/blog/entry/testing-restful-response-types # def assert_response_is(type, message = '') # case type # when :js # check = [ # 'text/javascript' # ] # when :json # check = [ ...
ruby
MIT
e92afc690f5c53da6f4fa5e91ca72a50873390be
2026-01-04T15:56:22.334252Z
false
cerebris/jsonapi-resources
https://github.com/cerebris/jsonapi-resources/blob/e92afc690f5c53da6f4fa5e91ca72a50873390be/test/helpers/value_matchers.rb
test/helpers/value_matchers.rb
module Helpers module ValueMatchers ### Matchers def matches_value?(v1, v2, options = {}) if v1 == :any # any value is acceptable elsif v1 == :not_nil if v2 == nil return false end elsif v1.kind_of?(Hash) unless matches_hash?(v1, v2, options) ...
ruby
MIT
e92afc690f5c53da6f4fa5e91ca72a50873390be
2026-01-04T15:56:22.334252Z
false
cerebris/jsonapi-resources
https://github.com/cerebris/jsonapi-resources/blob/e92afc690f5c53da6f4fa5e91ca72a50873390be/test/benchmark/reflect_create_and_delete_benchmark.rb
test/benchmark/reflect_create_and_delete_benchmark.rb
require File.expand_path('../../test_helper', __FILE__) class ReflectCreateAndDeleteBenchmark < IntegrationBenchmark def setup $test_user = Person.find(1) end def create_and_delete_comments post '/posts/15/relationships/comments', params: { 'data' => [ {type: 'comments', id: 1}, ...
ruby
MIT
e92afc690f5c53da6f4fa5e91ca72a50873390be
2026-01-04T15:56:22.334252Z
false
cerebris/jsonapi-resources
https://github.com/cerebris/jsonapi-resources/blob/e92afc690f5c53da6f4fa5e91ca72a50873390be/test/benchmark/reflect_update_relationships_benchmark.rb
test/benchmark/reflect_update_relationships_benchmark.rb
require File.expand_path('../../test_helper', __FILE__) class ReflectUpdateRelationshipsBenchmark < IntegrationBenchmark def setup $test_user = Person.find(1) end def replace_tags put '/posts/15/relationships/tags', params: { 'data' => [{type: 'tags', id: 11}, {type: 'tags', id: 3}, {type:...
ruby
MIT
e92afc690f5c53da6f4fa5e91ca72a50873390be
2026-01-04T15:56:22.334252Z
false
cerebris/jsonapi-resources
https://github.com/cerebris/jsonapi-resources/blob/e92afc690f5c53da6f4fa5e91ca72a50873390be/test/benchmark/request_benchmark.rb
test/benchmark/request_benchmark.rb
require File.expand_path('../../test_helper', __FILE__) class RequestBenchmark < IntegrationBenchmark def setup super $test_user = Person.find(1) end def bench_large_index_request_uncached 10.times do assert_jsonapi_get '/api/v2/books?include=bookComments,bookComments.author' end end ...
ruby
MIT
e92afc690f5c53da6f4fa5e91ca72a50873390be
2026-01-04T15:56:22.334252Z
false
cerebris/jsonapi-resources
https://github.com/cerebris/jsonapi-resources/blob/e92afc690f5c53da6f4fa5e91ca72a50873390be/test/fixtures/active_record.rb
test/fixtures/active_record.rb
require 'active_record' require 'jsonapi-resources' ActiveSupport::Inflector.inflections(:en) do |inflect| inflect.uncountable 'preferences' inflect.uncountable 'file_properties' inflect.irregular 'numero_telefone', 'numeros_telefone' end ### DATABASE ActiveRecord::Schema.define do create_table :sessions, id:...
ruby
MIT
e92afc690f5c53da6f4fa5e91ca72a50873390be
2026-01-04T15:56:22.334252Z
true
cerebris/jsonapi-resources
https://github.com/cerebris/jsonapi-resources/blob/e92afc690f5c53da6f4fa5e91ca72a50873390be/test/controllers/controller_test.rb
test/controllers/controller_test.rb
require File.expand_path('../../test_helper', __FILE__) def set_content_type_header! @request.headers['Content-Type'] = JSONAPI::MEDIA_TYPE end class PostsControllerTest < ActionController::TestCase def setup super JSONAPI.configuration.raise_if_parameters_not_allowed = true JSONAPI.configuration.alwa...
ruby
MIT
e92afc690f5c53da6f4fa5e91ca72a50873390be
2026-01-04T15:56:22.334252Z
true
cerebris/jsonapi-resources
https://github.com/cerebris/jsonapi-resources/blob/e92afc690f5c53da6f4fa5e91ca72a50873390be/test/lib/generators/jsonapi/resource_generator_test.rb
test/lib/generators/jsonapi/resource_generator_test.rb
require File.expand_path('../../../../test_helper', __FILE__) require 'generators/jsonapi/resource_generator' module Jsonapi class ResourceGeneratorTest < Rails::Generators::TestCase tests ResourceGenerator destination Rails.root.join('../resources') setup :prepare_destination teardown :cleanup_desti...
ruby
MIT
e92afc690f5c53da6f4fa5e91ca72a50873390be
2026-01-04T15:56:22.334252Z
false
cerebris/jsonapi-resources
https://github.com/cerebris/jsonapi-resources/blob/e92afc690f5c53da6f4fa5e91ca72a50873390be/test/lib/generators/jsonapi/controller_generator_test.rb
test/lib/generators/jsonapi/controller_generator_test.rb
require File.expand_path('../../../../test_helper', __FILE__) require 'generators/jsonapi/controller_generator' module Jsonapi class ControllerGeneratorTest < Rails::Generators::TestCase tests ControllerGenerator destination Rails.root.join('../controllers') setup :prepare_destination teardown :clean...
ruby
MIT
e92afc690f5c53da6f4fa5e91ca72a50873390be
2026-01-04T15:56:22.334252Z
false
cerebris/jsonapi-resources
https://github.com/cerebris/jsonapi-resources/blob/e92afc690f5c53da6f4fa5e91ca72a50873390be/test/unit/resource/resource_test.rb
test/unit/resource/resource_test.rb
require File.expand_path('../../../test_helper', __FILE__) class ArticleResource < JSONAPI::Resource model_name 'Post' def self.records(options) options[:context].posts end end class PostWithBadAfterSave < ActiveRecord::Base self.table_name = 'posts' after_save :do_some_after_save_stuff def do_some_...
ruby
MIT
e92afc690f5c53da6f4fa5e91ca72a50873390be
2026-01-04T15:56:22.334252Z
false
cerebris/jsonapi-resources
https://github.com/cerebris/jsonapi-resources/blob/e92afc690f5c53da6f4fa5e91ca72a50873390be/test/unit/resource/active_relation_resource_test.rb
test/unit/resource/active_relation_resource_test.rb
require File.expand_path('../../../test_helper', __FILE__) class ArPostResource < JSONAPI::Resource model_name 'Post' attribute :headline, delegate: :title has_one :author has_many :tags, primary_key: :tags_import_id end class ActiveRelationResourceTest < ActiveSupport::TestCase def setup end def test_...
ruby
MIT
e92afc690f5c53da6f4fa5e91ca72a50873390be
2026-01-04T15:56:22.334252Z
false
cerebris/jsonapi-resources
https://github.com/cerebris/jsonapi-resources/blob/e92afc690f5c53da6f4fa5e91ca72a50873390be/test/unit/resource/relationship_test.rb
test/unit/resource/relationship_test.rb
require File.expand_path('../../../test_helper', __FILE__) class LambdaBlogPostsResource < JSONAPI::Resource model_name 'Post' has_one :author, allow_include: -> (context) { context[:admin] } has_many :comments, allow_include: -> (context) { context[:admin] } end class CallableBlogPostsResource < JSONAPI::Reso...
ruby
MIT
e92afc690f5c53da6f4fa5e91ca72a50873390be
2026-01-04T15:56:22.334252Z
false
cerebris/jsonapi-resources
https://github.com/cerebris/jsonapi-resources/blob/e92afc690f5c53da6f4fa5e91ca72a50873390be/test/unit/processor/default_processor_test.rb
test/unit/processor/default_processor_test.rb
require File.expand_path('../../../test_helper', __FILE__) require 'jsonapi-resources' require 'json' class DefaultProcessorTest < ActionDispatch::IntegrationTest def setup JSONAPI.configuration.json_key_format = :camelized_key JSONAPI.configuration.route_format = :camelized_route JSONAPI.configuration.a...
ruby
MIT
e92afc690f5c53da6f4fa5e91ca72a50873390be
2026-01-04T15:56:22.334252Z
false
cerebris/jsonapi-resources
https://github.com/cerebris/jsonapi-resources/blob/e92afc690f5c53da6f4fa5e91ca72a50873390be/test/unit/serializer/link_builder_test.rb
test/unit/serializer/link_builder_test.rb
require File.expand_path('../../../test_helper', __FILE__) require 'jsonapi-resources' require 'json' module Api module Secret class PostResource < JSONAPI::Resource attribute :title attribute :body has_one :author, class_name: 'Person' end class PersonResource < JSONAPI::Resource ...
ruby
MIT
e92afc690f5c53da6f4fa5e91ca72a50873390be
2026-01-04T15:56:22.334252Z
false
cerebris/jsonapi-resources
https://github.com/cerebris/jsonapi-resources/blob/e92afc690f5c53da6f4fa5e91ca72a50873390be/test/unit/serializer/include_directives_test.rb
test/unit/serializer/include_directives_test.rb
require File.expand_path('../../../test_helper', __FILE__) require 'jsonapi-resources' class IncludeDirectivesTest < ActiveSupport::TestCase def test_one_level_one_include directives = JSONAPI::IncludeDirectives.new(PersonResource, ['posts']).instance_variable_get(:@include_directives_hash) assert_hash_equ...
ruby
MIT
e92afc690f5c53da6f4fa5e91ca72a50873390be
2026-01-04T15:56:22.334252Z
false
cerebris/jsonapi-resources
https://github.com/cerebris/jsonapi-resources/blob/e92afc690f5c53da6f4fa5e91ca72a50873390be/test/unit/serializer/serializer_test.rb
test/unit/serializer/serializer_test.rb
require File.expand_path('../../../test_helper', __FILE__) require 'jsonapi-resources' require 'json' class SerializerTest < ActionDispatch::IntegrationTest def setup @post = Post.find(1) @fred = Person.find_by(name: 'Fred Reader') @expense_entry = ExpenseEntry.find(1) JSONAPI.configuration.json_ke...
ruby
MIT
e92afc690f5c53da6f4fa5e91ca72a50873390be
2026-01-04T15:56:22.334252Z
false
cerebris/jsonapi-resources
https://github.com/cerebris/jsonapi-resources/blob/e92afc690f5c53da6f4fa5e91ca72a50873390be/test/unit/pagination/offset_paginator_test.rb
test/unit/pagination/offset_paginator_test.rb
require File.expand_path('../../../test_helper', __FILE__) require 'jsonapi-resources' class OffsetPaginatorTest < ActiveSupport::TestCase def test_offset_default_page_params params = ActionController::Parameters.new( { } ) paginator = OffsetPaginator.new(params) assert_equal JSONAPI.c...
ruby
MIT
e92afc690f5c53da6f4fa5e91ca72a50873390be
2026-01-04T15:56:22.334252Z
false
cerebris/jsonapi-resources
https://github.com/cerebris/jsonapi-resources/blob/e92afc690f5c53da6f4fa5e91ca72a50873390be/test/unit/pagination/paged_paginator_test.rb
test/unit/pagination/paged_paginator_test.rb
require File.expand_path('../../../test_helper', __FILE__) require 'jsonapi-resources' class PagedPaginatorTest < ActiveSupport::TestCase def test_paged_default_page_params params = ActionController::Parameters.new( { } ) paginator = PagedPaginator.new(params) assert_equal JSONAPI.conf...
ruby
MIT
e92afc690f5c53da6f4fa5e91ca72a50873390be
2026-01-04T15:56:22.334252Z
false
cerebris/jsonapi-resources
https://github.com/cerebris/jsonapi-resources/blob/e92afc690f5c53da6f4fa5e91ca72a50873390be/test/unit/paths/path_test.rb
test/unit/paths/path_test.rb
require File.expand_path('../../../test_helper', __FILE__) require 'jsonapi-resources' class PathTest < ActiveSupport::TestCase def test_one_relationship path = JSONAPI::Path.new(resource_klass: Api::V1::PostResource, path_string: 'comments') assert path.segments.is_a?(Array) assert path.segments[0].is...
ruby
MIT
e92afc690f5c53da6f4fa5e91ca72a50873390be
2026-01-04T15:56:22.334252Z
false
cerebris/jsonapi-resources
https://github.com/cerebris/jsonapi-resources/blob/e92afc690f5c53da6f4fa5e91ca72a50873390be/test/unit/formatters/dasherized_key_formatter_test.rb
test/unit/formatters/dasherized_key_formatter_test.rb
require File.expand_path('../../../test_helper', __FILE__) class DasherizedKeyFormatterTest < ActiveSupport::TestCase def test_dasherize_camelize formatted = DasherizedKeyFormatter.format("CarWash") assert_equal formatted, "car-wash" end end
ruby
MIT
e92afc690f5c53da6f4fa5e91ca72a50873390be
2026-01-04T15:56:22.334252Z
false
cerebris/jsonapi-resources
https://github.com/cerebris/jsonapi-resources/blob/e92afc690f5c53da6f4fa5e91ca72a50873390be/test/unit/jsonapi_request/jsonapi_request_test.rb
test/unit/jsonapi_request/jsonapi_request_test.rb
require File.expand_path('../../../test_helper', __FILE__) class CatResource < JSONAPI::Resource attribute :name attribute :breed has_one :mother, class_name: 'Cat' has_one :father, class_name: 'Cat' filters :name def self.sortable_fields(context) super(context) << :"mother.name" end end class Tr...
ruby
MIT
e92afc690f5c53da6f4fa5e91ca72a50873390be
2026-01-04T15:56:22.334252Z
false
cerebris/jsonapi-resources
https://github.com/cerebris/jsonapi-resources/blob/e92afc690f5c53da6f4fa5e91ca72a50873390be/test/unit/active_relation_resource_finder/join_manager_test.rb
test/unit/active_relation_resource_finder/join_manager_test.rb
require File.expand_path('../../../test_helper', __FILE__) require 'jsonapi-resources' class JoinTreeTest < ActiveSupport::TestCase def db_true case ActiveRecord::Base.connection.adapter_name when 'SQLite' if Rails::VERSION::MAJOR >= 6 || (Rails::VERSION::MAJOR >= 5 && ActiveRecord::VERSION::MINOR...
ruby
MIT
e92afc690f5c53da6f4fa5e91ca72a50873390be
2026-01-04T15:56:22.334252Z
false
cerebris/jsonapi-resources
https://github.com/cerebris/jsonapi-resources/blob/e92afc690f5c53da6f4fa5e91ca72a50873390be/lib/jsonapi-resources.rb
lib/jsonapi-resources.rb
# frozen_string_literal: true require 'jsonapi/resources/railtie' require 'jsonapi/naive_cache' require 'jsonapi/compiled_json' require 'jsonapi/basic_resource' require 'jsonapi/active_relation_resource' require 'jsonapi/resource' require 'jsonapi/cached_response_fragment' require 'jsonapi/response_document' require '...
ruby
MIT
e92afc690f5c53da6f4fa5e91ca72a50873390be
2026-01-04T15:56:22.334252Z
false
cerebris/jsonapi-resources
https://github.com/cerebris/jsonapi-resources/blob/e92afc690f5c53da6f4fa5e91ca72a50873390be/lib/bug_report_templates/rails_5_master.rb
lib/bug_report_templates/rails_5_master.rb
begin require 'bundler/inline' require 'bundler' rescue LoadError => e STDERR.puts 'Bundler version 1.10 or later is required. Please update your Bundler' raise e end gemfile(true, ui: ENV['SILENT'] ? Bundler::UI::Silent.new : Bundler::UI::Shell.new) do source 'https://rubygems.org' gem 'rails', require: ...
ruby
MIT
e92afc690f5c53da6f4fa5e91ca72a50873390be
2026-01-04T15:56:22.334252Z
false
cerebris/jsonapi-resources
https://github.com/cerebris/jsonapi-resources/blob/e92afc690f5c53da6f4fa5e91ca72a50873390be/lib/bug_report_templates/rails_5_latest.rb
lib/bug_report_templates/rails_5_latest.rb
begin require 'bundler/inline' rescue LoadError => e STDERR.puts 'Bundler version 1.10 or later is required. Please update your Bundler' raise e end gemfile(true) do source 'https://rubygems.org' gem 'rails', require: false gem 'sqlite3', platform: :mri gem 'activerecord-jdbcsqlite3-adapter', git...
ruby
MIT
e92afc690f5c53da6f4fa5e91ca72a50873390be
2026-01-04T15:56:22.334252Z
false
cerebris/jsonapi-resources
https://github.com/cerebris/jsonapi-resources/blob/e92afc690f5c53da6f4fa5e91ca72a50873390be/lib/generators/jsonapi/resource_generator.rb
lib/generators/jsonapi/resource_generator.rb
module Jsonapi class ResourceGenerator < Rails::Generators::NamedBase source_root File.expand_path('../templates', __FILE__) def create_resource template_file = File.join( 'app/resources', class_path, "#{file_name.singularize}_resource.rb" ) template 'jsonapi_resourc...
ruby
MIT
e92afc690f5c53da6f4fa5e91ca72a50873390be
2026-01-04T15:56:22.334252Z
false
cerebris/jsonapi-resources
https://github.com/cerebris/jsonapi-resources/blob/e92afc690f5c53da6f4fa5e91ca72a50873390be/lib/generators/jsonapi/controller_generator.rb
lib/generators/jsonapi/controller_generator.rb
module Jsonapi class ControllerGenerator < Rails::Generators::NamedBase source_root File.expand_path('../templates', __FILE__) def create_resource template_file = File.join( 'app/controllers', class_path, "#{file_name.pluralize}_controller.rb" ) template 'jsonapi_con...
ruby
MIT
e92afc690f5c53da6f4fa5e91ca72a50873390be
2026-01-04T15:56:22.334252Z
false
cerebris/jsonapi-resources
https://github.com/cerebris/jsonapi-resources/blob/e92afc690f5c53da6f4fa5e91ca72a50873390be/lib/generators/jsonapi/templates/jsonapi_resource.rb
lib/generators/jsonapi/templates/jsonapi_resource.rb
<% module_namespacing do -%> class <%= class_name.singularize %>Resource < JSONAPI::Resource end <% end -%>
ruby
MIT
e92afc690f5c53da6f4fa5e91ca72a50873390be
2026-01-04T15:56:22.334252Z
false
cerebris/jsonapi-resources
https://github.com/cerebris/jsonapi-resources/blob/e92afc690f5c53da6f4fa5e91ca72a50873390be/lib/generators/jsonapi/templates/jsonapi_controller.rb
lib/generators/jsonapi/templates/jsonapi_controller.rb
<% module_namespacing do -%> class <%= class_name.pluralize %>Controller < JSONAPI::ResourceController end <% end -%>
ruby
MIT
e92afc690f5c53da6f4fa5e91ca72a50873390be
2026-01-04T15:56:22.334252Z
false
cerebris/jsonapi-resources
https://github.com/cerebris/jsonapi-resources/blob/e92afc690f5c53da6f4fa5e91ca72a50873390be/lib/jsonapi/routing_ext.rb
lib/jsonapi/routing_ext.rb
# frozen_string_literal: true module ActionDispatch module Routing class Mapper Resource.class_eval do def unformat_route(route) JSONAPI.configuration.route_formatter.unformat(route.to_s) end def nested_param :"#{unformat_route(singular)}_#{param}" end ...
ruby
MIT
e92afc690f5c53da6f4fa5e91ca72a50873390be
2026-01-04T15:56:22.334252Z
false