mongohq-client 0.0.2 → 0.0.3
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.
- data/Gemfile.lock +1 -1
- data/README.md +8 -2
- data/lib/mongohq-client/http.rb +0 -3
- data/mongohq-client.gemspec +1 -1
- data/spec/integration_spec.rb +48 -0
- metadata +2 -1
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -2,8 +2,6 @@
|
|
2
2
|
|
3
3
|
A simple MongoHQ api client for ruby
|
4
4
|
|
5
|
-
TODO: Write a gem description
|
6
|
-
|
7
5
|
## Installation
|
8
6
|
|
9
7
|
Add this line to your application's Gemfile:
|
@@ -36,6 +34,14 @@ Retrive collections from database
|
|
36
34
|
|
37
35
|
collections = client.databases.first.collections
|
38
36
|
|
37
|
+
Retrieve documents from collection
|
38
|
+
|
39
|
+
documents = client.databases.first.collections.first.documents
|
40
|
+
|
41
|
+
Retrieve indexes from from collection
|
42
|
+
|
43
|
+
indexes = client.databases.first.collections.first.indexes
|
44
|
+
|
39
45
|
## Contributing
|
40
46
|
|
41
47
|
1. Fork it
|
data/lib/mongohq-client/http.rb
CHANGED
data/mongohq-client.gemspec
CHANGED
@@ -0,0 +1,48 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe "Integration Tests" do
|
4
|
+
let(:client) { MongoHQClient.from_apikey "123456" }
|
5
|
+
|
6
|
+
before do
|
7
|
+
FakeWeb.register_uri :get, "https://api.mongohq.com/databases?_apikey=#{client.apikey}", body: '[{"name":"database1","hostname":"host.mongohq.com","port":27036,"shared":true,"plan":"Micro"},{"name":"database2","hostname":"host2.mongohq.com","port":10075,"shared":true,"plan":"Sandbox"},{"name":"database3","hostname":"staff.mongohq.com","port":10025,"shared":true,"plan":"Sandbox"}]'
|
8
|
+
|
9
|
+
FakeWeb.register_uri :get, "https://api.mongohq.com/databases/database1/collections?_apikey=123456", body: '[{"name":"collections1","count":0,"storageSize":40960,"avgObjSize":null,"indexCount":1,"ok":1.0},{"name":"collection2","count":15,"storageSize":192512,"avgObjSize":2257.866666666667,"indexCount":1,"ok":1.0},{"name":"collections3","count":162,"storageSize":294912,"avgObjSize":1006.8395061728395,"indexCount":1,"ok":1.0},{"name":"collections4","count":36,"storageSize":8192,"avgObjSize":92.22222222222223,"indexCount":1,"ok":1.0},{"name":"collections5","count":0,"storageSize":8192,"avgObjSize":null,"indexCount":1,"ok":1.0},{"name":"collections6","count":0,"storageSize":8192,"avgObjSize":null,"indexCount":1,"ok":1.0},{"name":"collections7","count":1558,"storageSize":1740800,"avgObjSize":278.9165596919127,"indexCount":1,"ok":1.0}]'
|
10
|
+
|
11
|
+
FakeWeb.register_uri :get, "https://api.mongohq.com/databases/database1/collections/collections1/documents?_apikey=123456", body: '[{"_id":{"$oid": "4ffde13927bce841321005ec0"},"name":"Test User","updated_at":"2012-07-11 20:25:29 UTC","created_at":"2012-07-11 20:25:29 UTC"}]'
|
12
|
+
|
13
|
+
FakeWeb.register_uri :get, "https://api.mongohq.com/databases/database1/collections/collections1/indexes?_apikey=123456", body: '[{"v":1,"key":{"_id":1},"ns":"database1.collection1","name":"_id_"}]'
|
14
|
+
end
|
15
|
+
|
16
|
+
describe "#databases" do
|
17
|
+
let(:databases) { client.databases }
|
18
|
+
|
19
|
+
it "should return databases" do
|
20
|
+
databases.size.should eq(3)
|
21
|
+
end
|
22
|
+
|
23
|
+
describe "#collections" do
|
24
|
+
let(:collections) { databases.first.collections }
|
25
|
+
|
26
|
+
it "should return collections" do
|
27
|
+
collections.size.should eq(7)
|
28
|
+
end
|
29
|
+
|
30
|
+
describe "#documents" do
|
31
|
+
let(:documents) { collections.first.documents }
|
32
|
+
|
33
|
+
it "should return documents" do
|
34
|
+
documents.size.should eq(1)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
describe "#indexes" do
|
39
|
+
let(:indexes) { collections.first.indexes}
|
40
|
+
|
41
|
+
it "should return indexes" do
|
42
|
+
indexes.size.should eq(1)
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mongohq-client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -133,6 +133,7 @@ files:
|
|
133
133
|
- lib/mongohq-client/invoice.rb
|
134
134
|
- lib/mongohq-client/plan.rb
|
135
135
|
- mongohq-client.gemspec
|
136
|
+
- spec/integration_spec.rb
|
136
137
|
- spec/mongohq-client/client_spec.rb
|
137
138
|
- spec/mongohq-client/collection_spec.rb
|
138
139
|
- spec/mongohq-client/database_details_spec.rb
|