factual-api 1.3.14 → 1.3.20
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -13
- data/CHANGELOG.md +20 -0
- data/README.md +221 -123
- data/lib/factual.rb +7 -8
- data/lib/factual/api.rb +2 -2
- data/lib/factual/query/facets.rb +1 -0
- data/lib/factual/query/resolve.rb +7 -0
- data/lib/factual/query/table.rb +1 -0
- data/lib/factual/write/flag.rb +1 -6
- metadata +35 -25
- data/lib/factual/query/geocode.rb +0 -13
- data/lib/factual/query/geopulse.rb +0 -19
checksums.yaml
CHANGED
@@ -1,15 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
|
5
|
-
data.tar.gz: !binary |-
|
6
|
-
MTcyYjY2NzJhNjdkN2EzZDg3OTJmN2Y5ZmU4ZjMxNjVkYWI4YzQ1ZQ==
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: fafdf90837e574051be839bdf2a06f8d638eefd41cd3304e4da45fb0d95e9d20
|
4
|
+
data.tar.gz: c1f6dbf964b383bd5f8f302d89b7088a4dfe621bab36f75b585cb6b9a2bca803
|
7
5
|
SHA512:
|
8
|
-
metadata.gz:
|
9
|
-
|
10
|
-
MDI0ZTU3ZGVkMjYyNDUwOWU5NzJiOWU2ODU3YTkwNDdkMzViNTNhNDkwNTAz
|
11
|
-
M2MxYmFiNWJhMjNmOGQzOTA0OTIxOWEzYWQ4YjNjMTdjOWM1YTc=
|
12
|
-
data.tar.gz: !binary |-
|
13
|
-
M2U5YjlmNWRmOTU5MTc1NDk5MjI3YTliOTEyNzA0ODFmYzg3NTVmM2M0NjFk
|
14
|
-
ODM0ZjA2NTg2YzljZWIzNjc3ZDljNWJhZTE2MjVlZTYzNDdjMGQ1YzdlMzkw
|
15
|
-
NWM1OTNiNWJmZTg0ZTEyMmJmNjg0YTZkZjUwYjhjZDVmNTcwMGM=
|
6
|
+
metadata.gz: 5780678f06356ba5fc51edc9150830c2370920585393b99dfdc0199709a7e0dbc760a0ac9bd13a449bf92f239af968b8f0baf6d2acfcd7ceab759a71cc69af21
|
7
|
+
data.tar.gz: b8c6d6753be15067ffcba561d3cd1a1288650d585180099368e34e35e3a025f1f8d40949136d489d73732a50f4890d7adcce5257fc6d08c79027431ef88b1b0f
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,23 @@
|
|
1
|
+
## v1.3.19
|
2
|
+
* re-enabled flag data parameter
|
3
|
+
* let flag.problem be checked by api, i/o in driver
|
4
|
+
* removed deprecated geocode
|
5
|
+
|
6
|
+
## v1.3.18
|
7
|
+
* added 'resolve-absolute' support
|
8
|
+
|
9
|
+
## v1.3.17
|
10
|
+
* threshold support in facets
|
11
|
+
|
12
|
+
## v1.3.16
|
13
|
+
* fixed flag closed #29
|
14
|
+
|
15
|
+
## v1.3.15
|
16
|
+
* changed flag parameters, +preferred, -data, +relocated as a problem
|
17
|
+
* sunset geopulse
|
18
|
+
* added 'threshold' to read parameters
|
19
|
+
* test cases cleanup
|
20
|
+
|
1
21
|
## v1.3.14
|
2
22
|
* configurable table name in resolve/match requests
|
3
23
|
|
data/README.md
CHANGED
@@ -1,141 +1,242 @@
|
|
1
1
|
# About
|
2
2
|
|
3
|
-
This is the Factual
|
3
|
+
This is the Factual-supported Ruby driver for [Factual's public API](http://developer.factual.com).
|
4
4
|
|
5
|
+
# Install
|
5
6
|
|
6
|
-
|
7
|
+
```bash
|
8
|
+
$ gem install factual-api
|
9
|
+
```
|
7
10
|
|
8
|
-
|
11
|
+
# Get Started
|
9
12
|
|
10
|
-
|
13
|
+
Include this driver in your project:
|
14
|
+
```ruby
|
15
|
+
require 'factual'
|
16
|
+
factual = Factual.new("YOUR_KEY", "YOUR_SECRET")
|
17
|
+
```
|
18
|
+
If you don't have a Factual API key yet, [it's free and easy to get one](https://www.factual.com/api-keys/request).
|
11
19
|
|
12
|
-
|
20
|
+
## Schema
|
21
|
+
Use the schema API call to determine which fields are available, the datatypes of those fields, and which operations (sorting, searching, writing, facetting) can be performed on each field.
|
13
22
|
|
14
|
-
|
15
|
-
|
16
|
-
factual.table("places").
|
17
|
-
|
18
|
-
.sort("name").page(2, :per => 10)
|
19
|
-
````
|
23
|
+
Full documentation: http://developer.factual.com/api-docs/#Schema
|
24
|
+
```ruby
|
25
|
+
factual.table("places-us").schema
|
26
|
+
```
|
20
27
|
|
21
|
-
|
28
|
+
## Read
|
29
|
+
Use the read API call to query data in Factual tables with any combination of full-text search, parametric filtering, and geo-location filtering.
|
22
30
|
|
23
|
-
|
31
|
+
Full documentation: http://developer.factual.com/api-docs/#Read
|
24
32
|
|
25
|
-
|
33
|
+
Related place-specific documentation:
|
34
|
+
* Categories: http://developer.factual.com/working-with-categories/
|
35
|
+
* Placerank, Sorting: http://developer.factual.com/search-placerank-and-boost/
|
26
36
|
|
27
|
-
|
37
|
+
```ruby
|
28
38
|
|
29
|
-
````bash
|
30
|
-
$ gem install factual-api
|
31
|
-
````
|
32
39
|
|
33
|
-
|
40
|
+
# Full-text search:
|
41
|
+
factual.table("places-us").search("century city mall").rows
|
34
42
|
|
35
|
-
|
36
|
-
|
37
|
-
|
43
|
+
# Row filters:
|
44
|
+
# search restaurants (http://developer.factual.com/working-with-categories/)
|
45
|
+
# note that this will return all sub-categories of 347 as well.
|
46
|
+
factual.table("places-us").filters("category_ids" => {"$includes" => 347}).rows
|
38
47
|
|
39
|
-
|
48
|
+
# search restaurants or bars
|
49
|
+
factual.table("places-us").filters("category_ids" => {"$includes_any" => [312, 347]}).rows
|
40
50
|
|
41
|
-
|
42
|
-
|
43
|
-
factual = Factual.new("YOUR_KEY", "YOUR_SECRET")
|
44
|
-
````
|
45
|
-
If you don't have a Factual API account yet, [it's free and easy to get one](https://www.factual.com/api-keys/request).
|
46
|
-
|
47
|
-
## Simple Read Examples
|
48
|
-
|
49
|
-
`````ruby
|
50
|
-
# Return entities from the Places dataset with names beginning with "starbucks"
|
51
|
-
factual.table("places").filters("name" => {"$bw" => "starbucks"}).rows
|
52
|
-
````
|
53
|
-
|
54
|
-
`````ruby
|
55
|
-
# Return entity names and non-blank websites from the Global dataset, for entities located in Thailand
|
56
|
-
factual.table("places").select(:name, :website)
|
57
|
-
.filters({"country" => "TH", "website" => {"$blank" => false}})
|
58
|
-
````
|
59
|
-
|
60
|
-
`````ruby
|
61
|
-
# Return highly rated U.S. restaurants in Los Angeles with WiFi
|
62
|
-
factual.table("restaurants")
|
63
|
-
.filters({"locality" => "los angeles", "rating" => {"$gte" => 4}, "wifi" => true}).rows
|
64
|
-
````
|
65
|
-
|
66
|
-
## Simple Places Example
|
67
|
-
|
68
|
-
````ruby
|
69
|
-
# Returns resolved entities as an array of hashes
|
70
|
-
query = factual.resolve("name" => "McDonalds",
|
71
|
-
"address" => "10451 Santa Monica Blvd",
|
72
|
-
"region" => "CA",
|
73
|
-
"postcode" => "90025")
|
74
|
-
|
75
|
-
query.first["resolved"] # true or false
|
76
|
-
query.rows # all candidate rows
|
77
|
-
````
|
78
|
-
|
79
|
-
````ruby
|
80
|
-
# Returns the nearest valid address information
|
81
|
-
query = factual.geocode(34.06021,-118.41828)
|
82
|
-
query.first
|
83
|
-
````
|
84
|
-
|
85
|
-
````ruby
|
86
|
-
# Returns georeferenced attributes generated by Factual
|
87
|
-
query = factual.geopulse(34.06021,-118.41828).select("area_statistics", "income", "housing")
|
88
|
-
query.first["income"]
|
89
|
-
````
|
90
|
-
|
91
|
-
## More Read Examples
|
92
|
-
|
93
|
-
````ruby
|
94
|
-
# 1. Specify the table Global Places
|
95
|
-
query = factual.table("places")
|
96
|
-
````
|
97
|
-
|
98
|
-
````ruby
|
99
|
-
# 2. Filter results in country US
|
100
|
-
query = query.filters("country" => "US")
|
101
|
-
````
|
102
|
-
|
103
|
-
````ruby
|
104
|
-
# 3. Search for "sushi" or "sashimi"
|
105
|
-
query = query.search("sushi", "sashimi")
|
106
|
-
````
|
107
|
-
|
108
|
-
````ruby
|
109
|
-
# 4. Filter by geolocation
|
110
|
-
query = query.geo("$circle" => {"$center" => [34.06021, -118.41828], "$meters" => 5000})
|
111
|
-
````
|
112
|
-
|
113
|
-
````ruby
|
114
|
-
# 5. Sort it
|
115
|
-
query = query.sort("name") # ascending
|
116
|
-
query = query.sort_desc("name") # descending
|
117
|
-
query = query.sort("address", "name") # sort by multiple columns
|
118
|
-
````
|
119
|
-
|
120
|
-
````ruby
|
121
|
-
# 6. Page it
|
122
|
-
query = query.page(2, :per => 10)
|
123
|
-
````
|
124
|
-
|
125
|
-
````ruby
|
126
|
-
# 7. Finally, get response in a hash or array of hashes
|
127
|
-
query.first # return one row
|
128
|
-
query.rows # return many rows
|
129
|
-
````
|
130
|
-
|
131
|
-
````ruby
|
132
|
-
# 8. Returns total row counts that matches the criteria
|
133
|
-
query.total_count
|
134
|
-
````
|
51
|
+
# search entertainment venues but NOT adult entertainment
|
52
|
+
factual.table("places-us").filters("$and" => [{"category_ids" => {"$includes" => 317}}, {"category_ids" => {"$excludes" => 318}}]).rows
|
135
53
|
|
136
|
-
#
|
54
|
+
# search for Starbucks in Los Angeles
|
55
|
+
factual.table("places-us").search("starbucks").filters("locality" => "los angeles").rows
|
56
|
+
|
57
|
+
# search for starbucks in Los Angeles or Santa Monica
|
58
|
+
factual.table("places-us").search("starbucks").filters("$or" => [{"locality" => {"$eq" =>"los angeles"}}, {"locality" => {"$eq" => "santa monica"}}]).rows
|
59
|
+
|
60
|
+
# Paging:
|
61
|
+
# search for starbucks in Los Angeles or Santa Monica (second page of results):
|
62
|
+
factual.table("places-us").search("starbucks").filters("$or" => [{"locality" => {"$eq" =>"los angeles"}}, {"locality" => {"$eq" => "santa monica"}}]).page(2, :per => 20).rows
|
63
|
+
|
64
|
+
# Geo filter:
|
65
|
+
# coffee near the Factual office
|
66
|
+
factual.table("places-us").search("coffee").geo("$circle" => {"$center" => [34.058583, -118.416582], "$meters" => 1000}).rows
|
67
|
+
|
68
|
+
# Existence threshold:
|
69
|
+
# prefer precision over recall:
|
70
|
+
factual.table("places-us").threshold("confident").rows
|
71
|
+
|
72
|
+
# Get a row by factual id:
|
73
|
+
factual.table("places-us").row("03c26917-5d66-4de9-96bc-b13066173c65")
|
74
|
+
|
75
|
+
```
|
76
|
+
|
77
|
+
## Facets
|
78
|
+
Use the facets call to get summarized counts, grouped by specified fields.
|
79
|
+
|
80
|
+
Full documentation: http://developer.factual.com/api-docs/#Facets
|
81
|
+
```ruby
|
82
|
+
# show top 5 cities that have more than 20 Starbucks in California
|
83
|
+
factual.facets("places-us").select("locality").search("starbucks").filters("region" => "CA").min_count(20).limit(5).columns
|
84
|
+
```
|
85
|
+
|
86
|
+
## Resolve
|
87
|
+
Use resolve to generate a confidence-based match to an existing set of place attributes.
|
88
|
+
|
89
|
+
Full documentation: http://developer.factual.com/api-docs/#Resolve
|
90
|
+
```ruby
|
91
|
+
# resovle from name and address info
|
92
|
+
factual.resolve("places-us").values("name" => "McDonalds", "address" => "10451 Santa Monica Blvd", "region" => "CA", "postcode" => "90025").rows
|
93
|
+
|
94
|
+
# resolve from name and geo location
|
95
|
+
factual.match("places-us").values("name" => "McDonalds", "latitude" => 34.05671, "longitude" => -118.42586).rows
|
96
|
+
```
|
97
|
+
|
98
|
+
## Match
|
99
|
+
Match is similar to resolve, but returns only the Factual ID and is intended for high volume mapping.
|
100
|
+
|
101
|
+
Full documentation: http://developer.factual.com/api-docs/#Match
|
102
|
+
```ruby
|
103
|
+
factual.table("places-us").match("name" => "McDonalds", "address" => "10451 Santa Monica Blvd", "region" => "CA", "postcode" => "90025").rows
|
104
|
+
```
|
105
|
+
|
106
|
+
## Crosswalk
|
107
|
+
Crosswalk contains third party mappings between entities.
|
108
|
+
|
109
|
+
Full documentation: http://developer.factual.com/places-crosswalk/
|
110
|
+
|
111
|
+
```ruby
|
112
|
+
# Query with factual id, and only show entites from Yelp:
|
113
|
+
factual.table("crosswalk").filters("factual_id" => "3b9e2b46-4961-4a31-b90a-b5e0aed2a45e", "namespace" => "yelp").rows
|
114
|
+
```
|
115
|
+
|
116
|
+
```ruby
|
117
|
+
# query with an entity from Foursquare:
|
118
|
+
factual.table("crosswalk").filters("namespace" => "foursquare", "namespace_id" => "4ae4df6df964a520019f21e3").rows
|
119
|
+
```
|
120
|
+
|
121
|
+
## World Geographies
|
122
|
+
World Geographies contains administrative geographies (states, counties, countries), natural geographies (rivers, oceans, continents), and assorted geographic miscallaney. This resource is intended to complement the Global Places and add utility to any geo-related content.
|
123
|
+
|
124
|
+
```ruby
|
125
|
+
# find California, USA
|
126
|
+
factual.table("world-geographies").select("contextname", "factual_id").search("los angeles").filters("name" => "California", "country" => "US", "placetype" => "region").rows
|
127
|
+
# returns 08649c86-8f76-11e1-848f-cfd5bf3ef515 as the Factual Id of "California, US"
|
128
|
+
```
|
129
|
+
|
130
|
+
```ruby
|
131
|
+
# find cities and town in California (first 20 rows)
|
132
|
+
factual.table("world-geographies").select("contextname", "factual_id").search("los angeles").filters("ancestors" => {"$includes" => "08649c86-8f76-11e1-848f-cfd5bf3ef515"}, "country" => "US", "placetype" => "locality").rows
|
133
|
+
```
|
134
|
+
|
135
|
+
## Submit
|
136
|
+
Submit new data, or update existing data. Submit behaves as an "upsert", meaning that Factual will attempt to match the provided data against any existing places first. Note: you should ALWAYS store the *commit ID* returned from the response for any future support requests.
|
137
137
|
|
138
|
-
|
138
|
+
Full documentation: http://developer.factual.com/api-docs/#Submit
|
139
|
+
|
140
|
+
Place-specific Write API documentation: http://developer.factual.com/write-api/
|
141
|
+
|
142
|
+
```ruby
|
143
|
+
new_value = {
|
144
|
+
name: "Factual",
|
145
|
+
address: "1999 Avenue of the Stars",
|
146
|
+
address_extended: "34th floor",
|
147
|
+
locality: "Los Angeles",
|
148
|
+
region: "CA",
|
149
|
+
postcode: "90067",
|
150
|
+
country: "us",
|
151
|
+
latitude: 34.058743,
|
152
|
+
longitude: -118.41694,
|
153
|
+
category_ids: [209,213],
|
154
|
+
hours: "Mon 11:30am-2pm Tue-Fri 11:30am-2pm, 5:30pm-9pm Sat-Sun closed"
|
155
|
+
}
|
156
|
+
factual.submit("us-sandbox", "a_user_id").values(new_value).write
|
157
|
+
```
|
158
|
+
|
159
|
+
Edit an existing row:
|
160
|
+
```ruby
|
161
|
+
factual.submit("us-sandbox", "a_user_id", "4e4a14fe-988c-4f03-a8e7-0efc806d0a7f").values(address_extended: "35th floor").write
|
162
|
+
```
|
163
|
+
|
164
|
+
|
165
|
+
## Flag
|
166
|
+
Use the flag API to flag problems in existing data.
|
167
|
+
|
168
|
+
Full documentation: http://developer.factual.com/api-docs/#Flag
|
169
|
+
|
170
|
+
Flag a place that is a duplicate of another. The *preferred* entity that should persist is passed as a GET parameter.
|
171
|
+
```ruby
|
172
|
+
factual.flag("us-sandbox", "a_user_id", "4e4a14fe-988c-4f03-a8e7-0efc806d0a7f", :duplicate).preferred("9d676355-6c74-4cf6-8c4a-03fdaaa2d66a").write
|
173
|
+
```
|
174
|
+
|
175
|
+
Flag a place that is closed.
|
176
|
+
```ruby
|
177
|
+
factual.flag("us-sandbox", "a_user_id", "4e4a14fe-988c-4f03-a8e7-0efc806d0a7f", :closed).comment("was shut down when I went there yesterday.").write
|
178
|
+
```
|
179
|
+
|
180
|
+
Flag a place that has been relocated, so that it will redirect to the new location. The *preferred* entity (the current location) is passed as a GET parameter. The old location is identified in the URL.
|
181
|
+
```ruby
|
182
|
+
factual.flag("us-sandbox", "a_user_id", "4e4a14fe-988c-4f03-a8e7-0efc806d0a7f", :relocated).preferred("9d676355-6c74-4cf6-8c4a-03fdaaa2d66a").write
|
183
|
+
```
|
184
|
+
|
185
|
+
## Clear
|
186
|
+
The clear API is used to signal that an existing attribute's value should be reset.
|
187
|
+
|
188
|
+
Full documentation: http://developer.factual.com/api-docs/#Clear
|
189
|
+
```ruby
|
190
|
+
factual.clear("us-sandbox", "a_user_id", "4e4a14fe-988c-4f03-a8e7-0efc806d0a7f").fields(:latitude, :longitude).write
|
191
|
+
```
|
192
|
+
|
193
|
+
## Boost
|
194
|
+
The boost API is used to signal rows that should appear higher in search results.
|
195
|
+
|
196
|
+
Full documentation: http://developer.factual.com/api-docs/#Boost
|
197
|
+
```ruby
|
198
|
+
factual.boost("us-sandbox", "a_user_id", "4e4a14fe-988c-4f03-a8e7-0efc806d0a7f", "local business data").write
|
199
|
+
```
|
200
|
+
|
201
|
+
## Multi
|
202
|
+
Make up to three simultaneous requests over a single HTTP connection. Note: while the requests are performed in parallel, the final response is not returned until all contained requests are complete. As such, you shouldn't use multi if you want non-blocking behavior. Also note that a contained response may include an API error message, if appropriate.
|
203
|
+
|
204
|
+
Full documentation: http://developer.factual.com/api-docs/#Multi
|
205
|
+
|
206
|
+
```ruby
|
207
|
+
# Query read and facets in one request:
|
208
|
+
read_query = factual.table("places-us").search("starbucks").geo("$circle" => {"$center" => [34.041195, -118.331518], "$meters" => 1000})
|
209
|
+
facets_query = factual.facets("places-us").search("starbucks").filters("region" => "CA").select("locality").min_count(20).limit(5)
|
210
|
+
factual.multi(read: read_query, facets: facets_query)
|
211
|
+
```
|
212
|
+
|
213
|
+
|
214
|
+
## Error Handling
|
215
|
+
The errors are thrown as StandardError instances.
|
216
|
+
|
217
|
+
## Debug Mode
|
218
|
+
To see detailed debug information at runtime, you can turn on Debug Mode:
|
219
|
+
```ruby
|
220
|
+
# start debug mode
|
221
|
+
factual = Factual.new(key, secret, :debug => true)
|
222
|
+
|
223
|
+
# run your querie(s)
|
224
|
+
|
225
|
+
```
|
226
|
+
Debug Mode will output useful information about what's going on, including the request sent to Factual and the response from Factual, outputting to stdout and stderr.
|
227
|
+
|
228
|
+
|
229
|
+
## Custom timeouts
|
230
|
+
You can set the request timeout (in seconds):
|
231
|
+
```ruby
|
232
|
+
# set the timeout as 1 second
|
233
|
+
factual = Factual.new(key, secret, :timeout => 1)
|
234
|
+
|
235
|
+
```
|
236
|
+
You will get [Timeout::Error: execution expired] for custom timeout errors.
|
237
|
+
|
238
|
+
|
239
|
+
# Where to Get Help
|
139
240
|
|
140
241
|
If you think you've identified a specific bug in this driver, please file an issue in the github repo. Please be as specific as you can, including:
|
141
242
|
|
@@ -144,7 +245,4 @@ If you think you've identified a specific bug in this driver, please file an iss
|
|
144
245
|
* What actually happened
|
145
246
|
* Detailed stack trace and/or line numbers
|
146
247
|
|
147
|
-
If you are having any other kind of issue, such as unexpected data or strange behaviour from Factual's API (or you're just not sure WHAT'S going on), please contact us through [
|
148
|
-
|
149
|
-
# Ruby Driver Wiki
|
150
|
-
https://github.com/Factual/factual-ruby-driver/wiki
|
248
|
+
If you are having any other kind of issue, such as unexpected data or strange behaviour from Factual's API (or you're just not sure WHAT'S going on), please contact us through the [Factual support site](http://support.factual.com/factual).
|
data/lib/factual.rb
CHANGED
@@ -13,8 +13,6 @@ require File.expand_path('../factual/query/table', __FILE__)
|
|
13
13
|
require File.expand_path('../factual/query/facets', __FILE__)
|
14
14
|
require File.expand_path('../factual/query/match', __FILE__)
|
15
15
|
require File.expand_path('../factual/query/resolve', __FILE__)
|
16
|
-
require File.expand_path('../factual/query/geocode', __FILE__)
|
17
|
-
require File.expand_path('../factual/query/geopulse', __FILE__)
|
18
16
|
require File.expand_path('../factual/write/base', __FILE__)
|
19
17
|
require File.expand_path('../factual/write/flag', __FILE__)
|
20
18
|
require File.expand_path('../factual/write/boost', __FILE__)
|
@@ -61,12 +59,13 @@ class Factual
|
|
61
59
|
Query::Resolve.new(@api, table, :values => values)
|
62
60
|
end
|
63
61
|
|
64
|
-
def
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
62
|
+
def resolve_absolute(*args)
|
63
|
+
table = 'places'
|
64
|
+
values = args[-1]
|
65
|
+
if args.first.is_a?(String)
|
66
|
+
table = args[0]
|
67
|
+
end
|
68
|
+
Query::ResolveAbsolute.new(@api, table, :values => values)
|
70
69
|
end
|
71
70
|
|
72
71
|
def get(path, query={})
|
data/lib/factual/api.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
class Factual
|
2
2
|
class API
|
3
|
-
VERSION = "1.3.
|
3
|
+
VERSION = "1.3.20"
|
4
4
|
API_V3_HOST = "api.v3.factual.com"
|
5
5
|
DRIVER_VERSION_TAG = "factual-ruby-driver-v" + VERSION
|
6
6
|
PARAM_ALIASES = { :search => :q, :sort_asc => :sort }
|
@@ -98,7 +98,7 @@ class Factual
|
|
98
98
|
|
99
99
|
def handle_payload(payload)
|
100
100
|
raise StandardError.new(payload.to_json) unless payload["status"] == "ok"
|
101
|
-
payload["response"]
|
101
|
+
payload["response"] || payload["status"]
|
102
102
|
end
|
103
103
|
|
104
104
|
def make_request(url, body=nil, method=:get)
|
data/lib/factual/query/facets.rb
CHANGED
data/lib/factual/query/table.rb
CHANGED
data/lib/factual/write/flag.rb
CHANGED
@@ -1,8 +1,7 @@
|
|
1
1
|
class Factual
|
2
2
|
module Write
|
3
3
|
class Flag < Base
|
4
|
-
|
5
|
-
VALID_KEYS = [:table, :factual_id, :problem, :user, :comment, :debug, :reference, :fields, :data]
|
4
|
+
VALID_KEYS = [:table, :factual_id, :data, :problem, :user, :comment, :debug, :reference, :fields, :preferred]
|
6
5
|
|
7
6
|
def initialize(api, params)
|
8
7
|
validate_params(params)
|
@@ -25,10 +24,6 @@ class Factual
|
|
25
24
|
params.keys.each do |key|
|
26
25
|
raise "Invalid flag option: #{key}" unless VALID_KEYS.include?(key)
|
27
26
|
end
|
28
|
-
|
29
|
-
unless PROBLEMS.include?(params[:problem])
|
30
|
-
raise "Flag problem should be one of the following: #{PROBLEMS.join(", ")}"
|
31
|
-
end
|
32
27
|
end
|
33
28
|
end
|
34
29
|
end
|
metadata
CHANGED
@@ -1,62 +1,74 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: factual-api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.3.
|
4
|
+
version: 1.3.20
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
|
-
- Rudiger Lippert
|
8
7
|
- Forrest Cao
|
9
|
-
|
8
|
+
- Hao Hong
|
9
|
+
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2020-11-10 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: oauth
|
16
16
|
requirement: !ruby/object:Gem::Requirement
|
17
17
|
requirements:
|
18
|
-
- -
|
18
|
+
- - "~>"
|
19
|
+
- !ruby/object:Gem::Version
|
20
|
+
version: 0.4.4
|
21
|
+
- - ">="
|
19
22
|
- !ruby/object:Gem::Version
|
20
23
|
version: 0.4.4
|
21
24
|
type: :runtime
|
22
25
|
prerelease: false
|
23
26
|
version_requirements: !ruby/object:Gem::Requirement
|
24
27
|
requirements:
|
25
|
-
- -
|
28
|
+
- - "~>"
|
29
|
+
- !ruby/object:Gem::Version
|
30
|
+
version: 0.4.4
|
31
|
+
- - ">="
|
26
32
|
- !ruby/object:Gem::Version
|
27
33
|
version: 0.4.4
|
28
34
|
- !ruby/object:Gem::Dependency
|
29
35
|
name: json
|
30
36
|
requirement: !ruby/object:Gem::Requirement
|
31
37
|
requirements:
|
32
|
-
- -
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '2.0'
|
41
|
+
- - ">="
|
33
42
|
- !ruby/object:Gem::Version
|
34
|
-
version:
|
43
|
+
version: 2.0.0
|
35
44
|
type: :runtime
|
36
45
|
prerelease: false
|
37
46
|
version_requirements: !ruby/object:Gem::Requirement
|
38
47
|
requirements:
|
39
|
-
- -
|
48
|
+
- - "~>"
|
49
|
+
- !ruby/object:Gem::Version
|
50
|
+
version: '2.0'
|
51
|
+
- - ">="
|
40
52
|
- !ruby/object:Gem::Version
|
41
|
-
version:
|
53
|
+
version: 2.0.0
|
42
54
|
- !ruby/object:Gem::Dependency
|
43
55
|
name: rspec
|
44
56
|
requirement: !ruby/object:Gem::Requirement
|
45
57
|
requirements:
|
46
|
-
- -
|
58
|
+
- - "~>"
|
47
59
|
- !ruby/object:Gem::Version
|
48
60
|
version: '0'
|
49
61
|
type: :development
|
50
62
|
prerelease: false
|
51
63
|
version_requirements: !ruby/object:Gem::Requirement
|
52
64
|
requirements:
|
53
|
-
- -
|
65
|
+
- - "~>"
|
54
66
|
- !ruby/object:Gem::Version
|
55
67
|
version: '0'
|
56
68
|
description: Factual's official Ruby driver for the Factual public API.
|
57
69
|
email:
|
58
|
-
-
|
59
|
-
-
|
70
|
+
- forrest@foursquare.com
|
71
|
+
- honghao@foursquare.com
|
60
72
|
executables: []
|
61
73
|
extensions: []
|
62
74
|
extra_rdoc_files: []
|
@@ -68,8 +80,6 @@ files:
|
|
68
80
|
- lib/factual/multi.rb
|
69
81
|
- lib/factual/query/base.rb
|
70
82
|
- lib/factual/query/facets.rb
|
71
|
-
- lib/factual/query/geocode.rb
|
72
|
-
- lib/factual/query/geopulse.rb
|
73
83
|
- lib/factual/query/match.rb
|
74
84
|
- lib/factual/query/resolve.rb
|
75
85
|
- lib/factual/query/table.rb
|
@@ -80,26 +90,26 @@ files:
|
|
80
90
|
- lib/factual/write/insert.rb
|
81
91
|
- lib/factual/write/submit.rb
|
82
92
|
homepage: http://github.com/Factual/factual-ruby-driver
|
83
|
-
licenses:
|
93
|
+
licenses:
|
94
|
+
- Apache-2.0
|
84
95
|
metadata: {}
|
85
|
-
post_install_message:
|
96
|
+
post_install_message:
|
86
97
|
rdoc_options: []
|
87
98
|
require_paths:
|
88
99
|
- lib
|
89
100
|
required_ruby_version: !ruby/object:Gem::Requirement
|
90
101
|
requirements:
|
91
|
-
- -
|
102
|
+
- - ">="
|
92
103
|
- !ruby/object:Gem::Version
|
93
|
-
version:
|
104
|
+
version: 2.0.0
|
94
105
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
95
106
|
requirements:
|
96
|
-
- -
|
107
|
+
- - ">="
|
97
108
|
- !ruby/object:Gem::Version
|
98
|
-
version: 1.
|
109
|
+
version: 1.8.7
|
99
110
|
requirements: []
|
100
|
-
|
101
|
-
|
102
|
-
signing_key:
|
111
|
+
rubygems_version: 3.1.2
|
112
|
+
signing_key:
|
103
113
|
specification_version: 4
|
104
114
|
summary: Ruby driver for Factual
|
105
115
|
test_files: []
|
@@ -1,19 +0,0 @@
|
|
1
|
-
class Factual
|
2
|
-
module Query
|
3
|
-
class Geopulse < Base
|
4
|
-
def initialize(api, lat, lng, params={})
|
5
|
-
@path = "geopulse/context"
|
6
|
-
@action = :read
|
7
|
-
@lat = lat
|
8
|
-
@lng = lng
|
9
|
-
|
10
|
-
@params = {:geo => {"$point" => [lat, lng]}}.merge(params)
|
11
|
-
super(api, @params)
|
12
|
-
end
|
13
|
-
|
14
|
-
def select(*args)
|
15
|
-
self.class.new(@api, @lat, @lng, :select => form_value(args))
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|