kloutbg 1.1.0 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (5) hide show
  1. data/README +2 -0
  2. data/Rakefile +6 -4
  3. data/klout.gemspec +7 -4
  4. data/lib/klout.rb +50 -36
  5. metadata +22 -5
data/README CHANGED
@@ -24,6 +24,8 @@ Not supported in this Gem:
24
24
 
25
25
  Disclaimer: Author is not anyway involved w/ Klout.com
26
26
 
27
+ This is becoming a ripoff of all klout gems....
28
+
27
29
  Klout is a copyright trademark of Klout.com
28
30
 
29
31
  MIT License
data/Rakefile CHANGED
@@ -1,14 +1,16 @@
1
1
  require 'rubygems'
2
2
  require 'echoe'
3
+ require 'httparty'
3
4
  require 'fileutils'
4
5
  require './lib/klout'
5
6
 
6
- Echoe.new 'klout', '0.1.0' do |p|
7
- p.author = 'Jason Torres'
8
- p.email = 'jason.e.torres@gmail.com'
9
- p.url = 'http://github.com/jasontorres/klout'
7
+ Echoe.new 'kloutbg', '1.2.0' do |p|
8
+ p.author = 'Brad Gilreath'
9
+ p.email = 'bwgilreath@gmail.com'
10
+ p.url = 'http://github.com/bgilreath/klout'
10
11
  p.description = "Klout - Twitter Analytics"
11
12
  p.runtime_dependencies = ["typhoeus"]
13
+ p.runtime_dependencies = ["httparty"]
12
14
 
13
15
  end
14
16
 
data/klout.gemspec CHANGED
@@ -2,16 +2,16 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{kloutbg}
5
- s.version = "1.1.0"
5
+ s.version = "1.2.0"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
8
- s.authors = ["Jason Torres", "Brad Gilreath"]
8
+ s.authors = ["Jason Torres", "Brad Gilreath", "Eddy Parris"]
9
9
  s.date = %q{2010-11-04}
10
- s.description = %q{Kloutbg - Fork of Jason Torres and updated to recent Klout API. No testing.}
10
+ s.description = %q{Kloutbg - Fork of Jason Torres and updated to recent Klout API. No testing. Now using httparty like Eddy Parris.}
11
11
  s.email = %q{bwgilreath@gmail.com}
12
12
  s.extra_rdoc_files = ["lib/klout.rb", "README", "tasks/rspec.rake"]
13
13
  s.files = ["lib/klout.rb", "Manifest", "Rakefile", "README", "spec/klout_spec.rb", "spec/spec.opts", "spec/spec_helper.rb", "tasks/rspec.rake", "klout.gemspec"]
