yahoo-group-data 1.1.1 → 1.2.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -17,6 +17,11 @@ class YahooGroupData
17
17
  @response_code = curb.response_code
18
18
  end
19
19
 
20
+ def [](thing)
21
+ return unless respond_to? thing
22
+ send(thing)
23
+ end
24
+
20
25
  def name
21
26
  @name ||= if not_found? || age_restricted?
22
27
  nil
@@ -153,7 +158,7 @@ class YahooGroupData
153
158
  attr_reader :html, :doc
154
159
 
155
160
  def has_category?
156
- doc.xpath('//ul[@class="ygrp-ul ygrp-info"]//li').count == 3 ? false : true
161
+ doc.xpath('//ul[@class="ygrp-ul ygrp-info"]//li').count == 3 ? false : true
157
162
  end
158
163
 
159
164
  def doc
@@ -1,3 +1,3 @@
1
1
  class YahooGroupData
2
- VERSION = "1.1.1"
2
+ VERSION = "1.2.1"
3
3
  end
@@ -7,7 +7,7 @@ require 'yajl'
7
7
 
8
8
  class YahooGroupDataTest < Test::Unit::TestCase
9
9
 
10
- def test_to_json
10
+ def test_to_json
11
11
  YAML.load_file('test/groups.yml')["groups"].each do |original_group|
12
12
  stub_request(:get, original_group["url"]).
13
13
  to_return(:status => 200, :body => File.read("test/yahoo_pages/#{original_group['id']}.html"), :headers => {})
@@ -31,6 +31,28 @@ class YahooGroupDataTest < Test::Unit::TestCase
31
31
  end
32
32
  end
33
33
 
34
+ def test_hash_access
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
+
41
+ # Real data
42
+ assert_equal original_group['private'], g['private?']
43
+ assert_equal original_group['private'], g[:private?]
44
+ assert_equal original_group['not_found'], g['not_found?']
45
+ assert_equal original_group['not_found'], g[:not_found?]
46
+ assert_equal original_group['age_restricted'], g['age_restricted?']
47
+ assert_equal original_group['age_restricted'], g[:age_restricted?]
48
+ assert_equal original_group['name'], g['name']
49
+ assert_equal original_group['name'], g[:name]
50
+
51
+ # Non-existant data
52
+ assert_nil g[:nameWOOOOOO]
53
+ end
54
+ end
55
+
34
56
  def test_no_data
35
57
  YAML.load_file('test/groups.yml')["groups"].each do |original_group|
36
58
  stub_request(:get, original_group["url"]).
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.1.1
4
+ version: 1.2.1
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-02-05 00:00:00.000000000 Z
12
+ date: 2012-05-18 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: nokogiri
16
- requirement: &70212330858720 !ruby/object:Gem::Requirement
16
+ requirement: &70250188180720 !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: *70212330858720
24
+ version_requirements: *70250188180720
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: yajl-ruby
27
- requirement: &70212330858040 !ruby/object:Gem::Requirement
27
+ requirement: &70250188180020 !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: *70212330858040
35
+ version_requirements: *70250188180020
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: curb
38
- requirement: &70212330856980 !ruby/object:Gem::Requirement
38
+ requirement: &70250188178700 !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: *70212330856980
46
+ version_requirements: *70250188178700
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: webmock
49
- requirement: &70212330856580 !ruby/object:Gem::Requirement
49
+ requirement: &70250188178160 !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: *70212330856580
57
+ version_requirements: *70250188178160
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: simplecov
60
- requirement: &70212330856100 !ruby/object:Gem::Requirement
60
+ requirement: &70250188177660 !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: *70212330856100
68
+ version_requirements: *70250188177660
69
69
  description: A lib to fetch public Yahoo group data
70
70
  email:
71
71
  - will@willj.net