klout 1.0.1 → 2.0.0
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/.travis.yml +1 -1
- data/Gemfile +7 -7
- data/README.rdoc +29 -17
- data/Rakefile +14 -9
- data/VERSION +1 -1
- data/klout.gemspec +37 -34
- data/lib/klout.rb +1 -4
- data/lib/klout/api.rb +55 -43
- data/spec/klout/fixtures/identity.json +4 -0
- data/spec/klout/fixtures/influence.json +45 -0
- data/spec/klout/fixtures/score.json +8 -0
- data/spec/klout/fixtures/topics.json +37 -0
- data/spec/klout/fixtures/user.json +6 -0
- data/spec/klout/klout_spec.rb +45 -48
- data/spec/spec_helper.rb +2 -3
- metadata +39 -36
- data/spec/klout/fixtures/klout.json +0 -13
- data/spec/klout/fixtures/klout.xml +0 -11
data/.travis.yml
CHANGED
@@ -1 +1 @@
|
|
1
|
-
rvm: 1.9.
|
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', '
|
8
|
-
gem 'fakeweb'
|
9
|
-
gem 'guard-rspec'
|
10
|
-
gem 'jeweler', '~> 1.
|
11
|
-
gem 'simplecov'
|
12
|
-
|
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
|
data/README.rdoc
CHANGED
@@ -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://
|
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://
|
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
|
-
|
17
|
+
require 'klout'
|
18
|
+
k = Klout::API.new('api_key')
|
18
19
|
|
19
|
-
|
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('
|
22
|
+
k = Klout::API.new('api_key')
|
22
23
|
|
23
|
-
|
24
|
+
Obtain the +klout_id+ for someone using their Twitter screen name or numerical Twitter ID:
|
24
25
|
|
25
|
-
k.
|
26
|
-
k.
|
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
|
-
|
30
|
+
Once you have a +klout_id+ for someone, you can access their Klout score, influence and topics:
|
35
31
|
|
36
|
-
|
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 '
|
29
|
-
|
30
|
-
|
31
|
-
|
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
|
-
|
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 '
|
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
|
+
2.0.0
|
data/klout.gemspec
CHANGED
@@ -4,14 +4,14 @@
|
|
4
4
|
# -*- encoding: utf-8 -*-
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
|
-
s.name =
|
8
|
-
s.version = "
|
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 = [
|
12
|
-
s.date =
|
13
|
-
s.description =
|
14
|
-
s.email =
|
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/
|
30
|
-
"spec/klout/fixtures/
|
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 =
|
35
|
-
s.licenses = [
|
36
|
-
s.require_paths = [
|
37
|
-
s.rubygems_version =
|
38
|
-
s.summary =
|
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.
|
46
|
-
s.add_development_dependency(%q<
|
47
|
-
s.add_development_dependency(%q<
|
48
|
-
s.add_development_dependency(%q<
|
49
|
-
s.add_development_dependency(%q<
|
50
|
-
s.add_development_dependency(%q<
|
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<
|
55
|
-
s.add_dependency(%q<
|
56
|
-
s.add_dependency(%q<
|
57
|
-
s.add_dependency(%q<
|
58
|
-
s.add_dependency(%q<
|
59
|
-
s.add_dependency(%q<
|
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<
|
65
|
-
s.add_dependency(%q<
|
66
|
-
s.add_dependency(%q<
|
67
|
-
s.add_dependency(%q<
|
68
|
-
s.add_dependency(%q<
|
69
|
-
s.add_dependency(%q<
|
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
|
|
data/lib/klout.rb
CHANGED
data/lib/klout/api.rb
CHANGED
@@ -1,57 +1,69 @@
|
|
1
1
|
module Klout
|
2
2
|
class API
|
3
|
-
|
4
|
-
|
5
|
-
|
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
|
-
#
|
9
|
-
|
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
|
-
#
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
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
|
-
|
38
|
-
|
39
|
-
#
|
40
|
-
#
|
41
|
-
|
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
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
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
|
-
|
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,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,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
|
+
]
|
data/spec/klout/klout_spec.rb
CHANGED
@@ -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
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
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
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
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
|
data/spec/spec_helper.rb
CHANGED
@@ -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 = '
|
10
|
-
@
|
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:
|
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-
|
12
|
+
date: 2012-04-11 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
|
-
name:
|
16
|
-
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: *
|
24
|
+
version_requirements: *70240588720160
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
|
-
name:
|
27
|
-
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: *
|
35
|
+
version_requirements: *70240588719280
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: bundler
|
38
|
-
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: *
|
46
|
+
version_requirements: *70240588717680
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: fakeweb
|
49
|
-
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:
|
54
|
+
version: 1.3.0
|
55
55
|
type: :development
|
56
56
|
prerelease: false
|
57
|
-
version_requirements: *
|
57
|
+
version_requirements: *70240588716380
|
58
58
|
- !ruby/object:Gem::Dependency
|
59
59
|
name: guard-rspec
|
60
|
-
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:
|
65
|
+
version: 0.7.0
|
66
66
|
type: :development
|
67
67
|
prerelease: false
|
68
|
-
version_requirements: *
|
68
|
+
version_requirements: *70240588715040
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: jeweler
|
71
|
-
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.
|
76
|
+
version: 1.8.3
|
77
77
|
type: :development
|
78
78
|
prerelease: false
|
79
|
-
version_requirements: *
|
79
|
+
version_requirements: *70240588714220
|
80
80
|
- !ruby/object:Gem::Dependency
|
81
81
|
name: simplecov
|
82
|
-
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:
|
87
|
+
version: 0.6.1
|
88
88
|
type: :development
|
89
89
|
prerelease: false
|
90
|
-
version_requirements: *
|
90
|
+
version_requirements: *70240588707800
|
91
91
|
- !ruby/object:Gem::Dependency
|
92
92
|
name: rspec
|
93
|
-
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:
|
98
|
+
version: 2.9.0
|
99
99
|
type: :development
|
100
100
|
prerelease: false
|
101
|
-
version_requirements: *
|
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/
|
120
|
-
- spec/klout/fixtures/
|
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:
|
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.
|
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: []
|