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
frozon/passbook
https://github.com/frozon/passbook
lib/rack/passbook_rack.rb
Ruby
mit
232
master
3,463
module Rack class PassbookRack def initialize(app) @app = app @parameters = {} end def call(env) @parameters['authToken'] = env['HTTP_AUTHORIZATION'].gsub(/ApplePass /,'') if env['HTTP_AUTHORIZATION'] @parameters.merge!(Rack::Utils.parse_nested_query(env['QUERY_STRING'])) m...
github
frozon/passbook
https://github.com/frozon/passbook
lib/commands/commands.rb
Ruby
mit
232
master
994
$:.push File.expand_path('../', __FILE__) require 'commands/build' require 'commands/generate' #require 'commands/serve' # this was added for testability because I couldn't figure out something better. private def determine_directory! files = Dir['*/pass.json'] @directory ||= case files.length w...
github
frozon/passbook
https://github.com/frozon/passbook
lib/commands/generate.rb
Ruby
mit
232
master
1,424
require 'fileutils' command :generate do |c| c.syntax = 'pk generate PASSNAME' c.summary = 'Generates a template pass directory' c.description = '' c.example 'description', 'pk generate mypass' c.option '-T', '--type [boardingPass|coupon|eventTicket|storeCard|generic]', 'Type of pass' c.action do |args, ...
github
frozon/passbook
https://github.com/frozon/passbook
lib/commands/build.rb
Ruby
mit
232
master
2,057
command :build do |c| c.syntax = 'pk build [PASSNAME]' c.summary = 'Creates a .pkpass archive' c.description = '' c.example 'description', 'pk archive mypass -o mypass.pkpass' c.option '-w', '--wwdc_certificate /path/to/wwdc_cert.pem', 'Pass certificate' c.option '-k', '--p12_key /path/to/cert.p12' c.opt...
github
frozon/passbook
https://github.com/frozon/passbook
lib/passbook/signer.rb
Ruby
mit
232
master
1,380
require 'openssl' require 'base64' module Passbook class Signer attr_accessor :certificate, :password, :key, :wwdc_cert, :key_hash, :p12_cert def initialize(params = {}) @certificate = params[:certificate] || Passbook.p12_certificate @password = params[:password] || Passbook.p12_password ...
github
frozon/passbook
https://github.com/frozon/passbook
lib/passbook/push_notification.rb
Ruby
mit
232
master
494
module Passbook class PushNotification class << self def pusher @pusher ||= Grocer.pusher( :certificate => Passbook.notification_cert, :passphrase => Passbook.notification_passphrase || "", :gateway => Passbook.notification_gateway ) end def send_no...
github
frozon/passbook
https://github.com/frozon/passbook
lib/passbook/pkpass.rb
Ruby
mit
232
master
3,099
require 'digest/sha1' require 'openssl' require 'zip' require 'base64' module Passbook class PKPass attr_accessor :pass, :manifest_files, :signer TYPES = ['boarding-pass', 'coupon', 'event-ticket', 'store-card', 'generic'] def initialize(pass, init_signer = nil) @pass = pass @mani...
github
frozon/passbook
https://github.com/frozon/passbook
spec/spec_helper.rb
Ruby
mit
232
master
314
require 'rubygems' require 'bundler' require 'json' require 'simplecov' require 'grocer' SimpleCov.start Dir['lib/passbook/**/*.rb'].each {|f| require File.join(File.dirname(__FILE__), '..', f.gsub(/.rb/, ''))} Dir['lib/rack/**/*.rb'].each {|f| require File.join(File.dirname(__FILE__), '..', f.gsub(/.rb/, ''))}
github
frozon/passbook
https://github.com/frozon/passbook
spec/lib/passbook/signer_spec.rb
Ruby
mit
232
master
4,151
require 'spec_helper' describe 'Signer' do context 'signatures' do context 'p12_cert_and_key' do context 'pem p12 certs' do context 'using config file certificates' do before do Passbook.should_receive(:p12_password).and_return 'password' Passbook.should_receive(...
github
frozon/passbook
https://github.com/frozon/passbook
spec/lib/passbook/push_notification_spec.rb
Ruby
mit
232
master
1,026
require 'spec_helper' require 'grocer' describe Passbook::PushNotification do context 'send notification' do let(:grocer_pusher) {double 'Grocer'} let(:notification) {double 'Grocer::Notification'} let(:notification_settings) {{:certificate => './notification_cert.pem', :gateway => 'honeybadger.apple.c...
github
frozon/passbook
https://github.com/frozon/passbook
spec/lib/passbook/pkpass_spec.rb
Ruby
mit
232
master
2,708
require 'spec_helper' describe Passbook do let (:content) {{ :formatVersion => 1, :passTypeIdentifier => "pass.passbook.test", :serialNumber => "001", :teamIdentifier => ENV['APPLE_TEAM_ID'], :relevantDate => "2012-10-02", :locations => [ #TODO { :longitude => 2.35403, :latit...
github
frozon/passbook
https://github.com/frozon/passbook
spec/lib/rack/passbook_rack_spec.rb
Ruby
mit
232
master
7,849
require 'spec_helper' describe Rack::PassbookRack do let(:register_delete_path) {'/v1/devices/fe772e610be3efafb65ed77772ca311a/registrations/pass.com.polyglotprogramminginc.testpass/27-1'} let(:register_delete_params) {{'deviceLibraryIdentifier' => 'fe772e610be3efafb65ed77772ca311a', 'passTypeIdentifier' => ...
github
frozon/passbook
https://github.com/frozon/passbook
spec/lib/commands/commands_spec_helper.rb
Ruby
mit
232
master
1,534
require 'spec_helper' require 'terminal-table' require 'commander/import' require 'utils/command_utils' def load_commands Dir['lib/commands/**/*.rb'].each {|f| load File.join(File.dirname(__FILE__), '../../..', f) require File.join(File.dirname(__FILE__), '../../..', f.gsub(/.rb/, '')) } end def mock_term...
github
frozon/passbook
https://github.com/frozon/passbook
spec/lib/commands/generate_spec.rb
Ruby
mit
232
master
2,530
require 'lib/commands/commands_spec_helper' require 'passbook' describe 'Generate' do before :each do $stderr = StringIO.new mock_terminal end context 'command' do specify 'no options' do run_command 'generate' do @output.string.should eq 'Enter a passbook name: ' end end ...
github
frozon/passbook
https://github.com/frozon/passbook
spec/lib/commands/build_spec.rb
Ruby
mit
232
master
3,492
require 'lib/commands/commands_spec_helper' require 'passbook' describe 'Build' do before :each do $stderr = StringIO.new mock_terminal end context 'command' do specify 'missing directory' do run_command 'build' do @output.string.should eq "\e[31mMissing argument\e[0m\n" end ...
github
frozon/passbook
https://github.com/frozon/passbook
spec/lib/commands/commands_spec.rb
Ruby
mit
232
master
3,329
require 'lib/commands/commands_spec_helper' describe 'Commands' do before :each do program :version, '1.2.3' program :description, "Honey Badger Don't Care" end context 'determine directory' do specify 'no directories' do Dir.should_receive(:[]).and_return [] determine_directory! ...
github
mattfinlayson/ansible-consul
https://github.com/mattfinlayson/ansible-consul
Vagrantfile
Ruby
apache-2.0
232
master
878
# -*- mode: ruby -*- # vi: set ft=ruby : Vagrant.configure("2") do |config| config.vm.network :private_network, ip: "192.168.33.99" config.vm.network :forwarded_port, guest: 22, host: 2299 config.vm.define 'ubuntu1404-amd64' do |instance| # Every Vagrant virtual environment requires a box to build off of. ...
github
mattfinlayson/ansible-consul
https://github.com/mattfinlayson/ansible-consul
test/integration/ui/serverspec/consul_spec.rb
Ruby
apache-2.0
232
master
588
require 'spec_helper' describe 'Consul' do describe service('consul') do it { should be_enabled } it { should be_running } end describe service('nginx') do it { should be_enabled } it { should be_running } end if ['debian', 'ubuntu'].include?(os[:family]) describe file('/etc/nginx/sites...
github
mattfinlayson/ansible-consul
https://github.com/mattfinlayson/ansible-consul
test/integration/default/serverspec/consul_spec.rb
Ruby
apache-2.0
232
master
969
require 'spec_helper' describe 'Consul' do describe service('consul') do it { should be_enabled } it { should be_running } end describe user('consul') do it { should exist } it { should belong_to_group 'consul' } end %w(/opt/consul /opt/consul/bin /opt/consul/data /etc/consul.d ).each do |d...
github
mattfinlayson/ansible-consul
https://github.com/mattfinlayson/ansible-consul
test/integration/logs/serverspec/consul_spec.rb
Ruby
apache-2.0
232
master
412
require 'spec_helper' describe 'Consul' do describe service('consul') do it { should be_enabled } it { should be_running } end describe file('/var/log/consul') do it { should be_directory } it { should be_owned_by('consul') } end describe file('/var/log/consul/consul.log') do it { shoul...
github
mattfinlayson/ansible-consul
https://github.com/mattfinlayson/ansible-consul
test/integration/dns/serverspec/consul_spec.rb
Ruby
apache-2.0
232
master
340
require 'spec_helper' describe 'Consul' do describe service('consul') do it { should be_enabled } it { should be_running } end describe file('/etc/consul.conf') do it { should be_file } its(:content) { should match /"dns": 8200/ } its(:content) { should match /"recursors": \["8.8.8.8", "8.8....
github
mattfinlayson/ansible-consul
https://github.com/mattfinlayson/ansible-consul
test/integration/dns/serverspec/dnsmasq_spec.rb
Ruby
apache-2.0
232
master
453
require 'spec_helper' describe 'dnsmasq' do describe service('dnsmasq') do it { should be_enabled } it { should be_running } end describe file('/etc/dnsmasq.d/10-consul') do it { should be_file } its(:content) { should match /server=\/consul.\/127.0.1.1#8200/ } end describe file('/etc/dnsma...
github
mattfinlayson/ansible-consul
https://github.com/mattfinlayson/ansible-consul
test/integration/atlas_configuration/serverspec/consul_spec.rb
Ruby
apache-2.0
232
master
450
require 'spec_helper' describe 'Consul' do describe service('consul') do it { should be_enabled } end describe file('/etc/consul.conf') do it { should be_file } its(:content) { should match /"server": true/ } its(:content) { should match /"atlas_infrastructure": "test_infrastructure"/ } its(...
github
mattfinlayson/ansible-consul
https://github.com/mattfinlayson/ansible-consul
test/integration/acls/serverspec/consul_spec.rb
Ruby
apache-2.0
232
master
690
require 'spec_helper' describe 'Consul' do describe service('consul') do it { should be_enabled } it { should be_running } end describe file('/etc/consul.conf') do its(:content) { should match /"acl_datacenter": \"my_datacenter\"/ } its(:content) { should match /"acl_default_policy": \"deny\"/ }...
github
mattfinlayson/ansible-consul
https://github.com/mattfinlayson/ansible-consul
test/integration/dynamic_binding/serverspec/consul_dynamic_binding_spec.rb
Ruby
apache-2.0
232
master
633
require 'spec_helper' describe 'Consul' do describe file('/etc/consul.conf') do it { should be_file } its(:content) { should_not match /"bind_addr":/ } end if ['debian', 'ubuntu'].include?(os[:family]) describe file('/etc/init/consul.conf') do it { should be_file } its(:content) { should...
github
mattfinlayson/ansible-consul
https://github.com/mattfinlayson/ansible-consul
test/integration/tls_client/serverspec/consul_tls_client_spec.rb
Ruby
apache-2.0
232
master
1,643
require 'spec_helper' describe 'Consul client with TLS enabled' do describe file('/opt/consul/cert') do it { should be_directory } it { should be_owned_by('consul') } end %w(consul.crt consul.key).each do |file| describe file("/opt/consul/cert/#{file}") do it { should be_file } it { sho...
github
mattfinlayson/ansible-consul
https://github.com/mattfinlayson/ansible-consul
test/integration/custom_templates/serverspec/consul_custom_templates_spec.rb
Ruby
apache-2.0
232
master
971
require 'spec_helper' describe 'Consul' do if ['debian', 'ubuntu'].include?(os[:family]) describe 'custom Upstart service' do describe file('/etc/init/consul.conf') do it { should be_file } its(:content) { should match /\/etc\/service\/consul/} its(:content) { should match /BIND=`i...
github
mattfinlayson/ansible-consul
https://github.com/mattfinlayson/ansible-consul
test/integration/tls/serverspec/consul_tls_spec.rb
Ruby
apache-2.0
232
master
1,704
require 'spec_helper' describe 'Consul with TLS enabled' do describe file('/opt/consul/cert') do it { should be_directory } it { should be_owned_by('consul') } end %w(ca.crt consul.crt consul.key).each do |file| describe file("/opt/consul/cert/#{file}") do it { should be_file } it { sho...
github
mattfinlayson/ansible-consul
https://github.com/mattfinlayson/ansible-consul
test/integration/cli/serverspec/consul_spec.rb
Ruby
apache-2.0
232
master
672
require 'spec_helper' describe 'Consul' do describe service('consul') do it { should be_enabled } it { should be_running } end describe user('consul') do it { should exist } it { should belong_to_group 'consul' } end %w(/opt/consul /opt/consul/bin /opt/consul/data /etc/consul.d ).each do |d...
github
jonmagic/grim
https://github.com/jonmagic/grim
grim.gemspec
Ruby
mit
231
master
911
# -*- encoding: utf-8 -*- $:.push File.expand_path("../lib", __FILE__) require "grim/version" Gem::Specification.new do |s| s.name = "grim" s.version = Grim::VERSION s.authors = ["Jonathan Hoyt"] s.email = ["jonmagic@gmail.com"] s.homepage = "http://github.com/jonmagic/grim" s.summa...
github
jonmagic/grim
https://github.com/jonmagic/grim
spec/spec_helper.rb
Ruby
mit
231
master
716
# encoding: UTF-8 require 'benchmark' require 'rubygems' require 'bundler/setup' require 'rbconfig' require 'grim' module FileHelpers def dimensions_for_path(path) width, height = `identify -format '%wx%h' #{path}`.strip.split('x').map(&:to_f) end def fixture_path(name) path = File.expand_path("./spec/...
github
jonmagic/grim
https://github.com/jonmagic/grim
spec/lib/grim_spec.rb
Ruby
mit
231
master
1,223
# encoding: UTF-8 require 'spec_helper' describe Grim do it "should have a default processor" do expect(Grim.processor.class).to eq(Grim::ImageMagickProcessor) end it "should have a VERSION constant" do expect(Grim.const_defined?('VERSION')).to be(true) end it "should have WIDTH constant set to 102...
github
jonmagic/grim
https://github.com/jonmagic/grim
spec/lib/grim/null_logger_spec.rb
Ruby
mit
231
master
256
require 'spec_helper' require "stringio" describe Grim::NullLogger do it "acts like Logger but doesn't log anything" do io = StringIO.new logger = Grim::NullLogger.new(io) logger.debug "hello world" expect(io.string).to eq("") end end
github
jonmagic/grim
https://github.com/jonmagic/grim
spec/lib/grim/multi_processor_spec.rb
Ruby
mit
231
master
1,300
# encoding: UTF-8 require 'spec_helper' describe Grim::MultiProcessor do before(:each) do @failure = Grim::ImageMagickProcessor.new @success = Grim::ImageMagickProcessor.new @extra = Grim::ImageMagickProcessor.new @processor = Grim::MultiProcessor.new([@failure, @success, @extra]) ...
github
jonmagic/grim
https://github.com/jonmagic/grim
spec/lib/grim/image_magick_processor_spec.rb
Ruby
mit
231
master
4,549
# encoding: UTF-8 require 'spec_helper' describe Grim::ImageMagickProcessor do before(:each) do @reset_to = ENV['PATH'] end after(:each) do ENV['PATH'] = @reset_to end describe "#count" do before(:each) do @processor = Grim::ImageMagickProcessor.new end it "should return page co...
github
jonmagic/grim
https://github.com/jonmagic/grim
spec/lib/grim/page_spec.rb
Ruby
mit
231
master
2,382
# encoding: UTF-8 require 'fileutils' require 'spec_helper' describe Grim::Page do after(:all) do FileUtils.rm_rf(tmp_dir) end it "should have number" do expect(Grim::Page.new(Grim::Pdf.new(fixture_path("smoker.pdf")), 1).number).to eq(2) end describe "#save" do before(:all) do @path = tm...
github
jonmagic/grim
https://github.com/jonmagic/grim
spec/lib/grim/pdf_spec.rb
Ruby
mit
231
master
1,545
# encoding: UTF-8 require 'spec_helper' describe Grim::Pdf do it "should not raise NoMethodErrod for File:class " do expect{ pdf = Grim::Pdf.new(fixture_path("smoker.pdf")) }.not_to raise_error(NoMethodError) end it "should have a path" do pdf = Grim::Pdf.new(fixture_path("smoker.pdf")) ...
github
jonmagic/grim
https://github.com/jonmagic/grim
lib/grim.rb
Ruby
mit
231
master
1,601
# encoding: UTF-8 require 'shellwords' module Grim extend self attr_accessor :processor # Default resize output width, any positive integer WIDTH = 1024 # Default image quality, 1 to 100 QUALITY = 90 # Default density, any positive integer DENSITY = 300 # Default colorspace COLORSPACE = "RGB" ...
github
jonmagic/grim
https://github.com/jonmagic/grim
lib/grim/image_magick_processor.rb
Ruby
mit
231
master
2,265
require 'open3' module Grim class ImageMagickProcessor # ghostscript prints out a warning, this regex matches it WarningRegex = /\*\*\*\*.*\n/ DefaultImagemagickPath = 'convert' DefaultGhostScriptPath = 'gs' def initialize(options={}) @imagemagick_path = options[:imagemagick_path] || Defa...
github
jonmagic/grim
https://github.com/jonmagic/grim
lib/grim/multi_processor.rb
Ruby
mit
231
master
611
module Grim class MultiProcessor def initialize(processors) @processors = processors end def count(path) result = "" @processors.each do |processor| result = processor.count(path) break if result != "" end result end def save(pdf, index, path, option...
github
jonmagic/grim
https://github.com/jonmagic/grim
lib/grim/pdf.rb
Ruby
mit
231
master
1,564
# encoding: UTF-8 module Grim class Pdf include Enumerable attr_reader :path # Raises an error if pdf not found and sets some instance # variables if pdf is found. # # path - A String or Path to the pdf # options - A Hash of options. # :pdftotext_path - The String path of w...
github
jonmagic/grim
https://github.com/jonmagic/grim
lib/grim/page.rb
Ruby
mit
231
master
1,911
# encoding: UTF-8 module Grim class Page attr_reader :number # Sets up some instance variables on new instance. # # pdf - the pdf this page belongs to # index - the index of the page in the array of pages # options - A Hash of options. # :pdftotext_path - The String path of whe...
github
dev-sec/windows-baseline
https://github.com/dev-sec/windows-baseline
Rakefile
Ruby
apache-2.0
231
master
1,457
# frozen_string_literal: true require 'cookstyle' require 'rake/testtask' require 'rubocop/rake_task' # Rubocop desc 'Run Rubocop lint checks' task :rubocop do RuboCop::RakeTask.new end RuboCop::RakeTask.new(:cookstyle) do |task| task.options << '--display-cop-names' end # lint the project desc 'Run robocop lin...
github
dev-sec/windows-baseline
https://github.com/dev-sec/windows-baseline
controls/advanced_windows_security_from_best_practices.rb
Ruby
apache-2.0
231
master
83,832
# frozen_string_literal: true title 'advanced windows security from best practices' # control 'windows-base-100' do # impact 1.0 # title 'Enable Strong Encryption for Windows Network Sessions on Clients' # desc 'Microsoft has implemented a variety of security support providers for use with RPC sessions. In a ho...
github
dev-sec/windows-baseline
https://github.com/dev-sec/windows-baseline
controls/windows_firewall_with_advanced_security.rb
Ruby
apache-2.0
231
master
38,966
# frozen_string_literal: true title 'windows firewall with advanced policy' control 'windows-120' do title 'Ensure \'Windows Firewall: Domain: Firewall state\' is set to \'On (recommended)\'' desc 'Select On (recommended) to have Windows Firewall with Advanced Security use the settings for this profile to filter ...
github
dev-sec/windows-baseline
https://github.com/dev-sec/windows-baseline
controls/advanced_audit_policy_configuration.rb
Ruby
apache-2.0
231
master
50,642
# frozen_string_literal: true title 'Advanced Audit Policy Configuration' control 'windows-146' do title 'Ensure \'Audit Credential Validation\' is set to \'Success and Failure\'' desc 'This subcategory reports the results of validation tests on credentials submitted for a user account logon request. These events...
github
dev-sec/windows-baseline
https://github.com/dev-sec/windows-baseline
controls/local_policies.rb
Ruby
apache-2.0
231
master
192,728
# frozen_string_literal: true title 'local policies' control 'windows-010' do title 'Ensure \'Access Credential Manager as a trusted caller\' is set to \'No One\'' desc 'This security setting is used by Credential Manager during Backup and Restore. No accounts should have this user right, as it is only assigned t...
github
dev-sec/windows-baseline
https://github.com/dev-sec/windows-baseline
controls/administrative_templates_user.rb
Ruby
apache-2.0
231
master
23,643
# frozen_string_literal: true title 'Administrative Templates (User)' control 'windows-360' do title 'Ensure \'Enable screen saver\' is set to \'Enabled\'' desc 'This policy setting enables/disables the use of desktop screen savers. The recommended state for this setting is: Enabled.' impact 1.0 tag 'windo...
github
dev-sec/windows-baseline
https://github.com/dev-sec/windows-baseline
controls/account_policies.rb
Ruby
apache-2.0
231
master
16,209
# frozen_string_literal: true title 'account policies' control 'windows-001' do title 'Ensure \'Enforce password history\' is set to \'24 or more password(s)\'' desc 'This policy setting determines the number of renewed, unique passwords that have to be associated with a user account before you can reuse an old p...
github
cookpad/expeditor
https://github.com/cookpad/expeditor
Rakefile
Ruby
mit
231
master
230
require "bundler/gem_tasks" require "rspec/core/rake_task" RSpec::Core::RakeTask.new(:spec) task default: [:spec, :performance_test] desc 'Check performance' task :performance_test do ruby 'scripts/command_performance.rb' end
github
cookpad/expeditor
https://github.com/cookpad/expeditor
expeditor.gemspec
Ruby
mit
231
master
1,312
# coding: utf-8 lib = File.expand_path('../lib', __FILE__) $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) require 'expeditor/version' Gem::Specification.new do |spec| spec.name = "expeditor" spec.version = Expeditor::VERSION spec.authors = ["shohei-yasutake"] spec.email = ...
github
cookpad/expeditor
https://github.com/cookpad/expeditor
examples/example.rb
Ruby
mit
231
master
1,649
require 'expeditor' start_time = Time.now # Create new service (it is containing a thread pool and circuit breaker function) service = Expeditor::Service.new( executor: Concurrent::ThreadPoolExecutor.new( min_threads: 5, # minimum number of threads max_threads: 5, # maximum number of threads max_q...
github
cookpad/expeditor
https://github.com/cookpad/expeditor
examples/circuit_breaker.rb
Ruby
mit
231
master
411
require 'expeditor' service = Expeditor::Service.new i = 1 loop do puts '=' * 100 p i command = Expeditor::Command.new(service: service, timeout: 1) { sleep 0.001 # simulate remote resource access if File.exist?('foo') 'result' else raise 'Demo error' end }.set_fallback { |e| ...
github
cookpad/expeditor
https://github.com/cookpad/expeditor
lib/expeditor.rb
Ruby
mit
231
master
205
require 'expeditor/rolling_number' require 'expeditor/command' require 'expeditor/errors' require 'expeditor/rich_future' require 'expeditor/service' require 'expeditor/status' require 'expeditor/version'
github
cookpad/expeditor
https://github.com/cookpad/expeditor
lib/expeditor/errors.rb
Ruby
mit
231
master
408
require 'concurrent/errors' module Expeditor NotStartedError = Class.new(StandardError) RejectedExecutionError = Concurrent::RejectedExecutionError CircuitBreakError = Class.new(StandardError) AlreadyStartedError = Class.new(StandardError) class DependencyError < StandardError attr :error def initial...
github
cookpad/expeditor
https://github.com/cookpad/expeditor
lib/expeditor/command.rb
Ruby
mit
231
master
6,424
require 'concurrent/ivar' require 'concurrent/executor/safe_task_executor' require 'concurrent/configuration' require 'expeditor/errors' require 'expeditor/rich_future' require 'expeditor/service' require 'expeditor/services' require 'retryable' require 'timeout' module Expeditor class Command def initialize(opt...
github
cookpad/expeditor
https://github.com/cookpad/expeditor
lib/expeditor/rolling_number.rb
Ruby
mit
231
master
1,488
require 'expeditor/status' require 'expeditor/ring_buffer' module Expeditor # A RollingNumber holds some Status objects and it rolls statuses each # `per_time` (default is 1 second). This is done so that the statistics are # recorded gradually with short time interval rahter than reset all the # record every w...
github
cookpad/expeditor
https://github.com/cookpad/expeditor
lib/expeditor/status.rb
Ruby
mit
231
master
1,176
module Expeditor # Thread unsafe. class Status attr_reader :success attr_reader :failure attr_reader :rejection attr_reader :timeout attr_reader :break attr_reader :dependency def initialize set(0, 0, 0, 0, 0, 0) end def increment(type, i = 1) case type when :...
github
cookpad/expeditor
https://github.com/cookpad/expeditor
lib/expeditor/service.rb
Ruby
mit
231
master
3,535
require 'concurrent/executor/thread_pool_executor' module Expeditor class Service attr_reader :executor attr_accessor :fallback_enabled def initialize(opts = {}) @mutex = Mutex.new @executor = opts.fetch(:executor) { Concurrent::ThreadPoolExecutor.new } @threshold = opts.fetch(:thresho...
github
cookpad/expeditor
https://github.com/cookpad/expeditor
lib/expeditor/ring_buffer.rb
Ruby
mit
231
master
2,194
module Expeditor # Circular buffer with user-defined initialization and optimized `move` # implementation. The next element will be always initialized with # user-defined initialization proc. # # Thread unsafe. class RingBuffer # @params [Integer] size def initialize(size, &initialize_proc) ra...
github
cookpad/expeditor
https://github.com/cookpad/expeditor
lib/expeditor/rich_future.rb
Ruby
mit
231
master
813
require 'concurrent/configuration' require 'concurrent/future' module Expeditor class RichFuture < Concurrent::Future def get wait if rejected? raise reason else value end end def get_or_else(&block) wait if rejected? block.call else ...
github
cookpad/expeditor
https://github.com/cookpad/expeditor
lib/expeditor/services.rb
Ruby
mit
231
master
287
require 'concurrent/configuration' require 'expeditor/services/default' module Expeditor module Services DEFAULT_SERVICE = Expeditor::Services::Default.new private_constant :DEFAULT_SERVICE def default DEFAULT_SERVICE end module_function :default end end
github
cookpad/expeditor
https://github.com/cookpad/expeditor
lib/expeditor/services/default.rb
Ruby
mit
231
master
519
require 'concurrent/configuration' require 'expeditor/service' module Expeditor module Services class Default < Expeditor::Service def initialize @executor = Concurrent.global_io_executor @bucket = nil @fallback_enabled = true end def success end def failur...
github
cookpad/expeditor
https://github.com/cookpad/expeditor
spec/spec_helper.rb
Ruby
mit
231
master
803
$LOAD_PATH.unshift File.expand_path('../../lib', __FILE__) require 'expeditor' Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f } RSpec.configure do |config| config.expect_with :rspec do |expectations| expectations.include_chain_clauses_in_custom_matcher_descriptions = true end config....
github
cookpad/expeditor
https://github.com/cookpad/expeditor
spec/expeditor/rich_future_spec.rb
Ruby
mit
231
master
6,996
require 'spec_helper' RSpec.describe Expeditor::RichFuture do let(:error_in_future) { Class.new(StandardError) } describe '#get' do context 'with success' do it 'should return normal value' do future = Expeditor::RichFuture.new do 42 end future.execute expect(fu...
github
cookpad/expeditor
https://github.com/cookpad/expeditor
spec/expeditor/ring_buffer_spec.rb
Ruby
mit
231
master
1,309
require 'spec_helper' RSpec.describe Expeditor::RingBuffer do def build Expeditor::RingBuffer.new(3) { 1 } end describe '#all' do it 'returns all elements' do expect(build.all).to eq([1, 1, 1]) end end describe '#current' do it 'returns current element' do expect(build.current)....
github
cookpad/expeditor
https://github.com/cookpad/expeditor
spec/expeditor/command_functions_spec.rb
Ruby
mit
231
master
3,217
require 'spec_helper' RSpec.describe Expeditor::Command do let(:error_in_command) { Class.new(StandardError) } describe 'dependencies function' do context 'with normal and no sleep' do it 'should be ok' do command1 = simple_command('The world of truth is...: ') command2 = simple_command(...
github
cookpad/expeditor
https://github.com/cookpad/expeditor
spec/expeditor/current_thread_function_spec.rb
Ruby
mit
231
master
3,612
require 'spec_helper' RSpec.describe Expeditor::Command do let(:error_in_command) { Class.new(StandardError) } describe '#start' do context 'with normal' do it 'executes on current thread' do Thread.current.thread_variable_set('foo', 'bar') command = Expeditor::Command.new do T...
github
cookpad/expeditor
https://github.com/cookpad/expeditor
spec/expeditor/command_spec.rb
Ruby
mit
231
master
15,220
require 'spec_helper' RSpec.describe Expeditor::Command do let(:error_in_command) { Class.new(StandardError) } describe '#start' do context 'with normal' do it 'should not block' do command = sleep_command(1, 42) start = Time.now command.start expect(Time.now - start).to...
github
cookpad/expeditor
https://github.com/cookpad/expeditor
spec/expeditor/status_spec.rb
Ruby
mit
231
master
2,215
require 'spec_helper' RSpec.describe Expeditor::Status do describe '#initialize' do it 'should be zero all' do status = Expeditor::Status.new expect(status.success).to eq(0) expect(status.failure).to eq(0) expect(status.rejection).to eq(0) expect(status.timeout).to eq(0) end e...
github
cookpad/expeditor
https://github.com/cookpad/expeditor
spec/expeditor/rolling_number_spec.rb
Ruby
mit
231
master
2,136
require 'spec_helper' RSpec.describe Expeditor::RollingNumber do describe '#increment' do context 'with same status' do it 'should be increased' do rolling_number = Expeditor::RollingNumber.new(size: 10, per_time: 1) rolling_number.increment :success rolling_number.increment :succes...
github
cookpad/expeditor
https://github.com/cookpad/expeditor
spec/expeditor/retry_function_spec.rb
Ruby
mit
231
master
4,324
require 'spec_helper' RSpec.describe Expeditor::Command do describe '#start_with_retry' do context 'with 3 tries' do it 'should be run 3 times' do count = 0 command = Expeditor::Command.new do count += 1 raise RuntimeError end command.start_with_retry(tri...
github
cookpad/expeditor
https://github.com/cookpad/expeditor
spec/expeditor/circuit_break_function_spec.rb
Ruby
mit
231
master
5,625
require 'spec_helper' RSpec.describe Expeditor::Command do describe 'circuit break function' do context 'with circuit break' do it 'should reject execution' do executor = Concurrent::ThreadPoolExecutor.new(max_queue: 0) service = Expeditor::Service.new(executor: executor, threshold: 0.1, no...
github
cookpad/expeditor
https://github.com/cookpad/expeditor
spec/expeditor/service_spec.rb
Ruby
mit
231
master
4,280
require 'spec_helper' RSpec.describe Expeditor::Service do describe '#run_if_allowed' do context 'with no count' do it 'runs given block' do options = { threshold: 0, non_break_count: 0, } service = Expeditor::Service.new(options) expect(service.run_if_al...
github
cookpad/expeditor
https://github.com/cookpad/expeditor
spec/support/command.rb
Ruby
mit
231
master
383
module CommandHelpers def simple_command(v, opts = {}) Expeditor::Command.new(opts) do v end end def sleep_command(n, v, opts = {}) Expeditor::Command.new(opts) do sleep n v end end def error_command(e, opts = {}) Expeditor::Command.new(opts) do raise e end ...
github
cookpad/expeditor
https://github.com/cookpad/expeditor
scripts/command_performance.rb
Ruby
mit
231
master
692
$LOAD_PATH.unshift(File.expand_path('../lib', __dir__)) require 'expeditor' require 'benchmark/ips' Benchmark.ips do |x| x.report("simple command") do |i| executor = Concurrent::ThreadPoolExecutor.new(min_threads: 100, max_threads: 100, max_queue: 100) service = Expeditor::Service.new(period: 10, non_break_...
github
adzap/timeliness
https://github.com/adzap/timeliness
Rakefile
Ruby
mit
231
master
619
require 'bundler' Bundler::GemHelper.install_tasks require 'rdoc/task' require 'rspec/core/rake_task' desc "Run specs" RSpec::Core::RakeTask.new(:spec) desc "Generate code coverage" RSpec::Core::RakeTask.new(:coverage) do |t| t.rcov = true t.rcov_opts = ['--exclude', 'spec'] end desc 'Generate documentation for...
github
adzap/timeliness
https://github.com/adzap/timeliness
timeliness.gemspec
Ruby
mit
231
master
1,488
# -*- encoding: utf-8 -*- $:.push File.expand_path("../lib", __FILE__) require "timeliness/version" Gem::Specification.new do |s| github_url = 'https://github.com/adzap/timeliness' s.name = "timeliness" s.version = Timeliness::VERSION s.platform = Gem::Platform::RUBY s.authors = ["Adam...
github
adzap/timeliness
https://github.com/adzap/timeliness
benchmark.rb
Ruby
mit
231
master
3,312
$:.unshift(File.expand_path('lib')) require 'benchmark' require 'time' require 'timeliness' if defined?(JRUBY_VERSION) # Warm up JRuby 20_000.times do Time.parse("2000-01-04 12:12:12") Timeliness::Parser.parse("2000-01-04 12:12:12", :datetime) end end n = 10_000 Benchmark.bm(40) do |x| x.report('time...
github
adzap/timeliness
https://github.com/adzap/timeliness
Appraisals
Ruby
mit
231
master
496
appraise "activesupport_5_2" do gem "activesupport", "~> 5.2.0" end appraise "activesupport_6_0" do gem "activesupport", "~> 6.0.0" end appraise "activesupport_6_1" do gem "activesupport", "~> 6.1.0" end appraise "activesupport_7_0" do gem "activesupport", "~> 7.0.0" end appraise "activesupport_7_2" do ge...
github
adzap/timeliness
https://github.com/adzap/timeliness
lib/timeliness.rb
Ruby
mit
231
master
916
require 'date' require 'forwardable' require 'timeliness/configuration' require 'timeliness/helpers' require 'timeliness/definitions' require 'timeliness/format' require 'timeliness/format_set' require 'timeliness/parser' require 'timeliness/version' module Timeliness class << self extend Forwardable def_de...
github
adzap/timeliness
https://github.com/adzap/timeliness
lib/timeliness/definitions.rb
Ruby
mit
231
master
9,393
# frozen_string_literal: true module Timeliness module Definitions # Format tokens: # y = year # m = month # d = day # h = hour # n = minute # s = second # u = micro-seconds # ampm = meridian (am or pm) with or without dots (e.g. am, a...
github
adzap/timeliness
https://github.com/adzap/timeliness
lib/timeliness/format_set.rb
Ruby
mit
231
master
1,482
# frozen_string_literal: true module Timeliness class FormatSet attr_reader :formats, :regexp def self.compile(formats) new(formats).compile! end def initialize(formats) @formats = formats @formats_hash = {} @match_indexes = {} end # Compiles the formats into...
github
adzap/timeliness
https://github.com/adzap/timeliness
lib/timeliness/format.rb
Ruby
mit
231
master
2,228
# frozen_string_literal: true module Timeliness class Format include Helpers CompilationFailed = Class.new(StandardError) attr_reader :format_string, :regexp, :regexp_string, :token_count def initialize(format_string) @format_string = format_string end def compile! found_token...
github
adzap/timeliness
https://github.com/adzap/timeliness
lib/timeliness/configuration.rb
Ruby
mit
231
master
1,014
module Timeliness class Configuration # Default timezone. Options: # - :local (default) # - :utc # # If ActiveSupport loaded, also # - :current # - 'Zone name' # attr_accessor :default_timezone # Set the default date part for a time type values. # attr_ac...
github
adzap/timeliness
https://github.com/adzap/timeliness
lib/timeliness/parser.rb
Ruby
mit
231
master
5,492
module Timeliness module Parser class MissingTimezoneSupport < StandardError; end class << self def parse(value, type=nil, **options) return value if acts_like_temporal?(value) return nil unless parseable?(value) if type && !type.is_a?(Symbol) options[:now] = type if...
github
adzap/timeliness
https://github.com/adzap/timeliness
lib/timeliness/helpers.rb
Ruby
mit
231
master
1,411
# frozen_string_literal: true module Timeliness module Helpers # Helper methods used in format component processing. See Definitions. def full_hour(hour, meridian) hour = hour.to_i return hour if meridian.nil? meridian.delete!('.') meridian.downcase! if meridian == 'am' ...
github
adzap/timeliness
https://github.com/adzap/timeliness
lib/timeliness/core_ext/string.rb
Ruby
mit
231
master
622
class String # Form can be either :utc (default) or :local. def to_time(form = :utc) return nil if self.blank? Timeliness::Parser.parse(self, :datetime, zone: form) end def to_date return nil if self.blank? values = Timeliness::Parser._parse(self, :date).map { |arg| arg || 0 } ::Date.new(*...
github
adzap/timeliness
https://github.com/adzap/timeliness
spec/spec_helper.rb
Ruby
mit
231
master
4,477
# 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 explicitly require it in any # file...
github
adzap/timeliness
https://github.com/adzap/timeliness
spec/timeliness_helper.rb
Ruby
mit
231
master
919
require 'active_support' require 'active_support/time' require 'active_support/core_ext/object' require 'timecop' require 'timeliness' require 'timeliness/core_ext' module TimelinessHelpers def parser Timeliness::Parser end def definitions Timeliness::Definitions end def parse(value, type=nil, **ar...
github
adzap/timeliness
https://github.com/adzap/timeliness
spec/timeliness/parser_spec.rb
Ruby
mit
231
master
19,034
describe Timeliness::Parser do def self.timezone_settings(zone: nil, output: nil) before do Time.zone = zone if zone Timeliness.configuration.default_timezone = output if output end end around do |example| current_zone = Time.zone example.call Time.zone = current_zone end bef...
github
adzap/timeliness
https://github.com/adzap/timeliness
spec/timeliness/helpers_spec.rb
Ruby
mit
231
master
3,908
describe Timeliness::Helpers do include Timeliness::Helpers describe "#full_hour" do it "should convert a 12-hour clock AM time to 24-hour format correctly" do expect(full_hour(12, 'am')).to eq 0 expect(full_hour(1, 'am')).to eq 1 expect(full_hour(10, 'am')).to eq 10 end it "should c...
github
adzap/timeliness
https://github.com/adzap/timeliness
spec/timeliness/definitions_spec.rb
Ruby
mit
231
master
4,511
describe Timeliness::Definitions do context "add_formats" do before do @default_formats = definitions.time_formats.dup end it "should add format to format array" do definitions.add_formats(:time, "h o'clock") expect(definitions.time_formats).to include("h o'clock") end it "shou...
github
adzap/timeliness
https://github.com/adzap/timeliness
spec/timeliness/format_spec.rb
Ruby
mit
231
master
5,643
describe Timeliness::Format do describe "#compile!" do it 'should compile valid string format' do expect { Timeliness::Format.new('yyyy-mm-dd hh:nn:ss.u zo').compile! }.to_not raise_error end it 'should return self' do format = Timeliness::Format.new('yyyy-mm-dd hh:nn:ss.u zo')...
github
adzap/timeliness
https://github.com/adzap/timeliness
spec/timeliness/format_set_spec.rb
Ruby
mit
231
master
4,983
describe Timeliness::FormatSet do context "#compile!" do let(:set) { Timeliness::FormatSet.new(['yyyy-mm-dd', 'dd/mm/yyyy']) } it 'should set the regexp for the set' do set.compile! expect(set.regexp).not_to be_nil end end context "compiled regexp" do context "for time formats" do ...
github
adzap/timeliness
https://github.com/adzap/timeliness
spec/timeliness/core_ext/string_spec.rb
Ruby
mit
231
master
2,352
describe Timeliness::CoreExt, 'String' do # Test values taken from ActiveSupport unit tests for compatibility describe "#to_time" do it 'should convert valid string to Time object in default zone' do expect("2005-02-27 23:50".to_time).to eq Time.utc(2005, 2, 27, 23, 50) end it 'should convert IS...
github
brandur/json_schema
https://github.com/brandur/json_schema
json_schema.gemspec
Ruby
mit
231
master
477
Gem::Specification.new do |s| s.name = "json_schema" s.version = "0.21.0" s.summary = "A JSON Schema V4 and Hyperschema V4 parser and validator." s.authors = ["Brandur"] s.email = ["brandur@mutelight.org"] s.homepage = "https://github.com/brandur/json_schema" s.li...
github
brandur/json_schema
https://github.com/brandur/json_schema
Gemfile
Ruby
mit
231
master
217
source 'https://rubygems.org' gemspec gem 'ecma-re-validator', '~> 0.1' gem 'minitest', '~> 5.3' gem 'rake', ">= 12.3.3" gem 'simplecov' if RUBY_VERSION >= "2.3.0" gem 'byebug' gem 'pry' gem 'pry-byebug' end
github
brandur/json_schema
https://github.com/brandur/json_schema
Rakefile
Ruby
mit
231
master
350
require 'bundler' require "rake/testtask" task :default => :test Bundler::GemHelper.install_tasks Rake::TestTask.new do |task| task.libs << "lib" task.libs << "test" task.name = :test task.test_files = FileList["test/**/*_test.rb"] task.ruby_opts = '' if task.ruby_opts.nil? task.ruby_opts << ' -w' unless...
github
brandur/json_schema
https://github.com/brandur/json_schema
lib/json_schema.rb
Ruby
mit
231
master
696
require_relative "json_schema/attributes" require_relative "json_schema/configuration" require_relative "json_schema/document_store" require_relative "json_schema/error" require_relative "json_schema/parser" require_relative "json_schema/reference_expander" require_relative "json_schema/schema" require_relative "json_s...