stats_combiner 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
data/Rakefile CHANGED
@@ -10,7 +10,7 @@ begin
10
10
  gem.email = "almshaw@gmail.com"
11
11
  gem.homepage = "http://github.com/tpm/stats_combiner"
12
12
  gem.authors = ["Al Shaw"]
13
- gem.add_dependency 'crack'
13
+ gem.add_dependency 'chartbeat'
14
14
  gem.add_dependency 'sequel'
15
15
  gem.add_development_dependency "rspec"
16
16
  gem.add_development_dependency "fakeweb"
@@ -22,4 +22,20 @@ begin
22
22
  Jeweler::GemcutterTasks.new
23
23
  rescue LoadError
24
24
  puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
25
- end
25
+ end
26
+
27
+ require 'spec/rake/spectask'
28
+ Spec::Rake::SpecTask.new(:spec) do |spec|
29
+ spec.libs << 'lib' << 'spec'
30
+ spec.spec_files = FileList['spec/**/*_spec.rb']
31
+ end
32
+
33
+ Spec::Rake::SpecTask.new(:rcov) do |spec|
34
+ spec.libs << 'lib' << 'spec'
35
+ spec.pattern = 'spec/**/*_spec.rb'
36
+ spec.rcov = true
37
+ end
38
+
39
+ task :spec => :check_dependencies
40
+
41
+ task :default => :spec
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.1
1
+ 0.0.2
@@ -1,6 +1,6 @@
1
1
  require 'open-uri'
2
2
  require 'fileutils'
3
- require 'crack/json'
3
+ require 'chartbeat'
4
4
  require 'sequel'
5
5
  require 'stats_combiner/filterer'
6
6
 
@@ -105,10 +105,8 @@ module StatsCombiner
105
105
  def combine
106
106
  host = @init_options[:host]
107
107
  api_key = @init_options[:api_key]
108
- @url = "http://api.chartbeat.com/toppages/?host=#{host}&limit=50&apikey=#{api_key}"
109
-
110
- @data = open(@url).read
111
- @data = Crack::JSON.parse(@data)
108
+ chartbeat = Chartbeat.new :host => host, :apikey => api_key
109
+ @data = chartbeat.toppages :limit => 50
112
110
 
113
111
  @data.each do |datum|
114
112
  visitors = datum['visitors']
data/spec/spec.opts ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --format specdoc
@@ -1,4 +1,12 @@
1
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
2
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
3
+ require 'stats_combiner'
4
+ require 'timecop'
5
+ require 'hpricot'
1
6
  require 'fakeweb'
7
+ require 'spec'
8
+ require 'spec/autorun'
9
+
2
10
 
3
11
  FakeWeb.allow_net_connect = false
4
12
 
