factual-api 1.3.4 → 1.3.5

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/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ ## v1.3.5
2
+ * get a row
3
+ * change the integration test of geopulse to match the new payload
4
+
1
5
  ## v1.3.4
2
6
  * multi requests as POST
3
7
 
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # About
2
2
 
3
- This is the Factual supported Ruby driver for [Factual's public API](http://developer.factual.com/display/docs/Factual+Developer+APIs+Version+3).
3
+ This is the Factual supported Ruby driver for [Factual's public API](http://developer.factual.com).
4
4
 
5
5
 
6
6
  # Overview
@@ -53,7 +53,7 @@ factual.table("places").filters("name" => {"$bw" => "starbucks"}).rows
53
53
 
54
54
  `````ruby
55
55
  # Return entity names and non-blank websites from the Global dataset, for entities located in Thailand
56
- factual.table("global").select(:name, :website)
56
+ factual.table("places").select(:name, :website)
57
57
  .filters({"country" => "TH", "website" => {"$blank" => false}})
58
58
  ````
59
59
 
@@ -91,8 +91,8 @@ query.first["income"]
91
91
  ## More Read Examples
92
92
 
93
93
  ````ruby
94
- # 1. Specify the table Global
95
- query = factual.table("global")
94
+ # 1. Specify the table Global Places
95
+ query = factual.table("places")
96
96
  ````
97
97
 
98
98
  ````ruby
data/lib/factual/api.rb CHANGED
@@ -4,7 +4,7 @@ require 'timeout'
4
4
 
5
5
  class Factual
6
6
  class API
7
- VERSION = "1.3.4"
7
+ VERSION = "1.3.5"
8
8
  API_V3_HOST = "api.v3.factual.com"
9
9
  DRIVER_VERSION_TAG = "factual-ruby-driver-v" + VERSION
10
10
  PARAM_ALIASES = { :search => :q, :sort_asc => :sort }
@@ -31,7 +31,11 @@ class Factual
31
31
 
32
32
  def raw_get(path, query)
33
33
  path = '/' + path unless path =~ /^\//
34
- url = "http://#{@host}#{path}?#{query_string(query)}"
34
+ url = "http://#{@host}#{path}"
35
+
36
+ qs = query_string(query)
37
+ url += "?#{qs}" unless qs.empty?
38
+
35
39
  resp = make_request(url)
36
40
  payload = JSON.parse(resp.body)
37
41
  handle_payload(payload)
@@ -61,7 +65,11 @@ class Factual
61
65
  def full_path(action, path, params)
62
66
  fp = "/#{path}"
63
67
  fp += "/#{action}" unless action == :read
64
- fp += "?#{query_string(params)}"
68
+
69
+ qs = query_string(params)
70
+ fp += "?#{qs}" unless qs.empty?
71
+
72
+ fp
65
73
  end
66
74
 
67
75
  private
@@ -22,10 +22,14 @@ class Factual
22
22
  rows[index]
23
23
  end
24
24
 
25
- def rows
25
+ def data
26
26
  response["data"]
27
27
  end
28
28
 
29
+ def rows
30
+ data
31
+ end
32
+
29
33
  def total_count
30
34
  resp = @api.get(self, :include_count => true, :limit => 1)
31
35
  resp["total_row_count"]
@@ -43,6 +43,12 @@ class Factual
43
43
  offset = (page_number - 1) * limit
44
44
  Table.new(@api, @path, @params.merge(:limit => limit, :offset => offset))
45
45
  end
46
+
47
+ def row(factual_id)
48
+ @path += "/#{factual_id}"
49
+ @params = {}
50
+ return self.first
51
+ end
46
52
  end
47
53
  end
48
54
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: factual-api
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.4
4
+ version: 1.3.5
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2013-01-16 00:00:00.000000000 Z
13
+ date: 2013-04-05 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: oauth