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
couchrest/couchrest_model
https://github.com/couchrest/couchrest_model
lib/couchrest/model/errors.rb
Ruby
apache-2.0
302
master
881
# encoding: utf-8 module CouchRest module Model module Errors class CouchRestModelError < StandardError; end # Raised when a persisence method ending in ! fails validation. The message # will contain the full error messages from the +Document+ in question. # # Example: # ...
github
couchrest/couchrest_model
https://github.com/couchrest/couchrest_model
lib/couchrest/model/connection_config.rb
Ruby
apache-2.0
302
master
566
module CouchRest module Model # Thead safe caching of connection configuration files. class ConnectionConfig include Singleton def initialize @config_files = {} @mutex = Mutex.new end def [](file) @mutex.synchronize do @config_files[file] ||= load...
github
couchrest/couchrest_model
https://github.com/couchrest/couchrest_model
lib/couchrest/model/casted_array.rb
Ruby
apache-2.0
302
master
1,930
# # Wrapper around Array so that the casted_by attribute is set in all # elements of the array. # module CouchRest::Model class CastedArray < Array include CouchRest::Model::Configuration include CouchRest::Model::CastedBy include CouchRest::Model::Dirty def initialize(array, property, parent = nil)...
github
couchrest/couchrest_model
https://github.com/couchrest/couchrest_model
lib/couchrest/model/proxyable.rb
Ruby
apache-2.0
302
master
6,051
module CouchRest module Model # :nodoc: Because I like inventing words module Proxyable extend ActiveSupport::Concern def proxy_database(assoc_name) raise StandardError, "Please set the #proxy_database_method" if self.class.proxy_database_method.nil? db_name = self.send(self.class...
github
couchrest/couchrest_model
https://github.com/couchrest/couchrest_model
lib/couchrest/model/properties.rb
Ruby
apache-2.0
302
master
8,702
# encoding: utf-8 module CouchRest module Model module Properties extend ActiveSupport::Concern included do class_attribute(:properties) unless self.respond_to?(:properties) class_attribute(:properties_by_name) unless self.respond_to?(:properties_by_name) self.properties ||= [...
github
couchrest/couchrest_model
https://github.com/couchrest/couchrest_model
lib/couchrest/model/extended_attachments.rb
Ruby
apache-2.0
302
master
2,647
module CouchRest module Model module ExtendedAttachments extend ActiveSupport::Concern # Add a file attachment to the current document. Expects # :file and :name to be included in the arguments. def create_attachment(args={}) raise ArgumentError unless args[:file] && args[:name] ...
github
couchrest/couchrest_model
https://github.com/couchrest/couchrest_model
lib/couchrest/model/associations.rb
Ruby
apache-2.0
302
master
8,498
module CouchRest module Model # Basic support for relationships between CouchRest::Model::Base module Associations extend ActiveSupport::Concern module ClassMethods # Define an association that this object belongs to. # # An attribute will be created matching the name of ...
github
couchrest/couchrest_model
https://github.com/couchrest/couchrest_model
lib/couchrest/model/document_queries.rb
Ruby
apache-2.0
302
master
2,060
module CouchRest module Model module DocumentQueries extend ActiveSupport::Concern module ClassMethods # Wrapper for the master design documents all method to provide # a total count of entries. def count all.count end # Wrapper for the master desig...
github
couchrest/couchrest_model
https://github.com/couchrest/couchrest_model
lib/couchrest/model/casted_by.rb
Ruby
apache-2.0
302
master
928
module CouchRest::Model module CastedBy extend ActiveSupport::Concern included do self.send(:attr_accessor, :casted_by) self.send(:attr_accessor, :casted_by_property) end # Gets a reference to the actual document in the DB # Calls up to the next document if there is one, # Otherwi...
github
couchrest/couchrest_model
https://github.com/couchrest/couchrest_model
lib/couchrest/model/property_protection.rb
Ruby
apache-2.0
302
master
2,359
module CouchRest module Model module PropertyProtection extend ActiveSupport::Concern # Property protection from mass assignment to CouchRest::Model properties # # Protected methods will be removed from # * new # * update_attributes # * upate_attributes_without_saving...
github
couchrest/couchrest_model
https://github.com/couchrest/couchrest_model
lib/couchrest/model/connection.rb
Ruby
apache-2.0
302
master
2,098
module CouchRest module Model module Connection extend ActiveSupport::Concern def server self.class.server end module ClassMethods # Overwrite the CouchRest::Document.use_database method so that a database # name can be provided instead of a full connection. ...
github
couchrest/couchrest_model
https://github.com/couchrest/couchrest_model
lib/couchrest/model/server_pool.rb
Ruby
apache-2.0
302
master
424
module CouchRest module Model # Simple Server Pool with thread safety so that a single server # instance can be shared with multiple classes. class ServerPool include Singleton def initialize @servers = {} @mutex = Mutex.new end def [](url) @mutex.synchro...
github
couchrest/couchrest_model
https://github.com/couchrest/couchrest_model
lib/couchrest/model/callbacks.rb
Ruby
apache-2.0
302
master
711
# encoding: utf-8 module CouchRest #:nodoc: module Model #:nodoc: module Callbacks extend ActiveSupport::Concern CALLBACKS = [ :before_validation, :after_validation, :after_initialize, :before_create, :around_create, :after_create, :before_destroy, :around_destroy, :...
github
couchrest/couchrest_model
https://github.com/couchrest/couchrest_model
lib/couchrest/model/dirty.rb
Ruby
apache-2.0
302
master
3,284
module CouchRest module Model # This applies to both Model::Base and Model::CastedModel module Dirty extend ActiveSupport::Concern included do # The original attributes data hash, used for comparing changes. self.send(:attr_reader, :original_change_data) end def use_...
github
couchrest/couchrest_model
https://github.com/couchrest/couchrest_model
lib/couchrest/model/property.rb
Ruby
apache-2.0
302
master
4,113
# encoding: utf-8 module CouchRest::Model class Property include ::CouchRest::Model::Typecast attr_reader :name, :type, :array, :read_only, :alias, :default, :casted, :init_method, :options, :allow_blank # Attribute to define. # All Properties are assumed casted unless the type is nil. def init...
github
couchrest/couchrest_model
https://github.com/couchrest/couchrest_model
lib/couchrest/model/persistence.rb
Ruby
apache-2.0
302
master
5,800
module CouchRest module Model module Persistence extend ActiveSupport::Concern # Create the document. Validation is enabled by default and will return # false if the document is not valid. If all goes well, the document will # be returned. def create(options = {}) return fal...
github
couchrest/couchrest_model
https://github.com/couchrest/couchrest_model
lib/couchrest/model/core_extensions/time_parsing.rb
Ruby
apache-2.0
302
master
2,442
module CouchRest module Model module CoreExtensions module TimeParsing # Attemtps to parse a time string in ISO8601 format. # If no match is found, the standard time parse will be used. # # Times, unless provided with a time zone, are assumed to be in # UTC. ...
github
couchrest/couchrest_model
https://github.com/couchrest/couchrest_model
lib/couchrest/model/core_extensions/hash.rb
Ruby
apache-2.0
302
master
303
# This file contains various hacks for Rails compatibility. class Hash # Hack so that CouchRest::Document, which descends from Hash, # doesn't appear to Rails routing as a Hash of options def self.===(other) return false if self == Hash && other.is_a?(CouchRest::Document) super end end
github
couchrest/couchrest_model
https://github.com/couchrest/couchrest_model
lib/couchrest/model/designs/design_mapper.rb
Ruby
apache-2.0
302
master
2,503
module CouchRest module Model module Designs # Support class that allows for a model's design # definition to be converted into an actual design document. # # The methods called in a DesignMapper instance will relay # the parameters to the appropriate method in the design document. ...
github
couchrest/couchrest_model
https://github.com/couchrest/couchrest_model
lib/couchrest/model/designs/view.rb
Ruby
apache-2.0
302
master
21,948
module CouchRest module Model module Designs # # A proxy class that allows view queries to be created using # chained method calls. After each call a new instance of the method # is created based on the original in a similar fashion to ruby's Sequel # library, or Rails 3's Arel. ...
github
couchrest/couchrest_model
https://github.com/couchrest/couchrest_model
lib/couchrest/model/designs/migrations.rb
Ruby
apache-2.0
302
master
4,158
module CouchRest module Model module Designs # Design Document Migrations Support # # A series of methods used inside design documents in order to perform migrations. # module Migrations # Migrate the design document preventing downtime on a production # system. Typ...
github
couchrest/couchrest_model
https://github.com/couchrest/couchrest_model
lib/couchrest/model/support/couchrest_database.rb
Ruby
apache-2.0
302
master
465
# # Extend CouchRest's normal database delete! method to ensure any caches are # also emptied. Given that this is a rare event, and the consequences are not # very severe, we just completely empty the cache. # module CouchRest::Model module Support module Database def delete! Thread.current[:couch...
github
couchrest/couchrest_model
https://github.com/couchrest/couchrest_model
lib/couchrest/model/utils/migrate.rb
Ruby
apache-2.0
302
master
4,967
module CouchRest module Model module Utils # Handle CouchDB Design Document migrations. # # Actual migrations are handled by the Design document, this serves as a utility # to find all the CouchRest Model submodels and perform the migration on them. # # Also contains some more...
github
couchrest/couchrest_model
https://github.com/couchrest/couchrest_model
lib/couchrest/model/validations/casted_model.rb
Ruby
apache-2.0
302
master
535
module CouchRest module Model module Validations class CastedModelValidator < ActiveModel::EachValidator def validate_each(document, attribute, value) values = value.is_a?(Array) ? value : [value] return if values.collect {|doc| doc.nil? || doc.valid? }.all? er...
github
couchrest/couchrest_model
https://github.com/couchrest/couchrest_model
lib/couchrest/model/validations/uniqueness.rb
Ruby
apache-2.0
302
master
2,639
I18n.load_path << File.join( File.dirname(__FILE__), "locale", "en.yml" ) module CouchRest module Model module Validations # Validates if a field is unique class UniquenessValidator < ActiveModel::EachValidator SETUP_DEPRECATED = ActiveModel.respond_to?(:version) && ActiveModel.version >...
github
couchrest/couchrest_model
https://github.com/couchrest/couchrest_model
lib/rails/generators/couchrest_model.rb
Ruby
apache-2.0
302
master
372
require 'rails/generators/named_base' require 'rails/generators/active_model' require 'couchrest_model' module CouchrestModel module Generators class Base < Rails::Generators::NamedBase #:nodoc: # Set the current directory as base for the inherited generators. def self.base_root File.d...
github
couchrest/couchrest_model
https://github.com/couchrest/couchrest_model
lib/rails/generators/couchrest_model/model/model_generator.rb
Ruby
apache-2.0
302
master
604
require 'rails/generators/couchrest_model' module CouchrestModel module Generators class ModelGenerator < Base check_class_collision def create_model_file template 'model.rb', File.join('app/models', class_path, "#{file_name}.rb") end def create_module_file return if cla...
github
couchrest/couchrest_model
https://github.com/couchrest/couchrest_model
lib/rails/generators/couchrest_model/config/config_generator.rb
Ruby
apache-2.0
302
master
426
require 'rails/generators/couchrest_model' module CouchrestModel module Generators class ConfigGenerator < Rails::Generators::Base source_root File.expand_path('../templates', __FILE__) def app_name Rails::Application.subclasses.first.parent.to_s.underscore end def copy_configur...
github
couchrest/couchrest_model
https://github.com/couchrest/couchrest_model
benchmarks/dirty.rb
Ruby
apache-2.0
302
master
2,384
#!/usr/bin/env ruby require 'rubygems' require 'benchmark' $:.unshift(File.dirname(__FILE__) + '/../lib') require 'couchrest_model' class BenchmarkCasted < Hash include CouchRest::Model::CastedModel property :name end class BenchmarkModel < CouchRest::Model::Base use_database CouchRest.database!(ENV['BENCH...
github
couchrest/couchrest_model
https://github.com/couchrest/couchrest_model
benchmarks/connections.rb
Ruby
apache-2.0
302
master
1,332
# # Simple Benchmarking Script. # # Meant to test performance for different types on connections under a typical # scenario of requesting multiple objects from the database in series. # # To run, use `bundle install` then: # # bundle exec ruby connections.rb # require 'rubygems' require 'bundler/setup' require 'ben...
github
couchrest/couchrest_model
https://github.com/couchrest/couchrest_model
spec/spec_helper.rb
Ruby
apache-2.0
302
master
1,996
$VERBOSE=true $LOAD_PATH.unshift(File.dirname(__FILE__)) $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), "..", "lib")) require "bundler/setup" require "rubygems" require "rspec" #require 'oj' require 'couchrest_model' unless defined?(FIXTURE_PATH) MODEL_PATH = File.join(File.dirname(__FILE__), "fixtures", "m...
github
couchrest/couchrest_model
https://github.com/couchrest/couchrest_model
spec/unit/translations_spec.rb
Ruby
apache-2.0
302
master
797
# encoding: utf-8 require "spec_helper" describe "ActiveModel Translations" do describe ".human_attribute_name" do it "should provide translation" do expect(Card.human_attribute_name(:first_name)).to eql("First name") end end describe ".i18n_scope" do it "should provide activemodel default" d...
github
couchrest/couchrest_model
https://github.com/couchrest/couchrest_model
spec/unit/embeddable_spec.rb
Ruby
apache-2.0
302
master
15,353
# encoding: utf-8 require "spec_helper" class WithCastedModelMixin include CouchRest::Model::Embeddable property :name property :no_value property :details, Object, :default => {} property :casted_attribute, WithCastedModelMixin end class OldFashionedMixin < Hash include CouchRest::Model::CastedModel pr...
github
couchrest/couchrest_model
https://github.com/couchrest/couchrest_model
spec/unit/connection_config_spec.rb
Ruby
apache-2.0
302
master
906
require "spec_helper" describe CouchRest::Model::ConnectionConfig do subject { CouchRest::Model::ConnectionConfig } describe ".instance" do it "should provide a singleton" do expect(subject.instance).to be_a(CouchRest::Model::ConnectionConfig) end end describe "#[file]" do let :file do...
github
couchrest/couchrest_model
https://github.com/couchrest/couchrest_model
spec/unit/active_model_lint_spec.rb
Ruby
apache-2.0
302
master
555
# encoding: utf-8 require 'spec_helper' require 'test/unit/assertions' require 'active_model/lint' class CompliantModel < CouchRest::Model::Base end describe CouchRest::Model::Base do include Test::Unit::Assertions include ActiveModel::Lint::Tests before :each do @model = CompliantModel.new end descr...
github
couchrest/couchrest_model
https://github.com/couchrest/couchrest_model
spec/unit/base_spec.rb
Ruby
apache-2.0
302
master
16,525
# encoding: utf-8 require "spec_helper" describe "Model Base" do before(:each) do @obj = WithDefaultValues.new end describe "instance database connection" do it "should use the default database" do expect(@obj.database.name).to eq('couchrest-model-test') end it "should override t...
github
couchrest/couchrest_model
https://github.com/couchrest/couchrest_model
spec/unit/properties_spec.rb
Ruby
apache-2.0
302
master
17,908
# encoding: utf-8 require "spec_helper" describe CouchRest::Model::Properties do context "general functionality" do before(:each) do reset_test_db! @card = Card.new(:first_name => "matt") end it "should be accessible from the object" do expect(@card.properties).to be_an_instance_of(A...
github
couchrest/couchrest_model
https://github.com/couchrest/couchrest_model
spec/unit/typecast_spec.rb
Ruby
apache-2.0
302
master
19,227
# encoding: utf-8 require 'spec_helper' describe "Type Casting" do before(:each) do @course = Course.new(:title => 'Relaxation') end describe "when value is nil" do it "leaves the value unchanged" do @course.title = nil expect(@course['title']).to eq(nil) end end describe "when val...
github
couchrest/couchrest_model
https://github.com/couchrest/couchrest_model
spec/unit/property_protection_spec.rb
Ruby
apache-2.0
302
master
5,936
require "spec_helper" describe "Model Attributes" do describe "no declarations" do class NoProtection < CouchRest::Model::Base use_database DB property :name property :phone end it "should not protect anything through new" do user = NoProtection.new(:name => "will", :phone => "...
github
couchrest/couchrest_model
https://github.com/couchrest/couchrest_model
spec/unit/subclass_spec.rb
Ruby
apache-2.0
302
master
2,575
require "spec_helper" # add a default value Card.property :bg_color, :default => '#ccc' class BusinessCard < Card property :extension_code property :job_title validates_presence_of :extension_code validates_presence_of :job_title end class DesignBusinessCard < BusinessCard property :bg_color, :default => ...
github
couchrest/couchrest_model
https://github.com/couchrest/couchrest_model
spec/unit/design_spec.rb
Ruby
apache-2.0
302
master
8,400
# encoding: utf-8 require 'spec_helper' describe CouchRest::Model::Design do before :all do reset_test_db! end class DesignSampleModelBase < CouchRest::Model::Base use_database DB property :name property :surname design do view :by_name end design :stats do view :by_sur...
github
couchrest/couchrest_model
https://github.com/couchrest/couchrest_model
spec/unit/proxyable_spec.rb
Ruby
apache-2.0
302
master
15,686
require "spec_helper" class DummyProxyable < CouchRest::Model::Base proxy_database_method :db def db 'db' end end class ProxyKitten < CouchRest::Model::Base end describe CouchRest::Model::Proxyable do describe "#proxy_database" do before do @class = Class.new(CouchRest::Model::Base) @cl...
github
couchrest/couchrest_model
https://github.com/couchrest/couchrest_model
spec/unit/persistence_spec.rb
Ruby
apache-2.0
302
master
16,614
# encoding: utf-8 require 'spec_helper' describe CouchRest::Model::Persistence do before(:each) do @obj = WithDefaultValues.new end describe "creating a new document from database" do it "should instantialize" do doc = Article.build_from_database({'_id' => 'testitem1', '_rev' => 123, 'couchrest-...
github
couchrest/couchrest_model
https://github.com/couchrest/couchrest_model
spec/unit/casted_spec.rb
Ruby
apache-2.0
302
master
1,736
require "spec_helper" class Driver < CouchRest::Model::Base use_database DB # You have to add a casted_by accessor if you want to reach a casted extended doc parent attr_accessor :casted_by property :name end class Car < CouchRest::Model::Base use_database DB property :name property :driver, Drive...
github
couchrest/couchrest_model
https://github.com/couchrest/couchrest_model
spec/unit/assocations_spec.rb
Ruby
apache-2.0
302
master
9,111
# encoding: utf-8 require 'spec_helper' describe "Assocations" do describe ".merge_belongs_to_association_options" do before :all do def SaleInvoice.merge_assoc_opts(*args) merge_belongs_to_association_options(*args) end end it "should return a default set of options" do o = S...
github
couchrest/couchrest_model
https://github.com/couchrest/couchrest_model
spec/unit/connection_spec.rb
Ruby
apache-2.0
302
master
4,959
# encoding: utf-8 require 'spec_helper' describe CouchRest::Model::Connection do before do @class = Class.new(CouchRest::Model::Base) end describe "instance methods" do before :each do @obj = @class.new end describe "#database" do it "should respond to" do expect(@obj).to r...
github
couchrest/couchrest_model
https://github.com/couchrest/couchrest_model
spec/unit/dirty_spec.rb
Ruby
apache-2.0
302
master
17,519
require "spec_helper" class WithCastedModelMixin include CouchRest::Model::CastedModel property :name property :details, Object, :default => {} property :casted_attribute, WithCastedModelMixin end class DirtyModel < CouchRest::Model::Base use_database DB property :casted_attribute, WithCastedModelMixin ...
github
couchrest/couchrest_model
https://github.com/couchrest/couchrest_model
spec/unit/configuration_spec.rb
Ruby
apache-2.0
302
master
1,919
# encoding: utf-8 require "spec_helper" describe CouchRest::Model::Configuration do before do @class = Class.new(CouchRest::Model::Base) end describe '.configure' do it "should set a configuration parameter" do @class.add_config :foo_bar @class.configure do |config| config.foo_bar =...
github
couchrest/couchrest_model
https://github.com/couchrest/couchrest_model
spec/unit/server_pool_spec.rb
Ruby
apache-2.0
302
master
621
require "spec_helper" describe CouchRest::Model::ServerPool do subject { CouchRest::Model::ServerPool } describe ".instance" do it "should provide a singleton" do expect(subject.instance).to be_a(CouchRest::Model::ServerPool) end end describe "#[url]" do it "should provide a server obj...
github
couchrest/couchrest_model
https://github.com/couchrest/couchrest_model
spec/unit/inherited_spec.rb
Ruby
apache-2.0
302
master
681
require 'spec_helper' class PlainParent class_attribute :foo self.foo = :bar end class PlainChild < PlainParent end class ExtendedParent < CouchRest::Model::Base class_attribute :foo self.foo = :bar end class ExtendedChild < ExtendedParent end describe "Using chained inheritance without CouchRest::Model::B...
github
couchrest/couchrest_model
https://github.com/couchrest/couchrest_model
spec/unit/attachment_spec.rb
Ruby
apache-2.0
302
master
6,802
require 'spec_helper' describe "Model attachments" do describe "#has_attachment?" do before(:each) do reset_test_db! @obj = Basic.new expect(@obj.save).to be_truthy @file = File.open(FIXTURE_PATH + '/attachments/test.html') @attachment_name = 'my_attachment' @obj.create_att...
github
couchrest/couchrest_model
https://github.com/couchrest/couchrest_model
spec/unit/validations_spec.rb
Ruby
apache-2.0
302
master
5,173
require "spec_helper" describe CouchRest::Model::Validations do describe "Uniqueness" do context "basic" do before(:all) do @objs = ['title 1', 'title 2', 'title 3'].map{|t| WithUniqueValidation.create(:title => t)} end it "should create a new view if none defined before performing" ...
github
couchrest/couchrest_model
https://github.com/couchrest/couchrest_model
spec/unit/designs_spec.rb
Ruby
apache-2.0
302
master
7,038
require "spec_helper" describe CouchRest::Model::Designs do it "should accessable from model" do expect(DesignModel.respond_to?(:design)).to be_truthy end describe "class methods" do describe ".design" do before :each do @klass = DesignsModel.dup end describe "without bloc...
github
couchrest/couchrest_model
https://github.com/couchrest/couchrest_model
spec/unit/casted_array_spec.rb
Ruby
apache-2.0
302
master
1,330
# encoding: utf-8 require "spec_helper" # # TODO This requires much more testing, although most of the basics # are checked by other parts of the code. # describe CouchRest::Model::CastedArray do let :klass do CouchRest::Model::CastedArray end describe "#initialize" do it "should set the casted proper...
github
couchrest/couchrest_model
https://github.com/couchrest/couchrest_model
spec/unit/property_spec.rb
Ruby
apache-2.0
302
master
7,493
# encoding: utf-8 require 'spec_helper' describe CouchRest::Model::Property do let :klass do CouchRest::Model::Property end it "should provide name as string" do property = CouchRest::Model::Property.new(:test, :type => String) expect(property.name).to eql('test') expect(property.to_s).to eql('...
github
couchrest/couchrest_model
https://github.com/couchrest/couchrest_model
spec/unit/core_extensions/time_parsing_spec.rb
Ruby
apache-2.0
302
master
4,515
# encoding: utf-8 require File.expand_path('../../../spec_helper', __FILE__) describe "Time Parsing core extension" do describe "Time" do it "should respond to .parse_iso8601" do expect(Time.respond_to?("parse_iso8601")).to be_truthy end describe "#as_json" do it "should convert local tim...
github
couchrest/couchrest_model
https://github.com/couchrest/couchrest_model
spec/unit/support/couchrest_database_spec.rb
Ruby
apache-2.0
302
master
334
require "spec_helper" describe CouchRest::Model::Support::Database do describe "#delete!" do it "should empty design cache after a database is destroyed" do Thread.current[:couchrest_design_cache] = { :foo => :bar } DB.delete! expect(Thread.current[:couchrest_design_cache]).to be_empty en...
github
couchrest/couchrest_model
https://github.com/couchrest/couchrest_model
spec/unit/designs/view_spec.rb
Ruby
apache-2.0
302
master
39,790
require File.expand_path("../../../spec_helper", __FILE__) class DesignViewModel < CouchRest::Model::Base use_database DB property :name property :title design do view :by_name view :by_just_name, :map => "function(doc) { emit(doc['name'], null); }" end end describe "Design View" do describe "(u...
github
couchrest/couchrest_model
https://github.com/couchrest/couchrest_model
spec/unit/designs/migrations_spec.rb
Ruby
apache-2.0
302
master
2,873
require 'spec_helper' describe CouchRest::Model::Designs::Migrations do before :all do reset_test_db! end describe "base methods" do describe "#migrate" do # WARNING! ORDER IS IMPORTANT! describe "with limited changes" do class MigrationModelBase < CouchRest::Model::Base ...
github
couchrest/couchrest_model
https://github.com/couchrest/couchrest_model
spec/unit/designs/design_mapper_spec.rb
Ruby
apache-2.0
302
master
3,837
# encoding: utf-8 require 'spec_helper' describe CouchRest::Model::Designs::DesignMapper do before :all do @klass = CouchRest::Model::Designs::DesignMapper end describe 'initialize without prefix' do before :all do @object = @klass.new(DesignModel) end it "should set basic variables" d...
github
couchrest/couchrest_model
https://github.com/couchrest/couchrest_model
spec/unit/utils/migrate_spec.rb
Ruby
apache-2.0
302
master
5,801
require 'spec_helper' class MigrateModel < CouchRest::Model::Base use_database :migrations proxy_database_method :id proxy_for :migrate_proxy_models property :name property :value design { view :by_name } end class MigrateProxyModel < CouchRest::Model::Base proxied_by :migrate_model proxy_database_met...
github
cldwalker/tux
https://github.com/cldwalker/tux
test/commands_test.rb
Ruby
mit
302
master
1,096
require File.dirname(__FILE__) + '/test_helper' describe Tux::Commands do def ripl @ripl ||= Object.new.extend(Tux::Commands) end describe "#app" do it "is an instance of the sinatra app" do ripl.app.class.should == Tux.app_class end it "can call a helper method" do ripl.app.moo('ma...
github
cldwalker/tux
https://github.com/cldwalker/tux
test/test_helper.rb
Ruby
mit
302
master
275
require 'bacon' require 'bacon/bits' require 'tux' require 'sinatra/base' class TestApp < Sinatra::Base helpers do def moo(str) "moo-#{str}" end end set :root, 'dir' set :ka, lambda { raise 'boom' } get '/' do end post '/:id/:format' do end end
github
cldwalker/tux
https://github.com/cldwalker/tux
lib/tux.rb
Ruby
mit
302
master
532
require 'ripl' require 'tux/version' require 'tux/commands' Ripl::Commands.include Tux::CommandsFormatted, Tux::Commands module Tux def self.app_class @app_class ||= begin klasses = objects(Class).select {|e| e.superclass == Sinatra::Base } raise "No Sinatra application found" if klasses.empty? ...
github
cldwalker/tux
https://github.com/cldwalker/tux
lib/tux/commands.rb
Ruby
mit
302
master
1,269
module Tux module Commands SETTINGS = %w{methodoverride inline_templates} def routes Tux.app_class.routes.inject([]) {|arr, (k,v)| arr += v.map {|regex,params,*| path = params.empty? ? regex.inspect : params.inject(regex.inspect) {|s,e| s.sub(/\([^()]+\)/, ":#{e}") } ...
github
cldwalker/tux
https://github.com/cldwalker/tux
lib/tux/runner.rb
Ruby
mit
302
master
336
module Tux class Runner < Ripl::Runner self.app = 'tux' add_options ['-c, --config FILE', 'Set rack config file i.e. config.ru'] def self.parse_option(option, argv) if option[/(?:-c|--config)=?(.*)/] ENV['RACK_CONFIG'] = $1.empty? ? argv.shift.to_s : $1 else super end ...
github
apokalipto/devise_saml_authenticatable
https://github.com/apokalipto/devise_saml_authenticatable
Gemfile
Ruby
mit
302
master
401
source 'https://rubygems.org' # Specify your gem's dependencies in devise_saml_authenticatable.gemspec gemspec group :test do gem 'rake' gem 'rspec', '~> 3.0' gem 'rails', '~> 8.0.0' gem 'rspec-rails' gem 'sqlite3', '~> 2.6.0' gem 'capybara' gem 'selenium-webdriver' gem 'webrick' gem 'net-smtp', req...
github
apokalipto/devise_saml_authenticatable
https://github.com/apokalipto/devise_saml_authenticatable
devise_saml_authenticatable.gemspec
Ruby
mit
302
master
975
# -*- encoding: utf-8 -*- require File.expand_path('../lib/devise_saml_authenticatable/version', __FILE__) Gem::Specification.new do |gem| gem.authors = ["Josef Sauter"] gem.email = ["Josef.Sauter@gmail.com"] gem.description = %q{SAML Authentication for devise} gem.summary = %q{SAML Authe...
github
apokalipto/devise_saml_authenticatable
https://github.com/apokalipto/devise_saml_authenticatable
lib/devise_saml_authenticatable.rb
Ruby
mit
302
master
6,545
require "devise" require "devise_saml_authenticatable/version" require "devise_saml_authenticatable/exception" require "devise_saml_authenticatable/logger" require "devise_saml_authenticatable/routes" require "devise_saml_authenticatable/saml_config" require "devise_saml_authenticatable/default_attribute_map_resolver"...
github
apokalipto/devise_saml_authenticatable
https://github.com/apokalipto/devise_saml_authenticatable
lib/devise_saml_authenticatable/model.rb
Ruby
mit
302
master
3,210
require 'devise_saml_authenticatable/strategy' require 'devise_saml_authenticatable/saml_response' module Devise module Models module SamlAuthenticatable extend ActiveSupport::Concern # Need to determine why these need to be included included do attr_reader :password, :current_password...
github
apokalipto/devise_saml_authenticatable
https://github.com/apokalipto/devise_saml_authenticatable
lib/devise_saml_authenticatable/routes.rb
Ruby
mit
302
master
1,112
ActionDispatch::Routing::Mapper.class_eval do protected def devise_saml_authenticatable(mapping, controllers) if ::Devise.saml_route_helper_prefix prefix = ::Devise.saml_route_helper_prefix resource :session, only: [], controller: controllers[:saml_sessions], path: '' do get :new, path: 'sam...
github
apokalipto/devise_saml_authenticatable
https://github.com/apokalipto/devise_saml_authenticatable
lib/devise_saml_authenticatable/default_attribute_map_resolver.rb
Ruby
mit
302
master
557
module DeviseSamlAuthenticatable class DefaultAttributeMapResolver def initialize(saml_response) @saml_response = saml_response end def attribute_map return {} unless File.exist?(attribute_map_path) attribute_map = YAML.load(File.read(attribute_map_path)) if attribute_map.key?(Ra...
github
apokalipto/devise_saml_authenticatable
https://github.com/apokalipto/devise_saml_authenticatable
lib/devise_saml_authenticatable/saml_config.rb
Ruby
mit
302
master
1,699
require 'ruby-saml' module DeviseSamlAuthenticatable module SamlConfig def saml_config(idp_entity_id = nil, request = nil) return file_based_config if file_based_config return adapter_based_config(idp_entity_id, request) if Devise.idp_settings_adapter Devise.saml_config end private ...
github
apokalipto/devise_saml_authenticatable
https://github.com/apokalipto/devise_saml_authenticatable
lib/devise_saml_authenticatable/saml_mapped_attributes.rb
Ruby
mit
302
master
877
module SamlAuthenticatable class SamlMappedAttributes def initialize(attributes, attribute_map) @attributes = attributes @attribute_map = attribute_map end def saml_attribute_keys @attribute_map.keys end def resource_keys @attribute_map.values end def value_by_re...
github
apokalipto/devise_saml_authenticatable
https://github.com/apokalipto/devise_saml_authenticatable
lib/devise_saml_authenticatable/default_idp_entity_id_reader.rb
Ruby
mit
302
master
607
module DeviseSamlAuthenticatable class DefaultIdpEntityIdReader def self.entity_id(params) if params[:SAMLRequest] OneLogin::RubySaml::SloLogoutrequest.new( params[:SAMLRequest], settings: Devise.saml_config, allowed_clock_drift: Devise.allowed_clock_drift_in_seconds, ...
github
apokalipto/devise_saml_authenticatable
https://github.com/apokalipto/devise_saml_authenticatable
lib/devise_saml_authenticatable/saml_response.rb
Ruby
mit
302
master
464
require 'devise_saml_authenticatable/saml_mapped_attributes' module SamlAuthenticatable class SamlResponse attr_reader :raw_response, :attributes def initialize(saml_response, attribute_map) @attributes = ::SamlAuthenticatable::SamlMappedAttributes.new(saml_response.attributes, attribute_map) @r...
github
apokalipto/devise_saml_authenticatable
https://github.com/apokalipto/devise_saml_authenticatable
lib/devise_saml_authenticatable/strategy.rb
Ruby
mit
302
master
2,412
require 'devise/strategies/authenticatable' module Devise module Strategies class SamlAuthenticatable < Authenticatable include DeviseSamlAuthenticatable::SamlConfig def valid? if params[:SAMLResponse] OneLogin::RubySaml::Response.new( params[:SAMLResponse], ...
github
apokalipto/devise_saml_authenticatable
https://github.com/apokalipto/devise_saml_authenticatable
lib/devise_saml_authenticatable/logger.rb
Ruby
mit
302
master
252
module DeviseSamlAuthenticatable class Logger def self.send(message, log_level = ::Logger::INFO, logger = Rails.logger) if ::Devise.saml_logger logger.add log_level, " \e[36msaml:\e[0m #{message}" end end end end
github
apokalipto/devise_saml_authenticatable
https://github.com/apokalipto/devise_saml_authenticatable
app/controllers/devise/saml_sessions_controller.rb
Ruby
mit
302
master
3,963
require 'ruby-saml' class Devise::SamlSessionsController < Devise::SessionsController include DeviseSamlAuthenticatable::SamlConfig skip_before_action :verify_authenticity_token, raise: false prepend_before_action :store_info_for_sp_initiated_logout, :verify_signed_out_user, only: :destroy def new idp_en...
github
apokalipto/devise_saml_authenticatable
https://github.com/apokalipto/devise_saml_authenticatable
spec/spec_helper.rb
Ruby
mit
302
master
1,586
require "fileutils" require 'capybara/rspec' RSpec.configure do |config| config.run_all_when_everything_filtered = true config.filter_run :focus config.order = 'random' # Specify a longer timeout for Capybara to allow for slower CI environments causing failing tests Capybara.default_max_wait_time = 10 # c...
github
apokalipto/devise_saml_authenticatable
https://github.com/apokalipto/devise_saml_authenticatable
spec/rails_helper.rb
Ruby
mit
302
master
1,178
ENV["RAILS_ENV"] ||= 'test' require 'spec_helper' create_app('sp', 'USE_SUBJECT_TO_AUTHENTICATE' => "false") require "#{working_directory}/sp/config/environment" require 'rspec/rails' # Starting from Rails 8.0, routes are lazy-loaded by default in test and development environments. # However, Devise's mappings are b...
github
apokalipto/devise_saml_authenticatable
https://github.com/apokalipto/devise_saml_authenticatable
spec/devise_saml_authenticatable/saml_config_spec.rb
Ruby
mit
302
master
8,798
require 'spec_helper' require 'support/ruby_saml_support' describe DeviseSamlAuthenticatable::SamlConfig do include RubySamlSupport let(:saml_config) { controller.saml_config } let(:controller) { Class.new { include DeviseSamlAuthenticatable::SamlConfig }.new } context "when config/idp.yml does not exist" do...
github
apokalipto/devise_saml_authenticatable
https://github.com/apokalipto/devise_saml_authenticatable
spec/devise_saml_authenticatable/strategy_spec.rb
Ruby
mit
302
master
14,085
require 'rails_helper' require 'support/ruby_saml_support' describe Devise::Strategies::SamlAuthenticatable do include RubySamlSupport subject(:strategy) { described_class.new(env, :user) } let(:env) { {} } let(:errors) { ["Test1", "Test2"] } let(:response) { double(:response, issuers: [idp_entity_id], :se...
github
apokalipto/devise_saml_authenticatable
https://github.com/apokalipto/devise_saml_authenticatable
spec/devise_saml_authenticatable/saml_mapped_attributes_spec.rb
Ruby
mit
302
master
1,875
require 'spec_helper' require 'devise_saml_authenticatable/saml_mapped_attributes' describe SamlAuthenticatable::SamlMappedAttributes do let(:instance) { described_class.new(saml_attributes, attribute_map) } let(:attribute_map_file) { File.join(File.dirname(__FILE__), '../support/attribute-map.yml') } let(:attri...
github
apokalipto/devise_saml_authenticatable
https://github.com/apokalipto/devise_saml_authenticatable
spec/devise_saml_authenticatable/default_idp_entity_id_reader_spec.rb
Ruby
mit
302
master
2,148
require "spec_helper" describe DeviseSamlAuthenticatable::DefaultIdpEntityIdReader do describe ".entity_id" do context "when there is a SAMLRequest in the params" do let(:params) { {SAMLRequest: "logout request"} } let(:slo_logout_request) { double('slo_logout_request', issuer: 'meow')} before ...
github
apokalipto/devise_saml_authenticatable
https://github.com/apokalipto/devise_saml_authenticatable
spec/devise_saml_authenticatable/default_attribute_map_resolver_spec.rb
Ruby
mit
302
master
1,690
require "spec_helper" require "devise_saml_authenticatable/default_attribute_map_resolver" describe DeviseSamlAuthenticatable::DefaultAttributeMapResolver do let!(:rails) { class_double("Rails", env: "test", logger: logger, root: rails_root).as_stubbed_const } let(:logger) { instance_double("Logger", info: nil) } ...
github
apokalipto/devise_saml_authenticatable
https://github.com/apokalipto/devise_saml_authenticatable
spec/devise_saml_authenticatable/model_spec.rb
Ruby
mit
302
master
18,930
require 'spec_helper' describe Devise::Models::SamlAuthenticatable do class Model include Devise::Models::SamlAuthenticatable attr_accessor :email, :name, :saved def initialize(params = {}) @email = params[:email] @name = params[:name] @new_record = params.fetch(:new_record, true) e...
github
apokalipto/devise_saml_authenticatable
https://github.com/apokalipto/devise_saml_authenticatable
spec/support/ruby_saml_support.rb
Ruby
mit
302
master
271
module RubySamlSupport VERSION_1_12 = Gem::Version.new("1.12.0") def with_ruby_saml_1_12_or_greater(body, args = {else_do: nil}) if Gem::Version.new(OneLogin::RubySaml::VERSION) >= VERSION_1_12 body.call else args[:else_do].call end end end
github
apokalipto/devise_saml_authenticatable
https://github.com/apokalipto/devise_saml_authenticatable
spec/support/sp_template.rb
Ruby
mit
302
master
5,235
# Set up a SAML Service Provider require "onelogin/ruby-saml/version" attribute_map_resolver = ENV.fetch("ATTRIBUTE_MAP_RESOLVER", "nil") saml_session_index_key = ENV.fetch('SAML_SESSION_INDEX_KEY', ":session_index") use_subject_to_authenticate = ENV.fetch('USE_SUBJECT_TO_AUTHENTICATE') idp_settings_adapter = ENV.fet...
github
apokalipto/devise_saml_authenticatable
https://github.com/apokalipto/devise_saml_authenticatable
spec/support/rails_app.rb
Ruby
mit
302
master
3,804
require "open3" require "socket" require "tempfile" require "timeout" require "bundler/setup" require "bundler/gem_tasks" APP_READY_TIMEOUT ||= 30 def sh!(cmd) unless system(cmd) raise "[#{cmd}] failed with exit code #{$?.exitstatus}" end end def app_ready?(pid, port) Process.getpgid(pid) && port_open?(por...
github
apokalipto/devise_saml_authenticatable
https://github.com/apokalipto/devise_saml_authenticatable
spec/support/idp_template.rb
Ruby
mit
302
master
1,164
# Set up a SAML IdP @email_address_attribute_key = ENV.fetch("EMAIL_ADDRESS_ATTRIBUTE_KEY", "http://schemas.xmlsoap.org/ws/2005/05/identity/claims/emailaddress") @name_attribute_key = ENV.fetch("NAME_ATTRIBUTE_KEY", "http://schemas.xmlsoap.org/ws/2005/05/identity/claims/name") @include_subject_in_attributes = ENV.fetc...
github
apokalipto/devise_saml_authenticatable
https://github.com/apokalipto/devise_saml_authenticatable
spec/controllers/devise/saml_sessions_controller_spec.rb
Ruby
mit
302
master
14,164
require 'rails_helper' require 'support/ruby_saml_support' # The important parts from devise class DeviseController < ApplicationController attr_accessor :current_user def resource_class User end def resource_name 'users' end def require_no_authentication; end def set_flash_message!(key, kind...
github
apokalipto/devise_saml_authenticatable
https://github.com/apokalipto/devise_saml_authenticatable
spec/features/saml_authentication_spec.rb
Ruby
mit
302
master
8,873
require 'spec_helper' require 'net/http' require 'timeout' require 'uri' require 'capybara/rspec' require 'selenium-webdriver' Capybara.register_driver :chrome do |app| options = Selenium::WebDriver::Chrome::Options.new options.add_argument('--headless') options.add_argument('--allow-insecure-localhost') optio...
github
apokalipto/devise_saml_authenticatable
https://github.com/apokalipto/devise_saml_authenticatable
spec/routes/routes_spec.rb
Ruby
mit
302
master
4,311
require 'rails_helper' describe 'SamlAuthenticatable Routes', type: :routing do describe 'GET /users/saml/sign_in (login)' do it 'routes to Devise::SamlSessionsController#new' do expect(get: '/users/saml/sign_in').to route_to(controller: 'devise/saml_sessions', action: 'new') expect(get: new_user_ses...
github
guard/guard-jasmine
https://github.com/guard/guard-jasmine
Guardfile
Ruby
mit
302
master
815
coffeescript_options = { input: 'lib/guard/jasmine/phantomjs/src', output: 'lib/guard/jasmine/phantomjs', patterns: [%r{^lib/guard/jasmine/phantomjs/src/(.+\.(?:coffee|coffee\.md|litcoffee))$}] } guard 'coffeescript', coffeescript_options do coffeescript_options[:patterns].each { |pattern| watch(pattern) } end...
github
guard/guard-jasmine
https://github.com/guard/guard-jasmine
Gemfile
Ruby
mit
302
master
473
source 'https://rubygems.org' gemspec development_group: :gem_build_tools group :development do gem 'coolline' gem 'rb-fsevent' gem 'redcarpet' gem 'yajl-ruby' gem 'rubocop' gem 'guard-coffeescript', '~> 2.0' gem 'guard-rspec', require: false gem 'guard-shell', require: false gem 'rack' gem 'yar...
github
guard/guard-jasmine
https://github.com/guard/guard-jasmine
Rakefile
Ruby
mit
302
master
1,339
require 'bundler/gem_tasks' require 'rspec/core/rake_task' def ci? ENV['CI'] == 'true' end default_tasks = [] default_tasks << RSpec::Core::RakeTask.new(:spec) do |t| t.verbose = ci? end unless ci? require 'rubocop/rake_task' default_tasks << RuboCop::RakeTask.new(:rubocop) end task default: default_tasks...
github
guard/guard-jasmine
https://github.com/guard/guard-jasmine
guard-jasmine.gemspec
Ruby
mit
302
master
1,317
# -*- encoding: utf-8 -*- $LOAD_PATH.push File.expand_path('../lib', __FILE__) require 'guard/jasmine/version' Gem::Specification.new do |s| s.name = 'guard-jasmine' s.version = Guard::JasmineVersion::VERSION s.platform = Gem::Platform::RUBY s.authors = ['Michael Kessler', 'Nathan Stitt'] s...
github
guard/guard-jasmine
https://github.com/guard/guard-jasmine
lib/generators/guard_jasmine/install_generator.rb
Ruby
mit
302
master
437
require 'rails/generators' module GuardJasmine class InstallGenerator < Rails::Generators::Base desc 'Install a sample Guardfile for running Jasmine specs via GuardJasmine' def self.source_root @source_root ||= File.join(File.dirname(__FILE__), 'templates') end # Generator Code. Remember this...
github
guard/guard-jasmine
https://github.com/guard/guard-jasmine
lib/generators/guard_jasmine/templates/Guardfile
Ruby
mit
302
master
298
# A sample Guardfile # More info at https://github.com/guard/guard#readme guard :jasmine do watch(%r{^spec/javascripts/.*(?:_s|S)pec\.(coffee|js)$}) watch(%r{app/assets/javascripts/(.+?)\.(js\.coffee|js|coffee)(?:\.\w+)*$}) do |m| "spec/javascripts/jasmine/#{m[1]}_spec.#{m[2]}" end end