@@ -6,4 +14,7 @@ TEST_DATA = <<-DOCUMENT
6
14
  [{"i": "Talking Points Memo | Breaking News and Analysis", "path": "\/", "visitors": 529}, {"i": "Theories of the Fall | Talking Points Memo", "path": "\/archives\/2010\/05\/theories_of_the_fall.php", "visitors": 66}, {"i": "What A Week: Rand Paul Takes The National Stage | TPMDC", "path": "\/2010\/05\/what-a-week-rand-paul-takes-the-national-stage.php?ref=fpa", "visitors": 37}, {"i": "Texas Board Of Ed Approves Right-Wing History Textbook Standards (VIDEO) | TPMMuckraker", "path": "\/2010\/05\/texas_history_textbooks_final_vote.php", "visitors": 15}, {"i": "Ron Paul Appeared On Meet The Press In '07 And Spoke Out Against Civil Rights Act (VIDEO) | TPMDC", "path": "\/2010\/05\/ron-paul-appeared-on-meet-the-press-in-07-and-spoke-out-against-civil-rights-act-video.php?ref=fpb", "visitors": 12}, {"i": "Texas Board Of Ed Approves Right-Wing History Textbook Standards (VIDEO) | TPMMuckraker", "path": "\/2010\/05\/texas_history_textbooks_final_vote.php?ref=fpb", "visitors": 11}, {"i": "CNN Headline: 'Miss USA: Muslim Trailblazer Or Hezbollah Spy?' | TPM LiveWire", "path": "\/2010\/05\/cnn-headline-miss-usa-muslim-trailblazer-or-hezbollah-spy.php?ref=fpb", "visitors": 8}, {"i": "GOP Kills Science Jobs Bill By Forcing Dems To Vote For Porn | TPMDC", "path": "\/2010\/05\/gop-kills-science-jobs-bill-by-forcing-dems-to-vote-for-porn.php", "visitors": 7}, {"i": "Texas Board Of Ed Approves Right-Wing History Textbook Standards (VIDEO) | TPMMuckraker", "path": "\/2010\/05\/texas_history_textbooks_final_vote.php?ref=fpa", "visitors": 7}, {"i": "Will Wall Street Reform Negotiators Publicly Weaken Derivative-Trading Regulations? (VIDEO) | TPMDC", "path": "\/2010\/05\/will-wall-street-reform-negotiators-publicly-weaken-derivative-trading-regulations-video.php?ref=fpb", "visitors": 6}, {"i": "What A Week: Rand Paul Takes The National Stage | TPMDC", "path": "\/2010\/05\/what-a-week-rand-paul-takes-the-national-stage.php?ref=tn", "visitors": 6}, {"i": "Unity In Kentucky As GOPers Rally 'Round Rand | TPMDC", "path": "\/2010\/05\/this-is-what-kentucky-unity-looks-like-gopers-rally-round-rand.php?ref=fpb", "visitors": 6}, {"i": "So Not Ready For Prime Time (or Even Sunday) | Talking Points Memo", "path": "\/archives\/2010\/05\/so_not_ready_for_prime_time_or_even_sunday.php", "visitors": 6}, {"i": "Paul Backs Out Of Meet The Press Appearance | TPMDC", "path": "\/2010\/05\/paul-backs-out-of-meet-the-press-appearance.php?ref=fpb", "visitors": 6}, {"i": "Jack Conway To TPMDC: Paul Civil Rights Comments 'Relevant' To General Election Campaign | TPMDC", "path": "\/2010\/05\/jack-conway-to-tpmdc-paul-civil-rights-comments-relevant-to-general-election-campaign.php?ref=fpb", "visitors": 5}, {"i": "TPMDC Saturday Roundup | TPMDC", "path": "\/2010\/05\/obama-announces-commission-on-oil-spill.php", "visitors": 5}, {"i": "What A Week: Rand Paul Takes The National Stage | TPMDC", "path": "\/2010\/05\/what-a-week-rand-paul-takes-the-national-stage.php", "visitors": 5}, {"i": "Dems Brace For Loss Of Usually Ultra-Safe Hawaii House Seat On Saturday | TPMDC", "path": "\/2010\/05\/dems-brace-for-loss-of-usually-ultra-safe-hawaii-house-seat-on-saturday.php", "visitors": 4}, {"i": "That Other Thing: Blumenthal And The Swim Team | TPMMuckraker", "path": "\/2010\/05\/that_other_thing_blumenthal_and_the_swim_team.php?ref=fpc", "visitors": 4}, {"i": "Franken Raises Money To Oppose Rand Paul -- And He Likes Brunch | TPMDC", "path": "\/2010\/05\/franken-raises-money-to-oppose-rand-paul----and-he-likes-brunch.php?ref=fpi", "visitors": 4}, {"i": "What Did Rand Paul Really Say On Maddow Last Night? | TPMDC", "path": "\/2010\/05\/what-did-rand-paul-really-say-on-maddow-last-night.php", "visitors": 4}, {"i": "Like a Friggin' Rock | Talking Points Memo", "path": "\/archives\/2010\/05\/like_a_friggin_rock.php", "visitors": 4}, {"i": "Franken Raises Money To Oppose Rand Paul -- And He Likes Brunch | TPMDC", "path": "\/2010\/05\/franken-raises-money-to-oppose-rand-paul----and-he-likes-brunch.php", "visitors": 4}, {"i": "Unity In Kentucky As GOPers Rally 'Round Rand | TPMDC", "path": "\/2010\/05\/this-is-what-kentucky-unity-looks-like-gopers-rally-round-rand.php?ref=fpa", "visitors": 4}, {"i": "Rand Paul: Economic Collapse Could Lead To 'A Hitler' Coming To Power | TPMMuckraker", "path": "\/2010\/05\/rand_paul_economic_collapse_could_lead_to_a_hitler.php", "visitors": 4}, {"i": "Rand Paul: Obama's BP Comments Sound 'Really Un-American' (VIDEO) | TPM LiveWire", "path": "\/2010\/05\/rand-paul-obamas-bp-comments-sound-really-un-american-video.php?ref=fpblg", "visitors": 4}, {"i": "CNN Headline: 'Miss USA: Muslim Trailblazer Or Hezbollah Spy?' | TPM LiveWire", "path": "\/2010\/05\/cnn-headline-miss-usa-muslim-trailblazer-or-hezbollah-spy.php", "visitors": 3}, {"i": "A Red Tulip Confirms All Crows Are Black | Fred Moolten's Blog", "path": "\/talk\/blogs\/fredmoolten\/2009\/06\/a-red-tulip-confirms-all-crows.php", "visitors": 3}, {"i": "Peter Beinart Unbound? | TPMCafe", "path": "\/2010\/05\/19\/beinart_unbound_here_and_in_bookforumcom\/", "visitors": 3}, {"i": "Bill Clinton To Campaign For Blanche Lincoln In Arkansas | TPMDC", "path": "\/2010\/05\/bill-clinton-to-campaign-for-blanche-lincoln-in-arkansas.php?ref=fpb", "visitors": 3}, {"i": "Texas Board Of Ed Approves Right-Wing History Textbook Standards (VIDEO) | TPMMuckraker", "path": "\/2010\/05\/texas_history_textbooks_final_vote.php?ref=tn", "visitors": 3}, {"i": "What A Week: Rand Paul Takes The National Stage | TPMDC", "path": "\/2010\/05\/what-a-week-rand-paul-takes-the-national-stage.php?ref=dcblt", "visitors": 3}, {"i": "Bwakfat's Dashboard | All", "path": "\/cgi-bin\/mt-current\/mt-cp.cgi?__mode=my_dashboard", "visitors": 3}, {"i": "Paul Has Been Guest Of Conspiracy Theorist Shock Jock Alex Jones (VIDEO) | TPMMuckraker", "path": "\/2010\/05\/paul_has_been_guest_of_conspiracy_theorist_shock_j.php", "visitors": 3}, {"i": "Full Text Of Newsmax Column Suggesting Military Coup Against Obama | TPM News Pages", "path": "\/news\/2009\/09\/full_text_of_newsmax_column_suggesting_military_co.php\/", "visitors": 3}, {"i": "Ron Paul Appeared On Meet The Press In '07 And Spoke Out Against Civil Rights Act (VIDEO) | TPMDC", "path": "\/2010\/05\/ron-paul-appeared-on-meet-the-press-in-07-and-spoke-out-against-civil-rights-act-video.php", "visitors": 3}, {"i": "Rand Paul In '08: Beware The NAFTA Superhighway! (VIDEO) | TPMMuckraker", "path": "\/2010\/05\/rand_paul_beware_the_nafta_superhighway_video.php", "visitors": 3}, {"i": "Jack Conway To TPMDC: Paul Civil Rights Comments 'Relevant' To General Election Campaign | TPMDC", "path": "\/2010\/05\/jack-conway-to-tpmdc-paul-civil-rights-comments-relevant-to-general-election-campaign.php?ref=tn", "visitors": 3}, {"i": "Ahistorical | Talking Points Memo", "path": "\/archives\/2010\/05\/ahistorical.php", "visitors": 3}, {"i": "Harvard Needs To Fire Dershowitz | TPMCafe", "path": "\/2010\/05\/22\/harvard_needs_to_fire_dershowitz\/", "visitors": 3}, {"i": "Scientists see video, adjust Gulf leak estimates | TPM News Pages", "path": "\/news\/2010\/05\/scientists_see_video_adjust_gulf_leak_estimates.php?ref=fpa", "visitors": 3}, {"i": "Rand Paul Defends Criticism Of Civil Rights Act To Rachel Maddow (VIDEO) | TPM LiveWire", "path": "\/2010\/05\/rand-paul-defends-criticism-of-civil-rights-act-to-rachel-maddow.php?ref=fpa", "visitors": 3}, {"i": "Dems Brace For Loss Of Usually Ultra-Safe Hawaii House Seat On Saturday | TPMDC", "path": "\/2010\/05\/dems-brace-for-loss-of-usually-ultra-safe-hawaii-house-seat-on-saturday.php?ref=fpb", "visitors": 3}, {"i": "LisB Blows A Gasket | LisB's Blog", "path": "\/talk\/blogs\/l\/i\/lisb\/2010\/05\/lisb-blows-a-gasket.php?ref=reccafe", "visitors": 2}, {"i": "Rand Paul In '08: Beware The NAFTA Superhighway! (VIDEO) | TPMMuckraker", "path": "\/2010\/05\/rand_paul_beware_the_nafta_superhighway_video.php?ref=fpblg", "visitors": 2}, {"i": "Texas Textbook Hearings | TPMMuckraker", "path": "\/texas_textbook_hearings\/", "visitors": 2}, {"i": "California Gov. Candidate Pushes Plan For 'Pedophile Island' | TPM LiveWire", "path": "\/2010\/05\/california-gov-candidate-pushes-plan-for-pedophile-island.php?ref=fpblg", "visitors": 2}, {"i": "Jack Conway Strikes Back At Paul's 'Un-American' Comment | TPM LiveWire", "path": "\/2010\/05\/jack-conway-strikes-back-at-pauls-un-american-comment.php?ref=fpa", "visitors": 2}, {"i": "Theories of the Fall | Talking Points Memo", "path": "\/archives\/2010\/05\/theories_of_the_fall.php?ref=fpblg", "visitors": 2}, {"i": "Jack Conway Strikes Back At Paul's 'Un-American' Comment | TPM LiveWire", "path": "\/2010\/05\/jack-conway-strikes-back-at-pauls-un-american-comment.php", "visitors": 2}]
