leanback 0.1.6 → 0.1.7

Sign up to get free protection for your applications and to get access to all the features.
data/README.rdoc CHANGED
@@ -55,6 +55,12 @@ Lets edit that document to change the email address, phone number, and add a gen
55
55
  Document.edit doc
56
56
  # => {"ok"=>true, "id"=>"Linda", "rev"=>"2-e813a0e902e3ac114400ff3959a2adde"}
57
57
 
58
+ Retrieve the document by id
59
+ doc = {:database => 'contacts', :doc_id => 'Linda'}
60
+ Couchdb.find doc
61
+ #=> {"_id"=>"Linda", "_rev"=>"2-e813a0e902e3ac114400ff3959a2adde", "firstname"=>"Linda",
62
+ "lastname"=>"smith", "email"=>"linda@mail.com", "gender"=>"female", "phone"=>"718-245-5611"}
63
+
58
64
  Delete the document
59
65
  doc = {:database => 'contacts', :doc_id => 'Linda', :rev => '2-e813a0e902e3ac114400ff3959a2adde'}
60
66
  Document.delete doc
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.6
1
+ 0.1.7
data/leanback.gemspec ADDED
@@ -0,0 +1,70 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = %q{leanback}
8
+ s.version = "0.1.7"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["Obi Akubue"]
12
+ s.date = %q{2011-06-19}
13
+ s.description = %q{lightweight Ruby interface to CouchDB}
14
+ s.email = %q{obioraakubue@yahoo.com}
15
+ s.extra_rdoc_files = [
16
+ "LICENSE.txt",
17
+ "README.rdoc"
18
+ ]
19
+ s.files = [
20
+ ".document",
21
+ "Gemfile",
22
+ "Gemfile.lock",
23
+ "LICENSE.txt",
24
+ "README.rdoc",
25
+ "Rakefile",
26
+ "VERSION",
27
+ "leanback.gemspec",
28
+ "lib/leanback.rb",
29
+ "test/helper.rb",
30
+ "test/test_leanback.rb"
31
+ ]
32
+ s.homepage = %q{http://github.com/obi-a/leanback}
33
+ s.licenses = ["MIT"]
34
+ s.require_paths = ["lib"]
35
+ s.rubygems_version = %q{1.3.7}
36
+ s.summary = %q{lightweight Ruby interface to CouchDB}
37
+ s.test_files = [
38
+ "test/helper.rb",
39
+ "test/test_leanback.rb"
40
+ ]
41
+
42
+ if s.respond_to? :specification_version then
43
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
44
+ s.specification_version = 3
45
+
46
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
47
+ s.add_runtime_dependency(%q<rest-client>, [">= 0"])
48
+ s.add_runtime_dependency(%q<yajl-ruby>, [">= 0"])
49
+ s.add_development_dependency(%q<shoulda>, [">= 0"])
50
+ s.add_development_dependency(%q<bundler>, ["~> 1.0.0"])
51
+ s.add_development_dependency(%q<jeweler>, ["~> 1.5.2"])
52
+ s.add_development_dependency(%q<rcov>, [">= 0"])
53
+ else
54
+ s.add_dependency(%q<rest-client>, [">= 0"])
55
+ s.add_dependency(%q<yajl-ruby>, [">= 0"])
56
+ s.add_dependency(%q<shoulda>, [">= 0"])
57
+ s.add_dependency(%q<bundler>, ["~> 1.0.0"])
58
+ s.add_dependency(%q<jeweler>, ["~> 1.5.2"])
59
+ s.add_dependency(%q<rcov>, [">= 0"])
60
+ end
61
+ else
62
+ s.add_dependency(%q<rest-client>, [">= 0"])
63
+ s.add_dependency(%q<yajl-ruby>, [">= 0"])
64
+ s.add_dependency(%q<shoulda>, [">= 0"])
65
+ s.add_dependency(%q<bundler>, ["~> 1.0.0"])
66
+ s.add_dependency(%q<jeweler>, ["~> 1.5.2"])
67
+ s.add_dependency(%q<rcov>, [">= 0"])
68
+ end
69
+ end
70
+
data/lib/leanback.rb CHANGED
@@ -94,6 +94,21 @@ module Couchdb
94
94
  end
95
95
  end
96
96
 
97
+ ##find a document by _id
98
+ def self.find(doc)
99
+ set_address
100
+ db_name = doc[:database]
101
+ doc_id = doc[:doc_id]
102
+ begin
103
+ response = RestClient.get 'http://' + @address + ':' + @port + '/' + db_name + '/' + doc_id
104
+ hash = Yajl::Parser.parse(response.to_str)
105
+ #puts hash.inspect
106
+ rescue => e
107
+ hash = Yajl::Parser.parse(e.response.to_s)
108
+ #puts hash.inspect
109
+ end
110
+ end
111
+
97
112
  #return a list of all docs in the database
98
113
  def self.docs_from(database_name)
99
114
  set_address
@@ -23,6 +23,13 @@ class TestLeanback < Test::Unit::TestCase
23
23
  # puts hash.inspect
24
24
  # end
25
25
 
26
+ should "return a document by ID" do
27
+
28
+ doc = {:database => 'monitors', :doc_id => 'ee6f4f65-2b5b-4452-a9c4-fd9d860ec17d'}
29
+ hash = Couchdb.find doc
30
+ puts hash.inspect
31
+ end
32
+
26
33
  should "return a display a list of all databases" do
27
34
  databases = Couchdb.all
28
35
  databases.each do |db_name|
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 1
8
- - 6
9
- version: 0.1.6
8
+ - 7
9
+ version: 0.1.7
10
10
  platform: ruby
11
11
  authors:
12
12
  - Obi Akubue
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2011-04-03 00:00:00 -04:00
17
+ date: 2011-06-19 00:00:00 -04:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
@@ -116,6 +116,7 @@ files:
116
116
  - README.rdoc
117
117
  - Rakefile
118
118
  - VERSION
119
+ - leanback.gemspec
119
120
  - lib/leanback.rb
120
121
  - test/helper.rb
121
122
  - test/test_leanback.rb
@@ -133,7 +134,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
133
134
  requirements:
134
135
  - - ">="
135
136
  - !ruby/object:Gem::Version
136
- hash: 327802877
137
+ hash: 609197857
137
138
  segments:
138
139
  - 0
139
140
  version: "0"