yahoo-group-data 1.0.0 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -17,6 +17,8 @@ p = g.post_email
17
17
  s = g.subscribe_email
18
18
  u = g.unsubscribe_email
19
19
  o = g.unsubscribe_email
20
+
21
+ json = g.to_json
20
22
  ```
21
23
 
22
24
  ### Available instance methods
@@ -28,6 +30,7 @@ These should be relatively self-explanatory. Where the data is unnavailable (for
28
30
  - not_found?
29
31
  - private?
30
32
  - age_restricted?
33
+ - no_data? (true if any of the above are true, othersise false. Here for convenience)
31
34
 
32
35
  #### String values
33
36
 
@@ -39,6 +42,7 @@ These should be relatively self-explanatory. Where the data is unnavailable (for
39
42
  - unsubscribe_email
40
43
  - language
41
44
  - category
45
+ - to_json
42
46
 
43
47
  #### Other values
44
48
 
@@ -1,3 +1,3 @@
1
1
  class YahooGroupData
2
- VERSION = "1.0.0"
2
+ VERSION = "1.1.0"
3
3
  end
@@ -106,6 +106,10 @@ class YahooGroupData
106
106
  Yajl::Encoder.encode(data_hash)
107
107
  end
108
108
 
109
+ def no_data?
110
+ private? or age_restricted? or not_found?
111
+ end
112
+
109
113
  private
110
114
 
111
115
  def matches_private?
@@ -119,10 +123,6 @@ class YahooGroupData
119
123
  @matches_age_restricted ||= (doc.xpath('/html/body/div[3]/div/div/div/h4').size > 0 and doc.xpath('/html/body/div[3]/div/div/div/h4').first.inner_html.strip.match(/You've reached an Age-Restricted Area/i)) ? true : false
120
124
  end
121
125
 
122
- def no_data?
123
- private? or age_restricted? or not_found?
124
- end
125
-
126
126
  # French: jan,fév,mar,avr,mai,jun,jul,aoû,sep,oct,nov,déc
127
127
  # German: jan,feb,mrz,apr,mai,jun,jul,aug,sep,okt,nov,dez
128
128
  # Portuguese: jan,fev,mar,abr,mai,jun,jul,ago,set,out,nov,dez
@@ -13,7 +13,6 @@ class YahooGroupDataTest < Test::Unit::TestCase
13
13
  to_return(:status => 200, :body => File.read("test/yahoo_pages/#{original_group['id']}.html"), :headers => {})
14
14
 
15
15
  g = YahooGroupData.new(original_group["url"])
16
- puts original_group["url"]
17
16
  data = Yajl::Parser.parse(g.to_json)
18
17
 
19
18
  assert_equal original_group['private'], data['private']
@@ -32,6 +31,16 @@ class YahooGroupDataTest < Test::Unit::TestCase
32
31
  end
33
32
  end
34
33
 
34
+ def test_no_data
35
+ YAML.load_file('test/groups.yml')["groups"].each do |original_group|
36
+ stub_request(:get, original_group["url"]).
37
+ to_return(:status => 200, :body => File.read("test/yahoo_pages/#{original_group['id']}.html"), :headers => {})
38
+
39
+ g = YahooGroupData.new(original_group["url"])
40
+ assert_equal g.no_data?, (original_group['private'] || original_group['not_found'] || original_group['age_restricted'])
41
+ end
42
+ end
43
+
35
44
  def test_initialize_with_invalid_params
36
45
  assert_raise(ArgumentError) { YahooGroupData.new }
37
46
  end
@@ -65,7 +74,6 @@ class YahooGroupDataTest < Test::Unit::TestCase
65
74
  # then runs the assertions on each one.
66
75
  def test_data_extraction
67
76
  YAML.load_file('test/groups.yml')["groups"].each do |g_data|
68
- puts "fetching #{g_data["url"]}"
69
77
  stub_request(:get, g_data["url"]).
70
78
  to_return(:status => 200, :body => File.read("test/yahoo_pages/#{g_data['id']}.html"), :headers => {})
71
79
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: yahoo-group-data
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.1.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -13,7 +13,7 @@ date: 2012-02-03 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: nokogiri
16
- requirement: &70311668310240 !ruby/object:Gem::Requirement
16
+ requirement: &70321718153700 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ~>
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '1.5'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70311668310240
24
+ version_requirements: *70321718153700
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: yajl-ruby
27
- requirement: &70311668309540 !ruby/object:Gem::Requirement
27
+ requirement: &70321718153000 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ~>
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: '1.1'
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *70311668309540
35
+ version_requirements: *70321718153000
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: curb
38
- requirement: &70311668308520 !ruby/object:Gem::Requirement
38
+ requirement: &70321718151980 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ~>
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: '0.8'
44
44
  type: :runtime
45
45
  prerelease: false
46
- version_requirements: *70311668308520
46
+ version_requirements: *70321718151980
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: webmock
49
- requirement: &70311668308100 !ruby/object:Gem::Requirement
49
+ requirement: &70321718151560 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ! '>='
@@ -54,10 +54,10 @@ dependencies:
54
54
  version: '0'
55
55
  type: :development
56
56
  prerelease: false
57
- version_requirements: *70311668308100
57
+ version_requirements: *70321718151560
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: simplecov
60
- requirement: &70311668307600 !ruby/object:Gem::Requirement
60
+ requirement: &70321718151060 !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
63
63
  - - ! '>='
@@ -65,7 +65,7 @@ dependencies:
65
65
  version: '0'
66
66
  type: :development
67
67
  prerelease: false
68
- version_requirements: *70311668307600
68
+ version_requirements: *70321718151060
69
69
  description: A lib to fetch public Yahoo group data
70
70
  email:
71
71
  - will@willj.net