mongoid_embedded_helper 0.3.0 → 0.3.1

Sign up to get free protection for your applications and to get access to all the features.
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --color --format nested
data/Gemfile CHANGED
@@ -1,10 +1,10 @@
1
1
  source :gemcutter
2
2
 
3
- gem 'mongoid', '>=2.0.0.beta.14'
4
- gem "mongoid_adjust", ">= 0.1.1"
5
- gem 'bson_ext', '>=1.0.1'
3
+ gem 'mongoid', '>= 2.0.2'
4
+ gem "mongoid_adjust", '>= 0.1.1'
5
+ gem 'bson_ext', '>= 1.0.1'
6
6
 
7
7
  group :test do
8
- gem 'rspec', '>= 2.0.0.beta.15'
8
+ gem 'rspec', '>= 2.4.0'
9
9
  gem 'mocha'
10
- end
10
+ end
@@ -1,24 +1,29 @@
1
- # Mongoid embedded helper #
1
+ h1. Mongoid embedded helper
2
2
 
3
3
  The Mongoid EmbeddedHelper helps overcome the limitation that you can't perform direct queries on an embedded collection without accessing it from the root.
4
4
  It simply introduces a generic function that performs the "local" query by accessing it from the nearest root ;)
5
5
 
6
- ## Update
6
+ h2. Update June 24, 2011
7
7
 
8
- In the latest release (0.3.0) the #assimilate method has been removed in order to work with Mongoid 2.0.0.rc1
8
+ In the latest release (0.3.1) the gem has been tested to work with Mongoid 2.0.2 (run the specs!)
9
9
 
10
- ## Installation ##
10
+ h2. Install
11
11
 
12
- <code>gem install mongoid_embedded_helper</code>
12
+ In Gemfile:
13
13
 
14
- ## Usage ##
14
+ @gem 'mongoid_embedded_helper'@
15
+
16
+ Run bundler
17
+
18
+ @$ bundle@
19
+
20
+ h2. Usage
15
21
 
16
22
  Mongoid doesn't allow you to perform direct queries on an embedded collection. You have to access the embedded collection from the root in order to do this.
17
23
  To overcome this limitation, use the EmbeddedHelper module to add a method <code>query_class</code> which will find the closest non-embedded node in the hierarchy and
18
24
  then traverse down the path back to the object, so that you can perform the query on the embedded collection.
19
25
 
20
- <pre>
21
- require 'mongoid_embedded_helper'
26
+ <pre>require 'mongoid_embedded_helper'
22
27
 
23
28
  class Item
24
29
  include Mongoid::Document
@@ -35,11 +40,13 @@ item.query_class.where(:number.gt => 1).to_a
35
40
 
36
41
  </pre>
37
42
 
38
- ## Adjust!
43
+ h2. Adjust!
39
44
 
40
45
  An as added bonus, an extra adjust! method has been added to Document, Criteria and Array. This enables multi-mutation of attributes!
46
+ This functionality comes along from the _mongoid_adjust_ gem.
47
+
48
+ Here an example using a number
41
49
 
42
- *Here an example using a number*
43
50
  <pre>
44
51
  it "should times all positions (greater than 1) by 2" do
45
52
  result = @person.lists[0].items.where(:pos.gt => 1).adjust!(:pos => lambda {|e| e * 2})
@@ -49,7 +56,8 @@ end
49
56
 
50
57
  Passing a number is a convenience shortcut for adding a number instead of having to use the Proc approach as shown below.
51
58
 
52
- *Here an example using a lambda (or Proc):*
59
+ Here an example using a lambda (or Proc):
60
+
53
61
  <pre>
54
62
  it "should times all positions (greater than 1) by 2" do
55
63
  result = @person.lists[0].items.where(:pos.gt => 1).adjust!(:pos => lambda {|e| e * 2})
@@ -59,7 +67,8 @@ end
59
67
 
60
68
  The Proc approach can in simple cases be declared using a shortcut Symbol/String approach
61
69
 
62
- *Here an example using a symbol :upcase to declare that the method #upcase should be used as the mutator:*
70
+ Here an example using a symbol :upcase to declare that the method #upcase should be used as the mutator:
71
+
63
72
  <pre>
64
73
  it "should upcase the name - using symbol arg" do
65
74
  result = @person.adjust!(:name => :upcase)
