factual-api 1.3.9 → 1.3.10

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,6 @@
1
+ ## v1.3.10
2
+ * adding function for boost
3
+
1
4
  ## v1.3.9
2
5
  * adding support for following redirects
3
6
  * sunsetting monetize
data/lib/factual/api.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  class Factual
2
2
  class API
3
- VERSION = "1.3.9"
3
+ VERSION = "1.3.10"
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 }
@@ -4,6 +4,7 @@ class Factual
4
4
  def initialize(api, params)
5
5
  @api = api
6
6
  @params = params
7
+ @params_on_path = [:table, :factual_id]
7
8
  end
8
9
 
9
10
  def path
@@ -11,7 +12,7 @@ class Factual
11
12
  end
12
13
 
13
14
  def body
14
- keys = @params.keys.reject { |key| [:table, :factual_id].include?(key) }
15
+ keys = @params.keys.reject { |key| @params_on_path.include?(key) }
15
16
  keys.map { |key| "#{key}=#{CGI.escape(stringify(@params[key]))}" }.join("&")
16
17
  end
17
18
 
@@ -0,0 +1,31 @@
1
+ class Factual
2
+ module Write
3
+ class Boost < Base
4
+ VALID_KEYS = [:table, :factual_id, :q, :boost, :user]
5
+
6
+ def initialize(api, params)
7
+ validate_params(params)
8
+ super(api, params)
9
+ @params_on_path.delete(:factual_id)
10
+ end
11
+
12
+ VALID_KEYS.each do |key|
13
+ define_method(key) do |*args|
14
+ Boost.new(@api, @params.merge(key => form_value(args)))
15
+ end
16
+ end
17
+
18
+ def path
19
+ "/t/#{@params[:table]}/boost"
20
+ end
21
+
22
+ private
23
+
24
+ def validate_params(params)
25
+ params.keys.each do |key|
26
+ raise "Invalid boost option: #{key}" unless VALID_KEYS.include?(key)
27
+ end
28
+ end
29
+ end
30
+ end
31
+ end
data/lib/factual.rb CHANGED
@@ -17,6 +17,7 @@ require File.expand_path('../factual/query/geocode', __FILE__)
17
17
  require File.expand_path('../factual/query/geopulse', __FILE__)
18
18
  require File.expand_path('../factual/write/base', __FILE__)
19
19
  require File.expand_path('../factual/write/flag', __FILE__)
20
+ require File.expand_path('../factual/write/boost', __FILE__)
20
21
  require File.expand_path('../factual/write/submit', __FILE__)
21
22
  require File.expand_path('../factual/write/clear', __FILE__)
22
23
  require File.expand_path('../factual/write/insert', __FILE__)
@@ -85,6 +86,16 @@ class Factual
85
86
  Write::Clear.new(@api, clear_params)
86
87
  end
87
88
 
89
+ def boost(table, user, factual_id, q)
90
+ boost_params = {
91
+ :table => table,
92
+ :factual_id => factual_id,
93
+ :q => q,
94
+ :user => user }
95
+
96
+ Write::Boost.new(@api, boost_params)
97
+ end
98
+
88
99
  def flag(table, user, factual_id, problem)
89
100
  flag_params = {
90
101
  :table => table,
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.9
4
+ version: 1.3.10
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-09-30 00:00:00.000000000 Z
13
+ date: 2013-10-22 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: oauth
@@ -78,6 +78,7 @@ files:
78
78
  - lib/factual/query/resolve.rb
79
79
  - lib/factual/query/table.rb
80
80
  - lib/factual/write/base.rb
81
+ - lib/factual/write/boost.rb
81
82
  - lib/factual/write/clear.rb
82
83
  - lib/factual/write/flag.rb
83
84
  - lib/factual/write/insert.rb