thebigdb 1.2.3 → 1.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +2 -0
- data/.travis.yml +2 -2
- data/Gemfile.lock +43 -35
- data/README.md +10 -10
- data/lib/thebigdb/resources/statement.rb +2 -2
- data/lib/thebigdb/version.rb +2 -2
- data/spec/resources/statement_spec.rb +9 -9
- data/thebigdb.gemspec +4 -4
- metadata +28 -46
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 208086548323d779597adb12e40c415503bb4dc8
|
4
|
+
data.tar.gz: 3b2ed441b52ac2c9c386f8652f8cb16c7ca5fc45
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 84e73081cd80956a93279d9582d88c8e5fe96697563f93734c123510ec289c1446a45c99300f317af0b5698eedbdc6b417f032578c5fc20af132933b9501c6f0
|
7
|
+
data.tar.gz: 786aaa6c59bb08c373a8b896397738f99408944111d5a5bc05ece4fde65a607230f8f21b5d91a0c0a46d43c16d06b5f067de6545e97af332b974508e5ab02bbe
|
data/.gitignore
CHANGED
data/.travis.yml
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,52 +1,60 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
thebigdb (1.
|
4
|
+
thebigdb (1.3.0)
|
5
5
|
rack (~> 1.4)
|
6
6
|
|
7
7
|
GEM
|
8
8
|
remote: https://rubygems.org/
|
9
9
|
specs:
|
10
|
-
addressable (2.3.
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
10
|
+
addressable (2.3.5)
|
11
|
+
celluloid (0.15.2)
|
12
|
+
timers (~> 1.1.0)
|
13
|
+
coderay (1.1.0)
|
14
|
+
crack (0.4.1)
|
15
|
+
safe_yaml (~> 0.9.0)
|
16
|
+
diff-lcs (1.2.5)
|
17
|
+
ffi (1.9.3)
|
15
18
|
formatador (0.2.4)
|
16
|
-
guard (
|
19
|
+
guard (2.2.5)
|
17
20
|
formatador (>= 0.2.4)
|
18
|
-
listen (
|
19
|
-
lumberjack (
|
20
|
-
pry (>= 0.9.
|
21
|
-
thor (>= 0.
|
22
|
-
guard-rspec (2.
|
23
|
-
guard (>= 1.
|
24
|
-
rspec (~> 2.
|
25
|
-
listen (
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
21
|
+
listen (~> 2.1)
|
22
|
+
lumberjack (~> 1.0)
|
23
|
+
pry (>= 0.9.12)
|
24
|
+
thor (>= 0.18.1)
|
25
|
+
guard-rspec (2.6.0)
|
26
|
+
guard (>= 1.8)
|
27
|
+
rspec (~> 2.13)
|
28
|
+
listen (2.4.0)
|
29
|
+
celluloid (>= 0.15.2)
|
30
|
+
rb-fsevent (>= 0.9.3)
|
31
|
+
rb-inotify (>= 0.9)
|
32
|
+
lumberjack (1.0.4)
|
33
|
+
method_source (0.8.2)
|
34
|
+
pry (0.9.12.4)
|
35
|
+
coderay (~> 1.0)
|
30
36
|
method_source (~> 0.8)
|
31
37
|
slop (~> 3.4)
|
32
38
|
rack (1.5.2)
|
33
|
-
rake (10.
|
39
|
+
rake (10.1.1)
|
34
40
|
rb-fchange (0.0.6)
|
35
41
|
ffi
|
36
|
-
rb-fsevent (0.9.
|
37
|
-
rb-inotify (0.9.
|
42
|
+
rb-fsevent (0.9.4)
|
43
|
+
rb-inotify (0.9.3)
|
38
44
|
ffi (>= 0.5.0)
|
39
|
-
rspec (2.
|
40
|
-
rspec-core (~> 2.
|
41
|
-
rspec-expectations (~> 2.
|
42
|
-
rspec-mocks (~> 2.
|
43
|
-
rspec-core (2.
|
44
|
-
rspec-expectations (2.
|
45
|
+
rspec (2.14.1)
|
46
|
+
rspec-core (~> 2.14.0)
|
47
|
+
rspec-expectations (~> 2.14.0)
|
48
|
+
rspec-mocks (~> 2.14.0)
|
49
|
+
rspec-core (2.14.7)
|
50
|
+
rspec-expectations (2.14.4)
|
45
51
|
diff-lcs (>= 1.1.3, < 2.0)
|
46
|
-
rspec-mocks (2.
|
47
|
-
|
52
|
+
rspec-mocks (2.14.4)
|
53
|
+
safe_yaml (0.9.7)
|
54
|
+
slop (3.4.7)
|
48
55
|
thor (0.18.1)
|
49
|
-
|
56
|
+
timers (1.1.0)
|
57
|
+
webmock (1.16.1)
|
50
58
|
addressable (>= 2.2.7)
|
51
59
|
crack (>= 0.3.2)
|
52
60
|
|
@@ -55,10 +63,10 @@ PLATFORMS
|
|
55
63
|
|
56
64
|
DEPENDENCIES
|
57
65
|
guard-rspec (~> 2.3)
|
58
|
-
rake (~> 10.0
|
59
|
-
rb-fchange
|
60
|
-
rb-fsevent
|
61
|
-
rb-inotify
|
66
|
+
rake (~> 10.0)
|
67
|
+
rb-fchange (~> 0)
|
68
|
+
rb-fsevent (~> 0)
|
69
|
+
rb-inotify (~> 0)
|
62
70
|
rspec (~> 2.12)
|
63
71
|
thebigdb!
|
64
72
|
webmock (~> 1.9)
|
data/README.md
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
[![Build Status](https://secure.travis-ci.org/thebigdb/thebigdb-ruby.png)](http://travis-ci.org/thebigdb/thebigdb-ruby)
|
4
4
|
|
5
|
-
A simple ruby wrapper for making requests to the API of [TheBigDB.com](http://thebigdb.com). [Full API documentation](http://
|
5
|
+
A simple ruby wrapper for making requests to the API of [TheBigDB.com](http://thebigdb.com). [Full API documentation](http://thebigdb.com/api).
|
6
6
|
|
7
7
|
## Install
|
8
8
|
|
@@ -14,18 +14,18 @@ The following actions return a TheBigDB::StatementRequest object, on which you c
|
|
14
14
|
The request will be executed once you call regular methods of Hash on it (``each_pair``, ``[key]``, etc.), or force it with ``load``.
|
15
15
|
The Hash returned represents the server's JSON response.
|
16
16
|
|
17
|
-
### Search \([api doc](http://
|
17
|
+
### Search \([api doc](http://thebigdb.com/api#statements-search)\)
|
18
18
|
|
19
|
-
TheBigDB.search("
|
20
|
-
TheBigDB.search(
|
21
|
-
TheBigDB.search(
|
19
|
+
TheBigDB.search(subject: {match: "James"}, property: "job", answer: "President of the United States")
|
20
|
+
TheBigDB.search(subject: "London", property: "population").with(period: {on: "2007-06-05"})
|
21
|
+
TheBigDB.search("iPhone") # will fulltext search "iPhone" in all fields
|
22
22
|
|
23
|
-
### Create \([api doc](http://
|
23
|
+
### Create \([api doc](http://thebigdb.com/api#statements-create)\)
|
24
24
|
|
25
|
-
TheBigDB.create("iPhone 5", "weight", "112 grams")
|
26
|
-
TheBigDB.create("Bill Clinton", "job", "President of the United States").with(period: {from: "1993-01-20 12:00:00", to: "2001-01-20
|
25
|
+
TheBigDB.create(subject: "iPhone 5", property: "weight", answer: "112 grams")
|
26
|
+
TheBigDB.create(subject: "Bill Clinton", property: "job", answer: "President of the United States").with(period: {from: "1993-01-20 12:00:00", to: "2001-01-20 12:00:00"})
|
27
27
|
|
28
|
-
### Show \([api doc](http://
|
28
|
+
### Show \([api doc](http://thebigdb.com/api#statements-show)\), Upvote \([api doc](http://thebigdb.com/api#statements-upvote)\) and Downvote \([api doc](http://thebigdb.com/api#statements-downvote)\)
|
29
29
|
|
30
30
|
TheBigDB.show("id-of-the-sentence")
|
31
31
|
TheBigDB.upvote("id-of-the-sentence")
|
@@ -38,7 +38,7 @@ That's it!
|
|
38
38
|
If you want more details on what is sent and what is received, you can use the generic TheBigDB::Statement method. It returns a TheBigDB::Request object.
|
39
39
|
It has several readable attributes:
|
40
40
|
|
41
|
-
request = TheBigDB::Statement(:search, {nodes:
|
41
|
+
request = TheBigDB::Statement(:search, {nodes: {subject: "iPhone", property: "weight"}})
|
42
42
|
request.http # Net::HTTP
|
43
43
|
request.http_request # subclass of Net::HTTPGenericRequest (Net::HTTP::Get or Net::HTTP::Post)
|
44
44
|
request.http_response # subclass of Net::HTTPResponse (e.g. Net::HTTPOK)
|
@@ -48,11 +48,11 @@ module TheBigDB
|
|
48
48
|
end
|
49
49
|
|
50
50
|
# Shortcuts to actions
|
51
|
-
def self.search(
|
51
|
+
def self.search(nodes = {})
|
52
52
|
StatementRequest.new("search").with("nodes" => nodes)
|
53
53
|
end
|
54
54
|
|
55
|
-
def self.create(
|
55
|
+
def self.create(nodes = {})
|
56
56
|
StatementRequest.new("create").with("nodes" => nodes)
|
57
57
|
end
|
58
58
|
|
data/lib/thebigdb/version.rb
CHANGED
@@ -5,7 +5,7 @@ describe "Statement" do
|
|
5
5
|
before do
|
6
6
|
stub_request(:get, @request_path.call("search")).to_return(:body => '{"server_says": "hello world"}')
|
7
7
|
|
8
|
-
@request = TheBigDB::Statement(:search, nodes:
|
8
|
+
@request = TheBigDB::Statement(:search, nodes: {subject: "a a", property: "b"}, contexts: [{property: "foo", answer: "bar"}])
|
9
9
|
end
|
10
10
|
|
11
11
|
it "sets the correct data_sent instance variable" do
|
@@ -15,7 +15,7 @@ describe "Statement" do
|
|
15
15
|
"port" => TheBigDB.api_port,
|
16
16
|
"path" => "/v#{TheBigDB.api_version}/statements/search",
|
17
17
|
"method" => "GET",
|
18
|
-
"params" => {"nodes" => {"
|
18
|
+
"params" => {"nodes" => {"subject" => "a a", "property" => "b"}, "contexts" => {"0" => {"property" => "foo", "answer" => "bar"}}}
|
19
19
|
}
|
20
20
|
end
|
21
21
|
|
@@ -33,27 +33,27 @@ describe "StatementRequest" do
|
|
33
33
|
end
|
34
34
|
|
35
35
|
it "makes normal requests" do
|
36
|
-
@search = TheBigDB.search("a a", "b", {match: "blue"})
|
36
|
+
@search = TheBigDB.search(subject: "a a", property: "b", answer: {match: "blue"})
|
37
37
|
@search.with(page: 2)
|
38
|
-
@search.params.should == {"nodes" =>
|
38
|
+
@search.params.should == {"nodes" => {subject: "a a", property: "b", answer: {match: "blue"}}, "page" => 2}
|
39
39
|
end
|
40
40
|
|
41
41
|
it "cache the response unless the params are modified, or asked to" do
|
42
42
|
stub_request(:get, @request_path.call("search")).to_return(:body => '{status: "success", statements: []}')
|
43
43
|
|
44
|
-
response = TheBigDB.search("a", "b", {match: "blue"}).with(page: 2)
|
44
|
+
response = TheBigDB.search(subject: "a", property: "b", answer: {match: "blue"}).with(page: 2)
|
45
45
|
response.load
|
46
46
|
response.load
|
47
47
|
|
48
|
-
response = TheBigDB.search("a", "b", {match: "red"}).with(page: 2)
|
48
|
+
response = TheBigDB.search(subject: "a", property: "b", answer: {match: "red"}).with(page: 2)
|
49
49
|
response.load
|
50
50
|
response.load!
|
51
51
|
|
52
52
|
a_request(:get, @request_path.call("search"))
|
53
|
-
.with(query: hash_including({"nodes" =>
|
53
|
+
.with(query: hash_including({"nodes" => {subject: "a", property: "b", answer: {match: "blue"}}, "page" => "2"})).should have_been_made.once
|
54
54
|
|
55
55
|
a_request(:get, @request_path.call("search"))
|
56
|
-
.with(query: hash_including({"nodes" =>
|
56
|
+
.with(query: hash_including({"nodes" => {subject: "a", property: "b", answer: {match: "red"}}, "page" => "2"})).should have_been_made.times(2)
|
57
57
|
end
|
58
58
|
|
59
59
|
it "has standard actions correctly binded" do
|
@@ -63,7 +63,7 @@ describe "StatementRequest" do
|
|
63
63
|
stub_request(:post, @request_path.call("upvote")).to_return(:body => '{status: "success"}')
|
64
64
|
stub_request(:post, @request_path.call("downvote")).to_return(:body => '{status: "success"}')
|
65
65
|
|
66
|
-
TheBigDB.search("a", "b", {match: "blue"}).load
|
66
|
+
TheBigDB.search(subject: "a", property: "b", answer: {match: "blue"}).load
|
67
67
|
TheBigDB.show("foobar").load
|
68
68
|
TheBigDB.create("foobar").load
|
69
69
|
TheBigDB.upvote("foobar").load
|
data/thebigdb.gemspec
CHANGED
@@ -14,12 +14,12 @@ Gem::Specification.new do |s|
|
|
14
14
|
|
15
15
|
s.add_runtime_dependency "rack", "~> 1.4"
|
16
16
|
|
17
|
-
s.add_development_dependency "rake", "~> 10.0
|
17
|
+
s.add_development_dependency "rake", "~> 10.0"
|
18
18
|
s.add_development_dependency "rspec", "~> 2.12"
|
19
19
|
s.add_development_dependency "guard-rspec", "~> 2.3"
|
20
|
-
s.add_development_dependency "rb-inotify"
|
21
|
-
s.add_development_dependency "rb-fsevent"
|
22
|
-
s.add_development_dependency "rb-fchange"
|
20
|
+
s.add_development_dependency "rb-inotify", "~> 0"
|
21
|
+
s.add_development_dependency "rb-fsevent", "~> 0"
|
22
|
+
s.add_development_dependency "rb-fchange", "~> 0"
|
23
23
|
s.add_development_dependency "webmock", "~> 1.9"
|
24
24
|
|
25
25
|
|
metadata
CHANGED
@@ -1,142 +1,125 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: thebigdb
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
5
|
-
prerelease:
|
4
|
+
version: 1.3.0
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Christophe Maximin
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date:
|
11
|
+
date: 2014-01-03 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
14
|
name: rack
|
16
15
|
requirement: !ruby/object:Gem::Requirement
|
17
|
-
none: false
|
18
16
|
requirements:
|
19
|
-
- - ~>
|
17
|
+
- - "~>"
|
20
18
|
- !ruby/object:Gem::Version
|
21
19
|
version: '1.4'
|
22
20
|
type: :runtime
|
23
21
|
prerelease: false
|
24
22
|
version_requirements: !ruby/object:Gem::Requirement
|
25
|
-
none: false
|
26
23
|
requirements:
|
27
|
-
- - ~>
|
24
|
+
- - "~>"
|
28
25
|
- !ruby/object:Gem::Version
|
29
26
|
version: '1.4'
|
30
27
|
- !ruby/object:Gem::Dependency
|
31
28
|
name: rake
|
32
29
|
requirement: !ruby/object:Gem::Requirement
|
33
|
-
none: false
|
34
30
|
requirements:
|
35
|
-
- - ~>
|
31
|
+
- - "~>"
|
36
32
|
- !ruby/object:Gem::Version
|
37
|
-
version: 10.0
|
33
|
+
version: '10.0'
|
38
34
|
type: :development
|
39
35
|
prerelease: false
|
40
36
|
version_requirements: !ruby/object:Gem::Requirement
|
41
|
-
none: false
|
42
37
|
requirements:
|
43
|
-
- - ~>
|
38
|
+
- - "~>"
|
44
39
|
- !ruby/object:Gem::Version
|
45
|
-
version: 10.0
|
40
|
+
version: '10.0'
|
46
41
|
- !ruby/object:Gem::Dependency
|
47
42
|
name: rspec
|
48
43
|
requirement: !ruby/object:Gem::Requirement
|
49
|
-
none: false
|
50
44
|
requirements:
|
51
|
-
- - ~>
|
45
|
+
- - "~>"
|
52
46
|
- !ruby/object:Gem::Version
|
53
47
|
version: '2.12'
|
54
48
|
type: :development
|
55
49
|
prerelease: false
|
56
50
|
version_requirements: !ruby/object:Gem::Requirement
|
57
|
-
none: false
|
58
51
|
requirements:
|
59
|
-
- - ~>
|
52
|
+
- - "~>"
|
60
53
|
- !ruby/object:Gem::Version
|
61
54
|
version: '2.12'
|
62
55
|
- !ruby/object:Gem::Dependency
|
63
56
|
name: guard-rspec
|
64
57
|
requirement: !ruby/object:Gem::Requirement
|
65
|
-
none: false
|
66
58
|
requirements:
|
67
|
-
- - ~>
|
59
|
+
- - "~>"
|
68
60
|
- !ruby/object:Gem::Version
|
69
61
|
version: '2.3'
|
70
62
|
type: :development
|
71
63
|
prerelease: false
|
72
64
|
version_requirements: !ruby/object:Gem::Requirement
|
73
|
-
none: false
|
74
65
|
requirements:
|
75
|
-
- - ~>
|
66
|
+
- - "~>"
|
76
67
|
- !ruby/object:Gem::Version
|
77
68
|
version: '2.3'
|
78
69
|
- !ruby/object:Gem::Dependency
|
79
70
|
name: rb-inotify
|
80
71
|
requirement: !ruby/object:Gem::Requirement
|
81
|
-
none: false
|
82
72
|
requirements:
|
83
|
-
- -
|
73
|
+
- - "~>"
|
84
74
|
- !ruby/object:Gem::Version
|
85
75
|
version: '0'
|
86
76
|
type: :development
|
87
77
|
prerelease: false
|
88
78
|
version_requirements: !ruby/object:Gem::Requirement
|
89
|
-
none: false
|
90
79
|
requirements:
|
91
|
-
- -
|
80
|
+
- - "~>"
|
92
81
|
- !ruby/object:Gem::Version
|
93
82
|
version: '0'
|
94
83
|
- !ruby/object:Gem::Dependency
|
95
84
|
name: rb-fsevent
|
96
85
|
requirement: !ruby/object:Gem::Requirement
|
97
|
-
none: false
|
98
86
|
requirements:
|
99
|
-
- -
|
87
|
+
- - "~>"
|
100
88
|
- !ruby/object:Gem::Version
|
101
89
|
version: '0'
|
102
90
|
type: :development
|
103
91
|
prerelease: false
|
104
92
|
version_requirements: !ruby/object:Gem::Requirement
|
105
|
-
none: false
|
106
93
|
requirements:
|
107
|
-
- -
|
94
|
+
- - "~>"
|
108
95
|
- !ruby/object:Gem::Version
|
109
96
|
version: '0'
|
110
97
|
- !ruby/object:Gem::Dependency
|
111
98
|
name: rb-fchange
|
112
99
|
requirement: !ruby/object:Gem::Requirement
|
113
|
-
none: false
|
114
100
|
requirements:
|
115
|
-
- -
|
101
|
+
- - "~>"
|
116
102
|
- !ruby/object:Gem::Version
|
117
103
|
version: '0'
|
118
104
|
type: :development
|
119
105
|
prerelease: false
|
120
106
|
version_requirements: !ruby/object:Gem::Requirement
|
121
|
-
none: false
|
122
107
|
requirements:
|
123
|
-
- -
|
108
|
+
- - "~>"
|
124
109
|
- !ruby/object:Gem::Version
|
125
110
|
version: '0'
|
126
111
|
- !ruby/object:Gem::Dependency
|
127
112
|
name: webmock
|
128
113
|
requirement: !ruby/object:Gem::Requirement
|
129
|
-
none: false
|
130
114
|
requirements:
|
131
|
-
- - ~>
|
115
|
+
- - "~>"
|
132
116
|
- !ruby/object:Gem::Version
|
133
117
|
version: '1.9'
|
134
118
|
type: :development
|
135
119
|
prerelease: false
|
136
120
|
version_requirements: !ruby/object:Gem::Requirement
|
137
|
-
none: false
|
138
121
|
requirements:
|
139
|
-
- - ~>
|
122
|
+
- - "~>"
|
140
123
|
- !ruby/object:Gem::Version
|
141
124
|
version: '1.9'
|
142
125
|
description: TheBigDB a simply structured open database of real life facts. See http://thebigdb.com
|
@@ -146,9 +129,9 @@ executables: []
|
|
146
129
|
extensions: []
|
147
130
|
extra_rdoc_files: []
|
148
131
|
files:
|
149
|
-
- .gitignore
|
150
|
-
- .rspec
|
151
|
-
- .travis.yml
|
132
|
+
- ".gitignore"
|
133
|
+
- ".rspec"
|
134
|
+
- ".travis.yml"
|
152
135
|
- Gemfile
|
153
136
|
- Gemfile.lock
|
154
137
|
- Guardfile
|
@@ -172,27 +155,26 @@ files:
|
|
172
155
|
- thebigdb.gemspec
|
173
156
|
homepage: http://thebigdb.com
|
174
157
|
licenses: []
|
158
|
+
metadata: {}
|
175
159
|
post_install_message:
|
176
160
|
rdoc_options: []
|
177
161
|
require_paths:
|
178
162
|
- lib
|
179
163
|
required_ruby_version: !ruby/object:Gem::Requirement
|
180
|
-
none: false
|
181
164
|
requirements:
|
182
|
-
- -
|
165
|
+
- - ">="
|
183
166
|
- !ruby/object:Gem::Version
|
184
167
|
version: '0'
|
185
168
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
186
|
-
none: false
|
187
169
|
requirements:
|
188
|
-
- -
|
170
|
+
- - ">="
|
189
171
|
- !ruby/object:Gem::Version
|
190
172
|
version: '0'
|
191
173
|
requirements: []
|
192
174
|
rubyforge_project:
|
193
|
-
rubygems_version:
|
175
|
+
rubygems_version: 2.2.0
|
194
176
|
signing_key:
|
195
|
-
specification_version:
|
177
|
+
specification_version: 4
|
196
178
|
summary: Ruby bindings for TheBigDB API
|
197
179
|
test_files:
|
198
180
|
- spec/helpers_spec.rb
|