mongoid-casino 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (53) hide show
  1. data/.gitignore +20 -0
  2. data/.ruby-gemset +1 -0
  3. data/.ruby-version +1 -0
  4. data/Gemfile +4 -0
  5. data/LICENSE.txt +22 -0
  6. data/README.md +93 -0
  7. data/Rakefile +9 -0
  8. data/casino.gemspec +30 -0
  9. data/lib/casino.rb +13 -0
  10. data/lib/casino/collection.rb +195 -0
  11. data/lib/casino/dimension.rb +11 -0
  12. data/lib/casino/focus.rb +26 -0
  13. data/lib/casino/intersection.rb +30 -0
  14. data/lib/casino/intersection/match/all.rb +29 -0
  15. data/lib/casino/intersection/match/base.rb +49 -0
  16. data/lib/casino/intersection/match/equivalence.rb +25 -0
  17. data/lib/casino/intersection/match/expression.rb +15 -0
  18. data/lib/casino/intersection/match/greater.rb +43 -0
  19. data/lib/casino/intersection/match/include.rb +15 -0
  20. data/lib/casino/intersection/match/lesser.rb +31 -0
  21. data/lib/casino/intersection/match/recurse.rb +19 -0
  22. data/lib/casino/lobby.rb +21 -0
  23. data/lib/casino/projection.rb +76 -0
  24. data/lib/casino/query.rb +23 -0
  25. data/lib/casino/question.rb +9 -0
  26. data/lib/casino/store.rb +49 -0
  27. data/lib/casino/version.rb +3 -0
  28. data/spec/fabricators/model_fabricator.rb +12 -0
  29. data/spec/fabricators/note_fabricator.rb +3 -0
  30. data/spec/fixtures/collections/collection.rb +3 -0
  31. data/spec/fixtures/collections/emails_by_day.rb +28 -0
  32. data/spec/fixtures/models/model.rb +8 -0
  33. data/spec/fixtures/models/note.rb +7 -0
  34. data/spec/lib/casino/collection_spec.rb +146 -0
  35. data/spec/lib/casino/dimension_spec.rb +27 -0
  36. data/spec/lib/casino/focus_spec.rb +53 -0
  37. data/spec/lib/casino/intersection/match/all_spec.rb +24 -0
  38. data/spec/lib/casino/intersection/match/base_spec.rb +159 -0
  39. data/spec/lib/casino/intersection/match/equivalence_spec.rb +26 -0
  40. data/spec/lib/casino/intersection/match/expression_spec.rb +26 -0
  41. data/spec/lib/casino/intersection/match/greater_spec.rb +72 -0
  42. data/spec/lib/casino/intersection/match/include_spec.rb +27 -0
  43. data/spec/lib/casino/intersection/match/lesser_spec.rb +74 -0
  44. data/spec/lib/casino/intersection/match/recurse_spec.rb +24 -0
  45. data/spec/lib/casino/intersection_spec.rb +33 -0
  46. data/spec/lib/casino/lobby_spec.rb +20 -0
  47. data/spec/lib/casino/projection_spec.rb +81 -0
  48. data/spec/lib/casino/query_spec.rb +42 -0
  49. data/spec/lib/casino/question_spec.rb +10 -0
  50. data/spec/lib/casino/store_spec.rb +60 -0
  51. data/spec/spec_helper.rb +26 -0
  52. data/spec/support/mongoid.yml +6 -0
  53. metadata +234 -0
