leanback 0.4.0 → 0.4.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 (47) hide show
  1. data/Changelog.rdoc +6 -0
  2. data/README.md +1 -1
  3. data/VERSION +1 -1
  4. data/documentation/static/2011/11/20/i-moved-leanback-documentation/index.html +180 -0
  5. data/documentation/static/2011/11/20/index.html +146 -0
  6. data/documentation/static/2011/11/index.html +146 -0
  7. data/documentation/static/2011/index.html +146 -0
  8. data/documentation/static/2013/06/02/index.html +146 -0
  9. data/documentation/static/2013/06/02/released-leanback-v0-3-4/index.html +180 -0
  10. data/documentation/static/2013/06/09/index.html +146 -0
  11. data/documentation/static/2013/06/09/released-leanback-v0-4-0/index.html +179 -0
  12. data/documentation/static/2013/06/index.html +158 -0
  13. data/documentation/static/2013/index.html +158 -0
  14. data/documentation/static/author/admin/index.html +175 -0
  15. data/documentation/static/basic-couchdb-operations/index.html +259 -0
  16. data/documentation/static/category/uncategorized/index.html +170 -0
  17. data/documentation/static/couchdb-configuration/index.html +189 -0
  18. data/documentation/static/couchdb-security/index.html +218 -0
  19. data/documentation/static/count-by-multiple-documents/index.html +221 -0
  20. data/documentation/static/count-documents-by-key/index.html +177 -0
  21. data/documentation/static/css/2c-l-fixed.css +1 -0
  22. data/documentation/static/css/2c-l-fixed.dev.css +62 -0
  23. data/documentation/static/css/2c-r-fixed.css +1 -0
  24. data/documentation/static/css/2c-r-fixed.dev.css +60 -0
  25. data/documentation/static/css/3c-c-fixed.css +1 -0
  26. data/documentation/static/css/3c-c-fixed.dev.css +84 -0
  27. data/documentation/static/css/3c-l-fixed.css +1 -0
  28. data/documentation/static/css/3c-l-fixed.dev.css +61 -0
  29. data/documentation/static/css/3c-r-fixed.css +1 -0
  30. data/documentation/static/css/3c-r-fixed.dev.css +62 -0
  31. data/documentation/static/css/holy-grail-fluid.css +5 -0
  32. data/documentation/static/css/plugins.css +5 -0
  33. data/documentation/static/css/print.css +5 -0
  34. data/documentation/static/css/screen.css +1 -0
  35. data/documentation/static/design-documents-and-permanent-views/index.html +454 -0
  36. data/documentation/static/error-handling/index.html +157 -0
  37. data/documentation/static/find-document-by-multiple-keys/index.html +269 -0
  38. data/documentation/static/find-documents-by-key/index.html +243 -0
  39. data/documentation/static/index.html +161 -0
  40. data/documentation/static/leanback/index.html +130 -0
  41. data/documentation/static/leanback/installation/index.html +119 -0
  42. data/documentation/static/setting-the-bind_address-port/index.html +151 -0
  43. data/documentation/static/style.css +16 -0
  44. data/leanback.gemspec +44 -2
  45. data/lib/leanback.rb +518 -535
  46. data/spec/no_admin_party/cloudant_spec.rb +365 -0
  47. metadata +45 -3
