rss_detector 0.0.2 → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.travis.yml +7 -0
- data/README.md +7 -2
- data/lib/rss_detector.rb +1 -0
- data/lib/rss_detector/version.rb +2 -2
- data/spec/rss_detector_spec.rb +48 -48
- metadata +5 -4
data/.travis.yml
ADDED
data/README.md
CHANGED
@@ -1,7 +1,12 @@
|
|
1
|
-
#
|
1
|
+
# RSSDetector [](https://travis-ci.org/yukihir0/rss_detector)
|
2
2
|
|
3
3
|
'rss_detector' provides feature for feed detection from html document.
|
4
4
|
|
5
|
+
## Requirements
|
6
|
+
|
7
|
+
- ruby 1.9
|
8
|
+
- [nokogiri](https://rubygems.org/gems/nokogiri)
|
9
|
+
|
5
10
|
## Install
|
6
11
|
|
7
12
|
```
|
@@ -22,7 +27,7 @@ in your Gemfile.
|
|
22
27
|
feed = RSSDetector::detect(html)
|
23
28
|
```
|
24
29
|
|
25
|
-
For more information, please see [here](https://github.com/yukihir0/rss_detector/blob/master/sample/sample.rb)
|
30
|
+
For more information, please see [here](https://github.com/yukihir0/rss_detector/blob/master/sample/sample.rb).
|
26
31
|
|
27
32
|
## License
|
28
33
|
|
data/lib/rss_detector.rb
CHANGED
data/lib/rss_detector/version.rb
CHANGED
@@ -1,3 +1,3 @@
|
|
1
|
-
|
2
|
-
VERSION = "0.0
|
1
|
+
class RssDetector
|
2
|
+
VERSION = "0.1.0"
|
3
3
|
end
|
data/spec/rss_detector_spec.rb
CHANGED
@@ -2,24 +2,24 @@
|
|
2
2
|
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
3
3
|
|
4
4
|
describe RSSDetector do
|
5
|
-
context
|
6
|
-
describe
|
7
|
-
context
|
8
|
-
it
|
9
|
-
|
10
|
-
|
5
|
+
context 'init' do
|
6
|
+
describe '#detect' do
|
7
|
+
context 'nil input' do
|
8
|
+
it 'should be no feed' do
|
9
|
+
feeds = RSSDetector::detect(nil)
|
10
|
+
feeds.size.should == 0
|
11
11
|
end
|
12
12
|
end
|
13
13
|
|
14
|
-
context
|
15
|
-
it
|
16
|
-
|
17
|
-
|
14
|
+
context 'null string input' do
|
15
|
+
it 'should be no feed' do
|
16
|
+
feeds = RSSDetector::detect('')
|
17
|
+
feeds.size.should == 0
|
18
18
|
end
|
19
19
|
end
|
20
20
|
|
21
|
-
context
|
22
|
-
it
|
21
|
+
context 'no contain feed input' do
|
22
|
+
it 'should be no feed' do
|
23
23
|
input = <<-EOS
|
24
24
|
<html><head>
|
25
25
|
</head></html>
|
@@ -30,23 +30,23 @@ describe RSSDetector do
|
|
30
30
|
end
|
31
31
|
end
|
32
32
|
|
33
|
-
context
|
34
|
-
it
|
33
|
+
context 'contain 1 rss feed input' do
|
34
|
+
it 'should be 1 rss feed' do
|
35
35
|
input = <<-EOS
|
36
36
|
<html><head>
|
37
37
|
<link rel="alternate" type="application/rss+xml" title="test_rss_feed_title" href="http://test_rss_feed_url/"/>
|
38
38
|
</head></html>
|
39
39
|
EOS
|
40
40
|
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
41
|
+
feeds = RSSDetector::detect(input)
|
42
|
+
feeds.length.should == 1
|
43
|
+
feeds[0][:title].to_s.should == 'test_rss_feed_title'
|
44
|
+
feeds[0][:url].to_s.should == 'http://test_rss_feed_url/'
|
45
45
|
end
|
46
46
|
end
|
47
47
|
|
48
|
-
context
|
49
|
-
it
|
48
|
+
context 'contain 2 rss feed input' do
|
49
|
+
it 'should be 2 rss feed' do
|
50
50
|
input = <<-EOS
|
51
51
|
<html><head>
|
52
52
|
<link rel="alternate" type="application/rss+xml" title="test_rss_feed_title_1" href="http://test_rss_feed_url_1/"/>
|
@@ -54,32 +54,32 @@ describe RSSDetector do
|
|
54
54
|
</head></html>
|
55
55
|
EOS
|
56
56
|
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
57
|
+
feeds = RSSDetector::detect(input)
|
58
|
+
feeds.length.should == 2
|
59
|
+
feeds[0][:title].to_s.should == 'test_rss_feed_title_1'
|
60
|
+
feeds[0][:url].to_s.should == 'http://test_rss_feed_url_1/'
|
61
|
+
feeds[1][:title].to_s.should == 'test_rss_feed_title_2'
|
62
|
+
feeds[1][:url].to_s.should == 'http://test_rss_feed_url_2/'
|
63
63
|
end
|
64
64
|
end
|
65
65
|
|
66
|
-
context
|
67
|
-
it
|
66
|
+
context 'contain 1 atom feed input' do
|
67
|
+
it 'should be 1 atom feed' do
|
68
68
|
input = <<-EOS
|
69
69
|
<html><head>
|
70
70
|
<link rel="alternate" type="application/atom+xml" title="test_atom_feed_title" href="http://test_atom_feed_url/"/>
|
71
71
|
</head></html>
|
72
72
|
EOS
|
73
73
|
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
74
|
+
feeds = RSSDetector::detect(input)
|
75
|
+
feeds.length.should == 1
|
76
|
+
feeds[0][:title].to_s.should == 'test_atom_feed_title'
|
77
|
+
feeds[0][:url].to_s.should == 'http://test_atom_feed_url/'
|
78
78
|
end
|
79
79
|
end
|
80
80
|
|
81
|
-
context
|
82
|
-
it
|
81
|
+
context 'contain 2 atom feed input' do
|
82
|
+
it 'should be 2 atom feed' do
|
83
83
|
input = <<-EOS
|
84
84
|
<html><head>
|
85
85
|
<link rel="alternate" type="application/atom+xml" title="test_atom_feed_title_1" href="http://test_atom_feed_url_1/"/>
|
@@ -87,17 +87,17 @@ describe RSSDetector do
|
|
87
87
|
</head></html>
|
88
88
|
EOS
|
89
89
|
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
90
|
+
feeds = RSSDetector::detect(input)
|
91
|
+
feeds.length.should == 2
|
92
|
+
feeds[0][:title].to_s.should == 'test_atom_feed_title_1'
|
93
|
+
feeds[0][:url].to_s.should == 'http://test_atom_feed_url_1/'
|
94
|
+
feeds[1][:title].to_s.should == 'test_atom_feed_title_2'
|
95
|
+
feeds[1][:url].to_s.should == 'http://test_atom_feed_url_2/'
|
96
96
|
end
|
97
97
|
end
|
98
98
|
|
99
|
-
context
|
100
|
-
it
|
99
|
+
context 'contain rss and atom feed input' do
|
100
|
+
it 'should be rss and atom feed' do
|
101
101
|
input = <<-EOS
|
102
102
|
<html><head>
|
103
103
|
<link rel="alternate" type="application/rss+xml" title="test_rss_feed_title" href="http://test_rss_feed_url/"/>
|
@@ -105,12 +105,12 @@ describe RSSDetector do
|
|
105
105
|
</head></html>
|
106
106
|
EOS
|
107
107
|
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
108
|
+
feeds = RSSDetector::detect(input)
|
109
|
+
feeds.length.should == 2
|
110
|
+
feeds[0][:title].to_s.should == 'test_rss_feed_title'
|
111
|
+
feeds[0][:url].to_s.should == 'http://test_rss_feed_url/'
|
112
|
+
feeds[1][:title].to_s.should == 'test_atom_feed_title'
|
113
|
+
feeds[1][:url].to_s.should == 'http://test_atom_feed_url/'
|
114
114
|
end
|
115
115
|
end
|
116
116
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rss_detector
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
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: 2013-01-
|
12
|
+
date: 2013-01-09 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: nokogiri
|
@@ -51,6 +51,7 @@ extensions: []
|
|
51
51
|
extra_rdoc_files: []
|
52
52
|
files:
|
53
53
|
- .gitignore
|
54
|
+
- .travis.yml
|
54
55
|
- Gemfile
|
55
56
|
- LICENSE.txt
|
56
57
|
- README.md
|
@@ -75,7 +76,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
75
76
|
version: '0'
|
76
77
|
segments:
|
77
78
|
- 0
|
78
|
-
hash:
|
79
|
+
hash: 3615957483934444237
|
79
80
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
80
81
|
none: false
|
81
82
|
requirements:
|
@@ -84,7 +85,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
84
85
|
version: '0'
|
85
86
|
segments:
|
86
87
|
- 0
|
87
|
-
hash:
|
88
|
+
hash: 3615957483934444237
|
88
89
|
requirements: []
|
89
90
|
rubyforge_project:
|
90
91
|
rubygems_version: 1.8.24
|