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 | cedarcode/webauthn-rails | https://github.com/cedarcode/webauthn-rails | lib/generators/webauthn_authentication/bundle_helper.rb | Ruby | mit | 47 | main | 1,140 | # Extracted from: https://github.com/rails/rails/blob/7549ba77254f038b1ca6304a0be6cbda8e2a09c4/railties/lib/rails/generators/bundle_helper.rb
module BundleHelper # :nodoc:
def bundle_command(command, env = {}, params = {})
say_status :run, "bundle #{command}"
# We are going to shell out rather than invoking... |
github | cedarcode/webauthn-rails | https://github.com/cedarcode/webauthn-rails | lib/generators/webauthn_authentication/webauthn_authentication_generator.rb | Ruby | mit | 47 | main | 6,440 | require "rails/generators/base"
require "rails/generators/active_record/migration"
if Rails.version >= "8.1"
require "rails/generators/bundle_helper"
else
require "generators/webauthn_authentication/bundle_helper"
end
class WebauthnAuthenticationGenerator < ::Rails::Generators::Base
include ActiveRecord::Generat... |
github | cedarcode/webauthn-rails | https://github.com/cedarcode/webauthn-rails | lib/generators/webauthn_authentication/templates/config/initializers/webauthn.rb | Ruby | mit | 47 | main | 314 | WebAuthn.configure do |config|
# This value needs to match `window.location.origin` evaluated by
# the User Agent during registration and authentication ceremonies.
# config.allowed_origins = [ "https://auth.example.com" ]
# Relying Party name for display purposes
# config.rp_name = "Example Inc."
end |
github | randoum/autonumeric-rails | https://github.com/randoum/autonumeric-rails | autonumeric-rails.gemspec | Ruby | mit | 47 | master | 1,529 | # coding: utf-8
lib = File.expand_path('../lib', __FILE__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require 'autonumeric/rails/version'
Gem::Specification.new do |spec|
spec.name = 'autonumeric-rails'
spec.version = Autonumeric::Rails::VERSION
spec.authors = ['randoum']
spec... |
github | randoum/autonumeric-rails | https://github.com/randoum/autonumeric-rails | Rakefile | Ruby | mit | 47 | master | 440 | begin
require 'bundler/setup'
rescue LoadError
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
end
APP_RAKEFILE = File.expand_path('../spec/dummy/Rakefile', __FILE__)
load 'rails/tasks/engine.rake'
load 'active_record/railties/databases.rake'
require 'bundler/gem_tasks'
require 'rspec... |
github | randoum/autonumeric-rails | https://github.com/randoum/autonumeric-rails | spec/spec_helper.rb | Ruby | mit | 47 | master | 1,822 | ENV['RAILS_ENV'] ||= 'test'
LOCAL_PLATFORM = (Gem::Platform.local.os == 'darwin' ? :mac : :linux)
SPEC_ROOT = File.expand_path('..', __FILE__)
# Load environment
require File.expand_path('../dummy/config/environment', __FILE__)
require 'rspec/rails'
# Requires support files
Dir[Rails.root.join(SPEC_ROOT, 'support/**... |
github | randoum/autonumeric-rails | https://github.com/randoum/autonumeric-rails | spec/autonumeric-rails_spec.rb | Ruby | mit | 47 | master | 522 | require 'spec_helper'
describe 'Autonumeric-rails', type: :feature, js: true do
subject { page }
let(:expected_params) { {aSign: 'USD ', mDec: 1}.to_json }
before {
visit "/#{url}#{record_id}?test_version=#{test_version}"
wait_for_jquery
}
describe 'autoNumeric version 1' do
let(:test_version... |
github | randoum/autonumeric-rails | https://github.com/randoum/autonumeric-rails | spec/dummy/db/schema.rb | Ruby | mit | 47 | master | 954 | # encoding: UTF-8
# This file is auto-generated from the current state of the database. Instead
# of editing this file, please use the migrations feature of Active Record to
# incrementally modify your database, and then regenerate this schema definition.
#
# Note that this schema.rb definition is the authoritative sou... |
github | randoum/autonumeric-rails | https://github.com/randoum/autonumeric-rails | spec/dummy/db/migrate/20131227002328_create_records.rb | Ruby | mit | 47 | master | 208 | class CreateRecords < ActiveRecord::Migration
def change
create_table :records do |t|
t.decimal :field1, precision: 10, scale: 8
t.decimal :field2, precision: 10, scale: 8
end
end
end |
github | randoum/autonumeric-rails | https://github.com/randoum/autonumeric-rails | spec/dummy/app/controllers/forms_controller.rb | Ruby | mit | 47 | master | 763 | class FormsController < ApplicationController
before_action :set_test_version
layout :set_layout
create_action :static_fields
create_action :javascript_fields
create_action :get_content_from_ajax
def ajax_fields
@url_prefix = ''
end
def ajax_fields_with_record
@url_prefix = "/#{params[:id]}"... |
github | randoum/autonumeric-rails | https://github.com/randoum/autonumeric-rails | spec/dummy/app/controllers/records_controller.rb | Ruby | mit | 47 | master | 325 | class RecordsController < ApplicationController
def create
Record.create record_params
render nothing: true
end
def update
Record.find(params[:id]).update_attributes record_params
render nothing: true
end
private
def record_params
params.require(:record).permit [:field1, :field2]
en... |
github | randoum/autonumeric-rails | https://github.com/randoum/autonumeric-rails | spec/dummy/app/controllers/application_controller.rb | Ruby | mit | 47 | master | 292 | class ApplicationController < ActionController::Base
def self.create_action(name)
define_method(name) do
send :without_record
render action: name
end
define_method("#{name}_with_record".to_sym) do
send :with_record
render action: name
end
end
end |
github | randoum/autonumeric-rails | https://github.com/randoum/autonumeric-rails | spec/dummy/config/routes.rb | Ruby | mit | 47 | master | 593 | Dummy::Application.routes.draw do
resources :records, only: [:create, :update]
get '/static_fields', to: 'forms#static_fields'
get '/static_fields/:id', to: 'forms#static_fields_with_record'
get '/javascript_fields', to: 'forms#javascript_fields'
get '/javascript_fields/:id', to: 'forms#javascript_fields_wi... |
github | randoum/autonumeric-rails | https://github.com/randoum/autonumeric-rails | spec/dummy/config/application.rb | Ruby | mit | 47 | master | 414 | require File.expand_path('../boot', __FILE__)
require 'active_record/railtie'
require 'action_controller/railtie'
require 'action_mailer/railtie'
require 'sprockets/railtie'
require 'jquery-rails'
Bundler.require(*Rails.groups)
require 'autonumeric-rails'
module Dummy
class Application < Rails::Application
Rai... |
github | randoum/autonumeric-rails | https://github.com/randoum/autonumeric-rails | spec/dummy/config/initializers/secret_token.rb | Ruby | mit | 47 | master | 659 | # Be sure to restart your server when you modify this file.
# Your secret key is used 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 diction... |
github | randoum/autonumeric-rails | https://github.com/randoum/autonumeric-rails | spec/support/shared_examples.rb | Ruby | mit | 47 | master | 4,589 | shared_examples 'test autonumeric-rails version' do
context 'Through form helper' do
let(:url) { 'static_fields' }
it_behaves_like 'all autonumeric-rails tests'
end
context 'Javascript manually created fields' do
let(:url) { 'javascript_fields' }
it_behaves_like 'all autonumeric-rails tests'
en... |
github | randoum/autonumeric-rails | https://github.com/randoum/autonumeric-rails | spec/support/firefox_path.rb | Ruby | mit | 47 | master | 713 | def firefox_path
file = File.expand_path('../../firefox_path', __FILE__)
raise "#{file} does not exist" unless File.file? file
path = File.open(file) { |f| f.gets }.strip
raise "Firefox executable #{path} does not exist" unless File.file? path
path
rescue StandardError => e
$stderr.puts ''
$stderr.puts ... |
github | randoum/autonumeric-rails | https://github.com/randoum/autonumeric-rails | spec/support/wait_for_jquery.rb | Ruby | mit | 47 | master | 218 | def wait_for_jquery
counter = 0
while page.execute_script('return $.active').to_i > 0
counter += 1
sleep(0.1)
raise 'Interrupted: JQuery activity took longer than 5 seconds.' if counter >= 50
end
end |
github | jamis/impose | https://github.com/jamis/impose | pdf-impose.gemspec | Ruby | mit | 47 | master | 962 | $:.push File.expand_path('../lib', __FILE__)
# Maintain your gem's version:
require 'pdf/impose/version'
# Describe your gem and declare its dependencies:
Gem::Specification.new do |s|
s.name = 'pdf-impose'
s.version = PDF::Impose::VERSION
s.authors = ['Jamis Buck']
s.email = ['jamis@jami... |
github | jamis/impose | https://github.com/jamis/impose | lib/pdf/impose/page.rb | Ruby | mit | 47 | master | 579 | module PDF
module Impose
# A Page represents a single page from the source document. It
# indicates the page (by number), as well as where on the form (column/row)
# it should go, and whether it should be mirrored (inverted, by rotation)
# on the form.
class Page
attr_reader :column, :row
... |
github | jamis/impose | https://github.com/jamis/impose | lib/pdf/impose/form.rb | Ruby | mit | 47 | master | 4,239 | require 'pdf/impose/page'
module PDF
module Impose
# A Form represents a collection of pages that will be printed together on a
# single sheet of paper, in a particular (grid) layout.
#
# Form subclasses define the layout of individual pages via the `recto` and
# `verso` methods (`recto` == front... |
github | jamis/impose | https://github.com/jamis/impose | lib/pdf/impose/builder.rb | Ruby | mit | 47 | master | 7,588 | require 'pdf/reader'
require 'prawn'
require 'prawn/templates'
require 'pdf/impose/ext'
require 'pdf/impose/forms/card_fold'
require 'pdf/impose/forms/duodecimo'
require 'pdf/impose/forms/folio'
require 'pdf/impose/forms/quarto'
require 'pdf/impose/forms/octavo'
require 'pdf/impose/forms/sexto'
require 'pdf/impose/for... |
github | jamis/impose | https://github.com/jamis/impose | lib/pdf/impose/ext.rb | Ruby | mit | 47 | master | 2,749 | module PDF
module Impose
module Ext
module Reference
def extract_content_stream
content = stream
content = content.filtered_stream if content.respond_to?(:filtered_stream)
if data[:Filter]
options = []
if data[:DecodeParams].is_a?(Hash)
... |
github | jamis/impose | https://github.com/jamis/impose | lib/pdf/impose/signature.rb | Ruby | mit | 47 | master | 387 | module PDF
module Impose
# A signature is composed of one or more forms.
class Signature
attr_reader :first, :last, :pairs
def initialize(first, last)
@first = first
@last = last
@pairs = []
f, l = first, last
while f < l
@pairs << [f, l]
... |
github | jamis/impose | https://github.com/jamis/impose | lib/pdf/impose/forms/quarto.rb | Ruby | mit | 47 | master | 298 | require 'pdf/impose/form'
module PDF
module Impose
module Forms
class Quarto < Form
per_signature 4
recto %w(3* *3),
%w(0. .0)
verso %w(*2 2*),
%w(.1 1.)
end
end
end
end
# 0 | 1 . 8
# 1 | 2 . 7
# 2 | 3 . 6
# 3 | 4 . 5 |
github | jamis/impose | https://github.com/jamis/impose | lib/pdf/impose/forms/sexto.rb | Ruby | mit | 47 | master | 374 | require 'pdf/impose/form'
module PDF
module Impose
module Forms
class Sexto < Form
per_signature 4
recto %w(0. .0),
%w(3* *3),
%w(4. .4)
verso %w(.1 1.),
%w(*2 2*),
%w(.5 5.)
end
end
end
end
# 0 | 1 . 12
# 1 | 2 ... |
github | jamis/impose | https://github.com/jamis/impose | lib/pdf/impose/forms/octavo.rb | Ruby | mit | 47 | master | 377 | require 'pdf/impose/form'
module PDF
module Impose
module Forms
class Octavo < Form
per_signature 2
recto %w(3* *3 *0 0*),
%w(4. .4 .7 7.)
verso %w(1* *1 *2 2*),
%w(6. .6 .5 5.)
end
end
end
end
# 0 | 1 . 16
# 1 | 2 . 15
# 2 | 3 . 14
# 3 | 4... |
github | jamis/impose | https://github.com/jamis/impose | lib/pdf/impose/forms/duodecimo.rb | Ruby | mit | 47 | master | 1,272 | require 'pdf/impose/form'
module PDF
module Impose
module Forms
module Duodecimo
# cut into three 4to strips
class TwoCut < Form
per_signature 2
cut_row 1, 2
recto %w(.3 3. 0. .0),
%w(.7 7. 4. .4),
%w(.11 11. 8. .8)
... |
github | jamis/impose | https://github.com/jamis/impose | lib/pdf/impose/forms/folio.rb | Ruby | mit | 47 | master | 385 | require 'pdf/impose/form'
module PDF
module Impose
module Forms
module Folio
class Standard < Form
per_signature 8
recto %w(0. .0)
verso %w(.1 1.)
end
class Recto < Form
per_signature 1
cut_col 1
layout :page_numbers
... |
github | jamis/impose | https://github.com/jamis/impose | lib/pdf/impose/forms/sextodecimo.rb | Ruby | mit | 47 | master | 764 | require 'pdf/impose/form'
module PDF
module Impose
module Forms
module Sextodecimo
# two 8vo forms that nest one inside the other
class Nested < Form
per_signature 2
cut_row 2
recto %w(7* *7 *0 0*),
%w(4. .4 .3 3.),
%w(15* *15 ... |
github | jamis/impose | https://github.com/jamis/impose | lib/pdf/impose/forms/card_fold.rb | Ruby | mit | 47 | master | 406 | require 'pdf/impose/form'
module PDF
module Impose
module Forms
module CardFold
class Octavo < Form
per_signature 1
layout :page_numbers
recto %w(*3 *2 *1 *8),
%w(.4 .5 .6 .7)
end
class Quarto < Form
per_signature 1
... |
github | jamis/impose | https://github.com/jamis/impose | examples/minibook.rb | Ruby | mit | 47 | master | 3,140 | # This takes a PDF and fits either 72 (MiniBook::Octavo) or 84
# (MiniBook::TripleQuarto) leaves on a single sheet of paper. If
# used with LETTER size paper, this can produce a text block that
# is roughly 1.25 inches by 1 inch.
#
# See https://twitter.com/jamis/status/847497088950599685
require 'pdf/impose/builder'
... |
github | cavalle/eventwire | https://github.com/cavalle/eventwire | eventwire.gemspec | Ruby | mit | 47 | master | 795 | # -*- encoding: utf-8 -*-
$:.push File.expand_path('../lib', __FILE__)
require 'eventwire/version'
Gem::Specification.new do |s|
s.name = 'eventwire'
s.version = Eventwire::VERSION
s.authors = ['Luismi Cavalle']
s.email = ['luismi@lmcavalle.com']
s.homepage = 'http://github.com/cavall... |
github | cavalle/eventwire | https://github.com/cavalle/eventwire | Gemfile | Ruby | mit | 47 | master | 657 | source "http://rubygems.org"
gem 'rspec'
gem 'activesupport', :require => 'active_support/all'
gem 'i18n'
gem 'delorean'
gem 'rake'
gem 'bson_ext'
gem 'hashie'
unless ENV["CI"]
gem 'ruby-debug', :platforms => :mri_18
gem 'debugger', :platforms => :mri_19
end
# Drivers
gem 'amqp', :require => false
gem ... |
github | cavalle/eventwire | https://github.com/cavalle/eventwire | lib/eventwire.rb | Ruby | mit | 47 | master | 1,031 | require 'eventwire/version'
require 'eventwire/configuration'
require 'eventwire/publisher'
require 'eventwire/subscriber'
require 'eventwire/adapters'
require 'eventwire/middleware'
module Eventwire
class << self
def configure
yield(configuration)
end
def configuration
@configuration ||... |
github | cavalle/eventwire | https://github.com/cavalle/eventwire | lib/eventwire/configuration.rb | Ruby | mit | 47 | master | 961 | module Eventwire
class Configuration
attr_reader :middleware, :error_handler
attr_accessor :namespace, :logger, :test_mode
def initialize
@adapter = Adapters::AMQP.new
@logger = Logger.new($stdout)
@error_handler = lambda {|ex| }
@middleware = [
[ Eventwire::Middleware:... |
github | cavalle/eventwire | https://github.com/cavalle/eventwire | lib/eventwire/middleware.rb | Ruby | mit | 47 | master | 546 | module Eventwire
module Middleware
autoload :Base, 'eventwire/middleware/base'
autoload :Logger, 'eventwire/middleware/logger'
autoload :ErrorHandler, 'eventwire/middleware/error_handler'
autoload :DataObjects, 'eventwire/middleware/data_objects'
autoload :... |
github | cavalle/eventwire | https://github.com/cavalle/eventwire | lib/eventwire/adapters.rb | Ruby | mit | 47 | master | 365 | module Eventwire
module Adapters
autoload :InProcess, 'eventwire/adapters/in_process'
autoload :AMQP, 'eventwire/adapters/amqp'
autoload :SafeAMQP, 'eventwire/adapters/safe_amqp'
autoload :Bunny, 'eventwire/adapters/bunny'
autoload :Redis, 'eventwire/adapters/redis'
autoload :Mon... |
github | cavalle/eventwire | https://github.com/cavalle/eventwire | lib/eventwire/subscriber.rb | Ruby | mit | 47 | master | 1,089 | # encoding: UTF-8
module Eventwire
module Subscriber
def self.included(base)
base.extend DSL
end
module DSL
def on(*event_names, &handler)
event_names.each do |event_name|
unless !Eventwire.configuration.test_mode && Eventwire.subscribe?(event_name.to_sym, handler_id(eve... |
github | cavalle/eventwire | https://github.com/cavalle/eventwire | lib/eventwire/adapters/redis.rb | Ruby | mit | 47 | master | 1,137 | require 'redis'
require 'em-redis'
class Eventwire::Adapters::Redis
def initialize
@handlers = []
end
def publish(event_name, event_data = nil)
redis = ::Redis.new
handlers = redis.smembers("event_handlers:#{event_name}")
handlers.each do |handler|
redis.rpush handler, event_data
end... |
github | cavalle/eventwire | https://github.com/cavalle/eventwire | lib/eventwire/adapters/bunny.rb | Ruby | mit | 47 | master | 1,537 | require 'bunny'
class Eventwire::Adapters::Bunny
def initialize(options = {})
@options = options
end
def publish(event_name, event_data = nil)
connect do |mq|
mq.exchange(event_name.to_s, :type => :fanout).publish(event_data)
end
end
def subscribe(event_name, handler_id, &handler)
... |
github | cavalle/eventwire | https://github.com/cavalle/eventwire | lib/eventwire/adapters/amqp.rb | Ruby | mit | 47 | master | 1,476 | require 'bunny'
require 'amqp'
class Eventwire::Adapters::AMQP
def initialize(options = {})
@options = options
end
def publish(event_name, event_data = nil)
connect_synch do |mq|
mq.exchange(event_name.to_s, :type => :fanout).publish(event_data)
end
end
def subscribe(event_name, handl... |
github | cavalle/eventwire | https://github.com/cavalle/eventwire | lib/eventwire/adapters/mongo.rb | Ruby | mit | 47 | master | 1,368 | require 'mongo'
class Eventwire::Adapters::Mongo
DB_NAME = 'broker'
def initialize
@handlers = []
end
def publish(event_name, event_data = nil)
collection = db.collection('event_handlers')
collection.find(:event_name => event_name).each do |handler|
queue = db.collection(handler['handler'... |
github | cavalle/eventwire | https://github.com/cavalle/eventwire | lib/eventwire/adapters/in_process.rb | Ruby | mit | 47 | master | 567 | class Eventwire::Adapters::InProcess
def initialize
@handlers = {}
end
def handlers(event_name)
@handlers[event_name] ||= []
end
def publish(event_name, event_data = nil)
handlers(event_name).map(&:last).each do |handler|
handler.call event_data
end
end
def subscribe(event_n... |
github | cavalle/eventwire | https://github.com/cavalle/eventwire | lib/eventwire/adapters/safe_amqp.rb | Ruby | mit | 47 | master | 2,114 | require 'bunny'
require 'amqp'
require 'amqp/extensions/rabbitmq'
class Eventwire::Adapters::SafeAMQP
def initialize(options = {})
@options = options
end
def publish(event_name, event_data = nil)
keep_reactor_loop = EM.reactor_running?
connect_asynch do |conn|
AMQP::Channel.new(conn) do |chan... |
github | cavalle/eventwire | https://github.com/cavalle/eventwire | lib/eventwire/middleware/json_serializer.rb | Ruby | mit | 47 | master | 498 | require 'json'
module Eventwire
module Middleware
class JSONSerializer < Base
def subscribe(event_name, handler_id, &handler)
@app.subscribe event_name, handler_id do |data|
handler.call parse_json(data)
end
end
def publish(event_name, event_data)
@app.p... |
github | cavalle/eventwire | https://github.com/cavalle/eventwire | lib/eventwire/middleware/logger.rb | Ruby | mit | 47 | master | 829 | module Eventwire
module Middleware
class Logger < Base
def initialize(app, config)
super(app)
@config = config
end
def subscribe(event_name, handler_id, &handler)
@app.subscribe event_name, handler_id do |data|
begin
logger.info "Starting to p... |
github | cavalle/eventwire | https://github.com/cavalle/eventwire | lib/eventwire/middleware/bson_serializer.rb | Ruby | mit | 47 | master | 399 | require 'bson'
module Eventwire
module Middleware
class BSONSerializer < Base
def subscribe(event_name, handler_id, &handler)
@app.subscribe event_name, handler_id do |data|
handler.call BSON.deserialize(data)
end
end
def publish(event_name, event_data)
... |
github | cavalle/eventwire | https://github.com/cavalle/eventwire | lib/eventwire/middleware/error_handler.rb | Ruby | mit | 47 | master | 666 | module Eventwire
module Middleware
class ErrorHandler < Base
def initialize(app, config = nil)
super(app)
@config = config
end
def subscribe(event_name, handler_id, &handler)
@app.subscribe event_name, handler_id do |data|
begin
handler.call(data)
... |
github | cavalle/eventwire | https://github.com/cavalle/eventwire | lib/eventwire/middleware/msgpack_serializer.rb | Ruby | mit | 47 | master | 435 | require 'msgpack'
# TODO: Add support for Time
module Eventwire
module Middleware
class MessagePackSerializer < Base
def subscribe(event_name, handler_id, &handler)
@app.subscribe event_name, handler_id do |data|
handler.call MessagePack.unpack(data)
end
end
def... |
github | cavalle/eventwire | https://github.com/cavalle/eventwire | lib/eventwire/middleware/data_objects.rb | Ruby | mit | 47 | master | 364 | require 'hashie/mash'
module Eventwire
module Middleware
class DataObjects < Base
def subscribe(event_name, handler_id, &handler)
@app.subscribe event_name, handler_id do |data|
handler.call build_event(data)
end
end
private
def build_event(data)
Hashie... |
github | cavalle/eventwire | https://github.com/cavalle/eventwire | spec/spec_helper.rb | Ruby | mit | 47 | master | 457 | require 'rubygems'
require 'bundler'
Bundler.require
require 'eventwire'
Dir[File.expand_path(File.join(File.dirname(__FILE__), 'support', '**', '*.rb'))].each { |f| require f }
include Adapters
def sleep(time)
factor = ENV['SLEEP_FACTOR'] || 1
super time * factor.to_f
end
RSpec.configure do |config|
config.... |
github | cavalle/eventwire | https://github.com/cavalle/eventwire | spec/acceptance/project_management_spec.rb | Ruby | mit | 47 | master | 2,172 | # encoding: UTF-8
require 'spec_helper'
describe 'Project Management System' do
adapters = %w{InProcess AMQP Redis}
adapters.each do |adapter|
with_adapter adapter do
before do
Eventwire.configure do |c|
c.adapter = adapter
c.logger = Logger.new(nil)
end
l... |
github | cavalle/eventwire | https://github.com/cavalle/eventwire | spec/support/adapters.rb | Ruby | mit | 47 | master | 760 | module Adapters
def describe_adapter(adapter_class, &block)
adapter = adapter_class.to_s.gsub(/^.*::/, '')
describe(adapter_class, &block) if should_be_tested?(adapter)
end
def with_adapter(adapter, &block)
if should_be_tested?(adapter)
context "using the #{adapter} adapter", &block
end
e... |
github | cavalle/eventwire | https://github.com/cavalle/eventwire | spec/support/helpers.rb | Ruby | mit | 47 | master | 664 | module Helpers
def class_including(mod)
Class.new.tap {|c| c.send :include, mod }
end
def eventually(timeout = 1, &block)
# Expectations must be met in less that timeout secs
start = Time.now
loop do
begin
block.call
break
rescue RSpec::Expectations::ExpectationNotMe... |
github | cavalle/eventwire | https://github.com/cavalle/eventwire | spec/unit/subscriber_spec.rb | Ruby | mit | 47 | master | 3,879 | # encoding: UTF-8
require 'spec_helper'
describe Eventwire::Subscriber do
describe '#on' do
before do
@driver = mock
Eventwire.configuration.stub(:driver => @driver)
Eventwire.configuration.logger = Logger.new(nil)
end
subject { class_including Eventwire::Subscriber }
... |
github | cavalle/eventwire | https://github.com/cavalle/eventwire | spec/unit/configuration_spec.rb | Ruby | mit | 47 | master | 3,763 | # encoding: UTF-8
require 'spec_helper'
describe Eventwire::Configuration do
describe 'driver' do
context 'without middleware' do
before do
subject.middleware.clear
end
it 'returns a AMQP adapter if none is set' do
subject.driver.should be_instance_of(Eventwire::Adapters::AMQP)... |
github | cavalle/eventwire | https://github.com/cavalle/eventwire | spec/unit/publisher_spec.rb | Ruby | mit | 47 | master | 930 | # encoding: UTF-8
require 'spec_helper'
describe Eventwire::Publisher do
describe '#publish_event' do
before do
@driver = mock
Eventwire.configuration.stub(:driver => @driver)
end
subject { class_including(Eventwire::Publisher).new }
it 'should publish the event using th... |
github | cavalle/eventwire | https://github.com/cavalle/eventwire | spec/unit/middleware/error_handler_spec.rb | Ruby | mit | 47 | master | 1,832 | # encoding: UTF-8
require 'spec_helper'
describe Eventwire::Middleware::ErrorHandler do
let(:app) { mock }
subject { Eventwire::Middleware::ErrorHandler.new(app, stub(:error_handler => proc {}, :logger => Logger.new(nil))) }
describe 'subscribe' do
it 'should call app’s subscribe' do
app.should_r... |
github | cavalle/eventwire | https://github.com/cavalle/eventwire | spec/unit/middleware/data_objects_spec.rb | Ruby | mit | 47 | master | 1,002 | # encoding: UTF-8
require 'spec_helper'
describe Eventwire::Middleware::DataObjects do
let(:app) { mock }
subject { Eventwire::Middleware::DataObjects.new(app) }
describe 'subscribe' do
it 'should call app’s subscribe' do
app.should_receive(:subscribe).with(:event_name, :handler_id)
sub... |
github | cavalle/eventwire | https://github.com/cavalle/eventwire | spec/unit/middleware/json_serializer_spec.rb | Ruby | mit | 47 | master | 1,194 | # encoding: UTF-8
require 'spec_helper'
describe Eventwire::Middleware::JSONSerializer do
let(:app) { mock }
subject { Eventwire::Middleware::JSONSerializer.new(app) }
describe 'subscribe' do
it 'should call app’s subscribe' do
app.should_receive(:subscribe).with(:event_name, :handler_id)
... |
github | cavalle/eventwire | https://github.com/cavalle/eventwire | spec/unit/middleware/msgpack_serializer_spec.rb | Ruby | mit | 47 | master | 966 | # encoding: UTF-8
require 'spec_helper'
describe Eventwire::Middleware::MessagePackSerializer do
let(:app) { mock }
subject { Eventwire::Middleware::MessagePackSerializer.new(app) }
describe 'subscribe' do
it 'should call app’s subscribe' do
app.should_receive(:subscribe).with(:event_name, :handler_... |
github | cavalle/eventwire | https://github.com/cavalle/eventwire | spec/unit/middleware/logger_spec.rb | Ruby | mit | 47 | master | 1,790 | # encoding: UTF-8
require 'spec_helper'
describe Eventwire::Middleware::Logger do
let(:app) { mock }
let(:io) { StringIO.new }
subject { Eventwire::Middleware::Logger.new(app, stub(:logger => Logger.new(io))) }
describe 'subscribe' do
it 'should call app’s subscribe' do
app.should_receive(:subs... |
github | cavalle/eventwire | https://github.com/cavalle/eventwire | spec/unit/middleware/bson_serializer_spec.rb | Ruby | mit | 47 | master | 962 | # encoding: UTF-8
require 'spec_helper'
describe Eventwire::Middleware::BSONSerializer do
let(:app) { mock }
subject { Eventwire::Middleware::BSONSerializer.new(app) }
describe 'subscribe' do
it 'should call app’s subscribe' do
app.should_receive(:subscribe).with(:event_name, :handler_id)
... |
github | cavalle/eventwire | https://github.com/cavalle/eventwire | spec/integration/adapters/mongo_spec.rb | Ruby | mit | 47 | master | 228 | require 'integration/adapters/adapters_helper'
describe_adapter Eventwire::Adapters::Mongo do
it_should_behave_like 'an adapter with single-process support'
it_should_behave_like 'an adapter with multi-process support'
end |
github | cavalle/eventwire | https://github.com/cavalle/eventwire | spec/integration/adapters/redis_spec.rb | Ruby | mit | 47 | master | 228 | require 'integration/adapters/adapters_helper'
describe_adapter Eventwire::Adapters::Redis do
it_should_behave_like 'an adapter with single-process support'
it_should_behave_like 'an adapter with multi-process support'
end |
github | cavalle/eventwire | https://github.com/cavalle/eventwire | spec/integration/adapters/amqp_spec.rb | Ruby | mit | 47 | master | 797 | require 'integration/adapters/adapters_helper'
describe_adapter Eventwire::Adapters::AMQP do
it_should_behave_like 'an adapter with single-process support'
it_should_behave_like 'an adapter with multi-process support'
describe 'with options given' do
let(:options) { stub }
subject { Eventwire::Adapters... |
github | cavalle/eventwire | https://github.com/cavalle/eventwire | spec/integration/adapters/safe_amqp_spec.rb | Ruby | mit | 47 | master | 806 | require 'integration/adapters/adapters_helper'
describe_adapter Eventwire::Adapters::SafeAMQP do
it_should_behave_like 'an adapter with single-process support'
it_should_behave_like 'an adapter with multi-process support'
describe 'with options given' do
let(:options) { stub }
subject { Eventwire::Adap... |
github | cavalle/eventwire | https://github.com/cavalle/eventwire | spec/integration/adapters/adapters_helper.rb | Ruby | mit | 47 | master | 4,283 | require 'spec_helper'
require 'timeout'
shared_examples_for 'an adapter with single-process support' do
def start_worker
@t = Thread.new { subject.start }
@t.abort_on_exception = true
sleep 0.1
end
after do
subject.stop
subject.purge
if @t
@t.join(1)
@t.kill
end
end
... |
github | cavalle/eventwire | https://github.com/cavalle/eventwire | spec/integration/adapters/bunny_spec.rb | Ruby | mit | 47 | master | 798 | require 'integration/adapters/adapters_helper'
describe_adapter Eventwire::Adapters::Bunny do
it_should_behave_like 'an adapter with single-process support'
it_should_behave_like 'an adapter with multi-process support'
describe 'with options given' do
let(:options) { stub }
subject { Eventwire::Adapter... |
github | cavalle/eventwire | https://github.com/cavalle/eventwire | examples/project_management/task.rb | Ruby | mit | 47 | master | 383 | self.class.send :remove_const, :Task if defined?(Task)
class Task
include Eventwire::Publisher
def initialize(name)
@name = name
publish_event :task_created, :task_name => @name, :timestamp => Time.now
end
def mark_as_complete!(user)
@completed = true
publish_event :task_completed, :task_na... |
github | cavalle/eventwire | https://github.com/cavalle/eventwire | examples/project_management/tasks_stats.rb | Ruby | mit | 47 | master | 619 | self.class.send :remove_const, :TasksStats if defined?(TasksStats)
module TasksStats
include Eventwire::Subscriber
@completion_time_sum = 0
@completion_time_count = 0
@start_times = {}
on :task_created do |event|
@start_times[event.task_name] = Time.parse(event.timestamp.to_s)
end
on :task_com... |
github | cavalle/eventwire | https://github.com/cavalle/eventwire | examples/project_management/notifier.rb | Ruby | mit | 47 | master | 512 | self.class.send :remove_const, :Notifier if defined?(Notifier)
class Notifier
include Eventwire::Subscriber
on :task_completed do |event|
Notifier.new(:email => find_boss_email(event.by),
:subject => "Task #{event.task_name} completed").send!
end
def initialize(email)
@email = e... |
github | mtgrosser/pdfunite | https://github.com/mtgrosser/pdfunite | pdfunite.gemspec | Ruby | mit | 47 | master | 774 | # coding: utf-8
lib = File.expand_path('../lib', __FILE__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require 'pdfunite/version'
Gem::Specification.new do |spec|
spec.name = 'pdfunite'
spec.version = Pdfunite::VERSION
spec.authors = ['Matthias Grosser']
spec.email = ['... |
github | mtgrosser/pdfunite | https://github.com/mtgrosser/pdfunite | Rakefile | Ruby | mit | 47 | master | 240 | require 'rake'
require 'rake/testtask'
desc 'Default: run unit tests.'
task :default => :test
desc 'Run all tests'
Rake::TestTask.new(:test) do |t|
t.libs << 'lib'
t.test_files = FileList['test/unit/*_test.rb']
t.verbose = true
end |
github | mtgrosser/pdfunite | https://github.com/mtgrosser/pdfunite | test/test_helper.rb | Ruby | mit | 47 | master | 671 | ENV["RAILS_ENV"] = "test"
require 'pathname'
if RUBY_VERSION >= '1.9'
require 'simplecov'
SimpleCov.start do
if artifacts_dir = ENV['CC_BUILD_ARTIFACTS']
coverage_dir Pathname.new(artifacts_dir).relative_path_from(Pathname.new(SimpleCov.root)).to_s
end
add_filter '/test/'
add_filter 'vendor'... |
github | mtgrosser/pdfunite | https://github.com/mtgrosser/pdfunite | test/unit/pdfunite_test.rb | Ruby | mit | 47 | master | 1,837 | require_relative '../test_helper'
class PdfuniteTest < Minitest::Test
def setup
@files = (1..4).map { |i| test_file(i).to_s }
end
def test_joining_existing_pdf_files
assert_pdf Pdfunite.join(@files)
end
def test_joining_pdf_data_provided_by_generic_objects
assert_pdf Pdfunite.join(@files) {... |
github | mtgrosser/pdfunite | https://github.com/mtgrosser/pdfunite | lib/pdfunite.rb | Ruby | mit | 47 | master | 1,881 | require 'pdfunite/version'
require 'tmpdir'
require 'pathname'
require 'open3'
require 'shellwords'
require 'logger'
module Pdfunite
class BinaryNotFound < StandardError; end
class << self
@@logger = nil
# You can set a custom logger here
def logger=(logger)
@@logger = logger
... |
github | kfischer-okarin/dragonruby-toolbox | https://github.com/kfischer-okarin/dragonruby-toolbox | lib/transformations.rb | Ruby | mit | 47 | master | 1,429 | # Copyright (c) 2020 Kevin Fischer
# https://github.com/kfischer-okarin/dragonruby-toolbox
# Released under the MIT License (see repository)
module DRT
module Transformations
# Primitive wrapper which returns transformed primitive values
class Transformed
attr_sprite
attr_reader :original, :tran... |
github | kfischer-okarin/dragonruby-toolbox | https://github.com/kfischer-okarin/dragonruby-toolbox | lib/attr_sprite_color.rb | Ruby | mit | 47 | master | 562 | # Copyright (c) 2020 Kevin Fischer
# https://github.com/kfischer-okarin/dragonruby-toolbox
# Released under the MIT License (see repository)
# Including this file will automatically extend the attr_sprite class macro
module DRT
# Adds support for color objects to attr_sprite enhanced classes
module AttrSpriteColo... |
github | kfischer-okarin/dragonruby-toolbox | https://github.com/kfischer-okarin/dragonruby-toolbox | lib/autotile.rb | Ruby | mit | 47 | master | 25,535 | # Copyright (c) 2020 Kevin Fischer
# https://github.com/kfischer-okarin/dragonruby-toolbox
# Released under the MIT License (see repository)
module DRT
# Autotile that renders in different ways depending on how many neighbors have the same tiles
class Autotile
attr_reader :path, :size
# Create a single au... |
github | kfischer-okarin/dragonruby-toolbox | https://github.com/kfischer-okarin/dragonruby-toolbox | lib/color.rb | Ruby | mit | 47 | master | 2,133 | # Copyright (c) 2020 Kevin Fischer
# https://github.com/kfischer-okarin/dragonruby-toolbox
# Released under the MIT License (see repository)
module DRT
# Color represented as a single object
class Color
def initialize(r, g, b, a = nil) # rubocop:disable Naming/MethodParameterName
@color = [r, g, b, a || ... |
github | kfischer-okarin/dragonruby-toolbox | https://github.com/kfischer-okarin/dragonruby-toolbox | lib/low_resolution_canvas.rb | Ruby | mit | 47 | master | 1,968 | # Copyright (c) 2020 Kevin Fischer
# https://github.com/kfischer-okarin/dragonruby-toolbox
# Released under the MIT License (see repository)
module DRT
# Add your primitives to the {#labels}, {#lines}, {#solids}, {#borders}, {#sprites} and {#primitives} properties of
# this object and then add this object to `args... |
github | kfischer-okarin/dragonruby-toolbox | https://github.com/kfischer-okarin/dragonruby-toolbox | lib/quaternion.rb | Ruby | mit | 47 | master | 1,973 | # Copyright (c) 2020 Kevin Fischer
# https://github.com/kfischer-okarin/dragonruby-toolbox
# Released under the MIT License (see repository)
module DRT
# Quaternion used to represent a rotation in 3D space
#
# @example Rotating an object by 120 degrees around the axis defined by vector (0, 1, 1)
# rotation =... |
github | kfischer-okarin/dragonruby-toolbox | https://github.com/kfischer-okarin/dragonruby-toolbox | lib/drt/math.rb | Ruby | mit | 47 | master | 1,399 | # Copyright (c) 2021-2022 Kevin Fischer
# https://github.com/kfischer-okarin/dragonruby-toolbox
# Released under the MIT License (see repository)
module DRT
module Math
# Calculates a parabola going through the given points.
class Parabola
# rubocop:disable Metrics/AbcSize, Metrics/MethodLength, Naming... |
github | kfischer-okarin/dragonruby-toolbox | https://github.com/kfischer-okarin/dragonruby-toolbox | lib/drt/damage_numbers/bof3_style.rb | Ruby | mit | 47 | master | 3,969 | # Copyright (c) 2021-2022 Kevin Fischer
# https://github.com/kfischer-okarin/dragonruby-toolbox
# Released under the MIT License (see repository)
require 'lib/drt/math.rb'
module DRT
module DamageNumbers
# Creates a Breath of Fire 3 style damage number animation
#
# @example Create a damage number anima... |
github | kfischer-okarin/dragonruby-toolbox | https://github.com/kfischer-okarin/dragonruby-toolbox | app/colors_hsv_hsl.rb | Ruby | mit | 47 | master | 3,004 | # require 'lib/color.rb'
# rubocop:disable all
class ColorsHsvHslExample
def tick(args)
args.state.type ||= :hsv
args.state.value ||= 1.0
refresh_wheel(args) if args.tick_count.zero?
args.outputs.sprites << [0, 0, 1280, 720, :wheel]
if args.inputs.keyboard.key_down.up
args.state.value = ... |
github | kfischer-okarin/dragonruby-toolbox | https://github.com/kfischer-okarin/dragonruby-toolbox | app/transformations.rb | Ruby | mit | 47 | master | 3,006 | # require 'lib/transformations.rb'
# rubocop:disable all
class TransformationsExample
def tick(args)
if args.tick_count.zero?
prepare_random_boxes args.render_target(:random_boxes)
args.state.night = false
args.state.camera = Camera.new([0, 0])
args.state.night_filter = NightFilter.new
... |
github | kfischer-okarin/dragonruby-toolbox | https://github.com/kfischer-okarin/dragonruby-toolbox | app/low_resolution.rb | Ruby | mit | 47 | master | 737 | # require 'lib/low_resolution_canvas.rb'
# rubocop:disable all
class LowResolutionExample
def tick(args)
# Specify your canvas resolution as the first constructor argument
args.state.canvas ||= DRT::LowResolutionCanvas.new([64, 64])
args.state.canvas.background_color = [255, 255, 255]
args.state.can... |
github | kfischer-okarin/dragonruby-toolbox | https://github.com/kfischer-okarin/dragonruby-toolbox | app/color_accessor.rb | Ruby | mit | 47 | master | 1,831 | # require 'lib/color.rb'
# require 'lib/attr_sprite_accessor.rb'
# rubocop:disable all
class ColorAccessorExample
def tick(args)
args.state.dragon ||= create_dragon
args.state.dragon.tick(args)
handle_dragon_movement(args)
args.outputs.labels << [10, 600, "Press 1, 2, 3 or 4 to change dragon color"... |
github | kfischer-okarin/dragonruby-toolbox | https://github.com/kfischer-okarin/dragonruby-toolbox | app/autotiles.rb | Ruby | mit | 47 | master | 2,493 | # require 'lib/low_resolution_canvas.rb'
# rubocop:disable all
class AutotileExample
TILE_SIZE = 32
RENDER_SIZE = 32
def tick(args)
# Uncomment to use a handmade 47-tile tileset
# args.state.tile ||= DRT::Autotile.new('sprites/autotile-tileset.png', TILE_SIZE)
args.state.tile ||= DRT::Autotile.new(:... |
github | kfischer-okarin/dragonruby-toolbox | https://github.com/kfischer-okarin/dragonruby-toolbox | app/main.rb | Ruby | mit | 47 | master | 1,607 | # rubocop:disable all
require 'lib/transformations.rb'
require 'app/transformations.rb'
require 'lib/color.rb'
require 'app/colors_hsv_hsl.rb'
require 'lib/attr_sprite_color.rb'
require 'app/color_accessor.rb'
require 'lib/low_resolution_canvas.rb'
require 'app/low_resolution.rb'
require 'lib/autotile.rb'
require '... |
github | kfischer-okarin/dragonruby-toolbox | https://github.com/kfischer-okarin/dragonruby-toolbox | app/damage_numbers.rb | Ruby | mit | 47 | master | 3,269 | require 'lib/drt/damage_numbers/bof3_style.rb'
class DamageNumbersExample
def initialize
@style_index = 0
@tick_slowdown_factor = 1
end
def tick(args)
if @animation
play_animation(args)
else
args.outputs.primitives << [10, 30, 'Press SPACE to show damage animation. Press number to ch... |
github | dzintars-valoda/dzintars | https://github.com/dzintars-valoda/dzintars | dzintars.gemspec | Ruby | mit | 47 | master | 962 | # coding: utf-8
lib = File.expand_path('../lib', __FILE__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require 'dzintars/version'
Gem::Specification.new do |spec|
spec.name = "dzintars"
spec.version = Dzintars::VERSION
spec.authors = ["Raimonds Simanovskis"]
spec.email ... |
github | dzintars-valoda/dzintars | https://github.com/dzintars-valoda/dzintars | spec/spec_helper.rb | Ruby | mit | 47 | master | 1,629 | # encoding: utf-8
# This file was generated by the `rspec --init` command. Conventionally, all
# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
# Require this file using `require "spec_helper"` to ensure that it is only
# loaded once.
#
# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Co... |
github | dzintars-valoda/dzintars | https://github.com/dzintars-valoda/dzintars | spec/dzintars/kompilators_spec.rb | Ruby | mit | 47 | master | 2,715 | # encoding: utf-8
require "spec_helper"
aprakstīt "Kompilators" do
lai(:sākuma_kods) do
"# encoding: utf-8\nrequire \"dzintars/core_ext\"\n"
end
lai(:kompilators) do
Dzintars::Kompilators.new
end
tas "nokompilē tukšu Dzintara programmu" do
kompilators.uz_ruby("").should == sākuma_kods + ""
en... |
github | dzintars-valoda/dzintars | https://github.com/dzintars-valoda/dzintars | lib/dzintars/ruby_parser_patches.rb | Ruby | mit | 47 | master | 4,790 | # encoding: utf-8
class RubyLexer
##
# Parse a number from the input stream.
#
# @param c The first character of the number.
# @return A int constant wich represents a token.
def parse_number
self.lex_state = :expr_end
case
when src.scan(/[+-]?0[xXbBdD]\b/) then
rb_compile_error "Inval... |
github | dzintars-valoda/dzintars | https://github.com/dzintars-valoda/dzintars | lib/dzintars/kompilators.rb | Ruby | mit | 47 | master | 484 | # encoding: utf-8
require 'ruby2ruby'
require 'ruby_parser'
require 'dzintars/ruby_parser_patches'
module Dzintars
class Kompilators
def initialize
end
SĀKUMA_KODS = "# encoding: utf-8\nrequire \"dzintars/core_ext\"\n"
def uz_ruby(kods)
ruby2ruby = Ruby2Ruby.new
parser = RubyParser.... |
github | sensu/sensu-docs-legacy | https://github.com/sensu/sensu-docs-legacy | legacy/0.18/files/cpu-metrics.rb | Ruby | mit | 47 | master | 1,635 | #! /usr/bin/env ruby
# encoding: UTF-8
#
# cpu-metrics
#
# DESCRIPTION:
#
# OUTPUT:
# metric data
#
# PLATFORMS:
# Linux
#
# DEPENDENCIES:
# gem: sensu-plugin
# gem: socket
#
# USAGE:
#
# NOTES:
#
# LICENSE:
# Copyright 2012 Sonian, Inc <chefs@sonian.net>
# Released under the same terms as Sensu (the MIT... |
github | sensu/sensu-docs-legacy | https://github.com/sensu/sensu-docs-legacy | legacy/0.18/files/event-file.rb | Ruby | mit | 47 | master | 402 | #!/usr/bin/env ruby
require 'rubygems'
require 'json'
# Read the JSON event data from STDIN.
event = JSON.parse(STDIN.read, :symbolize_names => true)
# Write the event data to a file.
# Using the client and check names in the file name.
file_name = "/tmp/sensu_#{event[:client][:name]}_#{event[:check][:name]}.json"
... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.