@@ -0,0 +1,365 @@
1
+ require 'spec_base.rb'
2
+
3
+ #a day in the life of a CouchDB admin user
4
+ Couchdb.address = "http://whisperservers.cloudant.com"
5
+ Couchdb.port = "80"
6
+ hash = Couchdb.login(username = ENV['CLOUDANT_USERNAME'],password =ENV['CLOUDANT_PASSWORD'])
7
+ @@auth_session = hash["AuthSession"]
8
+
9
+
10
+ describe "CouchDB " do
11
+
12
+ it "should create and delete a database" do
13
+ hash = Couchdb.create('employees',@@auth_session)
14
+ #hash.to_s.should == '{"ok"=>true}'
15
+ #hash = Couchdb.all
16
+ #hash.include?("employees").should == true
17
+ hash = Couchdb.delete 'employees',@@auth_session
18
+ #hash.include?("employees").should == false
19
+ end
20
+
21
+ it "should create a database add a finder method to it and then delete the database" do
22
+ Couchdb.create('wiseguys',@@auth_session)
23
+ hash = Couchdb.add_finder({:database => 'wiseguys', :key => 'email'},@@auth_session)
24
+ hash.include?("_design/email_finder").should == true
25
+ hash.include?("true").should == true
26
+ hash.include?("rev").should == true
27
+
28
+ doc = {:database => 'wiseguys', :doc_id => '_design/email_finder'}
29
+ hash = Couchdb.view doc,@@auth_session
30
+ hash["_id"].should == '_design/email_finder'
31
+ Couchdb.delete 'wiseguys',@@auth_session
32
+ end
33
+
34
+ it "should create and view document doc" do
35
+ Couchdb.create('contacts',@@auth_session)
36
+ data = {:firstname => 'John',
37
+ :lastname =>'smith',
38
+ :phone => '202-234-1234',
39
+ :email =>'james@mail.com',
40
+ :age =>'34',
41
+ :gender =>'male'}
42
+ doc = {:database => 'contacts', :doc_id => 'john', :data => data}
43
+ Couchdb.create_doc doc,@@auth_session
44
+
45
+ doc = {:database => 'contacts', :doc_id => 'john'}
46
+ hash = Couchdb.view doc,@@auth_session
47
+ hash["_id"].should == 'john'
48
+ end
49
+
50
+ it "should count the lastnames named smith" do
51
+ count = Couchdb.count({:database => 'contacts', :lastname => 'smith'},@@auth_session)
52
+ count.should == 1
53
+ end
54
+
55
+ it "should count lastnames named brown" do
56
+ count = Couchdb.count({:database => 'contacts', :lastname => 'brown'},@@auth_session)
57
+ count.should == 0
58
+ end
59
+
60
+
61
+ it "find items by key" do
62
+ docs = Couchdb.find_by({:database => 'contacts', :lastname => 'smith'},@@auth_session)
63
+ d = docs[0]
64
+ d["lastname"].should == "smith"
65
+ Couchdb.delete_doc({:database => 'contacts', :doc_id => '_design/lastname_finder'},@@auth_session)
66
+ end
67
+
68
+ it "should find items by multiple keys" do
69
+ keys = {:gender => 'male',:age => '34'}
70
+ docs = Couchdb.find_by_keys({:database => 'contacts', :keys => keys},@@auth_session)
71
+ d = docs[0]
72
+ d["age"].should == "34"
73
+ end
74
+
75
+ it "should find items by multiple keys using a single key" do
76
+ keys = {:lastname => 'smith'}
77
+ docs = Couchdb.find_by_keys({:database => 'contacts', :keys => keys},@@auth_session)
78
+ d = docs[0]
79
+ d["lastname"].should == "smith"
80
+ end
81
+
82
+ it "should find items by multiple keys" do
83
+ keys = {:gender => 'male',:age => '40'}
84
+ docs = Couchdb.find_by_keys({:database => 'contacts', :keys => keys},@@auth_session)
85
+ docs.should == []
86
+ end
87
+
88
+ it "should count items by multiple keys" do
89
+ keys = {:gender => 'male',:age => '34'}
90
+ count = Couchdb.count_by_keys({:database => 'contacts', :keys => keys},@@auth_session)
91
+ count.should == 1
92
+ end
93
+
94
+ it "should count items by multiple keys" do
95
+ keys = {:gender => 'male',:age => '40'}
96
+ count = Couchdb.count_by_keys({:database => 'contacts', :keys => keys},@@auth_session)
97
+ count.should == 0
98
+ end
99
+
100
+
101
+
102
+ it "should query a permanent view that doesn't exist and handle exception" do
103
+ begin
104
+ view = { :database => "contacts", :design_doc => 'more_views', :view => 'get_user_email'}
105
+ Couchdb.find view,@@auth_session
106
+ rescue CouchdbException => e
107
+ e.to_s.should == "CouchDB: Error - not_found. Reason - missing"
108
+ e.error.should == "not_found"
109
+ end
110
+ end
111
+
112
+ it "should query a permanent view and create the view on the fly, if it doesn't already exist" do
113
+ view = {:database => 'contacts',
114
+ :design_doc => 'my_views',
115
+ :view => 'get_emails',
116
+ :json_doc => '/home/obi/bin/leanback/test/my_view.json'}
117
+
118
+ docs = Couchdb.find_on_fly(view,@@auth_session)
119
+ docs[0].include?("Email").should == true
120
+ docs[0].include?("Name").should == true
121
+ #verify that the view was created
122
+ doc = {:database => 'contacts', :doc_id => '_design/my_views'}
123
+ hash = Couchdb.view doc,@@auth_session
124
+ hash["_id"].should == '_design/my_views'
125
+ Couchdb.delete_doc({:database => 'contacts', :doc_id => '_design/my_views'},@@auth_session)
126
+ end
127
+
128
+ it "should query a permanent view by key and create the view on the fly, if it doesn't already exist" do
129
+ view = { :database => 'contacts',
130
+ :design_doc => 'the_view',
131
+ :view => 'age',
132
+ :json_doc => '/home/obi/bin/leanback/test/view_age.json'}
133
+
134
+ age = '34'
135
+ docs = Couchdb.find_on_fly(view,@@auth_session,key = age)
136
+ docs[0].include?("age").should == true
137
+ d = docs[0]
138
+ d["age"].should == '34'
139
+ #verify that the view was created
140
+ doc = {:database => 'contacts', :doc_id => '_design/the_view'}
141
+ hash = Couchdb.view doc,@@auth_session
142
+ hash["_id"].should == '_design/the_view'
143
+ Couchdb.delete_doc({:database => 'contacts', :doc_id => '_design/the_view'},@@auth_session)
144
+ end
145
+
146
+ it "should create a design doc/permanent view and query it" do
147
+ doc = { :database => 'contacts', :design_doc => 'more_views', :json_doc => '/home/obi/bin/leanback/test/my_views.json' }
148
+ hash = Couchdb.create_design doc,@@auth_session
149
+ hash["id"].should == '_design/more_views'
150
+ hash["ok"].should == true
151
+
152
+ view = { :database => "contacts", :design_doc => 'more_views', :view => 'get_email'}
153
+ hash = Couchdb.find view,@@auth_session
154
+ hash[0].has_key?("Firstname").should == true
155
+ hash[0].has_key?("Lastname").should == true
156
+ hash[0].has_key?("Email").should == true
157
+
158
+ doc = {:database => 'contacts', :doc_id => '_design/more_views'}
159
+ hash = Couchdb.view doc,@@auth_session
160
+ hash["_id"].should == '_design/more_views'
161
+ Couchdb.delete_doc({:database => 'contacts', :doc_id => '_design/more_views'},@@auth_session)
162
+ end
163
+
164
+
165
+
166
+ it "should create a document" do
167
+ data = {:firstname => 'Nancy', :lastname =>'Lee', :phone => '347-808-3734',:email =>'nancy@mail.com',:gender => 'female'}
168
+ doc = {:database => 'contacts', :doc_id => 'Nancy', :data => data}
169
+ hash = Couchdb.create_doc doc,@@auth_session
170
+ hash["id"].should == 'Nancy'
171
+ hash["ok"].should == true
172
+
173
+ doc = {:database => 'contacts', :doc_id => 'Nancy'}
174
+ hash = Couchdb.view doc,@@auth_session
175
+ hash["_id"].should == 'Nancy'
176
+ hash["firstname"].should == 'Nancy'
177
+ hash["lastname"].should == 'Lee'
178
+ hash["phone"].should == '347-808-3734'
179
+ Couchdb.delete_doc({:database => 'contacts', :doc_id => 'Nancy'},@@auth_session)
180
+ end
181
+
182
+ it "should update the document" do
183
+ data = {:age => "41", :lastname => "Stevens" }
184
+ doc = { :database => 'contacts', :doc_id => 'john', :data => data}
185
+ hash = Couchdb.update_doc doc,@@auth_session
186
+ hash["id"].should == 'john'
187
+ hash["ok"].should == true
188
+
189
+ doc = {:database => 'contacts', :doc_id => 'john'}
190
+ hash = Couchdb.view doc,@@auth_session
191
+ hash["_id"].should == 'john'
192
+ hash["age"].should == '41'
193
+ hash["lastname"].should == 'Stevens'
194
+ Couchdb.delete_doc({:database => 'contacts', :doc_id => 'john'},@@auth_session)
195
+ end
196
+
197
+
198
+ it "should delete a document after creating it" do
199
+ data = {:firstname => 'Sun',
200
+ :lastname =>'Nova',
201
+ :phone => '212-234-1234',
202
+ :email =>'james@mail.com'}
203
+
204
+ doc = {:database => 'contacts', :doc_id => 'Sun', :data => data}
205
+ Couchdb.create_doc doc,@@auth_session
206
+
207
+ doc = {:database => 'contacts', :doc_id => 'Sun'}
208
+ hash = Couchdb.delete_doc doc,@@auth_session
209
+ hash["id"].should == 'Sun'
210
+ hash["ok"].should == true
211
+ begin
212
+ doc = {:database => 'contacts', :doc_id => 'Sun'}
213
+ Couchdb.view doc,@@auth_session
214
+ rescue CouchdbException => e
215
+ e.to_s.should == "CouchDB: Error - not_found. Reason - deleted"
216
+ e.error.should == "not_found"
217
+ end
218
+ end
219
+
220
+ it "should test finder options" do
221
+
222
+ Couchdb.create('fishes',@@auth_session)
223
+
224
+ data = {:firstname => 'aaron', :gender =>'male', :age => '28', :salary => '50000'}
225
+ doc = {:database => 'fishes', :doc_id => 'aaron', :data => data}
226
+ Couchdb.create_doc doc,@@auth_session
227
+
228
+ data = {:firstname => 'john', :gender =>'male', :age => '28', :salary => '60000'}
229
+ doc = {:database => 'fishes', :doc_id => 'john', :data => data}
230
+ Couchdb.create_doc doc,@@auth_session
231
+
232
+ data = {:firstname => 'peter', :gender =>'male', :age => '45', :salary => '78000'}
233
+ doc = {:database => 'fishes', :doc_id => 'peter', :data => data}
234
+ Couchdb.create_doc doc,@@auth_session
235
+
236
+ data = {:firstname => 'sam', :gender =>'male', :age => '28', :salary => '97000'}
237
+ doc = {:database => 'fishes', :doc_id => 'sam', :data => data}
238
+ Couchdb.create_doc doc,@@auth_session
239
+
240
+
241
+ keys = {:age =>'28', :gender => 'male'}
242
+ hash = Couchdb.find_by_keys({:database => 'fishes', :keys => keys},@@auth_session, options = {:limit => 2, :skip => 1})
243
+ h = hash[0]
244
+ h["firstname"].should == "john"
245
+ hash.length.should == 2
246
+
247
+ #create the design doc to be queryed in the test
248
+ Couchdb.find_by({:database => 'fishes', :gender => 'male'},@@auth_session)
249
+
250
+
251
+ view = { :database => "fishes",
252
+ :design_doc => 'gender_finder',
253
+ :view => 'find_by_gender'}
254
+
255
+ hash = Couchdb.find view,@@auth_session,key=nil, options = {:limit => 2, :skip => 1}
256
+ h = hash[0]
257
+ h["firstname"].should == "john"
258
+ hash.length.should == 2
259
+
260
+ Couchdb.find_by({:database => 'fishes', :gender => 'male'},@@auth_session,options = {:limit => 2, :skip => 1})
261
+ h = hash[0]
262
+ h["firstname"].should == "john"
263
+ hash.length.should == 2
264
+
265
+
266
+
267
+ hash = Couchdb.find view,@@auth_session,key='male', options = {:descending => true}
268
+ h = hash[0]
269
+ h["firstname"].should == "sam"
270
+
271
+ Couchdb.find_by({:database => 'fishes', :gender => 'male'},@@auth_session, options = {:descending => true})
272
+ h = hash[0]
273
+ h["firstname"].should == "sam"
274
+
275
+
276
+
277
+ hash = Couchdb.find view,@@auth_session,key='male', options = {:limit => 3}
278
+ hash.length.should == 3
279
+
280
+ hash = Couchdb.find view,@@auth_session,key=nil, options = {:skip => 2}
281
+ h = hash[0]
282
+ h["firstname"].should == "peter"
283
+ hash.length.should == 2
284
+
285
+ hash = Couchdb.find view,@@auth_session,key='male', options = {:descending => true,:limit => 1}
286
+ h = hash[0]
287
+ h["firstname"].should == "sam"
288
+ hash.length.should == 1
289
+
290
+ Couchdb.find_by({:database => 'fishes', :gender => 'male'},@@auth_session, options = {:descending => true,:limit => 1})
291
+ h = hash[0]
292
+ h["firstname"].should == "sam"
293
+ hash.length.should == 1
294
+
295
+ Couchdb.find_by({:database => 'fishes', :salary => '5000'},@@auth_session)
296
+
297
+
298
+ view = { :database => "fishes",
299
+ :design_doc => 'salary_finder',
300
+ :view => 'find_by_salary'}
301
+
302
+ hash = Couchdb.find view, @@auth_session,key=nil, options = {:startkey => "3000", :endkey => "65000"}
303
+ h = hash[0]
304
+ h["firstname"].should == "aaron"
305
+ hash.length.should == 2
306
+
307
+ hash = Couchdb.find view, @@auth_session,key=nil, options = {:startkey => "53000", :endkey => "99000",:limit => 2}
308
+ h = hash[0]
309
+ h["firstname"].should == "john"
310
+ hash.length.should == 2
311
+
312
+ Couchdb.find_by({:database => 'fishes', :salary => ''},@@auth_session, options = {:startkey => "53000", :endkey => "99000",:limit => 2})
313
+ h = hash[0]
314
+ h["firstname"].should == "john"
315
+ hash.length.should == 2
316
+
317
+ view = {:database => 'fishes',
318
+ :design_doc => 'my_views',
319
+ :view => 'age_gender',
320
+ :json_doc => '/home/obi/bin/leanback/test/start.json'}
321
+
322
+ options = {:startkey => ["28","male"], :endkey => ["28","male"], :limit => 2}
323
+
324
+ hash = Couchdb.find_on_fly(view,@@auth_session,key=nil, options)
325
+ h0 = hash[0]
326
+ h1 = hash[1]
327
+ h0["firstname"].should == "aaron"
328
+ h1["firstname"].should == "john"
329
+ hash.length.should == 2
330
+
331
+ options = {:startkey => ["28","male"], :endkey => ["28","male"], :skip => 1}
332
+
333
+ hash = Couchdb.find_on_fly(view,@@auth_session,key=nil, options)
334
+ h0 = hash[0]
335
+ h1 = hash[1]
336
+ h0["firstname"].should == "john"
337
+ h1["firstname"].should == "sam"
338
+ hash.length.should == 2
339
+
340
+
341
+ options = {:startkey => ["28","male"], :endkey => ["28","male"]}
342
+
343
+ hash = Couchdb.find_on_fly(view,@@auth_session,key=nil, options)
344
+ h0 = hash[0]
345
+ h1 = hash[1]
346
+ h0["firstname"].should == "aaron"
347
+ h1["firstname"].should == "john"
348
+ hash.length.should == 3
349
+
350
+ Couchdb.delete 'fishes',@@auth_session
351
+ end
352
+
353
+
354
+
355
+
356
+
357
+
358
+
359
+
360
+ it "should delete the database" do
361
+ Couchdb.delete 'contacts',@@auth_session
362
+ end
363
+
364
+
365
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: leanback
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.4.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-06-09 00:00:00.000000000 Z
12
+ date: 2013-08-24 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rest-client
@@ -139,9 +139,50 @@ files:
139
139
  - README.md
