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
sonots/activerecord-refresh_connection
https://github.com/sonots/activerecord-refresh_connection/blob/5f5a742f2feae8e5fbbce1576ef4b72d81e073e4/lib/activerecord-refresh_connection.rb
lib/activerecord-refresh_connection.rb
require 'activerecord-refresh_connection/active_record/connection_adapters/refresh_connection_management'
ruby
MIT
5f5a742f2feae8e5fbbce1576ef4b72d81e073e4
2026-01-04T17:48:56.747439Z
false
sonots/activerecord-refresh_connection
https://github.com/sonots/activerecord-refresh_connection/blob/5f5a742f2feae8e5fbbce1576ef4b72d81e073e4/lib/activerecord-refresh_connection/active_record/connection_adapters/refresh_connection_management.rb
lib/activerecord-refresh_connection/active_record/connection_adapters/refresh_connection_management.rb
module ActiveRecord module ConnectionAdapters class RefreshConnectionManagement DEFAULT_OPTIONS = {max_requests: 1} def initialize(app, options = {}) @app = app @options = DEFAULT_OPTIONS.merge(options) @mutex = Mutex.new reset_remain_count end def call(e...
ruby
MIT
5f5a742f2feae8e5fbbce1576ef4b72d81e073e4
2026-01-04T17:48:56.747439Z
false
EDMC/api-versions
https://github.com/EDMC/api-versions/blob/4e6f2d01369c1a82b0a1c927b0237d487cf7658c/spec/routing_spec.rb
spec/routing_spec.rb
require 'spec_helper' describe 'API Routing' do include RSpec::Rails::RequestExampleGroup describe "V1" do it "should not route something from V2" do get new_api_foo_path, headers: { 'HTTP_ACCEPT' => 'application/vnd.myvendor+json;version=1' } expect(response.status).to eq(404) end it "sh...
ruby
MIT
4e6f2d01369c1a82b0a1c927b0237d487cf7658c
2026-01-04T17:49:05.418211Z
false
EDMC/api-versions
https://github.com/EDMC/api-versions/blob/4e6f2d01369c1a82b0a1c927b0237d487cf7658c/spec/api_versions_spec.rb
spec/api_versions_spec.rb
require 'spec_helper' describe ApiVersions do let(:testclass) { Class.new.extend ApiVersions } it "should raise if no vendor string is provided" do expect { testclass.api }.to raise_exception(RuntimeError, 'Please set a vendor_string for the api method') end end
ruby
MIT
4e6f2d01369c1a82b0a1c927b0237d487cf7658c
2026-01-04T17:49:05.418211Z
false
EDMC/api-versions
https://github.com/EDMC/api-versions/blob/4e6f2d01369c1a82b0a1c927b0237d487cf7658c/spec/middleware_spec.rb
spec/middleware_spec.rb
require 'spec_helper' require 'rack/test' describe ApiVersions::Middleware do let(:app) { ->(env) { [200, { "Content-Type" => "text/plain" }, [env["HTTP_ACCEPT"]]] } } around do |example| original = ApiVersions::VersionCheck.vendor_string ApiVersions::VersionCheck.vendor_string = "myvendor" example.ru...
ruby
MIT
4e6f2d01369c1a82b0a1c927b0237d487cf7658c
2026-01-04T17:49:05.418211Z
false
EDMC/api-versions
https://github.com/EDMC/api-versions/blob/4e6f2d01369c1a82b0a1c927b0237d487cf7658c/spec/spec_helper.rb
spec/spec_helper.rb
require 'coveralls' Coveralls.wear! do add_filter "/spec/" end ENV["RAILS_ENV"] ||= 'test' require File.expand_path("../dummy/config/environment", __FILE__) require 'rspec/rails' require 'ammeter/init' Dir[Rails.root.join("spec/support/**/*.rb")].each {|f| require f} RSpec.configure do |config| config.infer_bas...
ruby
MIT
4e6f2d01369c1a82b0a1c927b0237d487cf7658c
2026-01-04T17:49:05.418211Z
false
EDMC/api-versions
https://github.com/EDMC/api-versions/blob/4e6f2d01369c1a82b0a1c927b0237d487cf7658c/spec/generators/bump_generator_spec.rb
spec/generators/bump_generator_spec.rb
require 'spec_helper' require 'generators/api_versions/bump_generator' describe ApiVersions::Generators::BumpGenerator do before do destination File.expand_path("../../../tmp", __FILE__) prepare_destination end describe "Generated files" do before { run_generator } describe "Bar Controller" do ...
ruby
MIT
4e6f2d01369c1a82b0a1c927b0237d487cf7658c
2026-01-04T17:49:05.418211Z
false
EDMC/api-versions
https://github.com/EDMC/api-versions/blob/4e6f2d01369c1a82b0a1c927b0237d487cf7658c/spec/dummy/app/controllers/errors_controller.rb
spec/dummy/app/controllers/errors_controller.rb
class ErrorsController < ActionController::Base def not_found head :not_found end end
ruby
MIT
4e6f2d01369c1a82b0a1c927b0237d487cf7658c
2026-01-04T17:49:05.418211Z
false
EDMC/api-versions
https://github.com/EDMC/api-versions/blob/4e6f2d01369c1a82b0a1c927b0237d487cf7658c/spec/dummy/app/controllers/v1/qux_controller.rb
spec/dummy/app/controllers/v1/qux_controller.rb
class V1::QuxController < ActionController::Base def new respond_to do |format| format.json { render json: {} } format.xml { render xml: {} } end end end
ruby
MIT
4e6f2d01369c1a82b0a1c927b0237d487cf7658c
2026-01-04T17:49:05.418211Z
false
EDMC/api-versions
https://github.com/EDMC/api-versions/blob/4e6f2d01369c1a82b0a1c927b0237d487cf7658c/spec/dummy/app/controllers/api/v1/bar_controller.rb
spec/dummy/app/controllers/api/v1/bar_controller.rb
class Api::V1::BarController < ActionController::Base def new respond_to do |format| format.json { render json: {} } format.xml { render xml: {} } end end end
ruby
MIT
4e6f2d01369c1a82b0a1c927b0237d487cf7658c
2026-01-04T17:49:05.418211Z
false
EDMC/api-versions
https://github.com/EDMC/api-versions/blob/4e6f2d01369c1a82b0a1c927b0237d487cf7658c/spec/dummy/app/controllers/api/v2/foo_controller.rb
spec/dummy/app/controllers/api/v2/foo_controller.rb
class Api::V2::FooController < ActionController::Base def new respond_to do |format| format.json { render json: {} } format.xml { render xml: {} } end end end
ruby
MIT
4e6f2d01369c1a82b0a1c927b0237d487cf7658c
2026-01-04T17:49:05.418211Z
false
EDMC/api-versions
https://github.com/EDMC/api-versions/blob/4e6f2d01369c1a82b0a1c927b0237d487cf7658c/spec/dummy/app/controllers/api/v2/users_controller.rb
spec/dummy/app/controllers/api/v2/users_controller.rb
class Api::V2::UsersController < ActionController::Base end
ruby
MIT
4e6f2d01369c1a82b0a1c927b0237d487cf7658c
2026-01-04T17:49:05.418211Z
false
EDMC/api-versions
https://github.com/EDMC/api-versions/blob/4e6f2d01369c1a82b0a1c927b0237d487cf7658c/spec/dummy/app/controllers/api/v2/bar_controller.rb
spec/dummy/app/controllers/api/v2/bar_controller.rb
class Api::V2::BarController < Api::V1::BarController end
ruby
MIT
4e6f2d01369c1a82b0a1c927b0237d487cf7658c
2026-01-04T17:49:05.418211Z
false
EDMC/api-versions
https://github.com/EDMC/api-versions/blob/4e6f2d01369c1a82b0a1c927b0237d487cf7658c/spec/dummy/app/controllers/api/v3/foo_controller.rb
spec/dummy/app/controllers/api/v3/foo_controller.rb
class Api::V3::FooController < Api::V2::FooController end
ruby
MIT
4e6f2d01369c1a82b0a1c927b0237d487cf7658c
2026-01-04T17:49:05.418211Z
false
EDMC/api-versions
https://github.com/EDMC/api-versions/blob/4e6f2d01369c1a82b0a1c927b0237d487cf7658c/spec/dummy/app/controllers/api/v3/bar_controller.rb
spec/dummy/app/controllers/api/v3/bar_controller.rb
class Api::V3::BarController < ActionController::Base end
ruby
MIT
4e6f2d01369c1a82b0a1c927b0237d487cf7658c
2026-01-04T17:49:05.418211Z
false
EDMC/api-versions
https://github.com/EDMC/api-versions/blob/4e6f2d01369c1a82b0a1c927b0237d487cf7658c/spec/dummy/app/controllers/api/v3/nests/nested_controller.rb
spec/dummy/app/controllers/api/v3/nests/nested_controller.rb
class Api::V3::Nests::NestedController < ActionController::Base def new render body: nil end end
ruby
MIT
4e6f2d01369c1a82b0a1c927b0237d487cf7658c
2026-01-04T17:49:05.418211Z
false
EDMC/api-versions
https://github.com/EDMC/api-versions/blob/4e6f2d01369c1a82b0a1c927b0237d487cf7658c/spec/dummy/app/controllers/auth_api/v1/quux_controller.rb
spec/dummy/app/controllers/auth_api/v1/quux_controller.rb
class AuthApi::V1::QuuxController < ActionController::Base def new respond_to do |format| format.json { render json: {} } format.xml { render xml: {} } end end end
ruby
MIT
4e6f2d01369c1a82b0a1c927b0237d487cf7658c
2026-01-04T17:49:05.418211Z
false
EDMC/api-versions
https://github.com/EDMC/api-versions/blob/4e6f2d01369c1a82b0a1c927b0237d487cf7658c/spec/dummy/config/application.rb
spec/dummy/config/application.rb
require File.expand_path('../boot', __FILE__) # Pick the frameworks you want: require "action_controller/railtie" if defined?(Rails.groups) Bundler.require(*Rails.groups) else Bundler.require end require "api-versions" module Dummy class Application < Rails::Application end end
ruby
MIT
4e6f2d01369c1a82b0a1c927b0237d487cf7658c
2026-01-04T17:49:05.418211Z
false
EDMC/api-versions
https://github.com/EDMC/api-versions/blob/4e6f2d01369c1a82b0a1c927b0237d487cf7658c/spec/dummy/config/environment.rb
spec/dummy/config/environment.rb
# Load the rails application. require File.expand_path('../application', __FILE__) # Initialize the rails application. Dummy::Application.initialize!
ruby
MIT
4e6f2d01369c1a82b0a1c927b0237d487cf7658c
2026-01-04T17:49:05.418211Z
false
EDMC/api-versions
https://github.com/EDMC/api-versions/blob/4e6f2d01369c1a82b0a1c927b0237d487cf7658c/spec/dummy/config/routes.rb
spec/dummy/config/routes.rb
Dummy::Application.routes.draw do api vendor_string: "myvendor" do version 1 do cache as: 'v1' do resources :bar end end version 2 do cache as: 'v2' do resources :foo inherit from: 'v1' end end version 3 do inherit from: 'v2' namespace...
ruby
MIT
4e6f2d01369c1a82b0a1c927b0237d487cf7658c
2026-01-04T17:49:05.418211Z
false
EDMC/api-versions
https://github.com/EDMC/api-versions/blob/4e6f2d01369c1a82b0a1c927b0237d487cf7658c/spec/dummy/config/boot.rb
spec/dummy/config/boot.rb
gemfile = File.expand_path('../../../../Gemfile', __FILE__) if File.exist?(gemfile) ENV['BUNDLE_GEMFILE'] = gemfile require 'bundler' Bundler.setup end $:.unshift File.expand_path('../../../../lib', __FILE__)
ruby
MIT
4e6f2d01369c1a82b0a1c927b0237d487cf7658c
2026-01-04T17:49:05.418211Z
false
EDMC/api-versions
https://github.com/EDMC/api-versions/blob/4e6f2d01369c1a82b0a1c927b0237d487cf7658c/spec/dummy/config/environments/test.rb
spec/dummy/config/environments/test.rb
Dummy::Application.configure do config.cache_classes = true config.eager_load = false config.consider_all_requests_local = true config.action_controller.perform_caching = false config.action_dispatch.show_exceptions = false config.action_controller.allow_forgery_protection = false config.active_supp...
ruby
MIT
4e6f2d01369c1a82b0a1c927b0237d487cf7658c
2026-01-04T17:49:05.418211Z
false
EDMC/api-versions
https://github.com/EDMC/api-versions/blob/4e6f2d01369c1a82b0a1c927b0237d487cf7658c/lib/api-versions.rb
lib/api-versions.rb
require "api-versions/version" require "api-versions/version_check" require "api-versions/dsl" require 'api-versions/middleware' require 'api-versions/railtie' module ApiVersions def api(options = {}, &block) raise "Please set a vendor_string for the api method" if options[:vendor_string].nil? VersionCheck....
ruby
MIT
4e6f2d01369c1a82b0a1c927b0237d487cf7658c
2026-01-04T17:49:05.418211Z
false
EDMC/api-versions
https://github.com/EDMC/api-versions/blob/4e6f2d01369c1a82b0a1c927b0237d487cf7658c/lib/generators/api_versions/bump_generator.rb
lib/generators/api_versions/bump_generator.rb
module ApiVersions module Generators class BumpGenerator < Rails::Generators::Base desc "Bump API version to next version, initializing controllers" source_root File.expand_path('../templates', __FILE__) def get_controllers Dir.chdir File.join(Rails.root, 'app', 'controllers') do ...
ruby
MIT
4e6f2d01369c1a82b0a1c927b0237d487cf7658c
2026-01-04T17:49:05.418211Z
false
EDMC/api-versions
https://github.com/EDMC/api-versions/blob/4e6f2d01369c1a82b0a1c927b0237d487cf7658c/lib/generators/api_versions/templates/controller.rb
lib/generators/api_versions/templates/controller.rb
class <%= @current_new_controller %> < <%= @current_old_controller %> end
ruby
MIT
4e6f2d01369c1a82b0a1c927b0237d487cf7658c
2026-01-04T17:49:05.418211Z
false
EDMC/api-versions
https://github.com/EDMC/api-versions/blob/4e6f2d01369c1a82b0a1c927b0237d487cf7658c/lib/api-versions/version.rb
lib/api-versions/version.rb
module ApiVersions class Version MAJOR = 1 MINOR = 2 PATCH = 1 def self.to_s [MAJOR, MINOR, PATCH].join('.') end end VERSION = Version.to_s end
ruby
MIT
4e6f2d01369c1a82b0a1c927b0237d487cf7658c
2026-01-04T17:49:05.418211Z
false
EDMC/api-versions
https://github.com/EDMC/api-versions/blob/4e6f2d01369c1a82b0a1c927b0237d487cf7658c/lib/api-versions/middleware.rb
lib/api-versions/middleware.rb
module ApiVersions class Middleware def initialize(app) @app = app end def call(env) accept_string = env['HTTP_ACCEPT'] || "" accepts = accept_string.split(',') accepts.push("application/vnd.#{ApiVersions::VersionCheck.vendor_string}+json") unless accept_string.include?('applicati...
ruby
MIT
4e6f2d01369c1a82b0a1c927b0237d487cf7658c
2026-01-04T17:49:05.418211Z
false
EDMC/api-versions
https://github.com/EDMC/api-versions/blob/4e6f2d01369c1a82b0a1c927b0237d487cf7658c/lib/api-versions/railtie.rb
lib/api-versions/railtie.rb
require 'rails/railtie' module ApiVersions class Railtie < Rails::Railtie config.app_middleware.use ApiVersions::Middleware end end
ruby
MIT
4e6f2d01369c1a82b0a1c927b0237d487cf7658c
2026-01-04T17:49:05.418211Z
false
EDMC/api-versions
https://github.com/EDMC/api-versions/blob/4e6f2d01369c1a82b0a1c927b0237d487cf7658c/lib/api-versions/dsl.rb
lib/api-versions/dsl.rb
require 'forwardable' module ApiVersions class DSL extend Forwardable def initialize(context, &block) @context = context singleton_class.def_delegators :@context, *(@context.public_methods - public_methods) instance_eval(&block) end def version(version_number, &block) Versio...
ruby
MIT
4e6f2d01369c1a82b0a1c927b0237d487cf7658c
2026-01-04T17:49:05.418211Z
false
EDMC/api-versions
https://github.com/EDMC/api-versions/blob/4e6f2d01369c1a82b0a1c927b0237d487cf7658c/lib/api-versions/version_check.rb
lib/api-versions/version_check.rb
module ApiVersions class VersionCheck class << self attr_accessor :default_version, :vendor_string end def initialize(args = {}) @process_version = args[:version] end def matches?(request) accepts = request.headers['Accept'].split(',') accepts.any? do |accept| acc...
ruby
MIT
4e6f2d01369c1a82b0a1c927b0237d487cf7658c
2026-01-04T17:49:05.418211Z
false
jamesbrooks/hash_validator
https://github.com/jamesbrooks/hash_validator/blob/05b09c196cb6ef3af5a36030ed70450b9d9baef0/spec/hash_validator_spec_helper.rb
spec/hash_validator_spec_helper.rb
# frozen_string_literal: true module HashValidatorSpecHelper def validate(hash, validations, strict = false) HashValidator.validate(hash, validations, strict) end end
ruby
MIT
05b09c196cb6ef3af5a36030ed70450b9d9baef0
2026-01-04T17:49:06.790742Z
false
jamesbrooks/hash_validator
https://github.com/jamesbrooks/hash_validator/blob/05b09c196cb6ef3af5a36030ed70450b9d9baef0/spec/configuration_spec.rb
spec/configuration_spec.rb
# frozen_string_literal: true require "spec_helper" describe "HashValidator.configure" do describe "configuration DSL" do after(:each) do # Clean up any validators added during tests HashValidator.remove_validator("test_pattern") HashValidator.remove_validator("test_func") HashValidator....
ruby
MIT
05b09c196cb6ef3af5a36030ed70450b9d9baef0
2026-01-04T17:49:06.790742Z
false
jamesbrooks/hash_validator
https://github.com/jamesbrooks/hash_validator/blob/05b09c196cb6ef3af5a36030ed70450b9d9baef0/spec/hash_validator_spec.rb
spec/hash_validator_spec.rb
# frozen_string_literal: true require "spec_helper" describe HashValidator do describe "Adding validators" do let(:new_validator1) { HashValidator::Validator::SimpleValidator.new("my_type1", lambda { |v| true }) } let(:new_validator2) { HashValidator::Validator::SimpleValidator.new("my_type2", lambda { |v| ...
ruby
MIT
05b09c196cb6ef3af5a36030ed70450b9d9baef0
2026-01-04T17:49:06.790742Z
false
jamesbrooks/hash_validator
https://github.com/jamesbrooks/hash_validator/blob/05b09c196cb6ef3af5a36030ed70450b9d9baef0/spec/spec_helper.rb
spec/spec_helper.rb
# frozen_string_literal: true require "rubygems" require "simplecov" require "simplecov_json_formatter" SimpleCov.start do formatter SimpleCov::Formatter::JSONFormatter add_filter "/spec/" end require "hash_validator" require "hash_validator_spec_helper" RSpec.configure do |config| config.run_all_when_everyth...
ruby
MIT
05b09c196cb6ef3af5a36030ed70450b9d9baef0
2026-01-04T17:49:06.790742Z
false
jamesbrooks/hash_validator
https://github.com/jamesbrooks/hash_validator/blob/05b09c196cb6ef3af5a36030ed70450b9d9baef0/spec/validators/ip_validator_spec.rb
spec/validators/ip_validator_spec.rb
# frozen_string_literal: true require "spec_helper" describe HashValidator::Validator::IpValidator do let(:validator) { HashValidator::Validator::IpValidator.new } context "valid IP addresses" do it "validates IPv4 addresses" do errors = {} validator.validate("key", "192.168.1.1", {}, errors) ...
ruby
MIT
05b09c196cb6ef3af5a36030ed70450b9d9baef0
2026-01-04T17:49:06.790742Z
false
jamesbrooks/hash_validator
https://github.com/jamesbrooks/hash_validator/blob/05b09c196cb6ef3af5a36030ed70450b9d9baef0/spec/validators/multiple_spec.rb
spec/validators/multiple_spec.rb
# frozen_string_literal: true require "spec_helper" describe HashValidator::Validator::Base do let(:validator) { HashValidator::Validator::MultipleValidator.new } let(:errors) { Hash.new } def multiple(*validations) HashValidator::Validations::Multiple.new(validations) end describe "#should_valid...
ruby
MIT
05b09c196cb6ef3af5a36030ed70450b9d9baef0
2026-01-04T17:49:06.790742Z
false
jamesbrooks/hash_validator
https://github.com/jamesbrooks/hash_validator/blob/05b09c196cb6ef3af5a36030ed70450b9d9baef0/spec/validators/simple_spec.rb
spec/validators/simple_spec.rb
# frozen_string_literal: true require "spec_helper" describe HashValidator::Validator::SimpleValidator do describe "#initialize" do it "accepts blocks with one argument" do expect { HashValidator::Validator::SimpleValidator.new("name", lambda { |a| true }) }.to_not raise_error end i...
ruby
MIT
05b09c196cb6ef3af5a36030ed70450b9d9baef0
2026-01-04T17:49:06.790742Z
false
jamesbrooks/hash_validator
https://github.com/jamesbrooks/hash_validator/blob/05b09c196cb6ef3af5a36030ed70450b9d9baef0/spec/validators/alpha_validator_spec.rb
spec/validators/alpha_validator_spec.rb
# frozen_string_literal: true require "spec_helper" describe HashValidator::Validator::AlphaValidator do let(:validator) { HashValidator::Validator::AlphaValidator.new } context "valid alpha strings" do it "validates lowercase letters" do errors = {} validator.validate("key", "abc", {}, errors) ...
ruby
MIT
05b09c196cb6ef3af5a36030ed70450b9d9baef0
2026-01-04T17:49:06.790742Z
false
jamesbrooks/hash_validator
https://github.com/jamesbrooks/hash_validator/blob/05b09c196cb6ef3af5a36030ed70450b9d9baef0/spec/validators/in_enumerable_spec.rb
spec/validators/in_enumerable_spec.rb
# frozen_string_literal: true require "spec_helper" describe "Enumerable validator" do describe "Accepting Enumerables in validations" do it "should accept an empty array" do validate({}, { foo: [] }) end it "should accept an array" do validate({}, { foo: [ "apple", "banana", "carrot" ] }) ...
ruby
MIT
05b09c196cb6ef3af5a36030ed70450b9d9baef0
2026-01-04T17:49:06.790742Z
false
jamesbrooks/hash_validator
https://github.com/jamesbrooks/hash_validator/blob/05b09c196cb6ef3af5a36030ed70450b9d9baef0/spec/validators/digits_validator_spec.rb
spec/validators/digits_validator_spec.rb
# frozen_string_literal: true require "spec_helper" describe HashValidator::Validator::DigitsValidator do let(:validator) { HashValidator::Validator::DigitsValidator.new } context "valid digit strings" do it "validates single digit" do errors = {} validator.validate("key", "1", {}, errors) ...
ruby
MIT
05b09c196cb6ef3af5a36030ed70450b9d9baef0
2026-01-04T17:49:06.790742Z
false
jamesbrooks/hash_validator
https://github.com/jamesbrooks/hash_validator/blob/05b09c196cb6ef3af5a36030ed70450b9d9baef0/spec/validators/email_spec.rb
spec/validators/email_spec.rb
# frozen_string_literal: true require "spec_helper" describe HashValidator::Validator::Base do let(:validator) { HashValidator::Validator::EmailValidator.new } let(:errors) { Hash.new } describe "#should_validate?" do it 'should validate the name "email"' do expect(validator.should_validate?("emai...
ruby
MIT
05b09c196cb6ef3af5a36030ed70450b9d9baef0
2026-01-04T17:49:06.790742Z
false
jamesbrooks/hash_validator
https://github.com/jamesbrooks/hash_validator/blob/05b09c196cb6ef3af5a36030ed70450b9d9baef0/spec/validators/array_spec.rb
spec/validators/array_spec.rb
# frozen_string_literal: true require "spec_helper" describe "Array validator" do let(:validator) { HashValidator::Validator::ArrayValidator.new } let(:errors) { Hash.new } describe "#should_validate?" do it 'should validate the array with first item ":array"' do expect(validator.should_validate?(...
ruby
MIT
05b09c196cb6ef3af5a36030ed70450b9d9baef0
2026-01-04T17:49:06.790742Z
false
jamesbrooks/hash_validator
https://github.com/jamesbrooks/hash_validator/blob/05b09c196cb6ef3af5a36030ed70450b9d9baef0/spec/validators/many_spec.rb
spec/validators/many_spec.rb
# frozen_string_literal: true require "spec_helper" describe HashValidator::Validator::Base do let(:validator) { HashValidator::Validator::ManyValidator.new } let(:errors) { Hash.new } def many(validation) HashValidator::Validations::Many.new(validation) end describe "#should_validate?" do it...
ruby
MIT
05b09c196cb6ef3af5a36030ed70450b9d9baef0
2026-01-04T17:49:06.790742Z
false
jamesbrooks/hash_validator
https://github.com/jamesbrooks/hash_validator/blob/05b09c196cb6ef3af5a36030ed70450b9d9baef0/spec/validators/class_spec.rb
spec/validators/class_spec.rb
# frozen_string_literal: true require "spec_helper" describe "Class validator" do let(:errors) { Hash.new } { Array => { valid: [ [], [1], ["foo"], [1, ["foo"], Time.now] ], invalid: [ nil, "", 123, "123", Time.now, "[1]" ] }, Complex => { valid: [ Complex(1), Complex(2, 3), Com...
ruby
MIT
05b09c196cb6ef3af5a36030ed70450b9d9baef0
2026-01-04T17:49:06.790742Z
false
jamesbrooks/hash_validator
https://github.com/jamesbrooks/hash_validator/blob/05b09c196cb6ef3af5a36030ed70450b9d9baef0/spec/validators/presence_spec.rb
spec/validators/presence_spec.rb
# frozen_string_literal: true require "spec_helper" describe HashValidator::Validator::Base do let(:validator) { HashValidator::Validator::PresenceValidator.new } let(:errors) { Hash.new } describe "#should_validate?" do it 'should validate the name "required"' do expect(validator.should_validate?...
ruby
MIT
05b09c196cb6ef3af5a36030ed70450b9d9baef0
2026-01-04T17:49:06.790742Z
false
jamesbrooks/hash_validator
https://github.com/jamesbrooks/hash_validator/blob/05b09c196cb6ef3af5a36030ed70450b9d9baef0/spec/validators/ipv6_validator_spec.rb
spec/validators/ipv6_validator_spec.rb
# frozen_string_literal: true require "spec_helper" describe HashValidator::Validator::Ipv6Validator do let(:validator) { HashValidator::Validator::Ipv6Validator.new } context "valid IPv6 addresses" do it "validates full IPv6 addresses" do errors = {} validator.validate("key", "2001:0db8:85a3:000...
ruby
MIT
05b09c196cb6ef3af5a36030ed70450b9d9baef0
2026-01-04T17:49:06.790742Z
false
jamesbrooks/hash_validator
https://github.com/jamesbrooks/hash_validator/blob/05b09c196cb6ef3af5a36030ed70450b9d9baef0/spec/validators/simple_types_spec.rb
spec/validators/simple_types_spec.rb
# frozen_string_literal: true require "spec_helper" describe "Simple validator types" do let(:errors) { Hash.new } # Simple types { array: { valid: [ [], [1], ["foo"], [1, ["foo"], Time.now] ], invalid: [ nil, "", 123, "123", Time.now, "[1]" ] }, complex: { valid: [ Complex(1)...
ruby
MIT
05b09c196cb6ef3af5a36030ed70450b9d9baef0
2026-01-04T17:49:06.790742Z
false
jamesbrooks/hash_validator
https://github.com/jamesbrooks/hash_validator/blob/05b09c196cb6ef3af5a36030ed70450b9d9baef0/spec/validators/optional_spec.rb
spec/validators/optional_spec.rb
# frozen_string_literal: true require "spec_helper" describe HashValidator::Validator::Base do let(:validator) { HashValidator::Validator::OptionalValidator.new } let(:errors) { Hash.new } def optional(validation) HashValidator::Validations::Optional.new(validation) end describe "#should_validate...
ruby
MIT
05b09c196cb6ef3af5a36030ed70450b9d9baef0
2026-01-04T17:49:06.790742Z
false
jamesbrooks/hash_validator
https://github.com/jamesbrooks/hash_validator/blob/05b09c196cb6ef3af5a36030ed70450b9d9baef0/spec/validators/hex_color_validator_spec.rb
spec/validators/hex_color_validator_spec.rb
# frozen_string_literal: true require "spec_helper" describe HashValidator::Validator::HexColorValidator do let(:validator) { HashValidator::Validator::HexColorValidator.new } context "valid hex colors" do it "validates 6-digit hex colors (lowercase)" do errors = {} validator.validate("key", "#ff...
ruby
MIT
05b09c196cb6ef3af5a36030ed70450b9d9baef0
2026-01-04T17:49:06.790742Z
false
jamesbrooks/hash_validator
https://github.com/jamesbrooks/hash_validator/blob/05b09c196cb6ef3af5a36030ed70450b9d9baef0/spec/validators/user_defined_spec.rb
spec/validators/user_defined_spec.rb
# frozen_string_literal: true require "spec_helper" describe "User-defined validator" do let(:validator) do unless defined?(HashValidator::Validator::OddValidator) # Define our custom validator class HashValidator::Validator::OddValidator < HashValidator::Validator::Base def initialize ...
ruby
MIT
05b09c196cb6ef3af5a36030ed70450b9d9baef0
2026-01-04T17:49:06.790742Z
false
jamesbrooks/hash_validator
https://github.com/jamesbrooks/hash_validator/blob/05b09c196cb6ef3af5a36030ed70450b9d9baef0/spec/validators/hash_validator_spec.rb
spec/validators/hash_validator_spec.rb
# frozen_string_literal: true require "spec_helper" describe "ActionController::Parameters support" do # Mock ActionController::Parameters for testing let(:mock_params_class) do Class.new do attr_reader :data def initialize(data) @data = data end def [](key) @data[key...
ruby
MIT
05b09c196cb6ef3af5a36030ed70450b9d9baef0
2026-01-04T17:49:06.790742Z
false
jamesbrooks/hash_validator
https://github.com/jamesbrooks/hash_validator/blob/05b09c196cb6ef3af5a36030ed70450b9d9baef0/spec/validators/base_spec.rb
spec/validators/base_spec.rb
# frozen_string_literal: true require "spec_helper" describe HashValidator::Validator::Base do let(:name) { "my_validator" } it "allows a validator to be created with a valid name" do expect { HashValidator::Validator::Base.new(name) }.to_not raise_error end it "does not allow a validator to be created...
ruby
MIT
05b09c196cb6ef3af5a36030ed70450b9d9baef0
2026-01-04T17:49:06.790742Z
false
jamesbrooks/hash_validator
https://github.com/jamesbrooks/hash_validator/blob/05b09c196cb6ef3af5a36030ed70450b9d9baef0/spec/validators/lambda_spec.rb
spec/validators/lambda_spec.rb
# frozen_string_literal: true require "spec_helper" describe "Functional validator" do describe "Accepting Lambdas in validations" do it "should accept a lambda" do validate({}, { foo: lambda { |arg| } }) end it "should accept a proc" do validate({}, { foo: Proc.new { |arg| } }) end e...
ruby
MIT
05b09c196cb6ef3af5a36030ed70450b9d9baef0
2026-01-04T17:49:06.790742Z
false
jamesbrooks/hash_validator
https://github.com/jamesbrooks/hash_validator/blob/05b09c196cb6ef3af5a36030ed70450b9d9baef0/spec/validators/dynamic_func_validator_spec.rb
spec/validators/dynamic_func_validator_spec.rb
# frozen_string_literal: true require "spec_helper" describe HashValidator::Validator::DynamicFuncValidator do describe "Function-based validator" do let(:odd_func_validator) do HashValidator::Validator::DynamicFuncValidator.new( "odd_func", ->(n) { n.is_a?(Integer) && n.odd? }, "i...
ruby
MIT
05b09c196cb6ef3af5a36030ed70450b9d9baef0
2026-01-04T17:49:06.790742Z
false
jamesbrooks/hash_validator
https://github.com/jamesbrooks/hash_validator/blob/05b09c196cb6ef3af5a36030ed70450b9d9baef0/spec/validators/regexp_spec.rb
spec/validators/regexp_spec.rb
# frozen_string_literal: true require "spec_helper" describe "Regular expression validator" do describe "Accepting RegExps in validations" do it "should accept a regexp" do validate({}, { foo: // }) end end describe "#validate" do let(:validations) { { string: /^foo$/ } } it "should vali...
ruby
MIT
05b09c196cb6ef3af5a36030ed70450b9d9baef0
2026-01-04T17:49:06.790742Z
false
jamesbrooks/hash_validator
https://github.com/jamesbrooks/hash_validator/blob/05b09c196cb6ef3af5a36030ed70450b9d9baef0/spec/validators/boolean_spec.rb
spec/validators/boolean_spec.rb
# frozen_string_literal: true require "spec_helper" describe HashValidator::Validator::Base do let(:validator) { HashValidator::Validator::BooleanValidator.new } let(:errors) { Hash.new } describe "#should_validate?" do it 'should validate the name "boolean"' do expect(validator.should_validate?("...
ruby
MIT
05b09c196cb6ef3af5a36030ed70450b9d9baef0
2026-01-04T17:49:06.790742Z
false
jamesbrooks/hash_validator
https://github.com/jamesbrooks/hash_validator/blob/05b09c196cb6ef3af5a36030ed70450b9d9baef0/spec/validators/alphanumeric_validator_spec.rb
spec/validators/alphanumeric_validator_spec.rb
# frozen_string_literal: true require "spec_helper" describe HashValidator::Validator::AlphanumericValidator do let(:validator) { HashValidator::Validator::AlphanumericValidator.new } context "valid alphanumeric strings" do it "validates letters only" do errors = {} validator.validate("key", "abc...
ruby
MIT
05b09c196cb6ef3af5a36030ed70450b9d9baef0
2026-01-04T17:49:06.790742Z
false
jamesbrooks/hash_validator
https://github.com/jamesbrooks/hash_validator/blob/05b09c196cb6ef3af5a36030ed70450b9d9baef0/spec/validators/ipv4_validator_spec.rb
spec/validators/ipv4_validator_spec.rb
# frozen_string_literal: true require "spec_helper" describe HashValidator::Validator::Ipv4Validator do let(:validator) { HashValidator::Validator::Ipv4Validator.new } context "valid IPv4 addresses" do it "validates standard IPv4 addresses" do errors = {} validator.validate("key", "192.168.1.1", ...
ruby
MIT
05b09c196cb6ef3af5a36030ed70450b9d9baef0
2026-01-04T17:49:06.790742Z
false
jamesbrooks/hash_validator
https://github.com/jamesbrooks/hash_validator/blob/05b09c196cb6ef3af5a36030ed70450b9d9baef0/spec/validators/dynamic_pattern_validator_spec.rb
spec/validators/dynamic_pattern_validator_spec.rb
# frozen_string_literal: true require "spec_helper" describe HashValidator::Validator::DynamicPatternValidator do describe "Pattern-based validator" do let(:odd_pattern_validator) do HashValidator::Validator::DynamicPatternValidator.new( "odd_pattern", /\A\d*[13579]\z/, "is not an ...
ruby
MIT
05b09c196cb6ef3af5a36030ed70450b9d9baef0
2026-01-04T17:49:06.790742Z
false
jamesbrooks/hash_validator
https://github.com/jamesbrooks/hash_validator/blob/05b09c196cb6ef3af5a36030ed70450b9d9baef0/spec/validators/json_validator_spec.rb
spec/validators/json_validator_spec.rb
# frozen_string_literal: true require "spec_helper" describe HashValidator::Validator::JsonValidator do let(:validator) { HashValidator::Validator::JsonValidator.new } context "valid JSON" do it "validates simple JSON objects" do errors = {} validator.validate("key", '{"name": "test"}', {}, error...
ruby
MIT
05b09c196cb6ef3af5a36030ed70450b9d9baef0
2026-01-04T17:49:06.790742Z
false
jamesbrooks/hash_validator
https://github.com/jamesbrooks/hash_validator/blob/05b09c196cb6ef3af5a36030ed70450b9d9baef0/spec/validators/url_validator_spec.rb
spec/validators/url_validator_spec.rb
# frozen_string_literal: true require "spec_helper" describe HashValidator::Validator::UrlValidator do let(:validator) { HashValidator::Validator::UrlValidator.new } context "valid URLs" do it "validates http URLs" do errors = {} validator.validate("key", "http://example.com", {}, errors) e...
ruby
MIT
05b09c196cb6ef3af5a36030ed70450b9d9baef0
2026-01-04T17:49:06.790742Z
false
jamesbrooks/hash_validator
https://github.com/jamesbrooks/hash_validator/blob/05b09c196cb6ef3af5a36030ed70450b9d9baef0/lib/hash_validator.rb
lib/hash_validator.rb
# frozen_string_literal: true module HashValidator def self.validate(*args) Base.validate(*args) end def self.optional(validation) Validations::Optional.new(validation) end def self.many(validation) Validations::Many.new(validation) end def self.multiple(*validations) Validations::Mult...
ruby
MIT
05b09c196cb6ef3af5a36030ed70450b9d9baef0
2026-01-04T17:49:06.790742Z
false
jamesbrooks/hash_validator
https://github.com/jamesbrooks/hash_validator/blob/05b09c196cb6ef3af5a36030ed70450b9d9baef0/lib/hash_validator/version.rb
lib/hash_validator/version.rb
# frozen_string_literal: true module HashValidator VERSION = "2.0.1" end
ruby
MIT
05b09c196cb6ef3af5a36030ed70450b9d9baef0
2026-01-04T17:49:06.790742Z
false
jamesbrooks/hash_validator
https://github.com/jamesbrooks/hash_validator/blob/05b09c196cb6ef3af5a36030ed70450b9d9baef0/lib/hash_validator/validations.rb
lib/hash_validator/validations.rb
# frozen_string_literal: true module HashValidator module Validations end end # Load validators require "hash_validator/validations/optional" require "hash_validator/validations/many" require "hash_validator/validations/multiple"
ruby
MIT
05b09c196cb6ef3af5a36030ed70450b9d9baef0
2026-01-04T17:49:06.790742Z
false
jamesbrooks/hash_validator
https://github.com/jamesbrooks/hash_validator/blob/05b09c196cb6ef3af5a36030ed70450b9d9baef0/lib/hash_validator/base.rb
lib/hash_validator/base.rb
# frozen_string_literal: true class HashValidator::Base attr_accessor :hash, :validations, :errors def initialize(hash, validations) self.errors = {} self.hash = hash self.validations = validations validate end def valid? errors.empty? end def self.validate(hash, valida...
ruby
MIT
05b09c196cb6ef3af5a36030ed70450b9d9baef0
2026-01-04T17:49:06.790742Z
false
jamesbrooks/hash_validator
https://github.com/jamesbrooks/hash_validator/blob/05b09c196cb6ef3af5a36030ed70450b9d9baef0/lib/hash_validator/configuration.rb
lib/hash_validator/configuration.rb
# frozen_string_literal: true module HashValidator class Configuration def add_validator(*args) HashValidator.add_validator(*args) end def remove_validator(name) HashValidator.remove_validator(name) end end def self.configure config = Configuration.new yield(config) if block...
ruby
MIT
05b09c196cb6ef3af5a36030ed70450b9d9baef0
2026-01-04T17:49:06.790742Z
false
jamesbrooks/hash_validator
https://github.com/jamesbrooks/hash_validator/blob/05b09c196cb6ef3af5a36030ed70450b9d9baef0/lib/hash_validator/validators.rb
lib/hash_validator/validators.rb
# frozen_string_literal: true module HashValidator @@validators = [] def self.remove_validator(name) name = name.to_s @@validators.reject! { |v| v.name == name } end def self.add_validator(*args) validator = case args.length when 1 # Instance-based validator (existing behavior) v...
ruby
MIT
05b09c196cb6ef3af5a36030ed70450b9d9baef0
2026-01-04T17:49:06.790742Z
false
jamesbrooks/hash_validator
https://github.com/jamesbrooks/hash_validator/blob/05b09c196cb6ef3af5a36030ed70450b9d9baef0/lib/hash_validator/validators/url_validator.rb
lib/hash_validator/validators/url_validator.rb
# frozen_string_literal: true require "uri" class HashValidator::Validator::UrlValidator < HashValidator::Validator::Base def initialize super("url") # The name of the validator end def error_message "is not a valid URL" end def valid?(value) return false unless value.is_a?(String) uri = ...
ruby
MIT
05b09c196cb6ef3af5a36030ed70450b9d9baef0
2026-01-04T17:49:06.790742Z
false
jamesbrooks/hash_validator
https://github.com/jamesbrooks/hash_validator/blob/05b09c196cb6ef3af5a36030ed70450b9d9baef0/lib/hash_validator/validators/multiple_validator.rb
lib/hash_validator/validators/multiple_validator.rb
# frozen_string_literal: true module HashValidator module Validator class MultipleValidator < Base def initialize super("_multiple") # The name of the validator, underscored as it won't usually be directly invoked (invoked through use of validator) end def should_validate?(validation)...
ruby
MIT
05b09c196cb6ef3af5a36030ed70450b9d9baef0
2026-01-04T17:49:06.790742Z
false
jamesbrooks/hash_validator
https://github.com/jamesbrooks/hash_validator/blob/05b09c196cb6ef3af5a36030ed70450b9d9baef0/lib/hash_validator/validators/regex_validator.rb
lib/hash_validator/validators/regex_validator.rb
# frozen_string_literal: true class HashValidator::Validator::RegexpValidator < HashValidator::Validator::Base def initialize super("_regex") # The name of the validator, underscored as it won't usually be directly invoked (invoked through use of validator) end def should_validate?(rhs) rhs.is_a?(Regex...
ruby
MIT
05b09c196cb6ef3af5a36030ed70450b9d9baef0
2026-01-04T17:49:06.790742Z
false
jamesbrooks/hash_validator
https://github.com/jamesbrooks/hash_validator/blob/05b09c196cb6ef3af5a36030ed70450b9d9baef0/lib/hash_validator/validators/alphanumeric_validator.rb
lib/hash_validator/validators/alphanumeric_validator.rb
# frozen_string_literal: true class HashValidator::Validator::AlphanumericValidator < HashValidator::Validator::Base def initialize super("alphanumeric") # The name of the validator end def error_message "must contain only letters and numbers" end def valid?(value) value.is_a?(String) && /\A[a...
ruby
MIT
05b09c196cb6ef3af5a36030ed70450b9d9baef0
2026-01-04T17:49:06.790742Z
false
jamesbrooks/hash_validator
https://github.com/jamesbrooks/hash_validator/blob/05b09c196cb6ef3af5a36030ed70450b9d9baef0/lib/hash_validator/validators/ipv4_validator.rb
lib/hash_validator/validators/ipv4_validator.rb
# frozen_string_literal: true class HashValidator::Validator::Ipv4Validator < HashValidator::Validator::Base def initialize super("ipv4") # The name of the validator end def error_message "is not a valid IPv4 address" end def valid?(value) return false unless value.is_a?(String) # IPv4 reg...
ruby
MIT
05b09c196cb6ef3af5a36030ed70450b9d9baef0
2026-01-04T17:49:06.790742Z
false
jamesbrooks/hash_validator
https://github.com/jamesbrooks/hash_validator/blob/05b09c196cb6ef3af5a36030ed70450b9d9baef0/lib/hash_validator/validators/hash_validator.rb
lib/hash_validator/validators/hash_validator.rb
# frozen_string_literal: true class HashValidator::Validator::HashValidator < HashValidator::Validator::Base def initialize super("hash") end def should_validate?(rhs) rhs.is_a?(Hash) || (defined?(ActionController::Parameters) && rhs.is_a?(ActionController::Parameters)) end def validate(key, value,...
ruby
MIT
05b09c196cb6ef3af5a36030ed70450b9d9baef0
2026-01-04T17:49:06.790742Z
false
jamesbrooks/hash_validator
https://github.com/jamesbrooks/hash_validator/blob/05b09c196cb6ef3af5a36030ed70450b9d9baef0/lib/hash_validator/validators/json_validator.rb
lib/hash_validator/validators/json_validator.rb
# frozen_string_literal: true require "json" class HashValidator::Validator::JsonValidator < HashValidator::Validator::Base def initialize super("json") # The name of the validator end def error_message "is not valid JSON" end def valid?(value) return false unless value.is_a?(String) JSON...
ruby
MIT
05b09c196cb6ef3af5a36030ed70450b9d9baef0
2026-01-04T17:49:06.790742Z
false
jamesbrooks/hash_validator
https://github.com/jamesbrooks/hash_validator/blob/05b09c196cb6ef3af5a36030ed70450b9d9baef0/lib/hash_validator/validators/class_validator.rb
lib/hash_validator/validators/class_validator.rb
# frozen_string_literal: true class HashValidator::Validator::ClassValidator < HashValidator::Validator::Base def initialize super("_class") # The name of the validator, underscored as it won't usually be directly invoked (invoked through use of validator) end def should_validate?(rhs) rhs.is_a?(Class)...
ruby
MIT
05b09c196cb6ef3af5a36030ed70450b9d9baef0
2026-01-04T17:49:06.790742Z
false
jamesbrooks/hash_validator
https://github.com/jamesbrooks/hash_validator/blob/05b09c196cb6ef3af5a36030ed70450b9d9baef0/lib/hash_validator/validators/many_validator.rb
lib/hash_validator/validators/many_validator.rb
# frozen_string_literal: true module HashValidator module Validator class ManyValidator < Base def initialize super("_many") # The name of the validator, underscored as it won't usually be directly invoked (invoked through use of validator) end def should_validate?(validation) ...
ruby
MIT
05b09c196cb6ef3af5a36030ed70450b9d9baef0
2026-01-04T17:49:06.790742Z
false
jamesbrooks/hash_validator
https://github.com/jamesbrooks/hash_validator/blob/05b09c196cb6ef3af5a36030ed70450b9d9baef0/lib/hash_validator/validators/array_validator.rb
lib/hash_validator/validators/array_validator.rb
# frozen_string_literal: true class HashValidator::Validator::ArrayValidator < HashValidator::Validator::Base def initialize super("__array__") # The name of the validator, underscored as it won't usually be directly invoked (invoked through use of validator) end def should_validate?(rhs) return false ...
ruby
MIT
05b09c196cb6ef3af5a36030ed70450b9d9baef0
2026-01-04T17:49:06.790742Z
false
jamesbrooks/hash_validator
https://github.com/jamesbrooks/hash_validator/blob/05b09c196cb6ef3af5a36030ed70450b9d9baef0/lib/hash_validator/validators/dynamic_func_validator.rb
lib/hash_validator/validators/dynamic_func_validator.rb
# frozen_string_literal: true class HashValidator::Validator::DynamicFuncValidator < HashValidator::Validator::Base attr_accessor :func, :custom_error_message def initialize(name, func, error_message = nil) super(name) unless func.respond_to?(:call) raise ArgumentError, "Function must be callable (...
ruby
MIT
05b09c196cb6ef3af5a36030ed70450b9d9baef0
2026-01-04T17:49:06.790742Z
false
jamesbrooks/hash_validator
https://github.com/jamesbrooks/hash_validator/blob/05b09c196cb6ef3af5a36030ed70450b9d9baef0/lib/hash_validator/validators/alpha_validator.rb
lib/hash_validator/validators/alpha_validator.rb
# frozen_string_literal: true class HashValidator::Validator::AlphaValidator < HashValidator::Validator::Base def initialize super("alpha") # The name of the validator end def error_message "must contain only letters" end def valid?(value) value.is_a?(String) && /\A[a-zA-Z]+\z/.match?(value) ...
ruby
MIT
05b09c196cb6ef3af5a36030ed70450b9d9baef0
2026-01-04T17:49:06.790742Z
false
jamesbrooks/hash_validator
https://github.com/jamesbrooks/hash_validator/blob/05b09c196cb6ef3af5a36030ed70450b9d9baef0/lib/hash_validator/validators/presence_validator.rb
lib/hash_validator/validators/presence_validator.rb
# frozen_string_literal: true class HashValidator::Validator::PresenceValidator < HashValidator::Validator::Base def initialize super("required") end def error_message "is required" end def valid?(value) !value.nil? end end HashValidator.add_validator(HashValidator::Validator::PresenceValida...
ruby
MIT
05b09c196cb6ef3af5a36030ed70450b9d9baef0
2026-01-04T17:49:06.790742Z
false
jamesbrooks/hash_validator
https://github.com/jamesbrooks/hash_validator/blob/05b09c196cb6ef3af5a36030ed70450b9d9baef0/lib/hash_validator/validators/base.rb
lib/hash_validator/validators/base.rb
# frozen_string_literal: true class HashValidator::Validator::Base attr_accessor :name def initialize(name) self.name = name.to_s unless self.name.size > 0 raise StandardError.new("Validator must be initialized with a valid name (length greater than zero)") end end def should_validate?(na...
ruby
MIT
05b09c196cb6ef3af5a36030ed70450b9d9baef0
2026-01-04T17:49:06.790742Z
false
jamesbrooks/hash_validator
https://github.com/jamesbrooks/hash_validator/blob/05b09c196cb6ef3af5a36030ed70450b9d9baef0/lib/hash_validator/validators/email_validator.rb
lib/hash_validator/validators/email_validator.rb
# frozen_string_literal: true class HashValidator::Validator::EmailValidator < HashValidator::Validator::Base def initialize super("email") # The name of the validator end def error_message "is not a valid email" end def valid?(value) value.is_a?(String) && value.include?("@") end end HashV...
ruby
MIT
05b09c196cb6ef3af5a36030ed70450b9d9baef0
2026-01-04T17:49:06.790742Z
false
jamesbrooks/hash_validator
https://github.com/jamesbrooks/hash_validator/blob/05b09c196cb6ef3af5a36030ed70450b9d9baef0/lib/hash_validator/validators/lambda_validator.rb
lib/hash_validator/validators/lambda_validator.rb
# frozen_string_literal: true class HashValidator::Validator::LambdaValidator < HashValidator::Validator::Base def initialize super("_lambda") # The name of the validator, underscored as it won't usually be directly invoked (invoked through use of validator) end def should_validate?(rhs) if rhs.is_a?(P...
ruby
MIT
05b09c196cb6ef3af5a36030ed70450b9d9baef0
2026-01-04T17:49:06.790742Z
false
jamesbrooks/hash_validator
https://github.com/jamesbrooks/hash_validator/blob/05b09c196cb6ef3af5a36030ed70450b9d9baef0/lib/hash_validator/validators/hex_color_validator.rb
lib/hash_validator/validators/hex_color_validator.rb
# frozen_string_literal: true class HashValidator::Validator::HexColorValidator < HashValidator::Validator::Base def initialize super("hex_color") # The name of the validator end def error_message "is not a valid hex color" end def valid?(value) value.is_a?(String) && /\A#([A-Fa-f0-9]{6}|[A-Fa...
ruby
MIT
05b09c196cb6ef3af5a36030ed70450b9d9baef0
2026-01-04T17:49:06.790742Z
false
jamesbrooks/hash_validator
https://github.com/jamesbrooks/hash_validator/blob/05b09c196cb6ef3af5a36030ed70450b9d9baef0/lib/hash_validator/validators/digits_validator.rb
lib/hash_validator/validators/digits_validator.rb
# frozen_string_literal: true class HashValidator::Validator::DigitsValidator < HashValidator::Validator::Base def initialize super("digits") # The name of the validator end def error_message "must contain only digits" end def valid?(value) value.is_a?(String) && /\A\d+\z/.match?(value) end ...
ruby
MIT
05b09c196cb6ef3af5a36030ed70450b9d9baef0
2026-01-04T17:49:06.790742Z
false
jamesbrooks/hash_validator
https://github.com/jamesbrooks/hash_validator/blob/05b09c196cb6ef3af5a36030ed70450b9d9baef0/lib/hash_validator/validators/simple_validator.rb
lib/hash_validator/validators/simple_validator.rb
# frozen_string_literal: true class HashValidator::Validator::SimpleValidator < HashValidator::Validator::Base attr_accessor :lambda def initialize(name, lambda) # lambda must accept one argument (the value) if lambda.arity != 1 raise StandardError.new("lambda should take only one argument - passed...
ruby
MIT
05b09c196cb6ef3af5a36030ed70450b9d9baef0
2026-01-04T17:49:06.790742Z
false
jamesbrooks/hash_validator
https://github.com/jamesbrooks/hash_validator/blob/05b09c196cb6ef3af5a36030ed70450b9d9baef0/lib/hash_validator/validators/simple_type_validators.rb
lib/hash_validator/validators/simple_type_validators.rb
# frozen_string_literal: true [ Array, Complex, Enumerable, Float, Integer, Numeric, Range, Rational, Regexp, String, Symbol, Time ].each do |type| name = type.to_s.gsub(/(.)([A-Z])/, '\1_\2').downcase # ActiveSupport/Inflector#underscore behaviour HashValidator.add_validator(HashValidator...
ruby
MIT
05b09c196cb6ef3af5a36030ed70450b9d9baef0
2026-01-04T17:49:06.790742Z
false
jamesbrooks/hash_validator
https://github.com/jamesbrooks/hash_validator/blob/05b09c196cb6ef3af5a36030ed70450b9d9baef0/lib/hash_validator/validators/ip_validator.rb
lib/hash_validator/validators/ip_validator.rb
# frozen_string_literal: true require "ipaddr" class HashValidator::Validator::IpValidator < HashValidator::Validator::Base def initialize super("ip") # The name of the validator end def error_message "is not a valid IP address" end def valid?(value) return false unless value.is_a?(String) ...
ruby
MIT
05b09c196cb6ef3af5a36030ed70450b9d9baef0
2026-01-04T17:49:06.790742Z
false
jamesbrooks/hash_validator
https://github.com/jamesbrooks/hash_validator/blob/05b09c196cb6ef3af5a36030ed70450b9d9baef0/lib/hash_validator/validators/optional_validator.rb
lib/hash_validator/validators/optional_validator.rb
# frozen_string_literal: true module HashValidator module Validator class OptionalValidator < Base def initialize super("_optional") # The name of the validator, underscored as it won't usually be directly invoked (invoked through use of validator) end def should_validate?(validation)...
ruby
MIT
05b09c196cb6ef3af5a36030ed70450b9d9baef0
2026-01-04T17:49:06.790742Z
false
jamesbrooks/hash_validator
https://github.com/jamesbrooks/hash_validator/blob/05b09c196cb6ef3af5a36030ed70450b9d9baef0/lib/hash_validator/validators/dynamic_pattern_validator.rb
lib/hash_validator/validators/dynamic_pattern_validator.rb
# frozen_string_literal: true class HashValidator::Validator::DynamicPatternValidator < HashValidator::Validator::Base attr_accessor :pattern, :custom_error_message def initialize(name, pattern, error_message = nil) super(name) unless pattern.is_a?(Regexp) raise ArgumentError, "Pattern must be a re...
ruby
MIT
05b09c196cb6ef3af5a36030ed70450b9d9baef0
2026-01-04T17:49:06.790742Z
false
jamesbrooks/hash_validator
https://github.com/jamesbrooks/hash_validator/blob/05b09c196cb6ef3af5a36030ed70450b9d9baef0/lib/hash_validator/validators/enumerable_validator.rb
lib/hash_validator/validators/enumerable_validator.rb
# frozen_string_literal: true class HashValidator::Validator::EnumerableValidator < HashValidator::Validator::Base def initialize super("_enumerable") # The name of the validator, underscored as it won't usually be directly invoked (invoked through use of validator) end def should_validate?(rhs) rhs.is...
ruby
MIT
05b09c196cb6ef3af5a36030ed70450b9d9baef0
2026-01-04T17:49:06.790742Z
false
jamesbrooks/hash_validator
https://github.com/jamesbrooks/hash_validator/blob/05b09c196cb6ef3af5a36030ed70450b9d9baef0/lib/hash_validator/validators/ipv6_validator.rb
lib/hash_validator/validators/ipv6_validator.rb
# frozen_string_literal: true require "ipaddr" class HashValidator::Validator::Ipv6Validator < HashValidator::Validator::Base def initialize super("ipv6") # The name of the validator end def error_message "is not a valid IPv6 address" end def valid?(value) return false unless value.is_a?(Stri...
ruby
MIT
05b09c196cb6ef3af5a36030ed70450b9d9baef0
2026-01-04T17:49:06.790742Z
false
jamesbrooks/hash_validator
https://github.com/jamesbrooks/hash_validator/blob/05b09c196cb6ef3af5a36030ed70450b9d9baef0/lib/hash_validator/validators/boolean_validator.rb
lib/hash_validator/validators/boolean_validator.rb
# frozen_string_literal: true class HashValidator::Validator::BooleanValidator < HashValidator::Validator::Base def initialize super("boolean") # The name of the validator end def valid?(value) [TrueClass, FalseClass].include?(value.class) end end HashValidator.add_validator(HashValidator::Validator...
ruby
MIT
05b09c196cb6ef3af5a36030ed70450b9d9baef0
2026-01-04T17:49:06.790742Z
false
jamesbrooks/hash_validator
https://github.com/jamesbrooks/hash_validator/blob/05b09c196cb6ef3af5a36030ed70450b9d9baef0/lib/hash_validator/validations/optional.rb
lib/hash_validator/validations/optional.rb
# frozen_string_literal: true module HashValidator::Validations class Optional attr_reader :validation def initialize(validation) @validation = validation end end end
ruby
MIT
05b09c196cb6ef3af5a36030ed70450b9d9baef0
2026-01-04T17:49:06.790742Z
false
jamesbrooks/hash_validator
https://github.com/jamesbrooks/hash_validator/blob/05b09c196cb6ef3af5a36030ed70450b9d9baef0/lib/hash_validator/validations/many.rb
lib/hash_validator/validations/many.rb
# frozen_string_literal: true module HashValidator::Validations class Many attr_reader :validation def initialize(validation) @validation = validation end end end
ruby
MIT
05b09c196cb6ef3af5a36030ed70450b9d9baef0
2026-01-04T17:49:06.790742Z
false
jamesbrooks/hash_validator
https://github.com/jamesbrooks/hash_validator/blob/05b09c196cb6ef3af5a36030ed70450b9d9baef0/lib/hash_validator/validations/multiple.rb
lib/hash_validator/validations/multiple.rb
# frozen_string_literal: true module HashValidator::Validations class Multiple attr_reader :validations def initialize(validations) @validations = validations end end end
ruby
MIT
05b09c196cb6ef3af5a36030ed70450b9d9baef0
2026-01-04T17:49:06.790742Z
false
postmodern/nokogiri-diff
https://github.com/postmodern/nokogiri-diff/blob/ea873edceb4e42fcdfc5a729ba899dff6ee68d80/spec/diff_spec.rb
spec/diff_spec.rb
require 'spec_helper' require 'nokogiri/diff' describe "nokogiri/diff" do let(:contents) { '<div><p>one</p></div>' } let(:doc) { Nokogiri::XML(contents) } let(:added_text) { Nokogiri::XML('<div><p>one</p>two</div>') } let(:added_element) { Nokogiri::XML('<div><p>one</p><p>two</p></div>') } let(:adde...
ruby
MIT
ea873edceb4e42fcdfc5a729ba899dff6ee68d80
2026-01-04T17:49:08.631513Z
false
postmodern/nokogiri-diff
https://github.com/postmodern/nokogiri-diff/blob/ea873edceb4e42fcdfc5a729ba899dff6ee68d80/spec/spec_helper.rb
spec/spec_helper.rb
require 'rspec' require 'simplecov' SimpleCov.start
ruby
MIT
ea873edceb4e42fcdfc5a729ba899dff6ee68d80
2026-01-04T17:49:08.631513Z
false
postmodern/nokogiri-diff
https://github.com/postmodern/nokogiri-diff/blob/ea873edceb4e42fcdfc5a729ba899dff6ee68d80/lib/nokogiri/diff.rb
lib/nokogiri/diff.rb
# frozen_string_literal: true require_relative 'diff/xml' require_relative 'diff/version'
ruby
MIT
ea873edceb4e42fcdfc5a729ba899dff6ee68d80
2026-01-04T17:49:08.631513Z
false
postmodern/nokogiri-diff
https://github.com/postmodern/nokogiri-diff/blob/ea873edceb4e42fcdfc5a729ba899dff6ee68d80/lib/nokogiri/diff/version.rb
lib/nokogiri/diff/version.rb
# frozen_string_literal: true module Nokogiri module Diff # nokogiri-diff version VERSION = '0.3.0' end end
ruby
MIT
ea873edceb4e42fcdfc5a729ba899dff6ee68d80
2026-01-04T17:49:08.631513Z
false