@@ -67,7 +76,8 @@ The Proc approach can in simple cases be declared using a shortcut Symbol/String
67
76
  end
68
77
  </pre>
69
78
 
70
- *And using a String 'upcase' instead of a symbol:*
79
+ And using a String 'upcase' instead of a symbol:
80
+
71
81
  <pre>
72
82
  it "should upcase the name - using symbol arg" do
73
83
  result = @person.adjust!(:name => 'upcase')
@@ -75,7 +85,6 @@ The Proc approach can in simple cases be declared using a shortcut Symbol/String
75
85
  end
76
86
  </pre>
77
87
 
88
+ h2. Copyright
78
89
 
79
- ## Copyright ##
80
-
81
- Copyright (c) <2010> <Kristian Mandrup>
90
+ Copyright (c) 2010 Kristian Mandrup
data/Rakefile CHANGED
@@ -10,48 +10,13 @@ begin
10
10
  gem.email = "kmandrup@gmail.com"
11
11
  gem.homepage = "http://github.com/kristianmandrup/mongoid_embedded_helper"
12
12
  gem.authors = ["Kristian Mandrup"]
13
- gem.add_dependency "mongoid", ">= 2.0.0.beta.18"
14
- gem.add_dependency "mongoid_adjust", ">= 0.1.1"
15
- gem.add_dependency "bson_ext", ">= 1.0.8"
13
+ gem.add_dependency "mongoid", ">= 2.0.0.rc.7"
14
+ gem.add_dependency "mongoid_adjust", ">= 0.1.1"
15
+ gem.add_dependency "bson_ext", ">= 1.0.8"
16
16
 
17
- gem.add_development_dependency "rspec", ">=2.0.1"
17
+ gem.add_development_dependency "rspec", ">= 2.4.0"
18
18
  end
19
19
  Jeweler::GemcutterTasks.new
20
20
  rescue LoadError
21
21
  puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
22
22
  end
23
- #
24
- # require 'rake/testtask'
25
- # Rake::TestTask.new(:test) do |test|
26
- # test.libs << 'lib' << 'test'
27
- # test.pattern = 'test/**/test_*.rb'
28
- # test.verbose = true
29
- # end
30
- #
31
- # begin
32
- # require 'rcov/rcovtask'
33
- # Rcov::RcovTask.new do |test|
34
- # test.libs << 'test'
35
- # test.pattern = 'test/**/test_*.rb'
36
- # test.verbose = true
37
- # end
38
- # rescue LoadError
39
- # task :rcov do
40
- # abort "RCov is not available. In order to run rcov, you must: sudo gem install spicycode-rcov"
41
- # end
42
- # end
43
- #
44
- # task :test => :check_dependencies
45
- #
46
- # task :default => :test
47
- #
48
- # require 'rake/rdoctask'
49
- # Rake::RDocTask.new do |rdoc|
50
- # version = File.exist?('VERSION') ? File.read('VERSION') : ""
51
- #
52
- # rdoc.rdoc_dir = 'rdoc'
53
- # rdoc.title = "mongoid_acts_as_tree #{version}"
54
- # rdoc.rdoc_files.include('README*')
55
- # rdoc.rdoc_files.include('lib/**/*.rb')
56
- # end
57
- #
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.3.0
1
+ 0.3.1
@@ -3,15 +3,13 @@ require 'mongoid'
3
3
  module Mongoid
4
4
  module EmbeddedHelper
5
5
  def self.included(model)
6
- model.class_eval do
7
-
6
+ model.class_eval do
8
7
  alias_method :old_parentize, :parentize
9
- def parentize(object, association_name)
10
- old_parentize object, association_name
8
+ def parentize(document)
9
+ old_parentize document
11
10
  send(:after_parentize) if respond_to?(:after_parentize)
12
11
  # run_callbacks(:after_parentize)
13
- end
14
-
12
+ end
15
13
  end
16
14
  end
17
15
 
@@ -5,20 +5,21 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{mongoid_embedded_helper}
8
- s.version = "0.3.0"
8
+ s.version = "0.3.1"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
- s.authors = ["Kristian Mandrup"]
12
- s.date = %q{2011-01-10}
11
+ s.authors = [%q{Kristian Mandrup}]
12
+ s.date = %q{2011-06-24}
13
13
  s.description = %q{Facilitates performing queries on collections in embedded Mongoid documents by performing query from the root node}
