couchrest_model 1.0.0.beta7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (69) hide show
  1. data/LICENSE +176 -0
  2. data/README.md +320 -0
  3. data/Rakefile +71 -0
  4. data/THANKS.md +19 -0
  5. data/examples/model/example.rb +144 -0
  6. data/history.txt +180 -0
  7. data/lib/couchrest/model.rb +10 -0
  8. data/lib/couchrest/model/associations.rb +207 -0
  9. data/lib/couchrest/model/attribute_protection.rb +74 -0
  10. data/lib/couchrest/model/attributes.rb +75 -0
  11. data/lib/couchrest/model/base.rb +111 -0
  12. data/lib/couchrest/model/callbacks.rb +27 -0
  13. data/lib/couchrest/model/casted_array.rb +39 -0
  14. data/lib/couchrest/model/casted_model.rb +68 -0
  15. data/lib/couchrest/model/class_proxy.rb +122 -0
  16. data/lib/couchrest/model/collection.rb +260 -0
  17. data/lib/couchrest/model/design_doc.rb +126 -0
  18. data/lib/couchrest/model/document_queries.rb +82 -0
  19. data/lib/couchrest/model/errors.rb +23 -0
  20. data/lib/couchrest/model/extended_attachments.rb +73 -0
  21. data/lib/couchrest/model/persistence.rb +141 -0
  22. data/lib/couchrest/model/properties.rb +144 -0
  23. data/lib/couchrest/model/property.rb +96 -0
  24. data/lib/couchrest/model/support/couchrest.rb +19 -0
  25. data/lib/couchrest/model/support/hash.rb +9 -0
  26. data/lib/couchrest/model/typecast.rb +170 -0
  27. data/lib/couchrest/model/validations.rb +68 -0
  28. data/lib/couchrest/model/validations/casted_model.rb +14 -0
  29. data/lib/couchrest/model/validations/locale/en.yml +5 -0
  30. data/lib/couchrest/model/validations/uniqueness.rb +45 -0
  31. data/lib/couchrest/model/views.rb +167 -0
  32. data/lib/couchrest_model.rb +56 -0
  33. data/spec/couchrest/assocations_spec.rb +213 -0
  34. data/spec/couchrest/attachment_spec.rb +148 -0
  35. data/spec/couchrest/attribute_protection_spec.rb +153 -0
  36. data/spec/couchrest/base_spec.rb +463 -0
  37. data/spec/couchrest/casted_model_spec.rb +424 -0
  38. data/spec/couchrest/casted_spec.rb +75 -0
  39. data/spec/couchrest/class_proxy_spec.rb +132 -0
  40. data/spec/couchrest/inherited_spec.rb +40 -0
  41. data/spec/couchrest/persistence_spec.rb +409 -0
  42. data/spec/couchrest/property_spec.rb +804 -0
  43. data/spec/couchrest/subclass_spec.rb +99 -0
  44. data/spec/couchrest/validations.rb +73 -0
  45. data/spec/couchrest/view_spec.rb +463 -0
  46. data/spec/fixtures/attachments/README +3 -0
  47. data/spec/fixtures/attachments/couchdb.png +0 -0
  48. data/spec/fixtures/attachments/test.html +11 -0
  49. data/spec/fixtures/base.rb +139 -0
  50. data/spec/fixtures/more/article.rb +35 -0
  51. data/spec/fixtures/more/card.rb +17 -0
  52. data/spec/fixtures/more/cat.rb +19 -0
  53. data/spec/fixtures/more/course.rb +25 -0
  54. data/spec/fixtures/more/event.rb +8 -0
  55. data/spec/fixtures/more/invoice.rb +14 -0
  56. data/spec/fixtures/more/person.rb +9 -0
  57. data/spec/fixtures/more/question.rb +7 -0
  58. data/spec/fixtures/more/service.rb +10 -0
  59. data/spec/fixtures/more/user.rb +22 -0
  60. data/spec/fixtures/views/lib.js +3 -0
  61. data/spec/fixtures/views/test_view/lib.js +3 -0
  62. data/spec/fixtures/views/test_view/only-map.js +4 -0
  63. data/spec/fixtures/views/test_view/test-map.js +3 -0
  64. data/spec/fixtures/views/test_view/test-reduce.js +3 -0
  65. data/spec/spec.opts +5 -0
  66. data/spec/spec_helper.rb +48 -0
  67. data/utils/remap.rb +27 -0
  68. data/utils/subset.rb +30 -0
  69. metadata +232 -0
