yahoo_ads_estimates 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
data/Rakefile CHANGED
@@ -59,6 +59,7 @@ begin
59
59
  gemspec.email = "josh@transfs.com"
60
60
  gemspec.homepage = "http://github.com/jkrall/yahoo_ads_estimates"
61
61
  gemspec.authors = ["Joshua Krall"]
62
+ gemspec.add_dependency('json')
62
63
  end
63
64
  Jeweler::GemcutterTasks.new
64
65
  rescue LoadError
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.1
1
+ 0.1.2
@@ -1,45 +1,46 @@
1
1
  require 'uri'
2
-
2
+ require 'json'
3
+
3
4
  module Yahoo
4
5
  class AdsEstimates
5
-
6
+
6
7
  attr_reader :keyword
7
8
  attr_reader :budgets
8
9
  attr_reader :max_cpcs, :impressions, :clicks
9
-
10
+
10
11
  def initialize(_keyword, _budgets=[1.0, 50.0])
11
12
  @keyword = _keyword
12
13
  @budgets = _budgets
13
-
14
+
14
15
  @max_cpcs = []
15
16
  @impressions = []
16
17
  @clicks = []
17
-
18
+
18
19
  @budgets.each do |budget|
19
20
  begin
20
21
  json = query(budget)
21
- result = ActiveSupport::JSON::decode(json)
22
+ result = JSON.parse(json)
22
23
  @impressions << result['impressions'].to_f
23
24
  @clicks << result['clicks'].to_f
24
- @max_cpcs << result['maxBid'].to_f
25
+ @max_cpcs << result['maxBid'].to_f
25
26
  rescue
26
27
  RAILS_DEFAULT_LOGGER.info "Problem querying and parsing Yahoo, json: #{json}"
27
28
  end
28
29
  end
29
30
  end
30
-
31
+
31
32
  private
32
-
33
+
33
34
  def request_uri(_budget)
34
35
  # From: http://sem.smallbusiness.yahoo.com/searchenginemarketing/marketingcost.php
35
36
  _keyword_escaped = URI.escape(@keyword)
36
37
  "http://sem.smallbusiness.yahoo.com/inc/getKeywordForecast.php?format=json&budget=#{_budget}&keyword=#{_keyword_escaped}&target=none"
37
38
  end
38
-
39
+
39
40
  def query(_budget)
40
41
  open(request_uri(_budget)) { |f| return f.string }
41
42
  nil
42
43
  end
43
-
44
+
44
45
  end
45
46
  end
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{yahoo_ads_estimates}
8
- s.version = "0.1.1"
8
+ s.version = "0.1.2"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Joshua Krall"]
@@ -47,9 +47,12 @@ Gem::Specification.new do |s|
47
47
  s.specification_version = 3
48
48
 
49
49
  if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
50
+ s.add_runtime_dependency(%q<json>, [">= 0"])
50
51
  else
52
+ s.add_dependency(%q<json>, [">= 0"])
51
53
  end
52
54
  else
55
+ s.add_dependency(%q<json>, [">= 0"])
53
56
  end
54
57
  end
55
58
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: yahoo_ads_estimates
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Joshua Krall
@@ -11,8 +11,17 @@ cert_chain: []
11
11
 
12
12
  date: 2009-12-10 00:00:00 -06:00
13
13
  default_executable:
14
- dependencies: []
15
-
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: json
17
+ type: :runtime
18
+ version_requirement:
19
+ version_requirements: !ruby/object:Gem::Requirement
20
+ requirements:
21
+ - - ">="
22
+ - !ruby/object:Gem::Version
23
+ version: "0"
24
+ version:
16
25
  description:
17
26
  email: josh@transfs.com
18
27
  executables: []