@@ -0,0 +1,60 @@
1
+ describe Casino::Store do
2
+
3
+ let(:key) { "collection_name" }
4
+ let(:store) { Casino::Store.new(key) }
5
+
6
+ subject { store }
7
+
8
+ it { subject.must_respond_to :collection_name }
9
+
10
+ it "establishes a connection to the default session" do
11
+ store.collection.database.session.must_equal Mongoid.default_session
12
+ end
13
+
14
+ it "establishes a connection to the correct collection" do
15
+ store.collection.name.must_equal key
16
+ end
17
+
18
+ describe '#criteria' do
19
+ it "provides a criteria interface" do
20
+ store.criteria.must_be_instance_of Mongoid::Criteria
21
+ end
22
+ end
23
+
24
+ describe '#merge' do
25
+
26
+ let(:womens_boots) do
27
+ { '_id' => { 'date' => "mm/dd/yyyy", 'label' => "women's boots" } }
28
+ end
29
+
30
+ let(:mens_boots) do
31
+ { '_id' => { 'date' => "mm/dd/yyyy", 'label' => "men's boots" } }
32
+ end
33
+
34
+ let(:value_hash) do
35
+ { 'value' => { 'signups' => 10850, 'uniques' => 9822 } }
36
+ end
37
+
38
+ let(:document) { womens_boots.merge(value_hash) }
39
+ let(:document_two) { mens_boots.merge(value_hash) }
40
+
41
+ it "adds new documents to the collection" do
42
+ store.merge(document)
43
+ store.first.must_equal document
44
+ end
45
+
46
+ it "updates documents" do
47
+ store.merge(document)
48
+ store.merge(document.merge(value: { signups: 2 }))
49
+ store.first['value']['signups'].must_equal 2
50
+ end
51
+
52
+ it "does not replace the wrong document" do
53
+ store.merge(document)
54
+ store.merge(document_two)
55
+ store.find.count.wont_equal 1
56
+ end
57
+
58
+ end
59
+
60
+ end
@@ -0,0 +1,26 @@
1
+ require 'simplecov'
2
+
3
+ SimpleCov.start do
4
+ add_filter "/spec/"
5
+ end
6
+
7
+ require 'casino'
8
+ require 'minitest/autorun'
9
+ require 'minitest/pride'
10
+ require 'database_cleaner'
11
+ require 'fabrication'
12
+
13
+ Mongoid.load! "./spec/support/mongoid.yml", :test
14
+
15
+
16
+ require './spec/fixtures/models/model'
17
+ require './spec/fixtures/models/note'
18
+ require './spec/fixtures/collections/collection'
19
+ require './spec/fixtures/collections/emails_by_day'
20
+
21
+ DatabaseCleaner[:mongoid].strategy = :truncation
22
+
23
+ class MiniTest::Spec
24
+ before(:each) { DatabaseCleaner.start }
25
+ after(:each) { DatabaseCleaner.clean }
26
+ end
@@ -0,0 +1,6 @@
1
+ test:
2
+ sessions:
3
+ default:
4
+ database: casino_test
5
+ hosts:
6
+ - localhost:27017
metadata ADDED
@@ -0,0 +1,234 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: mongoid-casino
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - JC McCormick
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2013-07-05 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: mongoid
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - '='
20
+ - !ruby/object:Gem::Version
21
+ version: 3.0.19
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - '='
28
+ - !ruby/object:Gem::Version
29
+ version: 3.0.19
30
+ - !ruby/object:Gem::Dependency
31
+ name: database_cleaner
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ~>
36
+ - !ruby/object:Gem::Version
37
+ version: '0.9'
38
+ type: :development
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ~>
44
+ - !ruby/object:Gem::Version
45
+ version: '0.9'
46
+ - !ruby/object:Gem::Dependency
47
+ name: fabrication
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ~>
52
+ - !ruby/object:Gem::Version
53
+ version: '2.6'
54
+ type: :development
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ~>
60
+ - !ruby/object:Gem::Version
61
+ version: '2.6'
62
+ - !ruby/object:Gem::Dependency
63
+ name: json
64
+ requirement: !ruby/object:Gem::Requirement
65
+ none: false
66
+ requirements:
67
+ - - ~>
68
+ - !ruby/object:Gem::Version
69
+ version: '1.7'
70
+ type: :development
71
+ prerelease: false
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ~>
76
+ - !ruby/object:Gem::Version
77
+ version: '1.7'
78
+ - !ruby/object:Gem::Dependency
79
+ name: minitest
80
+ requirement: !ruby/object:Gem::Requirement
81
+ none: false
82
+ requirements:
83
+ - - ~>
84
+ - !ruby/object:Gem::Version
85
+ version: '4.3'
86
+ type: :development
87
+ prerelease: false
88
+ version_requirements: !ruby/object:Gem::Requirement
89
+ none: false
90
+ requirements:
91
+ - - ~>
92
+ - !ruby/object:Gem::Version
93
+ version: '4.3'
94
+ - !ruby/object:Gem::Dependency
95
+ name: rake
96
+ requirement: !ruby/object:Gem::Requirement
97
+ none: false
98
+ requirements:
99
+ - - ~>
100
+ - !ruby/object:Gem::Version
101
+ version: '10.0'
102
+ type: :development
103
+ prerelease: false
104
+ version_requirements: !ruby/object:Gem::Requirement
105
+ none: false
106
+ requirements:
107
+ - - ~>
108
+ - !ruby/object:Gem::Version
109
+ version: '10.0'
110
+ - !ruby/object:Gem::Dependency
111
+ name: simplecov
112
+ requirement: !ruby/object:Gem::Requirement
113
+ none: false
114
+ requirements:
115
+ - - ~>
116
+ - !ruby/object:Gem::Version
117
+ version: '0.7'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ none: false
122
+ requirements:
123
+ - - ~>
124
+ - !ruby/object:Gem::Version
125
+ version: '0.7'
126
+ description: Create and maintain aggregate metadata with Mongoid
127
+ email:
128
+ - esmevane@gmail.com
129
+ executables: []
130
+ extensions: []
131
+ extra_rdoc_files: []
132
+ files:
133
+ - .gitignore
134
+ - .ruby-gemset
135
+ - .ruby-version
136
+ - Gemfile
137
+ - LICENSE.txt
138
+ - README.md
139
+ - Rakefile
140
+ - casino.gemspec
141
+ - lib/casino.rb
142
+ - lib/casino/collection.rb
143
+ - lib/casino/dimension.rb
144
+ - lib/casino/focus.rb
145
+ - lib/casino/intersection.rb
146
+ - lib/casino/intersection/match/all.rb
147
+ - lib/casino/intersection/match/base.rb
148
+ - lib/casino/intersection/match/equivalence.rb
149
+ - lib/casino/intersection/match/expression.rb
150
+ - lib/casino/intersection/match/greater.rb
151
+ - lib/casino/intersection/match/include.rb
152
+ - lib/casino/intersection/match/lesser.rb
153
+ - lib/casino/intersection/match/recurse.rb
154
+ - lib/casino/lobby.rb
155
+ - lib/casino/projection.rb
156
+ - lib/casino/query.rb
157
+ - lib/casino/question.rb
158
+ - lib/casino/store.rb
159
+ - lib/casino/version.rb
160
+ - spec/fabricators/model_fabricator.rb
161
+ - spec/fabricators/note_fabricator.rb
162
+ - spec/fixtures/collections/collection.rb
163
+ - spec/fixtures/collections/emails_by_day.rb
164
+ - spec/fixtures/models/model.rb
165
+ - spec/fixtures/models/note.rb
166
+ - spec/lib/casino/collection_spec.rb
167
+ - spec/lib/casino/dimension_spec.rb
168
+ - spec/lib/casino/focus_spec.rb
169
+ - spec/lib/casino/intersection/match/all_spec.rb
170
+ - spec/lib/casino/intersection/match/base_spec.rb
171
+ - spec/lib/casino/intersection/match/equivalence_spec.rb
172
+ - spec/lib/casino/intersection/match/expression_spec.rb
173
+ - spec/lib/casino/intersection/match/greater_spec.rb
174
+ - spec/lib/casino/intersection/match/include_spec.rb
175
+ - spec/lib/casino/intersection/match/lesser_spec.rb
176
+ - spec/lib/casino/intersection/match/recurse_spec.rb
177
+ - spec/lib/casino/intersection_spec.rb
178
+ - spec/lib/casino/lobby_spec.rb
179
+ - spec/lib/casino/projection_spec.rb
180
+ - spec/lib/casino/query_spec.rb
181
+ - spec/lib/casino/question_spec.rb
182
+ - spec/lib/casino/store_spec.rb
183
+ - spec/spec_helper.rb
184
+ - spec/support/mongoid.yml
185
+ homepage: http://www.github.com/esmevane/casino
186
+ licenses: []
187
+ post_install_message:
188
+ rdoc_options: []
189
+ require_paths:
190
+ - lib
191
+ required_ruby_version: !ruby/object:Gem::Requirement
192
+ none: false
193
+ requirements:
194
+ - - ! '>='
195
+ - !ruby/object:Gem::Version
196
+ version: '0'
197
+ required_rubygems_version: !ruby/object:Gem::Requirement
198
+ none: false
199
+ requirements:
200
+ - - ! '>='
201
+ - !ruby/object:Gem::Version
202
+ version: '0'
203
+ requirements: []
204
+ rubyforge_project:
205
+ rubygems_version: 1.8.25
206
+ signing_key:
207
+ specification_version: 3
208
+ summary: Aggregation handler for Mongoid
209
+ test_files:
210
+ - spec/fabricators/model_fabricator.rb
211
+ - spec/fabricators/note_fabricator.rb
212
+ - spec/fixtures/collections/collection.rb
213
+ - spec/fixtures/collections/emails_by_day.rb
214
+ - spec/fixtures/models/model.rb
215
+ - spec/fixtures/models/note.rb
216
+ - spec/lib/casino/collection_spec.rb
217
+ - spec/lib/casino/dimension_spec.rb
218
+ - spec/lib/casino/focus_spec.rb
219
+ - spec/lib/casino/intersection/match/all_spec.rb
220
+ - spec/lib/casino/intersection/match/base_spec.rb
221
+ - spec/lib/casino/intersection/match/equivalence_spec.rb
222
+ - spec/lib/casino/intersection/match/expression_spec.rb
223
+ - spec/lib/casino/intersection/match/greater_spec.rb
224
+ - spec/lib/casino/intersection/match/include_spec.rb
225
+ - spec/lib/casino/intersection/match/lesser_spec.rb
226
+ - spec/lib/casino/intersection/match/recurse_spec.rb
227
+ - spec/lib/casino/intersection_spec.rb
228
+ - spec/lib/casino/lobby_spec.rb
229
+ - spec/lib/casino/projection_spec.rb
230
+ - spec/lib/casino/query_spec.rb
231
+ - spec/lib/casino/question_spec.rb
232
+ - spec/lib/casino/store_spec.rb
233
+ - spec/spec_helper.rb
234
+ - spec/support/mongoid.yml