source
stringclasses
1 value
repo
stringlengths
5
63
repo_url
stringlengths
24
82
path
stringlengths
5
167
language
stringclasses
1 value
license
stringclasses
5 values
stars
int64
10
51.4k
ref
stringclasses
23 values
size_bytes
int64
200
258k
text
stringlengths
137
258k
github
oleganza/strokedb-core
https://github.com/oleganza/strokedb-core
lib/strokedb/util/verify.rb
Ruby
mit
19
master
1,084
module StrokeDB module Util def verify(*args, &blk) if block_given? # test for exception begin r = yield(*args) rescue Exception => e raise VerifyFailed.new(e), "Verification failed!" else r or raise VerifyFailed.new(nil), "Verification failed!" ...
github
oleganza/strokedb-core
https://github.com/oleganza/strokedb-core
lib/strokedb/util/lazy_mapping_array.rb
Ruby
mit
19
master
2,885
module StrokeDB # Lazy loads items from array applying procs on each read and write. # # Example: # # @ary[i] = 10 # # applies "unmap proc" to new item value. # # @ary.at(i) # # applies "map proc" to value just have been read. # # StrokeDB uses this class to "follow" links to other documents ...
github
oleganza/strokedb-core
https://github.com/oleganza/strokedb-core
lib/strokedb/util/require_one_of.rb
Ruby
mit
19
master
432
module StrokeDB module Util def self.require_one_of(*args) if args.first.class == Array args = args.first original_args = args[1] end original_args ||= args begin require args.shift rescue LoadError raise LoadError, "You need one of these gems: #{orig...
github
oleganza/strokedb-core
https://github.com/oleganza/strokedb-core
lib/strokedb/util/class_factory.rb
Ruby
mit
19
master
573
module StrokeDB module Util class ClassFactory attr_accessor :composite_module, :modules def initialize(*modules) @modules = modules @composite_module = if modules.size == 1 modules.first else Module.new do modules.each do |m| ...
github
oleganza/strokedb-core
https://github.com/oleganza/strokedb-core
lib/strokedb/util/lazy_mapping_hash.rb
Ruby
mit
19
master
990
module StrokeDB class LazyMappingHash < Hash def initialize(original = {}, decoder = nil, encoder = nil) @decoder = decoder || proc {|v| v} @encoder = encoder || proc {|v| v} super(default) original.each {|k,v| self[k] = v } end def map_with(&block) @encoder = block s...
github
oleganza/strokedb-core
https://github.com/oleganza/strokedb-core
lib/strokedb/stroke_objects/instance_methods.rb
Ruby
mit
19
master
1,575
module StrokeDB module StrokeObjects # This module is mixed in Database mixin, thus it is mixed into every model class. module InstanceMethods Cuuid = "uuid" Cversion = "version" attr_accessor :strokedb_database attr_accessor :strokedb_slots # Initialized with a set...
github
oleganza/strokedb-core
https://github.com/oleganza/strokedb-core
lib/strokedb/stroke_objects/slot_hooks.rb
Ruby
mit
19
master
2,254
module StrokeDB module StrokeObjects module SlotHooks include Declarations # Sets inheritable get/set hooks on a slot. # # Example: # # class Person < Hash # extend SlotHooks # # slot_hook :name do # def get(doc, slotname) # puts "Acc...
github
oleganza/strokedb-core
https://github.com/oleganza/strokedb-core
lib/strokedb/stroke_objects/class_methods.rb
Ruby
mit
19
master
1,332
module StrokeDB module StrokeObjects # Database mixes this module into the class it is included to. # # MyModel.new(attributes = {}) #=> initializes new document # doc.save # saves the document # doc.reference = another_doc # stores the reference # module ClassMetho...
github
oleganza/strokedb-core
https://github.com/oleganza/strokedb-core
lib/strokedb/stroke_objects/database.rb
Ruby
mit
19
master
3,033
module StrokeDB module StrokeObjects # Instance of this class is a module containing connection to a database. # Include this module into the classes of interest, which represent different kinds of objects. # Database.new(:path => 'pth-to-database', :nsurl => "http://myhost.com/") # Initialization op...
github
oleganza/strokedb-core
https://github.com/oleganza/strokedb-core
lib/strokedb/stroke_objects/lazy_accessors.rb
Ruby
mit
19
master
1,003
module StrokeDB module StrokeObjects # Included in a StrokeDB object. # Relies on #has_slot? method. module LazyAccessors # This method catches slot access calls (obj.slot, obj.slot=). # Slot accessors are created on the fly. Ceq = "=" R_0_minus2 = (0..-2) def method_missing...
github
oleganza/strokedb-core
https://github.com/oleganza/strokedb-core
spec/spec_helper.rb
Ruby
mit
19
master
1,233
$LOAD_PATH.unshift( File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib')) ).uniq! require 'strokedb' include StrokeDB SPEC_ROOT = File.expand_path(File.dirname(__FILE__)) TEMP_DIR = SPEC_ROOT + '/temp' TEMP_STORAGES = TEMP_DIR + '/storages' def setup_default_store(store=nil) # if store # StrokeDB.stu...
github
oleganza/strokedb-core
https://github.com/oleganza/strokedb-core
spec/lib/stroke_objects/slot_hooks_spec.rb
Ruby
mit
19
master
890
require File.expand_path(File.join(File.dirname(__FILE__), 'spec_helper')) describe StrokeObjects::SlotHooks do before :each do @dumper_mod = dumper_mod = Module.new do def get(doc, slotname) v = super v ? Marshal.load(v) : v end def set(doc, slotname, value) sup...
github
oleganza/strokedb-core
https://github.com/oleganza/strokedb-core
spec/lib/stroke_objects/lazy_accessors_spec.rb
Ruby
mit
19
master
1,545
require File.expand_path(File.join(File.dirname(__FILE__), 'spec_helper')) describe StrokeObjects::LazyAccessors do before :each do @cls = Class.new(Hash) do include StrokeObjects::LazyAccessors include Util::OptionsHash # for strigification def has_slot?(slotname) has_key?(slotname....
github
oleganza/strokedb-core
https://github.com/oleganza/strokedb-core
spec/lib/views/default_key_codec_spec.rb
Ruby
mit
19
master
3,350
require File.expand_path(File.join(File.dirname(__FILE__), 'spec_helper')) describe Views::DefaultKeyCodec do before(:all) do @v = ClassFactory.new(Views::DefaultKeyCodec).new_class.new @items = [ nil, false, true, -66666, -66666 + 0.1, -0.0000000001, 0, 0.0...
github
oleganza/strokedb-core
https://github.com/oleganza/strokedb-core
spec/lib/views/tokyocabinet_view_spec.rb
Ruby
mit
19
master
1,608
require File.expand_path(File.join(File.dirname(__FILE__), 'spec_helper')) describe Views::TokyoCabinetView do def find(view, opts = {}) opts[:start_key] = opts[:end_key] = opts[:key] if opts[:key] view.find(*([:start_key, :end_key, :limit, :offset, :reverse, :with_keys].map{|p|opts[p]})) end befor...
github
oleganza/strokedb-core
https://github.com/oleganza/strokedb-core
spec/lib/validations/introspection_spec.rb
Ruby
mit
19
master
2,219
require File.expand_path(File.join(File.dirname(__FILE__), 'spec_helper')) describe "Validations[introspection]" do before :each do @contacts_validations = contacts_validations = Module.new do include Validations validate_presence_of :phone validate_presence_of :email end @more_valid...
github
oleganza/strokedb-core
https://github.com/oleganza/strokedb-core
spec/lib/validations/validation_spec.rb
Ruby
mit
19
master
2,914
require File.expand_path(File.join(File.dirname(__FILE__), 'spec_helper')) describe "Validation of" do before :each do @person_cls = Class.new do attr_accessor :name, :age, :gender attr_accessor :validate_age, :skip_gender include Validations validate_presence_of :name val...
github
oleganza/strokedb-core
https://github.com/oleganza/strokedb-core
spec/lib/util/lazy_mapping_hash_spec.rb
Ruby
mit
19
master
2,370
require File.dirname(__FILE__) + '/spec_helper' describe "LazyMappingHash instance" do before(:each) do @lash = LazyMappingHash.new end it "should have class Hash" do @lash.class.should == Hash end it "should be inherited from Hash" do @lash.class.ancestors.first.should == Hash end ...
github
oleganza/strokedb-core
https://github.com/oleganza/strokedb-core
spec/lib/util/uuid_spec.rb
Ruby
mit
19
master
1,464
require File.expand_path(File.join(File.dirname(__FILE__), 'spec_helper')) describe "String UUID" do it "should have specific format" do 1000.times do uuid = Util::random_uuid uuid.should =~ /^#{UUID_RE}$/ end end it "should be converted to raw string" do "00000000-0000-0000-0000-0000000...
github
oleganza/strokedb-core
https://github.com/oleganza/strokedb-core
spec/lib/util/lazy_mapping_array_spec.rb
Ruby
mit
19
master
4,343
require File.expand_path(File.join(File.dirname(__FILE__), 'spec_helper')) describe "LazyMappingArray instance" do before(:each) do @array = LazyMappingArray.new end it "should have class Array" do @array.class.should == Array end it "should be inherited from Array" do @array.class.ancestors.fi...
github
oleganza/strokedb-core
https://github.com/oleganza/strokedb-core
spec/lib/util/class_factory_spec.rb
Ruby
mit
19
master
1,477
require File.expand_path(File.join(File.dirname(__FILE__), 'spec_helper')) describe "ClassFactory.new" do before(:each) do @a = Module.new do def m "a" end end @b = Module.new do def m "b" + super end end @obj = Object.new end it "should make a mo...
github
oleganza/strokedb-core
https://github.com/oleganza/strokedb-core
spec/lib/util/verify_spec.rb
Ruby
mit
19
master
640
require File.expand_path(File.join(File.dirname(__FILE__), 'spec_helper')) describe "verify", :shared => true do it do lambda{ @context.verify{ true } }.should_not raise_error end it do lambda{ @context.verify{ false } }.should raise_error(Util::VerifyFailed) end it "should return the block resul...
github
oleganza/strokedb-core
https://github.com/oleganza/strokedb-core
spec/lib/util/options_hash_spec.rb
Ruby
mit
19
master
2,348
require File.expand_path(File.join(File.dirname(__FILE__), 'spec_helper')) describe "OptionsHash!(hash)" do before(:each) do @h = {"a" => "string", :b => "sym"} @oh = OptionsHash!(@h) end it { @oh.object_id.should == @h.object_id } it { @h.should be_kind_of(OptionsHash) } it { @h.should respond...
github
oleganza/strokedb-core
https://github.com/oleganza/strokedb-core
spec/lib/associations/has_many_spec.rb
Ruby
mit
19
master
318
require File.expand_path(File.join(File.dirname(__FILE__), 'spec_helper')) describe "has_many :as" do before(:each) do @person_mod = Module.new do extend Associations::HasMany has_many :owned_accounts, :as => :owner, :kind_of => [] end end it "should description" do end end
github
oleganza/strokedb-core
https://github.com/oleganza/strokedb-core
spec/lib/associations/introspection_spec.rb
Ruby
mit
19
master
271
require File.expand_path(File.join(File.dirname(__FILE__), 'spec_helper')) describe "Associations[introspection]" do before :each do # TODO: port spec from the validations/introspection_spec.rb end it "should be inheritable when defined in a module" end
github
oleganza/strokedb-core
https://github.com/oleganza/strokedb-core
spec/lib/associations/belongs_to_spec.rb
Ruby
mit
19
master
570
require File.expand_path(File.join(File.dirname(__FILE__), 'spec_helper')) describe "Belongs to association" do before :each do @person_cls = Class.new(Hash) do include Associations belongs_to :account end @person = @person_cls.new end it "should provide reader methods" do @pers...
github
oleganza/strokedb-core
https://github.com/oleganza/strokedb-core
spec/lib/repositories/tokyocabinet_repository_spec.rb
Ruby
mit
19
master
2,044
require File.expand_path(File.join(File.dirname(__FILE__), 'spec_helper')) describe "TokyoCabinetRepository with default setup" do before(:all) do @r = ClassFactory.new(Repositories::AbstractHelpers, Repositories::DefaultUuidHelpers, Repositories::HashHelper, ...
github
oleganza/strokedb-core
https://github.com/oleganza/strokedb-core
spec/lib/repositories/branches_spec.rb
Ruby
mit
19
master
1,230
require File.expand_path(File.join(File.dirname(__FILE__), 'spec_helper')) describe "TokyoCabinetRepository with default setup" do before(:all) do @rc = ClassFactory.new(Repositories::AbstractRepository, Repositories::DefaultUuidHelpers, Repositories::HashH...
github
oleganza/strokedb-core
https://github.com/oleganza/strokedb-core
spec/lib/repositories/helpers/hash_helper_spec.rb
Ruby
mit
19
master
284
require File.expand_path(File.join(File.dirname(__FILE__), 'spec_helper')) describe "HashHelper" do before(:each) do @h = ClassFactory.new(Repositories::AbstractHelpers, Repositories::HashHelper).new_class.new end it { @h.new_document.should == { "uuid" => nil } } end
github
oleganza/strokedb-core
https://github.com/oleganza/strokedb-core
spec/lib/repositories/helpers/default_uuid_helpers_spec.rb
Ruby
mit
19
master
348
require File.expand_path(File.join(File.dirname(__FILE__), 'spec_helper')) describe "DefaultUuidHelpers" do before(:each) do @h = ClassFactory.new(Repositories::AbstractHelpers, Repositories::DefaultUuidHelpers).new_class.new end it { @h.generate_version(nil).should =~ UUID_RE } it { @h.generate_uuid(nil)...
github
oleganza/strokedb-core
https://github.com/oleganza/strokedb-core
spec/lib/document/nsurl_spec.rb
Ruby
mit
19
master
1,754
require File.expand_path(File.join(File.dirname(__FILE__), 'spec_helper')) describe NSURL do before(:each) do base = @base = Module.new do extend NSURL end @sub = Module.new do include base end end it "should be nil by default" do @base.nsurl.should == nil end it "should...
github
oleganza/strokedb-core
https://github.com/oleganza/strokedb-core
spec/lib/document/generic_spec.rb
Ruby
mit
19
master
1,262
require File.expand_path(File.join(File.dirname(__FILE__), 'spec_helper')) describe "document with metas", :shared => true do it { @doc[:uuid].should_not be_nil } it { @doc[:metas].should be_kind_of(Array) } it { @doc[:metas].should_not be_empty } it "for each meta should respond positively to kind_of?, is_...
github
oleganza/strokedb-core
https://github.com/oleganza/strokedb-core
test/inheritable_declarations.rb
Ruby
mit
19
master
3,259
#!/usr/bin/env ruby module Declarations # When set up a new child, notify all the ancestors # When add declaration to a parent, update all known children module SelfMethods def setup(container, *args) setup_inheritance(container, args) macros = [:validates_presence_of, :before_save, :has_many...
github
oleganza/strokedb-core
https://github.com/oleganza/strokedb-core
test/module_ancestors.rb
Ruby
mit
19
master
698
#!/usr/bin/env ruby class Module # Default implementation doesn't collect all possible ancestors. alias not_all_ancestors ancestors def ancestors(collected = []) collected << self (not_all_ancestors - collected).inject(collected) do |c, a| (c | a.ancestors(c)) end end end module A1; end modu...
github
oleganza/strokedb-core
https://github.com/oleganza/strokedb-core
test/tcbdbcur.rb
Ruby
mit
19
master
937
#!/usr/bin/env ruby require 'irb' require 'fileutils' require 'tokyocabinet' include TokyoCabinet path = "casket.bdb" # create the object bdb = BDB::new FileUtils.rm_f(path) # open the database if(!bdb.open(path, BDB::OWRITER | BDB::OCREAT)) ecode = bdb.ecode STDERR.printf("open error: %s\n", bdb.errmsg(ecode)...
github
oleganza/strokedb-core
https://github.com/oleganza/strokedb-core
test/inheritable_declarations2.rb
Ruby
mit
19
master
3,069
#!/usr/bin/env ruby module InheritableAttributes def include(mod) invalidate_children_78f4156b_f3cb_55e8_9083_680ed199f277 super end def extend(mod) invalidate_children_78f4156b_f3cb_55e8_9083_680ed199f277 super end def included(mod) invalidate_children_78f4156b_f3cb_55e8_9083_680ed199f27...
github
oleganza/strokedb-core
https://github.com/oleganza/strokedb-core
examples/mml.rb
Ruby
mit
19
master
2,422
$LOAD_PATH.unshift File.expand_path(File.dirname(__FILE__) + "/../lib") require 'strokedb-core' include StrokeDB dir = File.dirname(__FILE__) MyDatabase = StrokeObjects::Database.new( :path => File.join(dir, ".mml.strokedb"), :plugins => [ Validations ] ) module MML...
github
oleganza/strokedb-core
https://github.com/oleganza/strokedb-core
examples/vkontakte_api.rb
Ruby
mit
19
master
1,343
$LOAD_PATH.unshift File.expand_path(File.dirname(__FILE__) + "/../lib") require 'strokedb-core' include StrokeDB dir = File.dirname(__FILE__) MyDatabase = StrokeObjects::Database.new( :path => File.join(dir, ".vkontakte_api.strokedb"), :plugins => [ Validations ] ) ...
github
oleganza/strokedb-core
https://github.com/oleganza/strokedb-core
examples/example.rb
Ruby
mit
19
master
223
require 'strokedb-core' include StrokeDB db = Repository.open("documents.db") oleg_uuid = db.post({"proto" => "User", "name" => "oleg"}) doc = db.get(oleg_uuid) doc["age"] = 21 db.put(oleg_uuid, doc) db.close
github
tomdalling/byebug-skipper
https://github.com/tomdalling/byebug-skipper
byebug-skipper.gemspec
Ruby
mit
19
main
630
require_relative 'lib/byebug/skipper/version' Gem::Specification.new do |s| s.name = 'byebug-skipper' s.version = Byebug::Skipper::VERSION s.licenses = ['MIT'] s.authors = ['Tom Dalling'] s.email = ['tom', '@', 'tomdalling', '.', 'com'].join s.homepage = 'https://github.com/tomdalling/byebug-skipper' s.s...
github
tomdalling/byebug-skipper
https://github.com/tomdalling/byebug-skipper
lib/byebug/skipper.rb
Ruby
mit
19
main
1,391
require 'byebug' module Byebug::Skipper extend self DEFAULT_SKIP_MATCHERS = [ %r{/ruby/[^/]+(/bundler)?/gems/}, # gems installed globally or via Bundler %r{/ruby-[^/]+/gems/}, # RVM directory format %r{/ruby-[^/]+/lib/ruby/[^/]+/}, # Ruby built-in files %r{/versions/[^/]+/lib/ruby/gems/}, # RBEnv ...
github
tomdalling/byebug-skipper
https://github.com/tomdalling/byebug-skipper
lib/byebug/skipper/ups_command.rb
Ruby
mit
19
main
694
module Byebug::Skipper # this class is partially copy/pasted from Byebug::UpCommand class UpsCommand < Byebug::Command include Byebug::Helpers::FrameHelper self.allow_in_post_mortem = true def self.regexp /^ \s* ups \s* $/x end def self.short_description "Same as `up` but skips ga...
github
tomdalling/byebug-skipper
https://github.com/tomdalling/byebug-skipper
lib/byebug/skipper/steps_command.rb
Ruby
mit
19
main
1,408
module Byebug::Skipper # this class is partially copy/pasted from Byebug::StepsCommand class StepsCommand < Byebug::Command def self.regexp /^ \s* s(?:tep)?s \s* $/x end def self.short_description "Same as `step` but skips garbage frames, e.g. from gems" end def self.description ...
github
tomdalling/byebug-skipper
https://github.com/tomdalling/byebug-skipper
lib/byebug/skipper/finishs_command.rb
Ruby
mit
19
main
876
module Byebug::Skipper # this class is partially copy/pasted from Byebug::FinishsCommand class FinishsCommand < Byebug::Command include Byebug::Helpers::FrameHelper self.allow_in_post_mortem = false def self.regexp /^ \s* fin(?:ish)?s \s* $/x end def self.short_description "Same a...
github
tomdalling/byebug-skipper
https://github.com/tomdalling/byebug-skipper
lib/byebug/skipper/comment_line_above.rb
Ruby
mit
19
main
672
# frozen_string_literal: true module Byebug::Skipper module CommentLineAbove extend self def call(location) path, _, line_no = location.rpartition(':') lines = File.readlines(path) idx = Integer(line_no) - 2 while ignore_line?(lines[idx]) idx -= 1 return if idx < 0 #...
github
tomdalling/byebug-skipper
https://github.com/tomdalling/byebug-skipper
lib/byebug/skipper/skip_bang_command.rb
Ruby
mit
19
main
657
module Byebug::Skipper class SkipBangCommand < Byebug::SkipCommand def self.regexp /^ \s* skip! \s* $/x end def self.short_description "Same as `skip` but also comments out the line before the current one (where `byebug` or `binding.pry` usually is)" end def self.description sh...
github
tomdalling/byebug-skipper
https://github.com/tomdalling/byebug-skipper
lib/byebug/skipper/pry.rb
Ruby
mit
19
main
2,207
require_relative '../skipper' require 'pry-byebug' module Byebug::Skipper::Pry COMMANDS = [ { cmd: 'ups', const_name: 'Ups', continues?: false, }, { cmd: 'downs', const_name: 'Downs', continues?: false, }, { cmd: 'steps', const_name: 'Steps', ...
github
tomdalling/byebug-skipper
https://github.com/tomdalling/byebug-skipper
lib/byebug/skipper/downs_command.rb
Ruby
mit
19
main
703
module Byebug::Skipper # this class is partially copy/pasted from Byebug::DownCommand class DownsCommand < Byebug::Command include Byebug::Helpers::FrameHelper self.allow_in_post_mortem = true def self.regexp /^ \s* downs \s* $/x end def self.short_description "Same as `down` but ...
github
tomdalling/byebug-skipper
https://github.com/tomdalling/byebug-skipper
spec/byebug-skipper_spec.rb
Ruby
mit
19
main
2,383
# frozen_string_literal: true RSpec.describe Byebug::Skipper do subject { described_class } around do |example| old_matchers = subject.skip_matchers example.call ensure subject.skip_matchers = old_matchers end it 'skips gem paths by default' do expect(subject.skip?('/Users/tom/.gem/ruby/2.7...
github
tomdalling/byebug-skipper
https://github.com/tomdalling/byebug-skipper
spec/manual.rb
Ruby
mit
19
main
1,262
# Run this manual test with `bundle exec ruby spec/manual.rb` and follow the # instructions in the comments. # # Replace "binding.pry" with "byebug" to test byebug standalone. # require 'pp' require_relative '../lib/byebug/skipper/pry' module MuhCode def self.pretty_print(pp) # Test #3: Use `ups` then `downs`. ...
github
tomdalling/byebug-skipper
https://github.com/tomdalling/byebug-skipper
spec/comment_line_above_spec.rb
Ruby
mit
19
main
1,226
# frozen_string_literal: true RSpec.describe Byebug::Skipper::CommentLineAbove do subject do described_class.(location) File.read(tempfile.path) end let(:location) { "#{tempfile.path}:#{line_number}" } let(:line_number) do file_contents.lines.index { _1.strip == 'stop_here' } + 1 end let(:tempf...
github
tomdalling/byebug-skipper
https://github.com/tomdalling/byebug-skipper
spec/spec_helper.rb
Ruby
mit
19
main
4,801
# frozen_string_literal: true require 'byebug/skipper' # 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 load...
github
first-try-software/manufacturable
https://github.com/first-try-software/manufacturable
manufacturable.gemspec
Ruby
mit
19
main
1,869
require_relative './lib/manufacturable/version' Gem::Specification.new do |spec| spec.name = "manufacturable" spec.version = Manufacturable::VERSION spec.authors = ["Alan Ridlehoover", "Fito von Zastrow"] spec.email = ["administators@firsttry.software"] spec.summary = %q{M...
github
first-try-software/manufacturable
https://github.com/first-try-software/manufacturable
lib/manufacturable.rb
Ruby
mit
19
main
968
require 'manufacturable/version' require 'manufacturable/config' require 'manufacturable/factory' require 'manufacturable/item' require 'manufacturable/object_factory' require 'manufacturable/railtie' require 'manufacturable/simple_registrar' require 'manufacturable/dispatcher' module Manufacturable def self.build(*...
github
first-try-software/manufacturable
https://github.com/first-try-software/manufacturable
lib/manufacturable/config.rb
Ruby
mit
19
main
519
module Manufacturable class Config class << self attr_writer :require_method def paths @paths ||= [] end def load_paths paths.each { |path| require_path(path) } end private def require_method @require_method || :require end def req...
github
first-try-software/manufacturable
https://github.com/first-try-software/manufacturable
lib/manufacturable/builder.rb
Ruby
mit
19
main
1,501
require 'manufacturable/injector' require 'manufacturable/registrar' module Manufacturable class Builder def self.build(*args, **kwargs, &block) self.new(*args, **kwargs, &block).build end def self.build_one(*args, **kwargs, &block) self.new(*args, **kwargs, &block).build_one end de...
github
first-try-software/manufacturable
https://github.com/first-try-software/manufacturable
lib/manufacturable/injector.rb
Ruby
mit
19
main
593
require 'manufacturable/simple_registrar' module Manufacturable class Injector class << self def inject(klass, *args, **kwargs) params = dependencies_for(klass).merge(**kwargs) klass.new(*args, **params) end private def dependencies_for(klass) return {} unless kl...
github
first-try-software/manufacturable
https://github.com/first-try-software/manufacturable
lib/manufacturable/registrar.rb
Ruby
mit
19
main
1,425
require 'set' module Manufacturable class Registrar ALL_KEY = :__all__ DEFAULT_KEY = :__default__ class << self def register(type, key, value) self.new(registry, type, key).register(value) end def get(type, key) self.new(registry, type, key).get end def re...
github
first-try-software/manufacturable
https://github.com/first-try-software/manufacturable
lib/manufacturable/dispatcher.rb
Ruby
mit
19
main
495
module Manufacturable class Dispatcher attr_reader :message, :receiver def initialize(message:, receiver:) @message = message @receiver = receiver end def method_missing(name, *args, **kwargs) return super unless respond_to?(name) Manufacturable.build_one(receiver, name, *ar...
github
first-try-software/manufacturable
https://github.com/first-try-software/manufacturable
lib/manufacturable/factory.rb
Ruby
mit
19
main
596
require 'manufacturable/builder' module Manufacturable module Factory def manufactures(klass) @type = klass end def build(key, *args) return if @type.nil? Builder.build(@type, key, *args) end def build_one(key, *args) return if @type.nil? Builder.build_one(@type,...
github
first-try-software/manufacturable
https://github.com/first-try-software/manufacturable
lib/manufacturable/simple_registrar.rb
Ruby
mit
19
main
583
module Manufacturable class SimpleRegistrar class << self def register(key, value) self.new(registry, key).register(value) end def entries(*keys) registry.slice(*keys) end private def registry @registry ||= Hash.new end end def initiali...
github
first-try-software/manufacturable
https://github.com/first-try-software/manufacturable
lib/manufacturable/railtie.rb
Ruby
mit
19
main
465
require 'manufacturable/config' module Manufacturable class Railtie def self.load load_railtie if rails_defined? end def self.load_railtie Class.new(Rails::Railtie).initializer('manufacturable.require_paths') do |app| Manufacturable::Config.require_method = app.config.eager_load ? :r...
github
first-try-software/manufacturable
https://github.com/first-try-software/manufacturable
lib/manufacturable/item.rb
Ruby
mit
19
main
853
require 'manufacturable/registrar' module Manufacturable module Item def new(*args, **kwargs, &block) key = kwargs.delete(:manufacturable_item_key) instance = kwargs.empty? ? super(*args, &block) : super instance.instance_variable_set(:@manufacturable_item_key, key) instance end ...
github
first-try-software/manufacturable
https://github.com/first-try-software/manufacturable
spec/manufacturable_spec.rb
Ruby
mit
19
main
2,610
RSpec.describe Manufacturable do it "has a version number" do expect(Manufacturable::VERSION).not_to be nil end describe '.build' do subject(:build) { described_class.build(args) } let(:args) { 'args' } before do allow(Manufacturable::Builder).to receive(:build) build end ...
github
first-try-software/manufacturable
https://github.com/first-try-software/manufacturable
spec/spec_helper.rb
Ruby
mit
19
main
312
require 'simplecov' SimpleCov.start do add_filter '/spec/' end require "bundler/setup" require "manufacturable" RSpec.configure do |config| config.example_status_persistence_file_path = ".rspec_status" config.disable_monkey_patching! config.expect_with :rspec do |c| c.syntax = :expect end end
github
first-try-software/manufacturable
https://github.com/first-try-software/manufacturable
spec/integration/manufacturable_spec.rb
Ruby
mit
19
main
4,328
RSpec.describe 'Manufacturable' do describe 'trying to build a class before registering anything' do it 'returns nil' do expect(Manufacturable.build(Object, :anything)).to be_nil end end describe 'building a class registered on the Object namespace' do let!(:sedan) { Class.new { extend Manufact...
github
first-try-software/manufacturable
https://github.com/first-try-software/manufacturable
spec/manufacturable/item_spec.rb
Ruby
mit
19
main
5,135
RSpec.describe Manufacturable::Item do let(:item) { Class.new(base_klass) { extend Manufacturable::Item } } let(:base_klass) { Class.new } let(:type) { base_klass } before do allow(Manufacturable::Registrar).to receive(:register) end describe '.corresponds_to' do subject(:corresponds_to) { item.co...
github
first-try-software/manufacturable
https://github.com/first-try-software/manufacturable
spec/manufacturable/config_spec.rb
Ruby
mit
19
main
2,034
RSpec.describe Manufacturable::Config do after { described_class.paths.clear } describe '.paths' do subject(:paths) { described_class.paths } context 'when there are NO manufacturable paths' do it 'returns an empty array' do expect(paths).to eq([]) end end context 'when there ...
github
first-try-software/manufacturable
https://github.com/first-try-software/manufacturable
spec/manufacturable/registrar_spec.rb
Ruby
mit
19
main
2,811
RSpec.describe Manufacturable::Registrar do subject(:registrar) { described_class } let(:type) { :type } let(:key) { :key } let(:klass) { class_double('Klass') } before { registrar.reset! } after { registrar.reset! } describe '.register' do subject(:register) { registrar.register(type, key, klass) ...
github
first-try-software/manufacturable
https://github.com/first-try-software/manufacturable
spec/manufacturable/railtie_spec.rb
Ruby
mit
19
main
1,576
RSpec.describe Manufacturable::Railtie do let!(:rails_railtie) do module Rails class Railtie def self.initializer(param, &block) end end end end describe '.load' do subject(:load) { described_class.load } before do allow(described_class).to receive(:rails_define...
github
first-try-software/manufacturable
https://github.com/first-try-software/manufacturable
spec/manufacturable/object_factory_spec.rb
Ruby
mit
19
main
478
RSpec.describe Manufacturable::ObjectFactory do subject(:factory) { described_class } describe '.build' do subject(:build) { factory.build(key, *args) } let(:key) { :key } let(:args) { [1, 2, 3] } before do allow(Manufacturable::Builder).to receive(:build) build end it 'dele...
github
first-try-software/manufacturable
https://github.com/first-try-software/manufacturable
spec/manufacturable/factory_spec.rb
Ruby
mit
19
main
2,878
RSpec.describe Manufacturable::Factory do subject(:factory) { Class.new { extend Manufacturable::Factory } } let(:klass) { class_double('Klass') } let(:key) { 'key' } let(:args) { 'args' } describe '.manufactures' do subject(:manufactures) { factory.manufactures(klass) } before { manufactures } ...
github
first-try-software/manufacturable
https://github.com/first-try-software/manufacturable
spec/manufacturable/builder_spec.rb
Ruby
mit
19
main
9,303
RSpec.describe Manufacturable::Builder do let(:type) { 'type' } let(:key) { 'key' } let(:args) { 'args' } let(:kwargs) { { manufacturable_item_key: key } } let(:klasses) { Set.new } describe '.build' do subject(:build) { described_class.build(type, key, args) } before do allow(Manufacturable...
github
ashmaroli/jekyll-locale
https://github.com/ashmaroli/jekyll-locale
Gemfile
Ruby
mit
19
master
522
# frozen_string_literal: true source "https://rubygems.org" gemspec def custom_gem_source(name, nwo, branch) path = File.expand_path("../#{name}", __dir__) if Dir.exist?(path) { :path => path } else { :git => "https://github.com/#{nwo}.git", :branch => branch } end end # gem "kramdown", custom_gem_...
github
ashmaroli/jekyll-locale
https://github.com/ashmaroli/jekyll-locale
jekyll-locale.gemspec
Ruby
mit
19
master
831
# frozen_string_literal: true lib = File.expand_path("lib", __dir__) $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) require "jekyll/locale/version" Gem::Specification.new do |spec| spec.name = "jekyll-locale" spec.version = Jekyll::Locale::VERSION spec.authors = ["Ashwin Maroli"] spec.email ...
github
ashmaroli/jekyll-locale
https://github.com/ashmaroli/jekyll-locale
lib/jekyll-locale.rb
Ruby
mit
19
master
1,461
# frozen_string_literal: true module Jekyll module Locale autoload :Drop, "jekyll/locale/drop" autoload :Document, "jekyll/locale/document" autoload :AutoPage, "jekyll/locale/auto_page" autoload :Page, "jekyll/locale/page" autoload :Handler, "jekyll/locale/handler" autoload :Identity...
github
ashmaroli/jekyll-locale
https://github.com/ashmaroli/jekyll-locale
lib/jekyll/patches/utils.rb
Ruby
mit
19
master
473
# frozen_string_literal: true module Jekyll module Utils extend self def snakeify(input) slug = slugify(input.to_s, :mode => "latin", :cased => true) slug.tr!("-", "_") slug end def recursive_symbolize_hash_keys(hash) result = {} hash.each do |key, value| new_k...
github
ashmaroli/jekyll-locale
https://github.com/ashmaroli/jekyll-locale
lib/jekyll/patches/site.rb
Ruby
mit
19
master
271
# frozen_string_literal: true module Jekyll class Drops::UnifiedPayloadDrop def locale @locale ||= Locale::Drop.new(@obj.locale_handler) end end class Site def locale_handler @locale_handler ||= Locale::Handler.new(self) end end end
github
ashmaroli/jekyll-locale
https://github.com/ashmaroli/jekyll-locale
lib/jekyll/locale/filters.rb
Ruby
mit
19
master
1,034
# frozen_string_literal: true module Jekyll module Locale module Filters def localize_date(input, format = :default) format = symbol_or_strftime(format) DateTimeHandler.localize(time(input), format) end def prefix_locale(input) return input unless input.is_a?(String) ...
github
ashmaroli/jekyll-locale
https://github.com/ashmaroli/jekyll-locale
lib/jekyll/locale/handler.rb
Ruby
mit
19
master
5,826
# frozen_string_literal: true module Jekyll class Locale::Handler attr_reader :default_locale, :available_locales, :locale_dates, :content_dirname, :user_locales attr_writer :current_locale DEFAULT_CONFIG = { "mode" => "manual", "locale" => "en-US", "data_di...
github
ashmaroli/jekyll-locale
https://github.com/ashmaroli/jekyll-locale
lib/jekyll/locale/identity.rb
Ruby
mit
19
master
308
# frozen_string_literal: true module Jekyll class Locale::Identity attr_reader :id, :data alias_method :to_s, :id def initialize(locale_id, metadata) @id = locale_id.to_s @data = metadata end def to_liquid @to_liquid ||= data.merge("id" => id) end end end
github
ashmaroli/jekyll-locale
https://github.com/ashmaroli/jekyll-locale
lib/jekyll/locale/document.rb
Ruby
mit
19
master
893
# frozen_string_literal: true module Jekyll class Locale::Document < Document attr_reader :type include Locale::Helper def initialize(canon, locale) setup(canon, locale) @collection = canon.collection @extname = File.extname(relative_path) @has_yaml_header = nil @type = @co...
github
ashmaroli/jekyll-locale
https://github.com/ashmaroli/jekyll-locale
lib/jekyll/locale/auto_page.rb
Ruby
mit
19
master
598
# frozen_string_literal: true module Jekyll class Locale::AutoPage < Page include Locale::Helper attr_reader :path attr_accessor :data, :content, :output def initialize(canon, locale) setup(canon, locale) @path = canon.path @content = canon.content @data = canon.da...
github
ashmaroli/jekyll-locale
https://github.com/ashmaroli/jekyll-locale
lib/jekyll/locale/page.rb
Ruby
mit
19
master
567
# frozen_string_literal: true module Jekyll class Locale::Page < Page include Locale::Helper attr_reader :path def initialize(canon, locale) setup(canon, locale) @dir, @name = File.split(relative_path) @base = site.source process(@name) read_yaml(@dir, @name) configur...
github
ashmaroli/jekyll-locale
https://github.com/ashmaroli/jekyll-locale
lib/jekyll/locale/date_time_handler.rb
Ruby
mit
19
master
1,546
# frozen_string_literal: true module Jekyll module Locale::DateTimeHandler DATETIME_DEFAULTS = { :date => { :day_names => Date::DAYNAMES, :month_names => Date::MONTHNAMES, :abbr_day_names => Date::ABBR_DAYNAMES, :abbr_month_names => Date::ABBR_MONTHNAMES, ...
github
ashmaroli/jekyll-locale
https://github.com/ashmaroli/jekyll-locale
lib/jekyll/locale/mixins/helper.rb
Ruby
mit
19
master
1,476
# frozen_string_literal: true module Jekyll module Locale::Helper attr_reader :canon, :relative_path def setup_hreflangs? true end def setup_hreflangs page_set = [canon] + canon.locale_pages @hreflangs = sibling_data(page_set) @locale_siblings = sibling_data(page_set - [self...
github
ashmaroli/jekyll-locale
https://github.com/ashmaroli/jekyll-locale
lib/jekyll/locale/mixins/support.rb
Ruby
mit
19
master
775
# frozen_string_literal: true module Jekyll module Locale::Support attr_reader :site, :locale def setup_hreflangs? false end def locale_siblings @locale_siblings ||= sibling_data(locale_pages) end def hreflangs @hreflangs ||= sibling_data([self] + locale_pages) end ...
github
ashmaroli/jekyll-locale
https://github.com/ashmaroli/jekyll-locale
example/Gemfile
Ruby
mit
19
master
263
# frozen_string_literal: true source "https://rubygems.org" gem "jekyll", :path => "../../jekyll" if Dir.exist?("../../jekyll") group :jekyll_plugins do gem "jekyll-feed" gem "jekyll-sitemap" gem "jekyll-seo-tag" gem "jekyll-locale", :path => ".." end
github
ashmaroli/jekyll-locale
https://github.com/ashmaroli/jekyll-locale
spec/spec_helper.rb
Ruby
mit
19
master
1,471
# frozen_string_literal: true require "simplecov" require "fileutils" require "jekyll" require_relative "../lib/jekyll-locale" Jekyll.logger.log_level = :error def dest_dir(*subdirs) File.join( File.expand_path("../tmp/dest", __dir__), subdirs ) end def source_dir(*subdirs) File.join( File.expand_...
github
ashmaroli/jekyll-locale
https://github.com/ashmaroli/jekyll-locale
spec/jekyll-locale/document_spec.rb
Ruby
mit
19
master
6,014
# frozen_string_literal: true RSpec.describe Jekyll::Locale::Document do let(:collection) { "posts" } let(:doc_name) { "2018-10-15-hello-world.md" } let(:locale_id) { "en" } let(:metadata) { {} } let(:locale) { Jekyll::Locale::Identity.new(locale_id, metadata) } let(:locales_set) { %w(fr en j...
github
ashmaroli/jekyll-locale
https://github.com/ashmaroli/jekyll-locale
spec/jekyll-locale/auto_page_spec.rb
Ruby
mit
19
master
4,539
# frozen_string_literal: true RSpec.describe Jekyll::Locale::AutoPage do let(:page_name) { "about.md" } let(:locale_id) { "en" } let(:metadata) { {} } let(:locale) { Jekyll::Locale::Identity.new(locale_id, metadata) } let(:locales_set) { %w(en fr ja) } let(:config) do { "title" ...
github
ashmaroli/jekyll-locale
https://github.com/ashmaroli/jekyll-locale
spec/jekyll-locale/handler_spec.rb
Ruby
mit
19
master
6,061
# frozen_string_literal: true RSpec.describe Jekyll::Locale::Handler do let(:config) { { "title" => "Localization Test" } } let(:site) { make_site(config) } let(:locale_id) { "en-US" } let(:metadata) { {} } let(:locale) { Jekyll::Locale::Identity.new(locale_id, metadata) } subject { described_...
github
ashmaroli/jekyll-locale
https://github.com/ashmaroli/jekyll-locale
spec/jekyll-locale/filters_spec.rb
Ruby
mit
19
master
3,011
# frozen_string_literal: true RSpec.describe Jekyll::Locale::Filters do class FilterMock def initialize(context) @context = context end end FilterMock.include(Liquid::StandardFilters) FilterMock.include(Jekyll::Filters) FilterMock.include(described_class) let(:locale_id) { "fr" } let(:met...
github
ashmaroli/jekyll-locale
https://github.com/ashmaroli/jekyll-locale
spec/jekyll-locale/page_spec.rb
Ruby
mit
19
master
4,599
# frozen_string_literal: true RSpec.describe Jekyll::Locale::Page do let(:page_name) { "about.md" } let(:locale_id) { "en" } let(:metadata) { {} } let(:locale) { Jekyll::Locale::Identity.new(locale_id, metadata) } let(:locales_set) { %w(en fr ja) } let(:config) do { "title" => ...
github
moeki0/baran
https://github.com/moeki0/baran
baran.gemspec
Ruby
mit
19
main
1,354
# frozen_string_literal: true require_relative "lib/baran/version" Gem::Specification.new do |spec| spec.name = "baran" spec.version = Baran::VERSION spec.authors = ["Moeki Kawakami"] spec.email = ["me@moeki.dev"] spec.summary = "Text Splitter for Large Language Model Datasets" spec.description = "Text S...
github
moeki0/baran
https://github.com/moeki0/baran
lib/baran.rb
Ruby
mit
19
main
382
# frozen_string_literal: true require_relative "baran/version" require_relative "baran/text_splitter" require_relative "baran/markdown_splitter" require_relative "baran/recursive_character_text_splitter" require_relative "baran/character_text_splitter" require_relative "baran/sentence_text_splitter" module Baran cl...
github
moeki0/baran
https://github.com/moeki0/baran
lib/baran/sentence_text_splitter.rb
Ruby
mit
19
main
423
# frozen_string_literal: true module Baran class SentenceTextSplitter < TextSplitter def initialize(chunk_size: 1024, chunk_overlap: 64) super(chunk_size: chunk_size, chunk_overlap: chunk_overlap) end def splitted(text) # Use a regex to split text based on the specified sentence-ending chara...
github
moeki0/baran
https://github.com/moeki0/baran
lib/baran/character_text_splitter.rb
Ruby
mit
19
main
453
require_relative './text_splitter' module Baran class CharacterTextSplitter < TextSplitter attr_accessor :separator def initialize(chunk_size: 1024, chunk_overlap: 64, separator: nil) super(chunk_size: chunk_size, chunk_overlap: chunk_overlap) @separator = separator || "\n\n" end def sp...
github
moeki0/baran
https://github.com/moeki0/baran
lib/baran/text_splitter.rb
Ruby
mit
19
main
1,665
require 'logger' module Baran class TextSplitter attr_accessor :chunk_size, :chunk_overlap def initialize(chunk_size: 1024, chunk_overlap: 64) @chunk_size = chunk_size @chunk_overlap = chunk_overlap raise "Cannot have chunk_overlap >= chunk_size" if @chunk_overlap >= @chunk_size end ...
github
moeki0/baran
https://github.com/moeki0/baran
lib/baran/recursive_character_text_splitter.rb
Ruby
mit
19
main
982
require_relative './text_splitter' module Baran class RecursiveCharacterTextSplitter < TextSplitter attr_accessor :separators def initialize(chunk_size: 1024, chunk_overlap: 64, separators: nil) super(chunk_size: chunk_size, chunk_overlap: chunk_overlap) @separators = separators || ["\n\n", "\n"...