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
moneytrackio/tezos_client
https://github.com/moneytrackio/tezos_client
lib/tezos_client/tools/convert_to_hash/big_map.rb
Ruby
mit
19
master
633
# frozen_string_literal: true class TezosClient class BigMap < Struct.new(:name, :id, :value_type, :key_type); end module Tools class ConvertToHash < ActiveInteraction::Base class BigMap < Base def decode if data.is_a? Hash ::TezosClient::BigMap.new( var_name,...
github
moneytrackio/tezos_client
https://github.com/moneytrackio/tezos_client
lib/tezos_client/tools/convert_to_hash/list.rb
Ruby
mit
19
master
436
# frozen_string_literal: true class TezosClient module Tools class ConvertToHash < ActiveInteraction::Base class List < Base def decode data.map do |elem| TezosClient::Tools::ConvertToHash::Base.new( data: elem, type: elem_type ).value ...
github
moneytrackio/tezos_client
https://github.com/moneytrackio/tezos_client
lib/tezos_client/tools/convert_to_hash/string.rb
Ruby
mit
19
master
223
# frozen_string_literal: true class TezosClient module Tools class ConvertToHash < ActiveInteraction::Base class String < Base def decode data[:string] end end end end end
github
moneytrackio/tezos_client
https://github.com/moneytrackio/tezos_client
lib/tezos_client/tools/convert_to_hash/key_hash.rb
Ruby
mit
19
master
253
# frozen_string_literal: true class TezosClient module Tools class ConvertToHash < ActiveInteraction::Base class KeyHash < Base def decode Address.new(data: data, type: type).decode end end end end end
github
moneytrackio/tezos_client
https://github.com/moneytrackio/tezos_client
lib/tezos_client/tools/convert_to_hash/option.rb
Ruby
mit
19
master
450
# frozen_string_literal: true class TezosClient module Tools class ConvertToHash < ActiveInteraction::Base class Option < Base def decode if data[:prim] == "None" nil elsif data[:prim] == "Some" TezosClient::Tools::ConvertToHash::Base.new( d...
github
moneytrackio/tezos_client
https://github.com/moneytrackio/tezos_client
lib/tezos_client/tools/hash_to_micheline/key.rb
Ruby
mit
19
master
312
# frozen_string_literal: true class TezosClient module Tools class HashToMicheline < ActiveInteraction::Base class Key < Base def encode raise "#{data} #{data.class} Not a 'String' type" unless data.is_a? ::String { string: data } end end end end end
github
moneytrackio/tezos_client
https://github.com/moneytrackio/tezos_client
lib/tezos_client/tools/hash_to_micheline/pair.rb
Ruby
mit
19
master
1,055
# frozen_string_literal: true class TezosClient module Tools class HashToMicheline < ActiveInteraction::Base class Pair < Base def encode { prim: "Pair", args: args } end private def args type[:args].each_with_index....
github
moneytrackio/tezos_client
https://github.com/moneytrackio/tezos_client
lib/tezos_client/tools/hash_to_micheline/nat.rb
Ruby
mit
19
master
227
# frozen_string_literal: true class TezosClient module Tools class HashToMicheline < ActiveInteraction::Base class Nat < Base def encode { int: data.to_s } end end end end end
github
moneytrackio/tezos_client
https://github.com/moneytrackio/tezos_client
lib/tezos_client/tools/hash_to_micheline/contract.rb
Ruby
mit
19
master
317
# frozen_string_literal: true class TezosClient module Tools class HashToMicheline < ActiveInteraction::Base class Contract < Base def encode raise "#{data} #{data.class} Not a 'String' type" unless data.is_a? ::String { string: data } end end end end end
github
moneytrackio/tezos_client
https://github.com/moneytrackio/tezos_client
lib/tezos_client/tools/hash_to_micheline/bytes.rb
Ruby
mit
19
master
313
# frozen_string_literal: true class TezosClient module Tools class HashToMicheline < ActiveInteraction::Base class Bytes < Base def encode raise "#{data} #{data.class} Not a 'String' type" unless data.is_a? ::String { bytes: data } end end end end end
github
moneytrackio/tezos_client
https://github.com/moneytrackio/tezos_client
lib/tezos_client/tools/hash_to_micheline/base.rb
Ruby
mit
19
master
1,090
# frozen_string_literal: true class TezosClient module Tools class HashToMicheline < ActiveInteraction::Base class Base def initialize(data:, type:) @data = data @type = type end attr_accessor :data, :type def value @data = anonymous? ? @data ...
github
moneytrackio/tezos_client
https://github.com/moneytrackio/tezos_client
lib/tezos_client/tools/hash_to_micheline/address.rb
Ruby
mit
19
master
316
# frozen_string_literal: true class TezosClient module Tools class HashToMicheline < ActiveInteraction::Base class Address < Base def encode raise "#{data} #{data.class} Not a 'String' type" unless data.is_a? ::String { string: data } end end end end end
github
moneytrackio/tezos_client
https://github.com/moneytrackio/tezos_client
lib/tezos_client/tools/hash_to_micheline/signature.rb
Ruby
mit
19
master
322
# frozen_string_literal: true class TezosClient module Tools class HashToMicheline < ActiveInteraction::Base class Signature < Base def encode raise "#{data} does not seem to be a signature" unless data.start_with?("edsig") { string: data } end end end end en...
github
moneytrackio/tezos_client
https://github.com/moneytrackio/tezos_client
lib/tezos_client/tools/hash_to_micheline/timestamp.rb
Ruby
mit
19
master
333
# frozen_string_literal: true class TezosClient module Tools class HashToMicheline < ActiveInteraction::Base class Timestamp < Base def encode raise "timestamp input (#{data}) must be an instance of Time" unless data.is_a? Time { int: data.to_i.to_s } end end e...
github
moneytrackio/tezos_client
https://github.com/moneytrackio/tezos_client
lib/tezos_client/tools/hash_to_micheline/string.rb
Ruby
mit
19
master
315
# frozen_string_literal: true class TezosClient module Tools class HashToMicheline < ActiveInteraction::Base class String < Base def encode raise "#{data} #{data.class} Not a 'String' type" unless data.is_a? ::String { string: data } end end end end end
github
moneytrackio/tezos_client
https://github.com/moneytrackio/tezos_client
lib/tezos_client/tools/hash_to_micheline/option.rb
Ruby
mit
19
master
481
# frozen_string_literal: true class TezosClient module Tools class HashToMicheline < ActiveInteraction::Base class Option < Base def encode return { prim: "None" } if data.nil? { prim: "Some", args: [ TezosClient::Tools::HashToMicheline::Ba...
github
moneytrackio/tezos_client
https://github.com/moneytrackio/tezos_client
lib/tezos_client/tools/hash_to_micheline/int.rb
Ruby
mit
19
master
227
# frozen_string_literal: true class TezosClient module Tools class HashToMicheline < ActiveInteraction::Base class Int < Base def encode { int: data.to_s } end end end end end
github
noelrappin/date_by_example
https://github.com/noelrappin/date_by_example
date_by_example.gemspec
Ruby
mit
19
master
1,085
lib = File.expand_path("lib", __dir__) $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) require "date_by_example/version" Gem::Specification.new do |spec| spec.name = "date_by_example" spec.version = DateByExample::VERSION spec.authors = ["Noel Rappin"] spec.email = ["noelra...
github
noelrappin/date_by_example
https://github.com/noelrappin/date_by_example
lib/date_by_example.rb
Ruby
mit
19
master
502
require "date" require "date_by_example/date" require "date_by_example/date_time" require "date_by_example/time" require "date_by_example/version" require "date_by_example/example_formatter" require "benchmark" module DateByExample def self.benchmark dt = DateTime.new(2018, 6, 9, 13, 15) Benchmark.bm do |x| ...
github
noelrappin/date_by_example
https://github.com/noelrappin/date_by_example
lib/date_by_example/example_formatter.rb
Ruby
mit
19
master
946
class ExampleFormatter attr_accessor :reference def initialize(reference) @reference = reference @format_string = nil end FORMATS = { ".000000000" => ".9N", "-07:00:00" => "%::z", ".000000" => ".%6N", "January" => "%B", "JANUARY" => "%^B", "Monday" => "%A", "MONDAY" => "%^A...
github
noelrappin/date_by_example
https://github.com/noelrappin/date_by_example
spec/spec_helper.rb
Ruby
mit
19
master
371
require "bundler/setup" require "date_by_example" RSpec.configure do |config| # Enable flags like --only-failures and --next-failure config.example_status_persistence_file_path = ".rspec_status" # Disable RSpec exposing methods globally on `Module` and `main` config.disable_monkey_patching! config.expect_w...
github
noelrappin/date_by_example
https://github.com/noelrappin/date_by_example
spec/example_formatter_spec.rb
Ruby
mit
19
master
3,623
RSpec.describe ExampleFormatter do def format_string_for(str) ExampleFormatter.new(str).format_string end def format_date(date, format) ExampleFormatter.new(format).format(date) end describe "years" do specify { expect(format_string_for("2006")).to eq("%Y") } specify { expect(format_string...
github
ostrovok-tech/redmine-plugin-webhook
https://github.com/ostrovok-tech/redmine-plugin-webhook
init.rb
Ruby
mit
19
master
521
require_dependency 'webhook' Redmine::Plugin.register :webhook do name 'Redmine Webhook Plugin' author 'Ivan Elfimov' description 'A plugin for Redmine which makes callback requests to specified URL when issue changes.' version '1.0.0' url 'https://github.com/ostrovok-team/redmine-webhook-plugin' author_ur...
github
ostrovok-tech/redmine-plugin-webhook
https://github.com/ostrovok-tech/redmine-plugin-webhook
lib/webhook/projects_helper_patch.rb
Ruby
mit
19
master
518
require_dependency 'projects_helper' module Webhook module ProjectsHelperPatch def self.included(base) base.class_eval do alias_method_chain :project_settings_tabs, :webhook end end def project_settings_tabs_with_webhook tabs = project_settings_tabs_without_webhook tabs <<...
github
ostrovok-tech/redmine-plugin-webhook
https://github.com/ostrovok-tech/redmine-plugin-webhook
lib/webhook/tracker_wrapper.rb
Ruby
mit
19
master
209
module Webhook class TrackerWrapper def initialize(tracker) @tracker = tracker end def to_hash { :id => @tracker.id, :name => @tracker.name } end end end
github
ostrovok-tech/redmine-plugin-webhook
https://github.com/ostrovok-tech/redmine-plugin-webhook
lib/webhook/priority_wrapper.rb
Ruby
mit
19
master
215
module Webhook class PriorityWrapper def initialize(priority) @priority = priority end def to_hash { :id => @priority.id, :name => @priority.name } end end end
github
ostrovok-tech/redmine-plugin-webhook
https://github.com/ostrovok-tech/redmine-plugin-webhook
lib/webhook/issue_wrapper.rb
Ruby
mit
19
master
1,374
module Webhook class IssueWrapper def initialize(issue) @issue = issue end def to_hash { :id => @issue.id, :subject => @issue.subject, :description => @issue.description, :created_on => @issue.created_on, :updated_on => @issue.updated_on, :close...
github
ostrovok-tech/redmine-plugin-webhook
https://github.com/ostrovok-tech/redmine-plugin-webhook
lib/webhook/custom_field_wrapper.rb
Ruby
mit
19
master
260
module Webhook class Webhook::CustomFieldWrapper def initialize(custom_field) @custom_field = custom_field end def to_hash { id: @custom_field.id, name: @custom_field.name, field_format: @custom_field.field_format } end end end
github
ostrovok-tech/redmine-plugin-webhook
https://github.com/ostrovok-tech/redmine-plugin-webhook
lib/webhook/project_wrapper.rb
Ruby
mit
19
master
344
class Webhook::ProjectWrapper def initialize(project) @project = project end def to_hash { :id => @project.id, :identifier => @project.identifier, :name => @project.name, :description => @project.description, :created_on => @project.created_on, :homepage => @project.ho...
github
ostrovok-tech/redmine-plugin-webhook
https://github.com/ostrovok-tech/redmine-plugin-webhook
lib/webhook/journal_wrapper.rb
Ruby
mit
19
master
479
module Webhook class JournalWrapper def initialize(journal) @journal = journal end def to_hash { :id => @journal.id, :notes => @journal.notes, :created_on => @journal.created_on, :private_notes => @journal.private_notes, :author => Webhook::AuthorWrappe...
github
ostrovok-tech/redmine-plugin-webhook
https://github.com/ostrovok-tech/redmine-plugin-webhook
lib/webhook/status_wrapper.rb
Ruby
mit
19
master
203
module Webhook class StatusWrapper def initialize(status) @status = status end def to_hash { :id => @status.id, :name => @status.name } end end end
github
ostrovok-tech/redmine-plugin-webhook
https://github.com/ostrovok-tech/redmine-plugin-webhook
lib/webhook/webhook_listener.rb
Ruby
mit
19
master
2,988
require 'net/http' module Webhook class WebhookListener < Redmine::Hook::Listener def skip_webhooks(context) request = context[:request] if request.headers['X-Skip-Webhooks'] return true end return false end def controller_issues_edit_after_save(context = {}) return if skip_webhooks(context...
github
ostrovok-tech/redmine-plugin-webhook
https://github.com/ostrovok-tech/redmine-plugin-webhook
lib/webhook/custom_field_value_wrapper.rb
Ruby
mit
19
master
333
class Webhook::CustomFieldValueWrapper def initialize(custom_field_value) @custom_field_value = custom_field_value end def to_hash { custom_field_id: @custom_field_value.custom_field_id, custom_field_name: @custom_field_value.custom_field.name, value: @custom_field_value.value ...
github
ostrovok-tech/redmine-plugin-webhook
https://github.com/ostrovok-tech/redmine-plugin-webhook
lib/webhook/author_wrapper.rb
Ruby
mit
19
master
636
module Webhook class AuthorWrapper include GravatarHelper::PublicMethods include ERB::Util def initialize(author) @author = author end def to_hash return nil unless @author { :id => @author.id, :login => @author.login, :mail => @author.mail, :fir...
github
ostrovok-tech/redmine-plugin-webhook
https://github.com/ostrovok-tech/redmine-plugin-webhook
lib/webhook/journal_detail_wrapper.rb
Ruby
mit
19
master
395
module Webhook class JournalDetailWrapper def initialize(journal_detail) @journal_detail = journal_detail end def to_hash { :id => @journal_detail.id, :value => @journal_detail.value, :old_value => @journal_detail.old_value, :prop_key => @journal_detail.prop_ke...
github
Tapjoy/chore
https://github.com/Tapjoy/chore
chore-core.gemspec
Ruby
mit
19
master
1,427
# -*- encoding: utf-8 -*- $: << File.expand_path('lib', File.dirname(__FILE__)) require 'chore/version' Gem::Specification.new do |s| s.name = "chore-core" s.version = Chore::Version::STRING s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version= s.authors = ["...
github
Tapjoy/chore
https://github.com/Tapjoy/chore
Rakefile
Ruby
mit
19
master
715
# encoding: utf-8 require 'rubygems' require 'bundler' begin Bundler.setup(:default, :development) rescue Bundler::BundlerError => e $stderr.puts e.message $stderr.puts "Run `bundle install` to install missing gems" exit e.status_code end require 'rake' require 'rspec/core' require 'rspec/core/rake_task' RSpe...
github
Tapjoy/chore
https://github.com/Tapjoy/chore
chore.gemspec
Ruby
mit
19
master
1,417
# -*- encoding: utf-8 -*- $: << File.expand_path('lib', File.dirname(__FILE__)) require 'chore/version' Gem::Specification.new do |s| s.name = "chore" s.version = Chore::Version::STRING s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version= s.authors = ["Tapjo...
github
Tapjoy/chore
https://github.com/Tapjoy/chore
spec/spec_helper.rb
Ruby
mit
19
master
1,392
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib')) $LOAD_PATH.unshift(File.dirname(__FILE__)) require 'rspec' require 'timecop' require 'chore' require 'test_job' # Requires supporting files with custom matchers and macros, etc, # in ./support/ and its subdirectories. Dir["#{File.dirname(__FILE__)}/sup...
github
Tapjoy/chore
https://github.com/Tapjoy/chore
spec/chore_spec.rb
Ruby
mit
19
master
2,974
require File.expand_path(File.dirname(__FILE__) + '/spec_helper') describe Chore do before(:each) do Chore.clear_hooks! end it 'should allow you to add a hook' do blk = proc { true } Chore.add_hook(:before_perform,&blk) expect(Chore.hooks_for(:before_perform).first).to be blk end it 'should ...
github
Tapjoy/chore
https://github.com/Tapjoy/chore
spec/support/queues/sqs/fake_objects.rb
Ruby
mit
19
master
466
describe Chore::Queues::SQS do RSpec.shared_context 'fake objects' do let(:queue_name) { 'test_queue' } let(:queue_url) { "http://amazon.sqs.url/queues/#{queue_name}" } let(:queue) do double(Aws::SQS::Queue, attributes: {'VisibilityTimeout' => rand(10)} ) end let(:sqs) do ...
github
Tapjoy/chore
https://github.com/Tapjoy/chore
spec/support/queues/pubsub/fake_objects.rb
Ruby
mit
19
master
2,003
describe Chore::Queues::PubSub do RSpec.shared_context 'fake pubsub objects' do let(:queue_name) { 'test_queue' } let(:subscription_name) { queue_name } let(:project_id) { 'test-project' } let(:message_data) { {'class' => 'TestJob', 'args' => [1, 2, '3']}.to_json } let(:message_id) { 'message-id-...
github
Tapjoy/chore
https://github.com/Tapjoy/chore
spec/chore/worker_spec.rb
Ruby
mit
19
master
9,615
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper') describe Chore::Worker do before(:each) do allow(consumer).to receive(:duplicate_message?).and_return(false) end class SimpleJob include Chore::Job queue_options :name => 'test', :publisher => FakePublisher, :max_attem...
github
Tapjoy/chore
https://github.com/Tapjoy/chore
spec/chore/duplicate_detector_spec.rb
Ruby
mit
19
master
3,115
require 'spec_helper' require 'securerandom' describe Chore::DuplicateDetector do class FakeDalli def initialize @store = {} end def add(id, val, ttl=0) if @store[id] && @store[id][:inserted] + @store[id][:ttl] > Time.now.to_i return false else @store[id] = {:val => val,...
github
Tapjoy/chore
https://github.com/Tapjoy/chore
spec/chore/job_spec.rb
Ruby
mit
19
master
3,536
require 'spec_helper' describe Chore::Job do let(:args) { [1,2, { :a => :hash }] } let(:config) { { :name => 'test_queue', :publisher => Chore::Publisher } } before(:each) do TestJob.queue_options config end after(:each) do # Reset the config TestJob.instance_variable_set(:@chore_options, nil) ...
github
Tapjoy/chore
https://github.com/Tapjoy/chore
spec/chore/cli_spec.rb
Ruby
mit
19
master
6,966
require 'spec_helper' class TestJob2 include Chore::Job end describe Chore::CLI do let(:cli) { Chore::CLI.send(:new) } describe ".register_option" do let(:cli) { Chore::CLI.instance } it 'should allow configuration options to be registered externally' do args = ['some','args'] Chore::CLI.r...
github
Tapjoy/chore
https://github.com/Tapjoy/chore
spec/chore/manager_spec.rb
Ruby
mit
19
master
1,330
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper') require 'timeout' describe Chore::Manager do let(:fetcher) { double(:start => nil) } let(:opts) { { :num_workers => 4, :other_opt => 'hi', :fetcher => fetcher } } before(:each) do Chore.configure {|c| c.fetcher = fetcher; c.worker_strateg...
github
Tapjoy/chore
https://github.com/Tapjoy/chore
spec/chore/hooks_spec.rb
Ruby
mit
19
master
1,205
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper') class TestHooks include Chore::Hooks end describe Chore::Hooks do let(:test_instance){ TestHooks.new } it 'should respond_to run_hooks_for' do expect(test_instance).to respond_to(:run_hooks_for) end it 'should call a defined hook' do ...
github
Tapjoy/chore
https://github.com/Tapjoy/chore
spec/chore/consumer_spec.rb
Ruby
mit
19
master
1,324
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper') describe Chore::Consumer do let(:queue) { "test" } let(:options) { {} } let(:consumer) { Chore::Consumer.new(queue) } let(:message) { "message" } it 'should have a consume method' do expect(consumer).to respond_to :consume end it ...
github
Tapjoy/chore
https://github.com/Tapjoy/chore
spec/chore/fetcher_spec.rb
Ruby
mit
19
master
794
require 'spec_helper' class TestConsumer < Chore::Consumer def initialize(queue_name, opts={}) end def consume # just something that looks like an SQS message msg = OpenStruct.new( :id => 1, :body => "test" ) yield msg if block_given? end end describe Chore::Fetcher do let(:manager) { double("m...
github
Tapjoy/chore
https://github.com/Tapjoy/chore
spec/chore/signal_spec.rb
Ruby
mit
19
master
6,383
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper') describe Chore::Signal do let(:signal_handlers) {{}} before :each do allow(::Signal).to receive(:trap) do |signal, command=nil, &block| if command signal_handlers.delete(signal) else signal_handlers[signal] = block...
github
Tapjoy/chore
https://github.com/Tapjoy/chore
spec/chore/strategies/worker/single_worker_strategy_spec.rb
Ruby
mit
19
master
1,614
require 'spec_helper' describe Chore::Strategy::SingleWorkerStrategy do let(:manager) { double('Manager') } let(:job_timeout) { 60 } let(:job) { Chore::UnitOfWork.new(SecureRandom.uuid, nil, 'test', job_timeout, Chore::Encoder::JsonEncoder.encode(Chore::PayloadHandler.job_hash(TestJob, [1,2,"3"])), 0) } subjec...
github
Tapjoy/chore
https://github.com/Tapjoy/chore
spec/chore/strategies/worker/preforked_worker_strategy_spec.rb
Ruby
mit
19
master
6,988
require 'spec_helper' describe Chore::Strategy::PreForkedWorkerStrategy do let(:manager) { double('manager') } let(:socket) { double('socket') } let(:pipe) { double('pipe') } let(:worker) { double('worker') } let(:worker_manager) { Chore::Strategy::WorkerManager.new(socket) } let(:strategy) ...
github
Tapjoy/chore
https://github.com/Tapjoy/chore
spec/chore/strategies/worker/forked_worker_strategy_spec.rb
Ruby
mit
19
master
8,570
require 'spec_helper' require 'securerandom' describe Chore::Strategy::ForkedWorkerStrategy do let(:manager) { double('manager') } let(:forker) do strategy = Chore::Strategy::ForkedWorkerStrategy.new(manager) allow(strategy).to receive(:exit!) strategy end let(:consumer) { double('consumer', :compl...
github
Tapjoy/chore
https://github.com/Tapjoy/chore
spec/chore/strategies/worker/helpers/preforked_worker_spec.rb
Ruby
mit
19
master
8,885
require 'spec_helper' describe Chore::Strategy::PreforkedWorker do before(:each) do allow_any_instance_of(Chore::Strategy::PreforkedWorker).to receive(:post_fork_setup) end let(:preforkedworker) { Chore::Strategy::PreforkedWorker.new } let(:socket) { double("socket") } let(:work) { d...
github
Tapjoy/chore
https://github.com/Tapjoy/chore
spec/chore/strategies/worker/helpers/worker_killer_spec.rb
Ruby
mit
19
master
3,391
require 'spec_helper' require 'get_process_mem' describe Chore::Strategy::WorkerKiller do let(:memory_limit) { 1024 } let(:request_limit) { 100 } let(:check_cycle) { 16 } let(:worker_killer) { Chore::Strategy::WorkerKiller.new } let(:process_mem_obj) { double('process_mem_obj', bytes: 10) } con...
github
Tapjoy/chore
https://github.com/Tapjoy/chore
spec/chore/strategies/worker/helpers/worker_manager_spec.rb
Ruby
mit
19
master
12,089
require 'spec_helper' require 'chore/signal' require 'chore/strategies/worker/helpers/worker_manager' describe Chore::Strategy::WorkerManager do let(:master_socket) { double('master_socket') } let(:worker_manager) { Chore::Strategy::WorkerManager.new(master_socket) } let(:worker_pid_1) { 1 } let(:socket_1) ...
github
Tapjoy/chore
https://github.com/Tapjoy/chore
spec/chore/strategies/worker/helpers/worker_info_spec.rb
Ruby
mit
19
master
373
require 'spec_helper' describe Chore::Strategy::WorkerInfo do let(:pid) { 1 } let(:worker_info) { Chore::Strategy::WorkerInfo.new(pid) } context '#initialize' do it 'should initialize the WorkerInfo with a pid' do wi = Chore::Strategy::WorkerInfo.new(pid) expect(wi.pid).to equal(pid) ...
github
Tapjoy/chore
https://github.com/Tapjoy/chore
spec/chore/strategies/worker/helpers/work_distributor_spec.rb
Ruby
mit
19
master
5,089
require 'spec_helper' require 'chore/strategies/worker/helpers/work_distributor' describe Chore::Strategy::WorkDistributor do let(:timestamp) { Time.now } let(:manager) { double('manager') } let(:worker) { Chore::Strategy::WorkerInfo.new(1) } let(:consumer) { double('consumer') } let(:job) do Chore::Unit...
github
Tapjoy/chore
https://github.com/Tapjoy/chore
spec/chore/strategies/worker/helpers/ipc_spec.rb
Ruby
mit
19
master
4,564
require 'spec_helper' require 'socket' describe Chore::Strategy::Ipc do class DummyClass include Chore::Strategy::Ipc end before(:each) do @dummy_instance = DummyClass.new end let(:socket) { double('socket') } let(:connection) { double('socket') } let(:message) { "test mes...
github
Tapjoy/chore
https://github.com/Tapjoy/chore
spec/chore/strategies/consumer/throttled_consumer_strategy_spec.rb
Ruby
mit
19
master
5,960
require 'spec_helper' class TestConsumer < Chore::Consumer def initialize(queue_name, opts={}) end def consume # just something that looks like an SQS message msg = OpenStruct.new( :id => 1, :body => "test" ) yield msg if block_given? end end class NoQueueConsumer < Chore::Consumer def initiali...
github
Tapjoy/chore
https://github.com/Tapjoy/chore
spec/chore/strategies/consumer/threaded_consumer_strategy_spec.rb
Ruby
mit
19
master
2,918
require 'spec_helper' class TestConsumer < Chore::Consumer def initialize(queue_name, opts={}) end def consume # just something that looks like an SQS message msg = OpenStruct.new( :id => 1, :body => "test" ) yield msg if block_given? end end class NoQueueConsumer < Chore::Consumer def initiali...
github
Tapjoy/chore
https://github.com/Tapjoy/chore
spec/chore/strategies/consumer/single_consumer_strategy_spec.rb
Ruby
mit
19
master
1,023
require 'spec_helper' describe Chore::Strategy::SingleConsumerStrategy do let(:fetcher) { double("fetcher") } let(:manager) { double("manager") } let(:consumer) { double("consumer") } let(:test_queues) { ["test-queue"] } let(:strategy) { Chore::Strategy::SingleConsumerStrategy.new(fetcher) } let(:received_...
github
Tapjoy/chore
https://github.com/Tapjoy/chore
spec/chore/strategies/consumer/batcher_spec.rb
Ruby
mit
19
master
3,462
require 'spec_helper' describe Chore::Strategy::Batcher do let(:batch_size) { 5 } let(:callback) { double("callback") } subject do batcher = Chore::Strategy::Batcher.new(batch_size) batcher.callback = callback batcher end context 'with no items' do it 'should not be ready' do expect(su...
github
Tapjoy/chore
https://github.com/Tapjoy/chore
spec/chore/queues/sqs_spec.rb
Ruby
mit
19
master
1,754
require 'spec_helper' describe Chore::Queues::SQS do include_context 'fake objects' context "when managing queues" do before(:each) do allow(Aws::SQS::Client).to receive(:new).and_return(sqs) allow(sqs).to receive(:create_queue).and_return(queue) allow(sqs).to receive(:delete_queue).and_retu...
github
Tapjoy/chore
https://github.com/Tapjoy/chore
spec/chore/queues/pubsub_spec.rb
Ruby
mit
19
master
6,777
require 'spec_helper' describe Chore::Queues::PubSub do include_context 'fake pubsub objects' let(:topic_admin) { double('topic_admin') } let(:subscription_admin) { double('subscription_admin') } let(:topic_path) { "projects/test/topics/#{queue_name}" } let(:subscription_path) { "projects/test/subscriptions...
github
Tapjoy/chore
https://github.com/Tapjoy/chore
spec/chore/queues/pubsub/publisher_spec.rb
Ruby
mit
19
master
2,233
require 'spec_helper' describe Chore::Queues::PubSub::Publisher do include_context 'fake pubsub objects' let(:spec_publisher) { Chore::Queues::PubSub::Publisher.new } let(:job) { {'class' => 'TestJob', 'args'=>[1,2,'3']} } let(:publish_result) { double('Google::Cloud::PubSub::Message', message_id: message_id)...
github
Tapjoy/chore
https://github.com/Tapjoy/chore
spec/chore/queues/pubsub/consumer_spec.rb
Ruby
mit
19
master
8,291
require 'spec_helper' describe Chore::Queues::PubSub::Consumer do include_context 'fake pubsub objects' let(:options) { {} } let(:consumer) { Chore::Queues::PubSub::Consumer.new(queue_name) } let(:job) { {'class' => 'TestJob', 'args'=>[1,2,'3']} } let(:backoff_func) { Proc.new { 2 + 2 } } # Since a messa...
github
Tapjoy/chore
https://github.com/Tapjoy/chore
spec/chore/queues/filesystem/filesystem_consumer_spec.rb
Ruby
mit
19
master
6,542
require 'spec_helper' # This test is actually testing both the publisher and the consumer behavior but what we # really want to validate is that they can pass messages off to each other. Hard coding in # the behavior of each in two separate tests was becoming a mess and would be hard to maintain. describe Chore::Queue...
github
Tapjoy/chore
https://github.com/Tapjoy/chore
spec/chore/queues/sqs/consumer_spec.rb
Ruby
mit
19
master
7,176
require 'spec_helper' describe Chore::Queues::SQS::Consumer do include_context 'fake objects' let(:options) { {} } let(:consumer) { Chore::Queues::SQS::Consumer.new(queue_name) } let(:job) { {'class' => 'TestJob', 'args'=>[1,2,'3']} } let(:backoff_func) { Proc.new { 2 + 2 } } let(:receive_message_result)...
github
Tapjoy/chore
https://github.com/Tapjoy/chore
spec/chore/queues/sqs/publisher_spec.rb
Ruby
mit
19
master
2,262
require 'spec_helper' describe Chore::Queues::SQS::Publisher do include_context 'fake objects' let(:publisher) { Chore::Queues::SQS::Publisher.new } let(:job) { {'class' => 'TestJob', 'args'=>[1,2,'3']}} let(:send_message_result) { double(Aws::SQS::Types::SendMessageResult, :data => job) } before(:each) do...
github
Tapjoy/chore
https://github.com/Tapjoy/chore
spec/chore/encoders/json_encoder_spec.rb
Ruby
mit
19
master
291
require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper') describe Chore::Encoder::JsonEncoder do it 'should have an encode method' do expect(subject).to respond_to :encode end it 'should have a decode method' do expect(subject).to respond_to :decode end end
github
Tapjoy/chore
https://github.com/Tapjoy/chore
lib/chore.rb
Ruby
mit
19
master
7,823
require 'ostruct' require 'logger' # Require chore files require 'chore/version' require 'chore/unit_of_work' require 'chore/configuration' require 'chore/cli' require 'chore/consumer' require 'chore/job' require 'chore/encoders/json_encoder' require 'chore/manager' require 'chore/publisher' require 'chore/util' requi...
github
Tapjoy/chore
https://github.com/Tapjoy/chore
lib/chore/consumer.rb
Ruby
mit
19
master
3,553
module Chore # Raised when Chore is booting up, but encounters a set of configuration that is impossible to boot from. Typically # you'll find additional information around the cause of the exception by examining the logfiles. # You can raise this exception if your queue is in a terrible state and must shut down....
github
Tapjoy/chore
https://github.com/Tapjoy/chore
lib/chore/publisher.rb
Ruby
mit
19
master
1,420
module Chore # Base class for a Chore Publisher. Provides the interface that a Chore::Publisher implementation should adhere to. class Publisher DEFAULT_OPTIONS = { :encoder => Encoder::JsonEncoder } attr_accessor :options # @param [Hash] opts def initialize(opts={}) self.options = DEFAULT_O...
github
Tapjoy/chore
https://github.com/Tapjoy/chore
lib/chore/worker.rb
Ruby
mit
19
master
6,095
require 'chore/util' require 'chore/job' module Chore class TimeoutError < StandardError end # Worker is one of the core classes in Chore. It's responsible for most of the logic # relating to actually processing a job. A given worker will take an amount of +work+ # and then process it all until either the w...
github
Tapjoy/chore
https://github.com/Tapjoy/chore
lib/chore/signal.rb
Ruby
mit
19
master
6,473
module Chore # Provides smarter signal handling capabilities than Ruby's built-in # Signal class. Specifically it runs callbacks in a separate thread since: # (1) Ruby 2.0 cannot obtain locks in the main Signal thread # (2) Doing so can result in deadlocks in Ruby 1.9.x. # # Ruby's core implementation...
github
Tapjoy/chore
https://github.com/Tapjoy/chore
lib/chore/unit_of_work.rb
Ruby
mit
19
master
1,342
module Chore # Simple class to hold job processing information. # Has six attributes: # * +:id+ The queue implementation specific identifier for this message. # * +:receipt_handle+ The queue implementation specific identifier for the receipt of this message. # * +:queue_name+ The name of the queue the job cam...
github
Tapjoy/chore
https://github.com/Tapjoy/chore
lib/chore/fetcher.rb
Ruby
mit
19
master
1,102
module Chore class Fetcher #:nodoc: attr_reader :manager, :consumers def initialize(manager) @stopping = false @manager = manager @strategy = Chore.config.consumer_strategy.new(self) end # Starts the fetcher with the configured Consumer Strategy. This will begin consuming messages ...
github
Tapjoy/chore
https://github.com/Tapjoy/chore
lib/chore/manager.rb
Ruby
mit
19
master
2,308
require 'multi_json' require 'chore/worker' require 'chore/fetcher' module Chore # Manages the interactions between fetching messages (Consumer Strategy), and working over them (Worker Strategy) class Manager include Util def initialize() Chore.logger.info "Booting Chore #{Chore::VERSION}" Cho...
github
Tapjoy/chore
https://github.com/Tapjoy/chore
lib/chore/payload_handler.rb
Ruby
mit
19
master
626
module Chore class PayloadHandler extend Util def self.payload_class(message) constantize(message["class"]) end # Takes UnitOfWork and return decoded message def self.decode(item) Encoder::JsonEncoder.decode(item.message) end def self.payload(message) message["args"] ...
github
Tapjoy/chore
https://github.com/Tapjoy/chore
lib/chore/hooks.rb
Ruby
mit
19
master
1,093
module Chore # Abstracts the notion of registering and running hooks during certain points in the lifecycle of chore # processing work. module Hooks # Helper method to look up, and execute hooks based on an event name. # Hooks are assumed to be methods defined on `self` that are of the pattern # hook...
github
Tapjoy/chore
https://github.com/Tapjoy/chore
lib/chore/duplicate_detector.rb
Ruby
mit
19
master
2,657
module Chore class DuplicateDetector #:nodoc: def initialize(opts={}) @timeouts = {} @dupe_on_cache_failure = opts.fetch(:dupe_on_cache_failure) { false } @timeout = opts.fetch(:timeout) { 0 } @timeout_offset = opts.fetch(:timeout_offset) { 10 } # Default...
github
Tapjoy/chore
https://github.com/Tapjoy/chore
lib/chore/job.rb
Ruby
mit
19
master
4,963
require 'chore/hooks' require 'chore/util' require 'chore/encoders/json_encoder' module Chore # <tt>Chore::Job</tt> is the module which gives your job classes the methods they need to be published # and run within Chore. You cannot have a Job in Chore that does not include this module module Job # An excep...
github
Tapjoy/chore
https://github.com/Tapjoy/chore
lib/chore/configuration.rb
Ruby
mit
19
master
370
module Chore # Wrapper around an OpenStruct to define configuration data # TODO: Add required opts, and validate that they're set class Configuration < OpenStruct # Helper method to make merging Hashes into OpenStructs easier def merge_hash(hsh={}) hsh.keys.each do |k| self.send("#{k.to_sym}...
github
Tapjoy/chore
https://github.com/Tapjoy/chore
lib/chore/railtie.rb
Ruby
mit
19
master
505
module Chore # Railtie for incorporating chores rake tasks into your Rails application class Railtie < Rails::Railtie rake_tasks do Dir[File.join(File.dirname(__FILE__),'tasks/*.task')].each { |f| load f } end config.after_initialize do if Chore.configuring? # Reset the logger on fo...
github
Tapjoy/chore
https://github.com/Tapjoy/chore
lib/chore/cli.rb
Ruby
mit
19
master
11,339
require 'pp' require 'singleton' require 'optparse' require 'chore' require 'erb' require 'set' require 'chore/manager' module Chore #:nodoc: # Class that handles the command line interactions in Chore. # It primarily is responsible for invoking the Chore process with the provided configuration # to begin proc...
github
Tapjoy/chore
https://github.com/Tapjoy/chore
lib/chore/util.rb
Ruby
mit
19
master
561
module Chore # Collection of utilities and helpers used by Chore internally module Util # To avoid bringing in all of active_support, we implemented constantize here def constantize(camel_cased_word) names = camel_cased_word.split('::') names.shift if names.empty? || names.first.empty? ...
github
Tapjoy/chore
https://github.com/Tapjoy/chore
lib/chore/queues/pubsub.rb
Ruby
mit
19
master
5,228
module Chore module Queues module PubSub REQUIRED_LIBRARY = "google/cloud/pubsub".freeze MIN_VERSION = Gem::Version.new('3.0.0') # Creates a configured PubSub client with the given options # Creates a GCP Pub/Sub client using global configuration def self.pubsub_client requi...
github
Tapjoy/chore
https://github.com/Tapjoy/chore
lib/chore/queues/sqs.rb
Ruby
mit
19
master
3,740
module Chore module Queues module SQS REQUIRED_LIBRARY = "aws-sdk-sqs".freeze MIN_VERSION = Gem::Version.new("1") def self.sqs_client require REQUIRED_LIBRARY # Verify compatible version gem_version = Gem::Version.new(Aws::SQS::GEM_VERSION) if gem_version < MIN_...
github
Tapjoy/chore
https://github.com/Tapjoy/chore
lib/chore/queues/pubsub/publisher.rb
Ruby
mit
19
master
1,383
require 'chore/publisher' module Chore module Queues module PubSub # GCP Pub/Sub Publisher, for writing messages to GCP Pub/Sub from Chore class Publisher < Chore::Publisher # @param [Hash] opts Publisher options def initialize(opts={}) super @pubsub_publisher = {}...
github
Tapjoy/chore
https://github.com/Tapjoy/chore
lib/chore/queues/pubsub/consumer.rb
Ruby
mit
19
master
5,628
require 'google/cloud/pubsub' require 'chore/duplicate_detector' module Chore module Queues module PubSub # GCP Pub/Sub Consumer for Chore. Requests messages from GCP Pub/Sub and passes them to be worked on. # Also controls acknowledging completed messages within GCP Pub/Sub. class Consumer < C...
github
Tapjoy/chore
https://github.com/Tapjoy/chore
lib/chore/queues/sqs/publisher.rb
Ruby
mit
19
master
1,945
require 'chore/publisher' module Chore module Queues module SQS # SQS Publisher, for writing messages to SQS from Chore class Publisher < Chore::Publisher @@reset_next = true # @param [Hash] opts Publisher options def initialize(opts={}) super @sqs_queues ...
github
Tapjoy/chore
https://github.com/Tapjoy/chore
lib/chore/queues/sqs/consumer.rb
Ruby
mit
19
master
6,242
require 'aws-sdk-sqs' require 'chore/duplicate_detector' module Chore module Queues module SQS # SQS Consumer for Chore. Requests messages from SQS and passes them to be worked on. Also controls # deleting completed messages within SQS. class Consumer < Chore::Consumer # Initialize the ...
github
Tapjoy/chore
https://github.com/Tapjoy/chore
lib/chore/queues/filesystem/consumer.rb
Ruby
mit
19
master
9,011
require 'fileutils' require 'chore/queues/filesystem/filesystem_queue' module Chore module Queues module Filesystem # This is the consuming side of the file system queue. This class consumes jobs created by # FilesystemPublisher#publish. The root of the file system queue is configured in # Ch...
github
Tapjoy/chore
https://github.com/Tapjoy/chore
lib/chore/queues/filesystem/filesystem_queue.rb
Ruby
mit
19
master
2,382
# Common methods used by FilesystemConsumer and FilesystemPublisher for dealing with the # directories which implement the queue. module Chore::FilesystemQueue # Local directory for new jobs to be placed NEW_JOB_DIR = "new" # Local directory for jobs currently in-process to be moved IN_PROGRESS_DIR = "inprogre...
github
Tapjoy/chore
https://github.com/Tapjoy/chore
lib/chore/queues/filesystem/publisher.rb
Ruby
mit
19
master
1,706
require 'chore/queues/filesystem/filesystem_queue' module Chore module Queues module Filesystem # Publisher for writing jobs to the local filesystem. Useful for testing in offline environments or # when queuing implementations are irrelevent to the task at hand, such as local development of new jobs...
github
Tapjoy/chore
https://github.com/Tapjoy/chore
lib/chore/strategies/consumer/single_consumer_strategy.rb
Ruby
mit
19
master
1,617
module Chore module Strategy # Consumer strategy for requesting batches of work in a linear fashion. Ideally used for running # a single Chore job locally in a development environment where performance or throughput may not matter. # <tt>SingleConsumerStrategy</tt> will raise an exception if you're confi...
github
Tapjoy/chore
https://github.com/Tapjoy/chore
lib/chore/strategies/consumer/threaded_consumer_strategy.rb
Ruby
mit
19
master
3,445
require 'chore/strategies/consumer/batcher' module Chore module Strategy class ThreadedConsumerStrategy #:nodoc attr_accessor :batcher Chore::CLI.register_option 'batch_size', '--batch-size SIZE', Integer, 'Number of items to collect for a single worker to process' Chore::CLI.register_option 'b...
github
Tapjoy/chore
https://github.com/Tapjoy/chore
lib/chore/strategies/consumer/batcher.rb
Ruby
mit
19
master
2,622
module Chore module Strategy # Handles holding jobs in memory until such time as the batch has become full, per the developers configured threshold, # or enough time elapses that Chore determines to not wait any longer (20 seconds by default) class Batcher attr_accessor :callback attr_accesso...