From 47d38d5467473aafd22c6afee180787eca54363d Mon Sep 17 00:00:00 2001 From: Jason Goecke Date: Thu, 30 Dec 2010 08:57:39 -0800 Subject: [PATCH 1/4] Added the appropriate dependencies. --- lib/klout.rb | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/klout.rb b/lib/klout.rb index 89a941b..31c5fb9 100644 --- a/lib/klout.rb +++ b/lib/klout.rb @@ -1,5 +1,8 @@ require 'rubygems' require 'json' +require 'open-uri' +require 'net/http' + $:.unshift(File.dirname(__FILE__)) unless $:.include?(File.dirname(__FILE__)) || $:.include?(File.expand_path(File.dirname(__FILE__))) From 19ed066f35b86d032b12e8bbb3019cc4f0995d3d Mon Sep 17 00:00:00 2001 From: Jason Goecke Date: Thu, 30 Dec 2010 09:20:04 -0800 Subject: [PATCH 2/4] Updated the gem to use the lateset Klout API and added an examples file. --- examples/examples.rb | 8 ++++++++ lib/klout.rb | 26 ++++++++++++++++++-------- 2 files changed, 26 insertions(+), 8 deletions(-) create mode 100644 examples/examples.rb diff --git a/examples/examples.rb b/examples/examples.rb new file mode 100644 index 0000000..dd79e57 --- /dev/null +++ b/examples/examples.rb @@ -0,0 +1,8 @@ +require 'lib/klout' + +Klout.api_key = 'YOUR_KEY' +p Klout.score('jsgoecke') +p Klout.score([ 'jsgoecke', 'chrismatthieu', 'johnnydiggz' ]) + +p Klout.profile('jsgoecke') +p Klout.profile([ 'jsgoecke', 'chrismatthieu', 'johnnydiggz' ]) \ No newline at end of file diff --git a/lib/klout.rb b/lib/klout.rb index 31c5fb9..3b68a74 100644 --- a/lib/klout.rb +++ b/lib/klout.rb @@ -22,6 +22,8 @@ class Klout VERSION = '0.0.1' + BASE_URI = 'http://api.klout.com/1' + class << self @@base_host = "klout.com" @@ -35,20 +37,31 @@ def api_key @@api_key end - def score(username) - request_uri = "http://klout.com/api/twitter/1/klout/#{@@api_key}/#{username}.json" + def score(usernames) + request_uri = "#{BASE_URI}/klout.json?key=#{ @@api_key }&users=#{ join_usernames(usernames) }" return request(request_uri) end - def profile(username) - request_uri = "http://klout.com/api/twitter/1.1/profiledetail/#{@@api_key}/#{username}.json" + def profile(usernames) + request_uri = "#{BASE_URI}/users/show.json?key=#{ @@api_key }&users=#{ join_usernames(usernames) }" return request(request_uri) end + private + + def join_usernames(usernames) + if usernames.instance_of? Array + usernames.join(',') + else + usernames + end + end + def request(request_uri) url = URI.parse(request_uri) response = Net::HTTP.start(url.host, url.port) { |http| - http.get(url.path) + ap url.request_uri + http.get(url.request_uri) } case response @@ -65,8 +78,5 @@ def request(request_uri) response.error! end end - - - end end \ No newline at end of file From 805f70a1f0a51b351181d93726b5b84b5c37976f Mon Sep 17 00:00:00 2001 From: Jason Goecke Date: Thu, 30 Dec 2010 09:56:54 -0800 Subject: [PATCH 3/4] Switched to using Jeweler, Rspec 2 and ensured tests passed by adding in FakeWeb. --- .gitignore | 42 +++++++++++++++++ Gemfile | 12 +++++ Rakefile | 52 +++++++++++++++++---- VERSION | 1 + examples/examples.rb | 7 ++- lib/klout.rb | 1 - pkg/klout-0.1.0.gem | Bin 6144 -> 0 bytes pkg/klout-0.1.0.tar.gz | Bin 3246 -> 0 bytes pkg/klout-0.1.0/Manifest | 8 ---- pkg/klout-0.1.0/README | 23 ---------- pkg/klout-0.1.0/Rakefile | 15 ------ pkg/klout-0.1.0/klout.gemspec | 33 ------------- pkg/klout-0.1.0/lib/klout.rb | 69 ---------------------------- pkg/klout-0.1.0/spec/klout_spec.rb | 68 --------------------------- pkg/klout-0.1.0/spec/spec.opts | 1 - pkg/klout-0.1.0/spec/spec_helper.rb | 10 ---- pkg/klout-0.1.0/tasks/rspec.rake | 21 --------- spec/klout_spec.rb | 46 +++++++++++-------- spec/spec_helper.rb | 15 +++--- 19 files changed, 136 insertions(+), 288 deletions(-) create mode 100644 .gitignore create mode 100644 Gemfile create mode 100644 VERSION delete mode 100644 pkg/klout-0.1.0.gem delete mode 100644 pkg/klout-0.1.0.tar.gz delete mode 100644 pkg/klout-0.1.0/Manifest delete mode 100644 pkg/klout-0.1.0/README delete mode 100644 pkg/klout-0.1.0/Rakefile delete mode 100644 pkg/klout-0.1.0/klout.gemspec delete mode 100644 pkg/klout-0.1.0/lib/klout.rb delete mode 100644 pkg/klout-0.1.0/spec/klout_spec.rb delete mode 100644 pkg/klout-0.1.0/spec/spec.opts delete mode 100644 pkg/klout-0.1.0/spec/spec_helper.rb delete mode 100644 pkg/klout-0.1.0/tasks/rspec.rake diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..2288186 --- /dev/null +++ b/.gitignore @@ -0,0 +1,42 @@ +# rcov generated +coverage + +# rdoc generated +rdoc + +# yard generated +doc +.yardoc + +# bundler +.bundle + +# jeweler generated +pkg + +# Have editor/IDE/OS specific files you need to ignore? Consider using a global gitignore: +# +# * Create a file at ~/.gitignore +# * Include files you want ignored +# * Run: git config --global core.excludesfile ~/.gitignore +# +# After doing this, these files will be ignored in all your git projects, +# saving you from having to 'pollute' every project you touch with them +# +# Not sure what to needs to be ignored for particular editors/OSes? Here's some ideas to get you started. (Remember, remove the leading # of the line) +# +# For MacOS: +# +#.DS_Store +# +# For TextMate +#*.tmproj +#tmtags +# +# For emacs: +#*~ +#\#* +#.\#* +# +# For vim: +#*.swp diff --git a/Gemfile b/Gemfile new file mode 100644 index 0000000..5d1ded2 --- /dev/null +++ b/Gemfile @@ -0,0 +1,12 @@ +source "http://rubygems.org" + +gem 'json' + +group :development do + gem "shoulda", ">= 0" + gem "bundler", "~> 1.0.0" + gem "jeweler", "~> 1.5.1" + gem "rcov", ">= 0" + gem "fakeweb" + gem "rspec" +end diff --git a/Rakefile b/Rakefile index 42e3abe..644fe9e 100644 --- a/Rakefile +++ b/Rakefile @@ -1,15 +1,47 @@ require 'rubygems' -require 'echoe' -require 'fileutils' -require './lib/klout' +require 'bundler' +require 'rspec' +require 'rspec/core' +require 'rspec/core/rake_task' +require 'rake/rdoctask' -Echoe.new 'klout', '0.1.0' do |p| - p.author = 'Jason Torres' - p.email = 'jason.e.torres@gmail.com' - p.url = 'http://github.com/jasontorres/klout' - p.description = "Klout - Twitter Analytics" - p.runtime_dependencies = ["typhoeus"] +begin + Bundler.setup(:default, :development) +rescue Bundler::BundlerError => e + $stderr.puts e.message + $stderr.puts "Run `bundle install` to install missing gems" + exit e.status_code +end +require 'rake' + +require 'jeweler' +Jeweler::Tasks.new do |gem| + gem.summary = "Ruby library for consuming the Klout API" + gem.description = "Klout measures influence on topics across the social web to find the people the world listens to. See http://klout.com for more information about their service" + gem.authors = 'Jason Torres' + gem.email = 'jason.e.torres@gmail.com' + gem.homepage = 'http://github.com/jasontorres/klout' + gem.name = "klout" + gem.license = "MIT" +end +Jeweler::RubygemsDotOrgTasks.new +RSpec::Core::RakeTask.new(:spec) do |spec| + spec.pattern = FileList['spec/**/*_spec.rb'] end -Dir["#{File.dirname(__FILE__)}/tasks/*.rake"].sort.each { |ext| load ext } \ No newline at end of file +RSpec::Core::RakeTask.new(:rcov) do |spec| + spec.pattern = 'spec/**/*_spec.rb' + spec.rcov = true +end + +task :default => :spec + +Rake::RDocTask.new do |rdoc| + version = File.exist?('VERSION') ? File.read('VERSION') : "" + + rdoc.rdoc_dir = 'rdoc' + rdoc.title = "new_k #{version}" + rdoc.rdoc_files.include('README*') + rdoc.rdoc_files.include('lib/**/*.rb') +end \ No newline at end of file diff --git a/VERSION b/VERSION new file mode 100644 index 0000000..341cf11 --- /dev/null +++ b/VERSION @@ -0,0 +1 @@ +0.2.0 \ No newline at end of file diff --git a/examples/examples.rb b/examples/examples.rb index dd79e57..6167cc6 100644 --- a/examples/examples.rb +++ b/examples/examples.rb @@ -1,6 +1,9 @@ -require 'lib/klout' +$:.unshift(File.dirname(__FILE__) + '/../lib') +require 'rubygems' +require 'klout' +require 'json' -Klout.api_key = 'YOUR_KEY' +Klout.api_key = 'YOUR_API_KEY' p Klout.score('jsgoecke') p Klout.score([ 'jsgoecke', 'chrismatthieu', 'johnnydiggz' ]) diff --git a/lib/klout.rb b/lib/klout.rb index 3b68a74..cb4cb64 100644 --- a/lib/klout.rb +++ b/lib/klout.rb @@ -60,7 +60,6 @@ def join_usernames(usernames) def request(request_uri) url = URI.parse(request_uri) response = Net::HTTP.start(url.host, url.port) { |http| - ap url.request_uri http.get(url.request_uri) } diff --git a/pkg/klout-0.1.0.gem b/pkg/klout-0.1.0.gem deleted file mode 100644 index ae7bd28a4ccd355215b660e27219af27dac95ef2..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 6144 zcmeHKWmFX0)*cuf%5gxthL92vW{3film_We8A4#_4(SkqA*Dl*76AzXl@uk00hDe5 zNl9stnCtu9^{ww+@Au>Wy0O-E|Jmo9z0Qv3?6uB*Y>-|^elMg4zg+;}pCzzgf)Ex4 z{GorzU$qDvf%xCEzuVzLLV}_I7T7;4p+Ece_WV`-ukgP1wzf`xHvDD%kL>?b+MkO1 z%k}@%Epr?Z06v(h1^{j`TfY2W%C&U&ecRBqlUFd?aRotNhLLgx@caN?vdH9yosP>p7r31p91qk`iRy{KlIJ~* zP1X-0=c}N_t(&;BcYn}wX(7FjI>SqxC7yH3^=;lgPtdJO5hHm?24V#;$Xn2!AC6UZ zOiaXC9$IZEwh4K!oFZB(kcS{IO8Ln1ej#+bmIEg8J=>~Y5)1tkc)WzFkvw}2=s8Pu zPZpVc!fojj5)=(;iNn zUa>3~Et6&M>8CWjAD)EVq*}yccSSYDLtsxiH#|qu(Y8kD_Ie>!zZ&zztXzpYx;RZd` zaEyQGO{(bT8_OH}5=klh0df-)`R2AxE(^Cf{HgcC{3JmDmuA{B(aj(=0pZ6YY?BKBO-i;+=RHG1N~FHB@9-w6 zD?XDJTdUJ$=zAzs*N#jOBeWem>9xV}Y6ywaU6|V#rZApWkvq zj349Rs+k8kv>qKAc#`^!{}JQi{KfGL*Qd9Sgfk;v6TPY!CCpKUpL=x+=jtS|3{#aA z4vK)ZgrC2!->lOb&a&W0wA~DOHDqRl8yF9`lvaF)#g%={9GVr~P~nS!L9EB>nToAw zgFe-;1!(Z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D9|!_6k3n&BpGF)Q1-671Df%Tu*7eMeg3u=@olMi_+RjeqPd}6#t-3q2k6k3Q0C( zLa7OY)%R8zkh1BQ>4Ln{t{3l=x5emq!}hhSce(tJbfw{#CopFq2fnUgxWQoC!jX=4 znVJ_hfZhN*Jq%!b{=h8wou0#Wox%aO_HIFH%P=^jf5y|a5415u)6LZ%6AB&T0xfs{+RL&m`t) z|B`n6KmPYgPu+DCM%H?6msV1X}FJnq{G8cRhMgnaG$7+kPO>tx7*s{ zY<4nrx2AI5!UVRRZ1G`Fd8G|z(q2Ie6!+)?Slhr_n+?@eD7(A$6@(u|yW@LV9+)N20ef=nr8Hc7p~dOzYk@aG0?d5NkCCLv817tKZ!XfsJ#sXB-sr)qP{*RkNUE zle}==du~w~)<6$d^@|LU*U!qV4a0K+HjcyerSr~FyLIu;)GZf%))~=@bbLNcN)iMi zRXK&+`O1OKeqH@aND4H03pzjO!Yv))e$FN^vime9$PE74j&m?JGhOk;U=;J64JdW# zvb(73FlD4+c`FpgaZ1l2_ii`XQU1rpFi*XLIU%TZSn)@+vh9t#oPyE~L)jD6cBF(z zD+rX_iLZI9HKonH!OXFKse2ujW|Ms$+t@UbVJJHBMurN3TmfRlPf)4lX_q*@fUoKd5vVLk&k#%M5hbL+tt}-v?y?K`c!R&i(XpiRC@hfelD&t zF*Rt^a(O{o)OhgK!80H1MWBlx4UI#B{(6cN@#9^cs<}Hs;yPImmv@c6RE;&JF-+>L zxcLnTRMYUGgI-@8mjKaT%Ew#+jr)Xu|07noI2BYt|B~ka9ppCxzY+M2z<)6Ue*;eF BqXhr} diff --git a/pkg/klout-0.1.0.tar.gz b/pkg/klout-0.1.0.tar.gz deleted file mode 100644 index d85d9d7bf9cfbb347f1ed59570cc98ef90644291..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 3246 zcmV;f3{mqRiwFQQ&X`L81MM7LZ`;UGDNq#Ud;7d$dXSYy6sgZx7yFXte0RRf$JKTY z4T6B6$d$#IB6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zRk_9FuM(;PA6%O$fzJ{fxCSG>CQ|~V>FQAl%oeOVmDXwb^`{b;7M8k78<3J4nO}YS za3ff-HuVt}_5OKy<;J)l@j$E3=2_w;zYx2;H|?dZ4;IA#SyEqFGM2~xM&kds+L-vI zLmbeN@&9IEmH7XsiirRJwHiwi|6lwyp};u*_6*9cY57X=|NTPvugmDaESR(Z(yf2F z{p;EOZ)X4Prp*7?2-NFfV?i9=bUP&63|#U4pRV_mAY=9XFR*`}|Iz8TdeZ(k0&C0v zI)70qG5@<=Z~(TY15gqyeE*kf{U2oiZJGbI8Q>=>6*5hX!tuxaZhl(wNnkm9cw#Y+ zktI|m=f26_vmahnpFKAZUi{(Z*LzP7tN2+ZOw_7|g4-N>9#k(qSk8AJG@fBzttqpq zTQ}Wv{~wUIf03+SzKjpZ|LFBvGXG-}FhBm9IX$sij*RQf|GhSjf5+&_`F}I8HvjM9 zAC-0G|2GZk|CI#u_FuO3uW> require 'rubygems' ->> require 'klout' ->> Klout.api_key = "yourkloutapikey" ->> Klout.score('jasontorres') -=> {"user"=>{"kscore"=>19.74, "status"=>200, "status_message"=>"OK"}} ->> Klout.profile('jasontorres') - {"user"=>{"score"=>{"slope"=>0, "kscore"=>"19.7429", "kclass"=>"connector", "true_reach"=>"195", "amplification_score"=>"0", "kscore_description"=>"", "network_score"=>"0", "kclass_description"=>"You are a constant source of information to your friends and co-workers. There is a good chance that you probably introduced several of your friends to Twitter. Your taste and opinion is respected and your judgment is trusted.", "date_updated"=>"2009-07-09 00:59:08"}, "twitter_screen_name"=>"jasontorres", "status"=>200, "twitter_id"=>"406073", "status_message"=>"OK"}} - -Disclaimer: Author is not anyway involved w/ Klout.com - -Klout is a copyright trademark of Klout.com - -MIT License \ No newline at end of file diff --git a/pkg/klout-0.1.0/Rakefile b/pkg/klout-0.1.0/Rakefile deleted file mode 100644 index 42e3abe..0000000 --- a/pkg/klout-0.1.0/Rakefile +++ /dev/null @@ -1,15 +0,0 @@ -require 'rubygems' -require 'echoe' -require 'fileutils' -require './lib/klout' - -Echoe.new 'klout', '0.1.0' do |p| - p.author = 'Jason Torres' - p.email = 'jason.e.torres@gmail.com' - p.url = 'http://github.com/jasontorres/klout' - p.description = "Klout - Twitter Analytics" - p.runtime_dependencies = ["typhoeus"] - -end - -Dir["#{File.dirname(__FILE__)}/tasks/*.rake"].sort.each { |ext| load ext } \ No newline at end of file diff --git a/pkg/klout-0.1.0/klout.gemspec b/pkg/klout-0.1.0/klout.gemspec deleted file mode 100644 index 1a603f8..0000000 --- a/pkg/klout-0.1.0/klout.gemspec +++ /dev/null @@ -1,33 +0,0 @@ -# -*- encoding: utf-8 -*- - -Gem::Specification.new do |s| - s.name = %q{klout} - s.version = "0.1.0" - - s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version= - s.authors = ["Jason Torres"] - s.date = %q{2010-03-11} - s.description = %q{Klout - Twitter Analytics} - s.email = %q{jason.e.torres@gmail.com} - s.extra_rdoc_files = ["lib/klout.rb", "README", "tasks/rspec.rake"] - s.files = ["lib/klout.rb", "Manifest", "Rakefile", "README", "spec/klout_spec.rb", "spec/spec.opts", "spec/spec_helper.rb", "tasks/rspec.rake", "klout.gemspec"] - s.homepage = %q{http://github.com/jasontorres/klout} - s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Klout", "--main", "README"] - s.require_paths = ["lib"] - s.rubyforge_project = %q{klout} - s.rubygems_version = %q{1.3.6} - s.summary = %q{Klout - Twitter Analytics} - - if s.respond_to? :specification_version then - current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION - s.specification_version = 3 - - if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then - s.add_runtime_dependency(%q, [">= 0"]) - else - s.add_dependency(%q, [">= 0"]) - end - else - s.add_dependency(%q, [">= 0"]) - end -end diff --git a/pkg/klout-0.1.0/lib/klout.rb b/pkg/klout-0.1.0/lib/klout.rb deleted file mode 100644 index 89a941b..0000000 --- a/pkg/klout-0.1.0/lib/klout.rb +++ /dev/null @@ -1,69 +0,0 @@ -require 'rubygems' -require 'json' -$:.unshift(File.dirname(__FILE__)) unless - $:.include?(File.dirname(__FILE__)) || $:.include?(File.expand_path(File.dirname(__FILE__))) - -=begin rdoc - -Klout measures influence on topics across the social web to find the people the world listens to - -See http://klout.com for more information about their service - -Usage: - -Klout.api_key = "" -Klout.score('jasontorres') - -=end - - -class Klout - VERSION = '0.0.1' - class << self - @@base_host = "klout.com" - - @@api_key = "" - - def api_key=(api) - @@api_key = api - end - - def api_key - @@api_key - end - - def score(username) - request_uri = "http://klout.com/api/twitter/1/klout/#{@@api_key}/#{username}.json" - return request(request_uri) - end - - def profile(username) - request_uri = "http://klout.com/api/twitter/1.1/profiledetail/#{@@api_key}/#{username}.json" - return request(request_uri) - end - - def request(request_uri) - url = URI.parse(request_uri) - response = Net::HTTP.start(url.host, url.port) { |http| - http.get(url.path) - } - - case response - when Net::HTTPSuccess - if response.body - begin - JSON.parse(response.body) - rescue Exception => e - puts e.backtrace - false - end - end - else - response.error! - end - end - - - - end -end \ No newline at end of file diff --git a/pkg/klout-0.1.0/spec/klout_spec.rb b/pkg/klout-0.1.0/spec/klout_spec.rb deleted file mode 100644 index da97ab6..0000000 --- a/pkg/klout-0.1.0/spec/klout_spec.rb +++ /dev/null @@ -1,68 +0,0 @@ -require File.dirname(__FILE__) + '/spec_helper.rb' - -describe "Klout" do - - before do - Klout.api_key = "" - end - - it "should assign the correct API key" do - Klout.api_key.should == "" - end - - context "score request" do - before do - @score_request ||= lambda { - Klout.score('jasontorres') - } - - @score_result ||= @score_request.call - end - - it "should score!" do - @score_result.should be_instance_of(Hash) - end - - it "should have the required keys" do - @score_result.has_key?('user').should == true - @score_result['user'].has_key?('kscore').should == true - @score_result['user'].has_key?('status').should == true - @score_result['user'].has_key?('status_message').should == true - end - end - - context "profile request" do - before do - @profile_request ||= lambda { - Klout.profile('jasontorres') - } - @profile_result ||= @profile_request.call - end - - it "should have a profile" do - @profile_result.should be_instance_of(Hash) - end - - it "should have the required keys" do - @profile_result.has_key?('user').should == true - @profile_result['user'].has_key?('score').should == true - @profile_result['user']['score'].has_key?('slope').should == true - @profile_result['user']['score'].has_key?('kscore').should == true - @profile_result['user']['score'].has_key?('kclass').should == true - @profile_result['user']['score'].has_key?('true_reach').should == true - @profile_result['user']['score'].has_key?('amplification_score').should == true - @profile_result['user']['score'].has_key?('kscore_description').should == true - @profile_result['user']['score'].has_key?('network_score').should == true - @profile_result['user']['score'].has_key?('kclass_description').should == true - @profile_result['user']['score'].has_key?('date_updated').should == true - @profile_result['user'].has_key?('twitter_screen_name').should == true - @profile_result['user'].has_key?('status').should == true - @profile_result['user'].has_key?('twitter_id').should == true - @profile_result['user'].has_key?('status_message').should == true - end - - end - - -end - diff --git a/pkg/klout-0.1.0/spec/spec.opts b/pkg/klout-0.1.0/spec/spec.opts deleted file mode 100644 index cf6add7..0000000 --- a/pkg/klout-0.1.0/spec/spec.opts +++ /dev/null @@ -1 +0,0 @@ ---colour \ No newline at end of file diff --git a/pkg/klout-0.1.0/spec/spec_helper.rb b/pkg/klout-0.1.0/spec/spec_helper.rb deleted file mode 100644 index 5163759..0000000 --- a/pkg/klout-0.1.0/spec/spec_helper.rb +++ /dev/null @@ -1,10 +0,0 @@ -begin - require 'spec' -rescue LoadError - require 'rubygems' unless ENV['NO_RUBYGEMS'] - gem 'rspec' - require 'spec' -end - -$:.unshift(File.dirname(__FILE__) + '/../lib') -require 'klout' diff --git a/pkg/klout-0.1.0/tasks/rspec.rake b/pkg/klout-0.1.0/tasks/rspec.rake deleted file mode 100644 index 31a99b0..0000000 --- a/pkg/klout-0.1.0/tasks/rspec.rake +++ /dev/null @@ -1,21 +0,0 @@ -begin - require 'spec' -rescue LoadError - require 'rubygems' unless ENV['NO_RUBYGEMS'] - require 'spec' -end -begin - require 'spec/rake/spectask' -rescue LoadError - puts <<-EOS -To use rspec for testing you must install rspec gem: - gem install rspec -EOS - exit(0) -end - -desc "Run the specs under spec/models" -Spec::Rake::SpecTask.new do |t| - t.spec_opts = ['--options', "spec/spec.opts"] - t.spec_files = FileList['spec/**/*_spec.rb'] -end diff --git a/spec/klout_spec.rb b/spec/klout_spec.rb index da97ab6..a4cdbcc 100644 --- a/spec/klout_spec.rb +++ b/spec/klout_spec.rb @@ -1,9 +1,19 @@ require File.dirname(__FILE__) + '/spec_helper.rb' +FakeWeb.allow_net_connect = false describe "Klout" do before do Klout.api_key = "" + + FakeWeb.register_uri(:get, + 'http://api.klout.com/1/klout.json?key=&users=jasontorres', + :body => '{"users":[{"kscore":37.65,"twitter_screen_name":"jasontorres"}],"status":200}', + :status => ["200", "ok"]) + FakeWeb.register_uri(:get, + 'http://api.klout.com/1/users/show.json?key=&users=jasontorres', + :body => "{\"users\":[{\"twitter_screen_name\":\"jasontorres\",\"twitter_id\":\"406073\",\"score\":{\"kscore\":37.65,\"kclass_description\":\"You actively engage in the social web, constantly trying out new ways to interact and network. You're exploring the ecosystem and making it work for you. Your level of activity and engagement shows that you \\\"get it\\\", we predict you'll be moving up.\",\"amplification_score\":17.45,\"slope\":0,\"network_score\":42.58,\"true_reach\":195,\"kscore_description\":\"jasontorres has a low level of influence.\",\"kclass\":\"Explorer\",\"kclass_id\":4,\"description\":\" is effectively using social media to influence their network across a variety of topics.\"}}],\"status\":200}", + :status => ["200", "ok"]) end it "should assign the correct API key" do @@ -24,10 +34,10 @@ end it "should have the required keys" do - @score_result.has_key?('user').should == true - @score_result['user'].has_key?('kscore').should == true - @score_result['user'].has_key?('status').should == true - @score_result['user'].has_key?('status_message').should == true + @score_result.has_key?('users').should == true + @score_result['users'][0].has_key?('kscore').should == true + @score_result['users'][0].has_key?('twitter_screen_name').should == true + @score_result.has_key?('status').should == true end end @@ -44,21 +54,19 @@ end it "should have the required keys" do - @profile_result.has_key?('user').should == true - @profile_result['user'].has_key?('score').should == true - @profile_result['user']['score'].has_key?('slope').should == true - @profile_result['user']['score'].has_key?('kscore').should == true - @profile_result['user']['score'].has_key?('kclass').should == true - @profile_result['user']['score'].has_key?('true_reach').should == true - @profile_result['user']['score'].has_key?('amplification_score').should == true - @profile_result['user']['score'].has_key?('kscore_description').should == true - @profile_result['user']['score'].has_key?('network_score').should == true - @profile_result['user']['score'].has_key?('kclass_description').should == true - @profile_result['user']['score'].has_key?('date_updated').should == true - @profile_result['user'].has_key?('twitter_screen_name').should == true - @profile_result['user'].has_key?('status').should == true - @profile_result['user'].has_key?('twitter_id').should == true - @profile_result['user'].has_key?('status_message').should == true + @profile_result.has_key?('users').should == true + @profile_result['users'][0].has_key?('score').should == true + @profile_result['users'][0]['score'].has_key?('slope').should == true + @profile_result['users'][0]['score'].has_key?('kscore').should == true + @profile_result['users'][0]['score'].has_key?('kclass').should == true + @profile_result['users'][0]['score'].has_key?('true_reach').should == true + @profile_result['users'][0]['score'].has_key?('amplification_score').should == true + @profile_result['users'][0]['score'].has_key?('kscore_description').should == true + @profile_result['users'][0]['score'].has_key?('network_score').should == true + @profile_result['users'][0]['score'].has_key?('kclass_description').should == true + @profile_result['users'][0].has_key?('twitter_screen_name').should == true + @profile_result['users'][0].has_key?('twitter_id').should == true + @profile_result.has_key?('status').should == true end end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 5163759..0afd87e 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,10 +1,9 @@ -begin - require 'spec' -rescue LoadError - require 'rubygems' unless ENV['NO_RUBYGEMS'] - gem 'rspec' - require 'spec' -end - $:.unshift(File.dirname(__FILE__) + '/../lib') +require 'rubygems' +require 'rspec' require 'klout' +require 'fakeweb' + +RSpec.configure do |config| + +end \ No newline at end of file From 9942d9793975a20d4b282f7c86c2736e656be124 Mon Sep 17 00:00:00 2001 From: Jason Goecke Date: Thu, 30 Dec 2010 09:57:26 -0800 Subject: [PATCH 4/4] Added the gemfile built with rake --- klout.gemspec | 73 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 73 insertions(+) create mode 100644 klout.gemspec diff --git a/klout.gemspec b/klout.gemspec new file mode 100644 index 0000000..4015b9c --- /dev/null +++ b/klout.gemspec @@ -0,0 +1,73 @@ +# Generated by jeweler +# DO NOT EDIT THIS FILE DIRECTLY +# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec' +# -*- encoding: utf-8 -*- + +Gem::Specification.new do |s| + s.name = %q{klout} + s.version = "0.2.0" + + s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version= + s.authors = ["Jason Torres"] + s.date = %q{2010-12-30} + s.description = %q{Klout measures influence on topics across the social web to find the people the world listens to. See http://klout.com for more information about their service} + s.email = %q{jason.e.torres@gmail.com} + s.extra_rdoc_files = [ + "README" + ] + s.files = [ + "Gemfile", + "Manifest", + "README", + "Rakefile", + "VERSION", + "examples/examples.rb", + "lib/klout.rb", + "spec/klout_spec.rb", + "spec/spec.opts", + "spec/spec_helper.rb", + "tasks/rspec.rake" + ] + s.homepage = %q{http://github.com/jasontorres/klout} + s.licenses = ["MIT"] + s.require_paths = ["lib"] + s.rubygems_version = %q{1.3.6} + s.summary = %q{Ruby library for consuming the Klout API} + s.test_files = [ + "examples/examples.rb", + "spec/klout_spec.rb", + "spec/spec_helper.rb" + ] + + if s.respond_to? :specification_version then + current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION + s.specification_version = 3 + + if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then + s.add_runtime_dependency(%q, [">= 0"]) + s.add_development_dependency(%q, [">= 0"]) + s.add_development_dependency(%q, ["~> 1.0.0"]) + s.add_development_dependency(%q, ["~> 1.5.1"]) + s.add_development_dependency(%q, [">= 0"]) + s.add_development_dependency(%q, [">= 0"]) + s.add_development_dependency(%q, [">= 0"]) + else + s.add_dependency(%q, [">= 0"]) + s.add_dependency(%q, [">= 0"]) + s.add_dependency(%q, ["~> 1.0.0"]) + s.add_dependency(%q, ["~> 1.5.1"]) + s.add_dependency(%q, [">= 0"]) + s.add_dependency(%q, [">= 0"]) + s.add_dependency(%q, [">= 0"]) + end + else + s.add_dependency(%q, [">= 0"]) + s.add_dependency(%q, [">= 0"]) + s.add_dependency(%q, ["~> 1.0.0"]) + s.add_dependency(%q, ["~> 1.5.1"]) + s.add_dependency(%q, [">= 0"]) + s.add_dependency(%q, [">= 0"]) + s.add_dependency(%q, [">= 0"]) + end +end +