peterpunk-couchrest 0.23.1

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.
Files changed (94) hide show
  1. data/LICENSE +176 -0
  2. data/README.md +95 -0
  3. data/Rakefile +75 -0
  4. data/THANKS.md +18 -0
  5. data/examples/model/example.rb +144 -0
  6. data/examples/word_count/markov +38 -0
  7. data/examples/word_count/views/books/chunked-map.js +3 -0
  8. data/examples/word_count/views/books/united-map.js +1 -0
  9. data/examples/word_count/views/markov/chain-map.js +6 -0
  10. data/examples/word_count/views/markov/chain-reduce.js +7 -0
  11. data/examples/word_count/views/word_count/count-map.js +6 -0
  12. data/examples/word_count/views/word_count/count-reduce.js +3 -0
  13. data/examples/word_count/word_count.rb +46 -0
  14. data/examples/word_count/word_count_query.rb +40 -0
  15. data/examples/word_count/word_count_views.rb +26 -0
  16. data/lib/couchrest.rb +198 -0
  17. data/lib/couchrest/commands/generate.rb +71 -0
  18. data/lib/couchrest/commands/push.rb +103 -0
  19. data/lib/couchrest/core/database.rb +303 -0
  20. data/lib/couchrest/core/design.rb +79 -0
  21. data/lib/couchrest/core/document.rb +87 -0
  22. data/lib/couchrest/core/response.rb +20 -0
  23. data/lib/couchrest/core/server.rb +88 -0
  24. data/lib/couchrest/core/view.rb +4 -0
  25. data/lib/couchrest/helper/pager.rb +103 -0
  26. data/lib/couchrest/helper/streamer.rb +44 -0
  27. data/lib/couchrest/helper/upgrade.rb +51 -0
  28. data/lib/couchrest/mixins.rb +4 -0
  29. data/lib/couchrest/mixins/attachments.rb +31 -0
  30. data/lib/couchrest/mixins/callbacks.rb +483 -0
  31. data/lib/couchrest/mixins/class_proxy.rb +108 -0
  32. data/lib/couchrest/mixins/design_doc.rb +90 -0
  33. data/lib/couchrest/mixins/document_queries.rb +44 -0
  34. data/lib/couchrest/mixins/extended_attachments.rb +68 -0
  35. data/lib/couchrest/mixins/extended_document_mixins.rb +7 -0
  36. data/lib/couchrest/mixins/properties.rb +133 -0
  37. data/lib/couchrest/mixins/validation.rb +244 -0
  38. data/lib/couchrest/mixins/views.rb +169 -0
  39. data/lib/couchrest/monkeypatches.rb +113 -0
  40. data/lib/couchrest/more/casted_model.rb +28 -0
  41. data/lib/couchrest/more/extended_document.rb +219 -0
  42. data/lib/couchrest/more/property.rb +40 -0
  43. data/lib/couchrest/support/blank.rb +42 -0
  44. data/lib/couchrest/support/class.rb +176 -0
  45. data/lib/couchrest/validation/auto_validate.rb +163 -0
  46. data/lib/couchrest/validation/contextual_validators.rb +78 -0
  47. data/lib/couchrest/validation/validation_errors.rb +119 -0
  48. data/lib/couchrest/validation/validators/absent_field_validator.rb +74 -0
  49. data/lib/couchrest/validation/validators/confirmation_validator.rb +99 -0
  50. data/lib/couchrest/validation/validators/format_validator.rb +117 -0
  51. data/lib/couchrest/validation/validators/formats/email.rb +66 -0
  52. data/lib/couchrest/validation/validators/formats/url.rb +43 -0
  53. data/lib/couchrest/validation/validators/generic_validator.rb +120 -0
  54. data/lib/couchrest/validation/validators/length_validator.rb +134 -0
  55. data/lib/couchrest/validation/validators/method_validator.rb +89 -0
  56. data/lib/couchrest/validation/validators/numeric_validator.rb +104 -0
  57. data/lib/couchrest/validation/validators/required_field_validator.rb +109 -0
  58. data/lib/couchrest/validation/validators/uniqueness_validator.rb +89 -0
  59. data/spec/couchrest/core/couchrest_spec.rb +201 -0
  60. data/spec/couchrest/core/database_spec.rb +699 -0
  61. data/spec/couchrest/core/design_spec.rb +138 -0
  62. data/spec/couchrest/core/document_spec.rb +267 -0
  63. data/spec/couchrest/core/server_spec.rb +35 -0
  64. data/spec/couchrest/helpers/pager_spec.rb +122 -0
  65. data/spec/couchrest/helpers/streamer_spec.rb +23 -0
  66. data/spec/couchrest/more/casted_extended_doc_spec.rb +40 -0
  67. data/spec/couchrest/more/casted_model_spec.rb +98 -0
  68. data/spec/couchrest/more/extended_doc_attachment_spec.rb +130 -0
  69. data/spec/couchrest/more/extended_doc_spec.rb +531 -0
  70. data/spec/couchrest/more/extended_doc_subclass_spec.rb +98 -0
  71. data/spec/couchrest/more/extended_doc_view_spec.rb +355 -0
  72. data/spec/couchrest/more/property_spec.rb +190 -0
  73. data/spec/fixtures/attachments/README +3 -0
  74. data/spec/fixtures/attachments/couchdb.png +0 -0
  75. data/spec/fixtures/attachments/test.html +11 -0
  76. data/spec/fixtures/more/article.rb +34 -0
  77. data/spec/fixtures/more/card.rb +20 -0
  78. data/spec/fixtures/more/course.rb +14 -0
  79. data/spec/fixtures/more/event.rb +6 -0
  80. data/spec/fixtures/more/invoice.rb +17 -0
  81. data/spec/fixtures/more/location.rb +18 -0
  82. data/spec/fixtures/more/person.rb +8 -0
  83. data/spec/fixtures/more/question.rb +6 -0
  84. data/spec/fixtures/more/service.rb +12 -0
  85. data/spec/fixtures/views/lib.js +3 -0
  86. data/spec/fixtures/views/test_view/lib.js +3 -0
  87. data/spec/fixtures/views/test_view/only-map.js +4 -0
  88. data/spec/fixtures/views/test_view/test-map.js +3 -0
  89. data/spec/fixtures/views/test_view/test-reduce.js +3 -0
  90. data/spec/spec.opts +6 -0
  91. data/spec/spec_helper.rb +26 -0
  92. data/utils/remap.rb +27 -0
  93. data/utils/subset.rb +30 -0
  94. metadata +203 -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,203 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: peterpunk-couchrest
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.23.1
5
+ platform: ruby
6
+ authors:
7
+ - J. Chris Anderson
8
+ - Matt Aimonetti
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+
13
+ date: 2008-11-22 00:00:00 -08:00
14
+ default_executable:
15
+ dependencies:
16
+ - !ruby/object:Gem::Dependency
17
+ name: json
18
+ type: :runtime
19
+ version_requirement:
20
+ version_requirements: !ruby/object:Gem::Requirement
21
+ requirements:
22
+ - - ">="
23
+ - !ruby/object:Gem::Version
24
+ version: 1.1.2
25
+ version:
26
+ - !ruby/object:Gem::Dependency
27
+ name: rest-client
28
+ type: :runtime
29
+ version_requirement:
30
+ version_requirements: !ruby/object:Gem::Requirement
31
+ requirements:
32
+ - - ">="
33
+ - !ruby/object:Gem::Version
34
+ version: "0.5"
35
+ version:
36
+ - !ruby/object:Gem::Dependency
37
+ name: mime-types
38
+ type: :runtime
39
+ version_requirement:
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ requirements:
42
+ - - ">="
43
+ - !ruby/object:Gem::Version
44
+ version: "1.15"
45
+ version:
46
+ description: CouchRest provides a simple interface on top of CouchDB's RESTful HTTP API, as well as including some utility scripts for managing views and attachments.
47
+ email: jchris@apache.org
48
+ executables: []
49
+
50
+ extensions: []
51
+
52
+ extra_rdoc_files:
53
+ - README.md
54
+ - LICENSE
55
+ - THANKS.md
56
+ files:
57
+ - LICENSE
58
+ - README.md
59
+ - Rakefile
60
+ - THANKS.md
61
+ - examples/model
62
+ - examples/model/example.rb
63
+ - examples/word_count
64
+ - examples/word_count/markov
65
+ - examples/word_count/views
66
+ - examples/word_count/views/books
67
+ - examples/word_count/views/books/chunked-map.js
68
+ - examples/word_count/views/books/united-map.js
69
+ - examples/word_count/views/markov
70
+ - examples/word_count/views/markov/chain-map.js
71
+ - examples/word_count/views/markov/chain-reduce.js
72
+ - examples/word_count/views/word_count
73
+ - examples/word_count/views/word_count/count-map.js
74
+ - examples/word_count/views/word_count/count-reduce.js
75
+ - examples/word_count/word_count.rb
76
+ - examples/word_count/word_count_query.rb
77
+ - examples/word_count/word_count_views.rb
78
+ - lib/couchrest
79
+ - lib/couchrest/commands
80
+ - lib/couchrest/commands/generate.rb
81
+ - lib/couchrest/commands/push.rb
82
+ - lib/couchrest/core
83
+ - lib/couchrest/core/database.rb
84
+ - lib/couchrest/core/design.rb
85
+ - lib/couchrest/core/document.rb
86
+ - lib/couchrest/core/response.rb
87
+ - lib/couchrest/core/server.rb
88
+ - lib/couchrest/core/view.rb
89
+ - lib/couchrest/helper
90
+ - lib/couchrest/helper/pager.rb
91
+ - lib/couchrest/helper/streamer.rb
92
+ - lib/couchrest/helper/upgrade.rb
93
+ - lib/couchrest/mixins
94
+ - lib/couchrest/mixins/attachments.rb
95
+ - lib/couchrest/mixins/callbacks.rb
96
+ - lib/couchrest/mixins/class_proxy.rb
97
+ - lib/couchrest/mixins/design_doc.rb
98
+ - lib/couchrest/mixins/document_queries.rb
99
+ - lib/couchrest/mixins/extended_attachments.rb
100
+ - lib/couchrest/mixins/extended_document_mixins.rb
101
+ - lib/couchrest/mixins/properties.rb
102
+ - lib/couchrest/mixins/validation.rb
103
+ - lib/couchrest/mixins/views.rb
104
+ - lib/couchrest/mixins.rb
105
+ - lib/couchrest/monkeypatches.rb
106
+ - lib/couchrest/more
107
+ - lib/couchrest/more/casted_model.rb
108
+ - lib/couchrest/more/extended_document.rb
109
+ - lib/couchrest/more/property.rb
110
+ - lib/couchrest/support
111
+ - lib/couchrest/support/blank.rb
112
+ - lib/couchrest/support/class.rb
113
+ - lib/couchrest/validation
114
+ - lib/couchrest/validation/auto_validate.rb
115
+ - lib/couchrest/validation/contextual_validators.rb
116
+ - lib/couchrest/validation/validation_errors.rb
117
+ - lib/couchrest/validation/validators
118
+ - lib/couchrest/validation/validators/absent_field_validator.rb
119
+ - lib/couchrest/validation/validators/confirmation_validator.rb
120
+ - lib/couchrest/validation/validators/format_validator.rb
121
+ - lib/couchrest/validation/validators/formats
122
+ - lib/couchrest/validation/validators/formats/email.rb
123
+ - lib/couchrest/validation/validators/formats/url.rb
124
+ - lib/couchrest/validation/validators/generic_validator.rb
125
+ - lib/couchrest/validation/validators/length_validator.rb
126
+ - lib/couchrest/validation/validators/method_validator.rb
127
+ - lib/couchrest/validation/validators/numeric_validator.rb
128
+ - lib/couchrest/validation/validators/uniqueness_validator.rb
129
+ - lib/couchrest/validation/validators/required_field_validator.rb
130
+ - lib/couchrest.rb
131
+ - spec/couchrest
132
+ - spec/couchrest/core
133
+ - spec/couchrest/core/couchrest_spec.rb
134
+ - spec/couchrest/core/database_spec.rb
135
+ - spec/couchrest/core/design_spec.rb
136
+ - spec/couchrest/core/document_spec.rb
137
+ - spec/couchrest/core/server_spec.rb
138
+ - spec/couchrest/helpers
139
+ - spec/couchrest/helpers/pager_spec.rb
140
+ - spec/couchrest/helpers/streamer_spec.rb
141
+ - spec/couchrest/more
142
+ - spec/couchrest/more/casted_extended_doc_spec.rb
143
+ - spec/couchrest/more/casted_model_spec.rb
144
+ - spec/couchrest/more/extended_doc_attachment_spec.rb
145
+ - spec/couchrest/more/extended_doc_spec.rb
146
+ - spec/couchrest/more/extended_doc_subclass_spec.rb
147
+ - spec/couchrest/more/extended_doc_view_spec.rb
148
+ - spec/couchrest/more/property_spec.rb
149
+ - spec/fixtures
150
+ - spec/fixtures/attachments
151
+ - spec/fixtures/attachments/couchdb.png
152
+ - spec/fixtures/attachments/README
153
+ - spec/fixtures/attachments/test.html
154
+ - spec/fixtures/more
155
+ - spec/fixtures/more/article.rb
156
+ - spec/fixtures/more/card.rb
157
+ - spec/fixtures/more/course.rb
158
+ - spec/fixtures/more/event.rb
159
+ - spec/fixtures/more/invoice.rb
160
+ - spec/fixtures/more/location.rb
161
+ - spec/fixtures/more/person.rb
162
+ - spec/fixtures/more/question.rb
163
+ - spec/fixtures/more/service.rb
164
+ - spec/fixtures/views
165
+ - spec/fixtures/views/lib.js
166
+ - spec/fixtures/views/test_view
167
+ - spec/fixtures/views/test_view/lib.js
168
+ - spec/fixtures/views/test_view/only-map.js
169
+ - spec/fixtures/views/test_view/test-map.js
170
+ - spec/fixtures/views/test_view/test-reduce.js
171
+ - spec/spec.opts
172
+ - spec/spec_helper.rb
173
+ - utils/remap.rb
174
+ - utils/subset.rb
175
+ has_rdoc: true
176
+ homepage: http://github.com/jchris/couchrest
177
+ licenses:
178
+ post_install_message:
179
+ rdoc_options: []
180
+
181
+ require_paths:
182
+ - lib
183
+ required_ruby_version: !ruby/object:Gem::Requirement
184
+ requirements:
185
+ - - ">="
186
+ - !ruby/object:Gem::Version
187
+ version: "0"
188
+ version:
189
+ required_rubygems_version: !ruby/object:Gem::Requirement
190
+ requirements:
191
+ - - ">="
192
+ - !ruby/object:Gem::Version
193
+ version: "0"
194
+ version:
195
+ requirements: []
196
+
197
+ rubyforge_project:
198
+ rubygems_version: 1.3.5
199
+ signing_key:
200
+ specification_version: 2
201
+ summary: Lean and RESTful interface to CouchDB.
202
+ test_files: []
203
+