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
copycopter/copycopter-ruby-client
https://github.com/copycopter/copycopter-ruby-client
lib/copycopter_client/errors.rb
Ruby
mit
177
master
514
module CopycopterClient # Raised when an error occurs while contacting the Copycopter server. This is # raised by {Client} and generally rescued by {Cache}. The application will # not encounter this error. Polling will continue even if this error is raised. class ConnectionError < StandardError end # Raise...
github
copycopter/copycopter-ruby-client
https://github.com/copycopter/copycopter-ruby-client
lib/copycopter_client/poller.rb
Ruby
mit
177
master
1,054
require 'thread' require 'copycopter_client/cache' module CopycopterClient # Starts a background thread that continually resynchronizes with the remote # server using the given {Cache} after a set delay. class Poller # @param options [Hash] # @option options [Logger] :logger where errors should be logged...
github
copycopter/copycopter-ruby-client
https://github.com/copycopter/copycopter-ruby-client
lib/copycopter_client/rails.rb
Ruby
mit
177
master
686
module CopycopterClient # Responsible for Rails initialization module Rails # Sets up the logger, environment, name, project root, and framework name # for Rails applications. Must be called after framework initialization. def self.initialize CopycopterClient.configure(false) do |config| c...
github
copycopter/copycopter-ruby-client
https://github.com/copycopter/copycopter-ruby-client
lib/copycopter_client/configuration.rb
Ruby
mit
177
master
7,850
require 'logger' require 'copycopter_client/i18n_backend' require 'copycopter_client/client' require 'copycopter_client/cache' require 'copycopter_client/process_guard' require 'copycopter_client/poller' require 'copycopter_client/prefixed_logger' require 'copycopter_client/request_sync' module CopycopterClient # Us...
github
copycopter/copycopter-ruby-client
https://github.com/copycopter/copycopter-ruby-client
lib/copycopter_client/prefixed_logger.rb
Ruby
mit
177
master
973
module CopycopterClient class PrefixedLogger attr_reader :prefix, :original_logger def initialize(prefix, logger) @prefix = prefix @original_logger = logger end def info(message = nil, &block) log(:info, message, &block) end def debug(message = nil, &block) ...
github
copycopter/copycopter-ruby-client
https://github.com/copycopter/copycopter-ruby-client
lib/copycopter_client/i18n_backend.rb
Ruby
mit
177
master
2,990
require 'i18n' module CopycopterClient # I18n implementation designed to synchronize with Copycopter. # # Expects an object that acts like a Hash, responding to +[]+, +[]=+, and +keys+. # # This backend will be used as the default I18n backend when the client is # configured, so you will not need to instan...
github
copycopter/copycopter-ruby-client
https://github.com/copycopter/copycopter-ruby-client
lib/copycopter_client/railtie.rb
Ruby
mit
177
master
332
module CopycopterClient # Connects to integration points for Rails 3 applications class Railtie < ::Rails::Railtie initializer :initialize_copycopter_rails, :after => :before_initialize do CopycopterClient::Rails.initialize end rake_tasks do load "tasks/copycopter_client_tasks.rake" end...
github
copycopter/copycopter-ruby-client
https://github.com/copycopter/copycopter-ruby-client
lib/copycopter_client/process_guard.rb
Ruby
mit
177
master
2,380
module CopycopterClient # Starts the poller from a worker process, or register hooks for a spawner # process (such as in Unicorn or Passenger). Also registers hooks for exiting # processes and completing background jobs. Applications using the client # will not need to interact with this class directly. class...
github
copycopter/copycopter-ruby-client
https://github.com/copycopter/copycopter-ruby-client
spec/copycopter_client_spec.rb
Ruby
mit
177
master
552
require 'spec_helper' describe CopycopterClient do before do CopycopterClient.configuration.stubs(:cache => 'cache', :client => 'client') end it 'delegates cache to the configuration object' do CopycopterClient.cache.should == 'cache' CopycopterClient.confi...
github
copycopter/copycopter-ruby-client
https://github.com/copycopter/copycopter-ruby-client
spec/spec_helper.rb
Ruby
mit
177
master
632
require 'rubygems' require 'rspec' require 'bourne' require 'sham_rack' require 'webmock/rspec' PROJECT_ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..')) $LOAD_PATH << File.join(PROJECT_ROOT, 'lib') require 'copycopter_client' Dir.glob(File.join(PROJECT_ROOT, 'spec', 'support', '**', '*.rb')).each do...
github
copycopter/copycopter-ruby-client
https://github.com/copycopter/copycopter-ruby-client
spec/copycopter_client/cache_spec.rb
Ruby
mit
177
master
6,576
require 'spec_helper' describe CopycopterClient::Cache do let(:client) { FakeClient.new } def build_cache(config = {}) config[:logger] ||= FakeLogger.new default_config = CopycopterClient::Configuration.new.to_hash CopycopterClient::Cache.new(client, default_config.update(config)) end it "provide...
github
copycopter/copycopter-ruby-client
https://github.com/copycopter/copycopter-ruby-client
spec/copycopter_client/prefixed_logger_spec.rb
Ruby
mit
177
master
1,012
require 'spec_helper' describe CopycopterClient::PrefixedLogger do let(:output_logger) { FakeLogger.new } let(:prefix) { "** NOTICE:" } let(:thread_info) { "[P:#{Process.pid}] [T:#{Thread.current.object_id}]" } subject { CopycopterClient::PrefixedLogger.new(prefix, output_logger) } it "provides the prefix" ...
github
copycopter/copycopter-ruby-client
https://github.com/copycopter/copycopter-ruby-client
spec/copycopter_client/process_guard_spec.rb
Ruby
mit
177
master
3,262
require 'spec_helper' describe CopycopterClient::ProcessGuard do include DefinesConstants before do @original_process_name = $0 end after do $0 = @original_process_name end let(:cache) { stub('cache', :flush => nil) } let(:poller) { stub('poller', :start => nil) } def build_process_guard(op...
github
copycopter/copycopter-ruby-client
https://github.com/copycopter/copycopter-ruby-client
spec/copycopter_client/configuration_spec.rb
Ruby
mit
177
master
9,731
require 'spec_helper' describe CopycopterClient::Configuration do RSpec::Matchers.define :have_config_option do |option| match do |config| config.should respond_to(option) if instance_variables.include?(:'@default') config.send(option).should == @default end if @overridable ...
github
copycopter/copycopter-ruby-client
https://github.com/copycopter/copycopter-ruby-client
spec/copycopter_client/request_sync_spec.rb
Ruby
mit
177
master
1,239
require 'spec_helper' describe CopycopterClient::RequestSync do let(:cache) { {} } let(:response) { 'response' } let(:env) { 'env' } let(:app) { stub('app', :call => response) } before { cache.stubs(:flush => nil, :download => nil) } subject { CopycopterClient::RequestSync.new(app, :cache => cache) } i...
github
copycopter/copycopter-ruby-client
https://github.com/copycopter/copycopter-ruby-client
spec/copycopter_client/poller_spec.rb
Ruby
mit
177
master
2,362
require 'spec_helper' describe CopycopterClient::Poller do POLLING_DELAY = 0.5 let(:client) { FakeClient.new } let(:cache) { CopycopterClient::Cache.new(client, :logger => FakeLogger.new) } def build_poller(config = {}) config[:logger] ||= FakeLogger.new config[:polling_delay] = POLLING_DELAY def...
github
copycopter/copycopter-ruby-client
https://github.com/copycopter/copycopter-ruby-client
spec/copycopter_client/client_spec.rb
Ruby
mit
177
master
6,742
require 'spec_helper' describe CopycopterClient do def build_client(config = {}) config[:logger] ||= FakeLogger.new default_config = CopycopterClient::Configuration.new.to_hash CopycopterClient::Client.new(default_config.update(config)) end def add_project api_key = 'xyz123' FakeCopycopterAp...
github
copycopter/copycopter-ruby-client
https://github.com/copycopter/copycopter-ruby-client
spec/copycopter_client/i18n_backend_spec.rb
Ruby
mit
177
master
4,592
require 'spec_helper' describe CopycopterClient::I18nBackend do let(:cache) { {} } def build_backend backend = CopycopterClient::I18nBackend.new(cache) I18n.backend = backend backend end before do @default_backend = I18n.backend cache.stubs(:wait_for_download) end after { I18n.backen...
github
copycopter/copycopter-ruby-client
https://github.com/copycopter/copycopter-ruby-client
spec/support/fake_html_safe_string.rb
Ruby
mit
177
master
245
class FakeHtmlSafeString < String def initialize(*args) super(*args) @html_safe = false end def html_safe dup.html_safe! end def html_safe! @html_safe = true self end def html_safe? @html_safe end end
github
copycopter/copycopter-ruby-client
https://github.com/copycopter/copycopter-ruby-client
spec/support/fake_client.rb
Ruby
mit
177
master
715
class FakeClient def initialize @data = {} @uploaded = {} @uploads = 0 @downloads = 0 end attr_reader :uploaded, :uploads, :downloads attr_accessor :delay, :error def []=(key, value) @data[key] = value end def download wait_for_delay raise_error_if_present @downloads += ...
github
copycopter/copycopter-ruby-client
https://github.com/copycopter/copycopter-ruby-client
spec/support/fake_resque_job.rb
Ruby
mit
177
master
230
class FakeResqueJob def initialize(&action) @action = action || lambda {} end def fork_and_perform fork do perform exit! end Process.wait end def perform @action.call true end end
github
copycopter/copycopter-ruby-client
https://github.com/copycopter/copycopter-ruby-client
spec/support/writing_cache.rb
Ruby
mit
177
master
256
class WritingCache def flush File.open(path, "w") do |file| file.write(object_id.to_s) end end def written? IO.read(path) == object_id.to_s end private def path File.join(PROJECT_ROOT, 'tmp', 'written_cache') end end
github
copycopter/copycopter-ruby-client
https://github.com/copycopter/copycopter-ruby-client
spec/support/fake_logger.rb
Ruby
mit
177
master
1,419
class FakeLogger def initialize @entries = { :info => [], :debug => [], :warn => [], :error => [], :fatal => [], } end def info(message = nil, &block) log(:info, message, &block) end def debug(message = nil, &block) log(:debug, message, &block) end def wa...
github
copycopter/copycopter-ruby-client
https://github.com/copycopter/copycopter-ruby-client
spec/support/fake_passenger.rb
Ruby
mit
177
master
465
class FakePassenger def initialize @handlers = {} end def on_event(name, &handler) @handlers[name] ||= [] @handlers[name] << handler end def call_event(name, *args) if @handlers[name] @handlers[name].each do |handler| handler.call(*args) end end end def become_ma...
github
copycopter/copycopter-ruby-client
https://github.com/copycopter/copycopter-ruby-client
spec/support/fake_copycopter_app.rb
Ruby
mit
177
master
3,393
require 'sinatra/base' require 'json' require 'thin' class FakeCopycopterApp < Sinatra::Base disable :show_exceptions def self.start Thread.new do if ENV['DEBUG'] Thin::Logging.debug = true else Thin::Logging.silent = true end Rack::Handler::Thin.run self, :Port => por...
github
copycopter/copycopter-ruby-client
https://github.com/copycopter/copycopter-ruby-client
spec/support/middleware_stack.rb
Ruby
mit
177
master
240
class MiddlewareStack def initialize @middlewares = [] end def use(klass, *args) @middlewares << klass.new('fake_app', *args) end def include?(klass) @middlewares.any? { |middleware| klass === middleware } end end
github
copycopter/copycopter-ruby-client
https://github.com/copycopter/copycopter-ruby-client
spec/support/defines_constants.rb
Ruby
mit
177
master
998
module DefinesConstants def self.included(example_group) super example_group.class_eval do before { @defined_constants = [] } after { undefine_constants } end end def define_class(class_name, base = Object, &block) class_name = class_name.to_s.camelize klass = Class.new(base) ...
github
jetruby/apollo_upload_server-ruby
https://github.com/jetruby/apollo_upload_server-ruby
apollo_upload_server.gemspec
Ruby
mit
177
master
1,088
lib = File.expand_path('../lib', __FILE__) $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) require 'apollo_upload_server/version' Gem::Specification.new do |spec| spec.name = 'apollo_upload_server' spec.version = ApolloUploadServer::VERSION spec.authors = ['JetRuby'] spec.email ...
github
jetruby/apollo_upload_server-ruby
https://github.com/jetruby/apollo_upload_server-ruby
spec/apollo_upload_server/upload_spec.rb
Ruby
mit
177
master
632
require 'spec_helper' require 'apollo_upload_server/upload' RSpec.describe ApolloUploadServer::Upload do let(:ctx) { {} } describe '#coerce_input' do let(:uploaded_file) { ApolloUploadServer::Wrappers::UploadedFile.new('test') } specify do expect(described_class.coerce_input(uploaded_file, ctx)).to...
github
jetruby/apollo_upload_server-ruby
https://github.com/jetruby/apollo_upload_server-ruby
spec/apollo_upload_server/graphql_data_builder_spec.rb
Ruby
mit
177
master
8,606
require 'spec_helper' require 'apollo_upload_server/graphql_data_builder' describe ApolloUploadServer::GraphQLDataBuilder do describe '#call for single operation' do let(:params) do { 'operations' => { 'query' => 'mutation { blah blah }', 'operationName' => 'SomeOperation', ...
github
jetruby/apollo_upload_server-ruby
https://github.com/jetruby/apollo_upload_server-ruby
spec/apollo_upload_server/middleware_spec.rb
Ruby
mit
177
master
1,551
require 'spec_helper' require 'action_dispatch' require 'apollo_upload_server/middleware' describe ApolloUploadServer::Middleware do around do |example| mode = described_class.strict_mode example.run described_class.strict_mode = mode end describe '#call' do let(:app) do Rack::Builder.new ...
github
jetruby/apollo_upload_server-ruby
https://github.com/jetruby/apollo_upload_server-ruby
lib/apollo_upload_server.rb
Ruby
mit
177
master
210
require 'apollo_upload_server/graphql_data_builder' require 'apollo_upload_server/middleware' require 'apollo_upload_server/version' require 'apollo_upload_server/railtie' require 'apollo_upload_server/upload'
github
jetruby/apollo_upload_server-ruby
https://github.com/jetruby/apollo_upload_server-ruby
lib/apollo_upload_server/upload.rb
Ruby
mit
177
master
373
# frozen_string_literal: true require 'graphql' module ApolloUploadServer class Upload < GraphQL::Schema::Scalar graphql_name "Upload" def self.coerce_input(value, _ctx) return super if value.nil? || value.is_a?(::ApolloUploadServer::Wrappers::UploadedFile) raise GraphQL::CoercionError, "#{val...
github
jetruby/apollo_upload_server-ruby
https://github.com/jetruby/apollo_upload_server-ruby
lib/apollo_upload_server/railtie.rb
Ruby
mit
177
master
221
require 'apollo_upload_server/middleware' module ApolloUploadServer class Railtie < Rails::Railtie initializer 'apollo_upload_server.apply_middleware' do |app| app.middleware.use Middleware end end end
github
jetruby/apollo_upload_server-ruby
https://github.com/jetruby/apollo_upload_server-ruby
lib/apollo_upload_server/middleware.rb
Ruby
mit
177
master
796
require 'apollo_upload_server/graphql_data_builder' module ApolloUploadServer class Middleware # Strict mode requires that all mapped files are present in the mapping arrays. class_attribute :strict_mode, default: false def initialize(app) @app = app end def call(env) unless env['CO...
github
jetruby/apollo_upload_server-ruby
https://github.com/jetruby/apollo_upload_server-ruby
lib/apollo_upload_server/graphql_data_builder.rb
Ruby
mit
177
master
2,908
# frozen_string_literal: true require 'json' require 'apollo_upload_server/wrappers/uploaded_file' module ApolloUploadServer class GraphQLDataBuilder OutOfBounds = Class.new(ArgumentError) def initialize(strict_mode: false) @strict_mode = strict_mode end def call(params) operations = J...
github
jetruby/apollo_upload_server-ruby
https://github.com/jetruby/apollo_upload_server-ruby
lib/apollo_upload_server/wrappers/uploaded_file.rb
Ruby
mit
177
master
390
# frozen_string_literal: true require 'delegate' require 'action_dispatch/http/upload' module ApolloUploadServer module Wrappers class UploadedFile < DelegateClass(::ActionDispatch::Http::UploadedFile) def initialize(wrapped_foo) super end def as_json(options = nil) instance_v...
github
benschwarz/amnesia
https://github.com/benschwarz/amnesia
config.ru
Ruby
mit
177
master
282
require 'rubygems' require 'bundler/setup' require 'amnesia' # This stops invalid US-ASCII characters on heroku. Encoding.default_internal = 'utf-8' Encoding.default_external = 'utf-8' use Amnesia::Application, hosts: ['localhost', 'example.local:10987'] run Sinatra::Application
github
benschwarz/amnesia
https://github.com/benschwarz/amnesia
amnesia.gemspec
Ruby
mit
177
master
762
Gem::Specification.new do |s| s.name = "amnesia" s.version = "1.2.0" s.platform = Gem::Platform::RUBY s.authors = ["Ben Schwarz"] s.email = ["ben.schwarz@gmail.com"] s.homepage = "http://github.com/benschwarz/amnesia" s.summary = "Amnesia is what you get when you lose your m...
github
benschwarz/amnesia
https://github.com/benschwarz/amnesia
lib/amnesia.rb
Ruby
mit
177
master
758
require 'sinatra/base' require 'haml' require 'amnesia/authentication' require 'amnesia/helpers' require 'amnesia/host' require 'amnesia/routes' module Amnesia class Application < Sinatra::Base include Amnesia::Authentication include Amnesia::Helpers include Amnesia::Routes set :public_folder, File....
github
benschwarz/amnesia
https://github.com/benschwarz/amnesia
lib/amnesia/routes.rb
Ruby
mit
177
master
1,086
module Amnesia module Routes def self.included app app.class_eval do get '/' do haml :index end get '/pie' do data = params[:d].to_s.split(",").map(&:to_i) r = 25 c = (2*Math::PI*r).ceil v = data.first.to_f / data.last * 100 * c / 1...
github
benschwarz/amnesia
https://github.com/benschwarz/amnesia
lib/amnesia/host.rb
Ruby
mit
177
master
1,321
require 'dalli' module Amnesia class Host FLOAT_STATS = %w[ rusage_user rusage_system ] STRING_STATS = %w[ version libevent ] DEFAULT_PORT = 11_211 def self.normalize_address address return "#{address}:#{DEFAULT_PORT}" unless address.include? ":" address end def initialize(add...
github
benschwarz/amnesia
https://github.com/benschwarz/amnesia
lib/amnesia/helpers.rb
Ruby
mit
177
master
1,266
module Amnesia module Helpers def self.included app app.helpers do include HelperMethods end end module HelperMethods SIZE_UNITS = %w[ Bytes KB MB GB TB PB EB ] def graph_url(*data) url "/pie?d="+data.join(',') end # https://github.com/rails/rails/blo...
github
benschwarz/amnesia
https://github.com/benschwarz/amnesia
lib/amnesia/authentication.rb
Ruby
mit
177
master
321
module Amnesia module Authentication def self.included app app.class_eval do use Rack::Auth::Basic, "Amnesia" do |username, password| user, pass = ENV['AMNESIA_CREDS'].split(':') username == user and password == pass end if ENV['AMNESIA_CREDS'] end end end end
github
benschwarz/amnesia
https://github.com/benschwarz/amnesia
spec/amnesia_spec.rb
Ruby
mit
177
master
972
require 'spec_helper' describe Amnesia::Application do context "unauthenticated" do it "responds with 401 to get" do get '/' expect(last_response.status).to eq 401 end end context "authenticated" do before(:each) do basic_authorize "admin", "amnesia" end let(:host) { Amnes...
github
benschwarz/amnesia
https://github.com/benschwarz/amnesia
spec/spec_helper.rb
Ruby
mit
177
master
320
require 'rspec' ENV['RACK_ENV'] ||= 'test' ENV['AMNESIA_CREDS'] ||= 'admin:amnesia' ENV['MEMCACHE_SERVERS'] ||= 'localhost' require 'rack/test' require 'amnesia' module TestedApp include Rack::Test::Methods def app Amnesia::Application.new end end RSpec.configure do |rspec| rspec.include TestedApp end
github
tizoc/bureaucrat
https://github.com/tizoc/bureaucrat
bureaucrat.gemspec
Ruby
mit
177
master
894
Gem::Specification.new do |s| s.name = 'bureaucrat' s.version = '0.10.2' s.summary = "Form handling for Ruby inspired by Django forms." s.description = "Bureaucrat is a form handling library for Ruby." s.author = "Bruno Deferrari" s.email = "utizoc@gmail.com" s.homepage = "http://github.com/tizoc/bureaucr...
github
tizoc/bureaucrat
https://github.com/tizoc/bureaucrat
lib/bureaucrat.rb
Ruby
mit
177
master
668
module Bureaucrat VERSION = '0.10.0' class ValidationError < Exception attr_reader :code, :params, :messages def initialize(message, code = nil, params = nil) if message.is_a? Array @messages = message else @code = code @params = params @messages = [message] ...
github
tizoc/bureaucrat
https://github.com/tizoc/bureaucrat
lib/bureaucrat/fields.rb
Ruby
mit
177
master
18,418
require 'set' module Bureaucrat module Fields class ErrorList < Array include Utils def to_s as_ul end def as_ul if empty? '' else ul = '<ul class="errorlist">%s</ul>' li = '<li>%s</li>' result = ul % map{|e| li % conditi...
github
tizoc/bureaucrat
https://github.com/tizoc/bureaucrat
lib/bureaucrat/utils.rb
Ruby
mit
177
master
1,923
module Bureaucrat module Utils extend self module SafeData end class SafeString < String include SafeData def +(rhs) rhs.is_a?(SafeString) ? SafeString.new(super(rhs)) : super(rhs) end end class StringAccessHash < Hash def initialize(other = {}) supe...
github
tizoc/bureaucrat
https://github.com/tizoc/bureaucrat
lib/bureaucrat/forms.rb
Ruby
mit
177
master
11,975
module Bureaucrat module Forms # Instances of +BoundField+ represent a fields with associated data. # +BoundField+s are used internally by the +Form+ class. class BoundField include Utils # Field label text attr_accessor :label, :form, :field, :name, :html_name, :html_initial_name, :he...
github
tizoc/bureaucrat
https://github.com/tizoc/bureaucrat
lib/bureaucrat/quickfields.rb
Ruby
mit
177
master
2,693
module Bureaucrat # Shortcuts for declaring form fields module Quickfields include Fields # Hide field named +name+ def hide(name) base_fields[name] = base_fields[name].dup base_fields[name].widget = Widgets::HiddenInput.new end # Delete field named +name+ def delete(name) ...
github
tizoc/bureaucrat
https://github.com/tizoc/bureaucrat
lib/bureaucrat/validators.rb
Ruby
mit
177
master
4,027
module Bureaucrat module Validators def empty_value?(value) value.nil? || value == '' || value == [] || value == {} end module_function :empty_value? class RegexValidator attr_accessor :regex, :message, :code def initialize(options = {}) @regex = Regexp.new(options.fetch(:r...
github
tizoc/bureaucrat
https://github.com/tizoc/bureaucrat
lib/bureaucrat/widgets.rb
Ruby
mit
177
master
14,758
require 'uri' module Bureaucrat module Widgets # Base class for widgets class Widget include Utils attr_accessor :is_required attr_reader :attrs def initialize(attrs = nil) @attrs = attrs.nil? ? {} : attrs.dup end def initialize_copy(original) super(orig...
github
tizoc/bureaucrat
https://github.com/tizoc/bureaucrat
lib/bureaucrat/temporary_uploaded_file.rb
Ruby
mit
177
master
358
module Bureaucrat class TemporaryUploadedFile attr_accessor :filename, :content_type, :name, :tempfile, :head, :size def initialize(data) @filename = data[:filename] @content_type = data[:content_type] @name = data[:name] @tempfile = data[:tempfile] @size = @tempfile.size ...
github
tizoc/bureaucrat
https://github.com/tizoc/bureaucrat
lib/bureaucrat/formsets.rb
Ruby
mit
177
master
8,446
module Bureaucrat module Formsets TOTAL_FORM_COUNT = :'TOTAL_FORMS' INITIAL_FORM_COUNT = :'INITIAL_FORMS' MAX_NUM_FORM_COUNT = :'MAX_NUM_FORMS' ORDERING_FIELD_NAME = :'ORDER' DELETION_FIELD_NAME = :'DELETE' class ManagementForm < Forms::Form include Fields include Widgets f...
github
tizoc/bureaucrat
https://github.com/tizoc/bureaucrat
examples/fields_test/config.ru
Ruby
mit
177
master
2,235
require 'erb' require 'bigdecimal' require 'prettyprint' require 'rack' require 'bureaucrat' require 'bureaucrat/quickfields' class TestForm1 < Bureaucrat::Forms::Form extend Bureaucrat::Quickfields string :string_field string :string_field2, :required => false,\ :label => 'Another St...
github
tizoc/bureaucrat
https://github.com/tizoc/bureaucrat
test/formsets_test.rb
Ruby
mit
177
master
2,390
require_relative 'test_helper' module FormsetTests class SimpleForm < Bureaucrat::Forms::Form include Bureaucrat::Fields field :name, CharField.new end SimpleFormFormSet = Bureaucrat::Formsets.make_formset_class(SimpleForm, extra: 2) class CustomFormSet < Bureaucrat::Formsets::BaseFormSet de...
github
tizoc/bureaucrat
https://github.com/tizoc/bureaucrat
test/test_helper.rb
Ruby
mit
177
master
641
require 'bigdecimal' require 'minitest/autorun' require_relative '../lib/bureaucrat' require_relative '../lib/bureaucrat/formsets' # Used to compare rendered htmls require 'rexml/document' class BureaucratTestCase < MiniTest::Unit::TestCase include Bureaucrat def assert_nothing_raised(&block) block.call ...
github
tizoc/bureaucrat
https://github.com/tizoc/bureaucrat
test/fields_test.rb
Ruby
mit
177
master
18,008
require_relative 'test_helper' module FieldTests class Test_with_empty_options < BureaucratTestCase def setup @field = Fields::Field.new end def test_be_required blank_value = '' assert_raises(ValidationError) do @field.clean(blank_value) end end end class Test_w...
github
tizoc/bureaucrat
https://github.com/tizoc/bureaucrat
test/forms_test.rb
Ruby
mit
177
master
4,134
require_relative 'test_helper' module FormTests class Test_inherited_form_with_a_CharField < BureaucratTestCase class OneForm < Forms::Form include Bureaucrat::Fields field :name, CharField.new end def test_have_a_BoundField form = OneForm.new assert_kind_of(Forms::BoundField, f...
github
tizoc/bureaucrat
https://github.com/tizoc/bureaucrat
test/widgets_test.rb
Ruby
mit
177
master
16,532
require_relative 'test_helper' module WidgetTests class Test_TextInput_widget < BureaucratTestCase class Test_with_empty_attributes < BureaucratTestCase def test_correctly_render input = Widgets::TextInput.new expected = normalize_html('<input type="text" value="hi" name="test" />') ...
github
tjgrathwell/rails5-spec-converter
https://github.com/tjgrathwell/rails5-spec-converter
rails5-spec-converter.gemspec
Ruby
mit
177
master
1,302
# coding: utf-8 lib = File.expand_path('../lib', __FILE__) $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) require 'rails5/spec_converter/version' Gem::Specification.new do |spec| spec.name = "rails5-spec-converter" spec.version = Rails5::SpecConverter::VERSION spec.authors = ["Travi...
github
tjgrathwell/rails5-spec-converter
https://github.com/tjgrathwell/rails5-spec-converter
lib/rails5/spec_converter/hash_rewriter.rb
Ruby
mit
177
master
7,163
require 'rails5/spec_converter/node_textifier' class HashRewriter OUTSIDE_PARAMS_KEYS = %i(format) attr_reader :hash_node, :original_indent def initialize(content:, hash_node:, original_indent:, options:) @options = options @content = content @hash_node = hash_node @original_indent = original_i...
github
tjgrathwell/rails5-spec-converter
https://github.com/tjgrathwell/rails5-spec-converter
lib/rails5/spec_converter/test_type_identifier.rb
Ruby
mit
177
master
2,535
require 'parser/current' require 'astrolabe/builder' module Rails5 module SpecConverter class TestTypeIdentifier DIRECTORY_TO_TYPE_MAP = { 'controllers' => :controller, 'requests' => :request, 'integration' => :request, 'api' => :request } def initial...
github
tjgrathwell/rails5-spec-converter
https://github.com/tjgrathwell/rails5-spec-converter
lib/rails5/spec_converter/node_textifier.rb
Ruby
mit
177
master
809
class NodeTextifier def initialize(content) @content = content end def text_before_first_pair(hash_node) @content[hash_node.loc.expression.begin_pos...hash_node.children.first.loc.expression.begin_pos] end def text_after_last_pair(hash_node) @content[hash_node.children.last.loc.expression.end_po...
github
tjgrathwell/rails5-spec-converter
https://github.com/tjgrathwell/rails5-spec-converter
lib/rails5/spec_converter/cli.rb
Ruby
mit
177
master
1,692
require 'rails5/spec_converter/text_transformer' require 'rails5/spec_converter/text_transformer_options' require 'rails5/spec_converter/version' require 'optparse' module Rails5 module SpecConverter class CLI def initialize @options = TextTransformerOptions.new OptionParser.new do |opts| ...
github
tjgrathwell/rails5-spec-converter
https://github.com/tjgrathwell/rails5-spec-converter
lib/rails5/spec_converter/text_transformer_options.rb
Ruby
mit
177
master
242
class TextTransformerOptions attr_accessor :hash_spacing, :indent, :file_path attr_writer :quiet def initialize @file_path = nil @quiet = false @indent = ' ' @hash_spacing = nil end def quiet? @quiet end end
github
tjgrathwell/rails5-spec-converter
https://github.com/tjgrathwell/rails5-spec-converter
lib/rails5/spec_converter/text_transformer.rb
Ruby
mit
177
master
4,096
require 'parser/current' require 'astrolabe/builder' require 'rails5/spec_converter/test_type_identifier' require 'rails5/spec_converter/text_transformer_options' require 'rails5/spec_converter/hash_rewriter' module Rails5 module SpecConverter HTTP_VERBS = %i(get post put patch delete) class TextTransformer...
github
tjgrathwell/rails5-spec-converter
https://github.com/tjgrathwell/rails5-spec-converter
spec/spec_helper.rb
Ruby
mit
177
master
274
$LOAD_PATH.unshift File.expand_path('../../lib', __FILE__) require 'support/strip' require 'rails5/spec_converter' require 'rails5/spec_converter/test_type_identifier' require 'rails5/spec_converter/text_transformer' require 'rails5/spec_converter/text_transformer_options'
github
tjgrathwell/rails5-spec-converter
https://github.com/tjgrathwell/rails5-spec-converter
spec/rails5/text_transformer_spec.rb
Ruby
mit
177
master
13,657
require 'spec_helper' describe Rails5::SpecConverter::TextTransformer do let(:controller_spec_file_path) { 'spec/controllers/test_spec.rb' } let(:request_spec_file_path) { 'spec/requests/test_spec.rb' } def transform(text, options = nil) if options described_class.new(text, options).transform else...
github
tjgrathwell/rails5-spec-converter
https://github.com/tjgrathwell/rails5-spec-converter
spec/rails5/test_type_identifier_spec.rb
Ruby
mit
177
master
4,460
require 'spec_helper' describe Rails5::SpecConverter::TestTypeIdentifier do describe 'determining the type of a test file' do def build_rspec_content(metadata = nil) <<-EOT.strip_heredoc describe "my test"#{metadata ? ", #{metadata}" : nil} do it 'runs this test' do get :index...
github
parolkar/pfeed
https://github.com/parolkar/pfeed
init.rb
Ruby
mit
177
master
676
# Author: Er Abhishek Parolkar require File.dirname(__FILE__) + '/lib/pfeed' require File.dirname(__FILE__) + '/lib/pfeed_utils' ActiveRecord::Base.send(:include, ParolkarInnovationLab::SocialNet) ActionController::Base.helper do def pfeed_content(pfeed) #FIXME: interesting idea , but currently un-supported co...
github
parolkar/pfeed
https://github.com/parolkar/pfeed
Rakefile
Ruby
mit
177
master
588
require 'rake' require 'rake/testtask' require 'rake/rdoctask' desc 'Default: run unit tests.' task :default => :test desc 'Test the has_profile_items plugin.' Rake::TestTask.new(:test) do |t| t.libs << 'lib' t.libs << 'test' t.pattern = 'test/**/*_test.rb' t.verbose = true end desc 'Generate documentation f...
github
parolkar/pfeed
https://github.com/parolkar/pfeed
lib/pfeed.rb
Ruby
mit
177
master
3,746
#snippet: https://gist.github.com/89e92409ca9016d2d919 module ParolkarInnovationLab module SocialNet def self.included(base) base.extend ParolkarInnovationLab::SocialNet::ClassMethods end module ClassMethods def emits_pfeeds arg_hash # {:on => [] , :for => [:itself , :...
github
parolkar/pfeed
https://github.com/parolkar/pfeed
lib/pfeed_utils.rb
Ruby
mit
177
master
739
module ParolkarInnovationLab module SocialNet module PfeedUtils extend self def attempt_pass_tense str_obj #What can it do? # it can automagically transform # "addFriend" => "added_friend" # "fightWithFriend" => "faught_with_friend" # "buy_item" => "baught_item"...
github
parolkar/pfeed
https://github.com/parolkar/pfeed
lib/tasks/pfeed.rake
Ruby
mit
177
master
1,752
namespace :pfeed do desc 'Sets up parolkar\'s pfeed plugin ' task :setup do root = "#{Rails.root}" raise 'pfeed plugin was only tested on unix & windows' if ! Rake.application.unix? && ! Rake.application.windows? if ! File.exists?("#{root}/vendor/plugins/inflectionist") p...
github
parolkar/pfeed
https://github.com/parolkar/pfeed
generators/pfeed_customization/pfeed_customization_generator.rb
Ruby
mit
177
master
853
class PfeedCustomizationGenerator < Rails::Generator::Base attr_reader :past_classname attr_reader :past_varname def initialize(args, other = {}) super @model, @current_action = args @past_action = ParolkarInnovationLab::SocialNet::PfeedUtils.attempt_pass_tense(@current_action) @past = @model.dow...
github
parolkar/pfeed
https://github.com/parolkar/pfeed
db/migrate/0000_create_pfeed_items.rb
Ruby
mit
177
master
371
class CreatePfeedItems < ActiveRecord::Migration def self.up create_table :pfeed_items do |t| t.string :type t.integer :originator_id t.string :originator_type t.integer :participant_id t.string :participant_type t.text :data t.datetime :expiry t.timestamps end end ...
github
parolkar/pfeed
https://github.com/parolkar/pfeed
db/migrate/0001_create_pfeed_deliveries.rb
Ruby
mit
177
master
305
class CreatePfeedDeliveries < ActiveRecord::Migration def self.up create_table :pfeed_deliveries do |t| t.integer :pfeed_receiver_id t.string :pfeed_receiver_type t.integer :pfeed_item_id t.timestamps end end def self.down drop_table :pfeed_deliveries end end
github
parolkar/pfeed
https://github.com/parolkar/pfeed
app/models/pfeed_item.rb
Ruby
mit
177
master
6,610
class PfeedItem < ActiveRecord::Base serialize :data, Hash serialize :participants, Array belongs_to :originator, :polymorphic => true belongs_to :participant, :polymorphic => true has_many :pfeed_deliveries, :dependent => :destroy attr_accessor :temp_references # this is an temporary Hash to ho...
github
parolkar/pfeed
https://github.com/parolkar/pfeed
app/models/pfeeds/user_updated_attribute.rb
Ruby
mit
177
master
400
class Pfeeds::UserUpdatedAttribute < PfeedItem def pack_data(method_name,method_name_in_past_tense,returned_result,*args_supplied_to_method,&block_supplied_to_method) super self.data = {} if ! self.data attribute_name = args_supplied_to_method[0].to_s.humanize hash_to_be_merged = {:attribute_n...
github
parolkar/pfeed
https://github.com/parolkar/pfeed
test/test_helper.rb
Ruby
mit
177
master
1,287
ENV['RAILS_ENV'] = 'test' require 'rubygems' require 'active_record' require 'action_controller' require 'active_support' def __DIR__ File.dirname(__FILE__) end require "#{__DIR__}/../init" require 'riot' # ? class String unless methods.include? 'normalize' def normalize *args self end end end ...
github
parolkar/pfeed
https://github.com/parolkar/pfeed
test/lib/pfeed_test.rb
Ruby
mit
177
master
1,479
require 'test_helper' load_schema def pfeed PfeedItem.find_by_originator_id(topic.id) end class Emitter < ActiveRecord::Base def if_false_ping; end def if_false; false end def if_true_ping; end def if_true; true end def unless_false_ping; end def unless_false; false end def unless_true_ping; end d...
github
parolkar/pfeed
https://github.com/parolkar/pfeed
test/lib/pfeed_utils_test.rb
Ruby
mit
177
master
308
require 'test_helper' context 'attempting past tense' do def _(verb, past_tense) asserts('') {ParolkarInnovationLab::SocialNet::PfeedUtils.attempt_pass_tense(verb)}.equals(past_tense) end _ "addFriend", "added_friend" _ "fightWithFriend", "fought_with_friend" _ "buy_item", "bought_item" end
github
jgv/area
https://github.com/jgv/area
area.gemspec
Ruby
mit
177
master
751
# -*- encoding: utf-8 -*- require File.expand_path('../lib/area/version', __FILE__) Gem::Specification.new do |s| s.name = "area" s.version = Area::VERSION s.author = "Jonathan Vingiano" s.email = "jgv@jonathanvingiano.com" s.homepage = "http://github.com/jgv/area" s.rubyforge_project = "area" s.summar...
github
jgv/area
https://github.com/jgv/area
Rakefile
Ruby
mit
177
master
220
require 'bundler' Bundler::GemHelper.install_tasks require 'rake/testtask' Rake::TestTask.new do |t| t.libs.push "lib" t.test_files = FileList['test/unit/*_test.rb'] # t.verbose = true end task :default => :test
github
jgv/area
https://github.com/jgv/area
test/unit/area_test.rb
Ruby
mit
177
master
6,929
require 'minitest/autorun' require 'minitest/benchmark' if ENV["BENCH"] require 'minitest/pride' require File.expand_path('../../../lib/area.rb', __FILE__) class TestInteger < MiniTest::Unit::TestCase def test_that_it_converts_area_code_to_region assert_equal "NY", 646.to_region end def test_that_it_conver...
github
jgv/area
https://github.com/jgv/area
lib/area.rb
Ruby
mit
177
master
1,819
if RUBY_VERSION.to_f >= 1.9 # ;_; require 'csv' else require 'rubygems' require 'faster_csv' end require 'area/array' require 'area/integer' require 'area/string' module Area zip_path = File.open(File.join(File.dirname(__FILE__), '..', 'data', 'zipcodes.csv')) area_path = File.open(File.join(File.dirname(_...
github
jgv/area
https://github.com/jgv/area
lib/area/array.rb
Ruby
mit
177
master
2,484
class Array # Public: Convert an lat/lon pair as an Array to a region. # # options - An optional hash indicating if you would like just the city or just the state. # # Examples # # ['40.71209', '-73.95427'].to_region # # => "Brooklyn, NY" # # ['40.71209', '-73.95427'].to_region(:state => true...
github
jgv/area
https://github.com/jgv/area
lib/area/string.rb
Ruby
mit
177
master
3,844
class String # Public: Convert a string to an area code. # # Examples # # "CT".to_area # # => ["203", "860"] # # Returns an Array of converted area codes. def to_area if Area.state_or_territory?(self) @area_codes = Area.area_codes.find_all {|row| row[1].upcase == self }.map {|a| a.first...
github
jgv/area
https://github.com/jgv/area
lib/area/integer.rb
Ruby
mit
177
master
3,090
class Integer # Public: Convert an area code or to a US state or region. # # Examples # # 646.to_region # #=> NY # # Returns a String representation of the converted area code. def to_region(options = {}) if Area.code?(self) # presume an area code row = Area.area_codes.find{|row| row.f...
github
ariejan/firefly
https://github.com/ariejan/firefly
Gemfile
Ruby
mit
177
master
649
source 'https://rubygems.org' git_source(:github) do |repo_name| repo_name = "#{repo_name}/#{repo_name}" unless repo_name.include?("/") "https://github.com/#{repo_name}.git" end gem 'rails', '~> 5.1.1' gem 'pg', '~> 0.18' gem 'puma', '~> 3.7' gem 'sass-rails', '~> 5.0' gem 'uglifier', '>= 1.3.0' gem 'haml', "~...
github
ariejan/firefly
https://github.com/ariejan/firefly
features/support/env.rb
Ruby
mit
177
master
2,631
# IMPORTANT: This file is generated by cucumber-rails - edit at your own peril. # It is recommended to regenerate this file in the future when you upgrade to a # newer version of cucumber-rails. Consider adding your own code to a new file # instead of editing this one. Cucumber will automatically load all features/**/*...
github
ariejan/firefly
https://github.com/ariejan/firefly
lib/tasks/cucumber.rake
Ruby
mit
177
master
2,742
# IMPORTANT: This file is generated by cucumber-rails - edit at your own peril. # It is recommended to regenerate this file in the future when you upgrade to a # newer version of cucumber-rails. Consider adding your own code to a new file # instead of editing this one. Cucumber will automatically load all features/**/*...
github
ariejan/firefly
https://github.com/ariejan/firefly
spec/rails_helper.rb
Ruby
mit
177
master
2,674
# This file is copied to spec/ when you run 'rails generate rspec:install' require 'spec_helper' ENV['RAILS_ENV'] ||= 'test' require File.expand_path('../../config/environment', __FILE__) # Prevent database truncation if the environment is production abort("The Rails environment is running in production mode!") if Rail...
github
ariejan/firefly
https://github.com/ariejan/firefly
spec/controllers/dashboard_controller_spec.rb
Ruby
mit
177
master
229
require 'rails_helper' RSpec.describe DashboardController, type: :controller do describe "GET #show" do it "returns http success" do get :show expect(response).to have_http_status(:success) end end end
github
ariejan/firefly
https://github.com/ariejan/firefly
db/schema.rb
Ruby
mit
177
master
881
# 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 source for your # dat...
github
ariejan/firefly
https://github.com/ariejan/firefly
config/application.rb
Ruby
mit
177
master
988
require_relative 'boot' require "rails" # Pick the frameworks you want: require "active_model/railtie" require "active_job/railtie" require "active_record/railtie" require "action_controller/railtie" require "action_mailer/railtie" require "action_view/railtie" require "action_cable/engine" require "sprockets/railtie"...
github
ariejan/firefly
https://github.com/ariejan/firefly
config/environments/production.rb
Ruby
mit
177
master
3,785
Rails.application.configure do # Settings specified here will take precedence over those in config/application.rb. # Code is not reloaded between requests. config.cache_classes = true # Eager load code on boot. This eager loads most of Rails and # your application in memory, allowing both threaded web serve...