14
14
  s.email = %q{kmandrup@gmail.com}
15
15
  s.extra_rdoc_files = [
16
- "README.markdown"
16
+ "README.textile"
17
17
  ]
18
18
  s.files = [
19
+ ".rspec",
19
20
  "Gemfile",
20
21
  "MITLICENSE",
21
- "README.markdown",
22
+ "README.textile",
22
23
  "Rakefile",
23
24
  "VERSION",
24
25
  "autotest/discover.rb",
@@ -33,46 +34,38 @@ Gem::Specification.new do |s|
33
34
  "spec/spec_helper.rb"
34
35
  ]
35
36
  s.homepage = %q{http://github.com/kristianmandrup/mongoid_embedded_helper}
36
- s.require_paths = ["lib"]
37
- s.rubygems_version = %q{1.3.7}
37
+ s.require_paths = [%q{lib}]
38
+ s.rubygems_version = %q{1.8.5}
38
39
  s.summary = %q{Facilitates performing queries on collections in embedded Mongoid documents}
39
- s.test_files = [
40
- "spec/model/list.rb",
41
- "spec/model/person_list.rb",
42
- "spec/mongoid/embedded_helper_spec.rb",
43
- "spec/mongoid/more_embedded_helper_spec.rb",
44
- "spec/spec_helper.rb"
45
- ]
46
40
 
47
41
  if s.respond_to? :specification_version then
48
- current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
49
42
  s.specification_version = 3
50
43
 
51
44
  if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
52
- s.add_runtime_dependency(%q<mongoid>, [">= 2.0.0.beta.14"])
45
+ s.add_runtime_dependency(%q<mongoid>, [">= 2.0.2"])
53
46
  s.add_runtime_dependency(%q<mongoid_adjust>, [">= 0.1.1"])
54
47
  s.add_runtime_dependency(%q<bson_ext>, [">= 1.0.1"])
55
- s.add_runtime_dependency(%q<mongoid>, [">= 2.0.0.beta.18"])
48
+ s.add_runtime_dependency(%q<mongoid>, [">= 2.0.0.rc.7"])
56
49
  s.add_runtime_dependency(%q<mongoid_adjust>, [">= 0.1.1"])
57
50
  s.add_runtime_dependency(%q<bson_ext>, [">= 1.0.8"])
58
- s.add_development_dependency(%q<rspec>, [">= 2.0.1"])
51
+ s.add_development_dependency(%q<rspec>, [">= 2.4.0"])
59
52
  else
60
- s.add_dependency(%q<mongoid>, [">= 2.0.0.beta.14"])
53
+ s.add_dependency(%q<mongoid>, [">= 2.0.2"])
61
54
  s.add_dependency(%q<mongoid_adjust>, [">= 0.1.1"])
62
55
  s.add_dependency(%q<bson_ext>, [">= 1.0.1"])
63
- s.add_dependency(%q<mongoid>, [">= 2.0.0.beta.18"])
56
+ s.add_dependency(%q<mongoid>, [">= 2.0.0.rc.7"])
64
57
  s.add_dependency(%q<mongoid_adjust>, [">= 0.1.1"])
65
58
  s.add_dependency(%q<bson_ext>, [">= 1.0.8"])
66
- s.add_dependency(%q<rspec>, [">= 2.0.1"])
59
+ s.add_dependency(%q<rspec>, [">= 2.4.0"])
67
60
  end
68
61
  else
69
- s.add_dependency(%q<mongoid>, [">= 2.0.0.beta.14"])
62
+ s.add_dependency(%q<mongoid>, [">= 2.0.2"])
70
63
  s.add_dependency(%q<mongoid_adjust>, [">= 0.1.1"])
71
64
  s.add_dependency(%q<bson_ext>, [">= 1.0.1"])
72
- s.add_dependency(%q<mongoid>, [">= 2.0.0.beta.18"])
65
+ s.add_dependency(%q<mongoid>, [">= 2.0.0.rc.7"])
73
66
  s.add_dependency(%q<mongoid_adjust>, [">= 0.1.1"])
74
67
  s.add_dependency(%q<bson_ext>, [">= 1.0.8"])
75
- s.add_dependency(%q<rspec>, [">= 2.0.1"])
68
+ s.add_dependency(%q<rspec>, [">= 2.4.0"])
76
69
  end
77
70
  end
78
71
 
metadata CHANGED
@@ -1,143 +1,105 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: mongoid_embedded_helper
3
- version: !ruby/object:Gem::Version
4
- prerelease: false
5
- segments:
6
- - 0
7
- - 3
8
- - 0
9
- version: 0.3.0
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.3.1
5
+ prerelease:
10
6
  platform: ruby
11
- authors:
7
+ authors:
12
8
  - Kristian Mandrup
13
9
  autorequire:
14
10
  bindir: bin
15
11
  cert_chain: []
16
-
17
- date: 2011-01-10 00:00:00 +01:00
18
- default_executable:
19
- dependencies:
20
- - !ruby/object:Gem::Dependency
12
+ date: 2011-06-24 00:00:00.000000000Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
21
15
  name: mongoid
22
- requirement: &id001 !ruby/object:Gem::Requirement
16
+ requirement: &2157044020 !ruby/object:Gem::Requirement
23
17
  none: false
24
- requirements:
25
- - - ">="
26
- - !ruby/object:Gem::Version
27
- segments:
28
- - 2
29
- - 0
30
- - 0
31
- - beta
32
- - 14
33
- version: 2.0.0.beta.14
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: 2.0.2
34
22
  type: :runtime
35
23
  prerelease: false
36
- version_requirements: *id001
37
- - !ruby/object:Gem::Dependency
24
+ version_requirements: *2157044020
25
+ - !ruby/object:Gem::Dependency
38
26
  name: mongoid_adjust
39
- requirement: &id002 !ruby/object:Gem::Requirement
27
+ requirement: &2157043260 !ruby/object:Gem::Requirement
40
28
  none: false
41
- requirements:
42
- - - ">="
43
- - !ruby/object:Gem::Version
44
- segments:
45
- - 0
46
- - 1
47
- - 1
29
+ requirements:
30
+ - - ! '>='
31
+ - !ruby/object:Gem::Version
48
32
  version: 0.1.1
49
33
  type: :runtime
50
34
  prerelease: false
51
- version_requirements: *id002
52
- - !ruby/object:Gem::Dependency
35
+ version_requirements: *2157043260
36
+ - !ruby/object:Gem::Dependency
53
37
  name: bson_ext
54
- requirement: &id003 !ruby/object:Gem::Requirement
38
+ requirement: &2157042400 !ruby/object:Gem::Requirement
55
39
  none: false
56
- requirements:
57
- - - ">="
58
- - !ruby/object:Gem::Version
59
- segments:
60
- - 1
61
- - 0
62
- - 1
40
+ requirements:
41
+ - - ! '>='
42
+ - !ruby/object:Gem::Version
63
43
  version: 1.0.1
64
44
  type: :runtime
65
45
  prerelease: false
66
- version_requirements: *id003
67
- - !ruby/object:Gem::Dependency
46
+ version_requirements: *2157042400
47
+ - !ruby/object:Gem::Dependency
68
48
  name: mongoid
69
- requirement: &id004 !ruby/object:Gem::Requirement
49
+ requirement: &2157041640 !ruby/object:Gem::Requirement
70
50
  none: false
71
- requirements:
72
- - - ">="
73
- - !ruby/object:Gem::Version
74
- segments:
75
- - 2
76
- - 0
77
- - 0
78
- - beta
79
- - 18
80
- version: 2.0.0.beta.18
51
+ requirements:
52
+ - - ! '>='
53
+ - !ruby/object:Gem::Version
54
+ version: 2.0.0.rc.7
81
55
  type: :runtime
82
56
  prerelease: false
83
- version_requirements: *id004
84
- - !ruby/object:Gem::Dependency
57
+ version_requirements: *2157041640
58
+ - !ruby/object:Gem::Dependency
85
59
  name: mongoid_adjust
86
- requirement: &id005 !ruby/object:Gem::Requirement
60
+ requirement: &2157040800 !ruby/object:Gem::Requirement
87
61
  none: false
88
- requirements:
89
- - - ">="
90
- - !ruby/object:Gem::Version
91
- segments:
92
- - 0
93
- - 1
94
- - 1
62
+ requirements:
63
+ - - ! '>='
64
+ - !ruby/object:Gem::Version
95
65
  version: 0.1.1
96
66
  type: :runtime
97
67
  prerelease: false
98
- version_requirements: *id005
99
- - !ruby/object:Gem::Dependency
68
+ version_requirements: *2157040800
69
+ - !ruby/object:Gem::Dependency
100
70
  name: bson_ext
101
- requirement: &id006 !ruby/object:Gem::Requirement
71
+ requirement: &2157040140 !ruby/object:Gem::Requirement
102
72
  none: false
103
- requirements:
104
- - - ">="
105
- - !ruby/object:Gem::Version
106
- segments:
107
- - 1
108
- - 0
109
- - 8
73
+ requirements:
74
+ - - ! '>='
75
+ - !ruby/object:Gem::Version
110
76
  version: 1.0.8
111
77
  type: :runtime
112
78
  prerelease: false
113
- version_requirements: *id006
114
- - !ruby/object:Gem::Dependency
79
+ version_requirements: *2157040140
80
+ - !ruby/object:Gem::Dependency
115
81
  name: rspec
116
- requirement: &id007 !ruby/object:Gem::Requirement
82
+ requirement: &2157039260 !ruby/object:Gem::Requirement
117
83
  none: false
118
- requirements:
119
- - - ">="
120
- - !ruby/object:Gem::Version
121
- segments:
122
- - 2
123
- - 0
124
- - 1
125
- version: 2.0.1
84
+ requirements:
85
+ - - ! '>='
86
+ - !ruby/object:Gem::Version
87
+ version: 2.4.0
126
88
  type: :development
127
89
  prerelease: false
128
- version_requirements: *id007
129
- description: Facilitates performing queries on collections in embedded Mongoid documents by performing query from the root node
90
+ version_requirements: *2157039260
91
+ description: Facilitates performing queries on collections in embedded Mongoid documents
92
+ by performing query from the root node
130
93
  email: kmandrup@gmail.com
131
94
  executables: []
132
-
133
95
  extensions: []
134
-
135
- extra_rdoc_files:
136
- - README.markdown
137
- files:
96
+ extra_rdoc_files:
97
+ - README.textile
98
+ files:
99
+ - .rspec
138
100
  - Gemfile
139
101
  - MITLICENSE
140
- - README.markdown
102
+ - README.textile
141
103
  - Rakefile
142
104
  - VERSION
143
105
  - autotest/discover.rb
@@ -150,41 +112,28 @@ files:
150
112
  - spec/mongoid/embedded_helper_spec.rb
151
113
  - spec/mongoid/more_embedded_helper_spec.rb
152
114
  - spec/spec_helper.rb
153
- has_rdoc: true
154
115
  homepage: http://github.com/kristianmandrup/mongoid_embedded_helper
155
116
  licenses: []
156
-
157
117
  post_install_message:
158
118
  rdoc_options: []
159
-
160
- require_paths:
119
+ require_paths:
161
120
  - lib
162
- required_ruby_version: !ruby/object:Gem::Requirement
121
+ required_ruby_version: !ruby/object:Gem::Requirement
163
122
  none: false
164
- requirements:
165
- - - ">="
166
- - !ruby/object:Gem::Version
167
- segments:
168
- - 0
169
- version: "0"
170
- required_rubygems_version: !ruby/object:Gem::Requirement
123
+ requirements:
124
+ - - ! '>='
125
+ - !ruby/object:Gem::Version
126
+ version: '0'
127
+ required_rubygems_version: !ruby/object:Gem::Requirement
171
128
  none: false
172
- requirements:
173
- - - ">="
174
- - !ruby/object:Gem::Version
175
- segments:
176
- - 0
177
- version: "0"
129
+ requirements:
130
+ - - ! '>='
131
+ - !ruby/object:Gem::Version
132
+ version: '0'
178
133
  requirements: []
179
-
180
134
  rubyforge_project:
181
- rubygems_version: 1.3.7
135
+ rubygems_version: 1.8.5
182
136
  signing_key:
183
137
  specification_version: 3
184
138
  summary: Facilitates performing queries on collections in embedded Mongoid documents
185
- test_files:
186
- - spec/model/list.rb
187
- - spec/model/person_list.rb
188
- - spec/mongoid/embedded_helper_spec.rb
189
- - spec/mongoid/more_embedded_helper_spec.rb
190
- - spec/spec_helper.rb
139
+ test_files: []