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
skaes/time_bandits
https://github.com/skaes/time_bandits/blob/6354956aa25040d2b68d21bdb49d50ea13a701b9/test/test_helper.rb
test/test_helper.rb
require 'minitest' require 'mocha/minitest' require 'minitest/autorun' require 'minitest/reporters' if ENV['MINITEST_REPORTER'] Minitest::Reporters.use! else Minitest::Reporters.use!([Minitest::Reporters::DefaultReporter.new]) end require 'active_support/testing/declarative' module Test module Unit class Te...
ruby
MIT
6354956aa25040d2b68d21bdb49d50ea13a701b9
2026-01-04T17:46:28.976145Z
false
skaes/time_bandits
https://github.com/skaes/time_bandits/blob/6354956aa25040d2b68d21bdb49d50ea13a701b9/test/unit/beetle_test.rb
test/unit/beetle_test.rb
require_relative '../test_helper' require 'beetle' class BeetleTest < Test::Unit::TestCase def setup TimeBandits.time_bandits = [] TimeBandits.add TimeBandits::TimeConsumers::Beetle TimeBandits.reset @beetle = Beetle::Client.new @beetle.configure do message :foo end @bandit = TimeB...
ruby
MIT
6354956aa25040d2b68d21bdb49d50ea13a701b9
2026-01-04T17:46:28.976145Z
false
skaes/time_bandits
https://github.com/skaes/time_bandits/blob/6354956aa25040d2b68d21bdb49d50ea13a701b9/test/unit/redis_test.rb
test/unit/redis_test.rb
require_relative '../test_helper' class RedisTest < Test::Unit::TestCase def setup TimeBandits.time_bandits = [] TimeBandits.add TimeBandits::TimeConsumers::Redis TimeBandits.reset @redis = Redis.new @bandit = TimeBandits::TimeConsumers::Redis.instance end test "getting metrics" do nothi...
ruby
MIT
6354956aa25040d2b68d21bdb49d50ea13a701b9
2026-01-04T17:46:28.976145Z
false
skaes/time_bandits
https://github.com/skaes/time_bandits/blob/6354956aa25040d2b68d21bdb49d50ea13a701b9/test/unit/database_test.rb
test/unit/database_test.rb
require_relative '../test_helper' require 'active_record' require 'time_bandits/monkey_patches/active_record' class DatabaseTest < Test::Unit::TestCase def setup TimeBandits.time_bandits = [] TimeBandits.add TimeBandits::TimeConsumers::Database TimeBandits.reset @old_logger = ActiveRecord::Base.logg...
ruby
MIT
6354956aa25040d2b68d21bdb49d50ea13a701b9
2026-01-04T17:46:28.976145Z
false
skaes/time_bandits
https://github.com/skaes/time_bandits/blob/6354956aa25040d2b68d21bdb49d50ea13a701b9/test/unit/sequel_test.rb
test/unit/sequel_test.rb
require_relative '../test_helper' require 'sequel' class SequelTest < Test::Unit::TestCase def setup TimeBandits.time_bandits = [] TimeBandits.add TimeBandits::TimeConsumers::Sequel TimeBandits.reset end test "getting metrics" do nothing_measured = { :db_time => 0, :db_calls => 0 ...
ruby
MIT
6354956aa25040d2b68d21bdb49d50ea13a701b9
2026-01-04T17:46:28.976145Z
false
skaes/time_bandits
https://github.com/skaes/time_bandits/blob/6354956aa25040d2b68d21bdb49d50ea13a701b9/test/unit/duplicate_bandits.rb
test/unit/duplicate_bandits.rb
require_relative '../test_helper' class DuplicateBandits < Test::Unit::TestCase class FooConsumer < TimeBandits::TimeConsumers::BaseConsumer prefix :simple fields :time, :calls format "SimpleFoo: %.1fms(%d calls)", :time, :calls end class BarConsumer < TimeBandits::TimeConsumers::BaseConsumer pr...
ruby
MIT
6354956aa25040d2b68d21bdb49d50ea13a701b9
2026-01-04T17:46:28.976145Z
false
skaes/time_bandits
https://github.com/skaes/time_bandits/blob/6354956aa25040d2b68d21bdb49d50ea13a701b9/test/unit/active_support_notifications_test.rb
test/unit/active_support_notifications_test.rb
require_relative '../test_helper' require 'active_support/notifications' require 'active_support/log_subscriber' require 'thread_variables/access' class ActiveSupportNotificationsTest < Test::Unit::TestCase class SimpleConsumer < TimeBandits::TimeConsumers::BaseConsumer prefix :simple fields :time, :calls ...
ruby
MIT
6354956aa25040d2b68d21bdb49d50ea13a701b9
2026-01-04T17:46:28.976145Z
false
skaes/time_bandits
https://github.com/skaes/time_bandits/blob/6354956aa25040d2b68d21bdb49d50ea13a701b9/test/unit/gc_consumer_test.rb
test/unit/gc_consumer_test.rb
require_relative '../test_helper' class GCConsumerTest < Test::Unit::TestCase def setup TimeBandits.time_bandits = [] TimeBandits.add TimeBandits::TimeConsumers::GarbageCollection.instance TimeBandits.reset end test "getting metrics" do # example metrics hash: sample = { :gc_time => 0....
ruby
MIT
6354956aa25040d2b68d21bdb49d50ea13a701b9
2026-01-04T17:46:28.976145Z
false
skaes/time_bandits
https://github.com/skaes/time_bandits/blob/6354956aa25040d2b68d21bdb49d50ea13a701b9/test/unit/base_test.rb
test/unit/base_test.rb
require_relative '../test_helper' class NoTimeBanditsTest < Test::Unit::TestCase def setup TimeBandits.time_bandits = [] end test "getting list of all time bandits" do assert_equal [], TimeBandits.time_bandits test_clean_state end test "reset" do assert_nothing_raised { TimeBandits.reset } ...
ruby
MIT
6354956aa25040d2b68d21bdb49d50ea13a701b9
2026-01-04T17:46:28.976145Z
false
skaes/time_bandits
https://github.com/skaes/time_bandits/blob/6354956aa25040d2b68d21bdb49d50ea13a701b9/test/unit/memcached_test.rb
test/unit/memcached_test.rb
require_relative '../test_helper' class MemcachedTest < Test::Unit::TestCase def setup skip "memcached is currently not supported on Ruby #{RUBY_VERSION} as the gem does not compile" unless RUBY_VERSION < "3.3.0" TimeBandits.time_bandits = [] TimeBandits.add TimeBandits::TimeConsumers::Memcached Time...
ruby
MIT
6354956aa25040d2b68d21bdb49d50ea13a701b9
2026-01-04T17:46:28.976145Z
false
skaes/time_bandits
https://github.com/skaes/time_bandits/blob/6354956aa25040d2b68d21bdb49d50ea13a701b9/test/unit/dalli_test.rb
test/unit/dalli_test.rb
require_relative '../test_helper' class DalliTest < Test::Unit::TestCase def setup TimeBandits.time_bandits = [] TimeBandits.add TimeBandits::TimeConsumers::Dalli TimeBandits.reset @cache = Rails.cache @bandit = TimeBandits::TimeConsumers::Dalli.instance end test "getting metrics" do not...
ruby
MIT
6354956aa25040d2b68d21bdb49d50ea13a701b9
2026-01-04T17:46:28.976145Z
false
skaes/time_bandits
https://github.com/skaes/time_bandits/blob/6354956aa25040d2b68d21bdb49d50ea13a701b9/lib/time_bandits.rb
lib/time_bandits.rb
require 'logger' require 'active_support' require 'active_support/core_ext' require 'thread_variables' module TimeBandits module TimeConsumers autoload :Database, 'time_bandits/time_consumers/database' autoload :GarbageCollection, 'time_bandits/time_consumers/garbage_collection' autoload :JMX, ...
ruby
MIT
6354956aa25040d2b68d21bdb49d50ea13a701b9
2026-01-04T17:46:28.976145Z
false
skaes/time_bandits
https://github.com/skaes/time_bandits/blob/6354956aa25040d2b68d21bdb49d50ea13a701b9/lib/time_bandits/version.rb
lib/time_bandits/version.rb
module TimeBandits VERSION = "0.15.2" end
ruby
MIT
6354956aa25040d2b68d21bdb49d50ea13a701b9
2026-01-04T17:46:28.976145Z
false
skaes/time_bandits
https://github.com/skaes/time_bandits/blob/6354956aa25040d2b68d21bdb49d50ea13a701b9/lib/time_bandits/railtie.rb
lib/time_bandits/railtie.rb
module TimeBandits module Rack autoload :Logger, 'time_bandits/rack/logger' end class Railtie < Rails::Railtie initializer "time_bandits" do |app| app.config.middleware.insert_after(Rails::Rack::Logger, TimeBandits::Rack::Logger) app.config.middleware.delete(Rails::Rack::Logger) Acti...
ruby
MIT
6354956aa25040d2b68d21bdb49d50ea13a701b9
2026-01-04T17:46:28.976145Z
false
skaes/time_bandits
https://github.com/skaes/time_bandits/blob/6354956aa25040d2b68d21bdb49d50ea13a701b9/lib/time_bandits/monkey_patches/active_record.rb
lib/time_bandits/monkey_patches/active_record.rb
if Gem::Version.new(ActiveRecord::VERSION::STRING) < Gem::Version.new("7.1.0") require_relative "active_record/log_subscriber" else require_relative "active_record/runtime_registry" end require_relative "active_record/railties/controller_runtime"
ruby
MIT
6354956aa25040d2b68d21bdb49d50ea13a701b9
2026-01-04T17:46:28.976145Z
false
skaes/time_bandits
https://github.com/skaes/time_bandits/blob/6354956aa25040d2b68d21bdb49d50ea13a701b9/lib/time_bandits/monkey_patches/redis.rb
lib/time_bandits/monkey_patches/redis.rb
require 'redis' if Redis::VERSION < "5.0" class Redis class Client alias :old_logging :logging def logging(commands, &block) ActiveSupport::Notifications.instrument('request.redis', commands: commands) do old_logging(commands, &block) end end end end else m...
ruby
MIT
6354956aa25040d2b68d21bdb49d50ea13a701b9
2026-01-04T17:46:28.976145Z
false
skaes/time_bandits
https://github.com/skaes/time_bandits/blob/6354956aa25040d2b68d21bdb49d50ea13a701b9/lib/time_bandits/monkey_patches/sequel.rb
lib/time_bandits/monkey_patches/sequel.rb
require 'sequel' major, minor, _ = Sequel.version.split('.').map(&:to_i) if major < 4 || (major == 4 && minor < 15) raise "time_bandits Sequel monkey patch is not compatible with your sequel version" end Sequel::Database.class_eval do if instance_methods.include?(:log_connection_yield) alias :_orig_log_conne...
ruby
MIT
6354956aa25040d2b68d21bdb49d50ea13a701b9
2026-01-04T17:46:28.976145Z
false
skaes/time_bandits
https://github.com/skaes/time_bandits/blob/6354956aa25040d2b68d21bdb49d50ea13a701b9/lib/time_bandits/monkey_patches/memcached.rb
lib/time_bandits/monkey_patches/memcached.rb
# Add this line to your ApplicationController (app/controllers/application_controller.rb) # to enable logging for memcached: # time_bandit TimeBandits::TimeConsumers::Memcached require 'memcached' raise "Memcached needs to be loaded before monkey patching it" unless defined?(Memcached) class Memcached def get_with_...
ruby
MIT
6354956aa25040d2b68d21bdb49d50ea13a701b9
2026-01-04T17:46:28.976145Z
false
skaes/time_bandits
https://github.com/skaes/time_bandits/blob/6354956aa25040d2b68d21bdb49d50ea13a701b9/lib/time_bandits/monkey_patches/action_controller.rb
lib/time_bandits/monkey_patches/action_controller.rb
module ActionController #:nodoc: require 'action_controller/metal/instrumentation' module Instrumentation def cleanup_view_runtime #:nodoc: consumed_before_rendering = TimeBandits.consumed runtime = yield consumed_during_rendering = TimeBandits.consumed - consumed_before_rendering run...
ruby
MIT
6354956aa25040d2b68d21bdb49d50ea13a701b9
2026-01-04T17:46:28.976145Z
false
skaes/time_bandits
https://github.com/skaes/time_bandits/blob/6354956aa25040d2b68d21bdb49d50ea13a701b9/lib/time_bandits/monkey_patches/memcache-client.rb
lib/time_bandits/monkey_patches/memcache-client.rb
# Add this line to your ApplicationController (app/controllers/application.rb) # to enable logging for memcache-client: # time_bandit MemCache require 'memcache' raise "MemCache needs to be loaded before monkey patching it" unless defined?(MemCache) class MemCache def get_with_benchmark(key, raw = false) Activ...
ruby
MIT
6354956aa25040d2b68d21bdb49d50ea13a701b9
2026-01-04T17:46:28.976145Z
false
skaes/time_bandits
https://github.com/skaes/time_bandits/blob/6354956aa25040d2b68d21bdb49d50ea13a701b9/lib/time_bandits/monkey_patches/active_record/log_subscriber.rb
lib/time_bandits/monkey_patches/active_record/log_subscriber.rb
# This file monkey patches class ActiveRecord::LogSubscriber to count # the number of sql statements being executed and the number of query # cache hits, but is only used for Rails versions before 7.1.0. require "active_record/log_subscriber" module ActiveRecord class LogSubscriber IGNORE_PAYLOAD_NAMES = ["SCHE...
ruby
MIT
6354956aa25040d2b68d21bdb49d50ea13a701b9
2026-01-04T17:46:28.976145Z
false
skaes/time_bandits
https://github.com/skaes/time_bandits/blob/6354956aa25040d2b68d21bdb49d50ea13a701b9/lib/time_bandits/monkey_patches/active_record/runtime_registry.rb
lib/time_bandits/monkey_patches/active_record/runtime_registry.rb
# This file monkey patches class ActiveRecord::RuntimeRegistry to # additionally store call counts and cache hits and subscribes an # event listener to manage those counters. It is used if the active # record version is 7.1.0 or higher. require "active_record/runtime_registry" module ActiveRecord module RuntimeRegi...
ruby
MIT
6354956aa25040d2b68d21bdb49d50ea13a701b9
2026-01-04T17:46:28.976145Z
false
skaes/time_bandits
https://github.com/skaes/time_bandits/blob/6354956aa25040d2b68d21bdb49d50ea13a701b9/lib/time_bandits/monkey_patches/active_record/railties/controller_runtime.rb
lib/time_bandits/monkey_patches/active_record/railties/controller_runtime.rb
require "active_record/railties/controller_runtime" module ActiveRecord module Railties module ControllerRuntime remove_method :cleanup_view_runtime def cleanup_view_runtime # this method has been redefined to do nothing for activerecord on purpose super end remove_method...
ruby
MIT
6354956aa25040d2b68d21bdb49d50ea13a701b9
2026-01-04T17:46:28.976145Z
false
skaes/time_bandits
https://github.com/skaes/time_bandits/blob/6354956aa25040d2b68d21bdb49d50ea13a701b9/lib/time_bandits/rack/logger.rb
lib/time_bandits/rack/logger.rb
require 'active_support/core_ext/time/conversions' require 'active_support/core_ext/object/blank' require 'active_support/log_subscriber' require 'action_dispatch/http/request' require 'rack/body_proxy' module TimeBandits module Rack # Sets log tags, logs the request, calls the app, and flushes the logs. cla...
ruby
MIT
6354956aa25040d2b68d21bdb49d50ea13a701b9
2026-01-04T17:46:28.976145Z
false
skaes/time_bandits
https://github.com/skaes/time_bandits/blob/6354956aa25040d2b68d21bdb49d50ea13a701b9/lib/time_bandits/time_consumers/beetle.rb
lib/time_bandits/time_consumers/beetle.rb
# a time consumer implementation for beetle publishing # install into application_controller.rb with the line # # time_bandit TimeBandits::TimeConsumers::Beetle # module TimeBandits module TimeConsumers class Beetle < BaseConsumer prefix :amqp fields :time, :calls format "Beetle: %.3f(%d)", :...
ruby
MIT
6354956aa25040d2b68d21bdb49d50ea13a701b9
2026-01-04T17:46:28.976145Z
false
skaes/time_bandits
https://github.com/skaes/time_bandits/blob/6354956aa25040d2b68d21bdb49d50ea13a701b9/lib/time_bandits/time_consumers/dalli.rb
lib/time_bandits/time_consumers/dalli.rb
module TimeBandits::TimeConsumers class Dalli < BaseConsumer prefix :memcache fields :time, :calls, :misses, :reads, :writes format "Dalli: %.3f(%dr,%dm,%dw,%dc)", :time, :reads, :misses, :writes, :calls class Subscriber < ActiveSupport::LogSubscriber # cache events are: read write fetch_hit ge...
ruby
MIT
6354956aa25040d2b68d21bdb49d50ea13a701b9
2026-01-04T17:46:28.976145Z
false
skaes/time_bandits
https://github.com/skaes/time_bandits/blob/6354956aa25040d2b68d21bdb49d50ea13a701b9/lib/time_bandits/time_consumers/redis.rb
lib/time_bandits/time_consumers/redis.rb
# a time consumer implementation for redis # install into application_controller.rb with the line # # time_bandit TimeBandits::TimeConsumers::Redis # require 'time_bandits/monkey_patches/redis' module TimeBandits module TimeConsumers class Redis < BaseConsumer prefix :redis fields :time, :calls ...
ruby
MIT
6354956aa25040d2b68d21bdb49d50ea13a701b9
2026-01-04T17:46:28.976145Z
false
skaes/time_bandits
https://github.com/skaes/time_bandits/blob/6354956aa25040d2b68d21bdb49d50ea13a701b9/lib/time_bandits/time_consumers/sequel.rb
lib/time_bandits/time_consumers/sequel.rb
# a time consumer implementation for sequel # install into application_controller.rb with the line # # time_bandit TimeBandits::TimeConsumers::Sequel # require 'time_bandits/monkey_patches/sequel' module TimeBandits module TimeConsumers class Sequel < BaseConsumer prefix :db fields :time, :calls ...
ruby
MIT
6354956aa25040d2b68d21bdb49d50ea13a701b9
2026-01-04T17:46:28.976145Z
false
skaes/time_bandits
https://github.com/skaes/time_bandits/blob/6354956aa25040d2b68d21bdb49d50ea13a701b9/lib/time_bandits/time_consumers/memcached.rb
lib/time_bandits/time_consumers/memcached.rb
# a time consumer implementation for memchached # install into application_controller.rb with the line # # time_bandit TimeBandits::TimeConsumers::Memcached # require 'time_bandits/monkey_patches/memcached' module TimeBandits module TimeConsumers class Memcached < BaseConsumer prefix :memcache fiel...
ruby
MIT
6354956aa25040d2b68d21bdb49d50ea13a701b9
2026-01-04T17:46:28.976145Z
false
skaes/time_bandits
https://github.com/skaes/time_bandits/blob/6354956aa25040d2b68d21bdb49d50ea13a701b9/lib/time_bandits/time_consumers/mem_cache.rb
lib/time_bandits/time_consumers/mem_cache.rb
# a time consumer implementation for memchache # install into application_controller.rb with the line # # time_bandit TimeBandits::TimeConsumers::MemCache # require 'time_bandits/monkey_patches/memcache-client' module TimeBandits module TimeConsumers class Memcache < BaseConsumer prefix :memcache f...
ruby
MIT
6354956aa25040d2b68d21bdb49d50ea13a701b9
2026-01-04T17:46:28.976145Z
false
skaes/time_bandits
https://github.com/skaes/time_bandits/blob/6354956aa25040d2b68d21bdb49d50ea13a701b9/lib/time_bandits/time_consumers/base_consumer.rb
lib/time_bandits/time_consumers/base_consumer.rb
module TimeBandits::TimeConsumers class BaseConsumer class << self def instance Thread.current.thread_variable_get(key) || Thread.current.thread_variable_set(key, new) end def key @key ||= name.to_sym end def prefix(sym) @metrics_prefix = sym ...
ruby
MIT
6354956aa25040d2b68d21bdb49d50ea13a701b9
2026-01-04T17:46:28.976145Z
false
skaes/time_bandits
https://github.com/skaes/time_bandits/blob/6354956aa25040d2b68d21bdb49d50ea13a701b9/lib/time_bandits/time_consumers/jmx.rb
lib/time_bandits/time_consumers/jmx.rb
# a time consumer implementation for jruby, using jmx # # the gc counts and times reported are summed over all the garbage collectors # heap_growth reflects changes in the committed size of the java heap # heap_size is the committed size of the java heap # allocated_size reflects changes in the active (used) part of th...
ruby
MIT
6354956aa25040d2b68d21bdb49d50ea13a701b9
2026-01-04T17:46:28.976145Z
false
skaes/time_bandits
https://github.com/skaes/time_bandits/blob/6354956aa25040d2b68d21bdb49d50ea13a701b9/lib/time_bandits/time_consumers/garbage_collection.rb
lib/time_bandits/time_consumers/garbage_collection.rb
# a time consumer implementation for garbage collection module TimeBandits module TimeConsumers class GarbageCollection @@heap_dumps_enabled = false def self.heap_dumps_enabled=(v) @@heap_dumps_enabled = v end def initialize enable_stats reset end priva...
ruby
MIT
6354956aa25040d2b68d21bdb49d50ea13a701b9
2026-01-04T17:46:28.976145Z
false
skaes/time_bandits
https://github.com/skaes/time_bandits/blob/6354956aa25040d2b68d21bdb49d50ea13a701b9/lib/time_bandits/time_consumers/database.rb
lib/time_bandits/time_consumers/database.rb
# this consumer gets installed automatically by the plugin # if this were not so # # TimeBandit.add TimeBandits::TimeConsumers::Database # # would do the job module TimeBandits module TimeConsumers # provide a time consumer interface to ActiveRecord class Database < TimeBandits::TimeConsumers::BaseConsumer...
ruby
MIT
6354956aa25040d2b68d21bdb49d50ea13a701b9
2026-01-04T17:46:28.976145Z
false
tomdalling/value_semantics
https://github.com/tomdalling/value_semantics/blob/209069ad7b3ad42f3bdbc9c4ed556dac21693f3d/benchmarks/initialize.rb
benchmarks/initialize.rb
require 'allocation_tracer' require 'pp' require 'benchmark/ips' require 'value_semantics' module StringCoercer def self.call(obj) if obj.is_a?(Symbol) obj.to_s else obj end end end class VSPerson include ValueSemantics.for_attributes { name String, coerce: StringCoercer age Inte...
ruby
MIT
209069ad7b3ad42f3bdbc9c4ed556dac21693f3d
2026-01-04T17:46:31.511345Z
false
tomdalling/value_semantics
https://github.com/tomdalling/value_semantics/blob/209069ad7b3ad42f3bdbc9c4ed556dac21693f3d/spec/either_spec.rb
spec/either_spec.rb
RSpec.describe ValueSemantics::Either do subject { described_class.new([Integer, String]) } it 'matches any of the subvalidators' do is_expected.to be === 5 is_expected.to be === 'hello' end it 'does not match anything else' do expect(subject === nil).to be(false) expect(subject === [1,2,3]).t...
ruby
MIT
209069ad7b3ad42f3bdbc9c4ed556dac21693f3d
2026-01-04T17:46:31.511345Z
false
tomdalling/value_semantics
https://github.com/tomdalling/value_semantics/blob/209069ad7b3ad42f3bdbc9c4ed556dac21693f3d/spec/pattern_matching_spec.rb
spec/pattern_matching_spec.rb
# Only works in Ruby 2.7+ RSpec.describe ValueSemantics, 'pattern matching integration' do shared_examples 'pattern matching' do it 'deconstructs to a hash' do case subject in { name:, age: Integer => age } expect(name).to eq('Tom') expect(age).to eq(69) else fail "Hash d...
ruby
MIT
209069ad7b3ad42f3bdbc9c4ed556dac21693f3d
2026-01-04T17:46:31.511345Z
false
tomdalling/value_semantics
https://github.com/tomdalling/value_semantics/blob/209069ad7b3ad42f3bdbc9c4ed556dac21693f3d/spec/dsl_spec.rb
spec/dsl_spec.rb
RSpec.describe ValueSemantics::DSL do subject { described_class.new } it 'turns method calls into attributes' do subject.fOO(Integer, default: 3, coerce: 'hi') expect(subject.__attributes.first).to have_attributes( name: :fOO, validator: Integer, coercer: 'hi', ) expect(subject._...
ruby
MIT
209069ad7b3ad42f3bdbc9c4ed556dac21693f3d
2026-01-04T17:46:31.511345Z
false
tomdalling/value_semantics
https://github.com/tomdalling/value_semantics/blob/209069ad7b3ad42f3bdbc9c4ed556dac21693f3d/spec/array_coercer_spec.rb
spec/array_coercer_spec.rb
RSpec.describe ValueSemantics::ArrayCoercer do it 'is frozen' do is_expected.to be_frozen end it 'calls #to_a on objects that respond to it' do expect(subject.(double(to_a: ['yep']))).to eq(['yep']) end it 'does not affect objects that dont respond to #to_a' do expect(subject.(111)).to eq(111) ...
ruby
MIT
209069ad7b3ad42f3bdbc9c4ed556dac21693f3d
2026-01-04T17:46:31.511345Z
false
tomdalling/value_semantics
https://github.com/tomdalling/value_semantics/blob/209069ad7b3ad42f3bdbc9c4ed556dac21693f3d/spec/struct_spec.rb
spec/struct_spec.rb
RSpec.describe ValueSemantics::Struct do subject do described_class.new do attr1 Array, default: [4,5,6] attr2 end end it "returns a value class, like Struct.new does" do expect(subject).to be_a(Class) expect(subject.value_semantics).to be_a(ValueSemantics::Recipe) expect(subject....
ruby
MIT
209069ad7b3ad42f3bdbc9c4ed556dac21693f3d
2026-01-04T17:46:31.511345Z
false
tomdalling/value_semantics
https://github.com/tomdalling/value_semantics/blob/209069ad7b3ad42f3bdbc9c4ed556dac21693f3d/spec/range_of_spec.rb
spec/range_of_spec.rb
RSpec.describe ValueSemantics::RangeOf do subject { described_class.new(Integer) } it 'matches ranges using the given subvalidator' do is_expected.to be === (1..10) end it 'does not match ranges whose `begin` does not match the subvalidator' do expect(subject === (1.0..10)).to be(false) end it 'd...
ruby
MIT
209069ad7b3ad42f3bdbc9c4ed556dac21693f3d
2026-01-04T17:46:31.511345Z
false
tomdalling/value_semantics
https://github.com/tomdalling/value_semantics/blob/209069ad7b3ad42f3bdbc9c4ed556dac21693f3d/spec/value_semantics_spec.rb
spec/value_semantics_spec.rb
require "pp" RSpec.describe ValueSemantics do around do |example| # this is necessary for mutation testing to work properly with_constant(:Doggums, dog_class) { example.run } end let(:dog_class) do Class.new do include ValueSemantics.for_attributes { name trained? } e...
ruby
MIT
209069ad7b3ad42f3bdbc9c4ed556dac21693f3d
2026-01-04T17:46:31.511345Z
false
tomdalling/value_semantics
https://github.com/tomdalling/value_semantics/blob/209069ad7b3ad42f3bdbc9c4ed556dac21693f3d/spec/range_of_endless_spec.rb
spec/range_of_endless_spec.rb
# Only works in Ruby 2.6+ RSpec.describe ValueSemantics::RangeOf do subject { described_class.new(Integer) } it 'matches beginless ranges' do is_expected.to be === (1..) end it 'matches endless ranges' do is_expected.to be === (..10) end end
ruby
MIT
209069ad7b3ad42f3bdbc9c4ed556dac21693f3d
2026-01-04T17:46:31.511345Z
false
tomdalling/value_semantics
https://github.com/tomdalling/value_semantics/blob/209069ad7b3ad42f3bdbc9c4ed556dac21693f3d/spec/value_object_coercer_spec.rb
spec/value_object_coercer_spec.rb
RSpec.describe ValueSemantics::ValueObjectCoercer do subject { described_class.new(Seal) } class Seal include ValueSemantics.for_attributes { name String d Integer, default: 1 } end it "converts hashes to an instance of the given value class" do expect(subject.(name: 'Jim')).to eq(Seal....
ruby
MIT
209069ad7b3ad42f3bdbc9c4ed556dac21693f3d
2026-01-04T17:46:31.511345Z
false
tomdalling/value_semantics
https://github.com/tomdalling/value_semantics/blob/209069ad7b3ad42f3bdbc9c4ed556dac21693f3d/spec/hash_coercer_spec.rb
spec/hash_coercer_spec.rb
RSpec.describe ValueSemantics::HashCoercer do subject do described_class.new( key_coercer: ->(x) { x.to_sym }, value_coercer: ->(x) { x.to_i }, ) end it { is_expected.to be_frozen } it 'coerces hash-like objects to hashes' do hashlike = double(to_h: {a: 1}) expect(subject.(hashlike...
ruby
MIT
209069ad7b3ad42f3bdbc9c4ed556dac21693f3d
2026-01-04T17:46:31.511345Z
false
tomdalling/value_semantics
https://github.com/tomdalling/value_semantics/blob/209069ad7b3ad42f3bdbc9c4ed556dac21693f3d/spec/attribute_spec.rb
spec/attribute_spec.rb
RSpec.describe ValueSemantics::Attribute do context 'defined with no options in particular' do subject { described_class.define(:whatever) } it 'raises if attempting to use missing default attribute' do expect { subject.default_generator.call }.to raise_error( "Attribute does not have a default...
ruby
MIT
209069ad7b3ad42f3bdbc9c4ed556dac21693f3d
2026-01-04T17:46:31.511345Z
false
tomdalling/value_semantics
https://github.com/tomdalling/value_semantics/blob/209069ad7b3ad42f3bdbc9c4ed556dac21693f3d/spec/array_of_spec.rb
spec/array_of_spec.rb
require 'set' RSpec.describe ValueSemantics::ArrayOf do subject { described_class.new(Integer) } it 'uses the subvalidator for each element in the array' do is_expected.to be === [1,2,3] is_expected.to be === [] end it 'does not match anything else' do expect(subject === nil).to be(false) exp...
ruby
MIT
209069ad7b3ad42f3bdbc9c4ed556dac21693f3d
2026-01-04T17:46:31.511345Z
false
tomdalling/value_semantics
https://github.com/tomdalling/value_semantics/blob/209069ad7b3ad42f3bdbc9c4ed556dac21693f3d/spec/hash_of_spec.rb
spec/hash_of_spec.rb
RSpec.describe ValueSemantics::HashOf do subject { described_class.new(Integer, Float) } it 'matches empty hashes' do is_expected.to be === {} end it 'matches hashes where the key and value validators also match' do is_expected.to be === { 1 => 1.2, 2 => 2.4 } end it 'does not match hashes where ...
ruby
MIT
209069ad7b3ad42f3bdbc9c4ed556dac21693f3d
2026-01-04T17:46:31.511345Z
false
tomdalling/value_semantics
https://github.com/tomdalling/value_semantics/blob/209069ad7b3ad42f3bdbc9c4ed556dac21693f3d/spec/monkey_patch_spec.rb
spec/monkey_patch_spec.rb
RSpec.describe ValueSemantics, '.monkey_patch!' do after(:each) do undo_monkey_patch! if monkey_patched? Object.send(:remove_const, :Munkey) if Object.const_defined?(:Munkey) end def monkey_patched? Class.respond_to?(:value_semantics, true) end def undo_monkey_patch! Class.class_eval do ...
ruby
MIT
209069ad7b3ad42f3bdbc9c4ed556dac21693f3d
2026-01-04T17:46:31.511345Z
false
tomdalling/value_semantics
https://github.com/tomdalling/value_semantics/blob/209069ad7b3ad42f3bdbc9c4ed556dac21693f3d/spec/bool_spec.rb
spec/bool_spec.rb
RSpec.describe ValueSemantics::Bool do it 'matches true and false' do is_expected.to be === true is_expected.to be === false end it 'does not match nil or other values' do expect(subject === nil).to be(false) expect(subject === 5).to be(false) end end
ruby
MIT
209069ad7b3ad42f3bdbc9c4ed556dac21693f3d
2026-01-04T17:46:31.511345Z
false
tomdalling/value_semantics
https://github.com/tomdalling/value_semantics/blob/209069ad7b3ad42f3bdbc9c4ed556dac21693f3d/spec/spec_helper.rb
spec/spec_helper.rb
require "bundler/setup" require "delegate" require "super_diff/rspec" require "value_semantics" require "byebug" module SpecHelperMethods def with_constant(const_name, const_value) Object.const_set(const_name, const_value) yield ensure Object.send(:remove_const, const_name) end end RSpec.configure d...
ruby
MIT
209069ad7b3ad42f3bdbc9c4ed556dac21693f3d
2026-01-04T17:46:31.511345Z
false
tomdalling/value_semantics
https://github.com/tomdalling/value_semantics/blob/209069ad7b3ad42f3bdbc9c4ed556dac21693f3d/lib/value_semantics.rb
lib/value_semantics.rb
%w( anything array_coercer array_of attribute bool class_methods dsl either hash_of hash_coercer instance_methods range_of recipe struct value_object_coercer version ).each do |filename| require_relative "value_semantics/#{filename}" end module ValueSemantics class Error < StandardE...
ruby
MIT
209069ad7b3ad42f3bdbc9c4ed556dac21693f3d
2026-01-04T17:46:31.511345Z
false
tomdalling/value_semantics
https://github.com/tomdalling/value_semantics/blob/209069ad7b3ad42f3bdbc9c4ed556dac21693f3d/lib/value_semantics/recipe.rb
lib/value_semantics/recipe.rb
module ValueSemantics # # Contains all the configuration necessary to bake a ValueSemantics module # # @see ValueSemantics.bake_module # @see ClassMethods#value_semantics # @see DSL.run # class Recipe attr_reader :attributes def initialize(attributes:) @attributes = attributes freez...
ruby
MIT
209069ad7b3ad42f3bdbc9c4ed556dac21693f3d
2026-01-04T17:46:31.511345Z
false
tomdalling/value_semantics
https://github.com/tomdalling/value_semantics/blob/209069ad7b3ad42f3bdbc9c4ed556dac21693f3d/lib/value_semantics/version.rb
lib/value_semantics/version.rb
module ValueSemantics VERSION = "3.6.1" end
ruby
MIT
209069ad7b3ad42f3bdbc9c4ed556dac21693f3d
2026-01-04T17:46:31.511345Z
false
tomdalling/value_semantics
https://github.com/tomdalling/value_semantics/blob/209069ad7b3ad42f3bdbc9c4ed556dac21693f3d/lib/value_semantics/struct.rb
lib/value_semantics/struct.rb
module ValueSemantics # # ValueSemantics equivalent of the Struct class from the Ruby standard # library # class Struct # # Creates a new Class with ValueSemantics mixed in # # @yield a block containing ValueSemantics DSL # @return [Class] the newly created class # def self.new(&bl...
ruby
MIT
209069ad7b3ad42f3bdbc9c4ed556dac21693f3d
2026-01-04T17:46:31.511345Z
false
tomdalling/value_semantics
https://github.com/tomdalling/value_semantics/blob/209069ad7b3ad42f3bdbc9c4ed556dac21693f3d/lib/value_semantics/class_methods.rb
lib/value_semantics/class_methods.rb
module ValueSemantics # # All the class methods available on ValueSemantics classes # # When a ValueSemantics module is included into a class, # the class is extended by this module. # module ClassMethods # # @return [Recipe] the recipe used to build the ValueSemantics module that # ...
ruby
MIT
209069ad7b3ad42f3bdbc9c4ed556dac21693f3d
2026-01-04T17:46:31.511345Z
false
tomdalling/value_semantics
https://github.com/tomdalling/value_semantics/blob/209069ad7b3ad42f3bdbc9c4ed556dac21693f3d/lib/value_semantics/bool.rb
lib/value_semantics/bool.rb
module ValueSemantics # # Validator that only matches `true` and `false` # module Bool # @return [Boolean] def self.===(value) true.equal?(value) || false.equal?(value) end end end
ruby
MIT
209069ad7b3ad42f3bdbc9c4ed556dac21693f3d
2026-01-04T17:46:31.511345Z
false
tomdalling/value_semantics
https://github.com/tomdalling/value_semantics/blob/209069ad7b3ad42f3bdbc9c4ed556dac21693f3d/lib/value_semantics/monkey_patched.rb
lib/value_semantics/monkey_patched.rb
require 'value_semantics' ValueSemantics.monkey_patch!
ruby
MIT
209069ad7b3ad42f3bdbc9c4ed556dac21693f3d
2026-01-04T17:46:31.511345Z
false
tomdalling/value_semantics
https://github.com/tomdalling/value_semantics/blob/209069ad7b3ad42f3bdbc9c4ed556dac21693f3d/lib/value_semantics/attribute.rb
lib/value_semantics/attribute.rb
module ValueSemantics # # Represents a single attribute of a value class # class Attribute NOT_SPECIFIED = Object.new.freeze NO_DEFAULT_GENERATOR = lambda do raise NoDefaultValue, "Attribute does not have a default value" end attr_reader :name, :validator, :coercer, :default_generator, ...
ruby
MIT
209069ad7b3ad42f3bdbc9c4ed556dac21693f3d
2026-01-04T17:46:31.511345Z
false
tomdalling/value_semantics
https://github.com/tomdalling/value_semantics/blob/209069ad7b3ad42f3bdbc9c4ed556dac21693f3d/lib/value_semantics/either.rb
lib/value_semantics/either.rb
module ValueSemantics # # Validator that matches if any of the given subvalidators matches # class Either attr_reader :subvalidators def initialize(subvalidators) @subvalidators = subvalidators freeze end # @return [Boolean] def ===(value) subvalidators.any? { |sv| sv ===...
ruby
MIT
209069ad7b3ad42f3bdbc9c4ed556dac21693f3d
2026-01-04T17:46:31.511345Z
false
tomdalling/value_semantics
https://github.com/tomdalling/value_semantics/blob/209069ad7b3ad42f3bdbc9c4ed556dac21693f3d/lib/value_semantics/range_of.rb
lib/value_semantics/range_of.rb
module ValueSemantics class RangeOf attr_reader :subvalidator def initialize(subvalidator) @subvalidator = subvalidator end def ===(obj) return false unless Range === obj # begin or end can be nil, if the range is beginless or endless [obj.begin, obj.end].compact.all? do |el...
ruby
MIT
209069ad7b3ad42f3bdbc9c4ed556dac21693f3d
2026-01-04T17:46:31.511345Z
false
tomdalling/value_semantics
https://github.com/tomdalling/value_semantics/blob/209069ad7b3ad42f3bdbc9c4ed556dac21693f3d/lib/value_semantics/hash_of.rb
lib/value_semantics/hash_of.rb
module ValueSemantics # # Validator that matches +Hash+es with homogeneous keys and values # class HashOf attr_reader :key_validator, :value_validator def initialize(key_validator, value_validator) @key_validator, @value_validator = key_validator, value_validator freeze end # @retu...
ruby
MIT
209069ad7b3ad42f3bdbc9c4ed556dac21693f3d
2026-01-04T17:46:31.511345Z
false
tomdalling/value_semantics
https://github.com/tomdalling/value_semantics/blob/209069ad7b3ad42f3bdbc9c4ed556dac21693f3d/lib/value_semantics/dsl.rb
lib/value_semantics/dsl.rb
module ValueSemantics # # Builds a {Recipe} via DSL methods # # DSL blocks are <code>instance_eval</code>d against an object of this class. # # @see Recipe # @see ValueSemantics.for_attributes # class DSL # TODO: this should maybe inherit from BasicObject so that method_missing # doesn't find ...
ruby
MIT
209069ad7b3ad42f3bdbc9c4ed556dac21693f3d
2026-01-04T17:46:31.511345Z
false
tomdalling/value_semantics
https://github.com/tomdalling/value_semantics/blob/209069ad7b3ad42f3bdbc9c4ed556dac21693f3d/lib/value_semantics/instance_methods.rb
lib/value_semantics/instance_methods.rb
module ValueSemantics # # All the instance methods available on ValueSemantics objects # module InstanceMethods # # Creates a value object based on a hash of attributes # # @param attributes [#to_h] A hash of attribute values by name. Typically a # +Hash+, but can be any object that respon...
ruby
MIT
209069ad7b3ad42f3bdbc9c4ed556dac21693f3d
2026-01-04T17:46:31.511345Z
false
tomdalling/value_semantics
https://github.com/tomdalling/value_semantics/blob/209069ad7b3ad42f3bdbc9c4ed556dac21693f3d/lib/value_semantics/hash_coercer.rb
lib/value_semantics/hash_coercer.rb
module ValueSemantics class HashCoercer attr_reader :key_coercer, :value_coercer def initialize(key_coercer:, value_coercer:) @key_coercer, @value_coercer = key_coercer, value_coercer freeze end def call(obj) hash = coerce_to_hash(obj) return obj unless hash {}.tap do ...
ruby
MIT
209069ad7b3ad42f3bdbc9c4ed556dac21693f3d
2026-01-04T17:46:31.511345Z
false
tomdalling/value_semantics
https://github.com/tomdalling/value_semantics/blob/209069ad7b3ad42f3bdbc9c4ed556dac21693f3d/lib/value_semantics/array_of.rb
lib/value_semantics/array_of.rb
module ValueSemantics # # Validator that matches arrays if each element matches a given subvalidator # class ArrayOf attr_reader :element_validator def initialize(element_validator) @element_validator = element_validator freeze end # @return [Boolean] def ===(value) Array...
ruby
MIT
209069ad7b3ad42f3bdbc9c4ed556dac21693f3d
2026-01-04T17:46:31.511345Z
false
tomdalling/value_semantics
https://github.com/tomdalling/value_semantics/blob/209069ad7b3ad42f3bdbc9c4ed556dac21693f3d/lib/value_semantics/anything.rb
lib/value_semantics/anything.rb
module ValueSemantics # # Validator that matches any and all values # module Anything # @return [true] def self.===(_) true end end end
ruby
MIT
209069ad7b3ad42f3bdbc9c4ed556dac21693f3d
2026-01-04T17:46:31.511345Z
false
tomdalling/value_semantics
https://github.com/tomdalling/value_semantics/blob/209069ad7b3ad42f3bdbc9c4ed556dac21693f3d/lib/value_semantics/array_coercer.rb
lib/value_semantics/array_coercer.rb
module ValueSemantics class ArrayCoercer attr_reader :element_coercer def initialize(element_coercer = nil) @element_coercer = element_coercer freeze end def call(obj) if obj.respond_to?(:to_a) array = obj.to_a if element_coercer array.map { |element| elem...
ruby
MIT
209069ad7b3ad42f3bdbc9c4ed556dac21693f3d
2026-01-04T17:46:31.511345Z
false
tomdalling/value_semantics
https://github.com/tomdalling/value_semantics/blob/209069ad7b3ad42f3bdbc9c4ed556dac21693f3d/lib/value_semantics/value_object_coercer.rb
lib/value_semantics/value_object_coercer.rb
module ValueSemantics # # A coercer for converting hashes into instances of value classes # # The coercer will coerce hash-like values into an instance of the value # class, using the hash for attribute values. It will return non-hash-like # values unchanged. It will also return hash-like values unchanged i...
ruby
MIT
209069ad7b3ad42f3bdbc9c4ed556dac21693f3d
2026-01-04T17:46:31.511345Z
false
testdouble/maybe_later
https://github.com/testdouble/maybe_later/blob/6fb75606869cbc278811c131dca49e3e66cf6662/test/test_helper.rb
test/test_helper.rb
$LOAD_PATH.unshift File.expand_path("../lib", __dir__) require "maybe_later" require "minitest/autorun"
ruby
MIT
6fb75606869cbc278811c131dca49e3e66cf6662
2026-01-04T17:46:35.630042Z
false
testdouble/maybe_later
https://github.com/testdouble/maybe_later/blob/6fb75606869cbc278811c131dca49e3e66cf6662/test/maybe_later_test.rb
test/maybe_later_test.rb
require "test_helper" require "rack" class MaybeLaterTest < Minitest::Test i_suck_and_my_tests_are_order_dependent! def setup MaybeLater.config do |config| config.after_each = nil config.on_error = nil config.inline_by_default = false config.max_threads = 5 config.invoke_even_if_...
ruby
MIT
6fb75606869cbc278811c131dca49e3e66cf6662
2026-01-04T17:46:35.630042Z
false
testdouble/maybe_later
https://github.com/testdouble/maybe_later/blob/6fb75606869cbc278811c131dca49e3e66cf6662/lib/maybe_later.rb
lib/maybe_later.rb
require_relative "maybe_later/version" require_relative "maybe_later/config" require_relative "maybe_later/middleware" require_relative "maybe_later/queues_callback" require_relative "maybe_later/runs_callbacks" require_relative "maybe_later/invokes_callback" require_relative "maybe_later/store" require_relative "maybe...
ruby
MIT
6fb75606869cbc278811c131dca49e3e66cf6662
2026-01-04T17:46:35.630042Z
false
testdouble/maybe_later
https://github.com/testdouble/maybe_later/blob/6fb75606869cbc278811c131dca49e3e66cf6662/lib/maybe_later/version.rb
lib/maybe_later/version.rb
module MaybeLater VERSION = "0.0.4" end
ruby
MIT
6fb75606869cbc278811c131dca49e3e66cf6662
2026-01-04T17:46:35.630042Z
false
testdouble/maybe_later
https://github.com/testdouble/maybe_later/blob/6fb75606869cbc278811c131dca49e3e66cf6662/lib/maybe_later/queues_callback.rb
lib/maybe_later/queues_callback.rb
module MaybeLater Callback = Struct.new(:inline, :callable, keyword_init: true) class QueuesCallback def call(callable:, inline:) raise Error.new("No block was passed to MaybeLater.run") if callable.nil? inline = MaybeLater.config.inline_by_default if inline.nil? Store.instance.add_callback(...
ruby
MIT
6fb75606869cbc278811c131dca49e3e66cf6662
2026-01-04T17:46:35.630042Z
false
testdouble/maybe_later
https://github.com/testdouble/maybe_later/blob/6fb75606869cbc278811c131dca49e3e66cf6662/lib/maybe_later/middleware.rb
lib/maybe_later/middleware.rb
module MaybeLater class Middleware RACK_AFTER_REPLY = "rack.after_reply" def initialize(app) @app = app end def call(env) config = MaybeLater.config status, headers, body = @app.call(env) if Store.instance.callbacks.any? if env.key?(RACK_AFTER_REPLY) env[RA...
ruby
MIT
6fb75606869cbc278811c131dca49e3e66cf6662
2026-01-04T17:46:35.630042Z
false
testdouble/maybe_later
https://github.com/testdouble/maybe_later/blob/6fb75606869cbc278811c131dca49e3e66cf6662/lib/maybe_later/store.rb
lib/maybe_later/store.rb
module MaybeLater class Store def self.instance Thread.current[:maybe_later_store] ||= new end attr_reader :callbacks def initialize @callbacks = [] end def add_callback(callable) @callbacks << callable end def clear_callbacks! @callbacks = [] end end e...
ruby
MIT
6fb75606869cbc278811c131dca49e3e66cf6662
2026-01-04T17:46:35.630042Z
false
testdouble/maybe_later
https://github.com/testdouble/maybe_later/blob/6fb75606869cbc278811c131dca49e3e66cf6662/lib/maybe_later/railtie.rb
lib/maybe_later/railtie.rb
module MaybeLater class Railtie < ::Rails::Railtie initializer "maybe_later.middleware" do config.app_middleware.use Middleware end end end
ruby
MIT
6fb75606869cbc278811c131dca49e3e66cf6662
2026-01-04T17:46:35.630042Z
false
testdouble/maybe_later
https://github.com/testdouble/maybe_later/blob/6fb75606869cbc278811c131dca49e3e66cf6662/lib/maybe_later/runs_callbacks.rb
lib/maybe_later/runs_callbacks.rb
module MaybeLater class RunsCallbacks def initialize @invokes_callback = InvokesCallback.new end def call store = Store.instance store.callbacks.each do |callback| if callback.inline @invokes_callback.call(callback) else ThreadPool.instance.run(callb...
ruby
MIT
6fb75606869cbc278811c131dca49e3e66cf6662
2026-01-04T17:46:35.630042Z
false
testdouble/maybe_later
https://github.com/testdouble/maybe_later/blob/6fb75606869cbc278811c131dca49e3e66cf6662/lib/maybe_later/invokes_callback.rb
lib/maybe_later/invokes_callback.rb
module MaybeLater class InvokesCallback def call(callback) config = MaybeLater.config callback.callable.call rescue => e config.on_error&.call(e) ensure config.after_each&.call end end end
ruby
MIT
6fb75606869cbc278811c131dca49e3e66cf6662
2026-01-04T17:46:35.630042Z
false
testdouble/maybe_later
https://github.com/testdouble/maybe_later/blob/6fb75606869cbc278811c131dca49e3e66cf6662/lib/maybe_later/thread_pool.rb
lib/maybe_later/thread_pool.rb
module MaybeLater class ThreadPool def self.instance @instance ||= new end # The only time this is invoked by the gem will be when an Async task runs # As a result, the max thread config will be locked after responding to the # first relevant request, since the pool will have been created ...
ruby
MIT
6fb75606869cbc278811c131dca49e3e66cf6662
2026-01-04T17:46:35.630042Z
false
testdouble/maybe_later
https://github.com/testdouble/maybe_later/blob/6fb75606869cbc278811c131dca49e3e66cf6662/lib/maybe_later/config.rb
lib/maybe_later/config.rb
module MaybeLater class Config attr_accessor :after_each, :on_error, :inline_by_default, :max_threads, :invoke_even_if_server_is_unsupported def initialize @after_each = nil @on_error = nil @inline_by_default = false @max_threads = 5 @invoke_even_if_server_is_unsupported =...
ruby
MIT
6fb75606869cbc278811c131dca49e3e66cf6662
2026-01-04T17:46:35.630042Z
false
jeremy/rack-ratelimit
https://github.com/jeremy/rack-ratelimit/blob/2fd0b190950e559c2b1d7032a71c16c294d686ac/test/ratelimit_test.rb
test/ratelimit_test.rb
require 'rubygems' require 'bundler/setup' require 'minitest/autorun' require 'rack/ratelimit' require 'stringio' require 'json' require 'dalli' require 'redis' module RatelimitTests def setup @app = ->(env) { [200, {}, []] } @logger = Logger.new(@out = StringIO.new) @limited = build_ratelimiter(@app,...
ruby
MIT
2fd0b190950e559c2b1d7032a71c16c294d686ac
2026-01-04T17:46:30.973090Z
false
jeremy/rack-ratelimit
https://github.com/jeremy/rack-ratelimit/blob/2fd0b190950e559c2b1d7032a71c16c294d686ac/lib/rack-ratelimit.rb
lib/rack-ratelimit.rb
require 'rack/ratelimit'
ruby
MIT
2fd0b190950e559c2b1d7032a71c16c294d686ac
2026-01-04T17:46:30.973090Z
false
jeremy/rack-ratelimit
https://github.com/jeremy/rack-ratelimit/blob/2fd0b190950e559c2b1d7032a71c16c294d686ac/lib/rack/ratelimit.rb
lib/rack/ratelimit.rb
require 'logger' require 'time' module Rack # = Ratelimit # # * Run multiple rate limiters in a single app # * Scope each rate limit to certain requests: API, files, GET vs POST, etc. # * Apply each rate limit by request characteristics: IP, subdomain, OAuth2 token, etc. # * Flexible time window to limit b...
ruby
MIT
2fd0b190950e559c2b1d7032a71c16c294d686ac
2026-01-04T17:46:30.973090Z
false
aasmith/feed-normalizer
https://github.com/aasmith/feed-normalizer/blob/afa7765c08481d38729a71bd5dfd5ef95736f026/test/test_feednormalizer.rb
test/test_feednormalizer.rb
$LOAD_PATH.unshift(File.expand_path(File.join(File.dirname(__FILE__), '../lib'))) require 'test/unit' require 'feed-normalizer' require 'yaml' class FeedNormalizerTest < Test::Unit::TestCase XML_FILES = {} Fn = FeedNormalizer data_dir = File.dirname(__FILE__) + '/data' # Load up the xml files Dir.open(da...
ruby
BSD-3-Clause
afa7765c08481d38729a71bd5dfd5ef95736f026
2026-01-04T17:46:36.268985Z
false
aasmith/feed-normalizer
https://github.com/aasmith/feed-normalizer/blob/afa7765c08481d38729a71bd5dfd5ef95736f026/test/test_htmlcleaner.rb
test/test_htmlcleaner.rb
$LOAD_PATH.unshift(File.expand_path(File.join(File.dirname(__FILE__), '../lib'))) require 'test/unit' require 'html-cleaner' include FeedNormalizer class HtmlCleanerTest < Test::Unit::TestCase def test_unescape assert_equal "' ' &deg;", FeedNormalizer::HtmlCleaner.unescapeHTML("&apos; &#39; &deg;") assert_...
ruby
BSD-3-Clause
afa7765c08481d38729a71bd5dfd5ef95736f026
2026-01-04T17:46:36.268985Z
false
aasmith/feed-normalizer
https://github.com/aasmith/feed-normalizer/blob/afa7765c08481d38729a71bd5dfd5ef95736f026/lib/html-cleaner.rb
lib/html-cleaner.rb
require 'rubygems' require 'hpricot' require 'cgi' module FeedNormalizer # Various methods for cleaning up HTML and preparing it for safe public # consumption. # # Documents used for refrence: # - http://www.w3.org/TR/html4/index/attributes.html # - http://en.wikipedia.org/wiki/List_of_XML_and_HTML_charac...
ruby
BSD-3-Clause
afa7765c08481d38729a71bd5dfd5ef95736f026
2026-01-04T17:46:36.268985Z
false
aasmith/feed-normalizer
https://github.com/aasmith/feed-normalizer/blob/afa7765c08481d38729a71bd5dfd5ef95736f026/lib/feed-normalizer.rb
lib/feed-normalizer.rb
require 'structures' require 'html-cleaner' module FeedNormalizer # The root parser object. Every parser must extend this object. class Parser # Parser being used. def self.parser nil end # Parses the given feed, and returns a normalized representation. # Returns nil if the feed could ...
ruby
BSD-3-Clause
afa7765c08481d38729a71bd5dfd5ef95736f026
2026-01-04T17:46:36.268985Z
false
aasmith/feed-normalizer
https://github.com/aasmith/feed-normalizer/blob/afa7765c08481d38729a71bd5dfd5ef95736f026/lib/structures.rb
lib/structures.rb
module FeedNormalizer module Singular # If the method being called is a singular (in this simple case, does not # end with an 's'), then it calls the plural method, and calls the first # element. We're assuming that plural methods provide an array. # # Example: # Object contains an array ca...
ruby
BSD-3-Clause
afa7765c08481d38729a71bd5dfd5ef95736f026
2026-01-04T17:46:36.268985Z
false
aasmith/feed-normalizer
https://github.com/aasmith/feed-normalizer/blob/afa7765c08481d38729a71bd5dfd5ef95736f026/lib/parsers/simple-rss.rb
lib/parsers/simple-rss.rb
require 'simple-rss' # Monkey patches for outstanding issues logged in the simple-rss project. # * Add support for issued time field: # http://rubyforge.org/tracker/index.php?func=detail&aid=13980&group_id=893&atid=3517 # * The '+' symbol is lost when escaping fields. # http://rubyforge.org/tracker/index.p...
ruby
BSD-3-Clause
afa7765c08481d38729a71bd5dfd5ef95736f026
2026-01-04T17:46:36.268985Z
false
aasmith/feed-normalizer
https://github.com/aasmith/feed-normalizer/blob/afa7765c08481d38729a71bd5dfd5ef95736f026/lib/parsers/rss.rb
lib/parsers/rss.rb
require 'rss' # For some reason, this is only included in the RDF Item by default (in 0.1.6). unless RSS::Rss::Channel::Item.new.respond_to?(:content_encoded) class RSS::Rss::Channel::Item # :nodoc: include RSS::ContentModel end end # Add equality onto Enclosures. class RSS::Rss::Channel::Item::Enclosure de...
ruby
BSD-3-Clause
afa7765c08481d38729a71bd5dfd5ef95736f026
2026-01-04T17:46:36.268985Z
false
open-uri-redirections/open_uri_redirections
https://github.com/open-uri-redirections/open_uri_redirections/blob/42828cdd98cabca60244d6b6e35943ec08c8bc8b/spec/redirections_spec.rb
spec/redirections_spec.rb
# -*- encoding: utf-8 -*- require File.join(File.dirname(__FILE__), '/spec_helper') class << OpenURI alias_method :open_uri_original__, :open_uri_original end describe 'OpenURI' do describe '#open' do describe 'Default settings' do it 'should disallow HTTP => HTTPS redirections' do expect { ...
ruby
MIT
42828cdd98cabca60244d6b6e35943ec08c8bc8b
2026-01-04T17:46:36.376805Z
false
open-uri-redirections/open_uri_redirections
https://github.com/open-uri-redirections/open_uri_redirections/blob/42828cdd98cabca60244d6b6e35943ec08c8bc8b/spec/spec_helper.rb
spec/spec_helper.rb
# -*- encoding: utf-8 -*- $: << File.join(File.dirname(__FILE__), "/../lib") require 'open_uri_redirections' require 'fakeweb' FakeWeb.allow_net_connect = false $samples_dir = File.dirname(__FILE__) + '/samples' ####################### # Faked web responses # ####################### FakeWeb.register_uri(:get, "htt...
ruby
MIT
42828cdd98cabca60244d6b6e35943ec08c8bc8b
2026-01-04T17:46:36.376805Z
false
open-uri-redirections/open_uri_redirections
https://github.com/open-uri-redirections/open_uri_redirections/blob/42828cdd98cabca60244d6b6e35943ec08c8bc8b/lib/open_uri_redirections.rb
lib/open_uri_redirections.rb
# -*- encoding: utf-8 -*- require 'open-uri' require File.expand_path(File.join(File.dirname(__FILE__), 'open-uri/redirections_patch'))
ruby
MIT
42828cdd98cabca60244d6b6e35943ec08c8bc8b
2026-01-04T17:46:36.376805Z
false
open-uri-redirections/open_uri_redirections
https://github.com/open-uri-redirections/open_uri_redirections/blob/42828cdd98cabca60244d6b6e35943ec08c8bc8b/lib/open_uri_redirections/version.rb
lib/open_uri_redirections/version.rb
module OpenUriRedirections VERSION = '0.2.1' end
ruby
MIT
42828cdd98cabca60244d6b6e35943ec08c8bc8b
2026-01-04T17:46:36.376805Z
false
open-uri-redirections/open_uri_redirections
https://github.com/open-uri-redirections/open_uri_redirections/blob/42828cdd98cabca60244d6b6e35943ec08c8bc8b/lib/open-uri/redirections_patch.rb
lib/open-uri/redirections_patch.rb
##### # Patch to allow open-uri to follow safe (http to https) # and unsafe redirections (https to http). # # Original gist URL: # https://gist.github.com/1271420 # # Relevant issue: # http://redmine.ruby-lang.org/issues/3719 # # Source here: # https://github.com/ruby/ruby/blob/trunk/lib/open-uri.rb # # Thread-safe imp...
ruby
MIT
42828cdd98cabca60244d6b6e35943ec08c8bc8b
2026-01-04T17:46:36.376805Z
false
taylorthurlow/panda-motd
https://github.com/taylorthurlow/panda-motd/blob/d1cc6db9220243e83fbb1a2bbf91c6a143b9f559/spec/motd_spec.rb
spec/motd_spec.rb
# frozen_string_literal: true require "spec_helper" describe MOTD do subject(:motd) { create(:motd) } it "creates a new MOTD" do expect(motd).not_to be_nil end it "prints the MOTD" do allow(motd.components.first).to receive(:format_uptime).and_return("") expect(motd.to_s).not_to be_nil end ...
ruby
MIT
d1cc6db9220243e83fbb1a2bbf91c6a143b9f559
2026-01-04T17:46:36.398098Z
false
taylorthurlow/panda-motd
https://github.com/taylorthurlow/panda-motd/blob/d1cc6db9220243e83fbb1a2bbf91c6a143b9f559/spec/spec_helper.rb
spec/spec_helper.rb
# frozen_string_literal: true require "factory_bot" require "simplecov" require "fileutils" unless ENV["NO_COVERAGE"] SimpleCov.start do add_filter "/vendor" end end require "bundler/setup" Bundler.setup require "panda_motd" # and any other gems you need RSpec.configure do |config| # set up factory_bot ...
ruby
MIT
d1cc6db9220243e83fbb1a2bbf91c6a143b9f559
2026-01-04T17:46:36.398098Z
false
taylorthurlow/panda-motd
https://github.com/taylorthurlow/panda-motd/blob/d1cc6db9220243e83fbb1a2bbf91c6a143b9f559/spec/component_spec.rb
spec/component_spec.rb
# frozen_string_literal: true require "spec_helper" describe Component do subject(:component) { motd = create(:motd) allow(motd.config).to receive(:component_config).with("name").and_return({}) described_class.new(motd, "name") } it "allows reading variables" do [:name, :errors, :results].each ...
ruby
MIT
d1cc6db9220243e83fbb1a2bbf91c6a143b9f559
2026-01-04T17:46:36.398098Z
false
taylorthurlow/panda-motd
https://github.com/taylorthurlow/panda-motd/blob/d1cc6db9220243e83fbb1a2bbf91c6a143b9f559/spec/factories/config_factory.rb
spec/factories/config_factory.rb
# frozen_string_literal: true require "yaml" FactoryBot.define do factory :config do skip_create config_number = SecureRandom.hex(10) transient do components { [] } end file_path { "tmp/config#{config_number}" } before(:create) do |_config, evaluator| if evaluator.components....
ruby
MIT
d1cc6db9220243e83fbb1a2bbf91c6a143b9f559
2026-01-04T17:46:36.398098Z
false