data/utils/subset.rb ADDED
@@ -0,0 +1,30 @@
1
+ require 'rubygems'
2
+ require 'couchrest'
3
+
4
+ # subset.rb replicates a percentage of a database to a fresh database.
5
+ # use it to create a smaller dataset on which to prototype views.
6
+
7
+ # specify the source database
8
+ source = CouchRest.new("http://127.0.0.1:5984").database('source-db')
9
+
10
+ # specify the target database
11
+ target = CouchRest.new("http://127.0.0.1:5984").database('target-db')
12
+
13
+ # pager efficiently yields all view rows
14
+ pager = CouchRest::Pager.new(source)
15
+
16
+ pager.all_docs(1000) do |rows|
17
+ docs = rows.collect do |r|
18
+ # the percentage of docs to clone
19
+ next if rand > 0.1
20
+ doc = source.get(r['id'])
21
+ doc.delete('_rev')
22
+ doc
23
+ end.compact
24
+ puts docs.length
25
+ next if docs.empty?
26
+
27
+ puts docs.first['_id']
28
+ target.bulk_save(docs)
29
+ end
30
+
metadata ADDED
@@ -0,0 +1,232 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: couchrest_model
3
+ version: !ruby/object:Gem::Version
4
+ hash: -1848230057
5
+ prerelease: true
6
+ segments:
7
+ - 1
8
+ - 0
9
+ - 0
10
+ - beta7
11
+ version: 1.0.0.beta7
12
+ platform: ruby
13
+ authors:
14
+ - J. Chris Anderson
15
+ - Matt Aimonetti
16
+ - Marcos Tapajos
17
+ - Will Leinweber
18
+ - Sam Lown
19
+ autorequire:
20
+ bindir: bin
21
+ cert_chain: []
22
+
23
+ date: 2010-06-21 00:00:00 -03:00
24
+ default_executable:
25
+ dependencies:
26
+ - !ruby/object:Gem::Dependency
27
+ name: couchrest
28
+ prerelease: false
29
+ requirement: &id001 !ruby/object:Gem::Requirement
30
+ none: false
31
+ requirements:
32
+ - - ">="
33
+ - !ruby/object:Gem::Version
34
+ hash: 31098193
35
+ segments:
36
+ - 1
37
+ - 0
38
+ - 0
39
+ - beta
40
+ version: 1.0.0.beta
41
+ type: :runtime
42
+ version_requirements: *id001
43
+ - !ruby/object:Gem::Dependency
44
+ name: mime-types
45
+ prerelease: false
46
+ requirement: &id002 !ruby/object:Gem::Requirement
47
+ none: false
48
+ requirements:
49
+ - - ">="
50
+ - !ruby/object:Gem::Version
51
+ hash: 17
52
+ segments:
53
+ - 1
54
+ - 15
55
+ version: "1.15"
56
+ type: :runtime
57
+ version_requirements: *id002
58
+ - !ruby/object:Gem::Dependency
59
+ name: activesupport
60
+ prerelease: false
61
+ requirement: &id003 !ruby/object:Gem::Requirement
62
+ none: false
63
+ requirements:
64
+ - - ">="
65
+ - !ruby/object:Gem::Version
66
+ hash: 9
67
+ segments:
68
+ - 2
69
+ - 3
70
+ - 5
71
+ version: 2.3.5
72
+ type: :runtime
73
+ version_requirements: *id003
74
+ - !ruby/object:Gem::Dependency
75
+ name: activemodel
76
+ prerelease: false
77
+ requirement: &id004 !ruby/object:Gem::Requirement
78
+ none: false
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ hash: -1848230024
83
+ segments:
84
+ - 3
85
+ - 0
86
+ - 0
87
+ - beta4
88
+ version: 3.0.0.beta4
89
+ type: :runtime
90
+ version_requirements: *id004
91
+ description: CouchRest Model provides aditional features to the standard CouchRest Document class such as properties, view designs, associations, callbacks, typecasting and validations.
92
+ email: jchris@apache.org
93
+ executables: []
94
+
95
+ extensions: []
96
+
97
+ extra_rdoc_files:
98
+ - LICENSE
99
+ - README.md
100
+ - THANKS.md
101
+ files:
102
+ - LICENSE
103
+ - README.md
104
+ - Rakefile
105
+ - THANKS.md
106
+ - examples/model/example.rb
107
+ - history.txt
108
+ - lib/couchrest/model.rb
109
+ - lib/couchrest/model/associations.rb
110
+ - lib/couchrest/model/attribute_protection.rb
111
+ - lib/couchrest/model/attributes.rb
112
+ - lib/couchrest/model/base.rb
113
+ - lib/couchrest/model/callbacks.rb
114
+ - lib/couchrest/model/casted_array.rb
115
+ - lib/couchrest/model/casted_model.rb
116
+ - lib/couchrest/model/class_proxy.rb
117
+ - lib/couchrest/model/collection.rb
118
+ - lib/couchrest/model/design_doc.rb
119
+ - lib/couchrest/model/document_queries.rb
120
+ - lib/couchrest/model/errors.rb
121
+ - lib/couchrest/model/extended_attachments.rb
122
+ - lib/couchrest/model/persistence.rb
123
+ - lib/couchrest/model/properties.rb
124
+ - lib/couchrest/model/property.rb
125
+ - lib/couchrest/model/support/couchrest.rb
126
+ - lib/couchrest/model/support/hash.rb
127
+ - lib/couchrest/model/typecast.rb
128
+ - lib/couchrest/model/validations.rb
129
+ - lib/couchrest/model/validations/casted_model.rb
130
+ - lib/couchrest/model/validations/locale/en.yml
131
+ - lib/couchrest/model/validations/uniqueness.rb
132
+ - lib/couchrest/model/views.rb
133
+ - lib/couchrest_model.rb
134
+ - spec/couchrest/assocations_spec.rb
135
+ - spec/couchrest/attachment_spec.rb
136
+ - spec/couchrest/attribute_protection_spec.rb
137
+ - spec/couchrest/base_spec.rb
138
+ - spec/couchrest/casted_model_spec.rb
139
+ - spec/couchrest/casted_spec.rb
140
+ - spec/couchrest/class_proxy_spec.rb
141
+ - spec/couchrest/inherited_spec.rb
142
+ - spec/couchrest/persistence_spec.rb
143
+ - spec/couchrest/property_spec.rb
144
+ - spec/couchrest/subclass_spec.rb
145
+ - spec/couchrest/validations.rb
146
+ - spec/couchrest/view_spec.rb
147
+ - spec/fixtures/attachments/README
148
+ - spec/fixtures/attachments/couchdb.png
149
+ - spec/fixtures/attachments/test.html
150
+ - spec/fixtures/base.rb
151
+ - spec/fixtures/more/article.rb
152
+ - spec/fixtures/more/card.rb
153
+ - spec/fixtures/more/cat.rb
154
+ - spec/fixtures/more/course.rb
155
+ - spec/fixtures/more/event.rb
156
+ - spec/fixtures/more/invoice.rb
157
+ - spec/fixtures/more/person.rb
158
+ - spec/fixtures/more/question.rb
159
+ - spec/fixtures/more/service.rb
160
+ - spec/fixtures/more/user.rb
161
+ - spec/fixtures/views/lib.js
162
+ - spec/fixtures/views/test_view/lib.js
163
+ - spec/fixtures/views/test_view/only-map.js
164
+ - spec/fixtures/views/test_view/test-map.js
165
+ - spec/fixtures/views/test_view/test-reduce.js
166
+ - spec/spec.opts
167
+ - spec/spec_helper.rb
168
+ - utils/remap.rb
169
+ - utils/subset.rb
170
+ has_rdoc: true
171
+ homepage: http://github.com/couchrest/couchrest_model
172
+ licenses: []
173
+
174
+ post_install_message:
175
+ rdoc_options:
176
+ - --charset=UTF-8
177
+ require_paths:
178
+ - lib
179
+ required_ruby_version: !ruby/object:Gem::Requirement
180
+ none: false
181
+ requirements:
182
+ - - ">="
183
+ - !ruby/object:Gem::Version
184
+ hash: 3
185
+ segments:
186
+ - 0
187
+ version: "0"
188
+ required_rubygems_version: !ruby/object:Gem::Requirement
189
+ none: false
190
+ requirements:
191
+ - - ">"
192
+ - !ruby/object:Gem::Version
193
+ hash: 25
194
+ segments:
195
+ - 1
196
+ - 3
197
+ - 1
198
+ version: 1.3.1
199
+ requirements: []
200
+
201
+ rubyforge_project:
202
+ rubygems_version: 1.3.7
203
+ signing_key:
204
+ specification_version: 3
205
+ summary: Extends the CouchRest Document for advanced modelling.
206
+ test_files:
207
+ - spec/couchrest/assocations_spec.rb
208
+ - spec/couchrest/attachment_spec.rb
209
+ - spec/couchrest/attribute_protection_spec.rb
210
+ - spec/couchrest/base_spec.rb
211
+ - spec/couchrest/casted_model_spec.rb
212
+ - spec/couchrest/casted_spec.rb
213
+ - spec/couchrest/class_proxy_spec.rb
214
+ - spec/couchrest/inherited_spec.rb
215
+ - spec/couchrest/persistence_spec.rb
216
+ - spec/couchrest/property_spec.rb
217
+ - spec/couchrest/subclass_spec.rb
218
+ - spec/couchrest/validations.rb
219
+ - spec/couchrest/view_spec.rb
220
+ - spec/fixtures/base.rb
221
+ - spec/fixtures/more/article.rb
222
+ - spec/fixtures/more/card.rb
223
+ - spec/fixtures/more/cat.rb
224
+ - spec/fixtures/more/course.rb
225
+ - spec/fixtures/more/event.rb
226
+ - spec/fixtures/more/invoice.rb
227
+ - spec/fixtures/more/person.rb
228
+ - spec/fixtures/more/question.rb
229
+ - spec/fixtures/more/service.rb
230
+ - spec/fixtures/more/user.rb
231
+ - spec/spec_helper.rb
232
+ - examples/model/example.rb