twitter-stats 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,5 +1,5 @@
1
1
  module Twitter
2
2
  module Stats
3
- VERSION = "0.0.2"
3
+ VERSION = "0.0.3"
4
4
  end
5
5
  end
data/lib/twitter-stats.rb CHANGED
@@ -1,6 +1,7 @@
1
1
  require "twitter-stats/version"
2
2
  require 'nokogiri'
3
3
  require 'open-uri'
4
+ require 'pry'
4
5
 
5
6
  module Twitter
6
7
  module Stats
@@ -26,8 +27,16 @@ module Twitter
26
27
  end
27
28
 
28
29
  def fetch
29
- doc = Nokogiri::HTML(open(topsy_search_url))
30
- doc.css('.result-desc strong')[2].content.to_i
30
+ @doc = Nokogiri::HTML(open(topsy_search_url))
31
+ has_no_results? ? 0 : results_count
32
+ end
33
+
34
+ def has_no_results?
35
+ @doc.css('.no-results-box').count > 0
36
+ end
37
+
38
+ def results_count
39
+ @doc.css('.result-desc strong')[2].content.to_i
31
40
  end
32
41
  end
33
42
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: twitter-stats
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-06-14 00:00:00.000000000 Z
12
+ date: 2012-06-15 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: nokogiri
@@ -56,12 +56,18 @@ required_ruby_version: !ruby/object:Gem::Requirement
56
56
  - - ! '>='
57
57
  - !ruby/object:Gem::Version
58
58
  version: '0'
59
+ segments:
60
+ - 0
61
+ hash: -1457191016837128775
59
62
  required_rubygems_version: !ruby/object:Gem::Requirement
60
63
  none: false
61
64
  requirements:
62
65
  - - ! '>='
63
66
  - !ruby/object:Gem::Version
64
67
  version: '0'
68
+ segments:
69
+ - 0
70
+ hash: -1457191016837128775
65
71
  requirements: []
66
72
  rubyforge_project:
67
73
  rubygems_version: 1.8.23