14
- s.homepage = %q{https://github.com/bgilreath/klout}
14
+ s.homepage = %q{http://github.com/bgilreath/klout}
15
15
  s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Klout", "--main", "README"]
16
16
  s.require_paths = ["lib"]
17
17
  s.rubyforge_project = %q{kloutbg}
@@ -24,10 +24,13 @@ Gem::Specification.new do |s|
24
24
 
25
25
  if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
26
26
  s.add_runtime_dependency(%q<typhoeus>, [">= 0"])
27
+ s.add_runtime_dependency(%q<httparty>, [">= 0.6.1"])
27
28
  else
28
29
  s.add_dependency(%q<typhoeus>, [">= 0"])
30
+ s.add_dependency(%q<httparty>, [">= 0.6.1"])
29
31
  end
30
32
  else
31
33
  s.add_dependency(%q<typhoeus>, [">= 0"])
34
+ s.add_dependency(%q<httparty>, [">= 0.6.1"])
32
35
  end
33
36
  end
data/lib/klout.rb CHANGED
@@ -1,5 +1,7 @@
1
1
  require 'rubygems'
2
2
  require 'json'
3
+ require 'httparty'
4
+
3
5
  $:.unshift(File.dirname(__FILE__)) unless
4
6
  $:.include?(File.dirname(__FILE__)) || $:.include?(File.expand_path(File.dirname(__FILE__)))
5
7
 
@@ -17,14 +19,19 @@ Klout.score('jasontorres')
17
19
  =end
18
20
 
19
21
 
20
- class Klout
21
- VERSION = '1.1.0'
22
+ class Kloutbg
23
+ include HTTParty
24
+ VERSION = '1.2.0'
22
25
  class << self
23
26
 
24
27
  @@base_host = "http://api.klout.com"
25
28
  @@api_version = "1"
26
29
  @@api_key = ""
27
30
 
31
+ def initialize(api_key)
32
+ @@api_key = api_key
33
+ end
34
+
28
35
  def base_host=(host)
29
36
  @@base_host = host
30
37
  end
@@ -57,50 +64,57 @@ class Klout
57
64
  #Score method: /klout
58
65
  def klout(username)
59
66
  #request_uri = "http://klout.com/api/twitter/1/klout/#{@@api_key}/#{username}.json"
60
- request_uri = "#{@@base_host}/#{@@api_version}/klout.json?key=#{@@api_key}&users=#{username}"
61
- return request(request_uri)
67
+ request_uri = "/#{@@api_version}/klout.json?key=#{@@api_key}&users=#{username}"
68
+ self.class.get(@@base_host + request_uri)
69
+ #return request(request_uri)
62
70
  end
63
71
 
64
72
  #User method: /show
65
73
  def show(username)
66
74
  #http://api.klout.com/1/users/show.[xml_or_json]?key=[your_api_key]&users=[usernames]
67
- request_uri = "#{@@base_host}/#{@@api_version}/users/show.json?key=#{@@api_key}&users=#{username}"
68
- return request(request_uri)
75
+ request_uri = "/#{@@api_version}/users/show.json?key=#{@@api_key}&users=#{username}"
76
+ self.class.get(@@base_host + request_uri)
77
+ #return request(request_uri)
69
78
  end
70
79
 
71
80
  #User method: /topics
72
81
  def topics(username)
73
82
  #http://api.klout.com/1/users/topics.[xml_or_json]?key=[your_api_key]&users=[usernames]
74
- request_uri = "#{@@base_host}/#{@@api_version}/users/topics.json?key=#{@@api_key}&users=#{username}"
75
- return request(request_uri)
83
+ request_uri = "/#{@@api_version}/users/topics.json?key=#{@@api_key}&users=#{username}"
84
+ self.class.get(@@base_host + request_uri)
85
+ #return request(request_uri)
76
86
  end
77
87
 
78
88
  #User method: /stats
79
89
  def stats(username)
80
90
  #http://api.klout.com/1/users/stats.[xml_or_json]?key=[your_api_key]&users=[usernames]
81
- request_uri = "#{@@base_host}/#{@@api_version}/users/stats.json?key=#{@@api_key}&users=#{username}"
82
- return request(request_uri)
91
+ request_uri = "/#{@@api_version}/users/stats.json?key=#{@@api_key}&users=#{username}"
92
+ self.class.get(@@base_host + request_uri)
93
+ #return request(request_uri)
83
94
  end
84
95
 
85
96
  #User method: /history
86
97
  def history(username,measure,start_date,end_date)
87
98
  #http://api.klout.com/1/users/topics.[xml_or_json]?key=[your_api_key]&measure=[measure]&start_date=[start_date]&end_date=[end_date]&users=[usernames]
88
- request_uri = "#{@@base_host}/#{@@api_version}/users/history.json?key=#{@@api_key}&measure=#{measure}&start_date=#{start_date}&end_date=#{end_date}&users=#{username}"
89
- return request(request_uri)
99
+ request_uri = "/#{@@api_version}/users/history.json?key=#{@@api_key}&measure=#{measure}&start_date=#{start_date}&end_date=#{end_date}&users=#{username}"
100
+ self.class.get(@@base_host + request_uri)
101
+ #return request(request_uri)
90
102
  end
91
103
 
92
104
  #Relationship method: /influenced_by
93
105
  def influenced_by(username)
94
106
  #http://api.klout.com/1/soi/influenced_by.[xml_or_json]?key=[your_api_key]&users=[usernames]
95
- request_uri = "#{@@base_host}/#{@@api_version}/soi/influenced_by.json?key=#{@@api_key}&users=#{username}"
96
- return request(request_uri)
107
+ request_uri = "/#{@@api_version}/soi/influenced_by.json?key=#{@@api_key}&users=#{username}"
108
+ self.class.get(@@base_host + request_uri)
109
+ #return request(request_uri)
97
110
  end
98
111
 
99
112
  #Relationship method: /influencer_of
100
113
  def influencer_of(username)
101
114
  #http://api.klout.com/1/soi/influencer_of.[xml_or_json]?key=[your_api_key]&users=[usernames]
102
- request_uri = "#{@@base_host}/#{@@api_version}/soi/influencer_of.json?key=#{@@api_key}&users=#{username}"
103
- return request(request_uri)
115
+ request_uri = "/#{@@api_version}/soi/influencer_of.json?key=#{@@api_key}&users=#{username}"
116
+ self.class.get(@@base_host + request_uri)
117
+ #return request(request_uri)
104
118
  end
105
119
 
106
120
  #Topic method: /search
@@ -109,26 +123,26 @@ class Klout
109
123
  #Topic method: /verify
110
124
  #Not supported here yet
111
125
 
112
- def request(request_uri)
113
- url = URI.parse(request_uri)
114
- response = Net::HTTP.start(url.host, url.port) { |http|
115
- http.get(url.path)
116
- }
126
+ #def request(request_uri)
127
+ # url = URI.parse(request_uri)
128
+ # response = Net::HTTP.start(url.host, url.port) { |http|
129
+ # http.get(url.path)
130
+ # }
117
131
 
118
- case response
119
- when Net::HTTPSuccess
120
- if response.body
121
- begin
122
- JSON.parse(response.body)
123
- rescue Exception => e
124
- puts e.backtrace
125
- false
126
- end
127
- end
128
- else
129
- response.error!
130
- end
131
- end
132
- end
132
+ # case response
133
+ # when Net::HTTPSuccess
134
+ # if response.body
135
+ # begin
136
+ # JSON.parse(response.body)
137
+ # rescue Exception => e
138
+ # puts e.backtrace
139
+ # false
140
+ # end
141
+ # end
142
+ #else
143
+ # response.error!
144
+ # end
145
+ #end
146
+ #end
133
147
 
134
148
  end
metadata CHANGED
@@ -1,17 +1,18 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kloutbg
3
3
  version: !ruby/object:Gem::Version
4
- hash: 19
4
+ hash: 31
5
5
  prerelease: false
6
6
  segments:
7
7
  - 1
8
- - 1
8
+ - 2
9
9
  - 0
10
- version: 1.1.0
10
+ version: 1.2.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - Jason Torres
14
14
  - Brad Gilreath
15
+ - Eddy Parris
15
16
  autorequire:
16
17
  bindir: bin
17
18
  cert_chain: []
@@ -33,7 +34,23 @@ dependencies:
33
34
  version: "0"
34
35
  type: :runtime
35
36
  version_requirements: *id001
36
- description: Kloutbg - Fork of Jason Torres and updated to recent Klout API. No testing.
37
+ - !ruby/object:Gem::Dependency
38
+ name: httparty
39
+ prerelease: false
40
+ requirement: &id002 !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ">="
44
+ - !ruby/object:Gem::Version
45
+ hash: 5
46
+ segments:
47
+ - 0
48
+ - 6
49
+ - 1
50
+ version: 0.6.1
51
+ type: :runtime
52
+ version_requirements: *id002
53
+ description: Kloutbg - Fork of Jason Torres and updated to recent Klout API. No testing. Now using httparty like Eddy Parris.
37
54
  email: bwgilreath@gmail.com
38
55
  executables: []
39
56
 
@@ -54,7 +71,7 @@ files:
54
71
  - tasks/rspec.rake
55
72
  - klout.gemspec
56
73
  has_rdoc: true
57
- homepage: https://github.com/bgilreath/klout
74
+ homepage: http://github.com/bgilreath/klout
58
75
  licenses: []
59
76
 
60
77
  post_install_message: