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
sporkd/html5-rails
https://github.com/sporkd/html5-rails
html5-rails.gemspec
Ruby
mit
236
master
933
# -*- encoding: utf-8 -*- $:.push File.expand_path("../lib", __FILE__) require "html5/rails/version" Gem::Specification.new do |s| s.name = "html5-rails" s.version = Html5::Rails::VERSION s.platform = Gem::Platform::RUBY s.authors = ["Peter Gumeson"] s.email = ["gumeson@gmail.com"] ...
github
sporkd/html5-rails
https://github.com/sporkd/html5-rails
test/test_helper.rb
Ruby
mit
236
master
643
# Configure Rails Envinronment ENV["RAILS_ENV"] = "test" require File.expand_path("../dummy/config/environment.rb", __FILE__) require "rails/test_help" ActionMailer::Base.delivery_method = :test ActionMailer::Base.perform_deliveries = true ActionMailer::Base.default_url_options[:host] = "test.com" Rails.backtrace_c...
github
sporkd/html5-rails
https://github.com/sporkd/html5-rails
test/generators/assets_generator_test.rb
Ruby
mit
236
master
2,519
require "test_helper" require "generators/html5/assets/assets_generator" class AssetsGeneratorTest < Rails::Generators::TestCase include GeneratorTestHelper tests Html5::Generators::AssetsGenerator test "html5:assets should make changes to application.js" do run_generator assert_file "app/assets/javasc...
github
sporkd/html5-rails
https://github.com/sporkd/html5-rails
test/generators/layout_generator_test.rb
Ruby
mit
236
master
2,672
require "test_helper" require "generators/html5/layout/layout_generator" class LayoutGeneratorTest < Rails::Generators::TestCase include GeneratorTestHelper tests Html5::Generators::LayoutGenerator %w(erb haml slim).each do |engine| defaults = ["--template-engine=#{ engine }"] test "html5:layout --temp...
github
sporkd/html5-rails
https://github.com/sporkd/html5-rails
test/generators/partial_generator_test.rb
Ruby
mit
236
master
2,715
require "test_helper" require "generators/html5/partial/partial_generator" class PartialGeneratorTest < Rails::Generators::TestCase include GeneratorTestHelper tests Html5::Generators::PartialGenerator %w(erb haml slim).each do |engine| defaults = ["--template-engine=#{ engine }"] test "html5:partial -...
github
sporkd/html5-rails
https://github.com/sporkd/html5-rails
test/generators/install_generator_test.rb
Ruby
mit
236
master
1,960
require "test_helper" require "generators/html5/install/install_generator" class InstallGeneratorTest < Rails::Generators::TestCase include GeneratorTestHelper tests Html5::Generators::InstallGenerator test "Compass config file should be generated" do run_generator assert_file "config/compass.rb" end ...
github
sporkd/html5-rails
https://github.com/sporkd/html5-rails
test/support/generator_test_helper.rb
Ruby
mit
236
master
499
module GeneratorTestHelper def self.included(base) base.class_eval do destination File.expand_path("../../tmp", __FILE__) setup :prepare_destination end end protected def prepare_destination rm_rf(destination_root) mkdir_p(destination_root + "/app") dummy_app = File.expand_path("...
github
sporkd/html5-rails
https://github.com/sporkd/html5-rails
test/dummy/config/application.rb
Ruby
mit
236
master
3,043
require File.expand_path('../boot', __FILE__) # Pick the frameworks you want: require "active_record/railtie" require "action_controller/railtie" require "action_mailer/railtie" require "active_resource/railtie" require "sprockets/railtie" # require "rails/test_unit/railtie" if defined?(Bundler) # If you precompile...
github
sporkd/html5-rails
https://github.com/sporkd/html5-rails
test/dummy/config/boot.rb
Ruby
mit
236
master
254
require 'rubygems' # Set up gems listed in the Gemfile. ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../../../Gemfile', __FILE__) require 'bundler/setup' if File.exists?(ENV['BUNDLE_GEMFILE']) $:.unshift File.expand_path('../../../../lib', __FILE__)
github
sporkd/html5-rails
https://github.com/sporkd/html5-rails
test/dummy/config/routes.rb
Ruby
mit
236
master
1,783
Dummy::Application.routes.draw do # The priority is based upon order of creation: # first created -> highest priority. # Sample of regular route: # match 'products/:id' => 'catalog#view' # Keep in mind you can assign values other than :controller and :action # Sample of named route: # match 'product...
github
sporkd/html5-rails
https://github.com/sporkd/html5-rails
test/dummy/config/initializers/secret_token.rb
Ruby
mit
236
master
496
# Be sure to restart your server when you modify this file. # Your secret key for verifying the integrity of signed cookies. # If you change this key, all old signed cookies will become invalid! # Make sure the secret is at least 30 characters and all random, # no regular words or you'll be exposed to dictionary attac...
github
sporkd/html5-rails
https://github.com/sporkd/html5-rails
lib/html5/rails/helpers.rb
Ruby
mit
236
master
1,824
module Html5 module Rails module Helpers # Helper to display conditional html tags for IE # http://paulirish.com/2008/conditional-stylesheets-vs-css-hacks-answer-neither def html_tag(attrs={}) attrs.symbolize_keys! html = "" html << "<!--[if lt IE 7]> #{ tag(:html, add_c...
github
sporkd/html5-rails
https://github.com/sporkd/html5-rails
lib/html5/rails/engine.rb
Ruby
mit
236
master
480
module Html5 module Rails class Engine < ::Rails::Engine # Extend application_helper initializer 'html5_rails_engine.helper' do |app| ActionController::Base.helper(Html5::Rails::Helpers) end # Extend application_controller # initializer 'html5_rails_engine.controller' do |a...
github
sporkd/html5-rails
https://github.com/sporkd/html5-rails
lib/generators/html5/generator_helpers.rb
Ruby
mit
236
master
778
module Html5 module Generators module GeneratorHelpers def application_name if defined?(::Rails) && ::Rails.application ::Rails.application.class.name.split('::').first else "application" end end def application_title if defined?(::Rails) && ...
github
sporkd/html5-rails
https://github.com/sporkd/html5-rails
lib/generators/html5/assets/assets_generator.rb
Ruby
mit
236
master
1,807
require "generators/html5/generator_helpers" module Html5 module Generators class AssetsGenerator < ::Rails::Generators::NamedBase include Html5::Generators::GeneratorHelpers source_root File.expand_path('../templates', __FILE__) argument :name, :type => :string, :requir...
github
sporkd/html5-rails
https://github.com/sporkd/html5-rails
lib/generators/html5/partial/partial_generator.rb
Ruby
mit
236
master
2,314
require "generators/html5/generator_helpers" module Html5 module Generators class PartialGenerator < ::Rails::Generators::NamedBase include Html5::Generators::GeneratorHelpers source_root File.expand_path('../templates', __FILE__) argument :name, :type => :string, :requi...
github
sporkd/html5-rails
https://github.com/sporkd/html5-rails
lib/generators/html5/install/install_generator.rb
Ruby
mit
236
master
917
require "generators/html5/generator_helpers" module Html5 module Generators class InstallGenerator < ::Rails::Generators::Base include Html5::Generators::GeneratorHelpers source_root File.expand_path('../templates', __FILE__) class_option :template_engine # def run_config # ins...
github
sporkd/html5-rails
https://github.com/sporkd/html5-rails
lib/generators/html5/layout/layout_generator.rb
Ruby
mit
236
master
1,657
require "generators/html5/generator_helpers" module Html5 module Generators class LayoutGenerator < ::Rails::Generators::NamedBase include Html5::Generators::GeneratorHelpers source_root File.expand_path('../templates', __FILE__) argument :name, :type => :string, :requir...
github
stjernstrom/capistrano_colors
https://github.com/stjernstrom/capistrano_colors
capistrano_colors.gemspec
Ruby
mit
236
master
1,509
# -*- encoding: utf-8 -*- Gem::Specification.new do |s| s.name = %q{capistrano_colors} s.version = "0.5.5" s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version= s.authors = ["Mathias Stjernstrom"] s.date = %q{2011-03-17} s.description = %q{Simple gem to ...
github
stjernstrom/capistrano_colors
https://github.com/stjernstrom/capistrano_colors
lib/capistrano_colors.rb
Ruby
mit
236
master
1,109
require 'capistrano/configuration' require 'capistrano/logger' require 'capistrano_colors/configuration' require 'capistrano_colors/logger' # DEBUG Capistrano::Logger.add_color_matcher({ :match => /executing `.*/, :color => :green, :level => 2, :prio => -10, :prepend => "== Currently ", :timestamp => tr...
github
stjernstrom/capistrano_colors
https://github.com/stjernstrom/capistrano_colors
lib/capistrano_colors/logger.rb
Ruby
mit
236
master
2,259
module Capistrano class Logger CAP_COLORS = { :none => "0", :black => "30", :red => "31", :green => "32", :yellow => "33", :blue => "34", :magenta => "35", :cyan => "3...
github
stjernstrom/capistrano_colors
https://github.com/stjernstrom/capistrano_colors
lib/capistrano_colors/configuration.rb
Ruby
mit
236
master
1,885
module Capistrano class Configuration # Add custom colormatchers # # Passing a hash or a array of hashes with custom colormatchers. # # Add the following to your deploy.rb or in your ~/.caprc # # == Example: # # require 'capistrano_colors' # # capistrano_color_matc...
github
zendesk/delivery_boy
https://github.com/zendesk/delivery_boy
Gemfile
Ruby
apache-2.0
236
main
264
source "https://rubygems.org" gemspec gem "base64" gem "bigdecimal" gem "debug" gem "logger" gem "rake", "~> 13.0" gem "rspec", "~> 3.0" gem "standard", "~> 1.51.1" if RUBY_VERSION > "3.0" gem "testcontainers-kafka", github: "testcontainers/testcontainers-ruby"
github
zendesk/delivery_boy
https://github.com/zendesk/delivery_boy
delivery_boy.gemspec
Ruby
apache-2.0
236
main
829
lib = File.expand_path("../lib", __FILE__) $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) require "delivery_boy/version" Gem::Specification.new do |spec| spec.name = "delivery_boy" spec.version = DeliveryBoy::VERSION spec.authors = ["Daniel Schierbeck"] spec.email = ["daniel.schierbeck@gmail.com"] ...
github
zendesk/delivery_boy
https://github.com/zendesk/delivery_boy
spec/fake_spec.rb
Ruby
apache-2.0
236
main
315
require "spec_helper" RSpec.describe DeliveryBoy::Fake do it "should match the public API" do aggregate_failures do DeliveryBoy::Instance.public_instance_methods(false).each do |public_method| expect(described_class.public_instance_methods).to include public_method end end end end
github
zendesk/delivery_boy
https://github.com/zendesk/delivery_boy
spec/delivery_boy_spec.rb
Ruby
apache-2.0
236
main
2,591
require "delivery_boy" RSpec.describe DeliveryBoy do after(:each) do DeliveryBoy.testing.clear DeliveryBoy.clear_config! end describe ".deliver_async" do it "delivers the message using .deliver_async!" do DeliveryBoy.test_mode! time1 = Time.now time2 = Time.now DeliveryBoy.d...
github
zendesk/delivery_boy
https://github.com/zendesk/delivery_boy
spec/spec_helper.rb
Ruby
apache-2.0
236
main
1,277
require "bundler/setup" require "delivery_boy" require "testcontainers/kafka" RSpec.configure do |config| config.add_setting :container, default: nil config.before(:suite) do puts "Starting test containers" config.container = Testcontainers::KafkaContainer.new config.container.start kafka_containe...
github
zendesk/delivery_boy
https://github.com/zendesk/delivery_boy
spec/instance_spec.rb
Ruby
apache-2.0
236
main
1,295
require "delivery_boy" RSpec.describe DeliveryBoy::Instance do let(:logger) { Logger.new($stdout, level: ENV["DEBUG"] ? Logger::DEBUG : Logger::FATAL) } let(:config) do DeliveryBoy::Config.new.tap do |conf| conf.set(:brokers, [ RSpec.configuration.container.connection_url ]) end end ...
github
zendesk/delivery_boy
https://github.com/zendesk/delivery_boy
lib/delivery_boy.rb
Ruby
apache-2.0
236
main
4,554
require "logger" require "kafka" require "delivery_boy/version" require "delivery_boy/instance" require "delivery_boy/fake" require "delivery_boy/config" require "delivery_boy/config_error" require "delivery_boy/railtie" if defined?(Rails::Railtie) module DeliveryBoy class << self # Write a message to a specifie...
github
zendesk/delivery_boy
https://github.com/zendesk/delivery_boy
lib/delivery_boy/config.rb
Ruby
apache-2.0
236
main
2,168
require "king_konf" module DeliveryBoy class Config < KingKonf::Config env_prefix :delivery_boy # Basic list :brokers, items: :string, sep: ",", default: ["localhost:9092"] string :client_id, default: "delivery_boy" string :log_level, default: nil # Buffering integer :max_buffer_bytesiz...
github
zendesk/delivery_boy
https://github.com/zendesk/delivery_boy
lib/delivery_boy/railtie.rb
Ruby
apache-2.0
236
main
789
module DeliveryBoy class Railtie < Rails::Railtie initializer "delivery_boy.load_config" do config = DeliveryBoy.config if File.exist?("config/delivery_boy.yml") config.load_file("config/delivery_boy.yml", Rails.env) end if File.exist?("config/delivery_boy.rb") require "....
github
zendesk/delivery_boy
https://github.com/zendesk/delivery_boy
lib/delivery_boy/fake.rb
Ruby
apache-2.0
236
main
2,127
module DeliveryBoy # A fake implementation that is useful for testing. class Fake FakeMessage = Struct.new(:value, :topic, :key, :headers, :offset, :partition, :partition_key, :create_time) do def bytesize key.to_s.bytesize + value.to_s.bytesize end end def initialize @message...
github
zendesk/delivery_boy
https://github.com/zendesk/delivery_boy
lib/delivery_boy/instance.rb
Ruby
apache-2.0
236
main
4,169
module DeliveryBoy # This class implements the actual logic of DeliveryBoy. The DeliveryBoy module # has a module-level singleton instance. class Instance def initialize(config, logger) @config = config @logger = logger @async_producer = nil end def deliver(value, topic:, **options)...
github
zendesk/delivery_boy
https://github.com/zendesk/delivery_boy
lib/generators/delivery_boy/install_generator.rb
Ruby
apache-2.0
236
main
268
module DeliveryBoy module Generators class InstallGenerator < Rails::Generators::Base source_root File.expand_path("../", __FILE__) def create_config_file template "config_file.yml.erb", "config/delivery_boy.yml" end end end end
github
zk-ruby/zk
https://github.com/zk-ruby/zk
zk.gemspec
Ruby
mit
236
master
756
# -*- encoding: utf-8 -*- $:.push File.expand_path("../lib", __FILE__) require "zk/version" Gem::Specification.new do |s| s.name = "zk" s.version = ZK::VERSION s.platform = Gem::Platform::RUBY s.authors = ["Jonathan D. Simms", "Topper Bowers"] s.email = ["slyphon@gmail.com"] s.homep...
github
zk-ruby/zk
https://github.com/zk-ruby/zk
Gemfile
Ruby
mit
236
master
1,285
source "https://rubygems.org" # gem 'slyphon-zookeeper', :path => '~/zookeeper' # gem 'zookeeper', :path => "~/zookeeper" # this is the last known commit that we tested against and is passing. # keep closer track of this stuff to make bisecting easier and travis more # accurate # git 'git://github.com/slyphon/zooke...
github
zk-ruby/zk
https://github.com/zk-ruby/zk
Rakefile
Ruby
mit
236
master
1,703
release_ops_path = File.expand_path('../releaseops/lib', __FILE__) # if the special submodule is availabe, use it # we use a submodule because it doesn't depend on anything else (*cough* bundler) # and can be shared across projects # if File.exists?(release_ops_path) require File.join(release_ops_path, 'releaseops')...
github
zk-ruby/zk
https://github.com/zk-ruby/zk
Guardfile
Ruby
mit
236
master
1,369
# A sample Guardfile # More info at https://github.com/guard/guard#readme dot_rspec_path = File.expand_path('../.rspec', __FILE__) rspec_options = File.open('.rspec', &:readlines).map(&:chomp).reject{|n| n =~ /\A(#|\Z)/} guard 'bundler' do watch 'Gemfile' watch /\A.+\.gemspec\Z/ end guard 'rspec', :version => 2...
github
zk-ruby/zk
https://github.com/zk-ruby/zk
spec/message_queue_spec.rb
Ruby
mit
236
master
1,554
require File.join(File.dirname(__FILE__), %w[spec_helper]) describe ZK::MessageQueue do include_context 'connection opts' before(:each) do @zk = ZK.new(connection_host) @zk2 = ZK.new(connection_host) wait_until{ @zk.connected? && @zk2.connected? } @queue_name = "_specQueue" @consume_queue = @z...
github
zk-ruby/zk
https://github.com/zk-ruby/zk
spec/spec_helper.rb
Ruby
mit
236
master
2,947
require 'rubygems' require 'bundler/setup' # not a constant so we don't pollute global namespace release_ops_path = File.expand_path('../../releaseops/lib', __FILE__) if File.exists?(release_ops_path) require File.join(release_ops_path, 'releaseops') ReleaseOps::SimpleCov.maybe_start end Bundler.require(:develop...
github
zk-ruby/zk
https://github.com/zk-ruby/zk
spec/logging_progress_bar_formatter.rb
Ruby
mit
236
master
473
require 'rspec/core/formatters/progress_formatter' # essentially a monkey-patch to the ProgressBarFormatter, outputs # '== #{example_proxy.description} ==' in the logs before each test. makes it # easier to match up tests with the SQL they produce class LoggingProgressBarFormatter < RSpec::Core::Formatters::Progress...
github
zk-ruby/zk
https://github.com/zk-ruby/zk
spec/event_catcher_spec.rb
Ruby
mit
236
master
677
# quick tests for one of the support classes require 'spec_helper' describe EventCatcher do subject { EventCatcher.new } let!(:latch) { Latch.new } describe :wait_for do it %[should wake when an event is delivered] do th = Thread.new do subject.synchronize do logger.debug { "about ...
github
zk-ruby/zk
https://github.com/zk-ruby/zk
spec/zk/zookeeper_spec.rb
Ruby
mit
236
master
4,617
require 'spec_helper' shared_examples_for 'ZK basic' do before do logger.debug { "connection_args: #{connection_args.inspect}" } begin @zk.create(@base_path) rescue ZK::Exceptions::NodeExists end end describe ZK, "with no authentication" do it "should add authentication" do expec...
github
zk-ruby/zk
https://github.com/zk-ruby/zk
spec/zk/00_forked_client_integration_spec.rb
Ruby
mit
236
master
906
require 'spec_helper' describe 'forked client integration' do describe :forked, :fork_required => true, :rbx => :broken do include_context 'connection opts' before do @base_path = '/zktests' @pids_root = "#{@base_path}/pid" @cnx_args = ["#{ZK.default_host}:#{ZK.test_port}", { :threa...
github
zk-ruby/zk
https://github.com/zk-ruby/zk
spec/zk/watch_spec.rb
Ruby
mit
236
master
11,207
require 'spec_helper' describe ZK do include_context 'connection opts' describe 'watchers' do before do mute_logger do @zk = ZK.new(*connection_args) @path = "/_testWatch" wait_until { @zk.connected? } @zk.rm_rf(@path) end end after do mute_logger do...
github
zk-ruby/zk
https://github.com/zk-ruby/zk
spec/zk/module_spec.rb
Ruby
mit
236
master
6,382
require 'spec_helper' # tests for the top-level module methods of ZK describe ZK do describe :new do include_context 'connection opts' let(:chroot_path) { '/zktest/path/to/chroot' } before do ZK.open(*connection_args) { |z| z.rm_rf('/zktest') } end after do mute_logger do ...
github
zk-ruby/zk
https://github.com/zk-ruby/zk
spec/zk/locker_spec.rb
Ruby
mit
236
master
602
require 'spec_helper' describe ZK::Locker do include_context 'threaded client connection' describe :cleanup do it %[should remove dead lock directories] do locker = @zk.locker('legit') locker.lock locker.assert! bogus_lock_dir_names = %w[a b c d e f g] bogus_lock_dir_names.each ...
github
zk-ruby/zk
https://github.com/zk-ruby/zk
spec/zk/client_spec.rb
Ruby
mit
236
master
3,163
require 'spec_helper' describe ZK::Client::Threaded do context do include_context 'threaded client connection' it_should_behave_like 'client' end describe :close! do describe 'from a threadpool thread' do include_context 'connection opts' before do @zk = ZK::Client::Threaded.new...
github
zk-ruby/zk
https://github.com/zk-ruby/zk
spec/zk/node_deletion_watcher_spec.rb
Ruby
mit
236
master
4,903
require 'spec_helper' describe ZK::NodeDeletionWatcher do include_context 'threaded client connection' before do @path = "#{@base_path}/node_deleteion_watcher_victim" @n = ZK::NodeDeletionWatcher.new(@zk, @path) @exc = nil end describe %[when the node already exists] do it %[blocks the calle...
github
zk-ruby/zk
https://github.com/zk-ruby/zk
spec/zk/threaded_callback_spec.rb
Ruby
mit
236
master
1,718
require 'spec_helper' describe ZK::ThreadedCallback do before do @called = [] @called.extend(MonitorMixin) @cond = @called.new_cond @callback = proc do |*a| @called.synchronize do @called << a @cond.broadcast end end @tcb = ZK::ThreadedCallback.new(@callback) e...
github
zk-ruby/zk
https://github.com/zk-ruby/zk
spec/zk/threadpool_spec.rb
Ruby
mit
236
master
3,620
require 'spec_helper' describe ZK::Threadpool do before do @threadpool = ZK::Threadpool.new end after do @threadpool.shutdown end describe :new do it %[should be running] do expect(@threadpool).to be_running end it %[should use the default size] do expect(@threadpool.size)....
github
zk-ruby/zk
https://github.com/zk-ruby/zk
spec/zk/election_spec.rb
Ruby
mit
236
master
8,817
require 'spec_helper' describe ZK::Election, :jruby => :broken do include_context 'connection opts' before do ZK.open(connection_host) do |cnx| logger.debug { "REMOVING /_zkelection" } cnx.rm_rf('/_zkelection') end @zk = ZK.new(*connection_args) @zk2 = ZK.new(*connection_args) @el...
github
zk-ruby/zk
https://github.com/zk-ruby/zk
spec/zk/extensions_spec.rb
Ruby
mit
236
master
311
require 'spec_helper' module ZK describe 'Extensions' do describe 'Exception#to_std_format' do it %[should not barf if backtrace is nil] do exc = StandardError.new expect(exc.backtrace).to be_nil expect { exc.to_std_format }.not_to raise_error end end end end
github
zk-ruby/zk
https://github.com/zk-ruby/zk
spec/zk/pool_spec.rb
Ruby
mit
236
master
8,822
require 'spec_helper' describe ZK::Pool do describe :Simple do include_context 'connection opts' before do report_realtime('opening pool') do @pool_size = 2 @connection_pool = ZK::Pool::Simple.new(connection_host, @pool_size, :watcher => :default) expect(@connection_pool).to be...
github
zk-ruby/zk
https://github.com/zk-ruby/zk
spec/zk/mongoid_spec.rb
Ruby
mit
236
master
8,279
require 'spec_helper' describe ZK::Mongoid::Locking do include_context 'connection opts' before do ZK::Mongoid::Locking.zk_lock_pool = ZK.new_pool(connection_host, :min_clients => 1, :max_clients => 5) @doc = BogusMongoid.new @other_doc = BogusMongoid.new end after do th = Thread.new...
github
zk-ruby/zk
https://github.com/zk-ruby/zk
spec/zk/client/locking_and_session_death_spec.rb
Ruby
mit
236
master
2,333
require 'spec_helper' shared_examples_for 'session death' do def deliver_session_event_to(event_num, zk) # jeez, Zookeeper callbacks are so frustratingly stupid bogus_event = Zookeeper::Callbacks::WatcherCallback.new bogus_event.initialize_context(:type => -1, :state => event_num, :path => '', :context =...
github
zk-ruby/zk
https://github.com/zk-ruby/zk
spec/zk/locker/shared_locker_spec.rb
Ruby
mit
236
master
5,163
require 'spec_helper' shared_examples_for 'ZK::Locker::SharedLocker' do let(:locker) { ZK::Locker::SharedLocker.new(zk, path) } let(:locker2) { ZK::Locker::SharedLocker.new(zk2, path) } describe :assert! do it_should_behave_like 'LockerBase#assert!' it %[should raise LockAssertionFailedError if there ...
github
zk-ruby/zk
https://github.com/zk-ruby/zk
spec/zk/locker/exclusive_locker_spec.rb
Ruby
mit
236
master
4,726
require 'spec_helper' shared_examples_for 'ZK::Locker::ExclusiveLocker' do let(:locker) { ZK::Locker.exclusive_locker(zk, path) } let(:locker2) { ZK::Locker.exclusive_locker(zk2, path) } describe :assert! do it_should_behave_like 'LockerBase#assert!' it %[should raise LockAssertionFailedError if there ...
github
zk-ruby/zk
https://github.com/zk-ruby/zk
spec/zk/locker/semaphore_spec.rb
Ruby
mit
236
master
4,623
require 'spec_helper' shared_examples_for 'ZK::Locker::Semaphore' do let(:semaphore_size){ 2 } let(:locker) { ZK::Locker::Semaphore.new(zk, path, semaphore_size) } let(:locker2) { ZK::Locker::Semaphore.new(zk2, path, semaphore_size) } let(:locker3) { ZK::Locker::Semaphore.new(zk3, path, semaphore_size) } d...
github
zk-ruby/zk
https://github.com/zk-ruby/zk
spec/zk/locker/locker_basic_spec.rb
Ruby
mit
236
master
5,006
require 'spec_helper' # this is a remnant of the old Locker class, but a good test of what's expected # from ZK::Client#locker # describe 'ZK::Client#locker' do include_context 'connection opts' before(:each) do @zk = ZK.new(*connection_args) @zk2 = ZK.new(*connection_args) @zk3 = ZK.new(*connection_a...
github
zk-ruby/zk
https://github.com/zk-ruby/zk
spec/zk/locker/shared_exclusive_integration_spec.rb
Ruby
mit
236
master
5,850
require 'spec_helper' shared_examples_for :shared_exclusive_integration do before do @sh_lock = ZK::Locker.shared_locker(zk, path) @ex_lock = ZK::Locker.exclusive_locker(zk2, path) end describe 'shared lock acquired first' do it %[should block exclusive locks from acquiring until released] do ...
github
zk-ruby/zk
https://github.com/zk-ruby/zk
spec/shared/client_examples.rb
Ruby
mit
236
master
12,820
shared_examples_for 'client' do describe :mkdir_p do before do base = @base_path.sub(%r_^/_, '') @path_ary = %W[#{base} test mkdir_p path creation] @bogus_path = File.join('', *@path_ary) end it %[should create all intermediate paths for the path givem] do expect(@zk.exists?(@bog...
github
zk-ruby/zk
https://github.com/zk-ruby/zk
spec/shared/locker_contexts.rb
Ruby
mit
236
master
1,759
shared_context 'locker non-chrooted' do include_context 'connection opts' let(:zk) { ZK.new(*connection_args) } let(:zk2) { ZK.new(*connection_args) } let(:zk3) { ZK.new(*connection_args) } let(:connections) { [zk, zk2, zk3] } let(:path) { "lock_path" } let(:root_lock_path) { "#{ZK::Locker.default_roo...
github
zk-ruby/zk
https://github.com/zk-ruby/zk
spec/shared/client_contexts.rb
Ruby
mit
236
master
1,301
shared_context 'connection opts' do let(:connection_opts) { { :thread => :per_callback, :timeout => 5 } } let(:connection_host) { "#{ZK.default_host}:#{ZK.test_port}" } let(:connection_args) { [connection_host, connection_opts] } end shared_context 'threaded client connection' do include_context 'connection op...
github
zk-ruby/zk
https://github.com/zk-ruby/zk
spec/shared/locker_examples.rb
Ruby
mit
236
master
1,762
# basic shared exmples for locker specs (both exclusive and shared) # these assume they're being executed in the 'locker chrooted' or 'locker # non-chrooted' contexts # shared_examples_for 'LockerBase#assert!' do it %[should raise LockAssertionFailedError if its connection is no longer connected?] do zk.close! ...
github
zk-ruby/zk
https://github.com/zk-ruby/zk
spec/support/00_test_port_attr.rb
Ruby
mit
236
master
466
module ZK def self.spawn_zookeeper? !!ENV['SPAWN_ZOOKEEPER'] end def self.travis? !!ENV['TRAVIS'] end @test_port ||= spawn_zookeeper? ? 21811 : 2181 class << self attr_accessor :test_port end # argh, blah, this affects ZK.new everywhere (which is kind of the point, but # still gross) ...
github
zk-ruby/zk
https://github.com/zk-ruby/zk
spec/support/pendings.rb
Ruby
mit
236
master
1,113
module Pendings def pending_192(msg) if ZK.mri_19x? if block_given? pending(msg) { yield } else pending(msg) end else yield if block_given? end end def pending_187(msg) if ZK.mri_187? if block_given? pending(msg) { yield } else p...
github
zk-ruby/zk
https://github.com/zk-ruby/zk
spec/support/logging.rb
Ruby
mit
236
master
719
module ZK TEST_LOG_PATH = File.join(ZK::ZK_ROOT, 'test.log') def self.setup_test_logger log = if ENV['ZK_DEBUG'] ::Logger.new(STDERR) else ::Logger.new(TEST_LOG_PATH) end log.level = ::Logger::DEBUG ZK::Logger.wrapped_logger = log end end ZK.setup_test_logger mod...
github
zk-ruby/zk
https://github.com/zk-ruby/zk
spec/support/event_catcher.rb
Ruby
mit
236
master
1,741
class EventCatcher extend Forwardable include ZK::Logger def_delegators :@mutex, :synchronize MEMBERS = [:created, :changed, :deleted, :child, :all] attr_reader :events, :mutex def initialize(*args) @mutex = Monitor.new @conds = {} @events = {} MEMBERS.each do |k| @conds[k] = ...
github
zk-ruby/zk
https://github.com/zk-ruby/zk
spec/support/client_forker.rb
Ruby
mit
236
master
5,382
class ClientForker include ZK::Logger attr_reader :base_path, :cnx_args, :stat def self.run(cnx_args, base_path) cf = new(cnx_args, base_path) cf.run yield cf end def initialize(cnx_args, base_path) @cnx_args = cnx_args @base_path = base_path @pids_root = "#{@base_path}/pid" @ch...
github
zk-ruby/zk
https://github.com/zk-ruby/zk
spec/support/wait_watchers.rb
Ruby
mit
236
master
1,402
module WaitWatchers class TimeoutError < StandardError; end # method to wait until block passed returns truthy (false will not work) or # timeout (default is 2 seconds) is reached raises TiemoutError on timeout # # @returns the truthy value # # @example # # @a = nil # # th = Thread.new ...
github
zk-ruby/zk
https://github.com/zk-ruby/zk
spec/informal/lock_with_dead_session.rb
Ruby
mit
236
master
1,629
#!/usr/bin/env ruby require 'zk' require 'logger' $stderr.sync = true ZK.logger = log = Logger.new('informal.log').tap { |l| l.level = Logger::DEBUG } Zookeeper.logger = log Zookeeper.set_debug_level(4) class ::Exception def to_std_format "#{self.class}: #{message}\n" + backtrace {|n| "\t#{n}"}.join("\n") e...
github
zk-ruby/zk
https://github.com/zk-ruby/zk
spec/informal/what-the-fork.rb
Ruby
mit
236
master
1,527
#!/usr/bin/env ruby require 'zk' def new_stderr_logger Logger.new($stderr).tap { |l| l.level = Logger::DEBUG } end ZK.logger = new_stderr_logger class WhatTheFork attr_reader :logger def initialize @zk = ZK.new @base_path = '/what-the-fork' @path_to_delete = "#{@base_path}/delete_me" end def...
github
zk-ruby/zk
https://github.com/zk-ruby/zk
spec/informal/two-locks-enter-three-locks-leave.rb
Ruby
mit
236
master
1,114
require 'rubygems' require 'zk' require 'logger' STDOUT.sync = true $logger = Logger.new(STDOUT) ZK_ERRORS = [ ZK::Exceptions::LockAssertionFailedError, ZK::Exceptions::InterruptedSession, ZK::Exceptions::Retryable, Zookeeper::Exceptions::ContinuationTimeoutError ].freeze ZK.logger = $logg...
github
zk-ruby/zk
https://github.com/zk-ruby/zk
spec/informal/close-in-event-thread.rb
Ruby
mit
236
master
949
#!/usr/bin/env ruby require 'zk' LOG = Logger.new($stderr).tap { |n| n.level = Logger::DEBUG } ZK.logger = LOG Zookeeper.logger = LOG class CloseInEventThread include Zookeeper::Constants def initialize @zk = ZK.new @q = Queue.new end def run @zk.on_connecting do |event| if @ok_do_it ...
github
zk-ruby/zk
https://github.com/zk-ruby/zk
lib/zk.rb
Ruby
mit
236
master
9,867
require 'rubygems' require 'zookeeper' # XXX: after 1.0 we'll need this # require 'zookeeper/compatibility' require 'forwardable' require 'thread' require 'monitor' require 'set' require 'time' require 'date' module ZK # just like stdlib Monitor but provides the SAME API AS MUTEX, FFS! # @private class Monito...
github
zk-ruby/zk
https://github.com/zk-ruby/zk
lib/zk/event_handler.rb
Ruby
mit
236
master
11,246
module ZK # This is the default watcher provided by the zookeeper connection # watchers are implemented by adding the :watch => true flag to # any #children or #get or #exists calls # # you never really need to initialize this yourself class EventHandler include Java::OrgApacheZookeeper::Watcher if defi...
github
zk-ruby/zk
https://github.com/zk-ruby/zk
lib/zk/find.rb
Ruby
mit
236
master
728
module ZK module Find # like ruby's Find module, will call the given block with each _absolute_ znode path # under +paths+. you can call ZK::Find.prune if you want to not recurse # deeper under the current directory path. # # @yield [String] each znode path under the list of paths given. # ...
github
zk-ruby/zk
https://github.com/zk-ruby/zk
lib/zk/client.rb
Ruby
mit
236
master
1,811
module ZK # A ruby-friendly wrapper around the low-level zookeeper drivers. # # You're probably looking for {Client::Base} and {Client::Threaded}. # # Once you've had a look there, take a look at {Client::Conveniences}, # {Client::StateMixin}, and {Client::Unixisms} # # @todo ACL support is pretty much ...
github
zk-ruby/zk
https://github.com/zk-ruby/zk
lib/zk/install_fork_hooks.rb
Ruby
mit
236
master
868
module ::Kernel def fork_with_zk_hooks(&block) if block new_block = proc do ::ZK::ForkHook.fire_after_child_hooks! block.call end ::ZK::ForkHook.fire_prepare_hooks! fork_without_zk_hooks(&new_block).tap do ::ZK::ForkHook.fire_after_parent_hooks! end else ...
github
zk-ruby/zk
https://github.com/zk-ruby/zk
lib/zk/pool.rb
Ruby
mit
236
master
9,705
module ZK module Pool # Base class for a ZK connection pool. There are some applications that may # require high synchronous throughput, which would be a suitable use for a # connection pool. The ZK::Client::Threaded class is threadsafe, so it's # not a problem accessing it from multiple threads, but ...
github
zk-ruby/zk
https://github.com/zk-ruby/zk
lib/zk/core_ext.rb
Ruby
mit
236
master
3,105
# @private class ::Exception unless method_defined?(:to_std_format) def to_std_format ary = ["#{self.class}: #{message}"] ary.concat(backtrace || []) ary.join("\n\t") end end end # @private class ::Thread def zk_mongoid_lock_registry self[:_zk_mongoid_lock_registry] end def zk_...
github
zk-ruby/zk
https://github.com/zk-ruby/zk
lib/zk/stat.rb
Ruby
mit
236
master
2,678
module ZK # Included in Zookeeper::Stat, extends it with some conveniences for # dealing with Stat objects. Also provides docuemntation here for the meaning # of these values. # # Some of the methods added are to match the names in [the documentation][] # # Some of this may eventually be pushed down to s...
github
zk-ruby/zk
https://github.com/zk-ruby/zk
lib/zk/logger.rb
Ruby
mit
236
master
843
module ZK # use the ZK.logger if non-nil (to allow users to override the logger) # otherwise, use a Loggging logger based on the class name module Logger def self.wrapped_logger if defined?(@@wrapped_logger) @@wrapped_logger else @@wrapped_logger = ::Logger.new(STDERR).tap { |l| l....
github
zk-ruby/zk
https://github.com/zk-ruby/zk
lib/zk/node_deletion_watcher.rb
Ruby
mit
236
master
7,752
module ZK class NodeDeletionWatcher include Zookeeper::Constants include Logger # @private module Constants NOT_YET = :not_yet BLOCKED = :yes NOT_ANYMORE = :not_anymore INTERRUPTED = :interrupted TIMED_OUT = :timed_out end include Constants attr_re...
github
zk-ruby/zk
https://github.com/zk-ruby/zk
lib/zk/subscription.rb
Ruby
mit
236
master
1,631
module ZK # Basic pattern for objects that have the concept of a parent (the thing that # granted this subscription), a callback, and that can unregister (so the # callback no longer receives events). # # expects the 'parent' to respond_to? the 'unregister' method, and will # be passed the subscription in...
github
zk-ruby/zk
https://github.com/zk-ruby/zk
lib/zk/event_handler_subscription.rb
Ruby
mit
236
master
677
module ZK # the subscription object that is passed back from subscribing # to events. # @see ZK::Client::Base#register module EventHandlerSubscription # @private def self.class_for_thread_option(thopt) case thopt when :single Base when :per_callback Actor else ...
github
zk-ruby/zk
https://github.com/zk-ruby/zk
lib/zk/extensions.rb
Ruby
mit
236
master
1,730
module ZK # this is taken from activesupport-3.2.3, and pasted here so that we don't conflict if someone # is using us as part of a rails app # # i've removed the code that includes InstanceMethods (tftfy) # @private module Concern def self.extended(base) base.instance_variable_set("@_dependencies...
github
zk-ruby/zk
https://github.com/zk-ruby/zk
lib/zk/election.rb
Ruby
mit
236
master
14,337
module ZK # NOTE: this module should be considered experimental. # # ==== Overview # # This module implements the "leader election" protocols described # {here}[http://hadoop.apache.org/zookeeper/docs/current/recipes.html#sc_leaderElection]. # # There are Candidates and Observers. Candidates take part i...
github
zk-ruby/zk
https://github.com/zk-ruby/zk
lib/zk/exceptions.rb
Ruby
mit
236
master
6,314
module ZK module Exceptions silence_warnings do OK = 0 # System and server-side errors SYSTEMERROR = -1 RUNTIMEINCONSISTENCY = SYSTEMERROR - 1 DATAINCONSISTENCY = SYSTEMERROR - 2 CONNECTIONLOSS = SYSTEMERROR - 3 MARSHALLI...
github
zk-ruby/zk
https://github.com/zk-ruby/zk
lib/zk/locker.rb
Ruby
mit
236
master
6,787
module ZK # This module contains implementations of the locking primitives described in # [the ZooKeeper recipes][recipes] that allow a user to obtain cluster-wide # global locks (with both blocking and non-blocking semantics). One # important (and attractive) attribute of these locks is that __they are # au...
github
zk-ruby/zk
https://github.com/zk-ruby/zk
lib/zk/threadpool.rb
Ruby
mit
236
master
7,310
module ZK # a simple threadpool for running blocks of code off the main thread class Threadpool include Logger include Exceptions DEFAULT_SIZE = 5 class << self # size of the ZK.defer threadpool (defaults to 5) attr_accessor :default_size ZK::Threadpool.default_size = DEFAULT_SIZ...
github
zk-ruby/zk
https://github.com/zk-ruby/zk
lib/zk/message_queue.rb
Ruby
mit
236
master
4,841
module ZK # implements a simple message queue based on Zookeeper recipes # # @see http://hadoop.apache.org/zookeeper/docs/r3.0.0/recipes.html#sc_recipes_Queues # # these are good for low-volume queues only # # because of the way zookeeper works, all message *titles* have to be read into memory # in orde...
github
zk-ruby/zk
https://github.com/zk-ruby/zk
lib/zk/threaded_callback.rb
Ruby
mit
236
master
4,072
module ZK # A class that encapsulates the queue + thread that calls a callback. # Repsonds to `call` but places call on a queue to be delivered by a thread. # You will not have a useful return value from `call` so this is only useful # for background processing. class ThreadedCallback include ZK::Logger ...
github
zk-ruby/zk
https://github.com/zk-ruby/zk
lib/zk/mongoid.rb
Ruby
mit
236
master
5,566
module ZK module Mongoid # provides a lock_for_update method based on the current class name # and Mongoid document _id. # # Before use (in one of your Rails initializers, for example) you should # assign either a ZK::Client or ZK::Pool subclass to # ZK::Mongoid::Locking.zk_lock_pool. # ...
github
zk-ruby/zk
https://github.com/zk-ruby/zk
lib/zk/fork_hook.rb
Ruby
mit
236
master
2,991
module ZK module ForkHook include ZK::Logger extend self @mutex = Mutex.new unless defined?(@mutex) @hooks = { :prepare => [], :after_child => [], :after_parent => [], } unless defined?(@hooks) attr_reader :hooks, :mutex # @private def fire_prepare_hooks! ...
github
zk-ruby/zk
https://github.com/zk-ruby/zk
lib/zk/event.rb
Ruby
mit
236
master
5,638
module ZK # Provides most of the functionality ZK uses around events. Base class is actually # [Zookeeper::Callbacks::WatcherCallback](http://rubydoc.info/gems/slyphon-zookeeper/Zookeeper::Callbacks/WatcherCallback), # but this module is mixed in and provides a lot of useful syntactic sugar. # module Event ...
github
zk-ruby/zk
https://github.com/zk-ruby/zk
lib/zk/event_handler_subscription/base.rb
Ruby
mit
236
master
2,161
module ZK module EventHandlerSubscription class Base < Subscription::Base include ZK::Logger # the path this subscription is for # @return [String] attr_accessor :path # the block associated with the path # @return [Proc] # attr_accessor :callback # an arra...
github
zk-ruby/zk
https://github.com/zk-ruby/zk
lib/zk/event_handler_subscription/actor.rb
Ruby
mit
236
master
2,049
module ZK module EventHandlerSubscription # Stealing some ideas from Celluloid, this event handler subscription # (basically, the wrapper around the user block), will spin up its own # thread for delivery, and use a queue. This gives us the basis for better # concurrency (event handlers run in paralle...
github
zk-ruby/zk
https://github.com/zk-ruby/zk
lib/zk/locker/semaphore.rb
Ruby
mit
236
master
1,913
module ZK module Locker # A semaphore implementation class Semaphore < LockerBase @default_root_node = '/_zksemaphore'.freeze unless @default_root_node class << self # the default root path we will use when a value is not given to a # constructor attr_accessor :default_roo...