7
15
  DOCUMENT
8
16
 
9
- FakeWeb.register_uri(:get, "http://api.chartbeat.com/toppages/?host=fake.com&limit=50&apikey=fake_key", :body => TEST_DATA)
17
+ FakeWeb.register_uri(:get, "http://chartbeat.com/api/toppages/?apikey=fake_key&host=fake.com&limit=50", :body => TEST_DATA)
18
+
19
+ Spec::Runner.configure do |config|
20
+ end
@@ -1,9 +1,4 @@
1
- require '../lib/stats_combiner'
2
- require 'test_data'
3
-
4
- require 'spec'
5
- require 'timecop'
6
- require 'hpricot'
1
+ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
7
2
 
8
3
  HOST = 'fake.com'
9
4
  KEY = 'fake_key'
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{stats_combiner}
8
- s.version = "0.0.1"
8
+ s.version = "0.0.2"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Al Shaw"]
12
- s.date = %q{2010-05-24}
12
+ s.date = %q{2010-06-21}
13
13
  s.description = %q{A tool to create most-viewed story widgets from the Chartbeat API.}
14
14
  s.email = %q{almshaw@gmail.com}
15
15
  s.extra_rdoc_files = [
@@ -23,33 +23,34 @@ Gem::Specification.new do |s|
23
23
  "combiner_sample.rb",
24
24
  "lib/stats_combiner.rb",
25
25
  "lib/stats_combiner/filterer.rb",
26
+ "spec/spec.opts",
27
+ "spec/spec_helper.rb",
26
28
  "spec/stats_combiner_spec.rb",
27
- "spec/test_data.rb",
28
29
  "stats_combiner.gemspec"
29
30
  ]
