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
rails/thor
https://github.com/rails/thor/blob/b2d98fea78fd993b936fc434a3ad722e73ad6bc5/lib/thor/rake_compat.rb
lib/thor/rake_compat.rb
require "rake" require "rake/dsl_definition" class Thor # Adds a compatibility layer to your Thor classes which allows you to use # rake package tasks. For example, to use rspec rake tasks, one can do: # # require 'thor/rake_compat' # require 'rspec/core/rake_task' # # class Default < Thor # ...
ruby
MIT
b2d98fea78fd993b936fc434a3ad722e73ad6bc5
2026-01-04T15:43:28.376179Z
false
rails/thor
https://github.com/rails/thor/blob/b2d98fea78fd993b936fc434a3ad722e73ad6bc5/lib/thor/group.rb
lib/thor/group.rb
require_relative "base" # Thor has a special class called Thor::Group. The main difference to Thor class # is that it invokes all commands at once. It also include some methods that allows # invocations to be done at the class method, which are not available to Thor # commands. class Thor::Group class << self # ...
ruby
MIT
b2d98fea78fd993b936fc434a3ad722e73ad6bc5
2026-01-04T15:43:28.376179Z
false
rails/thor
https://github.com/rails/thor/blob/b2d98fea78fd993b936fc434a3ad722e73ad6bc5/lib/thor/parser.rb
lib/thor/parser.rb
require_relative "parser/argument" require_relative "parser/arguments" require_relative "parser/option" require_relative "parser/options"
ruby
MIT
b2d98fea78fd993b936fc434a3ad722e73ad6bc5
2026-01-04T15:43:28.376179Z
false
rails/thor
https://github.com/rails/thor/blob/b2d98fea78fd993b936fc434a3ad722e73ad6bc5/lib/thor/base.rb
lib/thor/base.rb
require_relative "command" require_relative "core_ext/hash_with_indifferent_access" require_relative "error" require_relative "invocation" require_relative "nested_context" require_relative "parser" require_relative "shell" require_relative "line_editor" require_relative "util" class Thor autoload :Actions, File....
ruby
MIT
b2d98fea78fd993b936fc434a3ad722e73ad6bc5
2026-01-04T15:43:28.376179Z
false
rails/thor
https://github.com/rails/thor/blob/b2d98fea78fd993b936fc434a3ad722e73ad6bc5/lib/thor/nested_context.rb
lib/thor/nested_context.rb
class Thor class NestedContext def initialize @depth = 0 end def enter push yield ensure pop end def entered? @depth.positive? end private def push @depth += 1 end def pop @depth -= 1 end end end
ruby
MIT
b2d98fea78fd993b936fc434a3ad722e73ad6bc5
2026-01-04T15:43:28.376179Z
false
rails/thor
https://github.com/rails/thor/blob/b2d98fea78fd993b936fc434a3ad722e73ad6bc5/lib/thor/runner.rb
lib/thor/runner.rb
require_relative "../thor" require_relative "group" require "digest/sha2" require "pathname" class Thor::Runner < Thor #:nodoc: map "-T" => :list, "-i" => :install, "-u" => :update, "-v" => :version def self.banner(command, all = false, subcommand = false) "thor " + command.formatted_usage(self, all, subcomm...
ruby
MIT
b2d98fea78fd993b936fc434a3ad722e73ad6bc5
2026-01-04T15:43:28.376179Z
false
rails/thor
https://github.com/rails/thor/blob/b2d98fea78fd993b936fc434a3ad722e73ad6bc5/lib/thor/shell.rb
lib/thor/shell.rb
require "rbconfig" class Thor module Base class << self attr_writer :shell # Returns the shell used in all Thor classes. If you are in a Unix platform # it will use a colored log, otherwise it will use a basic one without color. # def shell @shell ||= if ENV["THOR_SHELL"] &...
ruby
MIT
b2d98fea78fd993b936fc434a3ad722e73ad6bc5
2026-01-04T15:43:28.376179Z
false
rails/thor
https://github.com/rails/thor/blob/b2d98fea78fd993b936fc434a3ad722e73ad6bc5/lib/thor/invocation.rb
lib/thor/invocation.rb
class Thor module Invocation def self.included(base) #:nodoc: super(base) base.extend ClassMethods end module ClassMethods # This method is responsible for receiving a name and find the proper # class and command for it. The key is an optional parameter which is # available ...
ruby
MIT
b2d98fea78fd993b936fc434a3ad722e73ad6bc5
2026-01-04T15:43:28.376179Z
false
rails/thor
https://github.com/rails/thor/blob/b2d98fea78fd993b936fc434a3ad722e73ad6bc5/lib/thor/error.rb
lib/thor/error.rb
class Thor Correctable = if defined?(DidYouMean::SpellChecker) && defined?(DidYouMean::Correctable) # rubocop:disable Naming/ConstantName Module.new do def to_s super + DidYouMean.formatter.message_for(corrections) end def corrections @corrections ||= self.class.const_get(:Spell...
ruby
MIT
b2d98fea78fd993b936fc434a3ad722e73ad6bc5
2026-01-04T15:43:28.376179Z
false
rails/thor
https://github.com/rails/thor/blob/b2d98fea78fd993b936fc434a3ad722e73ad6bc5/lib/thor/util.rb
lib/thor/util.rb
require "rbconfig" class Thor module Sandbox #:nodoc: end # This module holds several utilities: # # 1) Methods to convert thor namespaces to constants and vice-versa. # # Thor::Util.namespace_from_thor_class(Foo::Bar::Baz) #=> "foo:bar:baz" # # 2) Loading thor files and sandboxing: # # Thor...
ruby
MIT
b2d98fea78fd993b936fc434a3ad722e73ad6bc5
2026-01-04T15:43:28.376179Z
false
rails/thor
https://github.com/rails/thor/blob/b2d98fea78fd993b936fc434a3ad722e73ad6bc5/lib/thor/line_editor/readline.rb
lib/thor/line_editor/readline.rb
class Thor module LineEditor class Readline < Basic def self.available? begin require "readline" rescue LoadError end Object.const_defined?(:Readline) end def readline if echo? ::Readline.completion_append_character = nil # ...
ruby
MIT
b2d98fea78fd993b936fc434a3ad722e73ad6bc5
2026-01-04T15:43:28.376179Z
false
rails/thor
https://github.com/rails/thor/blob/b2d98fea78fd993b936fc434a3ad722e73ad6bc5/lib/thor/line_editor/basic.rb
lib/thor/line_editor/basic.rb
class Thor module LineEditor class Basic attr_reader :prompt, :options def self.available? true end def initialize(prompt, options) @prompt = prompt @options = options end def readline $stdout.print(prompt) get_input end pri...
ruby
MIT
b2d98fea78fd993b936fc434a3ad722e73ad6bc5
2026-01-04T15:43:28.376179Z
false
rails/thor
https://github.com/rails/thor/blob/b2d98fea78fd993b936fc434a3ad722e73ad6bc5/lib/thor/actions/directory.rb
lib/thor/actions/directory.rb
require_relative "empty_directory" class Thor module Actions # Copies recursively the files from source directory to root directory. # If any of the files finishes with .tt, it's considered to be a template # and is placed in the destination without the extension .tt. If any # empty directory is foun...
ruby
MIT
b2d98fea78fd993b936fc434a3ad722e73ad6bc5
2026-01-04T15:43:28.376179Z
false
rails/thor
https://github.com/rails/thor/blob/b2d98fea78fd993b936fc434a3ad722e73ad6bc5/lib/thor/actions/create_link.rb
lib/thor/actions/create_link.rb
require_relative "create_file" class Thor module Actions # Create a new file relative to the destination root from the given source. # # ==== Parameters # destination<String>:: the relative path to the destination root. # source<String|NilClass>:: the relative path to the source root. # confi...
ruby
MIT
b2d98fea78fd993b936fc434a3ad722e73ad6bc5
2026-01-04T15:43:28.376179Z
false
rails/thor
https://github.com/rails/thor/blob/b2d98fea78fd993b936fc434a3ad722e73ad6bc5/lib/thor/actions/create_file.rb
lib/thor/actions/create_file.rb
require_relative "empty_directory" class Thor module Actions # Create a new file relative to the destination root with the given data, # which is the return value of a block or a data string. # # ==== Parameters # destination<String>:: the relative path to the destination root. # data<String|...
ruby
MIT
b2d98fea78fd993b936fc434a3ad722e73ad6bc5
2026-01-04T15:43:28.376179Z
false
rails/thor
https://github.com/rails/thor/blob/b2d98fea78fd993b936fc434a3ad722e73ad6bc5/lib/thor/actions/file_manipulation.rb
lib/thor/actions/file_manipulation.rb
require "erb" class Thor module Actions # Copies the file from the relative source to the relative destination. If # the destination is not given it's assumed to be equal to the source. # # ==== Parameters # source<String>:: the relative path to the source root. # destination<String>:: the re...
ruby
MIT
b2d98fea78fd993b936fc434a3ad722e73ad6bc5
2026-01-04T15:43:28.376179Z
false
rails/thor
https://github.com/rails/thor/blob/b2d98fea78fd993b936fc434a3ad722e73ad6bc5/lib/thor/actions/inject_into_file.rb
lib/thor/actions/inject_into_file.rb
require_relative "empty_directory" class Thor module Actions WARNINGS = {unchanged_no_flag: "File unchanged! Either the supplied flag value not found or the content has already been inserted!"} # Injects the given content into a file, raising an error if the contents of # the file are not changed. Diffe...
ruby
MIT
b2d98fea78fd993b936fc434a3ad722e73ad6bc5
2026-01-04T15:43:28.376179Z
false
rails/thor
https://github.com/rails/thor/blob/b2d98fea78fd993b936fc434a3ad722e73ad6bc5/lib/thor/actions/empty_directory.rb
lib/thor/actions/empty_directory.rb
class Thor module Actions # Creates an empty directory. # # ==== Parameters # destination<String>:: the relative path to the destination root. # config<Hash>:: give :verbose => false to not log the status. # # ==== Examples # # empty_directory "doc" # def empty_directory(...
ruby
MIT
b2d98fea78fd993b936fc434a3ad722e73ad6bc5
2026-01-04T15:43:28.376179Z
false
rails/thor
https://github.com/rails/thor/blob/b2d98fea78fd993b936fc434a3ad722e73ad6bc5/lib/thor/core_ext/hash_with_indifferent_access.rb
lib/thor/core_ext/hash_with_indifferent_access.rb
class Thor module CoreExt #:nodoc: # A hash with indifferent access and magic predicates. # # hash = Thor::CoreExt::HashWithIndifferentAccess.new 'foo' => 'bar', 'baz' => 'bee', 'force' => true # # hash[:foo] #=> 'bar' # hash['foo'] #=> 'bar' # hash.foo? #=> true # class...
ruby
MIT
b2d98fea78fd993b936fc434a3ad722e73ad6bc5
2026-01-04T15:43:28.376179Z
false
rails/thor
https://github.com/rails/thor/blob/b2d98fea78fd993b936fc434a3ad722e73ad6bc5/lib/thor/shell/lcs_diff.rb
lib/thor/shell/lcs_diff.rb
module LCSDiff protected # Overwrite show_diff to show diff with colors if Diff::LCS is # available. def show_diff(destination, content) #:nodoc: if diff_lcs_loaded? && ENV["THOR_DIFF"].nil? && ENV["RAILS_DIFF"].nil? actual = File.binread(destination).to_s.split("\n") content = content.to_s.spli...
ruby
MIT
b2d98fea78fd993b936fc434a3ad722e73ad6bc5
2026-01-04T15:43:28.376179Z
false
rails/thor
https://github.com/rails/thor/blob/b2d98fea78fd993b936fc434a3ad722e73ad6bc5/lib/thor/shell/column_printer.rb
lib/thor/shell/column_printer.rb
require_relative "terminal" class Thor module Shell class ColumnPrinter attr_reader :stdout, :options def initialize(stdout, options = {}) @stdout = stdout @options = options @indent = options[:indent].to_i end def print(array) return if array.empty? ...
ruby
MIT
b2d98fea78fd993b936fc434a3ad722e73ad6bc5
2026-01-04T15:43:28.376179Z
false
rails/thor
https://github.com/rails/thor/blob/b2d98fea78fd993b936fc434a3ad722e73ad6bc5/lib/thor/shell/color.rb
lib/thor/shell/color.rb
# frozen_string_literal: true require_relative "basic" require_relative "lcs_diff" class Thor module Shell # Inherit from Thor::Shell::Basic and add set_color behavior. Check # Thor::Shell::Basic to see all available methods. # class Color < Basic include LCSDiff # Embed in a String to ...
ruby
MIT
b2d98fea78fd993b936fc434a3ad722e73ad6bc5
2026-01-04T15:43:28.376179Z
false
rails/thor
https://github.com/rails/thor/blob/b2d98fea78fd993b936fc434a3ad722e73ad6bc5/lib/thor/shell/basic.rb
lib/thor/shell/basic.rb
require_relative "column_printer" require_relative "table_printer" require_relative "wrapped_printer" class Thor module Shell class Basic attr_accessor :base attr_reader :padding # Initialize base, mute and padding to nil. # def initialize #:nodoc: @base = nil @mu...
ruby
MIT
b2d98fea78fd993b936fc434a3ad722e73ad6bc5
2026-01-04T15:43:28.376179Z
false
rails/thor
https://github.com/rails/thor/blob/b2d98fea78fd993b936fc434a3ad722e73ad6bc5/lib/thor/shell/terminal.rb
lib/thor/shell/terminal.rb
class Thor module Shell module Terminal DEFAULT_TERMINAL_WIDTH = 80 class << self # This code was copied from Rake, available under MIT-LICENSE # Copyright (c) 2003, 2004 Jim Weirich def terminal_width result = if ENV["THOR_COLUMNS"] ENV["THOR_COLUMNS"].t...
ruby
MIT
b2d98fea78fd993b936fc434a3ad722e73ad6bc5
2026-01-04T15:43:28.376179Z
false
rails/thor
https://github.com/rails/thor/blob/b2d98fea78fd993b936fc434a3ad722e73ad6bc5/lib/thor/shell/wrapped_printer.rb
lib/thor/shell/wrapped_printer.rb
require_relative "column_printer" require_relative "terminal" class Thor module Shell class WrappedPrinter < ColumnPrinter def print(message) width = Terminal.terminal_width - @indent paras = message.split("\n\n") paras.map! do |unwrapped| words = unwrapped.split(" ") ...
ruby
MIT
b2d98fea78fd993b936fc434a3ad722e73ad6bc5
2026-01-04T15:43:28.376179Z
false
rails/thor
https://github.com/rails/thor/blob/b2d98fea78fd993b936fc434a3ad722e73ad6bc5/lib/thor/shell/table_printer.rb
lib/thor/shell/table_printer.rb
require_relative "column_printer" require_relative "terminal" class Thor module Shell class TablePrinter < ColumnPrinter BORDER_SEPARATOR = :separator def initialize(stdout, options = {}) super @formats = [] @maximas = [] @colwidth = options[:colwidth] @trunca...
ruby
MIT
b2d98fea78fd993b936fc434a3ad722e73ad6bc5
2026-01-04T15:43:28.376179Z
false
rails/thor
https://github.com/rails/thor/blob/b2d98fea78fd993b936fc434a3ad722e73ad6bc5/lib/thor/shell/html.rb
lib/thor/shell/html.rb
require_relative "basic" require_relative "lcs_diff" class Thor module Shell # Inherit from Thor::Shell::Basic and add set_color behavior. Check # Thor::Shell::Basic to see all available methods. # class HTML < Basic include LCSDiff # The start of an HTML bold sequence. BOLD ...
ruby
MIT
b2d98fea78fd993b936fc434a3ad722e73ad6bc5
2026-01-04T15:43:28.376179Z
false
rails/thor
https://github.com/rails/thor/blob/b2d98fea78fd993b936fc434a3ad722e73ad6bc5/lib/thor/parser/options.rb
lib/thor/parser/options.rb
class Thor class Options < Arguments #:nodoc: LONG_RE = /^(--\w+(?:-\w+)*)$/ SHORT_RE = /^(-[a-z])$/i EQ_RE = /^(--\w+(?:-\w+)*|-[a-z])=(.*)$/i SHORT_SQ_RE = /^-([a-z]{2,})$/i # Allow either -x -v or -xv style for single char args SHORT_NUM = /^(-[a-z])#{NUMERIC}$/i OPTS_END ...
ruby
MIT
b2d98fea78fd993b936fc434a3ad722e73ad6bc5
2026-01-04T15:43:28.376179Z
false
rails/thor
https://github.com/rails/thor/blob/b2d98fea78fd993b936fc434a3ad722e73ad6bc5/lib/thor/parser/arguments.rb
lib/thor/parser/arguments.rb
class Thor class Arguments #:nodoc: NUMERIC = /[-+]?(\d*\.\d+|\d+)/ # Receives an array of args and returns two arrays, one with arguments # and one with switches. # def self.split(args) arguments = [] args.each do |item| break if item.is_a?(String) && item =~ /^-/ ar...
ruby
MIT
b2d98fea78fd993b936fc434a3ad722e73ad6bc5
2026-01-04T15:43:28.376179Z
false
rails/thor
https://github.com/rails/thor/blob/b2d98fea78fd993b936fc434a3ad722e73ad6bc5/lib/thor/parser/option.rb
lib/thor/parser/option.rb
class Thor class Option < Argument #:nodoc: attr_reader :aliases, :group, :lazy_default, :hide, :repeatable VALID_TYPES = [:boolean, :numeric, :hash, :array, :string] def initialize(name, options = {}) @check_default_type = options[:check_default_type] options[:required] = false unless optio...
ruby
MIT
b2d98fea78fd993b936fc434a3ad722e73ad6bc5
2026-01-04T15:43:28.376179Z
false
rails/thor
https://github.com/rails/thor/blob/b2d98fea78fd993b936fc434a3ad722e73ad6bc5/lib/thor/parser/argument.rb
lib/thor/parser/argument.rb
class Thor class Argument #:nodoc: VALID_TYPES = [:numeric, :hash, :array, :string] attr_reader :name, :description, :enum, :required, :type, :default, :banner alias_method :human_name, :name def initialize(name, options = {}) class_name = self.class.name.split("::").last type = options...
ruby
MIT
b2d98fea78fd993b936fc434a3ad722e73ad6bc5
2026-01-04T15:43:28.376179Z
false
activerecord-hackery/ransack
https://github.com/activerecord-hackery/ransack/blob/271cb42db33a2fe168f74b4844b9198253f52674/spec/console.rb
spec/console.rb
Bundler.setup require 'factory_bot' require 'faker' require 'ransack' Dir[File.expand_path('../../spec/{helpers,support,factories}/*.rb', __FILE__)] .each do |f| require f end Faker::Config.random = Random.new(0) Schema.create
ruby
MIT
271cb42db33a2fe168f74b4844b9198253f52674
2026-01-04T15:41:47.582999Z
false
activerecord-hackery/ransack
https://github.com/activerecord-hackery/ransack/blob/271cb42db33a2fe168f74b4844b9198253f52674/spec/spec_helper.rb
spec/spec_helper.rb
require 'ransack' require 'factory_bot' require 'faker' require 'action_controller' require 'ransack/helpers' require 'pry' require 'simplecov' require 'byebug' require 'rspec' SimpleCov.start I18n.enforce_available_locales = false Time.zone = 'Eastern Time (US & Canada)' I18n.load_path += Dir[File.join(File.dirname(_...
ruby
MIT
271cb42db33a2fe168f74b4844b9198253f52674
2026-01-04T15:41:47.582999Z
false
activerecord-hackery/ransack
https://github.com/activerecord-hackery/ransack/blob/271cb42db33a2fe168f74b4844b9198253f52674/spec/support/schema.rb
spec/support/schema.rb
require 'active_record' require 'activerecord-postgis-adapter' case ENV['DB'].try(:downcase) when 'mysql', 'mysql2' # To test with MySQL: `DB=mysql bundle exec rake spec` ActiveRecord::Base.establish_connection( adapter: 'mysql2', database: 'ransack', username: ENV.fetch("MYSQL_USERNAME") { "root" }, ...
ruby
MIT
271cb42db33a2fe168f74b4844b9198253f52674
2026-01-04T15:41:47.582999Z
false
activerecord-hackery/ransack
https://github.com/activerecord-hackery/ransack/blob/271cb42db33a2fe168f74b4844b9198253f52674/spec/helpers/ransack_helper.rb
spec/helpers/ransack_helper.rb
module RansackHelper def quote_table_name(table) ActiveRecord::Base.connection.quote_table_name(table) end def quote_column_name(column) ActiveRecord::Base.connection.quote_column_name(column) end end
ruby
MIT
271cb42db33a2fe168f74b4844b9198253f52674
2026-01-04T15:41:47.582999Z
false
activerecord-hackery/ransack
https://github.com/activerecord-hackery/ransack/blob/271cb42db33a2fe168f74b4844b9198253f52674/spec/helpers/polyamorous_helper.rb
spec/helpers/polyamorous_helper.rb
module PolyamorousHelper def new_join_association(reflection, children, klass) Polyamorous::JoinAssociation.new reflection, children, klass end def new_join_dependency(klass, associations = {}) Polyamorous::JoinDependency.new klass, klass.arel_table, associations, Polyamorous::InnerJoin end def new_...
ruby
MIT
271cb42db33a2fe168f74b4844b9198253f52674
2026-01-04T15:41:47.582999Z
false
activerecord-hackery/ransack
https://github.com/activerecord-hackery/ransack/blob/271cb42db33a2fe168f74b4844b9198253f52674/spec/factories/notes.rb
spec/factories/notes.rb
FactoryBot.define do factory :note do note { Faker::Lorem.words(number: 7).join(' ') } trait :for_person do association :notable, factory: :person end trait :for_article do association :notable, factory: :article end end end
ruby
MIT
271cb42db33a2fe168f74b4844b9198253f52674
2026-01-04T15:41:47.582999Z
false
activerecord-hackery/ransack
https://github.com/activerecord-hackery/ransack/blob/271cb42db33a2fe168f74b4844b9198253f52674/spec/factories/comments.rb
spec/factories/comments.rb
FactoryBot.define do factory :comment do association :article association :person body { Faker::Lorem.paragraph } end end
ruby
MIT
271cb42db33a2fe168f74b4844b9198253f52674
2026-01-04T15:41:47.582999Z
false
activerecord-hackery/ransack
https://github.com/activerecord-hackery/ransack/blob/271cb42db33a2fe168f74b4844b9198253f52674/spec/factories/articles.rb
spec/factories/articles.rb
FactoryBot.define do factory :article do association :person title { Faker::Lorem.sentence } body { Faker::Lorem.paragraph } end end
ruby
MIT
271cb42db33a2fe168f74b4844b9198253f52674
2026-01-04T15:41:47.582999Z
false
activerecord-hackery/ransack
https://github.com/activerecord-hackery/ransack/blob/271cb42db33a2fe168f74b4844b9198253f52674/spec/factories/people.rb
spec/factories/people.rb
FactoryBot.define do factory :person do name { Faker::Name.name } email { "test@example.com" } sequence(:salary) { |n| 30000 + (n * 1000) } only_sort { Faker::Lorem.words(number: 3).join(' ') } only_search { Faker::Lorem.words(number: 3).join(' ') } only_admin { Faker::Lorem.words(number: 3).j...
ruby
MIT
271cb42db33a2fe168f74b4844b9198253f52674
2026-01-04T15:41:47.582999Z
false
activerecord-hackery/ransack
https://github.com/activerecord-hackery/ransack/blob/271cb42db33a2fe168f74b4844b9198253f52674/spec/factories/tags.rb
spec/factories/tags.rb
FactoryBot.define do factory :tag do name { Faker::Lorem.words(number: 3).join(' ') } end end
ruby
MIT
271cb42db33a2fe168f74b4844b9198253f52674
2026-01-04T15:41:47.582999Z
false
activerecord-hackery/ransack
https://github.com/activerecord-hackery/ransack/blob/271cb42db33a2fe168f74b4844b9198253f52674/spec/ransack/search_spec.rb
spec/ransack/search_spec.rb
require 'spec_helper' module Ransack describe Search do describe '#initialize' do it 'removes empty conditions before building' do expect_any_instance_of(Search).to receive(:build).with({}) Search.new(Person, name_eq: '') end it 'keeps conditions with a false value before build...
ruby
MIT
271cb42db33a2fe168f74b4844b9198253f52674
2026-01-04T15:41:47.582999Z
false
activerecord-hackery/ransack
https://github.com/activerecord-hackery/ransack/blob/271cb42db33a2fe168f74b4844b9198253f52674/spec/ransack/predicate_spec.rb
spec/ransack/predicate_spec.rb
require 'spec_helper' module Ransack TRUE_VALUES = [true, 1, '1', 't', 'T', 'true', 'TRUE'].to_set FALSE_VALUES = [false, 0, '0', 'f', 'F', 'false', 'FALSE'].to_set describe Predicate do before do @s = Search.new(Person) end shared_examples 'wildcard escaping' do |method, regexp| it ...
ruby
MIT
271cb42db33a2fe168f74b4844b9198253f52674
2026-01-04T15:41:47.582999Z
false
activerecord-hackery/ransack
https://github.com/activerecord-hackery/ransack/blob/271cb42db33a2fe168f74b4844b9198253f52674/spec/ransack/configuration_spec.rb
spec/ransack/configuration_spec.rb
require 'spec_helper' module Ransack describe Configuration do it 'yields Ransack on configure' do Ransack.configure { |config| expect(config).to eq Ransack } end it 'adds predicates' do Ransack.configure do |config| config.add_predicate :test_predicate end expect(Ransac...
ruby
MIT
271cb42db33a2fe168f74b4844b9198253f52674
2026-01-04T15:41:47.582999Z
false
activerecord-hackery/ransack
https://github.com/activerecord-hackery/ransack/blob/271cb42db33a2fe168f74b4844b9198253f52674/spec/ransack/ransacker_spec.rb
spec/ransack/ransacker_spec.rb
require 'spec_helper' module Ransack describe Ransacker do let(:klass) { Person } let(:name) { :test_ransacker } let(:opts) { {} } describe '#initialize' do context 'with minimal options' do subject { Ransacker.new(klass, name, opts) } it 'sets the name' do expect(su...
ruby
MIT
271cb42db33a2fe168f74b4844b9198253f52674
2026-01-04T15:41:47.582999Z
false
activerecord-hackery/ransack
https://github.com/activerecord-hackery/ransack/blob/271cb42db33a2fe168f74b4844b9198253f52674/spec/ransack/translate_spec.rb
spec/ransack/translate_spec.rb
require 'spec_helper' module Ransack describe Translate do describe '.attribute' do it 'translate namespaced attribute like AR does' do ar_translation = ::Namespace::Article.human_attribute_name(:title) ransack_translation = Ransack::Translate.attribute( :title, context:...
ruby
MIT
271cb42db33a2fe168f74b4844b9198253f52674
2026-01-04T15:41:47.582999Z
false
activerecord-hackery/ransack
https://github.com/activerecord-hackery/ransack/blob/271cb42db33a2fe168f74b4844b9198253f52674/spec/ransack/invalid_search_error_spec.rb
spec/ransack/invalid_search_error_spec.rb
require 'spec_helper' module Ransack describe InvalidSearchError do it 'inherits from ArgumentError' do expect(InvalidSearchError.superclass).to eq(ArgumentError) end it 'can be instantiated with a message' do error = InvalidSearchError.new('Test error message') expect(error.message).t...
ruby
MIT
271cb42db33a2fe168f74b4844b9198253f52674
2026-01-04T15:41:47.582999Z
false
activerecord-hackery/ransack
https://github.com/activerecord-hackery/ransack/blob/271cb42db33a2fe168f74b4844b9198253f52674/spec/ransack/helpers/form_builder_spec.rb
spec/ransack/helpers/form_builder_spec.rb
require 'spec_helper' module Ransack module Helpers describe FormBuilder do router = ActionDispatch::Routing::RouteSet.new router.draw do resources :people, :comments, :notes end include router.url_helpers # FIXME: figure out a cleaner way to get this behavior before...
ruby
MIT
271cb42db33a2fe168f74b4844b9198253f52674
2026-01-04T15:41:47.582999Z
false
activerecord-hackery/ransack
https://github.com/activerecord-hackery/ransack/blob/271cb42db33a2fe168f74b4844b9198253f52674/spec/ransack/helpers/form_helper_spec.rb
spec/ransack/helpers/form_helper_spec.rb
require 'spec_helper' module Ransack module Helpers describe FormHelper do router = ActionDispatch::Routing::RouteSet.new router.draw do resources :people, :notes namespace :admin do resources :comments end end include router.url_helpers # FIXME: ...
ruby
MIT
271cb42db33a2fe168f74b4844b9198253f52674
2026-01-04T15:41:47.582999Z
true
activerecord-hackery/ransack
https://github.com/activerecord-hackery/ransack/blob/271cb42db33a2fe168f74b4844b9198253f52674/spec/ransack/nodes/value_spec.rb
spec/ransack/nodes/value_spec.rb
require 'spec_helper' module Ransack module Nodes describe Value do let(:context) { Context.for(Person) } subject do Value.new(context, raw_value) end context "with a date value" do let(:raw_value) { "2022-05-23" } [:date].each do |type| it "should cas...
ruby
MIT
271cb42db33a2fe168f74b4844b9198253f52674
2026-01-04T15:41:47.582999Z
false
activerecord-hackery/ransack
https://github.com/activerecord-hackery/ransack/blob/271cb42db33a2fe168f74b4844b9198253f52674/spec/ransack/nodes/condition_spec.rb
spec/ransack/nodes/condition_spec.rb
require 'spec_helper' module Ransack module Nodes describe Condition do context 'bug report #1245' do it 'preserves tuple behavior' do ransack_hash = { m: 'and', g: [ { title_type_in: ['["title 1", ""]'] } ] } ...
ruby
MIT
271cb42db33a2fe168f74b4844b9198253f52674
2026-01-04T15:41:47.582999Z
false
activerecord-hackery/ransack
https://github.com/activerecord-hackery/ransack/blob/271cb42db33a2fe168f74b4844b9198253f52674/spec/ransack/nodes/grouping_spec.rb
spec/ransack/nodes/grouping_spec.rb
require 'spec_helper' module Ransack module Nodes describe Grouping do before do @g = 1 end let(:context) { Context.for(Person) } subject { described_class.new(context) } describe '#attribute_method?' do context 'for attributes of the context' do it 'is ...
ruby
MIT
271cb42db33a2fe168f74b4844b9198253f52674
2026-01-04T15:41:47.582999Z
false
activerecord-hackery/ransack
https://github.com/activerecord-hackery/ransack/blob/271cb42db33a2fe168f74b4844b9198253f52674/spec/ransack/adapters/active_record/context_spec.rb
spec/ransack/adapters/active_record/context_spec.rb
require 'spec_helper' module Ransack module Adapters module ActiveRecord version = ::ActiveRecord::VERSION AR_version = "#{version::MAJOR}.#{version::MINOR}" describe Context do subject { Context.new(Person) } it 'has an Active Record alias tracker method' do expect(...
ruby
MIT
271cb42db33a2fe168f74b4844b9198253f52674
2026-01-04T15:41:47.582999Z
false
activerecord-hackery/ransack
https://github.com/activerecord-hackery/ransack/blob/271cb42db33a2fe168f74b4844b9198253f52674/spec/ransack/adapters/active_record/base_spec.rb
spec/ransack/adapters/active_record/base_spec.rb
require 'spec_helper' module Ransack module Adapters module ActiveRecord describe Base do subject { ::ActiveRecord::Base } it { should respond_to :ransack } describe '#search' do subject { Person.ransack } it { should be_a Search } it 'has a Relation...
ruby
MIT
271cb42db33a2fe168f74b4844b9198253f52674
2026-01-04T15:41:47.582999Z
true
activerecord-hackery/ransack
https://github.com/activerecord-hackery/ransack/blob/271cb42db33a2fe168f74b4844b9198253f52674/spec/polyamorous/activerecord_compatibility_spec.rb
spec/polyamorous/activerecord_compatibility_spec.rb
require 'spec_helper' module Polyamorous describe "ActiveRecord Compatibility" do it 'works with self joins and includes' do trade_account = Account.create! Account.create!(trade_account: trade_account) accounts = Account.joins(:trade_account).includes(:trade_account, :agent_account) acc...
ruby
MIT
271cb42db33a2fe168f74b4844b9198253f52674
2026-01-04T15:41:47.582999Z
false
activerecord-hackery/ransack
https://github.com/activerecord-hackery/ransack/blob/271cb42db33a2fe168f74b4844b9198253f52674/spec/polyamorous/join_association_spec.rb
spec/polyamorous/join_association_spec.rb
require 'spec_helper' module Polyamorous describe JoinAssociation do let(:join_dependency) { new_join_dependency Note, {} } let(:reflection) { Note.reflect_on_association(:notable) } let(:parent) { join_dependency.send(:join_root) } let(:join_association) { new_join_association(reflection, pare...
ruby
MIT
271cb42db33a2fe168f74b4844b9198253f52674
2026-01-04T15:41:47.582999Z
false
activerecord-hackery/ransack
https://github.com/activerecord-hackery/ransack/blob/271cb42db33a2fe168f74b4844b9198253f52674/spec/polyamorous/join_spec.rb
spec/polyamorous/join_spec.rb
require 'spec_helper' module Polyamorous describe Join do it 'is a tree node' do join = new_join(:articles, :outer) expect(join).to be_kind_of(TreeNode) end it 'can be added to a tree' do join = new_join(:articles, :outer) tree_hash = {} join.add_to_tree(tree_hash) ...
ruby
MIT
271cb42db33a2fe168f74b4844b9198253f52674
2026-01-04T15:41:47.582999Z
false
activerecord-hackery/ransack
https://github.com/activerecord-hackery/ransack/blob/271cb42db33a2fe168f74b4844b9198253f52674/spec/polyamorous/join_dependency_spec.rb
spec/polyamorous/join_dependency_spec.rb
require 'spec_helper' module Polyamorous describe JoinDependency do context 'with symbol joins' do subject { new_join_dependency Person, articles: :comments } specify { expect(subject.send(:join_root).drop(1).size) .to eq(2) } specify { expect(subject.send(:join_root).drop(1).map(&:joi...
ruby
MIT
271cb42db33a2fe168f74b4844b9198253f52674
2026-01-04T15:41:47.582999Z
false
activerecord-hackery/ransack
https://github.com/activerecord-hackery/ransack/blob/271cb42db33a2fe168f74b4844b9198253f52674/lib/ransack.rb
lib/ransack.rb
require 'active_support/dependencies/autoload' require 'active_support/deprecation' require 'active_support/deprecator' require 'active_support/core_ext' require 'ransack/configuration' require 'polyamorous/polyamorous' module Ransack extend Configuration class UntraversableAssociationError < StandardError; end e...
ruby
MIT
271cb42db33a2fe168f74b4844b9198253f52674
2026-01-04T15:41:47.582999Z
false
activerecord-hackery/ransack
https://github.com/activerecord-hackery/ransack/blob/271cb42db33a2fe168f74b4844b9198253f52674/lib/ransack/active_record.rb
lib/ransack/active_record.rb
require 'ransack/adapters/active_record/base' ActiveSupport.on_load(:active_record) do extend Ransack::Adapters::ActiveRecord::Base Ransack::SUPPORTS_ATTRIBUTE_ALIAS = begin ActiveRecord::Base.respond_to?(:attribute_aliases) rescue NameError false end end require 'ransack/adapters/active_record/con...
ruby
MIT
271cb42db33a2fe168f74b4844b9198253f52674
2026-01-04T15:41:47.582999Z
false
activerecord-hackery/ransack
https://github.com/activerecord-hackery/ransack/blob/271cb42db33a2fe168f74b4844b9198253f52674/lib/ransack/predicate.rb
lib/ransack/predicate.rb
module Ransack class Predicate attr_reader :name, :arel_predicate, :type, :formatter, :validator, :compound, :wants_array, :case_insensitive class << self def names Ransack.predicates.keys end def named(name) Ransack.predicates[(name || Ransack.options[:def...
ruby
MIT
271cb42db33a2fe168f74b4844b9198253f52674
2026-01-04T15:41:47.582999Z
false
activerecord-hackery/ransack
https://github.com/activerecord-hackery/ransack/blob/271cb42db33a2fe168f74b4844b9198253f52674/lib/ransack/ransacker.rb
lib/ransack/ransacker.rb
module Ransack class Ransacker attr_reader :name, :type, :formatter, :args delegate :call, to: :@callable def initialize(klass, name, opts = {}, &block) @klass, @name = klass, name @type = opts[:type] || :string @args = opts[:args] || [:parent] @formatter = opts[:formatter] ...
ruby
MIT
271cb42db33a2fe168f74b4844b9198253f52674
2026-01-04T15:41:47.582999Z
false
activerecord-hackery/ransack
https://github.com/activerecord-hackery/ransack/blob/271cb42db33a2fe168f74b4844b9198253f52674/lib/ransack/version.rb
lib/ransack/version.rb
module Ransack VERSION = '4.4.1' end
ruby
MIT
271cb42db33a2fe168f74b4844b9198253f52674
2026-01-04T15:41:47.582999Z
false
activerecord-hackery/ransack
https://github.com/activerecord-hackery/ransack/blob/271cb42db33a2fe168f74b4844b9198253f52674/lib/ransack/translate.rb
lib/ransack/translate.rb
require 'i18n' I18n.load_path += Dir[ File.join(File.dirname(__FILE__), 'locale'.freeze, '*.yml'.freeze) ] module Ransack module Translate class << self def word(key, options = {}) I18n.translate(:"ransack.#{key}", default: key.to_s) end def predicate(key, options = {}) I18n...
ruby
MIT
271cb42db33a2fe168f74b4844b9198253f52674
2026-01-04T15:41:47.582999Z
false
activerecord-hackery/ransack
https://github.com/activerecord-hackery/ransack/blob/271cb42db33a2fe168f74b4844b9198253f52674/lib/ransack/invalid_search_error.rb
lib/ransack/invalid_search_error.rb
module Ransack class InvalidSearchError < ArgumentError; end end
ruby
MIT
271cb42db33a2fe168f74b4844b9198253f52674
2026-01-04T15:41:47.582999Z
false
activerecord-hackery/ransack
https://github.com/activerecord-hackery/ransack/blob/271cb42db33a2fe168f74b4844b9198253f52674/lib/ransack/constants.rb
lib/ransack/constants.rb
module Ransack module Constants OR = 'or'.freeze AND = 'and'.freeze CAP_SEARCH = 'Search'.freeze SEARCH = 'search'.freeze SEARCHES = 'searches'.freeze ATTRIBUTE = 'attribute'.freeze ATTRIBUTES = 'attribu...
ruby
MIT
271cb42db33a2fe168f74b4844b9198253f52674
2026-01-04T15:41:47.582999Z
false
activerecord-hackery/ransack
https://github.com/activerecord-hackery/ransack/blob/271cb42db33a2fe168f74b4844b9198253f52674/lib/ransack/search.rb
lib/ransack/search.rb
require 'ransack/nodes/bindable' require 'ransack/nodes/node' require 'ransack/nodes/attribute' require 'ransack/nodes/value' require 'ransack/nodes/condition' require 'ransack/nodes/sort' require 'ransack/nodes/grouping' require 'ransack/context' require 'ransack/naming' require 'ransack/invalid_search_error' module ...
ruby
MIT
271cb42db33a2fe168f74b4844b9198253f52674
2026-01-04T15:41:47.582999Z
false
activerecord-hackery/ransack
https://github.com/activerecord-hackery/ransack/blob/271cb42db33a2fe168f74b4844b9198253f52674/lib/ransack/helpers.rb
lib/ransack/helpers.rb
require 'ransack/helpers/form_builder' require 'ransack/helpers/form_helper'
ruby
MIT
271cb42db33a2fe168f74b4844b9198253f52674
2026-01-04T15:41:47.582999Z
false
activerecord-hackery/ransack
https://github.com/activerecord-hackery/ransack/blob/271cb42db33a2fe168f74b4844b9198253f52674/lib/ransack/configuration.rb
lib/ransack/configuration.rb
require 'ransack/constants' require 'ransack/predicate' module Ransack module Configuration mattr_accessor :predicates, :options class PredicateCollection attr_reader :sorted_names_with_underscores def initialize @collection = {} @sorted_names_with_underscores = [] end ...
ruby
MIT
271cb42db33a2fe168f74b4844b9198253f52674
2026-01-04T15:41:47.582999Z
false
activerecord-hackery/ransack
https://github.com/activerecord-hackery/ransack/blob/271cb42db33a2fe168f74b4844b9198253f52674/lib/ransack/visitor.rb
lib/ransack/visitor.rb
module Ransack class Visitor def accept(object) visit(object) end def can_accept?(object) respond_to? DISPATCH[object.class] end def visit_Array(object) object.map { |o| accept(o) }.compact end def visit_Ransack_Nodes_Condition(object) object.arel_predicate if o...
ruby
MIT
271cb42db33a2fe168f74b4844b9198253f52674
2026-01-04T15:41:47.582999Z
false
activerecord-hackery/ransack
https://github.com/activerecord-hackery/ransack/blob/271cb42db33a2fe168f74b4844b9198253f52674/lib/ransack/context.rb
lib/ransack/context.rb
require 'ransack/visitor' module Ransack class Context attr_reader :search, :object, :klass, :base, :engine, :arel_visitor attr_accessor :auth_object, :search_key attr_reader :arel_visitor class << self def for_class(klass, options = {}) if klass < ActiveRecord::Base Adapter...
ruby
MIT
271cb42db33a2fe168f74b4844b9198253f52674
2026-01-04T15:41:47.582999Z
false
activerecord-hackery/ransack
https://github.com/activerecord-hackery/ransack/blob/271cb42db33a2fe168f74b4844b9198253f52674/lib/ransack/naming.rb
lib/ransack/naming.rb
module Ransack module Naming def self.included(base) base.extend ClassMethods end def persisted? false end def to_key nil end def to_param nil end def to_model self end def model_name self.class.model_name end end class Nam...
ruby
MIT
271cb42db33a2fe168f74b4844b9198253f52674
2026-01-04T15:41:47.582999Z
false
activerecord-hackery/ransack
https://github.com/activerecord-hackery/ransack/blob/271cb42db33a2fe168f74b4844b9198253f52674/lib/ransack/helpers/form_helper.rb
lib/ransack/helpers/form_helper.rb
module Ransack module Helpers module FormHelper # +search_form_for+ # # <%= search_form_for(@q) do |f| %> # def search_form_for(record, options = {}, &proc) search = extract_search_and_set_url(record, options, 'search_form_for') options[:html] ||= {} html_o...
ruby
MIT
271cb42db33a2fe168f74b4844b9198253f52674
2026-01-04T15:41:47.582999Z
false
activerecord-hackery/ransack
https://github.com/activerecord-hackery/ransack/blob/271cb42db33a2fe168f74b4844b9198253f52674/lib/ransack/helpers/form_builder.rb
lib/ransack/helpers/form_builder.rb
require 'action_view' module ActionView::Helpers::Tags # TODO: Find a better way to solve this issue! # This patch is needed since this Rails commit: # https://github.com/rails/rails/commit/c1a118a class Base private def value if @allow_method_names_outside_object object.send @method_nam...
ruby
MIT
271cb42db33a2fe168f74b4844b9198253f52674
2026-01-04T15:41:47.582999Z
false
activerecord-hackery/ransack
https://github.com/activerecord-hackery/ransack/blob/271cb42db33a2fe168f74b4844b9198253f52674/lib/ransack/nodes/value.rb
lib/ransack/nodes/value.rb
module Ransack module Nodes class Value < Node attr_accessor :value delegate :present?, :blank?, to: :value def initialize(context, value = nil) super(context) @value = value end def persisted? false end def eql?(other) self.class == oth...
ruby
MIT
271cb42db33a2fe168f74b4844b9198253f52674
2026-01-04T15:41:47.582999Z
false
activerecord-hackery/ransack
https://github.com/activerecord-hackery/ransack/blob/271cb42db33a2fe168f74b4844b9198253f52674/lib/ransack/nodes/node.rb
lib/ransack/nodes/node.rb
module Ransack module Nodes class Node attr_reader :context delegate :contextualize, to: :context class_attribute :i18n_words class_attribute :i18n_aliases self.i18n_words = [] self.i18n_aliases = {} class << self def i18n_word(*args) self.i18n_words +=...
ruby
MIT
271cb42db33a2fe168f74b4844b9198253f52674
2026-01-04T15:41:47.582999Z
false
activerecord-hackery/ransack
https://github.com/activerecord-hackery/ransack/blob/271cb42db33a2fe168f74b4844b9198253f52674/lib/ransack/nodes/attribute.rb
lib/ransack/nodes/attribute.rb
module Ransack module Nodes class Attribute < Node include Bindable attr_reader :name, :ransacker_args delegate :blank?, :present?, to: :name delegate :engine, to: :context def initialize(context, name = nil, ransacker_args = []) super(context) self.name = name unl...
ruby
MIT
271cb42db33a2fe168f74b4844b9198253f52674
2026-01-04T15:41:47.582999Z
false
activerecord-hackery/ransack
https://github.com/activerecord-hackery/ransack/blob/271cb42db33a2fe168f74b4844b9198253f52674/lib/ransack/nodes/sort.rb
lib/ransack/nodes/sort.rb
module Ransack module Nodes class Sort < Node include Bindable attr_reader :name, :dir, :ransacker_args i18n_word :asc, :desc class << self def extract(context, str) return if str.blank? attr, direction = str.split(/\s+/, 2) self.new(context).build(n...
ruby
MIT
271cb42db33a2fe168f74b4844b9198253f52674
2026-01-04T15:41:47.582999Z
false
activerecord-hackery/ransack
https://github.com/activerecord-hackery/ransack/blob/271cb42db33a2fe168f74b4844b9198253f52674/lib/ransack/nodes/bindable.rb
lib/ransack/nodes/bindable.rb
module Ransack module Nodes module Bindable attr_accessor :parent, :attr_name def attr @attr ||= get_arel_attribute end alias :arel_attribute :attr def ransacker klass._ransackers[attr_name] end def klass @klass ||= context.klassify(parent) ...
ruby
MIT
271cb42db33a2fe168f74b4844b9198253f52674
2026-01-04T15:41:47.582999Z
false
activerecord-hackery/ransack
https://github.com/activerecord-hackery/ransack/blob/271cb42db33a2fe168f74b4844b9198253f52674/lib/ransack/nodes/grouping.rb
lib/ransack/nodes/grouping.rb
module Ransack module Nodes class Grouping < Node attr_reader :conditions attr_accessor :combinator alias :m :combinator alias :m= :combinator= i18n_word :condition, :and, :or i18n_alias c: :condition, n: :and, o: :or delegate :each, to: :values def initialize(co...
ruby
MIT
271cb42db33a2fe168f74b4844b9198253f52674
2026-01-04T15:41:47.582999Z
false
activerecord-hackery/ransack
https://github.com/activerecord-hackery/ransack/blob/271cb42db33a2fe168f74b4844b9198253f52674/lib/ransack/nodes/condition.rb
lib/ransack/nodes/condition.rb
require 'ransack/invalid_search_error' module Ransack module Nodes class Condition < Node i18n_word :attribute, :predicate, :combinator, :value i18n_alias a: :attribute, p: :predicate, m: :combinator, v: :value attr_accessor :predicate class << self def extract(...
ruby
MIT
271cb42db33a2fe168f74b4844b9198253f52674
2026-01-04T15:41:47.582999Z
false
activerecord-hackery/ransack
https://github.com/activerecord-hackery/ransack/blob/271cb42db33a2fe168f74b4844b9198253f52674/lib/ransack/adapters/active_record/base.rb
lib/ransack/adapters/active_record/base.rb
module Ransack module Adapters module ActiveRecord module Base def self.extended(base) base.class_eval do class_attribute :_ransackers class_attribute :_ransack_aliases self._ransackers ||= {} self._ransack_aliases ||= {} end ...
ruby
MIT
271cb42db33a2fe168f74b4844b9198253f52674
2026-01-04T15:41:47.582999Z
false
activerecord-hackery/ransack
https://github.com/activerecord-hackery/ransack/blob/271cb42db33a2fe168f74b4844b9198253f52674/lib/ransack/adapters/active_record/context.rb
lib/ransack/adapters/active_record/context.rb
require 'ransack/context' require 'polyamorous/polyamorous' module Ransack module Adapters module ActiveRecord class Context < ::Ransack::Context def relation_for(object) object.all end def type_for(attr) return nil unless attr && attr.valid? relation...
ruby
MIT
271cb42db33a2fe168f74b4844b9198253f52674
2026-01-04T15:41:47.582999Z
false
activerecord-hackery/ransack
https://github.com/activerecord-hackery/ransack/blob/271cb42db33a2fe168f74b4844b9198253f52674/lib/polyamorous/tree_node.rb
lib/polyamorous/tree_node.rb
module Polyamorous module TreeNode def add_to_tree(hash) raise NotImplementedError end end end
ruby
MIT
271cb42db33a2fe168f74b4844b9198253f52674
2026-01-04T15:41:47.582999Z
false
activerecord-hackery/ransack
https://github.com/activerecord-hackery/ransack/blob/271cb42db33a2fe168f74b4844b9198253f52674/lib/polyamorous/polyamorous.rb
lib/polyamorous/polyamorous.rb
ActiveSupport.on_load(:active_record) do module Polyamorous InnerJoin = Arel::Nodes::InnerJoin OuterJoin = Arel::Nodes::OuterJoin JoinDependency = ::ActiveRecord::Associations::JoinDependency JoinAssociation = ::ActiveRecord::Associations::JoinDependency::JoinAssociation end require 'polyamorou...
ruby
MIT
271cb42db33a2fe168f74b4844b9198253f52674
2026-01-04T15:41:47.582999Z
false
activerecord-hackery/ransack
https://github.com/activerecord-hackery/ransack/blob/271cb42db33a2fe168f74b4844b9198253f52674/lib/polyamorous/swapping_reflection_class.rb
lib/polyamorous/swapping_reflection_class.rb
module Polyamorous module SwappingReflectionClass def swapping_reflection_klass(reflection, klass) new_reflection = reflection.clone new_reflection.instance_variable_set(:@options, reflection.options.clone) new_reflection.options.delete(:polymorphic) new_reflection.instance_variable_set(:@...
ruby
MIT
271cb42db33a2fe168f74b4844b9198253f52674
2026-01-04T15:41:47.582999Z
false
activerecord-hackery/ransack
https://github.com/activerecord-hackery/ransack/blob/271cb42db33a2fe168f74b4844b9198253f52674/lib/polyamorous/join.rb
lib/polyamorous/join.rb
module Polyamorous class Join include TreeNode attr_accessor :name attr_reader :type, :klass def initialize(name, type = InnerJoin, klass = nil) @name = name @type = convert_to_arel_join_type(type) @klass = convert_to_class(klass) if klass end def klass=(klass) @klas...
ruby
MIT
271cb42db33a2fe168f74b4844b9198253f52674
2026-01-04T15:41:47.582999Z
false
activerecord-hackery/ransack
https://github.com/activerecord-hackery/ransack/blob/271cb42db33a2fe168f74b4844b9198253f52674/lib/polyamorous/activerecord/join_dependency.rb
lib/polyamorous/activerecord/join_dependency.rb
module Polyamorous module JoinDependencyExtensions # Replaces ActiveRecord::Associations::JoinDependency#build def build(associations, base_klass) associations.map do |name, right| if name.is_a? Join reflection = find_reflection base_klass, name.name reflection.check_validity...
ruby
MIT
271cb42db33a2fe168f74b4844b9198253f52674
2026-01-04T15:41:47.582999Z
false
activerecord-hackery/ransack
https://github.com/activerecord-hackery/ransack/blob/271cb42db33a2fe168f74b4844b9198253f52674/lib/polyamorous/activerecord/join_association.rb
lib/polyamorous/activerecord/join_association.rb
module Polyamorous module JoinAssociationExtensions include SwappingReflectionClass def self.prepended(base) base.class_eval { attr_reader :join_type } end def initialize(reflection, children, polymorphic_class = nil, join_type = Arel::Nodes::InnerJoin) @join_type = join_type if pol...
ruby
MIT
271cb42db33a2fe168f74b4844b9198253f52674
2026-01-04T15:41:47.582999Z
false
activerecord-hackery/ransack
https://github.com/activerecord-hackery/ransack/blob/271cb42db33a2fe168f74b4844b9198253f52674/lib/polyamorous/activerecord/join_association_7_2.rb
lib/polyamorous/activerecord/join_association_7_2.rb
module Polyamorous module JoinAssociationExtensions # Same as #join_constraints, but instead of constructing tables from the # given block, uses the ones passed def join_constraints_with_tables(foreign_table, foreign_klass, join_type, alias_tracker, tables) joins = [] chain = [] reflect...
ruby
MIT
271cb42db33a2fe168f74b4844b9198253f52674
2026-01-04T15:41:47.582999Z
false
activerecord-hackery/ransack
https://github.com/activerecord-hackery/ransack/blob/271cb42db33a2fe168f74b4844b9198253f52674/lib/polyamorous/activerecord/reflection.rb
lib/polyamorous/activerecord/reflection.rb
module Polyamorous module ReflectionExtensions def join_scope(table, foreign_table, foreign_klass) if respond_to?(:polymorphic?) && polymorphic? super.where!(foreign_table[foreign_type].eq(klass.name)) else super end end end end
ruby
MIT
271cb42db33a2fe168f74b4844b9198253f52674
2026-01-04T15:41:47.582999Z
false
aasm/aasm
https://github.com/aasm/aasm/blob/726a578808e0f403bfd24e505f9a45319670a6b7/test/minitest_helper.rb
test/minitest_helper.rb
$LOAD_PATH.unshift(File.expand_path(File.dirname(__FILE__))) $LOAD_PATH.unshift(File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec', 'models'))) $LOAD_PATH.unshift(File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib'))) require 'aasm' require 'minitest/autorun' require 'aasm/minitest_spec' require...
ruby
MIT
726a578808e0f403bfd24e505f9a45319670a6b7
2026-01-04T15:43:55.088186Z
false
aasm/aasm
https://github.com/aasm/aasm/blob/726a578808e0f403bfd24e505f9a45319670a6b7/test/unit/minitest_matcher_test.rb
test/unit/minitest_matcher_test.rb
require 'minitest_helper' class StateMachineTest < Minitest::Spec let(:simple) { SimpleExample.new } let(:multiple) { SimpleMultipleExample.new } describe 'transition_from' do it "works for simple state machines" do simple.must_transition_from :initialised, to: :filled_out, on_event: :fill_out ...
ruby
MIT
726a578808e0f403bfd24e505f9a45319670a6b7
2026-01-04T15:43:55.088186Z
false
aasm/aasm
https://github.com/aasm/aasm/blob/726a578808e0f403bfd24e505f9a45319670a6b7/spec/spec_helper.rb
spec/spec_helper.rb
require 'simplecov' SimpleCov.start do add_filter '/spec/' end if ENV['CI'] == 'true' require 'simplecov-cobertura' SimpleCov.formatter = SimpleCov::Formatter::CoberturaFormatter end $LOAD_PATH.unshift(File.expand_path(File.dirname(__FILE__))) $LOAD_PATH.unshift(File.expand_path(File.join(File.dirname(__FILE__)...
ruby
MIT
726a578808e0f403bfd24e505f9a45319670a6b7
2026-01-04T15:43:55.088186Z
false
aasm/aasm
https://github.com/aasm/aasm/blob/726a578808e0f403bfd24e505f9a45319670a6b7/spec/database.rb
spec/database.rb
ActiveRecord::Migration.suppress_messages do %w{gates multiple_gates readers writers transients simples no_scopes multiple_no_scopes no_direct_assignments multiple_no_direct_assignments thieves multiple_thieves localizer_test_models persisted_states provided_and_persisted_states with_enums with_enum_without_columns m...
ruby
MIT
726a578808e0f403bfd24e505f9a45319670a6b7
2026-01-04T15:43:55.088186Z
false
aasm/aasm
https://github.com/aasm/aasm/blob/726a578808e0f403bfd24e505f9a45319670a6b7/spec/models/guardian_without_from_specified.rb
spec/models/guardian_without_from_specified.rb
class GuardianWithoutFromSpecified include AASM aasm do state :alpha, :initial => true state :beta state :gamma event :use_guards_where_the_first_fails do transitions :to => :beta, :guard => :fail transitions :to => :gamma, :guard => :succeed end end def fail; false; end d...
ruby
MIT
726a578808e0f403bfd24e505f9a45319670a6b7
2026-01-04T15:43:55.088186Z
false
aasm/aasm
https://github.com/aasm/aasm/blob/726a578808e0f403bfd24e505f9a45319670a6b7/spec/models/class_with_keyword_arguments.rb
spec/models/class_with_keyword_arguments.rb
# frozen_string_literal: true class CallbackWithOptionalKeywordArguments def initialize(state_machine, my_optional_arg: nil, **_args) @state_machine = state_machine @my_optional_arg = my_optional_arg end def call @state_machine.my_attribute = @my_optional_arg if @my_optional_arg end end class Cal...
ruby
MIT
726a578808e0f403bfd24e505f9a45319670a6b7
2026-01-04T15:43:55.088186Z
false
aasm/aasm
https://github.com/aasm/aasm/blob/726a578808e0f403bfd24e505f9a45319670a6b7/spec/models/event_with_keyword_arguments.rb
spec/models/event_with_keyword_arguments.rb
class EventWithKeywordArguments include AASM aasm do state :open, :initial => true, :column => :status state :closed event :close do before :_before_close transitions from: :open, to: :closed end event :another_close do before :_before_another_close transitions from: :...
ruby
MIT
726a578808e0f403bfd24e505f9a45319670a6b7
2026-01-04T15:43:55.088186Z
false
aasm/aasm
https://github.com/aasm/aasm/blob/726a578808e0f403bfd24e505f9a45319670a6b7/spec/models/foo_callback_multiple.rb
spec/models/foo_callback_multiple.rb
class FooCallbackMultiple include AASM aasm(:left) do state :open, :initial => true, :before_exit => :before_exit state :closed, :before_enter => :before_enter state :final event :close, :success => :success_callback do transitions :from => [:open], :to => [:closed] end event :null ...
ruby
MIT
726a578808e0f403bfd24e505f9a45319670a6b7
2026-01-04T15:43:55.088186Z
false
aasm/aasm
https://github.com/aasm/aasm/blob/726a578808e0f403bfd24e505f9a45319670a6b7/spec/models/parametrised_event.rb
spec/models/parametrised_event.rb
class ParametrisedEvent include AASM aasm do state :sleeping, :initial => true state :showering state :working state :dating state :prettying_up event :wakeup do transitions :from => :sleeping, :to => [:showering, :working] end event :shower do transitions :from => :sle...
ruby
MIT
726a578808e0f403bfd24e505f9a45319670a6b7
2026-01-04T15:43:55.088186Z
false