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 |
|---|---|---|---|---|---|---|---|---|
ankane/searchkick | https://github.com/ankane/searchkick/blob/107d270a0d2d7e1935dc7fee1ea0305edb5e4b3b/test/notifications_test.rb | test/notifications_test.rb | require_relative "test_helper"
class NotificationsTest < Minitest::Test
def test_search
Product.searchkick_index.refresh
notifications = capture_notifications do
Product.search("product").to_a
end
assert_equal 1, notifications.size
assert_equal "search.searchkick", notifications.last[:nam... | ruby | MIT | 107d270a0d2d7e1935dc7fee1ea0305edb5e4b3b | 2026-01-04T15:40:12.176737Z | false |
ankane/searchkick | https://github.com/ankane/searchkick/blob/107d270a0d2d7e1935dc7fee1ea0305edb5e4b3b/test/parameters_test.rb | test/parameters_test.rb | require_relative "test_helper"
class ParametersTest < Minitest::Test
def setup
require "action_controller"
super
end
def test_options
params = ActionController::Parameters.new({store_id: 1})
assert_raises(ActionController::UnfilteredParameters) do
Product.search("*", **params)
end
en... | ruby | MIT | 107d270a0d2d7e1935dc7fee1ea0305edb5e4b3b | 2026-01-04T15:40:12.176737Z | false |
ankane/searchkick | https://github.com/ankane/searchkick/blob/107d270a0d2d7e1935dc7fee1ea0305edb5e4b3b/test/multi_indices_test.rb | test/multi_indices_test.rb | require_relative "test_helper"
class MultiIndicesTest < Minitest::Test
def setup
super
setup_speaker
end
def test_basic
store_names ["Product A"]
store_names ["Product B"], Speaker
assert_search_multi "product", ["Product A", "Product B"]
end
def test_index_name
store_names ["Produc... | ruby | MIT | 107d270a0d2d7e1935dc7fee1ea0305edb5e4b3b | 2026-01-04T15:40:12.176737Z | false |
ankane/searchkick | https://github.com/ankane/searchkick/blob/107d270a0d2d7e1935dc7fee1ea0305edb5e4b3b/test/index_cache_test.rb | test/index_cache_test.rb | require_relative "test_helper"
class IndexCacheTest < Minitest::Test
def setup
Product.class_variable_get(:@@searchkick_index_cache).clear
end
def test_default
object_id = Product.searchkick_index.object_id
3.times do
assert_equal object_id, Product.searchkick_index.object_id
end
end
... | ruby | MIT | 107d270a0d2d7e1935dc7fee1ea0305edb5e4b3b | 2026-01-04T15:40:12.176737Z | false |
ankane/searchkick | https://github.com/ankane/searchkick/blob/107d270a0d2d7e1935dc7fee1ea0305edb5e4b3b/test/multi_search_test.rb | test/multi_search_test.rb | require_relative "test_helper"
class MultiSearchTest < Minitest::Test
def test_basic
store_names ["Product A"]
store_names ["Store A"], Store
products = Product.search("*")
stores = Store.search("*")
Searchkick.multi_search([products, stores])
assert_equal ["Product A"], products.map(&:name)
... | ruby | MIT | 107d270a0d2d7e1935dc7fee1ea0305edb5e4b3b | 2026-01-04T15:40:12.176737Z | false |
ankane/searchkick | https://github.com/ankane/searchkick/blob/107d270a0d2d7e1935dc7fee1ea0305edb5e4b3b/test/scroll_test.rb | test/scroll_test.rb | require_relative "test_helper"
class ScrollTest < Minitest::Test
def test_works
store_names ["Product A", "Product B", "Product C", "Product D", "Product E", "Product F"]
products = Product.search("product", order: {name: :asc}, scroll: '1m', per_page: 2)
assert_equal ["Product A", "Product B"], products... | ruby | MIT | 107d270a0d2d7e1935dc7fee1ea0305edb5e4b3b | 2026-01-04T15:40:12.176737Z | false |
ankane/searchkick | https://github.com/ankane/searchkick/blob/107d270a0d2d7e1935dc7fee1ea0305edb5e4b3b/test/order_test.rb | test/order_test.rb | require_relative "test_helper"
class OrderTest < Minitest::Test
def test_hash
store_names ["Product A", "Product B", "Product C", "Product D"]
assert_order "product", ["Product D", "Product C", "Product B", "Product A"], order: {name: :desc}
assert_order_relation ["Product D", "Product C", "Product B", "... | ruby | MIT | 107d270a0d2d7e1935dc7fee1ea0305edb5e4b3b | 2026-01-04T15:40:12.176737Z | false |
ankane/searchkick | https://github.com/ankane/searchkick/blob/107d270a0d2d7e1935dc7fee1ea0305edb5e4b3b/test/marshal_test.rb | test/marshal_test.rb | require_relative "test_helper"
class MarshalTest < Minitest::Test
def test_marshal
store_names ["Product A"]
assert Marshal.dump(Product.search("*").to_a)
end
def test_marshal_highlights
store_names ["Product A"]
assert Marshal.dump(Product.search("product", highlight: true, load: {dumpable: tru... | ruby | MIT | 107d270a0d2d7e1935dc7fee1ea0305edb5e4b3b | 2026-01-04T15:40:12.176737Z | false |
ankane/searchkick | https://github.com/ankane/searchkick/blob/107d270a0d2d7e1935dc7fee1ea0305edb5e4b3b/test/partial_reindex_test.rb | test/partial_reindex_test.rb | require_relative "test_helper"
class PartialReindexTest < Minitest::Test
def test_record_inline
store [{name: "Hi", color: "Blue"}]
product = Product.first
Searchkick.callbacks(false) do
product.update!(name: "Bye", color: "Red")
end
product.reindex(:search_name, refresh: true)
# nam... | ruby | MIT | 107d270a0d2d7e1935dc7fee1ea0305edb5e4b3b | 2026-01-04T15:40:12.176737Z | false |
ankane/searchkick | https://github.com/ankane/searchkick/blob/107d270a0d2d7e1935dc7fee1ea0305edb5e4b3b/test/callbacks_test.rb | test/callbacks_test.rb | require_relative "test_helper"
class CallbacksTest < Minitest::Test
def test_false
Searchkick.callbacks(false) do
store_names ["Product A", "Product B"]
end
assert_search "product", []
end
def test_bulk
Searchkick.callbacks(:bulk) do
store_names ["Product A", "Product B"]
end
... | ruby | MIT | 107d270a0d2d7e1935dc7fee1ea0305edb5e4b3b | 2026-01-04T15:40:12.176737Z | false |
ankane/searchkick | https://github.com/ankane/searchkick/blob/107d270a0d2d7e1935dc7fee1ea0305edb5e4b3b/test/language_test.rb | test/language_test.rb | require_relative "test_helper"
class LanguageTest < Minitest::Test
def setup
skip "Requires plugin" unless ci? || ENV["TEST_LANGUAGE"]
Song.destroy_all
end
def test_chinese
skip if ci?
# requires https://github.com/medcl/elasticsearch-analysis-ik
with_options({language: "chinese"}) do
... | ruby | MIT | 107d270a0d2d7e1935dc7fee1ea0305edb5e4b3b | 2026-01-04T15:40:12.176737Z | false |
ankane/searchkick | https://github.com/ankane/searchkick/blob/107d270a0d2d7e1935dc7fee1ea0305edb5e4b3b/test/exclude_test.rb | test/exclude_test.rb | require_relative "test_helper"
class ExcludeTest < Minitest::Test
def test_butter
store_names ["Butter Tub", "Peanut Butter Tub"]
assert_search "butter", ["Butter Tub"], exclude: ["peanut butter"]
end
def test_butter_word_start
store_names ["Butter Tub", "Peanut Butter Tub"]
assert_search "butte... | ruby | MIT | 107d270a0d2d7e1935dc7fee1ea0305edb5e4b3b | 2026-01-04T15:40:12.176737Z | false |
ankane/searchkick | https://github.com/ankane/searchkick/blob/107d270a0d2d7e1935dc7fee1ea0305edb5e4b3b/test/support/apartment.rb | test/support/apartment.rb | module Rails
def self.env
ENV["RACK_ENV"]
end
end
tenants = ["tenant1", "tenant2"]
Apartment.configure do |config|
config.tenant_names = tenants
config.database_schema_file = false
config.excluded_models = ["Product", "Store", "Region", "Speaker", "Animal", "Dog", "Cat", "Sku", "Song", "Band"]
end
class... | ruby | MIT | 107d270a0d2d7e1935dc7fee1ea0305edb5e4b3b | 2026-01-04T15:40:12.176737Z | false |
ankane/searchkick | https://github.com/ankane/searchkick/blob/107d270a0d2d7e1935dc7fee1ea0305edb5e4b3b/test/support/activerecord.rb | test/support/activerecord.rb | require "active_record"
# for debugging
ActiveRecord::Base.logger = $logger
# rails does this in activerecord/lib/active_record/railtie.rb
ActiveRecord.default_timezone = :utc
ActiveRecord::Base.time_zone_aware_attributes = true
# migrations
ActiveRecord::Base.establish_connection adapter: "sqlite3", database: ":mem... | ruby | MIT | 107d270a0d2d7e1935dc7fee1ea0305edb5e4b3b | 2026-01-04T15:40:12.176737Z | false |
ankane/searchkick | https://github.com/ankane/searchkick/blob/107d270a0d2d7e1935dc7fee1ea0305edb5e4b3b/test/support/redis.rb | test/support/redis.rb | options = {}
options[:logger] = $logger if !defined?(RedisClient)
Searchkick.redis =
if !defined?(Redis)
RedisClient.config.new_pool
elsif defined?(ConnectionPool)
ConnectionPool.new { Redis.new(**options) }
else
Redis.new(**options)
end
module RedisInstrumentation
def call(command, redis_config... | ruby | MIT | 107d270a0d2d7e1935dc7fee1ea0305edb5e4b3b | 2026-01-04T15:40:12.176737Z | false |
ankane/searchkick | https://github.com/ankane/searchkick/blob/107d270a0d2d7e1935dc7fee1ea0305edb5e4b3b/test/support/mongoid.rb | test/support/mongoid.rb | Mongoid.logger = $logger
Mongo::Logger.logger = $logger if defined?(Mongo::Logger)
Mongoid.configure do |config|
config.connect_to "searchkick_test", server_selection_timeout: 1
end
class Product
include Mongoid::Document
include Mongoid::Timestamps
field :name
field :store_id, type: Integer
field :in_st... | ruby | MIT | 107d270a0d2d7e1935dc7fee1ea0305edb5e4b3b | 2026-01-04T15:40:12.176737Z | false |
ankane/searchkick | https://github.com/ankane/searchkick/blob/107d270a0d2d7e1935dc7fee1ea0305edb5e4b3b/test/support/helpers.rb | test/support/helpers.rb | class Minitest::Test
include ActiveJob::TestHelper
def setup
[Product, Store].each do |model|
setup_model(model)
end
end
protected
def setup_animal
setup_model(Animal)
end
def setup_region
setup_model(Region)
end
def setup_speaker
setup_model(Speaker)
end
def setup_... | ruby | MIT | 107d270a0d2d7e1935dc7fee1ea0305edb5e4b3b | 2026-01-04T15:40:12.176737Z | false |
ankane/searchkick | https://github.com/ankane/searchkick/blob/107d270a0d2d7e1935dc7fee1ea0305edb5e4b3b/test/models/artist.rb | test/models/artist.rb | class Artist
searchkick unscope: true
def should_index?
should_index
end
end
| ruby | MIT | 107d270a0d2d7e1935dc7fee1ea0305edb5e4b3b | 2026-01-04T15:40:12.176737Z | false |
ankane/searchkick | https://github.com/ankane/searchkick/blob/107d270a0d2d7e1935dc7fee1ea0305edb5e4b3b/test/models/region.rb | test/models/region.rb | class Region
searchkick \
geo_shape: [:territory]
attr_accessor :territory
def search_data
{
name: name,
text: text,
territory: territory
}
end
end
| ruby | MIT | 107d270a0d2d7e1935dc7fee1ea0305edb5e4b3b | 2026-01-04T15:40:12.176737Z | false |
ankane/searchkick | https://github.com/ankane/searchkick/blob/107d270a0d2d7e1935dc7fee1ea0305edb5e4b3b/test/models/speaker.rb | test/models/speaker.rb | class Speaker
searchkick \
conversions_v1: ["conversions_a", "conversions_b"],
search_synonyms: [
["clorox", "bleach"],
["burger", "hamburger"],
["bandaids", "bandages"],
["UPPERCASE", "lowercase"],
"led => led,lightbulb",
"halogen lamp => lightbulb",
["United States ... | ruby | MIT | 107d270a0d2d7e1935dc7fee1ea0305edb5e4b3b | 2026-01-04T15:40:12.176737Z | false |
ankane/searchkick | https://github.com/ankane/searchkick/blob/107d270a0d2d7e1935dc7fee1ea0305edb5e4b3b/test/models/animal.rb | test/models/animal.rb | class Animal
searchkick \
inheritance: true,
text_start: [:name],
suggest: [:name]
end
| ruby | MIT | 107d270a0d2d7e1935dc7fee1ea0305edb5e4b3b | 2026-01-04T15:40:12.176737Z | false |
ankane/searchkick | https://github.com/ankane/searchkick/blob/107d270a0d2d7e1935dc7fee1ea0305edb5e4b3b/test/models/store.rb | test/models/store.rb | class Store
mappings = {
properties: {
name: {type: "text"}
}
}
searchkick \
routing: true,
merge_mappings: true,
mappings: mappings
def search_document_id
id
end
def search_routing
name
end
end
| ruby | MIT | 107d270a0d2d7e1935dc7fee1ea0305edb5e4b3b | 2026-01-04T15:40:12.176737Z | false |
ankane/searchkick | https://github.com/ankane/searchkick/blob/107d270a0d2d7e1935dc7fee1ea0305edb5e4b3b/test/models/sku.rb | test/models/sku.rb | class Sku
searchkick callbacks: :async
end
| ruby | MIT | 107d270a0d2d7e1935dc7fee1ea0305edb5e4b3b | 2026-01-04T15:40:12.176737Z | false |
ankane/searchkick | https://github.com/ankane/searchkick/blob/107d270a0d2d7e1935dc7fee1ea0305edb5e4b3b/test/models/product.rb | test/models/product.rb | class Product
searchkick \
synonyms: [
["clorox", "bleach"],
["burger", "hamburger"],
["bandaid", "bandages"],
["UPPERCASE", "lowercase"],
"lightbulb => led,lightbulb",
"lightbulb => halogenlamp"
],
suggest: [:name, :color],
conversions_v1: [:conversions],
conve... | ruby | MIT | 107d270a0d2d7e1935dc7fee1ea0305edb5e4b3b | 2026-01-04T15:40:12.176737Z | false |
ankane/searchkick | https://github.com/ankane/searchkick/blob/107d270a0d2d7e1935dc7fee1ea0305edb5e4b3b/test/models/band.rb | test/models/band.rb | class Band
searchkick
end
| ruby | MIT | 107d270a0d2d7e1935dc7fee1ea0305edb5e4b3b | 2026-01-04T15:40:12.176737Z | false |
ankane/searchkick | https://github.com/ankane/searchkick/blob/107d270a0d2d7e1935dc7fee1ea0305edb5e4b3b/test/models/song.rb | test/models/song.rb | class Song
searchkick
def search_routing
name
end
end
| ruby | MIT | 107d270a0d2d7e1935dc7fee1ea0305edb5e4b3b | 2026-01-04T15:40:12.176737Z | false |
ankane/searchkick | https://github.com/ankane/searchkick/blob/107d270a0d2d7e1935dc7fee1ea0305edb5e4b3b/examples/semantic.rb | examples/semantic.rb | require "bundler/setup"
require "active_record"
require "elasticsearch" # or "opensearch-ruby"
require "informers"
require "searchkick"
ActiveRecord::Base.establish_connection adapter: "sqlite3", database: ":memory:"
ActiveRecord::Schema.verbose = false
ActiveRecord::Schema.define do
create_table :products do |t|
... | ruby | MIT | 107d270a0d2d7e1935dc7fee1ea0305edb5e4b3b | 2026-01-04T15:40:12.176737Z | false |
ankane/searchkick | https://github.com/ankane/searchkick/blob/107d270a0d2d7e1935dc7fee1ea0305edb5e4b3b/examples/hybrid.rb | examples/hybrid.rb | require "bundler/setup"
require "active_record"
require "elasticsearch" # or "opensearch-ruby"
require "informers"
require "searchkick"
ActiveRecord::Base.establish_connection adapter: "sqlite3", database: ":memory:"
ActiveRecord::Schema.verbose = false
ActiveRecord::Schema.define do
create_table :products do |t|
... | ruby | MIT | 107d270a0d2d7e1935dc7fee1ea0305edb5e4b3b | 2026-01-04T15:40:12.176737Z | false |
ankane/searchkick | https://github.com/ankane/searchkick/blob/107d270a0d2d7e1935dc7fee1ea0305edb5e4b3b/lib/searchkick.rb | lib/searchkick.rb | # dependencies
require "active_support"
require "active_support/core_ext/hash/deep_merge"
require "active_support/core_ext/module/attr_internal"
require "active_support/core_ext/module/delegation"
require "active_support/deprecation"
require "active_support/log_subscriber"
require "active_support/notifications"
# stdl... | ruby | MIT | 107d270a0d2d7e1935dc7fee1ea0305edb5e4b3b | 2026-01-04T15:40:12.176737Z | false |
ankane/searchkick | https://github.com/ankane/searchkick/blob/107d270a0d2d7e1935dc7fee1ea0305edb5e4b3b/lib/searchkick/record_data.rb | lib/searchkick/record_data.rb | module Searchkick
class RecordData
TYPE_KEYS = ["type", :type]
attr_reader :index, :record
def initialize(index, record)
@index = index
@record = record
end
def index_data
data = record_data
data[:data] = search_data
{index: data}
end
def update_data(metho... | ruby | MIT | 107d270a0d2d7e1935dc7fee1ea0305edb5e4b3b | 2026-01-04T15:40:12.176737Z | false |
ankane/searchkick | https://github.com/ankane/searchkick/blob/107d270a0d2d7e1935dc7fee1ea0305edb5e4b3b/lib/searchkick/script.rb | lib/searchkick/script.rb | module Searchkick
class Script
attr_reader :source, :lang, :params
def initialize(source, lang: "painless", params: {})
@source = source
@lang = lang
@params = params
end
end
end
| ruby | MIT | 107d270a0d2d7e1935dc7fee1ea0305edb5e4b3b | 2026-01-04T15:40:12.176737Z | false |
ankane/searchkick | https://github.com/ankane/searchkick/blob/107d270a0d2d7e1935dc7fee1ea0305edb5e4b3b/lib/searchkick/version.rb | lib/searchkick/version.rb | module Searchkick
VERSION = "6.0.2"
end
| ruby | MIT | 107d270a0d2d7e1935dc7fee1ea0305edb5e4b3b | 2026-01-04T15:40:12.176737Z | false |
ankane/searchkick | https://github.com/ankane/searchkick/blob/107d270a0d2d7e1935dc7fee1ea0305edb5e4b3b/lib/searchkick/index_cache.rb | lib/searchkick/index_cache.rb | module Searchkick
class IndexCache
def initialize(max_size: 20)
@data = {}
@mutex = Mutex.new
@max_size = max_size
end
# probably a better pattern for this
# but keep it simple
def fetch(name)
# thread-safe in MRI without mutex
# due to how context switching works
... | ruby | MIT | 107d270a0d2d7e1935dc7fee1ea0305edb5e4b3b | 2026-01-04T15:40:12.176737Z | false |
ankane/searchkick | https://github.com/ankane/searchkick/blob/107d270a0d2d7e1935dc7fee1ea0305edb5e4b3b/lib/searchkick/reindex_queue.rb | lib/searchkick/reindex_queue.rb | module Searchkick
class ReindexQueue
attr_reader :name
def initialize(name)
@name = name
raise Error, "Searchkick.redis not set" unless Searchkick.redis
end
# supports single and multiple ids
def push(record_ids)
Searchkick.with_redis { |r| r.call("LPUSH", redis_key, record_id... | ruby | MIT | 107d270a0d2d7e1935dc7fee1ea0305edb5e4b3b | 2026-01-04T15:40:12.176737Z | false |
ankane/searchkick | https://github.com/ankane/searchkick/blob/107d270a0d2d7e1935dc7fee1ea0305edb5e4b3b/lib/searchkick/log_subscriber.rb | lib/searchkick/log_subscriber.rb | # based on https://gist.github.com/mnutt/566725
module Searchkick
class LogSubscriber < ActiveSupport::LogSubscriber
def self.runtime=(value)
Thread.current[:searchkick_runtime] = value
end
def self.runtime
Thread.current[:searchkick_runtime] ||= 0
end
def self.reset_runtime
rt... | ruby | MIT | 107d270a0d2d7e1935dc7fee1ea0305edb5e4b3b | 2026-01-04T15:40:12.176737Z | false |
ankane/searchkick | https://github.com/ankane/searchkick/blob/107d270a0d2d7e1935dc7fee1ea0305edb5e4b3b/lib/searchkick/middleware.rb | lib/searchkick/middleware.rb | require "faraday"
module Searchkick
class Middleware < Faraday::Middleware
def call(env)
path = env[:url].path.to_s
if path.end_with?("/_search")
env[:request][:timeout] = Searchkick.search_timeout
elsif path.end_with?("/_msearch")
# assume no concurrent searches for timeout for... | ruby | MIT | 107d270a0d2d7e1935dc7fee1ea0305edb5e4b3b | 2026-01-04T15:40:12.176737Z | false |
ankane/searchkick | https://github.com/ankane/searchkick/blob/107d270a0d2d7e1935dc7fee1ea0305edb5e4b3b/lib/searchkick/controller_runtime.rb | lib/searchkick/controller_runtime.rb | # based on https://gist.github.com/mnutt/566725
module Searchkick
module ControllerRuntime
extend ActiveSupport::Concern
protected
attr_internal :searchkick_runtime
def process_action(action, *args)
# We also need to reset the runtime before each action
# because of queries in middlewar... | ruby | MIT | 107d270a0d2d7e1935dc7fee1ea0305edb5e4b3b | 2026-01-04T15:40:12.176737Z | false |
ankane/searchkick | https://github.com/ankane/searchkick/blob/107d270a0d2d7e1935dc7fee1ea0305edb5e4b3b/lib/searchkick/hash_wrapper.rb | lib/searchkick/hash_wrapper.rb | module Searchkick
class HashWrapper
def initialize(attributes)
@attributes = attributes
end
def [](name)
@attributes[name.to_s]
end
def to_h
@attributes
end
def as_json(...)
@attributes.as_json(...)
end
def to_json(...)
@attributes.to_json(...)
... | ruby | MIT | 107d270a0d2d7e1935dc7fee1ea0305edb5e4b3b | 2026-01-04T15:40:12.176737Z | false |
ankane/searchkick | https://github.com/ankane/searchkick/blob/107d270a0d2d7e1935dc7fee1ea0305edb5e4b3b/lib/searchkick/index.rb | lib/searchkick/index.rb | module Searchkick
class Index
attr_reader :name, :options
def initialize(name, options = {})
@name = name
@options = options
@klass_document_type = {} # cache
end
def index_options
IndexOptions.new(self).index_options
end
def create(body = {})
client.indices.cr... | ruby | MIT | 107d270a0d2d7e1935dc7fee1ea0305edb5e4b3b | 2026-01-04T15:40:12.176737Z | false |
ankane/searchkick | https://github.com/ankane/searchkick/blob/107d270a0d2d7e1935dc7fee1ea0305edb5e4b3b/lib/searchkick/process_queue_job.rb | lib/searchkick/process_queue_job.rb | module Searchkick
class ProcessQueueJob < Searchkick.parent_job.constantize
queue_as { Searchkick.queue_name }
def perform(class_name:, index_name: nil, inline: false, job_options: nil)
model = Searchkick.load_model(class_name)
index = model.searchkick_index(name: index_name)
limit = model.... | ruby | MIT | 107d270a0d2d7e1935dc7fee1ea0305edb5e4b3b | 2026-01-04T15:40:12.176737Z | false |
ankane/searchkick | https://github.com/ankane/searchkick/blob/107d270a0d2d7e1935dc7fee1ea0305edb5e4b3b/lib/searchkick/record_indexer.rb | lib/searchkick/record_indexer.rb | module Searchkick
class RecordIndexer
attr_reader :index
def initialize(index)
@index = index
end
def reindex(records, mode:, method_name:, ignore_missing:, full: false, single: false, job_options: nil)
# prevents exists? check if records is a relation
records = records.to_a
... | ruby | MIT | 107d270a0d2d7e1935dc7fee1ea0305edb5e4b3b | 2026-01-04T15:40:12.176737Z | false |
ankane/searchkick | https://github.com/ankane/searchkick/blob/107d270a0d2d7e1935dc7fee1ea0305edb5e4b3b/lib/searchkick/query.rb | lib/searchkick/query.rb | module Searchkick
class Query
include Enumerable
extend Forwardable
@@metric_aggs = [:avg, :cardinality, :max, :min, :sum]
attr_reader :klass, :term, :options
attr_accessor :body
def_delegators :execute, :map, :each, :any?, :empty?, :size, :length, :slice, :[], :to_ary,
:results, :sug... | ruby | MIT | 107d270a0d2d7e1935dc7fee1ea0305edb5e4b3b | 2026-01-04T15:40:12.176737Z | true |
ankane/searchkick | https://github.com/ankane/searchkick/blob/107d270a0d2d7e1935dc7fee1ea0305edb5e4b3b/lib/searchkick/relation.rb | lib/searchkick/relation.rb | module Searchkick
class Relation
NO_DEFAULT_VALUE = Object.new
# note: modifying body directly is not supported
# and has no impact on query after being executed
# TODO freeze body object?
delegate :params, to: :query
delegate_missing_to :private_execute
attr_reader :model
alias_meth... | ruby | MIT | 107d270a0d2d7e1935dc7fee1ea0305edb5e4b3b | 2026-01-04T15:40:12.176737Z | false |
ankane/searchkick | https://github.com/ankane/searchkick/blob/107d270a0d2d7e1935dc7fee1ea0305edb5e4b3b/lib/searchkick/where.rb | lib/searchkick/where.rb | module Searchkick
class Where
def initialize(relation)
@relation = relation
end
def not(value)
@relation.where(_not: value)
end
end
end
| ruby | MIT | 107d270a0d2d7e1935dc7fee1ea0305edb5e4b3b | 2026-01-04T15:40:12.176737Z | false |
ankane/searchkick | https://github.com/ankane/searchkick/blob/107d270a0d2d7e1935dc7fee1ea0305edb5e4b3b/lib/searchkick/index_options.rb | lib/searchkick/index_options.rb | module Searchkick
class IndexOptions
attr_reader :options
def initialize(index)
@options = index.options
end
def index_options
# mortal symbols are garbage collected in Ruby 2.2+
custom_settings = (options[:settings] || {}).deep_symbolize_keys
custom_mappings = (options[:mapp... | ruby | MIT | 107d270a0d2d7e1935dc7fee1ea0305edb5e4b3b | 2026-01-04T15:40:12.176737Z | false |
ankane/searchkick | https://github.com/ankane/searchkick/blob/107d270a0d2d7e1935dc7fee1ea0305edb5e4b3b/lib/searchkick/railtie.rb | lib/searchkick/railtie.rb | module Searchkick
class Railtie < Rails::Railtie
rake_tasks do
load "tasks/searchkick.rake"
end
end
end
| ruby | MIT | 107d270a0d2d7e1935dc7fee1ea0305edb5e4b3b | 2026-01-04T15:40:12.176737Z | false |
ankane/searchkick | https://github.com/ankane/searchkick/blob/107d270a0d2d7e1935dc7fee1ea0305edb5e4b3b/lib/searchkick/reindex_v2_job.rb | lib/searchkick/reindex_v2_job.rb | module Searchkick
class ReindexV2Job < Searchkick.parent_job.constantize
queue_as { Searchkick.queue_name }
def perform(class_name, id, method_name = nil, routing: nil, index_name: nil, ignore_missing: nil)
model = Searchkick.load_model(class_name, allow_child: true)
index = model.searchkick_inde... | ruby | MIT | 107d270a0d2d7e1935dc7fee1ea0305edb5e4b3b | 2026-01-04T15:40:12.176737Z | false |
ankane/searchkick | https://github.com/ankane/searchkick/blob/107d270a0d2d7e1935dc7fee1ea0305edb5e4b3b/lib/searchkick/results.rb | lib/searchkick/results.rb | module Searchkick
class Results
include Enumerable
extend Forwardable
attr_reader :response
def_delegators :results, :each, :any?, :empty?, :size, :length, :slice, :[], :to_ary
def initialize(klass, response, options = {})
@klass = klass
@response = response
@options = options... | ruby | MIT | 107d270a0d2d7e1935dc7fee1ea0305edb5e4b3b | 2026-01-04T15:40:12.176737Z | false |
ankane/searchkick | https://github.com/ankane/searchkick/blob/107d270a0d2d7e1935dc7fee1ea0305edb5e4b3b/lib/searchkick/bulk_reindex_job.rb | lib/searchkick/bulk_reindex_job.rb | module Searchkick
class BulkReindexJob < Searchkick.parent_job.constantize
queue_as { Searchkick.queue_name }
def perform(class_name:, record_ids: nil, index_name: nil, method_name: nil, batch_id: nil, min_id: nil, max_id: nil, ignore_missing: nil)
model = Searchkick.load_model(class_name)
index ... | ruby | MIT | 107d270a0d2d7e1935dc7fee1ea0305edb5e4b3b | 2026-01-04T15:40:12.176737Z | false |
ankane/searchkick | https://github.com/ankane/searchkick/blob/107d270a0d2d7e1935dc7fee1ea0305edb5e4b3b/lib/searchkick/indexer.rb | lib/searchkick/indexer.rb | # thread-local (technically fiber-local) indexer
# used to aggregate bulk callbacks across models
module Searchkick
class Indexer
attr_reader :queued_items
def initialize
@queued_items = []
end
def queue(items)
@queued_items.concat(items)
perform unless Searchkick.callbacks_value =... | ruby | MIT | 107d270a0d2d7e1935dc7fee1ea0305edb5e4b3b | 2026-01-04T15:40:12.176737Z | false |
ankane/searchkick | https://github.com/ankane/searchkick/blob/107d270a0d2d7e1935dc7fee1ea0305edb5e4b3b/lib/searchkick/multi_search.rb | lib/searchkick/multi_search.rb | module Searchkick
class MultiSearch
attr_reader :queries
def initialize(queries, opaque_id: nil)
@queries = queries
@opaque_id = opaque_id
end
def perform
if queries.any?
perform_search(queries)
end
end
private
def perform_search(search_queries, perform_... | ruby | MIT | 107d270a0d2d7e1935dc7fee1ea0305edb5e4b3b | 2026-01-04T15:40:12.176737Z | false |
ankane/searchkick | https://github.com/ankane/searchkick/blob/107d270a0d2d7e1935dc7fee1ea0305edb5e4b3b/lib/searchkick/relation_indexer.rb | lib/searchkick/relation_indexer.rb | module Searchkick
class RelationIndexer
attr_reader :index
def initialize(index)
@index = index
end
def reindex(relation, mode:, method_name: nil, ignore_missing: nil, full: false, resume: false, scope: nil, job_options: nil)
# apply scopes
if scope
relation = relation.send... | ruby | MIT | 107d270a0d2d7e1935dc7fee1ea0305edb5e4b3b | 2026-01-04T15:40:12.176737Z | false |
ankane/searchkick | https://github.com/ankane/searchkick/blob/107d270a0d2d7e1935dc7fee1ea0305edb5e4b3b/lib/searchkick/process_batch_job.rb | lib/searchkick/process_batch_job.rb | module Searchkick
class ProcessBatchJob < Searchkick.parent_job.constantize
queue_as { Searchkick.queue_name }
def perform(class_name:, record_ids:, index_name: nil)
model = Searchkick.load_model(class_name)
index = model.searchkick_index(name: index_name)
items =
record_ids.map do... | ruby | MIT | 107d270a0d2d7e1935dc7fee1ea0305edb5e4b3b | 2026-01-04T15:40:12.176737Z | false |
ankane/searchkick | https://github.com/ankane/searchkick/blob/107d270a0d2d7e1935dc7fee1ea0305edb5e4b3b/lib/searchkick/model.rb | lib/searchkick/model.rb | module Searchkick
module Model
def searchkick(**options)
options = Searchkick.model_options.deep_merge(options)
if options[:conversions]
Searchkick.warn("The `conversions` option is deprecated in favor of `conversions_v2`, which provides much better search performance. Upgrade to `conversions... | ruby | MIT | 107d270a0d2d7e1935dc7fee1ea0305edb5e4b3b | 2026-01-04T15:40:12.176737Z | false |
ankane/searchkick | https://github.com/ankane/searchkick/blob/107d270a0d2d7e1935dc7fee1ea0305edb5e4b3b/lib/searchkick/reranking.rb | lib/searchkick/reranking.rb | module Searchkick
module Reranking
def self.rrf(first_ranking, *rankings, k: 60)
rankings.unshift(first_ranking)
rankings.map!(&:to_ary)
ranks = []
results = []
rankings.each do |ranking|
ranks << ranking.map.with_index.to_h { |v, i| [v, i + 1] }
results.concat(ranki... | ruby | MIT | 107d270a0d2d7e1935dc7fee1ea0305edb5e4b3b | 2026-01-04T15:40:12.176737Z | false |
busyloop/lolcat | https://github.com/busyloop/lolcat/blob/f4cca5601ea57df2b5b3c98feea8ad05f4421039/lib/lolcat.rb | lib/lolcat.rb | # Copyright (c) 2016, moe@busyloop.net
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
# * Redistributions of source code must retain the above copyright
# notice, this list of condition... | ruby | BSD-3-Clause | f4cca5601ea57df2b5b3c98feea8ad05f4421039 | 2026-01-04T15:40:26.663979Z | false |
busyloop/lolcat | https://github.com/busyloop/lolcat/blob/f4cca5601ea57df2b5b3c98feea8ad05f4421039/lib/lolcat/version.rb | lib/lolcat/version.rb | module Lolcat
VERSION = "100.0.1"
end
| ruby | BSD-3-Clause | f4cca5601ea57df2b5b3c98feea8ad05f4421039 | 2026-01-04T15:40:26.663979Z | false |
busyloop/lolcat | https://github.com/busyloop/lolcat/blob/f4cca5601ea57df2b5b3c98feea8ad05f4421039/lib/lolcat/lol.rb | lib/lolcat/lol.rb | # Copyright (c) 2016, moe@busyloop.net
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
# * Redistributions of source code must retain the above copyright
# notice, this list of condition... | ruby | BSD-3-Clause | f4cca5601ea57df2b5b3c98feea8ad05f4421039 | 2026-01-04T15:40:26.663979Z | false |
busyloop/lolcat | https://github.com/busyloop/lolcat/blob/f4cca5601ea57df2b5b3c98feea8ad05f4421039/lib/lolcat/cat.rb | lib/lolcat/cat.rb | # Copyright (c) 2016, moe@busyloop.net
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
# * Redistributions of source code must retain the above copyright
# notice, this list of condition... | ruby | BSD-3-Clause | f4cca5601ea57df2b5b3c98feea8ad05f4421039 | 2026-01-04T15:40:26.663979Z | false |
ankane/chartkick | https://github.com/ankane/chartkick/blob/c2f50b9bf922a1df7beb8fb1b8a4990bb517a15f/test/test_helper.rb | test/test_helper.rb | require "bundler/setup"
Bundler.require(:default)
require "minitest/autorun"
| ruby | MIT | c2f50b9bf922a1df7beb8fb1b8a4990bb517a15f | 2026-01-04T15:40:24.593942Z | false |
ankane/chartkick | https://github.com/ankane/chartkick/blob/c2f50b9bf922a1df7beb8fb1b8a4990bb517a15f/test/chartkick_test.rb | test/chartkick_test.rb | require_relative "test_helper"
class ChartkickTest < Minitest::Test
include Chartkick::Helper
def setup
@data = [[34, 42], [56, 49]]
@content_for = {}
end
def test_line_chart
assert_chart line_chart(@data)
end
def test_pie_chart
assert_chart pie_chart(@data)
end
def test_column_char... | ruby | MIT | c2f50b9bf922a1df7beb8fb1b8a4990bb517a15f | 2026-01-04T15:40:24.593942Z | false |
ankane/chartkick | https://github.com/ankane/chartkick/blob/c2f50b9bf922a1df7beb8fb1b8a4990bb517a15f/lib/chartkick.rb | lib/chartkick.rb | # stdlib
require "erb"
require "json"
# modules
require_relative "chartkick/core_ext"
require_relative "chartkick/helper"
require_relative "chartkick/utils"
require_relative "chartkick/version"
# integrations
require_relative "chartkick/engine" if defined?(Rails)
require_relative "chartkick/sinatra" if defined?(Sinat... | ruby | MIT | c2f50b9bf922a1df7beb8fb1b8a4990bb517a15f | 2026-01-04T15:40:24.593942Z | false |
ankane/chartkick | https://github.com/ankane/chartkick/blob/c2f50b9bf922a1df7beb8fb1b8a4990bb517a15f/lib/chartkick/sinatra.rb | lib/chartkick/sinatra.rb | require "sinatra/base"
class Sinatra::Base
helpers Chartkick::Helper
end
| ruby | MIT | c2f50b9bf922a1df7beb8fb1b8a4990bb517a15f | 2026-01-04T15:40:24.593942Z | false |
ankane/chartkick | https://github.com/ankane/chartkick/blob/c2f50b9bf922a1df7beb8fb1b8a4990bb517a15f/lib/chartkick/version.rb | lib/chartkick/version.rb | module Chartkick
VERSION = "5.2.1"
end
| ruby | MIT | c2f50b9bf922a1df7beb8fb1b8a4990bb517a15f | 2026-01-04T15:40:24.593942Z | false |
ankane/chartkick | https://github.com/ankane/chartkick/blob/c2f50b9bf922a1df7beb8fb1b8a4990bb517a15f/lib/chartkick/core_ext.rb | lib/chartkick/core_ext.rb | # for both multiple series and
# making sure hash order is preserved in JavaScript
class Array
def chart_json
map do |v|
if v.is_a?(Hash) && v[:data].is_a?(Hash)
v = v.dup
v[:data] = v[:data].to_a
end
v
end.to_json
end
end
class Hash
def chart_json
if (key = keys.fi... | ruby | MIT | c2f50b9bf922a1df7beb8fb1b8a4990bb517a15f | 2026-01-04T15:40:24.593942Z | false |
ankane/chartkick | https://github.com/ankane/chartkick/blob/c2f50b9bf922a1df7beb8fb1b8a4990bb517a15f/lib/chartkick/utils.rb | lib/chartkick/utils.rb | module Chartkick
module Utils
# https://github.com/rails/rails/blob/master/activesupport/lib/active_support/core_ext/hash/deep_merge.rb
def self.deep_merge(hash_a, hash_b)
hash_a = hash_a.dup
hash_b.each_pair do |k, v|
tv = hash_a[k]
hash_a[k] = tv.is_a?(Hash) && v.is_a?(Hash) ? de... | ruby | MIT | c2f50b9bf922a1df7beb8fb1b8a4990bb517a15f | 2026-01-04T15:40:24.593942Z | false |
ankane/chartkick | https://github.com/ankane/chartkick/blob/c2f50b9bf922a1df7beb8fb1b8a4990bb517a15f/lib/chartkick/helper.rb | lib/chartkick/helper.rb | module Chartkick
module Helper
def line_chart(data_source, **options)
chartkick_chart "LineChart", data_source, **options
end
def pie_chart(data_source, **options)
chartkick_chart "PieChart", data_source, **options
end
def column_chart(data_source, **options)
chartkick_chart "C... | ruby | MIT | c2f50b9bf922a1df7beb8fb1b8a4990bb517a15f | 2026-01-04T15:40:24.593942Z | false |
ankane/chartkick | https://github.com/ankane/chartkick/blob/c2f50b9bf922a1df7beb8fb1b8a4990bb517a15f/lib/chartkick/engine.rb | lib/chartkick/engine.rb | module Chartkick
class Engine < ::Rails::Engine
# for assets
# for importmap
initializer "chartkick.importmap" do |app|
if app.config.respond_to?(:assets) && defined?(Importmap) && defined?(Sprockets)
app.config.assets.precompile << "chartkick.js"
app.config.assets.precompile << "Ch... | ruby | MIT | c2f50b9bf922a1df7beb8fb1b8a4990bb517a15f | 2026-01-04T15:40:24.593942Z | false |
guard/guard | https://github.com/guard/guard/blob/b20b7910245aee5cd4ee79fe8dc7984568afdbc4/features/support/env.rb | features/support/env.rb | # frozen_string_literal: true
require "aruba"
require "aruba/cucumber"
require "aruba/processes/in_process"
require "aruba/processes/spawn_process"
require_relative "aruba_adapter"
Before("@spawn") do
aruba.config.command_launcher = :spawn
gemfile_path = expand_path("Gemfile")
set_environment_variable "BUNDLE... | ruby | MIT | b20b7910245aee5cd4ee79fe8dc7984568afdbc4 | 2026-01-04T15:40:13.883835Z | false |
guard/guard | https://github.com/guard/guard/blob/b20b7910245aee5cd4ee79fe8dc7984568afdbc4/features/support/aruba_adapter.rb | features/support/aruba_adapter.rb | # frozen_string_literal: true
require "guard/cli"
require "guard/ui"
# @private
class ArubaAdapter
def initialize(argv, stdin = STDIN, stdout = STDOUT, stderr = STDERR,
kernel = Kernel)
@argv = argv
@stdin = stdin
@stdout = stdout
@stderr = stderr
@kernel = kernel
if ENV["I... | ruby | MIT | b20b7910245aee5cd4ee79fe8dc7984568afdbc4 | 2026-01-04T15:40:13.883835Z | false |
guard/guard | https://github.com/guard/guard/blob/b20b7910245aee5cd4ee79fe8dc7984568afdbc4/features/step_definitions/guard_steps.rb | features/step_definitions/guard_steps.rb | # frozen_string_literal: true
Given(/^my Guardfile contains:$/) do |contents|
write_file("Guardfile", contents)
end
Given(/^my Rakefile contains:$/) do |contents|
write_file("Rakefile", contents)
end
Given(/^my Gemfile includes "([^"]*)"$/) do |gem|
(@gems ||= []) << gem
end
Given(/^Guard is bundled using sou... | ruby | MIT | b20b7910245aee5cd4ee79fe8dc7984568afdbc4 | 2026-01-04T15:40:13.883835Z | false |
guard/guard | https://github.com/guard/guard/blob/b20b7910245aee5cd4ee79fe8dc7984568afdbc4/spec/spec_helper.rb | spec/spec_helper.rb | # frozen_string_literal: true
# This file was generated by the `rspec --init` command. Conventionally, all
# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
# The generated `.rspec` file contains `--require spec_helper` which will cause
# this file to always be loaded, without a need to expl... | ruby | MIT | b20b7910245aee5cd4ee79fe8dc7984568afdbc4 | 2026-01-04T15:40:13.883835Z | false |
guard/guard | https://github.com/guard/guard/blob/b20b7910245aee5cd4ee79fe8dc7984568afdbc4/spec/support/gems_helper.rb | spec/support/gems_helper.rb | # frozen_string_literal: true
def growl_installed?
require "growl"
true
rescue LoadError
false
end
def libnotify_installed?
require "libnotify"
true
rescue LoadError
false
end
def rbnotifu_installed?
require "rb-notifu"
true
rescue LoadError
false
end
| ruby | MIT | b20b7910245aee5cd4ee79fe8dc7984568afdbc4 | 2026-01-04T15:40:13.883835Z | false |
guard/guard | https://github.com/guard/guard/blob/b20b7910245aee5cd4ee79fe8dc7984568afdbc4/spec/support/platform_helper.rb | spec/support/platform_helper.rb | # frozen_string_literal: true
def mac?
RbConfig::CONFIG["target_os"] =~ /darwin/i
end
def linux?
RbConfig::CONFIG["target_os"] =~ /linux/i
end
def windows?
RbConfig::CONFIG["target_os"] =~ /mswin|mingw/i
end
| ruby | MIT | b20b7910245aee5cd4ee79fe8dc7984568afdbc4 | 2026-01-04T15:40:13.883835Z | false |
guard/guard | https://github.com/guard/guard/blob/b20b7910245aee5cd4ee79fe8dc7984568afdbc4/spec/lib/guard/group_spec.rb | spec/lib/guard/group_spec.rb | # frozen_string_literal: true
require "guard/group"
RSpec.describe Guard::Group do
subject { described_class.new(name, options) }
let(:name) { :foo }
let(:options) { {} }
describe "#name" do
specify { expect(subject.name).to eq :foo }
context "when initialized from a string" do
let(:name) { "... | ruby | MIT | b20b7910245aee5cd4ee79fe8dc7984568afdbc4 | 2026-01-04T15:40:13.883835Z | false |
guard/guard | https://github.com/guard/guard/blob/b20b7910245aee5cd4ee79fe8dc7984568afdbc4/spec/lib/guard/terminal_spec.rb | spec/lib/guard/terminal_spec.rb | # frozen_string_literal: true
require "guard/terminal"
RSpec.describe Guard::Terminal do
subject { described_class }
it { is_expected.to respond_to(:clear) }
let(:sheller) { class_double("Shellany::Sheller") }
before do
stub_const("Shellany::Sheller", sheller)
end
describe ".clear" do
context ... | ruby | MIT | b20b7910245aee5cd4ee79fe8dc7984568afdbc4 | 2026-01-04T15:40:13.883835Z | false |
guard/guard | https://github.com/guard/guard/blob/b20b7910245aee5cd4ee79fe8dc7984568afdbc4/spec/lib/guard/notifier_spec.rb | spec/lib/guard/notifier_spec.rb | # frozen_string_literal: true
require "guard/notifier"
RSpec.describe Guard::Notifier, :stub_ui do
subject { described_class }
let(:notifier) { instance_double("Notiffany::Notifier") }
before do
allow(Notiffany::Notifier).to receive(:new).and_return(notifier)
end
after do
Guard::Notifier.instance_... | ruby | MIT | b20b7910245aee5cd4ee79fe8dc7984568afdbc4 | 2026-01-04T15:40:13.883835Z | false |
guard/guard | https://github.com/guard/guard/blob/b20b7910245aee5cd4ee79fe8dc7984568afdbc4/spec/lib/guard/interactor_spec.rb | spec/lib/guard/interactor_spec.rb | # frozen_string_literal: true
require "guard/interactor"
RSpec.describe Guard::Interactor, :stub_ui do
include_context "with engine"
let(:interactive) { true }
subject { described_class.new(engine, interactive) }
let!(:pry_interactor) { instance_double("Guard::Jobs::PryWrapper", foreground: true, backgroun... | ruby | MIT | b20b7910245aee5cd4ee79fe8dc7984568afdbc4 | 2026-01-04T15:40:13.883835Z | false |
guard/guard | https://github.com/guard/guard/blob/b20b7910245aee5cd4ee79fe8dc7984568afdbc4/spec/lib/guard/plugin_util_spec.rb | spec/lib/guard/plugin_util_spec.rb | # frozen_string_literal: true
require "guard/plugin_util"
RSpec.describe Guard::PluginUtil, :stub_ui do
let(:evaluator) { instance_double("Guard::Guardfile::Evaluator", evaluate: true, guardfile_include?: false) }
describe ".plugin_names" do
before do
spec = Gem::Specification
gems = [
in... | ruby | MIT | b20b7910245aee5cd4ee79fe8dc7984568afdbc4 | 2026-01-04T15:40:13.883835Z | false |
guard/guard | https://github.com/guard/guard/blob/b20b7910245aee5cd4ee79fe8dc7984568afdbc4/spec/lib/guard/watcher_spec.rb | spec/lib/guard/watcher_spec.rb | # frozen_string_literal: true
require "guard/watcher"
require "guard/plugin"
RSpec.describe Guard::Watcher, :stub_ui do
let(:args) { [] }
subject { described_class.new(*args) }
describe "#initialize" do
context "with no arguments" do
let(:args) { [] }
it "raises an error" do
expect { sub... | ruby | MIT | b20b7910245aee5cd4ee79fe8dc7984568afdbc4 | 2026-01-04T15:40:13.883835Z | false |
guard/guard | https://github.com/guard/guard/blob/b20b7910245aee5cd4ee79fe8dc7984568afdbc4/spec/lib/guard/dsl_spec.rb | spec/lib/guard/dsl_spec.rb | # frozen_string_literal: true
require "guard/dsl"
RSpec.describe Guard::Dsl do
describe "#notification" do
it "stores notification as a hash when :off is passed" do
subject.notification(:off)
expect(subject.result.notification).to eq(off: {})
end
it "stores notification as a hash" do
... | ruby | MIT | b20b7910245aee5cd4ee79fe8dc7984568afdbc4 | 2026-01-04T15:40:13.883835Z | false |
guard/guard | https://github.com/guard/guard/blob/b20b7910245aee5cd4ee79fe8dc7984568afdbc4/spec/lib/guard/ui_spec.rb | spec/lib/guard/ui_spec.rb | # frozen_string_literal: true
require "guard/ui"
RSpec.describe Guard::UI do
include_context "with engine"
let(:logger) { instance_double("Lumberjack::Logger") }
let(:terminal) { class_double("Guard::Terminal") }
before do
described_class.reset
stub_const("Guard::Terminal", terminal)
allow(Lum... | ruby | MIT | b20b7910245aee5cd4ee79fe8dc7984568afdbc4 | 2026-01-04T15:40:13.883835Z | false |
guard/guard | https://github.com/guard/guard/blob/b20b7910245aee5cd4ee79fe8dc7984568afdbc4/spec/lib/guard/cli_spec.rb | spec/lib/guard/cli_spec.rb | # frozen_string_literal: true
require "guard/cli"
RSpec.describe Guard::CLI do
include_context "Guard options"
let(:write_environment) { instance_double("Guard::Cli::Environments::Write") }
let(:read_only_environment) do
instance_double("Guard::Cli::Environments::ReadOnly")
end
let(:dsl_describer) { in... | ruby | MIT | b20b7910245aee5cd4ee79fe8dc7984568afdbc4 | 2026-01-04T15:40:13.883835Z | false |
guard/guard | https://github.com/guard/guard/blob/b20b7910245aee5cd4ee79fe8dc7984568afdbc4/spec/lib/guard/dsl_describer_spec.rb | spec/lib/guard/dsl_describer_spec.rb | # frozen_string_literal: true
require "guard/dsl_describer"
require "guard/guardfile/result"
RSpec.describe Guard::DslDescriber, :stub_ui do
let(:guardfile_result) { Guard::Guardfile::Result.new }
let(:interactor) { instance_double(Guard::Interactor) }
let(:env) { double("ENV") }
subject { described_class.ne... | ruby | MIT | b20b7910245aee5cd4ee79fe8dc7984568afdbc4 | 2026-01-04T15:40:13.883835Z | false |
guard/guard | https://github.com/guard/guard/blob/b20b7910245aee5cd4ee79fe8dc7984568afdbc4/spec/lib/guard/plugin_spec.rb | spec/lib/guard/plugin_spec.rb | # frozen_string_literal: true
require "guard/plugin"
RSpec.describe Guard::Plugin, :stub_ui do
include_context "with engine"
subject { described_class.new(engine: engine) }
describe "#initialize" do
it "assigns the defined watchers" do
watchers = [double("foo")]
expect(described_class.new(wat... | ruby | MIT | b20b7910245aee5cd4ee79fe8dc7984568afdbc4 | 2026-01-04T15:40:13.883835Z | false |
guard/guard | https://github.com/guard/guard/blob/b20b7910245aee5cd4ee79fe8dc7984568afdbc4/spec/lib/guard/bin_spec.rb | spec/lib/guard/bin_spec.rb | # frozen_string_literal: true
path = File.expand_path("../../../bin/guard", __dir__)
load path
RSpec.describe GuardReloader do
let(:config) { instance_double(described_class::Config) }
subject { described_class.new(config) }
let(:guard_core_path) { "/home/me/.rvm/gems/ruby-2.2.2/bin/_guard-core" }
before d... | ruby | MIT | b20b7910245aee5cd4ee79fe8dc7984568afdbc4 | 2026-01-04T15:40:13.883835Z | false |
guard/guard | https://github.com/guard/guard/blob/b20b7910245aee5cd4ee79fe8dc7984568afdbc4/spec/lib/guard/runner_spec.rb | spec/lib/guard/runner_spec.rb | # frozen_string_literal: true
require "guard/runner"
RSpec.describe Guard::Runner, :stub_ui do
include_context "with engine"
let(:frontend_group) { engine.groups.add(:frontend) }
let(:backend_group) { engine.groups.add(:backend) }
let!(:dummy_plugin) { plugins.add("dummy", group: frontend_group, watchers: [G... | ruby | MIT | b20b7910245aee5cd4ee79fe8dc7984568afdbc4 | 2026-01-04T15:40:13.883835Z | false |
guard/guard | https://github.com/guard/guard/blob/b20b7910245aee5cd4ee79fe8dc7984568afdbc4/spec/lib/guard/config_spec.rb | spec/lib/guard/config_spec.rb | # frozen_string_literal: true
require "guard/config"
RSpec.describe Guard::Config do
it { is_expected.to respond_to(:strict?) }
it { is_expected.to respond_to(:silence_deprecations?) }
describe ".strict?" do
before do
allow(subject).to receive(:strict?).and_return(result)
end
context "when G... | ruby | MIT | b20b7910245aee5cd4ee79fe8dc7984568afdbc4 | 2026-01-04T15:40:13.883835Z | false |
guard/guard | https://github.com/guard/guard/blob/b20b7910245aee5cd4ee79fe8dc7984568afdbc4/spec/lib/guard/engine_spec.rb | spec/lib/guard/engine_spec.rb | # frozen_string_literal: true
require "guard/engine"
require "guard/plugin"
require "guard/jobs/pry_wrapper"
require "guard/jobs/sleep"
RSpec.describe Guard::Engine, :stub_ui do
include_context "with engine"
let(:traps) { Guard::Internals::Traps }
describe "#session" do
it "passes options to #session" do
... | ruby | MIT | b20b7910245aee5cd4ee79fe8dc7984568afdbc4 | 2026-01-04T15:40:13.883835Z | false |
guard/guard | https://github.com/guard/guard/blob/b20b7910245aee5cd4ee79fe8dc7984568afdbc4/spec/lib/guard/options_spec.rb | spec/lib/guard/options_spec.rb | # frozen_string_literal: true
require "guard/options"
RSpec.describe Guard::Options do
describe ".initialize" do
it "handles nil options" do
expect { described_class.new(nil) }.to_not raise_error
end
it "has indifferent access" do
options = described_class.new({ foo: "bar" }, "foo2" => "baz... | ruby | MIT | b20b7910245aee5cd4ee79fe8dc7984568afdbc4 | 2026-01-04T15:40:13.883835Z | false |
guard/guard | https://github.com/guard/guard/blob/b20b7910245aee5cd4ee79fe8dc7984568afdbc4/spec/lib/guard/jobs/sleep_spec.rb | spec/lib/guard/jobs/sleep_spec.rb | # frozen_string_literal: true
require "guard/jobs/sleep"
RSpec.describe Guard::Jobs::Sleep, :stub_ui do
include_context "with engine"
subject { described_class.new(engine) }
describe "#foreground" do
it "sleeps" do
status = "unknown"
Thread.new do
sleep 0.1
status = Thread.mai... | ruby | MIT | b20b7910245aee5cd4ee79fe8dc7984568afdbc4 | 2026-01-04T15:40:13.883835Z | false |
guard/guard | https://github.com/guard/guard/blob/b20b7910245aee5cd4ee79fe8dc7984568afdbc4/spec/lib/guard/jobs/pry_wrapper_spec.rb | spec/lib/guard/jobs/pry_wrapper_spec.rb | # frozen_string_literal: true
require "guard/jobs/pry_wrapper"
RSpec.describe Guard::Jobs::PryWrapper, :stub_ui do
include_context "with engine"
let(:pry_hooks) { double("pry_hooks", add_hook: true) }
let(:pry_config) do
double("pry_config", "history_file=" => true, command_prefix: true, "prompt=" => true,... | ruby | MIT | b20b7910245aee5cd4ee79fe8dc7984568afdbc4 | 2026-01-04T15:40:13.883835Z | false |
guard/guard | https://github.com/guard/guard/blob/b20b7910245aee5cd4ee79fe8dc7984568afdbc4/spec/lib/guard/watcher/pattern_spec.rb | spec/lib/guard/watcher/pattern_spec.rb | # frozen_string_literal: true
require "guard/watcher/pattern"
RSpec.describe Guard::Watcher::Pattern do
describe ".create" do
subject { described_class.create(pattern) }
context "when a string is given" do
let(:pattern) { "foo.rb" }
it { is_expected.to be_a(described_class::SimplePath) }
en... | ruby | MIT | b20b7910245aee5cd4ee79fe8dc7984568afdbc4 | 2026-01-04T15:40:13.883835Z | false |
guard/guard | https://github.com/guard/guard/blob/b20b7910245aee5cd4ee79fe8dc7984568afdbc4/spec/lib/guard/watcher/pattern/simple_path_spec.rb | spec/lib/guard/watcher/pattern/simple_path_spec.rb | # frozen_string_literal: true
require "guard/watcher/pattern/simple_path"
RSpec.describe Guard::Watcher::Pattern::SimplePath do
subject { described_class.new(path) }
describe "#match result" do
context "when constructed with filename string" do
let(:path) { "foo.rb" }
context "when matched file ... | ruby | MIT | b20b7910245aee5cd4ee79fe8dc7984568afdbc4 | 2026-01-04T15:40:13.883835Z | false |
guard/guard | https://github.com/guard/guard/blob/b20b7910245aee5cd4ee79fe8dc7984568afdbc4/spec/lib/guard/watcher/pattern/matcher_spec.rb | spec/lib/guard/watcher/pattern/matcher_spec.rb | # frozen_string_literal: true
require "guard/watcher/pattern/matcher"
RSpec.describe Guard::Watcher::Pattern::Matcher do
subject { described_class.new(obj) }
describe "#match" do
let(:expected) { double("match_result") }
context "when constructed with valid matcher object" do
let(:obj) { double("ma... | ruby | MIT | b20b7910245aee5cd4ee79fe8dc7984568afdbc4 | 2026-01-04T15:40:13.883835Z | false |
guard/guard | https://github.com/guard/guard/blob/b20b7910245aee5cd4ee79fe8dc7984568afdbc4/spec/lib/guard/watcher/pattern/match_result_spec.rb | spec/lib/guard/watcher/pattern/match_result_spec.rb | # frozen_string_literal: true
require "guard/watcher/pattern/match_result"
RSpec.describe Guard::Watcher::Pattern::MatchResult do
let(:match_result) { double("match_data") }
let(:original_value) { "foo/bar.rb" }
subject { described_class.new(match_result, original_value) }
describe "#initialize" do
conte... | ruby | MIT | b20b7910245aee5cd4ee79fe8dc7984568afdbc4 | 2026-01-04T15:40:13.883835Z | false |
guard/guard | https://github.com/guard/guard/blob/b20b7910245aee5cd4ee79fe8dc7984568afdbc4/spec/lib/guard/commands/show_spec.rb | spec/lib/guard/commands/show_spec.rb | # frozen_string_literal: true
require "guard/commands/show"
RSpec.describe Guard::Commands::Show, :stub_ui do
include_context "with engine"
include_context "with fake pry"
before do
allow(Pry::Commands).to receive(:create_command).with("show") do |&block|
FakePry.instance_eval(&block)
end
de... | ruby | MIT | b20b7910245aee5cd4ee79fe8dc7984568afdbc4 | 2026-01-04T15:40:13.883835Z | false |
guard/guard | https://github.com/guard/guard/blob/b20b7910245aee5cd4ee79fe8dc7984568afdbc4/spec/lib/guard/commands/all_spec.rb | spec/lib/guard/commands/all_spec.rb | # frozen_string_literal: true
require "guard/commands/all"
RSpec.describe Guard::Commands::All, :stub_ui do
include_context "with engine"
include_context "with fake pry"
let(:foo_group) { double }
let(:bar_guard) { double }
before do
allow(Pry::Commands).to receive(:create_command).with("all") do |&bl... | ruby | MIT | b20b7910245aee5cd4ee79fe8dc7984568afdbc4 | 2026-01-04T15:40:13.883835Z | false |
guard/guard | https://github.com/guard/guard/blob/b20b7910245aee5cd4ee79fe8dc7984568afdbc4/spec/lib/guard/commands/pause_spec.rb | spec/lib/guard/commands/pause_spec.rb | # frozen_string_literal: true
require "guard/commands/pause"
RSpec.describe Guard::Commands::Pause, :stub_ui do
include_context "with engine"
include_context "with fake pry"
let(:output) { instance_double(Pry::Output) }
before do
allow(Pry::Commands).to receive(:create_command).with("pause") do |&block|... | ruby | MIT | b20b7910245aee5cd4ee79fe8dc7984568afdbc4 | 2026-01-04T15:40:13.883835Z | false |
guard/guard | https://github.com/guard/guard/blob/b20b7910245aee5cd4ee79fe8dc7984568afdbc4/spec/lib/guard/commands/reload_spec.rb | spec/lib/guard/commands/reload_spec.rb | # frozen_string_literal: true
require "guard/commands/reload"
RSpec.describe Guard::Commands::Reload, :stub_ui do
include_context "with engine"
include_context "with fake pry"
let(:foo_group) { double }
let(:bar_guard) { double }
before do
allow(Pry::Commands).to receive(:create_command).with("reload"... | ruby | MIT | b20b7910245aee5cd4ee79fe8dc7984568afdbc4 | 2026-01-04T15:40:13.883835Z | false |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.