30
31
  s.homepage = %q{http://github.com/tpm/stats_combiner}
31
32
  s.rdoc_options = ["--charset=UTF-8"]
32
33
  s.require_paths = ["lib"]
33
- s.rubygems_version = %q{1.3.6}
34
+ s.rubygems_version = %q{1.3.7}
34
35
  s.summary = %q{StatsCombiner creates most-viewed story widgets from the Chartbeat API}
35
36
  s.test_files = [
36
- "spec/stats_combiner_spec.rb",
37
- "spec/test_data.rb"
37
+ "spec/spec_helper.rb",
38
+ "spec/stats_combiner_spec.rb"
38
39
  ]
39
40
 
40
41
  if s.respond_to? :specification_version then
41
42
  current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
42
43
  s.specification_version = 3
43
44
 
44
- if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
45
- s.add_runtime_dependency(%q<crack>, [">= 0"])
45
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
46
+ s.add_runtime_dependency(%q<chartbeat>, [">= 0"])
46
47
  s.add_runtime_dependency(%q<sequel>, [">= 0"])
47
48
  s.add_development_dependency(%q<rspec>, [">= 0"])
48
49
  s.add_development_dependency(%q<fakeweb>, [">= 0"])
49
50
  s.add_development_dependency(%q<timecop>, [">= 0"])
50
51
  s.add_development_dependency(%q<hpricot>, [">= 0"])
51
52
  else
52
- s.add_dependency(%q<crack>, [">= 0"])
53
+ s.add_dependency(%q<chartbeat>, [">= 0"])
53
54
  s.add_dependency(%q<sequel>, [">= 0"])
54
55
  s.add_dependency(%q<rspec>, [">= 0"])
55
56
  s.add_dependency(%q<fakeweb>, [">= 0"])
@@ -57,7 +58,7 @@ Gem::Specification.new do |s|
57
58
  s.add_dependency(%q<hpricot>, [">= 0"])
58
59
  end
59
60
  else
60
- s.add_dependency(%q<crack>, [">= 0"])
61
+ s.add_dependency(%q<chartbeat>, [">= 0"])
61
62
  s.add_dependency(%q<sequel>, [">= 0"])
62
63
  s.add_dependency(%q<rspec>, [">= 0"])
63
64
  s.add_dependency(%q<fakeweb>, [">= 0"])
metadata CHANGED
@@ -1,12 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: stats_combiner
3
3
  version: !ruby/object:Gem::Version
4
+ hash: 27
4
5
  prerelease: false
5
6
  segments:
6
7
  - 0
7
8
  - 0
8
- - 1
9
- version: 0.0.1
9
+ - 2
10
+ version: 0.0.2
10
11
  platform: ruby
11
12
  authors:
12
13
  - Al Shaw
@@ -14,16 +15,18 @@ autorequire:
14
15
  bindir: bin
15
16
  cert_chain: []
16
17
 
17
- date: 2010-05-24 00:00:00 -04:00
18
+ date: 2010-06-21 00:00:00 -04:00
18
19
  default_executable:
19
20
  dependencies:
20
21
  - !ruby/object:Gem::Dependency
21
- name: crack
22
+ name: chartbeat
22
23
  prerelease: false
23
24
  requirement: &id001 !ruby/object:Gem::Requirement
25
+ none: false
24
26
  requirements:
25
27
  - - ">="
26
28
  - !ruby/object:Gem::Version
29
+ hash: 3
27
30
  segments:
28
31
  - 0
29
32
  version: "0"
@@ -33,9 +36,11 @@ dependencies:
33
36
  name: sequel
34
37
  prerelease: false
35
38
  requirement: &id002 !ruby/object:Gem::Requirement
39
+ none: false
36
40
  requirements:
37
41
  - - ">="
38
42
  - !ruby/object:Gem::Version
43
+ hash: 3
39
44
  segments:
40
45
  - 0
41
46
  version: "0"
@@ -45,9 +50,11 @@ dependencies:
45
50
  name: rspec
46
51
  prerelease: false
47
52
  requirement: &id003 !ruby/object:Gem::Requirement
53
+ none: false
48
54
  requirements:
49
55
  - - ">="
50
56
  - !ruby/object:Gem::Version
57
+ hash: 3
51
58
  segments:
52
59
  - 0
53
60
  version: "0"
@@ -57,9 +64,11 @@ dependencies:
57
64
  name: fakeweb
58
65
  prerelease: false
59
66
  requirement: &id004 !ruby/object:Gem::Requirement
67
+ none: false
60
68
  requirements:
61
69
  - - ">="
62
70
  - !ruby/object:Gem::Version
71
+ hash: 3
63
72
  segments:
64
73
  - 0
65
74
  version: "0"
@@ -69,9 +78,11 @@ dependencies:
69
78
  name: timecop
70
79
  prerelease: false
71
80
  requirement: &id005 !ruby/object:Gem::Requirement
81
+ none: false
72
82
  requirements:
73
83
  - - ">="
74
84
  - !ruby/object:Gem::Version
85
+ hash: 3
75
86
  segments:
76
87
  - 0
77
88
  version: "0"
@@ -81,9 +92,11 @@ dependencies:
81
92
  name: hpricot
82
93
  prerelease: false
83
94
  requirement: &id006 !ruby/object:Gem::Requirement
95
+ none: false
84
96
  requirements:
85
97
  - - ">="
86
98
  - !ruby/object:Gem::Version
99
+ hash: 3
87
100
  segments:
88
101
  - 0
89
102
  version: "0"
@@ -105,8 +118,9 @@ files:
105
118
  - combiner_sample.rb
106
119
  - lib/stats_combiner.rb
107
120
  - lib/stats_combiner/filterer.rb
121
+ - spec/spec.opts
122
+ - spec/spec_helper.rb
108
123
  - spec/stats_combiner_spec.rb
109
- - spec/test_data.rb
110
124
  - stats_combiner.gemspec
111
125
  has_rdoc: true
112
126
  homepage: http://github.com/tpm/stats_combiner
@@ -118,26 +132,30 @@ rdoc_options:
118
132
  require_paths:
119
133
  - lib
120
134
  required_ruby_version: !ruby/object:Gem::Requirement
135
+ none: false
121
136
  requirements:
122
137
  - - ">="
123
138
  - !ruby/object:Gem::Version
139
+ hash: 3
124
140
  segments:
125
141
  - 0
126
142
  version: "0"
127
143
  required_rubygems_version: !ruby/object:Gem::Requirement
144
+ none: false
128
145
  requirements:
129
146
  - - ">="
130
147
  - !ruby/object:Gem::Version
148
+ hash: 3
131
149
  segments:
132
150
  - 0
133
151
  version: "0"
134
152
  requirements: []
135
153
 
136
154
  rubyforge_project:
137
- rubygems_version: 1.3.6
155
+ rubygems_version: 1.3.7
138
156
  signing_key:
139
157
  specification_version: 3
140
158
  summary: StatsCombiner creates most-viewed story widgets from the Chartbeat API
141
159
  test_files:
160
+ - spec/spec_helper.rb
142
161
  - spec/stats_combiner_spec.rb
143
- - spec/test_data.rb