140
140
  - Rakefile
141
141
  - VERSION
142
+ - documentation/static/2011/11/20/i-moved-leanback-documentation/index.html
143
+ - documentation/static/2011/11/20/index.html
144
+ - documentation/static/2011/11/index.html
145
+ - documentation/static/2011/index.html
146
+ - documentation/static/2013/06/02/index.html
147
+ - documentation/static/2013/06/02/released-leanback-v0-3-4/index.html
148
+ - documentation/static/2013/06/09/index.html
149
+ - documentation/static/2013/06/09/released-leanback-v0-4-0/index.html
150
+ - documentation/static/2013/06/index.html
151
+ - documentation/static/2013/index.html
152
+ - documentation/static/author/admin/index.html
153
+ - documentation/static/basic-couchdb-operations/index.html
154
+ - documentation/static/category/uncategorized/index.html
155
+ - documentation/static/couchdb-configuration/index.html
156
+ - documentation/static/couchdb-security/index.html
157
+ - documentation/static/count-by-multiple-documents/index.html
158
+ - documentation/static/count-documents-by-key/index.html
159
+ - documentation/static/css/2c-l-fixed.css
160
+ - documentation/static/css/2c-l-fixed.dev.css
161
+ - documentation/static/css/2c-r-fixed.css
162
+ - documentation/static/css/2c-r-fixed.dev.css
163
+ - documentation/static/css/3c-c-fixed.css
164
+ - documentation/static/css/3c-c-fixed.dev.css
165
+ - documentation/static/css/3c-l-fixed.css
166
+ - documentation/static/css/3c-l-fixed.dev.css
167
+ - documentation/static/css/3c-r-fixed.css
168
+ - documentation/static/css/3c-r-fixed.dev.css
169
+ - documentation/static/css/holy-grail-fluid.css
170
+ - documentation/static/css/plugins.css
171
+ - documentation/static/css/print.css
172
+ - documentation/static/css/screen.css
173
+ - documentation/static/design-documents-and-permanent-views/index.html
174
+ - documentation/static/error-handling/index.html
175
+ - documentation/static/find-document-by-multiple-keys/index.html
176
+ - documentation/static/find-documents-by-key/index.html
177
+ - documentation/static/index.html
178
+ - documentation/static/leanback/index.html
179
+ - documentation/static/leanback/installation/index.html
180
+ - documentation/static/setting-the-bind_address-port/index.html
181
+ - documentation/static/style.css
142
182
  - leanback.gemspec
143
183
  - lib/leanback.rb
144
184
  - spec/admin_party/database_spec.rb
185
+ - spec/no_admin_party/cloudant_spec.rb
145
186
  - spec/no_admin_party/database_spec.rb
146
187
  - spec/no_admin_party/non_admin_user_spec.rb
147
188
  - spec/spec_base.rb
@@ -167,7 +208,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
167
208
  version: '0'
168
209
  segments:
169
210
  - 0
170
- hash: -3576361140829374907
211
+ hash: 3337391598339047950
171
212
  required_rubygems_version: !ruby/object:Gem::Requirement
172
213
  none: false
173
214
  requirements:
@@ -182,6 +223,7 @@ specification_version: 3
182
223
  summary: lightweight Ruby interface to CouchDB
183
224
  test_files:
184
225
  - spec/admin_party/database_spec.rb
226
+ - spec/no_admin_party/cloudant_spec.rb
185
227
  - spec/no_admin_party/database_spec.rb
186
228
  - spec/no_admin_party/non_admin_user_spec.rb
187
229
  - spec/spec_base.rb