thebigdb 1.2.3 → 1.3.0

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.
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
@@ -16,5 +16,7 @@ log/*
16
16
  *~
17
17
  *.swp
18
18
  .rvmrc
19
+ .versions.conf
20
+ .ruby-version
19
21
  *.gem
20
22
  tmp/*
data/.travis.yml CHANGED
@@ -1,5 +1,5 @@
1
1
  language: ruby
2
2
  rvm:
3
- - 1.9.2
4
3
  - 1.9.3
5
- - 2.0.0
4
+ - 2.0.0
5
+ - 2.1.0
data/Gemfile.lock CHANGED
@@ -1,52 +1,60 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- thebigdb (1.2.3)
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.3)
11
- coderay (1.0.9)
12
- crack (0.3.2)
13
- diff-lcs (1.2.2)
14
- ffi (1.6.0)
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 (1.7.0)
19
+ guard (2.2.5)
17
20
  formatador (>= 0.2.4)
18
- listen (>= 0.6.0)
19
- lumberjack (>= 1.0.2)
20
- pry (>= 0.9.10)
21
- thor (>= 0.14.6)
22
- guard-rspec (2.5.1)
23
- guard (>= 1.1)
24
- rspec (~> 2.11)
25
- listen (0.7.3)
26
- lumberjack (1.0.3)
27
- method_source (0.8.1)
28
- pry (0.9.12)
29
- coderay (~> 1.0.5)
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.0.4)
39
+ rake (10.1.1)
34
40
  rb-fchange (0.0.6)
35
41
  ffi
36
- rb-fsevent (0.9.3)
37
- rb-inotify (0.9.0)
42
+ rb-fsevent (0.9.4)
43
+ rb-inotify (0.9.3)
38
44
  ffi (>= 0.5.0)
39
- rspec (2.13.0)
40
- rspec-core (~> 2.13.0)
41
- rspec-expectations (~> 2.13.0)
42
- rspec-mocks (~> 2.13.0)
43
- rspec-core (2.13.1)
44
- rspec-expectations (2.13.0)
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.13.0)
47
- slop (3.4.4)
52
+ rspec-mocks (2.14.4)
53
+ safe_yaml (0.9.7)
54
+ slop (3.4.7)
48
55
  thor (0.18.1)
49
- webmock (1.11.0)
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.3)
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://developers.thebigdb.com/api).
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://developers.thebigdb.com/api#statements-search)\)
17
+ ### Search \([api doc](http://thebigdb.com/api#statements-search)\)
18
18
 
19
- TheBigDB.search("iPhone").with(page: 2)
20
- TheBigDB.search({match: "James"}, "job", "President of the United States")
21
- TheBigDB.search({match: "Facebook"}, "job", {match: "Executive"})
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://developers.thebigdb.com/api#statements-create)\)
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 11:59:59"})
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://developers.thebigdb.com/api#statements-show)\), Upvote \([api doc](http://developers.thebigdb.com/api#statements-upvote)\) and Downvote \([api doc](http://developers.thebigdb.com/api#statements-downvote)\)
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: ["iPhone", "weight"]})
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(*nodes)
51
+ def self.search(nodes = {})
52
52
  StatementRequest.new("search").with("nodes" => nodes)
53
53
  end
54
54
 
55
- def self.create(*nodes)
55
+ def self.create(nodes = {})
56
56
  StatementRequest.new("create").with("nodes" => nodes)
57
57
  end
58
58
 
@@ -1,8 +1,8 @@
1
1
  module TheBigDB
2
2
  module VERSION
3
3
  MAJOR = 1
4
- MINOR = 2
5
- TINY = 3
4
+ MINOR = 3
5
+ TINY = 0
6
6
 
7
7
  STRING = [MAJOR, MINOR, TINY].compact.join('.')
8
8
  end
@@ -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: ["a a", "b"])
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" => {"0" => "a a", "1" => "b"}}
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" => ["a a", "b", {match: "blue"}], "page" => 2}
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" => ["a", "b", {match: "blue"}], "page" => "2"})).should have_been_made.once
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" => ["a", "b", {match: "red"}], "page" => "2"})).should have_been_made.times(2)
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.3"
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.2.3
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: 2013-04-04 00:00:00.000000000 Z
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.3
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.3
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: 1.8.25
175
+ rubygems_version: 2.2.0
194
176
  signing_key:
195
- specification_version: 3
177
+ specification_version: 4
196
178
  summary: Ruby bindings for TheBigDB API
197
179
  test_files:
198
180
  - spec/helpers_spec.rb