mongoid_multiparams 0.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 8340a1e3d4d6accd94b7114db83ea342f867040a
4
+ data.tar.gz: 49328b55f0e85ab0f5afafb7579af955eaf4bc35
5
+ SHA512:
6
+ metadata.gz: 3c1e20f35079000c02298b17f68715bcbb81551dd1d5441757edc03bdb6e552890c1c7f72030ebfaa835b821da42cdf4701325dbd300b1ec8e3ec27e2b4505d6
7
+ data.tar.gz: a6b94c0e94e33037115a291c716c356d28f6bbb7fee1ac9a843d12c55d328f1f0aeb214f1e14a389bc02ddc019c7ee25c2b656c386943b952ac7531c51cf53e0
data/.gitignore ADDED
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --tty
2
+ --colour
3
+ --format <%= ENV["CI"] ? 'progress' : 'documentation'%>
data/.travis.yml ADDED
@@ -0,0 +1,6 @@
1
+ language: ruby
2
+ bundler_args: --without development
3
+ rvm:
4
+ - 2.0.0
5
+ services:
6
+ - mongodb
data/Gemfile ADDED
@@ -0,0 +1,14 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in mongoid_multiparams.gemspec
4
+ gemspec
5
+
6
+ group :test do
7
+ gem 'rake'
8
+ gem 'mongoid', '~> 4.0.0', github: 'mongoid/mongoid'
9
+ gem 'rspec', '~> 2.13.0'
10
+
11
+ if ENV['CI']
12
+ gem "coveralls", require: false
13
+ end
14
+ end
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 Matt D
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,29 @@
1
+ # Mongoid Multiparams [![Build Status](https://travis-ci.org/mdoza/mongoid_multiparams.png?branch=master)](https://travis-ci.org/mdoza/mongoid_multiparams) [![Code Climate](https://codeclimate.com/github/mdoza/mongoid_multiparams.png)](https://codeclimate.com/github/mdoza/mongoid_multiparams)
2
+
3
+ TODO: Write a gem description
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'mongoid_multiparams'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install mongoid_multiparams
18
+
19
+ ## Usage
20
+
21
+ TODO: Write usage instructions here
22
+
23
+ ## Contributing
24
+
25
+ 1. Fork it
26
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
27
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
28
+ 4. Push to the branch (`git push origin my-new-feature`)
29
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,20 @@
1
+ require "bundler/gem_tasks"
2
+
3
+ require "bundler"
4
+ Bundler.setup
5
+
6
+ require "rake"
7
+ require "rspec/core/rake_task"
8
+
9
+ $LOAD_PATH.unshift File.expand_path("../lib", __FILE__)
10
+
11
+ RSpec::Core::RakeTask.new("spec") do |spec|
12
+ spec.pattern = "spec/**/*_spec.rb"
13
+ end
14
+
15
+ RSpec::Core::RakeTask.new('spec:progress') do |spec|
16
+ spec.rspec_opts = %w(--format progress)
17
+ spec.pattern = "spec/**/*_spec.rb"
18
+ end
19
+
20
+ task :default => :spec
@@ -0,0 +1,20 @@
1
+ -----BEGIN CERTIFICATE-----
2
+ MIIDWDCCAkCgAwIBAgIBATANBgkqhkiG9w0BAQUFADA5MQ4wDAYDVQQDDAVtZG96
3
+ YTESMBAGCgmSJomT8ixkARkWAm1lMRMwEQYKCZImiZPyLGQBGRYDY29tMB4XDTEz
4
+ MDcwMjE3MzIzOVoXDTE0MDcwMjE3MzIzOVowOTEOMAwGA1UEAwwFbWRvemExEjAQ
5
+ BgoJkiaJk/IsZAEZFgJtZTETMBEGCgmSJomT8ixkARkWA2NvbTCCASIwDQYJKoZI
6
+ hvcNAQEBBQADggEPADCCAQoCggEBAJqGyPTFSMgduP0/sQvorKD/RoNUs6w9Z6Fj
7
+ kD2BTkzpvS4GWkMMObijJfOSC+irdRLaRqnwVummVwWmBfmR4aL8mU9Ci+ACQQ6q
8
+ B0pFurkQYknncu0TmuxluibD1wWGKHaCtq06mxvZ2KyF1L2PWOUj210qgmrV9kN8
9
+ 7e/UUysW971zvb3kz1KWoD4+Yszz9y89vc2jkm5gJwh9JqRnfwaxKnTKtUhpdmEK
10
+ V+KirIEZFcCoOcTSNtL8v6CWqrk4AVfIgkbTSPjhMgaMQxEyGWMBzocFpH2uj/Vr
11
+ DuAP7/f3ue6JHNolUGILmQL9xit206fHlU8X6brG+JokONA4N8UCAwEAAaNrMGkw
12
+ CQYDVR0TBAIwADALBgNVHQ8EBAMCBLAwHQYDVR0OBBYEFAfOoGwOwg93PfisoBwb
13
+ i4r+Q0rnMBcGA1UdEQQQMA6BDG1kb3phQG1lLmNvbTAXBgNVHRIEEDAOgQxtZG96
14
+ YUBtZS5jb20wDQYJKoZIhvcNAQEFBQADggEBAI0FlaBc8JVe3Fr+4xjP5va9UxHK
15
+ q8iocrVwxzdKxmS8Rv/URvIe/6IaAHyxJmIfqzTDGS0/hJwQUPbNypdRSRr7YzDD
16
+ /h0oCFVAuorR0rmytkOG8Uk49v/BA4KyG7hkZFRmxy46avP2+3oPxX2k0cpWz1TP
17
+ wTbx/W7oQyVMqHLXbvf8dvmZj/5WC5utyRvKuGxJEpnTF4IRPRmwCnhcQMDnceqf
18
+ aEmvIrgJPRl1aciRcmln1i4QNokV0yxE8brgR5+XznqUV1PUu3G1ehREsqfMJdt3
19
+ Xxsjs3Wtv/t2KgkzoIoX/bXxrGhQ3RKVoMkp4xlp0ygEyqCmNzYL5yINWP4=
20
+ -----END CERTIFICATE-----
@@ -0,0 +1,133 @@
1
+ #
2
+ # Copyright (c) 2009-2013 Durran Jordan
3
+ #
4
+ # Permission is hereby granted, free of charge, to any person obtaining
5
+ # a copy of this software and associated documentation files (the
6
+ # "Software"), to deal in the Software without restriction, including
7
+ # without limitation the rights to use, copy, modify, merge, publish,
8
+ # distribute, sublicense, and/or sell copies of the Software, and to
9
+ # permit persons to whom the Software is furnished to do so, subject to
10
+ # the following conditions:
11
+ #
12
+ # The above copyright notice and this permission notice shall be
13
+ # included in all copies or substantial portions of the Software.
14
+ #
15
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16
+ # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17
+ # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18
+ # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
19
+ # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
20
+ # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
21
+ # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22
+ #
23
+
24
+ require "mongoid_multiparams/version"
25
+ require 'mongoid'
26
+
27
+ module MongoidMultiparams
28
+ # Your code goes here...
29
+ end
30
+
31
+ # encoding: utf-8
32
+ module Mongoid
33
+
34
+ # Adds Rails' multi-parameter attribute support to Mongoid.
35
+ #
36
+ # @todo: Durran: This module needs an overhaul.
37
+ module MultiParameterAttributes
38
+
39
+ module Errors
40
+
41
+ # Raised when an error occurred while doing a mass assignment to an
42
+ # attribute through the <tt>attributes=</tt> method. The exception
43
+ # has an +attribute+ property that is the name of the offending attribute.
44
+ class AttributeAssignmentError < Mongoid::Errors::MongoidError
45
+ attr_reader :exception, :attribute
46
+
47
+ def initialize(message, exception, attribute)
48
+ @exception = exception
49
+ @attribute = attribute
50
+ @message = message
51
+ end
52
+ end
53
+
54
+ # Raised when there are multiple errors while doing a mass assignment
55
+ # through the +attributes+ method. The exception has an +errors+
56
+ # property that contains an array of AttributeAssignmentError
57
+ # objects, each corresponding to the error while assigning to an
58
+ # attribute.
59
+ class MultiparameterAssignmentErrors < Mongoid::Errors::MongoidError
60
+ attr_reader :errors
61
+
62
+ def initialize(errors)
63
+ @errors = errors
64
+ end
65
+ end
66
+ end
67
+
68
+ # Process the provided attributes casting them to their proper values if a
69
+ # field exists for them on the document. This will be limited to only the
70
+ # attributes provided in the suppied +Hash+ so that no extra nil values get
71
+ # put into the document's attributes.
72
+ #
73
+ # @example Process the attributes.
74
+ # person.process_attributes(:title => "sir", :age => 40)
75
+ #
76
+ # @param [ Hash ] attrs The attributes to set.
77
+ #
78
+ # @since 2.0.0.rc.7
79
+ def process_attributes(attrs = nil)
80
+ if attrs
81
+ errors = []
82
+ attributes = attrs.class.new
83
+ attributes.permit! if attrs.respond_to?(:permitted?) && attrs.permitted?
84
+ multi_parameter_attributes = {}
85
+
86
+ attrs.each_pair do |key, value|
87
+ if key =~ /\A([^\(]+)\((\d+)([if])\)$/
88
+ key, index = $1, $2.to_i
89
+ (multi_parameter_attributes[key] ||= {})[index] = value.empty? ? nil : value.send("to_#{$3}")
90
+ else
91
+ attributes[key] = value
92
+ end
93
+ end
94
+
95
+ multi_parameter_attributes.each_pair do |key, values|
96
+ begin
97
+ values = (values.keys.min..values.keys.max).map { |i| values[i] }
98
+ field = self.class.fields[database_field_name(key)]
99
+ attributes[key] = instantiate_object(field, values)
100
+ rescue => e
101
+ errors << Errors::AttributeAssignmentError.new(
102
+ "error on assignment #{values.inspect} to #{key}", e, key
103
+ )
104
+ end
105
+ end
106
+
107
+ unless errors.empty?
108
+ raise Errors::MultiparameterAssignmentErrors.new(errors),
109
+ "#{errors.size} error(s) on assignment of multiparameter attributes"
110
+ end
111
+ super(attributes)
112
+ else
113
+ super
114
+ end
115
+ end
116
+
117
+ protected
118
+
119
+ def instantiate_object(field, values_with_empty_parameters)
120
+ return nil if values_with_empty_parameters.all? { |v| v.nil? }
121
+ values = values_with_empty_parameters.collect { |v| v.nil? ? 1 : v }
122
+ klass = field.type
123
+ if klass == DateTime || klass == Date || klass == Time
124
+ field.mongoize(values)
125
+ elsif klass
126
+ klass.new(*values)
127
+ else
128
+ values
129
+ end
130
+ end
131
+
132
+ end
133
+ end
@@ -0,0 +1,3 @@
1
+ module MongoidMultiparams
2
+ VERSION = "0.0.4"
3
+ end
@@ -0,0 +1,29 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'mongoid_multiparams/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "mongoid_multiparams"
8
+ spec.version = MongoidMultiparams::VERSION
9
+ spec.authors = ["Matt D"]
10
+ spec.email = ["mdoza@me.com"]
11
+ spec.description = %q{Multi parameter support for Mongoid.}
12
+ spec.summary = %q{As of Mongoid 4.0.0, multi parameter support had been removed. This gem replaces the missing functionality.}
13
+ spec.homepage = "http://github.com/mdoza/mongoid_multiparams"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files`.split($/)
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_development_dependency "bundler", "~> 1.3"
22
+ spec.add_development_dependency "rake"
23
+ spec.add_dependency "mongoid", '~> 4.0.0.alpha1'
24
+
25
+ # signing key and certificate chain
26
+ # TODO: Will deal with this later.
27
+ # spec.signing_key = '/Users/matt/.security/gem-private_key.pem'
28
+ # spec.cert_chain = ['gem-public_cert.pem']
29
+ end
@@ -0,0 +1,151 @@
1
+ #
2
+ # Copyright (c) 2009-2013 Durran Jordan
3
+ #
4
+ # Permission is hereby granted, free of charge, to any person obtaining
5
+ # a copy of this software and associated documentation files (the
6
+ # "Software"), to deal in the Software without restriction, including
7
+ # without limitation the rights to use, copy, modify, merge, publish,
8
+ # distribute, sublicense, and/or sell copies of the Software, and to
9
+ # permit persons to whom the Software is furnished to do so, subject to
10
+ # the following conditions:
11
+ #
12
+ # The above copyright notice and this permission notice shall be
13
+ # included in all copies or substantial portions of the Software.
14
+ #
15
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16
+ # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17
+ # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18
+ # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
19
+ # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
20
+ # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
21
+ # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22
+ #
23
+
24
+ require "spec_helper"
25
+
26
+ describe Mongoid::MultiParameterAttributes do
27
+
28
+ describe "#process" do
29
+
30
+ class Multi
31
+ include Mongoid::Document
32
+ include Mongoid::MultiParameterAttributes
33
+ field :created_at, type: Time
34
+ field :dob, type: Date
35
+ field :checked_at, as: :last_user_checked_at, type: Time
36
+ end
37
+
38
+ context "creating a multi" do
39
+
40
+ let(:multi) do
41
+ Multi.new(
42
+ "created_at(1i)" => "2010",
43
+ "created_at(2i)" => "8",
44
+ "created_at(3i)" => "12",
45
+ "created_at(4i)" => "15",
46
+ "created_at(5i)" => "45"
47
+ )
48
+ end
49
+
50
+ it "sets a multi-parameter Time attribute correctly" do
51
+ multi.created_at.should eq(Time.local(2010, 8, 12, 15, 45))
52
+ end
53
+
54
+ it "does not leave ugly attributes on the model" do
55
+ multi.attributes.should_not have_key("created_at(1i)")
56
+ end
57
+ end
58
+
59
+ context "creating a multi" do
60
+
61
+ context "with a valid DOB" do
62
+
63
+ let(:multi) do
64
+ Multi.new({
65
+ "dob(1i)" => "1980",
66
+ "dob(2i)" => "7",
67
+ "dob(3i)" => "27"
68
+ })
69
+ end
70
+
71
+ it "sets a multi-parameter Date attribute correctly" do
72
+ multi.dob.should eq(Date.civil(1980, 7, 27))
73
+ end
74
+ end
75
+
76
+ context "with an invalid DOB" do
77
+
78
+ let(:invalid_multi) do
79
+ Multi.new({
80
+ "dob(1i)" => "1980",
81
+ "dob(2i)" => "2",
82
+ "dob(3i)" => "31"
83
+ })
84
+ end
85
+
86
+ it "uses Time's logic to convert the invalid date to valid" do
87
+ invalid_multi.dob.should eq(Time.new(1980, 2, 31).to_date)
88
+ end
89
+ end
90
+ end
91
+
92
+ context "with a blank DOB" do
93
+
94
+ let(:multi) do
95
+ Multi.new(
96
+ "dob(1i)" => "",
97
+ "dob(2i)" => "",
98
+ "dob(3i)" => ""
99
+ )
100
+ end
101
+
102
+ it "generates a nil date" do
103
+ multi.dob.should be_nil
104
+ end
105
+ end
106
+
107
+ context "with a partially blank DOB" do
108
+
109
+ let(:multi) do
110
+ Multi.new(
111
+ "dob(1i)" => "1980",
112
+ "dob(2i)" => "",
113
+ "dob(3i)" => ""
114
+ )
115
+ end
116
+
117
+ it "sets empty date's year" do
118
+ multi.dob.year.should eq(1980)
119
+ end
120
+
121
+ it "sets empty date's month" do
122
+ multi.dob.month.should eq(1)
123
+ end
124
+
125
+ it "sets empty date's day" do
126
+ multi.dob.day.should eq(1)
127
+ end
128
+ end
129
+
130
+ context "with aliased field" do
131
+
132
+ let(:multi) do
133
+ Multi.new(
134
+ "last_user_checked_at(1i)" => "2010",
135
+ "last_user_checked_at(2i)" => "8",
136
+ "last_user_checked_at(3i)" => "12",
137
+ "last_user_checked_at(4i)" => "15",
138
+ "last_user_checked_at(5i)" => "45"
139
+ )
140
+ end
141
+
142
+ it "sets a multi-parameter Time attribute correctly" do
143
+ multi.last_user_checked_at.should eq(Time.local(2010, 8, 12, 15, 45))
144
+ end
145
+
146
+ it "does not leave ugly attributes on the model" do
147
+ multi.attributes.should_not have_key("created_at(1i)")
148
+ end
149
+ end
150
+ end
151
+ end
@@ -0,0 +1,119 @@
1
+ #
2
+ # Copyright (c) 2009-2013 Durran Jordan
3
+ #
4
+ # Permission is hereby granted, free of charge, to any person obtaining
5
+ # a copy of this software and associated documentation files (the
6
+ # "Software"), to deal in the Software without restriction, including
7
+ # without limitation the rights to use, copy, modify, merge, publish,
8
+ # distribute, sublicense, and/or sell copies of the Software, and to
9
+ # permit persons to whom the Software is furnished to do so, subject to
10
+ # the following conditions:
11
+ #
12
+ # The above copyright notice and this permission notice shall be
13
+ # included in all copies or substantial portions of the Software.
14
+ #
15
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16
+ # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17
+ # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18
+ # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
19
+ # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
20
+ # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
21
+ # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22
+ #
23
+
24
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
25
+
26
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), "..", "lib"))
27
+
28
+ MODELS = File.join(File.dirname(__FILE__), "app/models")
29
+ $LOAD_PATH.unshift(MODELS)
30
+
31
+ Dir[File.join(File.dirname(__FILE__), "..", "lib", "*.rb")].each {|file| require file }
32
+
33
+ if ENV["CI"]
34
+ require "simplecov"
35
+ require "coveralls"
36
+ SimpleCov.formatter = Coveralls::SimpleCov::Formatter
37
+ SimpleCov.start do
38
+ add_filter "spec"
39
+ end
40
+ end
41
+
42
+ require "mongoid"
43
+ require "rspec"
44
+
45
+ ENV["MONGOID_SPEC_HOST"] ||= "localhost"
46
+ ENV["MONGOID_SPEC_PORT"] ||= "27017"
47
+
48
+ HOST = ENV["MONGOID_SPEC_HOST"]
49
+ PORT = ENV["MONGOID_SPEC_PORT"].to_i
50
+
51
+ def database_id
52
+ "mongoid_test"
53
+ end
54
+
55
+ def database_id_alt
56
+ "mongoid_test_alt"
57
+ end
58
+
59
+ CONFIG = {
60
+ sessions: {
61
+ default: {
62
+ database: database_id,
63
+ hosts: [ "#{HOST}:#{PORT}" ]
64
+ }
65
+ }
66
+ }
67
+
68
+ # Can we connect to MongoHQ from this box?
69
+ def mongohq_connectable?
70
+ ENV["MONGOHQ_REPL_PASS"].present?
71
+ end
72
+
73
+ def purge_database_alt!
74
+ session = Mongoid::Sessions.default
75
+ session.use(database_id_alt)
76
+ session.collections.each do |collection|
77
+ collection.drop
78
+ end
79
+ end
80
+
81
+ # Set the database that the spec suite connects to.
82
+ Mongoid.configure do |config|
83
+ config.load_configuration(CONFIG)
84
+ end
85
+
86
+ # Autoload every model for the test suite that sits in spec/app/models.
87
+ Dir[ File.join(MODELS, "*.rb") ].sort.each do |file|
88
+ name = File.basename(file, ".rb")
89
+ autoload name.camelize.to_sym, name
90
+ end
91
+
92
+ module Rails
93
+ class Application
94
+ end
95
+ end
96
+
97
+ module MyApp
98
+ class Application < Rails::Application
99
+ end
100
+ end
101
+
102
+ ActiveSupport::Inflector.inflections do |inflect|
103
+ inflect.irregular("canvas", "canvases")
104
+ inflect.singular("address_components", "address_component")
105
+ end
106
+
107
+ RSpec.configure do |config|
108
+
109
+ # Drop all collections and clear the identity map before each spec.
110
+ config.before(:each) do
111
+ Mongoid.purge!
112
+ Mongoid::IdentityMap.clear
113
+ end
114
+
115
+ # Filter out MongoHQ specs if we can't connect to it.
116
+ config.filter_run_excluding(config: ->(value){
117
+ return true if value == :mongohq && !mongohq_connectable?
118
+ })
119
+ end
metadata ADDED
@@ -0,0 +1,102 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: mongoid_multiparams
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.4
5
+ platform: ruby
6
+ authors:
7
+ - Matt D
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-01-01 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ~>
18
+ - !ruby/object:Gem::Version
19
+ version: '1.3'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: '1.3'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: mongoid
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ~>
46
+ - !ruby/object:Gem::Version
47
+ version: 4.0.0.alpha1
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ~>
53
+ - !ruby/object:Gem::Version
54
+ version: 4.0.0.alpha1
55
+ description: Multi parameter support for Mongoid.
56
+ email:
57
+ - mdoza@me.com
58
+ executables: []
59
+ extensions: []
60
+ extra_rdoc_files: []
61
+ files:
62
+ - .gitignore
63
+ - .rspec
64
+ - .travis.yml
65
+ - Gemfile
66
+ - LICENSE.txt
67
+ - README.md
68
+ - Rakefile
69
+ - gem-public_cert.pem
70
+ - lib/mongoid_multiparams.rb
71
+ - lib/mongoid_multiparams/version.rb
72
+ - mongoid_multiparams.gemspec
73
+ - spec/mongoid/multi_parameter_attributes_spec.rb
74
+ - spec/spec_helper.rb
75
+ homepage: http://github.com/mdoza/mongoid_multiparams
76
+ licenses:
77
+ - MIT
78
+ metadata: {}
79
+ post_install_message:
80
+ rdoc_options: []
81
+ require_paths:
82
+ - lib
83
+ required_ruby_version: !ruby/object:Gem::Requirement
84
+ requirements:
85
+ - - '>='
86
+ - !ruby/object:Gem::Version
87
+ version: '0'
88
+ required_rubygems_version: !ruby/object:Gem::Requirement
89
+ requirements:
90
+ - - '>='
91
+ - !ruby/object:Gem::Version
92
+ version: '0'
93
+ requirements: []
94
+ rubyforge_project:
95
+ rubygems_version: 2.1.11
96
+ signing_key:
97
+ specification_version: 4
98
+ summary: As of Mongoid 4.0.0, multi parameter support had been removed. This gem replaces
99
+ the missing functionality.
100
+ test_files:
101
+ - spec/mongoid/multi_parameter_attributes_spec.rb
102
+ - spec/spec_helper.rb