klout 1.0.1 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1 +1 @@
1
- rvm: 1.9.2
1
+ rvm: 1.9.3
data/Gemfile CHANGED
@@ -1,13 +1,13 @@
1
1
  source "http://rubygems.org"
2
2
 
3
+ gem 'httparty'
3
4
  gem 'json'
4
- gem 'xml-simple'
5
5
 
6
6
  group :development do
7
- gem 'bundler', '~> 1.0.0'
8
- gem 'fakeweb'
9
- gem 'guard-rspec'
10
- gem 'jeweler', '~> 1.6.4'
11
- gem 'simplecov'
12
- gem 'rspec'
7
+ gem 'bundler', '> 1.0.0'
8
+ gem 'fakeweb', '~> 1.3.0'
9
+ gem 'guard-rspec', '~> 0.7.0'
10
+ gem 'jeweler', '~> 1.8.3'
11
+ gem 'simplecov', '~> 0.6.1'
12
+ gem 'rspec', '~> 2.9.0'
13
13
  end
@@ -1,6 +1,6 @@
1
- = Klout
1
+ = Klout {<img src="http://travis-ci.org/terra-firma/klout.png" />}[http://travis-ci.org/terra-firma/klout] {<img src="https://gemnasium.com/terra-firma/klout.png" alt="Dependency Status" />}[https://gemnasium.com/terra-firma/klout]
2
2
 
3
- Klout is a Ruby gem that provides a wrapper for interacting with the {Klout API}[http://developer.klout.com/docs/read/api/API].
3
+ Klout is a Ruby gem that provides a wrapper for interacting with the {Klout API}[http://klout.com/s/developers/v2]. <i>Note: this gem only supports {version 2}[http://klout.com/s/developers/v2] of the Klout API. Use the {V1 branch}[https://github.com/terra-firma/klout/tree/v1] if you need legacy support.</i>
4
4
 
5
5
  == Requirements
6
6
 
@@ -12,28 +12,40 @@ You will need a {Klout API Key}[http://developer.klout.com/member/register] in o
12
12
 
13
13
  == Usage
14
14
 
15
- Please refer to the {Klout API Documentation}[http://developer.klout.com/docs/read/api/API] for more information about the API, or follow the examples below:
15
+ Please refer to the {Klout API Documentation}[http://klout.com/s/developers/v2] for more information about the API, or follow the examples below:
16
16
 
17
- k = Klout::API.new('your_secret_api_key')
17
+ require 'klout'
18
+ k = Klout::API.new('api_key')
18
19
 
19
- There are also configuration options:
20
+ If you set the +ENV['KLOUT_API_KEY']+ environment variable you don't need to pass anything:
20
21
 
21
- k = Klout::API.new('your_secret_api_key', {:format => 'xml', :secure => true})
22
+ k = Klout::API.new('api_key')
22
23
 
23
- Once you have created a Klout object, you can interact with the API to find out how much influence certain Twitter users have. You can also pass comma-delimited string of multiple Twitter usernames as well.
24
+ Obtain the +klout_id+ for someone using their Twitter screen name or numerical Twitter ID:
24
25
 
25
- k.klout('dhh')
26
- k.klout('dhh, rails')
27
-
28
- k.show('dhh')
29
- k.topics('dhh')
30
-
31
- k.influencer_of('rails')
32
- k.influenced_by('dhh, rails')
26
+ k.identity('screen_name')
27
+ k.identity(12345678)
28
+ k.identity('screen_name', :ks) # Query a different network.
33
29
 
34
- == Travis Build Status
30
+ Once you have a +klout_id+ for someone, you can access their Klout score, influence and topics:
35
31
 
36
- {<img src="http://travis-ci.org/terra-firma/klout.png" />}[http://travis-ci.org/terra-firma/klout]
32
+ k.users klout_id
33
+ k.users klout_id, :score
34
+ k.users klout_id, :influence
35
+ k.users klout_id, :topics
36
+
37
+ And that's it!
38
+
39
+ == Caching
40
+
41
+ The {Klout API Documentation}[http://klout.com/s/developers/v2] has great information about what data can be cached safely, and for how long, in order to improve the performance of your app.
42
+
43
+ == Errors
44
+
45
+ When an error is received an instance of <code>Klout::API::Error</code> will be returned so that you can rescue accordingly:
46
+
47
+ rescue Klout::API::Error > error
48
+ ...
37
49
 
38
50
  == Contributing to Klout
39
51
 
data/Rakefile CHANGED
@@ -17,26 +17,31 @@ Jeweler::Tasks.new do |gem|
17
17
  gem.name = "klout"
18
18
  gem.homepage = "http://github.com/terra-firma/klout"
19
19
  gem.license = "MIT"
20
- gem.summary = %Q{Ruby gem for interacting with the Klout API.}
21
- gem.description = %Q{Ruby gem for interacting with the Klout API.}
20
+ gem.summary = %Q{A Ruby gem for interacting with the Klout API.}
21
+ gem.description = %Q{Klout is a Ruby gem for interacting with the Klout API.}
22
22
  gem.email = "brian@terra-firma-design.com"
23
23
  gem.authors = ["Brian Getting"]
24
24
  # dependencies defined in Gemfile
25
25
  end
26
26
  Jeweler::RubygemsDotOrgTasks.new
27
27
 
28
- require 'rake/testtask'
29
- Rake::TestTask.new(:test) do |test|
30
- test.libs << 'lib' << 'test'
31
- test.pattern = 'test/**/test_*.rb'
32
- test.verbose = true
28
+ require 'rspec/core'
29
+ require 'rspec/core/rake_task'
30
+ RSpec::Core::RakeTask.new(:spec) do |spec|
31
+ spec.pattern = FileList['spec/**/*_spec.rb']
33
32
  end
34
33
 
35
- task :default => :test
34
+ RSpec::Core::RakeTask.new(:rcov) do |spec|
35
+ spec.pattern = 'spec/**/*_spec.rb'
36
+ spec.rcov = true
37
+ end
38
+
39
+ task :default => :spec
36
40
 
37
- require 'rake/rdoctask'
41
+ require 'rdoc/task'
38
42
  Rake::RDocTask.new do |rdoc|
39
43
  version = File.exist?('VERSION') ? File.read('VERSION') : ""
44
+
40
45
  rdoc.rdoc_dir = 'rdoc'
41
46
  rdoc.title = "klout #{version}"
42
47
  rdoc.rdoc_files.include('README*')
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.0.1
1
+ 2.0.0
@@ -4,14 +4,14 @@
4
4
  # -*- encoding: utf-8 -*-
5
5
 
6
6
  Gem::Specification.new do |s|
7
- s.name = %q{klout}
8
- s.version = "1.0.1"
7
+ s.name = "klout"
8
+ s.version = "2.0.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
- s.authors = [%q{Brian Getting}]
12
- s.date = %q{2012-02-02}
13
- s.description = %q{Ruby gem for interacting with the Klout API.}
14
- s.email = %q{brian@terra-firma-design.com}
11
+ s.authors = ["Brian Getting"]
12
+ s.date = "2012-04-11"
13
+ s.description = "Klout is a Ruby gem for interacting with the Klout API."
14
+ s.email = "brian@terra-firma-design.com"
15
15
  s.extra_rdoc_files = [
16
16
  "README.rdoc"
17
17
  ]
@@ -26,48 +26,51 @@ Gem::Specification.new do |s|
26
26
  "klout.gemspec",
27
27
  "lib/klout.rb",
28
28
  "lib/klout/api.rb",
29
- "spec/klout/fixtures/klout.json",
30
- "spec/klout/fixtures/klout.xml",
29
+ "spec/klout/fixtures/identity.json",
30
+ "spec/klout/fixtures/influence.json",
31
+ "spec/klout/fixtures/score.json",
32
+ "spec/klout/fixtures/topics.json",
33
+ "spec/klout/fixtures/user.json",
31
34
  "spec/klout/klout_spec.rb",
32
35
  "spec/spec_helper.rb"
33
36
  ]
34
- s.homepage = %q{http://github.com/terra-firma/klout}
35
- s.licenses = [%q{MIT}]
36
- s.require_paths = [%q{lib}]
37
- s.rubygems_version = %q{1.8.8}
38
- s.summary = %q{Ruby gem for interacting with the Klout API.}
37
+ s.homepage = "http://github.com/terra-firma/klout"
38
+ s.licenses = ["MIT"]
39
+ s.require_paths = ["lib"]
40
+ s.rubygems_version = "1.8.10"
41
+ s.summary = "A Ruby gem for interacting with the Klout API."
39
42
 
40
43
  if s.respond_to? :specification_version then
41
44
  s.specification_version = 3
42
45
 
43
46
  if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
47
+ s.add_runtime_dependency(%q<httparty>, [">= 0"])
44
48
  s.add_runtime_dependency(%q<json>, [">= 0"])
45
- s.add_runtime_dependency(%q<xml-simple>, [">= 0"])
46
- s.add_development_dependency(%q<bundler>, ["~> 1.0.0"])
47
- s.add_development_dependency(%q<fakeweb>, [">= 0"])
48
- s.add_development_dependency(%q<guard-rspec>, [">= 0"])
49
- s.add_development_dependency(%q<jeweler>, ["~> 1.6.4"])
50
- s.add_development_dependency(%q<simplecov>, [">= 0"])
51
- s.add_development_dependency(%q<rspec>, [">= 0"])
49
+ s.add_development_dependency(%q<bundler>, ["> 1.0.0"])
50
+ s.add_development_dependency(%q<fakeweb>, ["~> 1.3.0"])
51
+ s.add_development_dependency(%q<guard-rspec>, ["~> 0.7.0"])
52
+ s.add_development_dependency(%q<jeweler>, ["~> 1.8.3"])
53
+ s.add_development_dependency(%q<simplecov>, ["~> 0.6.1"])
54
+ s.add_development_dependency(%q<rspec>, ["~> 2.9.0"])
52
55
  else
56
+ s.add_dependency(%q<httparty>, [">= 0"])
53
57
  s.add_dependency(%q<json>, [">= 0"])
54
- s.add_dependency(%q<xml-simple>, [">= 0"])
55
- s.add_dependency(%q<bundler>, ["~> 1.0.0"])
56
- s.add_dependency(%q<fakeweb>, [">= 0"])
57
- s.add_dependency(%q<guard-rspec>, [">= 0"])
58
- s.add_dependency(%q<jeweler>, ["~> 1.6.4"])
59
- s.add_dependency(%q<simplecov>, [">= 0"])
60
- s.add_dependency(%q<rspec>, [">= 0"])
58
+ s.add_dependency(%q<bundler>, ["> 1.0.0"])
59
+ s.add_dependency(%q<fakeweb>, ["~> 1.3.0"])
60
+ s.add_dependency(%q<guard-rspec>, ["~> 0.7.0"])
61
+ s.add_dependency(%q<jeweler>, ["~> 1.8.3"])
62
+ s.add_dependency(%q<simplecov>, ["~> 0.6.1"])
63
+ s.add_dependency(%q<rspec>, ["~> 2.9.0"])
61
64
  end
62
65
  else
66
+ s.add_dependency(%q<httparty>, [">= 0"])
63
67
  s.add_dependency(%q<json>, [">= 0"])
64
- s.add_dependency(%q<xml-simple>, [">= 0"])
65
- s.add_dependency(%q<bundler>, ["~> 1.0.0"])
66
- s.add_dependency(%q<fakeweb>, [">= 0"])
67
- s.add_dependency(%q<guard-rspec>, [">= 0"])
68
- s.add_dependency(%q<jeweler>, ["~> 1.6.4"])
69
- s.add_dependency(%q<simplecov>, [">= 0"])
70
- s.add_dependency(%q<rspec>, [">= 0"])
68
+ s.add_dependency(%q<bundler>, ["> 1.0.0"])
69
+ s.add_dependency(%q<fakeweb>, ["~> 1.3.0"])
70
+ s.add_dependency(%q<guard-rspec>, ["~> 0.7.0"])
71
+ s.add_dependency(%q<jeweler>, ["~> 1.8.3"])
72
+ s.add_dependency(%q<simplecov>, ["~> 0.6.1"])
73
+ s.add_dependency(%q<rspec>, ["~> 2.9.0"])
71
74
  end
72
75
  end
73
76
 
@@ -1,7 +1,4 @@
1
- require 'uri'
2
- require 'net/http'
3
- require 'rubygems'
1
+ require 'httparty'
4
2
  require 'json'
5
- require 'xmlsimple'
6
3
 
7
4
  require 'klout/api'
@@ -1,57 +1,69 @@
1
1
  module Klout
2
2
  class API
3
- # Blank slate
4
- instance_methods.each do |m|
5
- undef_method m unless m.to_s =~ /^__|object_id|method_missing|respond_to?|to_s|inspect/
3
+ include HTTParty
4
+ format :plain
5
+ default_timeout 30
6
+
7
+ attr_accessor :api_key, :timeout
8
+
9
+ # == Usage
10
+ #
11
+ # Initialize with your Klout API key:
12
+ #
13
+ # k = Klout::API.new('api-key')
14
+ #
15
+ # Or you can set the +ENV['KLOUT_API_KEY']+ environment variable:
16
+ #
17
+ # k = Klout::API.new
18
+ #
19
+ def initialize(api_key = nil)
20
+ @api_key = api_key || ENV['KLOUT_API_KEY'] || raise(ArgumentError)
6
21
  end
7
22
 
8
- # Initialize
9
- def initialize(api_key, config = {})
10
- defaults = {
11
- :format => 'json',
12
- :secure => false
13
- }
14
- @config = defaults.merge(config).freeze
15
- @api_key = api_key
16
- protocol = @config[:secure] ? 'https' : 'http'
17
- api_base = URI.parse("#{protocol}://api.klout.com/")
18
- @klout_api = Net::HTTP.new(api_base.host, api_base.port)
23
+ def base_api_url # :nodoc:
24
+ "http://api.klout.com/v2"
19
25
  end
20
26
 
21
- # Class Methods
22
- def call(api_method, usernames)
23
- path = '/1'
24
- path += '/users' if ['show', 'topics'].include?(api_method.to_s)
25
- path += '/soi' if ['influenced_by', 'influencer_of'].include?(api_method.to_s)
26
- path += "/#{api_method}.#{@config[:format]}"
27
- path += "?key=#{@api_key}"
28
- path += "&users=#{URI.escape(usernames.gsub(/ /,''))}"
29
- url = Net::HTTP::Get.new(path)
30
- response = @klout_api.request(url)
31
- # TODO: Clean this up when Klout fixes their ambiguous 404 responses.
32
- raise APIError.new(response.code, response.message) if response.code.to_i > 202
33
- return nil if response.body == ''
34
- @config[:format] == 'xml' ? XmlSimple.xml_in(response.body, {'ForceArray' => false}) : JSON.parse(response.body)
27
+ # === Identity
28
+ #
29
+ # Use the +identity+ method to get a user's +klout_id+.
30
+ # Pass either a numerical Twitter ID (Integer) or a Twitter screen name (String)
31
+ #
32
+ # k.identity(500042487)
33
+ # k.identity('dhh')
34
+ #
35
+ # You can also select a different network:
36
+ #
37
+ # k.identity('dhh', :ks)
38
+ #
39
+ def identity(id, network = :tw)
40
+ path = id.is_a?(Integer) ? "#{network}/#{id}?key=#{@api_key}" : "twitter?screenName=#{id}&key=#{@api_key}"
41
+ call("/identity.json/#{path}")
35
42
  end
36
43
 
37
- def method_missing(api_method, *args) # :nodoc:
38
- call(api_method, *args)
39
- # TODO: Need Klout to fix their ambiguous 404 responses.
40
- #rescue Klout::APIError => error
41
- #super if error.message == "<404> Not Found"
44
+ # === User
45
+ #
46
+ # Use the +user+ method to get information about a user. Pass in a trait
47
+ # option to get score, influence and topics data:
48
+ #
49
+ # k.user(635263)
50
+ # k.user(635263, :influence)
51
+ # k.user(635263, :score)
52
+ # k.user(635263, :topics)
53
+ #
54
+ def user(id, trait = nil)
55
+ lookup = trait.nil? ? '' : "/#{trait.to_s}"
56
+ call("/user.json/#{id}#{lookup}?key=#{@api_key}")
42
57
  end
43
58
 
44
- def respond_to?(api_method) # :nodoc:
45
- call(api_method, 'twitter')
46
- rescue Klout::APIError => error
47
- error.message == "<404> Not Found" ? false : true
59
+ protected
60
+
61
+ def call(endpoint) # :nodoc:
62
+ response = self.class.get(base_api_url + endpoint)
63
+ response.code.to_i == 200 ? JSON.parse(response.body) : raise(API::Error.new("HTTP Response Code: #{response.code}"))
48
64
  end
49
- end
50
-
51
- class APIError < StandardError
52
- # Initialize
53
- def initialize(code, message)
54
- super "<#{code}> #{message}"
65
+
66
+ class Error < StandardError
55
67
  end
56
68
  end
57
69
  end
@@ -0,0 +1,4 @@
1
+ {
2
+ "id": "54887627490056592",
3
+ "network": "ks"
4
+ }
@@ -0,0 +1,45 @@
1
+ {
2
+ "myInfluencers" : [
3
+ {
4
+ "entity" : {
5
+ "id" : "851563",
6
+ "payload" : {
7
+ "kloutId" : "851563",
8
+ "score" : {
9
+ "score" : 100.0
10
+ },
11
+ "topics" : [
12
+ {
13
+ "topicData" : {
14
+ "id" : "8655841127676549162",
15
+ "displayName" : "Social Media",
16
+ "name" : "social media",
17
+ "slug" : "social-media",
18
+ "imageUrl" : "http://kcdn3.klout.com/static/images/topics/social-media2.png"
19
+ },
20
+ "score" : 90.0,
21
+ "strength" : "strong",
22
+ "seconds" : 7736654
23
+ }
24
+ ]
25
+ }
26
+ }
27
+ }
28
+ ],
29
+ "myInfluencees" : [
30
+ {
31
+ "entity" : {
32
+ "id" : "54606150835198872",
33
+ "payload" : {
34
+ "kloutId" : "54606150835198872",
35
+ "score" : {
36
+ "score" : 14.543242454528809
37
+ },
38
+ "topics" : []
39
+ }
40
+ }
41
+ }
42
+ ],
43
+ "myInfluencersCount" : 15,
44
+ "myInfluenceesCount" : 138166
45
+ }
@@ -0,0 +1,8 @@
1
+ {
2
+ "score": 18.162389755249023,
3
+ "scoreDelta": {
4
+ "dayChange": -0.09396934509277344,
5
+ "weekChange": -0.5575828552246094,
6
+ "monthChange": -0.7959918975830078
7
+ }
8
+ }
@@ -0,0 +1,37 @@
1
+ [
2
+ {
3
+ "id": "9050521595422321114",
4
+ "displayName": "Email Marketing",
5
+ "name": "email marketing",
6
+ "slug": "email-marketing",
7
+ "imageUrl": "http://kcdn3.klout.com/static/images/icons/generic-topic.png"
8
+ },
9
+ {
10
+ "id": "8450884106658763087",
11
+ "displayName": "Law",
12
+ "name": "law",
13
+ "slug": "law",
14
+ "imageUrl": "http://kcdn3.klout.com/static/images/topics/law_a883efae09bbe8bea4677d217d18fa85.png"
15
+ },
16
+ {
17
+ "id": "9219221220892053994",
18
+ "displayName": "Ruby",
19
+ "name": "ruby",
20
+ "slug": "ruby",
21
+ "imageUrl": "http://kcdn3.klout.com/static/images/topics/ruby_2f7531a7ddf45d64367d533f8674c714.png"
22
+ },
23
+ {
24
+ "id": "6843285985518810775",
25
+ "displayName": "Ruby on Rails",
26
+ "name": "ruby on rails",
27
+ "slug": "ruby-on-rails",
28
+ "imageUrl": "http://kcdn3.klout.com/static/images/topics/ruby on rails_3efb002572bbce5be4c27932ca05e52a.png"
29
+ },
30
+ {
31
+ "id": "7815",
32
+ "displayName": "Manhattan",
33
+ "name": "manhattan",
34
+ "slug": "manhattan",
35
+ "imageUrl": "http://kcdn3.klout.com/static/images/icons/generic-topic.png"
36
+ }
37
+ ]
@@ -0,0 +1,6 @@
1
+ {
2
+ "kloutId": "635263",
3
+ "score": {
4
+ "score": 76.60027313232422
5
+ }
6
+ }
@@ -2,57 +2,54 @@ require 'spec_helper'
2
2
 
3
3
  module Klout
4
4
  describe API do
5
+ API_URL = "http://api.klout.com/v2/"
5
6
 
6
- API_URL = "http://api.klout.com/1"
7
- API_URL_SECURE = "http://api.klout.com:443/1"
8
-
9
- it "requires an API key" do
10
- expect {Klout::API.new}.should raise_error(ArgumentError)
11
- end
12
-
13
- it "also accepts config options" do
14
- expect {Klout::API.new(@api_key, {:secure => true})}.should_not raise_error(ArgumentError)
15
- end
16
-
17
- it "requires username passed to methods" do
18
- k = Klout::API.new(@apikey)
19
- expect {k.klout}.should raise_error(ArgumentError)
20
- end
21
-
22
- it "can make a request to the API" do
23
- FakeWeb.register_uri(:get, "#{API_URL}/klout.json?key=#{@api_key}&users=testuser", :body => @json_response)
24
- k = Klout::API.new(@api_key)
25
- k.klout('testuser')['status'].should eq(200)
7
+ describe "initializing" do
8
+ it "requires an API key" do
9
+ expect {Klout::API.new}.should raise_error(ArgumentError)
10
+ end
26
11
  end
27
12
 
28
- it "can make a secure request to the API" do
29
- FakeWeb.register_uri(:get, "#{API_URL_SECURE}/klout.json?key=#{@api_key}&users=testuser", :body => @json_response)
30
- k = Klout::API.new(@api_key, {:secure => true})
31
- k.klout('testuser')['users'].first['kscore'].should eq("30.01")
32
- end
33
-
34
- it "can return XML from the API" do
35
- FakeWeb.register_uri(:get, "#{API_URL}/klout.xml?key=#{@api_key}&users=testuser", :body => @xml_response)
36
- k = Klout::API.new(@api_key, {:format => 'xml'})
37
- k.klout('testuser')['user'].first['kscore'].should eq("30.01")
38
- end
39
-
40
- it "injects the 'user' prefix for user requests" do
41
- FakeWeb.register_uri(:get, "#{API_URL}/users/show.json?key=#{@api_key}&users=testuser", :body => @json_response)
42
- k = Klout::API.new(@api_key)
43
- k.show('testuser')['status'].should eq(200)
44
- end
45
-
46
- it "injects the 'soi' prefix for influence requests" do
47
- FakeWeb.register_uri(:get, "#{API_URL}/soi/influenced_by.json?key=#{@api_key}&users=testuser", :body => @json_response)
48
- k = Klout::API.new(@api_key)
49
- k.influenced_by('testuser')['status'].should eq(200)
50
- end
51
-
52
- it "only responds to methods supported by the Klout API" do
53
- FakeWeb.register_uri(:get, "#{API_URL}/bogus_method.json?key=#{@api_key}&users=twitter", :status => ["404", "Not Found"])
54
- k = Klout::API.new(@api_key)
55
- k.respond_to?("bogus_method").should eq(false)
13
+ describe "calling the API" do
14
+ before(:each) do
15
+ @k = Klout::API.new(@api_key)
16
+ end
17
+
18
+ describe "for a klout_id" do
19
+ it "should accept a Twitter ID" do
20
+ user_id = 500042487
21
+ FakeWeb.register_uri(:get, "#{API_URL}identity.json/tw/#{user_id}?key=#{@api_key}", :body => File.read(File.expand_path('spec/klout/fixtures/identity.json')))
22
+ @k.identity(user_id)['id'].should eq('54887627490056592')
23
+ end
24
+
25
+ it "should accept a Twitter screen name" do
26
+ screen_name = 'dhh'
27
+ FakeWeb.register_uri(:get, "#{API_URL}identity.json/twitter?screenName=#{screen_name}&key=#{@api_key}", :body => File.read(File.expand_path('spec/klout/fixtures/identity.json')))
28
+ @k.identity(screen_name)['id'].should eq('54887627490056592')
29
+ end
30
+ end
31
+
32
+ describe "for user" do
33
+ it "should return profile information" do
34
+ FakeWeb.register_uri(:get, "#{API_URL}user.json/#{@klout_id}?key=#{@api_key}", :body => File.read(File.expand_path('spec/klout/fixtures/user.json')))
35
+ @k.user(@klout_id)['kloutId'].to_i.should eq(@klout_id)
36
+ end
37
+
38
+ it "should return score data" do
39
+ FakeWeb.register_uri(:get, "#{API_URL}user.json/#{@klout_id}/score?key=#{@api_key}", :body => File.read(File.expand_path('spec/klout/fixtures/score.json')))
40
+ @k.user(@klout_id, :score)['score'].should eq(18.162389755249023)
41
+ end
42
+
43
+ it "should return influence data" do
44
+ FakeWeb.register_uri(:get, "#{API_URL}user.json/#{@klout_id}/influence?key=#{@api_key}", :body => File.read(File.expand_path('spec/klout/fixtures/influence.json')))
45
+ @k.user(@klout_id, :influence)['myInfluencersCount'].to_i.should eq(15)
46
+ end
47
+
48
+ it "should return topics data" do
49
+ FakeWeb.register_uri(:get, "#{API_URL}user.json/#{@klout_id}/topics?key=#{@api_key}", :body => File.read(File.expand_path('spec/klout/fixtures/topics.json')))
50
+ @k.user(@klout_id, :topics).size.should eq(5)
51
+ end
52
+ end
56
53
  end
57
54
  end
58
55
  end
@@ -6,8 +6,7 @@ FakeWeb.allow_net_connect = false
6
6
  RSpec.configure do |config|
7
7
  config.before(:each) do
8
8
  FakeWeb.clean_registry
9
- @api_key = 'valid-api-key'
10
- @json_response = File.read(File.expand_path('spec/klout/fixtures/klout.json'))
11
- @xml_response = File.read(File.expand_path('spec/klout/fixtures/klout.xml'))
9
+ @api_key = '13adsf2dsf67adsf824aadfdsf12'
10
+ @klout_id = 635263
12
11
  end
13
12
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: klout
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 2.0.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-02-02 00:00:00.000000000Z
12
+ date: 2012-04-11 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
- name: json
16
- requirement: &2165150660 !ruby/object:Gem::Requirement
15
+ name: httparty
16
+ requirement: &70240588720160 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '0'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *2165150660
24
+ version_requirements: *70240588720160
25
25
  - !ruby/object:Gem::Dependency
26
- name: xml-simple
27
- requirement: &2165149560 !ruby/object:Gem::Requirement
26
+ name: json
27
+ requirement: &70240588719280 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,74 +32,74 @@ dependencies:
32
32
  version: '0'
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *2165149560
35
+ version_requirements: *70240588719280
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: bundler
38
- requirement: &2165148720 !ruby/object:Gem::Requirement
38
+ requirement: &70240588717680 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
- - - ~>
41
+ - - ! '>'
42
42
  - !ruby/object:Gem::Version
43
43
  version: 1.0.0
44
44
  type: :development
45
45
  prerelease: false
46
- version_requirements: *2165148720
46
+ version_requirements: *70240588717680
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: fakeweb
49
- requirement: &2165147780 !ruby/object:Gem::Requirement
49
+ requirement: &70240588716380 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
- - - ! '>='
52
+ - - ~>
53
53
  - !ruby/object:Gem::Version
54
- version: '0'
54
+ version: 1.3.0
55
55
  type: :development
56
56
  prerelease: false
57
- version_requirements: *2165147780
57
+ version_requirements: *70240588716380
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: guard-rspec
60
- requirement: &2165146760 !ruby/object:Gem::Requirement
60
+ requirement: &70240588715040 !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
63
- - - ! '>='
63
+ - - ~>
64
64
  - !ruby/object:Gem::Version
65
- version: '0'
65
+ version: 0.7.0
66
66
  type: :development
67
67
  prerelease: false
68
- version_requirements: *2165146760
68
+ version_requirements: *70240588715040
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: jeweler
71
- requirement: &2165145780 !ruby/object:Gem::Requirement
71
+ requirement: &70240588714220 !ruby/object:Gem::Requirement
72
72
  none: false
73
73
  requirements:
74
74
  - - ~>
75
75
  - !ruby/object:Gem::Version
76
- version: 1.6.4
76
+ version: 1.8.3
77
77
  type: :development
78
78
  prerelease: false
79
- version_requirements: *2165145780
79
+ version_requirements: *70240588714220
80
80
  - !ruby/object:Gem::Dependency
81
81
  name: simplecov
82
- requirement: &2165144920 !ruby/object:Gem::Requirement
82
+ requirement: &70240588707800 !ruby/object:Gem::Requirement
83
83
  none: false
84
84
  requirements:
85
- - - ! '>='
85
+ - - ~>
86
86
  - !ruby/object:Gem::Version
87
- version: '0'
87
+ version: 0.6.1
88
88
  type: :development
89
89
  prerelease: false
90
- version_requirements: *2165144920
90
+ version_requirements: *70240588707800
91
91
  - !ruby/object:Gem::Dependency
92
92
  name: rspec
93
- requirement: &2165128940 !ruby/object:Gem::Requirement
93
+ requirement: &70240588707100 !ruby/object:Gem::Requirement
94
94
  none: false
95
95
  requirements:
96
- - - ! '>='
96
+ - - ~>
97
97
  - !ruby/object:Gem::Version
98
- version: '0'
98
+ version: 2.9.0
99
99
  type: :development
100
100
  prerelease: false
101
- version_requirements: *2165128940
102
- description: Ruby gem for interacting with the Klout API.
101
+ version_requirements: *70240588707100
102
+ description: Klout is a Ruby gem for interacting with the Klout API.
103
103
  email: brian@terra-firma-design.com
104
104
  executables: []
105
105
  extensions: []
@@ -116,8 +116,11 @@ files:
116
116
  - klout.gemspec
117
117
  - lib/klout.rb
118
118
  - lib/klout/api.rb
119
- - spec/klout/fixtures/klout.json
120
- - spec/klout/fixtures/klout.xml
119
+ - spec/klout/fixtures/identity.json
120
+ - spec/klout/fixtures/influence.json
121
+ - spec/klout/fixtures/score.json
122
+ - spec/klout/fixtures/topics.json
123
+ - spec/klout/fixtures/user.json
121
124
  - spec/klout/klout_spec.rb
122
125
  - spec/spec_helper.rb
123
126
  homepage: http://github.com/terra-firma/klout
@@ -135,7 +138,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
135
138
  version: '0'
136
139
  segments:
137
140
  - 0
138
- hash: -135046269901848319
141
+ hash: 1810060536700847596
139
142
  required_rubygems_version: !ruby/object:Gem::Requirement
140
143
  none: false
141
144
  requirements:
@@ -144,8 +147,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
144
147
  version: '0'
145
148
  requirements: []
146
149
  rubyforge_project:
147
- rubygems_version: 1.8.8
150
+ rubygems_version: 1.8.10
148
151
  signing_key:
149
152
  specification_version: 3
150
- summary: Ruby gem for interacting with the Klout API.
153
+ summary: A Ruby gem for interacting with the Klout API.
151
154
  test_files: []
@@ -1,13 +0,0 @@
1
- {
2
- "status": 200,
3
- "users": [
4
- {
5
- "twitter_screen_name": "sampler",
6
- "kscore": "30.01"
7
- },
8
- {
9
- "twitter_screen_name": "another",
10
- "kscore": "60.02"
11
- }
12
- ]
13
- }
@@ -1,11 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <users>
3
- <user>
4
- <twitter_screen_name>sampler</twitter_screen_name>
5
- <kscore>30.01</kscore>
6
- </user>
7
- <user>
8
- <twitter_screen_name>another</twitter_screen_name>
9
- <kscore>60.02</kscore>
10
- </user>
11
- </users>