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 |
|---|---|---|---|---|---|---|---|---|
jm/matchy | https://github.com/jm/matchy/blob/2e01918ad8d601685386aa9ac5d547ffb9b70b27/test/test_change_expectation.rb | test/test_change_expectation.rb | require File.dirname(__FILE__) + '/test_helper.rb'
class TestChangeExpectations < Test::Unit::TestCase
def test_change
var = 1
lambda {var += 1}.should change {var}
end
def test_change_fails
var = 1
lambda do
lambda { }.should change {var}
end.should raise_error
end
def test_... | ruby | MIT | 2e01918ad8d601685386aa9ac5d547ffb9b70b27 | 2026-01-04T17:56:08.640464Z | false |
jm/matchy | https://github.com/jm/matchy/blob/2e01918ad8d601685386aa9ac5d547ffb9b70b27/test/test_matcher_builder.rb | test/test_matcher_builder.rb | require File.dirname(__FILE__) + '/test_helper.rb'
class TestMatcherBuilder < Test::Unit::TestCase
include Matchy::MatcherBuilder
def setup
@obj = Object.new
end
def test_matcher_responds_to_matches
block = lambda {|given, matcher, args| true}
build_matcher(:m, &block).should respond_to(:matche... | ruby | MIT | 2e01918ad8d601685386aa9ac5d547ffb9b70b27 | 2026-01-04T17:56:08.640464Z | false |
jm/matchy | https://github.com/jm/matchy/blob/2e01918ad8d601685386aa9ac5d547ffb9b70b27/test/test_modals.rb | test/test_modals.rb | require File.dirname(__FILE__) + '/test_helper.rb'
class TestModals < Test::Unit::TestCase
def setup
@expectation = build_matcher() {|r,m,a| true}
@bad_expectation = build_matcher() {|r,m,a| false}
end
def test_should
3.should(@expectation)
end
def test_will
3.will(@expectation)
end
... | ruby | MIT | 2e01918ad8d601685386aa9ac5d547ffb9b70b27 | 2026-01-04T17:56:08.640464Z | false |
jm/matchy | https://github.com/jm/matchy/blob/2e01918ad8d601685386aa9ac5d547ffb9b70b27/test/test_helper.rb | test/test_helper.rb | require File.dirname(__FILE__) + '/../lib/matchy.rb'
| ruby | MIT | 2e01918ad8d601685386aa9ac5d547ffb9b70b27 | 2026-01-04T17:56:08.640464Z | false |
jm/matchy | https://github.com/jm/matchy/blob/2e01918ad8d601685386aa9ac5d547ffb9b70b27/test/test_operator_expectations.rb | test/test_operator_expectations.rb | require File.dirname(__FILE__) + '/test_helper.rb'
class TestOperatorExpectations < Test::Unit::TestCase
# EQUALS (==)
def test_equals
3.should == 3
end
def test_equals_fails
lambda {
3.should == 5
}.should raise_error(Test::Unit::AssertionFailedError)
end
def test_negative_equals
... | ruby | MIT | 2e01918ad8d601685386aa9ac5d547ffb9b70b27 | 2026-01-04T17:56:08.640464Z | false |
jm/matchy | https://github.com/jm/matchy/blob/2e01918ad8d601685386aa9ac5d547ffb9b70b27/test/test_expectation_builder.rb | test/test_expectation_builder.rb | require File.dirname(__FILE__) + '/test_helper.rb'
class TestExpectationBuilder < Test::Unit::TestCase
def setup
@obj = Object.new
end
def test_should
exp = Matchy::ExpectationBuilder.build_expectation(true, nil, @obj)
exp.send(:==, @obj)
end
def test_should_fails
expect_1 = Matchy::... | ruby | MIT | 2e01918ad8d601685386aa9ac5d547ffb9b70b27 | 2026-01-04T17:56:08.640464Z | false |
jm/matchy | https://github.com/jm/matchy/blob/2e01918ad8d601685386aa9ac5d547ffb9b70b27/test/test_def_matcher.rb | test/test_def_matcher.rb | require File.dirname(__FILE__) + '/test_helper.rb'
class TestDefMatcher < Test::Unit::TestCase
def setup
@obj = Object.new
end
def test_defines_method
def_matcher :method_ do |given, matcher, args|
end
self.should respond_to(:method_)
end
def test_object_responds_to_matches
de... | ruby | MIT | 2e01918ad8d601685386aa9ac5d547ffb9b70b27 | 2026-01-04T17:56:08.640464Z | false |
jm/matchy | https://github.com/jm/matchy/blob/2e01918ad8d601685386aa9ac5d547ffb9b70b27/test/test_truth_expectations.rb | test/test_truth_expectations.rb | require File.dirname(__FILE__) + '/test_helper.rb'
class Exister
def initialize(what)
@what = what
end
def exist?
@what
end
end
class TestTruthExpectations < Test::Unit::TestCase
def setup
@obj = Object.new
end
def test_equal
3.should equal(3)
end
def test_negative_equal
... | ruby | MIT | 2e01918ad8d601685386aa9ac5d547ffb9b70b27 | 2026-01-04T17:56:08.640464Z | false |
jm/matchy | https://github.com/jm/matchy/blob/2e01918ad8d601685386aa9ac5d547ffb9b70b27/test/all.rb | test/all.rb | dir = File.dirname(__FILE__)
Dir[File.expand_path("#{dir}/*.rb")].uniq.each do |file|
if file =~ /\/test_\w+\.rb$/
puts file
require file
end
end | ruby | MIT | 2e01918ad8d601685386aa9ac5d547ffb9b70b27 | 2026-01-04T17:56:08.640464Z | false |
jm/matchy | https://github.com/jm/matchy/blob/2e01918ad8d601685386aa9ac5d547ffb9b70b27/lib/matchy.rb | lib/matchy.rb | $:.unshift(File.dirname(__FILE__)) unless
$:.include?(File.dirname(__FILE__)) || $:.include?(File.expand_path(File.dirname(__FILE__)))
# Matchy should work with either test/unit
# or minitest
module Matchy
def self.minitest?
# This needs to be better.
# How can we decide if we really have a
# suite o... | ruby | MIT | 2e01918ad8d601685386aa9ac5d547ffb9b70b27 | 2026-01-04T17:56:08.640464Z | false |
jm/matchy | https://github.com/jm/matchy/blob/2e01918ad8d601685386aa9ac5d547ffb9b70b27/lib/matchy/expectation_builder.rb | lib/matchy/expectation_builder.rb | module Matchy
module ExpectationBuilder
def self.build_expectation(match, exp, obj)
return Matchy::Expectations::OperatorExpectation.new(obj, match) unless exp
(exp.matches?(obj) != match) ? exp.fail!(match) : exp.pass!(match)
end
end
end | ruby | MIT | 2e01918ad8d601685386aa9ac5d547ffb9b70b27 | 2026-01-04T17:56:08.640464Z | false |
jm/matchy | https://github.com/jm/matchy/blob/2e01918ad8d601685386aa9ac5d547ffb9b70b27/lib/matchy/version.rb | lib/matchy/version.rb | module Matchy
module VERSION #:nodoc:
MAJOR = 0
MINOR = 3
TINY = 0
STRING = [MAJOR, MINOR, TINY].join('.')
end
end
| ruby | MIT | 2e01918ad8d601685386aa9ac5d547ffb9b70b27 | 2026-01-04T17:56:08.640464Z | false |
jm/matchy | https://github.com/jm/matchy/blob/2e01918ad8d601685386aa9ac5d547ffb9b70b27/lib/matchy/def_matcher.rb | lib/matchy/def_matcher.rb | module Matchy
module DefMatcher
include Matchy::MatcherBuilder
def def_matcher(matcher_name, &block)
self.class.send :define_method, matcher_name do |*args|
build_matcher(matcher_name, args, &block)
end
end
end
end
| ruby | MIT | 2e01918ad8d601685386aa9ac5d547ffb9b70b27 | 2026-01-04T17:56:08.640464Z | false |
jm/matchy | https://github.com/jm/matchy/blob/2e01918ad8d601685386aa9ac5d547ffb9b70b27/lib/matchy/modals.rb | lib/matchy/modals.rb | module Matchy
module Modals
# Tests an expectation against the given object.
#
# ==== Examples
#
# "hello".should eql("hello")
# 13.should equal(13)
# lambda { raise "u r doomed" }.should raise_error
#
def should(expectation = nil)
Matchy::ExpectationBuilder.build_expe... | ruby | MIT | 2e01918ad8d601685386aa9ac5d547ffb9b70b27 | 2026-01-04T17:56:08.640464Z | false |
jm/matchy | https://github.com/jm/matchy/blob/2e01918ad8d601685386aa9ac5d547ffb9b70b27/lib/matchy/matcher_builder.rb | lib/matchy/matcher_builder.rb | module Matchy
module MatcherBuilder
def build_matcher(matcher_name=nil, args=[], &block)
match_block = lambda do |actual, matcher|
block.call(actual, matcher, args)
end
body = lambda do |klass|
include Matchy.assertions_module
@matcher_name = matcher_name.to_s
def... | ruby | MIT | 2e01918ad8d601685386aa9ac5d547ffb9b70b27 | 2026-01-04T17:56:08.640464Z | false |
jm/matchy | https://github.com/jm/matchy/blob/2e01918ad8d601685386aa9ac5d547ffb9b70b27/lib/matchy/built_in/truth_expectations.rb | lib/matchy/built_in/truth_expectations.rb | module Matchy
module Expectations
module TestCaseExtensions
# Simply checks if the receiver matches the expected object.
# TODO: Fill this out to implement much of the RSpec functionality (and then some)
#
# ==== Examples
#
# "hello".should be("hello")
# (13 < 20).sho... | ruby | MIT | 2e01918ad8d601685386aa9ac5d547ffb9b70b27 | 2026-01-04T17:56:08.640464Z | false |
jm/matchy | https://github.com/jm/matchy/blob/2e01918ad8d601685386aa9ac5d547ffb9b70b27/lib/matchy/built_in/error_expectations.rb | lib/matchy/built_in/error_expectations.rb | module Matchy
module Expectations
module TestCaseExtensions
# Expects a lambda to raise an error. You can specify the error or leave it blank to encompass
# any error.
#
# ==== Examples
#
# lambda { raise "FAILURE." }.should raise_error
# lambda { puts i_dont_exist }... | ruby | MIT | 2e01918ad8d601685386aa9ac5d547ffb9b70b27 | 2026-01-04T17:56:08.640464Z | false |
jm/matchy | https://github.com/jm/matchy/blob/2e01918ad8d601685386aa9ac5d547ffb9b70b27/lib/matchy/built_in/change_expectations.rb | lib/matchy/built_in/change_expectations.rb | module Matchy
module Expectations
module TestCaseExtensions
# Checks if the given block alters the value of the block attached to change
#
# ==== Examples
# lambda {var += 1}.should change {var}.by(1)
# lambda {var += 2}.should change {var}.by_at_least(1)
# lambda {var +=... | ruby | MIT | 2e01918ad8d601685386aa9ac5d547ffb9b70b27 | 2026-01-04T17:56:08.640464Z | false |
jm/matchy | https://github.com/jm/matchy/blob/2e01918ad8d601685386aa9ac5d547ffb9b70b27/lib/matchy/built_in/enumerable_expectations.rb | lib/matchy/built_in/enumerable_expectations.rb | module Matchy
module Expectations
module TestCaseExtensions
# Calls +include?+ on the receiver for any object. You can also provide
# multiple arguments to see if all of them are included.
#
# ==== Examples
#
# [1,2,3].should include(1)
# [7,8,8].should_no... | ruby | MIT | 2e01918ad8d601685386aa9ac5d547ffb9b70b27 | 2026-01-04T17:56:08.640464Z | false |
jm/matchy | https://github.com/jm/matchy/blob/2e01918ad8d601685386aa9ac5d547ffb9b70b27/lib/matchy/built_in/operator_expectations.rb | lib/matchy/built_in/operator_expectations.rb | module Matchy
module Expectations
# Class to handle operator expectations.
#
# ==== Examples
#
# 13.should == 13
# "hello".length.should_not == 2
#
class OperatorExpectation #< Base
include Matchy.assertions_module
def initialize(receiver, match)
... | ruby | MIT | 2e01918ad8d601685386aa9ac5d547ffb9b70b27 | 2026-01-04T17:56:08.640464Z | false |
jm/matchy | https://github.com/jm/matchy/blob/2e01918ad8d601685386aa9ac5d547ffb9b70b27/config/hoe.rb | config/hoe.rb | require 'matchy/version'
AUTHOR = 'Jeremy McAnally' # can also be an array of Authors
EMAIL = "jeremy@entp.com"
DESCRIPTION = "RSpec-esque matchers for use in Test::Unit"
GEM_NAME = 'matchy' # what ppl will type to install your gem
RUBYFORGE_PROJECT = 'matchy' # The unix name for your project
HOMEPATH = "http://#{RUB... | ruby | MIT | 2e01918ad8d601685386aa9ac5d547ffb9b70b27 | 2026-01-04T17:56:08.640464Z | false |
jm/matchy | https://github.com/jm/matchy/blob/2e01918ad8d601685386aa9ac5d547ffb9b70b27/config/requirements.rb | config/requirements.rb | require 'fileutils'
include FileUtils
require 'rubygems'
%w[rake hoe newgem rubigen].each do |req_gem|
begin
require req_gem
rescue LoadError
puts "This Rakefile requires the '#{req_gem}' RubyGem."
puts "Installation: gem install #{req_gem} -y"
exit
end
end
$:.unshift(File.join(File.dirname(__FI... | ruby | MIT | 2e01918ad8d601685386aa9ac5d547ffb9b70b27 | 2026-01-04T17:56:08.640464Z | false |
ryw/pinboard | https://github.com/ryw/pinboard/blob/5c813b7018b7df9a6d359c34ed294eb0d65cb28a/spec/helper.rb | spec/helper.rb | require 'pinboard'
require 'rspec'
require 'webmock/rspec'
def a_get(path)
a_request(:get, Pinboard.endpoint + path)
end
def stub_get(path)
stub_request(:get, uri(path))
end
def stub_post(path)
stub_request(:post, uri(path))
end
def uri(path)
"https://api.pinboard.in/v1/#{path}"
end
def fixture_path
File... | ruby | MIT | 5c813b7018b7df9a6d359c34ed294eb0d65cb28a | 2026-01-04T17:56:09.554894Z | false |
ryw/pinboard | https://github.com/ryw/pinboard/blob/5c813b7018b7df9a6d359c34ed294eb0d65cb28a/spec/pinboard_spec.rb | spec/pinboard_spec.rb | require 'helper'
describe Pinboard do
describe ".new" do
it "returns a Pinboard client" do
Pinboard.new.should be_a Pinboard::Client
end
end
describe ".endpoint" do
it "sets the endpoint" do
Pinboard.endpoint.should == 'https://api.pinboard.in:443/v1'
end
end
end
| ruby | MIT | 5c813b7018b7df9a6d359c34ed294eb0d65cb28a | 2026-01-04T17:56:09.554894Z | false |
ryw/pinboard | https://github.com/ryw/pinboard/blob/5c813b7018b7df9a6d359c34ed294eb0d65cb28a/spec/pinboard/client_spec.rb | spec/pinboard/client_spec.rb | require 'helper'
describe Pinboard::Client do
describe "#posts" do
let(:client) { Pinboard::Client.new }
context "when there are many posts" do
before do
stub_get("posts/all?").
to_return(:body => fixture("multiple_posts.xml"),
:headers => { 'content-type' => 'tex... | ruby | MIT | 5c813b7018b7df9a6d359c34ed294eb0d65cb28a | 2026-01-04T17:56:09.554894Z | false |
ryw/pinboard | https://github.com/ryw/pinboard/blob/5c813b7018b7df9a6d359c34ed294eb0d65cb28a/spec/pinboard/post_spec.rb | spec/pinboard/post_spec.rb | require 'helper'
describe Pinboard::Post do
describe ".all" do
let(:posts) { Pinboard::Post.all }
before do
stub_get("posts/all").
to_return(:body => fixture("multiple_posts.xml"),
:headers => { 'content-type' => 'text/xml' })
end
it "returns a collection" do
... | ruby | MIT | 5c813b7018b7df9a6d359c34ed294eb0d65cb28a | 2026-01-04T17:56:09.554894Z | false |
ryw/pinboard | https://github.com/ryw/pinboard/blob/5c813b7018b7df9a6d359c34ed294eb0d65cb28a/lib/pinboard.rb | lib/pinboard.rb | require 'pinboard/util'
require 'pinboard/client'
require 'pinboard/post'
require 'pinboard/tag'
require 'pinboard/note'
module Pinboard
class << self
def new(options={})
Pinboard::Client.new(options)
end
def endpoint
Pinboard::Client.base_uri
end
end
end
| ruby | MIT | 5c813b7018b7df9a6d359c34ed294eb0d65cb28a | 2026-01-04T17:56:09.554894Z | false |
ryw/pinboard | https://github.com/ryw/pinboard/blob/5c813b7018b7df9a6d359c34ed294eb0d65cb28a/lib/pinboard/tag.rb | lib/pinboard/tag.rb | module Pinboard
class Tag < Struct.new(:tag, :count)
def initialize(attributes={})
self.tag = attributes.delete(:tag)
self.count = attributes.delete(:count).to_i
end
end
end
| ruby | MIT | 5c813b7018b7df9a6d359c34ed294eb0d65cb28a | 2026-01-04T17:56:09.554894Z | false |
ryw/pinboard | https://github.com/ryw/pinboard/blob/5c813b7018b7df9a6d359c34ed294eb0d65cb28a/lib/pinboard/note.rb | lib/pinboard/note.rb | module Pinboard
class Note < Struct.new(:id, :title, :created_at, :updated_at, :length, :text)
def initialize(attributes={})
self.id = attributes[:id]
self.title = attributes[:title]
self.created_at = attributes[:created_at] && Util.parse_time(attributes[:created_at])
self.upd... | ruby | MIT | 5c813b7018b7df9a6d359c34ed294eb0d65cb28a | 2026-01-04T17:56:09.554894Z | false |
ryw/pinboard | https://github.com/ryw/pinboard/blob/5c813b7018b7df9a6d359c34ed294eb0d65cb28a/lib/pinboard/post.rb | lib/pinboard/post.rb | module Pinboard
class Post < Struct.new(:href, :description, :extended, :tag, :time, :replace, :shared, :toread)
def self.all(options={})
client = Pinboard::Client.new(options)
posts = client.class.get('/posts/all',
:basic_auth => options)['posts']['post']
posts.map { |p| Post.ne... | ruby | MIT | 5c813b7018b7df9a6d359c34ed294eb0d65cb28a | 2026-01-04T17:56:09.554894Z | false |
ryw/pinboard | https://github.com/ryw/pinboard/blob/5c813b7018b7df9a6d359c34ed294eb0d65cb28a/lib/pinboard/client.rb | lib/pinboard/client.rb | require 'httparty'
require 'time'
module Pinboard
# Raised when API returns failure
Error = Class.new(StandardError)
class Client
include HTTParty
base_uri 'api.pinboard.in:443/v1'
# Construct a new instance of the client
#
# @param [Hash] options Options for the connection
# @option op... | ruby | MIT | 5c813b7018b7df9a6d359c34ed294eb0d65cb28a | 2026-01-04T17:56:09.554894Z | false |
ryw/pinboard | https://github.com/ryw/pinboard/blob/5c813b7018b7df9a6d359c34ed294eb0d65cb28a/lib/pinboard/util.rb | lib/pinboard/util.rb | module Pinboard
module Util
extend self
def symbolize_keys(hash)
hash.inject({}) do |options, (key, value)|
options[(key.to_sym rescue key) || key] = value
options
end
end
def parse_time(time)
return time if time.is_a?(Time)
return time.to_time if time.is_a?(D... | ruby | MIT | 5c813b7018b7df9a6d359c34ed294eb0d65cb28a | 2026-01-04T17:56:09.554894Z | false |
kibitan/masking | https://github.com/kibitan/masking/blob/ad72ffa4263c94de97b1749df8791d254e38017e/benchmark/run.rb | benchmark/run.rb | #!/usr/bin/env ruby
# frozen_string_literal: true
$LOAD_PATH.unshift('./lib')
require 'benchmark'
require 'masking'
Masking.configure do |config|
config.target_columns_file_path = 'benchmark/masking.yml'
end
n = 30
fixture = File.open('benchmark/users.sql')
Benchmark.bm do |x|
x.report do
n.times do
... | ruby | MIT | ad72ffa4263c94de97b1749df8791d254e38017e | 2026-01-04T17:56:11.837143Z | false |
kibitan/masking | https://github.com/kibitan/masking/blob/ad72ffa4263c94de97b1749df8791d254e38017e/spec/masking_spec.rb | spec/masking_spec.rb | # frozen_string_literal: true
require 'spec_helper'
RSpec.describe Masking do
describe '.run' do
subject { described_class.run }
it 'call Main.new.run' do
expect(Masking::Main).to receive_message_chain(:new, :run)
expect { subject }.not_to raise_error
end
end
describe Masking::Main do... | ruby | MIT | ad72ffa4263c94de97b1749df8791d254e38017e | 2026-01-04T17:56:11.837143Z | false |
kibitan/masking | https://github.com/kibitan/masking/blob/ad72ffa4263c94de97b1749df8791d254e38017e/spec/spec_helper.rb | spec/spec_helper.rb | # frozen_string_literal: true
require 'bundler/setup'
require 'rspec'
require 'tapp'
require 'simplecov'
if ENV['CI'] == 'true' &&
# compare only for major/minor version of Ruby in order to enable report for Coverall
Gem::Version.new(RUBY_VERSION).segments[0..1] == \
Gem::Version.new(File.read(File.join(File... | ruby | MIT | ad72ffa4263c94de97b1749df8791d254e38017e | 2026-01-04T17:56:11.837143Z | false |
kibitan/masking | https://github.com/kibitan/masking/blob/ad72ffa4263c94de97b1749df8791d254e38017e/spec/masking/sql_dump_line_spec.rb | spec/masking/sql_dump_line_spec.rb | # frozen_string_literal: true
require 'spec_helper'
require 'masking/sql_dump_line'
RSpec.describe Masking::SQLDumpLine do
describe '#mask' do
subject { described_class.new(line, mask_processor: mask_processor).mask }
let(:mask_processor) { class_double(Masking::DataMaskProcessor) }
shared_examples '... | ruby | MIT | ad72ffa4263c94de97b1749df8791d254e38017e | 2026-01-04T17:56:11.837143Z | false |
kibitan/masking | https://github.com/kibitan/masking/blob/ad72ffa4263c94de97b1749df8791d254e38017e/spec/masking/version_spec.rb | spec/masking/version_spec.rb | # frozen_string_literal: true
require 'masking/version'
RSpec.describe Masking::VERSION do
it 'has a version number' do
expect(Masking::VERSION).not_to be_nil # rubocop:disable RSpec/DescribedClass
end
end
| ruby | MIT | ad72ffa4263c94de97b1749df8791d254e38017e | 2026-01-04T17:56:11.837143Z | false |
kibitan/masking | https://github.com/kibitan/masking/blob/ad72ffa4263c94de97b1749df8791d254e38017e/spec/masking/insert_statement_spec.rb | spec/masking/insert_statement_spec.rb | # frozen_string_literal: true
require 'spec_helper'
require 'masking/insert_statement'
RSpec.describe Masking::InsertStatement do
subject { described_class.new(raw_line, sql_builder: sql_builder) }
let(:raw_line) { insert_statement_fixture }
let(:sql_builder) do
class_double(
Masking::InsertStatement... | ruby | MIT | ad72ffa4263c94de97b1749df8791d254e38017e | 2026-01-04T17:56:11.837143Z | false |
kibitan/masking | https://github.com/kibitan/masking/blob/ad72ffa4263c94de97b1749df8791d254e38017e/spec/masking/data_mask_processor_spec.rb | spec/masking/data_mask_processor_spec.rb | # frozen_string_literal: true
require 'spec_helper'
require 'masking/data_mask_processor'
class DummyCache
def self.fetch_or_store_if_no_cache(table:, proc:) # rubocop:disable Lint/UnusedMethodArgument
proc.call
end
end
RSpec.describe Masking::DataMaskProcessor do
describe '#process' do
subject {
... | ruby | MIT | ad72ffa4263c94de97b1749df8791d254e38017e | 2026-01-04T17:56:11.837143Z | false |
kibitan/masking | https://github.com/kibitan/masking/blob/ad72ffa4263c94de97b1749df8791d254e38017e/spec/masking/cli_spec.rb | spec/masking/cli_spec.rb | # frozen_string_literal: true
require 'spec_helper'
RSpec.describe Masking::Cli do
describe '#run' do
subject { described_class.new(argv).run }
shared_examples 'set config and call Main.run' do
it 'set config and call Main.run' do
expect(Masking).to receive(:config).and_return(
inst... | ruby | MIT | ad72ffa4263c94de97b1749df8791d254e38017e | 2026-01-04T17:56:11.837143Z | false |
kibitan/masking | https://github.com/kibitan/masking/blob/ad72ffa4263c94de97b1749df8791d254e38017e/spec/masking/config_spec.rb | spec/masking/config_spec.rb | # frozen_string_literal: true
require 'spec_helper'
RSpec.describe Masking::Config do
describe 'Masking.config' do
subject { Masking.config }
it { is_expected.to be_instance_of described_class }
end
describe 'Masking.configure' do
subject do
Masking.configure do |config|
config.sampl... | ruby | MIT | ad72ffa4263c94de97b1749df8791d254e38017e | 2026-01-04T17:56:11.837143Z | false |
kibitan/masking | https://github.com/kibitan/masking/blob/ad72ffa4263c94de97b1749df8791d254e38017e/spec/masking/data_mask_processor/cache_spec.rb | spec/masking/data_mask_processor/cache_spec.rb | # frozen_string_literal: true
require 'spec_helper'
require 'masking/data_mask_processor'
RSpec.describe Masking::DataMaskProcessor::Cache do
describe '.fetch_or_store_if_no_cache' do
subject { described_class.fetch_or_store_if_no_cache(table: 'sample_table', proc: proc { 'sample_value' }) }
before { desc... | ruby | MIT | ad72ffa4263c94de97b1749df8791d254e38017e | 2026-01-04T17:56:11.837143Z | false |
kibitan/masking | https://github.com/kibitan/masking/blob/ad72ffa4263c94de97b1749df8791d254e38017e/spec/masking/insert_statement/sql_builder_spec.rb | spec/masking/insert_statement/sql_builder_spec.rb | # frozen_string_literal: true
require 'spec_helper'
require 'masking/insert_statement/sql_builder'
RSpec.describe Masking::InsertStatement::SQLBuilder do
describe '#sql' do
subject { described_class.new(table: table, columns: columns, values: values).sql }
let(:table) { 'users' }
let(:columns) { %i[id... | ruby | MIT | ad72ffa4263c94de97b1749df8791d254e38017e | 2026-01-04T17:56:11.837143Z | false |
kibitan/masking | https://github.com/kibitan/masking/blob/ad72ffa4263c94de97b1749df8791d254e38017e/spec/masking/config/target_columns_spec.rb | spec/masking/config/target_columns_spec.rb | # frozen_string_literal: true
require 'spec_helper'
require 'masking/config/target_columns'
RSpec.describe Masking::Config::TargetColumns do
describe '#initialize' do
subject { described_class.new(file_path) }
context 'file_path is valid' do
let(:file_path) { config_fixture_path }
it 'contain... | ruby | MIT | ad72ffa4263c94de97b1749df8791d254e38017e | 2026-01-04T17:56:11.837143Z | false |
kibitan/masking | https://github.com/kibitan/masking/blob/ad72ffa4263c94de97b1749df8791d254e38017e/spec/masking/config/target_columns/column_spec.rb | spec/masking/config/target_columns/column_spec.rb | # frozen_string_literal: true
require 'spec_helper'
require 'masking/config/target_columns/column'
require 'masking/config/target_columns/table'
RSpec.describe Masking::Config::TargetColumns::Column do
let(:name) { 'sample_column' }
let(:table_name) { 'sample_table' }
let(:method_value) { 'sample_met... | ruby | MIT | ad72ffa4263c94de97b1749df8791d254e38017e | 2026-01-04T17:56:11.837143Z | false |
kibitan/masking | https://github.com/kibitan/masking/blob/ad72ffa4263c94de97b1749df8791d254e38017e/spec/masking/config/target_columns/table_spec.rb | spec/masking/config/target_columns/table_spec.rb | # frozen_string_literal: true
require 'spec_helper'
require 'masking/config/target_columns/table'
RSpec.describe Masking::Config::TargetColumns::Table do
let(:name) { 'sample_table' }
let(:columns) do
{
column_a: 'string',
column_b: 123,
column_c: nil
}
end
describe '#name' do
... | ruby | MIT | ad72ffa4263c94de97b1749df8791d254e38017e | 2026-01-04T17:56:11.837143Z | false |
kibitan/masking | https://github.com/kibitan/masking/blob/ad72ffa4263c94de97b1749df8791d254e38017e/spec/masking/config/target_columns/method_spec.rb | spec/masking/config/target_columns/method_spec.rb | # frozen_string_literal: true
require 'spec_helper'
require 'masking/config/target_columns/method'
require 'masking/config/target_columns/method/type/extension/ignore_null'
RSpec.describe Masking::Config::TargetColumns::Method do
shared_examples_for 'with argument `ignore_null: true`' do
context 'with argument... | ruby | MIT | ad72ffa4263c94de97b1749df8791d254e38017e | 2026-01-04T17:56:11.837143Z | false |
kibitan/masking | https://github.com/kibitan/masking/blob/ad72ffa4263c94de97b1749df8791d254e38017e/spec/masking/config/target_columns/method/string_binary_distinctor_spec.rb | spec/masking/config/target_columns/method/string_binary_distinctor_spec.rb | # frozen_string_literal: true
require 'spec_helper'
require 'masking/config/target_columns/method/string_binary_distinctor'
RSpec.describe Masking::Config::TargetColumns::Method::StringBinaryDistinctor do
describe '.new' do
subject { described_class.new(arg) }
context 'with argument is string' do
le... | ruby | MIT | ad72ffa4263c94de97b1749df8791d254e38017e | 2026-01-04T17:56:11.837143Z | false |
kibitan/masking | https://github.com/kibitan/masking/blob/ad72ffa4263c94de97b1749df8791d254e38017e/spec/masking/config/target_columns/method/type/null_spec.rb | spec/masking/config/target_columns/method/type/null_spec.rb | # frozen_string_literal: true
require 'spec_helper'
require 'masking/config/target_columns/method/type/null'
RSpec.describe Masking::Config::TargetColumns::Method::Type::Null do
describe '#call' do
subject { described_class.new(value).call('sql_value') }
let(:value) { nil }
it { is_expected.to eq 'NU... | ruby | MIT | ad72ffa4263c94de97b1749df8791d254e38017e | 2026-01-04T17:56:11.837143Z | false |
kibitan/masking | https://github.com/kibitan/masking/blob/ad72ffa4263c94de97b1749df8791d254e38017e/spec/masking/config/target_columns/method/type/string_spec.rb | spec/masking/config/target_columns/method/type/string_spec.rb | # frozen_string_literal: true
require 'spec_helper'
require 'masking/config/target_columns/method/type/string'
RSpec.describe Masking::Config::TargetColumns::Method::Type::String do
describe '#call' do
subject { described_class.new(value).call('sql_value') }
context 'with "hoge"' do
let(:value) { 'h... | ruby | MIT | ad72ffa4263c94de97b1749df8791d254e38017e | 2026-01-04T17:56:11.837143Z | false |
kibitan/masking | https://github.com/kibitan/masking/blob/ad72ffa4263c94de97b1749df8791d254e38017e/spec/masking/config/target_columns/method/type/binary_spec.rb | spec/masking/config/target_columns/method/type/binary_spec.rb | # frozen_string_literal: true
require 'spec_helper'
require 'masking/config/target_columns/method/type/binary'
RSpec.describe Masking::Config::TargetColumns::Method::Type::Binary do
describe '#call' do
context 'with binary string (only ascii)' do
let(:value) { 'only ascii binary' }
it { expect(des... | ruby | MIT | ad72ffa4263c94de97b1749df8791d254e38017e | 2026-01-04T17:56:11.837143Z | false |
kibitan/masking | https://github.com/kibitan/masking/blob/ad72ffa4263c94de97b1749df8791d254e38017e/spec/masking/config/target_columns/method/type/base_spec.rb | spec/masking/config/target_columns/method/type/base_spec.rb | # frozen_string_literal: true
require 'spec_helper'
require 'masking/config/target_columns/method/type/base'
RSpec.describe Masking::Config::TargetColumns::Method::Type::Base do
describe '#value' do
context 'when initialized with abc' do
let(:type) { described_class.new('abc') }
it 'returns abc' do... | ruby | MIT | ad72ffa4263c94de97b1749df8791d254e38017e | 2026-01-04T17:56:11.837143Z | false |
kibitan/masking | https://github.com/kibitan/masking/blob/ad72ffa4263c94de97b1749df8791d254e38017e/spec/masking/config/target_columns/method/type/time_spec.rb | spec/masking/config/target_columns/method/type/time_spec.rb | # frozen_string_literal: true
require 'spec_helper'
require 'masking/config/target_columns/method/type/time'
RSpec.describe Masking::Config::TargetColumns::Method::Type::Time do
describe '#call' do
subject { described_class.new(value).call('sql_value') }
context 'when 2018-03-20 18:15:30' do
let(:va... | ruby | MIT | ad72ffa4263c94de97b1749df8791d254e38017e | 2026-01-04T17:56:11.837143Z | false |
kibitan/masking | https://github.com/kibitan/masking/blob/ad72ffa4263c94de97b1749df8791d254e38017e/spec/masking/config/target_columns/method/type/float_spec.rb | spec/masking/config/target_columns/method/type/float_spec.rb | # frozen_string_literal: true
require 'spec_helper'
require 'masking/config/target_columns/method/type/float'
RSpec.describe Masking::Config::TargetColumns::Method::Type::Float do
describe '#call' do
subject { described_class.new(value).call('sql_value') }
context 'when 1.2345' do
let(:value) { 1.23... | ruby | MIT | ad72ffa4263c94de97b1749df8791d254e38017e | 2026-01-04T17:56:11.837143Z | false |
kibitan/masking | https://github.com/kibitan/masking/blob/ad72ffa4263c94de97b1749df8791d254e38017e/spec/masking/config/target_columns/method/type/boolean_spec.rb | spec/masking/config/target_columns/method/type/boolean_spec.rb | # frozen_string_literal: true
require 'spec_helper'
require 'masking/config/target_columns/method/type/integer'
RSpec.describe Masking::Config::TargetColumns::Method::Type::Boolean do
describe '#call' do
subject { described_class.new(value).call('sql_value') }
context 'when false' do
let(:value) { f... | ruby | MIT | ad72ffa4263c94de97b1749df8791d254e38017e | 2026-01-04T17:56:11.837143Z | false |
kibitan/masking | https://github.com/kibitan/masking/blob/ad72ffa4263c94de97b1749df8791d254e38017e/spec/masking/config/target_columns/method/type/date_spec.rb | spec/masking/config/target_columns/method/type/date_spec.rb | # frozen_string_literal: true
require 'spec_helper'
require 'masking/config/target_columns/method/type/date'
RSpec.describe Masking::Config::TargetColumns::Method::Type::Date do
describe '#call' do
subject { described_class.new(value).call('sql_value') }
context 'when 2018-07-20' do
let(:value) { Da... | ruby | MIT | ad72ffa4263c94de97b1749df8791d254e38017e | 2026-01-04T17:56:11.837143Z | false |
kibitan/masking | https://github.com/kibitan/masking/blob/ad72ffa4263c94de97b1749df8791d254e38017e/spec/masking/config/target_columns/method/type/integer_spec.rb | spec/masking/config/target_columns/method/type/integer_spec.rb | # frozen_string_literal: true
require 'spec_helper'
require 'masking/config/target_columns/method/type/integer'
RSpec.describe Masking::Config::TargetColumns::Method::Type::Integer do
describe '#call' do
subject { described_class.new(value).call('sql_value') }
context 'when 12345' do
let(:value) { 1... | ruby | MIT | ad72ffa4263c94de97b1749df8791d254e38017e | 2026-01-04T17:56:11.837143Z | false |
kibitan/masking | https://github.com/kibitan/masking/blob/ad72ffa4263c94de97b1749df8791d254e38017e/spec/masking/config/target_columns/method/type/extension/ignore_null_spec.rb | spec/masking/config/target_columns/method/type/extension/ignore_null_spec.rb | # frozen_string_literal: true
require 'spec_helper'
require 'masking/config/target_columns/method/type/base'
require 'masking/config/target_columns/method/type/extension/ignore_null'
RSpec.describe Masking::Config::TargetColumns::Method::Type::Extension::IgnoreNull do
let(:base_type_class) do
Class.new(Masking... | ruby | MIT | ad72ffa4263c94de97b1749df8791d254e38017e | 2026-01-04T17:56:11.837143Z | false |
kibitan/masking | https://github.com/kibitan/masking/blob/ad72ffa4263c94de97b1749df8791d254e38017e/spec/masking/cli/error_message_spec.rb | spec/masking/cli/error_message_spec.rb | # frozen_string_literal: true
require 'spec_helper'
require 'masking/cli/error_message'
RSpec.describe Masking::Cli::ErrorMessage do
describe '#message' do
subject { described_class.new(error).message(**keyword_args) }
describe 'Masking::Error::ConfigFileDoesNotExist' do
let(:error) { Masking::Error... | ruby | MIT | ad72ffa4263c94de97b1749df8791d254e38017e | 2026-01-04T17:56:11.837143Z | false |
kibitan/masking | https://github.com/kibitan/masking/blob/ad72ffa4263c94de97b1749df8791d254e38017e/spec/integration/integration_spec_helper.rb | spec/integration/integration_spec_helper.rb | # frozen_string_literal: true
require 'spec_helper'
require 'open3'
def command_subject(command, stdin: '')
subject { Open3.capture3(command, stdin_data: stdin) }
let(:stdout) { subject[0] }
let(:stderr) { subject[1] }
let(:exitstatus) { subject[2].exitstatus }
end
| ruby | MIT | ad72ffa4263c94de97b1749df8791d254e38017e | 2026-01-04T17:56:11.837143Z | false |
kibitan/masking | https://github.com/kibitan/masking/blob/ad72ffa4263c94de97b1749df8791d254e38017e/spec/integration/commandline_spec.rb | spec/integration/commandline_spec.rb | # frozen_string_literal: true
require_relative 'integration_spec_helper'
RSpec.describe 'execute in command line' do
context 'with version option' do
command_subject('masking -v')
it 'puts version', :aggregate_failures do
expect(stdout).to eq("#{Masking::VERSION}\n")
expect(stderr).to be_empty
... | ruby | MIT | ad72ffa4263c94de97b1749df8791d254e38017e | 2026-01-04T17:56:11.837143Z | false |
kibitan/masking | https://github.com/kibitan/masking/blob/ad72ffa4263c94de97b1749df8791d254e38017e/lib/masking.rb | lib/masking.rb | # frozen_string_literal: true
require 'masking/cli'
require 'masking/config'
require 'masking/sql_dump_line'
module Masking
class << self
def run
Main.new.run
end
end
class Main
def initialize(input: $stdin, output: $stdout, line_processor: SQLDumpLine)
@input = input.set_encoding(Enco... | ruby | MIT | ad72ffa4263c94de97b1749df8791d254e38017e | 2026-01-04T17:56:11.837143Z | false |
kibitan/masking | https://github.com/kibitan/masking/blob/ad72ffa4263c94de97b1749df8791d254e38017e/lib/masking/version.rb | lib/masking/version.rb | # frozen_string_literal: true
module Masking
VERSION = '1.1.3-alpha'
end
| ruby | MIT | ad72ffa4263c94de97b1749df8791d254e38017e | 2026-01-04T17:56:11.837143Z | false |
kibitan/masking | https://github.com/kibitan/masking/blob/ad72ffa4263c94de97b1749df8791d254e38017e/lib/masking/data_mask_processor.rb | lib/masking/data_mask_processor.rb | # frozen_string_literal: true
require 'masking/data_mask_processor/cache'
require 'masking/config/target_columns'
require 'masking/insert_statement'
module Masking
class DataMaskProcessor
def initialize(
insert_statement_line,
target_columns: ::Masking.config.target_columns,
insert_statement: ... | ruby | MIT | ad72ffa4263c94de97b1749df8791d254e38017e | 2026-01-04T17:56:11.837143Z | false |
kibitan/masking | https://github.com/kibitan/masking/blob/ad72ffa4263c94de97b1749df8791d254e38017e/lib/masking/insert_statement.rb | lib/masking/insert_statement.rb | # frozen_string_literal: true
require 'masking/errors'
require 'masking/insert_statement/sql_builder'
module Masking
class InsertStatement
attr_reader :raw_statement, :table
def initialize(raw_statement, sql_builder: SQLBuilder)
@raw_statement = raw_statement
@sql_builder = sql_builder
P... | ruby | MIT | ad72ffa4263c94de97b1749df8791d254e38017e | 2026-01-04T17:56:11.837143Z | false |
kibitan/masking | https://github.com/kibitan/masking/blob/ad72ffa4263c94de97b1749df8791d254e38017e/lib/masking/errors.rb | lib/masking/errors.rb | # frozen_string_literal: true
# Global Errors in Masking library
module Masking
class Error < StandardError
class ConfigFileDoesNotExist < Error; end
class ConfigFileIsNotFile < Error; end
class ConfigFileIsNotValidYaml < Error; end
class ConfigFileContainsNullAsColumnName < Error; end
class Inse... | ruby | MIT | ad72ffa4263c94de97b1749df8791d254e38017e | 2026-01-04T17:56:11.837143Z | false |
kibitan/masking | https://github.com/kibitan/masking/blob/ad72ffa4263c94de97b1749df8791d254e38017e/lib/masking/sql_dump_line.rb | lib/masking/sql_dump_line.rb | # frozen_string_literal: true
require 'masking/data_mask_processor'
module Masking
class SQLDumpLine
def initialize(line, mask_processor: DataMaskProcessor)
@line = line
@mask_processor = mask_processor
end
def mask
processor.new(line).process
end
def insert_statement?
... | ruby | MIT | ad72ffa4263c94de97b1749df8791d254e38017e | 2026-01-04T17:56:11.837143Z | false |
kibitan/masking | https://github.com/kibitan/masking/blob/ad72ffa4263c94de97b1749df8791d254e38017e/lib/masking/cli.rb | lib/masking/cli.rb | # frozen_string_literal: true
require 'masking/config'
require 'masking/version'
require 'masking/errors'
require 'masking/cli/error_message'
require 'optparse'
module Masking
class Cli
def initialize(argv)
@argv = argv
end
def run
option_parser.parse(argv)
Masking.run
rescue Mask... | ruby | MIT | ad72ffa4263c94de97b1749df8791d254e38017e | 2026-01-04T17:56:11.837143Z | false |
kibitan/masking | https://github.com/kibitan/masking/blob/ad72ffa4263c94de97b1749df8791d254e38017e/lib/masking/config.rb | lib/masking/config.rb | # frozen_string_literal: true
require 'pathname'
require 'masking/config/target_columns'
module Masking
class << self
def config
@config ||= Config.new
end
def configure
yield config
end
end
class Config
DEFAULT_TARGET_COLUMNS_YAML_PATH = Pathname('masking.yml')
attr_reader... | ruby | MIT | ad72ffa4263c94de97b1749df8791d254e38017e | 2026-01-04T17:56:11.837143Z | false |
kibitan/masking | https://github.com/kibitan/masking/blob/ad72ffa4263c94de97b1749df8791d254e38017e/lib/masking/data_mask_processor/cache.rb | lib/masking/data_mask_processor/cache.rb | # frozen_string_literal: true
module Masking
class DataMaskProcessor
class Cache
def self.fetch_or_store_if_no_cache(table:, proc:)
@cache ||= {}
if @cache.key?(table)
@cache[table]
else
@cache[table] = proc.call
end
end
# onlu for test
... | ruby | MIT | ad72ffa4263c94de97b1749df8791d254e38017e | 2026-01-04T17:56:11.837143Z | false |
kibitan/masking | https://github.com/kibitan/masking/blob/ad72ffa4263c94de97b1749df8791d254e38017e/lib/masking/insert_statement/sql_builder.rb | lib/masking/insert_statement/sql_builder.rb | # frozen_string_literal: true
module Masking
class InsertStatement
class SQLBuilder
def initialize(table:, columns:, values:)
@table = table
@columns = columns
@values = values
end
def sql
%(INSERT INTO `#{table}` #{columns_section} VALUES #{values_section};\... | ruby | MIT | ad72ffa4263c94de97b1749df8791d254e38017e | 2026-01-04T17:56:11.837143Z | false |
kibitan/masking | https://github.com/kibitan/masking/blob/ad72ffa4263c94de97b1749df8791d254e38017e/lib/masking/config/target_columns.rb | lib/masking/config/target_columns.rb | # frozen_string_literal: true
require 'yaml'
require 'masking/config/target_columns/table'
require 'masking/config/target_columns/column'
require 'masking/errors'
module Masking
class Config
# TODO: find better naming of TargetColumns
class TargetColumns
attr_reader :file_path
def initialize(fi... | ruby | MIT | ad72ffa4263c94de97b1749df8791d254e38017e | 2026-01-04T17:56:11.837143Z | false |
kibitan/masking | https://github.com/kibitan/masking/blob/ad72ffa4263c94de97b1749df8791d254e38017e/lib/masking/config/target_columns/table.rb | lib/masking/config/target_columns/table.rb | # frozen_string_literal: true
require 'masking/config/target_columns/column'
module Masking
class Config
class TargetColumns
class Table
attr_reader :name, :columns
def initialize(name, columns:)
@name = name.to_sym
@columns = columns.map do |column, method_value|
... | ruby | MIT | ad72ffa4263c94de97b1749df8791d254e38017e | 2026-01-04T17:56:11.837143Z | false |
kibitan/masking | https://github.com/kibitan/masking/blob/ad72ffa4263c94de97b1749df8791d254e38017e/lib/masking/config/target_columns/method.rb | lib/masking/config/target_columns/method.rb | # frozen_string_literal: true
require 'pathname'
require 'forwardable'
require 'masking/config/target_columns/method/type/extension/ignore_null'
require 'masking/config/target_columns/method/string_binary_distinctor'
Dir[Pathname(__FILE__).dirname.join('method/type/*.rb').to_s].sort.each(&method(:require))
module Mas... | ruby | MIT | ad72ffa4263c94de97b1749df8791d254e38017e | 2026-01-04T17:56:11.837143Z | false |
kibitan/masking | https://github.com/kibitan/masking/blob/ad72ffa4263c94de97b1749df8791d254e38017e/lib/masking/config/target_columns/column.rb | lib/masking/config/target_columns/column.rb | # frozen_string_literal: true
require 'masking/config/target_columns/method'
module Masking
class Config
class TargetColumns
class Column
attr_reader :table_name, :method_value, :method
def initialize(name, table_name:, method_value:)
raise ColumnNameIsNil if name.nil?
... | ruby | MIT | ad72ffa4263c94de97b1749df8791d254e38017e | 2026-01-04T17:56:11.837143Z | false |
kibitan/masking | https://github.com/kibitan/masking/blob/ad72ffa4263c94de97b1749df8791d254e38017e/lib/masking/config/target_columns/method/string_binary_distinctor.rb | lib/masking/config/target_columns/method/string_binary_distinctor.rb | # frozen_string_literal: true
require 'masking/config/target_columns/method/type/binary'
require 'masking/config/target_columns/method/type/string'
module Masking
class Config
class TargetColumns
class Method
module StringBinaryDistinctor
class << self
def new(value)
... | ruby | MIT | ad72ffa4263c94de97b1749df8791d254e38017e | 2026-01-04T17:56:11.837143Z | false |
kibitan/masking | https://github.com/kibitan/masking/blob/ad72ffa4263c94de97b1749df8791d254e38017e/lib/masking/config/target_columns/method/type/binary.rb | lib/masking/config/target_columns/method/type/binary.rb | # frozen_string_literal: true
require 'masking/config/target_columns/method/type/base'
module Masking
class Config
class TargetColumns
class Method
module Type
class Binary < Base
def call(_sql_value)
"_binary '#{value}'".b
end
end
... | ruby | MIT | ad72ffa4263c94de97b1749df8791d254e38017e | 2026-01-04T17:56:11.837143Z | false |
kibitan/masking | https://github.com/kibitan/masking/blob/ad72ffa4263c94de97b1749df8791d254e38017e/lib/masking/config/target_columns/method/type/time.rb | lib/masking/config/target_columns/method/type/time.rb | # frozen_string_literal: true
require 'masking/config/target_columns/method/type/base'
module Masking
class Config
class TargetColumns
class Method
module Type
class Time < Base
def call(_sql_value)
"'#{time_format}'"
end
private
... | ruby | MIT | ad72ffa4263c94de97b1749df8791d254e38017e | 2026-01-04T17:56:11.837143Z | false |
kibitan/masking | https://github.com/kibitan/masking/blob/ad72ffa4263c94de97b1749df8791d254e38017e/lib/masking/config/target_columns/method/type/float.rb | lib/masking/config/target_columns/method/type/float.rb | # frozen_string_literal: true
require 'masking/config/target_columns/method/type/base'
module Masking
class Config
class TargetColumns
class Method
module Type
class Float < Base
def call(_sql_value)
value.to_s
end
end
end
end... | ruby | MIT | ad72ffa4263c94de97b1749df8791d254e38017e | 2026-01-04T17:56:11.837143Z | false |
kibitan/masking | https://github.com/kibitan/masking/blob/ad72ffa4263c94de97b1749df8791d254e38017e/lib/masking/config/target_columns/method/type/boolean.rb | lib/masking/config/target_columns/method/type/boolean.rb | # frozen_string_literal: true
require 'masking/config/target_columns/method/type/base'
module Masking
class Config
class TargetColumns
class Method
module Type
class Boolean < Base
def call(_sql_value)
boolean_format.to_s
end
private
... | ruby | MIT | ad72ffa4263c94de97b1749df8791d254e38017e | 2026-01-04T17:56:11.837143Z | false |
kibitan/masking | https://github.com/kibitan/masking/blob/ad72ffa4263c94de97b1749df8791d254e38017e/lib/masking/config/target_columns/method/type/base.rb | lib/masking/config/target_columns/method/type/base.rb | # frozen_string_literal: true
module Masking
class Config
class TargetColumns
class Method
module Type
class Base
def initialize(value)
@value = value
end
def call(_sql_value)
raise NotImplementedError
end
... | ruby | MIT | ad72ffa4263c94de97b1749df8791d254e38017e | 2026-01-04T17:56:11.837143Z | false |
kibitan/masking | https://github.com/kibitan/masking/blob/ad72ffa4263c94de97b1749df8791d254e38017e/lib/masking/config/target_columns/method/type/null.rb | lib/masking/config/target_columns/method/type/null.rb | # frozen_string_literal: true
module Masking
class Config
class TargetColumns
class Method
module Type
class Null < Base
def call(_sql_value)
'NULL'
end
end
end
end
end
end
end
| ruby | MIT | ad72ffa4263c94de97b1749df8791d254e38017e | 2026-01-04T17:56:11.837143Z | false |
kibitan/masking | https://github.com/kibitan/masking/blob/ad72ffa4263c94de97b1749df8791d254e38017e/lib/masking/config/target_columns/method/type/string.rb | lib/masking/config/target_columns/method/type/string.rb | # frozen_string_literal: true
require 'masking/config/target_columns/method/type/base'
module Masking
class Config
class TargetColumns
class Method
module Type
class String < Base
def initialize(value)
super(value)
@sequence = 0
end
... | ruby | MIT | ad72ffa4263c94de97b1749df8791d254e38017e | 2026-01-04T17:56:11.837143Z | false |
kibitan/masking | https://github.com/kibitan/masking/blob/ad72ffa4263c94de97b1749df8791d254e38017e/lib/masking/config/target_columns/method/type/integer.rb | lib/masking/config/target_columns/method/type/integer.rb | # frozen_string_literal: true
require 'masking/config/target_columns/method/type/base'
module Masking
class Config
class TargetColumns
class Method
module Type
class Integer < Base
def call(_sql_value)
value.to_s
end
end
end
e... | ruby | MIT | ad72ffa4263c94de97b1749df8791d254e38017e | 2026-01-04T17:56:11.837143Z | false |
kibitan/masking | https://github.com/kibitan/masking/blob/ad72ffa4263c94de97b1749df8791d254e38017e/lib/masking/config/target_columns/method/type/date.rb | lib/masking/config/target_columns/method/type/date.rb | # frozen_string_literal: true
require 'masking/config/target_columns/method/type/base'
require 'date'
module Masking
class Config
class TargetColumns
class Method
module Type
class Date < Base
def call(_sql_value)
"'#{date_format}'"
end
... | ruby | MIT | ad72ffa4263c94de97b1749df8791d254e38017e | 2026-01-04T17:56:11.837143Z | false |
kibitan/masking | https://github.com/kibitan/masking/blob/ad72ffa4263c94de97b1749df8791d254e38017e/lib/masking/config/target_columns/method/type/extension/ignore_null.rb | lib/masking/config/target_columns/method/type/extension/ignore_null.rb | # frozen_string_literal: true
module Masking
class Config
class TargetColumns
class Method
module Type
module Extension
module IgnoreNull
def call(sql_value)
if sql_value == 'NULL'
sequence! if respond_to?(:sequence!, true)
... | ruby | MIT | ad72ffa4263c94de97b1749df8791d254e38017e | 2026-01-04T17:56:11.837143Z | false |
kibitan/masking | https://github.com/kibitan/masking/blob/ad72ffa4263c94de97b1749df8791d254e38017e/lib/masking/cli/error_message.rb | lib/masking/cli/error_message.rb | # frozen_string_literal: true
require 'erb'
require 'ostruct'
require 'masking/errors'
module Masking
class Cli
class ErrorMessage
def initialize(error_class)
@error_class = error_class
end
def message(**keyword_args)
error_message(keyword_args)
end
private
... | ruby | MIT | ad72ffa4263c94de97b1749df8791d254e38017e | 2026-01-04T17:56:11.837143Z | false |
flyerhzm/eager_group | https://github.com/flyerhzm/eager_group/blob/7dc79e5705b24e6193e869ab8624c188399b438e/benchmark.rb | benchmark.rb | # frozen_string_literal: true
# Calculating -------------------------------------
# Without EagerGroup 2.000 i/100ms
# With EagerGroup 28.000 i/100ms
# -------------------------------------------------
# Without EagerGroup 28.883 (± 6.9%) i/s - 144.000
# With EagerGroup 281.755 (± 5.... | ruby | MIT | 7dc79e5705b24e6193e869ab8624c188399b438e | 2026-01-04T17:56:14.651123Z | false |
flyerhzm/eager_group | https://github.com/flyerhzm/eager_group/blob/7dc79e5705b24e6193e869ab8624c188399b438e/spec/spec_helper.rb | spec/spec_helper.rb | # frozen_string_literal: true
# This file was generated by the `rspec --init` command. Conventionally, all
# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
# The generated `.rspec` file contains `--require spec_helper` which will cause
# this file to always be loaded, without a need to expl... | ruby | MIT | 7dc79e5705b24e6193e869ab8624c188399b438e | 2026-01-04T17:56:14.651123Z | false |
flyerhzm/eager_group | https://github.com/flyerhzm/eager_group/blob/7dc79e5705b24e6193e869ab8624c188399b438e/spec/support/data.rb | spec/support/data.rb | # frozen_string_literal: true
teacher1 = Teacher.create name: 'Teacher 1'
teacher2 = Teacher.create name: 'Teacher 2'
teacher3 = Teacher.create name: 'Teacher 3'
student1 = Student.create name: 'Student 1'
student2 = Student.create name: 'Student 2'
student3 = Student.create name: 'Student 3'
student4 = Student.create... | ruby | MIT | 7dc79e5705b24e6193e869ab8624c188399b438e | 2026-01-04T17:56:14.651123Z | false |
flyerhzm/eager_group | https://github.com/flyerhzm/eager_group/blob/7dc79e5705b24e6193e869ab8624c188399b438e/spec/support/models.rb | spec/support/models.rb | # frozen_string_literal: true
class User < ActiveRecord::Base
has_many :posts
has_many :comments, through: :posts
define_eager_group :comments_count, :comments, :count, :*
end
class Post < ActiveRecord::Base
belongs_to :user
has_many :comments
define_eager_group :comments_average_rating, :comments, :ave... | ruby | MIT | 7dc79e5705b24e6193e869ab8624c188399b438e | 2026-01-04T17:56:14.651123Z | false |
flyerhzm/eager_group | https://github.com/flyerhzm/eager_group/blob/7dc79e5705b24e6193e869ab8624c188399b438e/spec/support/schema.rb | spec/support/schema.rb | # frozen_string_literal: true
ActiveRecord::Base.establish_connection(adapter: 'sqlite3', database: ':memory:')
ActiveRecord::Schema.define do
self.verbose = false
create_table :users, force: true do |t|
t.string :name
t.timestamps null: false
end
create_table :posts, force: true do |t|
t.string... | ruby | MIT | 7dc79e5705b24e6193e869ab8624c188399b438e | 2026-01-04T17:56:14.651123Z | false |
flyerhzm/eager_group | https://github.com/flyerhzm/eager_group/blob/7dc79e5705b24e6193e869ab8624c188399b438e/spec/integration/eager_group_spec.rb | spec/integration/eager_group_spec.rb | # frozen_string_literal: true
require 'spec_helper'
RSpec.describe EagerGroup, type: :model do
describe '.eager_group' do
context 'has_many' do
it 'gets Post#approved_comments_count' do
posts = Post.eager_group(:approved_comments_count)
expect(posts[0].approved_comments_count).to eq 1
... | ruby | MIT | 7dc79e5705b24e6193e869ab8624c188399b438e | 2026-01-04T17:56:14.651123Z | false |
flyerhzm/eager_group | https://github.com/flyerhzm/eager_group/blob/7dc79e5705b24e6193e869ab8624c188399b438e/lib/eager_group.rb | lib/eager_group.rb | # frozen_string_literal: true
require 'active_support/core_ext/module/attribute_accessors'
require 'active_support/core_ext/class/attribute'
require 'active_support/core_ext/hash'
require 'eager_group/version'
module EagerGroup
autoload :Preloader, 'eager_group/preloader'
autoload :Definition, 'eager_group/defini... | ruby | MIT | 7dc79e5705b24e6193e869ab8624c188399b438e | 2026-01-04T17:56:14.651123Z | false |
flyerhzm/eager_group | https://github.com/flyerhzm/eager_group/blob/7dc79e5705b24e6193e869ab8624c188399b438e/lib/active_record/with_eager_group.rb | lib/active_record/with_eager_group.rb | # frozen_string_literal: true
module ActiveRecord
module WithEagerGroup
def exec_queries
records = super
EagerGroup::Preloader.new(klass, records, eager_group_values).run if eager_group_values.present?
records
end
def eager_group(*args)
# we does not use the `check_if_method_has_... | ruby | MIT | 7dc79e5705b24e6193e869ab8624c188399b438e | 2026-01-04T17:56:14.651123Z | false |
flyerhzm/eager_group | https://github.com/flyerhzm/eager_group/blob/7dc79e5705b24e6193e869ab8624c188399b438e/lib/eager_group/preloader.rb | lib/eager_group/preloader.rb | # frozen_string_literal: true
module EagerGroup
class Preloader
autoload :AggregationFinder, 'eager_group/preloader/aggregation_finder'
autoload :HasMany, 'eager_group/preloader/has_many'
autoload :HasManyThroughBelongsTo, 'eager_group/preloader/has_many_through_belongs_to'
autoload :HasManyThroughMa... | ruby | MIT | 7dc79e5705b24e6193e869ab8624c188399b438e | 2026-01-04T17:56:14.651123Z | false |
flyerhzm/eager_group | https://github.com/flyerhzm/eager_group/blob/7dc79e5705b24e6193e869ab8624c188399b438e/lib/eager_group/version.rb | lib/eager_group/version.rb | # frozen_string_literal: true
module EagerGroup
VERSION = '0.10.0'
end
| ruby | MIT | 7dc79e5705b24e6193e869ab8624c188399b438e | 2026-01-04T17:56:14.651123Z | false |
flyerhzm/eager_group | https://github.com/flyerhzm/eager_group/blob/7dc79e5705b24e6193e869ab8624c188399b438e/lib/eager_group/definition.rb | lib/eager_group/definition.rb | # frozen_string_literal: true
module EagerGroup
class Definition
attr_reader :association, :column_name, :scope
def initialize(association, aggregate_function, column_name, scope)
@association = association
@aggregate_function = aggregate_function
@column_name = column_name
@scope = ... | ruby | MIT | 7dc79e5705b24e6193e869ab8624c188399b438e | 2026-01-04T17:56:14.651123Z | false |
flyerhzm/eager_group | https://github.com/flyerhzm/eager_group/blob/7dc79e5705b24e6193e869ab8624c188399b438e/lib/eager_group/preloader/has_many_through_belongs_to.rb | lib/eager_group/preloader/has_many_through_belongs_to.rb | # frozen_string_literal: true
module EagerGroup
class Preloader
class HasManyThroughBelongsTo < AggregationFinder
def group_by_foreign_key
"#{reflection.table_name}.#{reflection.through_reflection.klass.reflect_on_association(reflection.name).foreign_key}"
end
def aggregate_hash
... | ruby | MIT | 7dc79e5705b24e6193e869ab8624c188399b438e | 2026-01-04T17:56:14.651123Z | false |
flyerhzm/eager_group | https://github.com/flyerhzm/eager_group/blob/7dc79e5705b24e6193e869ab8624c188399b438e/lib/eager_group/preloader/aggregation_finder.rb | lib/eager_group/preloader/aggregation_finder.rb | # frozen_string_literal: true
module EagerGroup
class Preloader
class AggregationFinder
attr_reader :klass, :reflection, :definition, :arguments, :record_ids
def initialize(klass, definition, arguments, records)
@klass = klass
@definition = definition
@reflection = @klass.ref... | ruby | MIT | 7dc79e5705b24e6193e869ab8624c188399b438e | 2026-01-04T17:56:14.651123Z | false |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.