pavlov_rss 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +21 -0
- data/.rspec +2 -0
- data/Gemfile +4 -0
- data/Gemfile.lock +164 -0
- data/Guardfile +9 -0
- data/LICENSE +20 -0
- data/README.md +4 -0
- data/Rakefile +1 -0
- data/lib/pavlov_rss/reader.rb +31 -0
- data/lib/pavlov_rss/version.rb +3 -0
- data/lib/pavlov_rss.rb +5 -0
- data/pavlov_rss.gemspec +32 -0
- data/spec/fixtures/rss0.xml +8 -0
- data/spec/fixtures/rss1.xml +13 -0
- data/spec/fixtures/rss2.xml +18 -0
- data/spec/fixtures/rss3.xml +23 -0
- data/spec/fixtures/rss4.xml +23 -0
- data/spec/fixtures/rss5.xml +23 -0
- data/spec/lib/pavlov_rss/reader_spec.rb +126 -0
- data/spec/spec_helper.rb +36 -0
- metadata +228 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 7a283bd077d0807c832bb7772d904597da3a9ae0
|
4
|
+
data.tar.gz: 4067c283aafb92a3240b51ecdd3030ddb3bf5391
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 032a7211bcaf5a3732cd147b80aef9c4362b2a71941e570e8ffed243ea16e4f16c72c0473a063d18decf24ff674457c937cf94134aa171f45e0a061925257de7
|
7
|
+
data.tar.gz: f528831eec780a89c1f867f095c25057c526f0ba5695e9bacbca37c6303d16fe270cd2106183f510749240d82cdd66088a612274ee8a8e96435b8837992c6070
|
data/.gitignore
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
*.swp
|
2
|
+
*.gem
|
3
|
+
*.rbc
|
4
|
+
.bundle
|
5
|
+
.config
|
6
|
+
coverage
|
7
|
+
InstalledFiles
|
8
|
+
lib/bundler/man
|
9
|
+
pkg
|
10
|
+
rdoc
|
11
|
+
spec/reports
|
12
|
+
test/tmp
|
13
|
+
test/version_tmp
|
14
|
+
tmp
|
15
|
+
.ruby-version
|
16
|
+
.ruby-gemset
|
17
|
+
|
18
|
+
# YARD artifacts
|
19
|
+
.yardoc
|
20
|
+
_yardoc
|
21
|
+
doc/
|
data/.rspec
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,164 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
pavlov_rss (0.0.1)
|
5
|
+
activesupport
|
6
|
+
nokogiri
|
7
|
+
|
8
|
+
GEM
|
9
|
+
remote: https://rubygems.org/
|
10
|
+
specs:
|
11
|
+
activesupport (4.0.2)
|
12
|
+
i18n (~> 0.6, >= 0.6.4)
|
13
|
+
minitest (~> 4.2)
|
14
|
+
multi_json (~> 1.3)
|
15
|
+
thread_safe (~> 0.1)
|
16
|
+
tzinfo (~> 0.3.37)
|
17
|
+
arrayfields (4.9.0)
|
18
|
+
atomic (1.1.14)
|
19
|
+
awesome_print (1.2.0)
|
20
|
+
cane (2.6.1)
|
21
|
+
parallel
|
22
|
+
celluloid (0.15.2)
|
23
|
+
timers (~> 1.1.0)
|
24
|
+
chronic (0.10.2)
|
25
|
+
churn (0.0.35)
|
26
|
+
chronic (>= 0.2.3)
|
27
|
+
hirb
|
28
|
+
json_pure
|
29
|
+
main
|
30
|
+
rest-client (>= 1.6.0)
|
31
|
+
ruby_parser (~> 3.0)
|
32
|
+
sexp_processor (~> 4.1)
|
33
|
+
code_analyzer (0.4.4)
|
34
|
+
sexp_processor
|
35
|
+
code_metrics (0.1.3)
|
36
|
+
coderay (1.1.0)
|
37
|
+
colored (1.2)
|
38
|
+
diff-lcs (1.2.5)
|
39
|
+
docile (1.1.2)
|
40
|
+
erubis (2.7.0)
|
41
|
+
fakeweb (1.3.0)
|
42
|
+
fattr (2.2.1)
|
43
|
+
ffi (1.9.3)
|
44
|
+
flay (2.4.0)
|
45
|
+
ruby_parser (~> 3.0)
|
46
|
+
sexp_processor (~> 4.0)
|
47
|
+
flog (4.2.0)
|
48
|
+
ruby_parser (~> 3.1, > 3.1.0)
|
49
|
+
sexp_processor (~> 4.4)
|
50
|
+
formatador (0.2.4)
|
51
|
+
guard (2.3.0)
|
52
|
+
formatador (>= 0.2.4)
|
53
|
+
listen (~> 2.1)
|
54
|
+
lumberjack (~> 1.0)
|
55
|
+
pry (>= 0.9.12)
|
56
|
+
thor (>= 0.18.1)
|
57
|
+
guard-rspec (4.2.4)
|
58
|
+
guard (~> 2.1)
|
59
|
+
rspec (>= 2.14, < 4.0)
|
60
|
+
hirb (0.7.1)
|
61
|
+
i18n (0.6.9)
|
62
|
+
json_pure (1.8.1)
|
63
|
+
listen (2.4.0)
|
64
|
+
celluloid (>= 0.15.2)
|
65
|
+
rb-fsevent (>= 0.9.3)
|
66
|
+
rb-inotify (>= 0.9)
|
67
|
+
lumberjack (1.0.4)
|
68
|
+
main (5.2.0)
|
69
|
+
arrayfields (>= 4.7.4)
|
70
|
+
chronic (>= 0.6.2)
|
71
|
+
fattr (>= 2.2.0)
|
72
|
+
map (>= 5.1.0)
|
73
|
+
map (6.5.1)
|
74
|
+
method_source (0.8.2)
|
75
|
+
metric_fu (4.7.2)
|
76
|
+
cane (~> 2.5, >= 2.5.2)
|
77
|
+
churn (~> 0.0.35)
|
78
|
+
code_metrics (~> 0.1)
|
79
|
+
coderay
|
80
|
+
flay (~> 2.1, >= 2.0.1)
|
81
|
+
flog (~> 4.1, >= 4.1.1)
|
82
|
+
metric_fu-Saikuro (~> 1.1, >= 1.1.3)
|
83
|
+
multi_json
|
84
|
+
rails_best_practices (~> 1.14, >= 1.14.3)
|
85
|
+
redcard
|
86
|
+
reek (~> 1.3, >= 1.3.4)
|
87
|
+
roodi (~> 3.1)
|
88
|
+
metric_fu-Saikuro (1.1.3)
|
89
|
+
mime-types (2.1)
|
90
|
+
mini_portile (0.5.2)
|
91
|
+
minitest (4.7.5)
|
92
|
+
multi_json (1.8.4)
|
93
|
+
nokogiri (1.6.1)
|
94
|
+
mini_portile (~> 0.5.0)
|
95
|
+
parallel (0.9.2)
|
96
|
+
pry (0.9.12.4)
|
97
|
+
coderay (~> 1.0)
|
98
|
+
method_source (~> 0.8)
|
99
|
+
slop (~> 3.4)
|
100
|
+
rails_best_practices (1.14.4)
|
101
|
+
activesupport
|
102
|
+
awesome_print
|
103
|
+
code_analyzer (>= 0.4.3)
|
104
|
+
colored
|
105
|
+
erubis
|
106
|
+
i18n
|
107
|
+
require_all
|
108
|
+
ruby-progressbar
|
109
|
+
rake (10.1.1)
|
110
|
+
rb-fsevent (0.9.4)
|
111
|
+
rb-inotify (0.9.3)
|
112
|
+
ffi (>= 0.5.0)
|
113
|
+
redcard (1.1.0)
|
114
|
+
reek (1.3.6)
|
115
|
+
ruby2ruby (~> 2.0.7)
|
116
|
+
ruby_parser (~> 3.2)
|
117
|
+
sexp_processor
|
118
|
+
require_all (1.3.2)
|
119
|
+
rest-client (1.6.7)
|
120
|
+
mime-types (>= 1.16)
|
121
|
+
roodi (3.3.1)
|
122
|
+
ruby_parser (~> 3.2, >= 3.2.2)
|
123
|
+
rspec (2.14.1)
|
124
|
+
rspec-core (~> 2.14.0)
|
125
|
+
rspec-expectations (~> 2.14.0)
|
126
|
+
rspec-mocks (~> 2.14.0)
|
127
|
+
rspec-core (2.14.7)
|
128
|
+
rspec-expectations (2.14.4)
|
129
|
+
diff-lcs (>= 1.1.3, < 2.0)
|
130
|
+
rspec-mocks (2.14.4)
|
131
|
+
ruby-progressbar (1.4.0)
|
132
|
+
ruby2ruby (2.0.7)
|
133
|
+
ruby_parser (~> 3.1)
|
134
|
+
sexp_processor (~> 4.0)
|
135
|
+
ruby_parser (3.3.0)
|
136
|
+
sexp_processor (~> 4.1)
|
137
|
+
sexp_processor (4.4.1)
|
138
|
+
simplecov (0.8.2)
|
139
|
+
docile (~> 1.1.0)
|
140
|
+
multi_json
|
141
|
+
simplecov-html (~> 0.8.0)
|
142
|
+
simplecov-html (0.8.0)
|
143
|
+
simplecov-rcov-text (0.0.2)
|
144
|
+
slop (3.4.7)
|
145
|
+
thor (0.18.1)
|
146
|
+
thread_safe (0.1.3)
|
147
|
+
atomic
|
148
|
+
timers (1.1.0)
|
149
|
+
tzinfo (0.3.38)
|
150
|
+
|
151
|
+
PLATFORMS
|
152
|
+
ruby
|
153
|
+
|
154
|
+
DEPENDENCIES
|
155
|
+
bundler (~> 1.5)
|
156
|
+
fakeweb (~> 1.3)
|
157
|
+
guard
|
158
|
+
guard-rspec
|
159
|
+
metric_fu
|
160
|
+
pavlov_rss!
|
161
|
+
rake
|
162
|
+
rspec
|
163
|
+
simplecov
|
164
|
+
simplecov-rcov-text
|
data/Guardfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2014 Minwoo Lee
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
6
|
+
this software and associated documentation files (the "Software"), to deal in
|
7
|
+
the Software without restriction, including without limitation the rights to
|
8
|
+
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
9
|
+
the Software, and to permit persons to whom the Software is furnished to do so,
|
10
|
+
subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
17
|
+
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
18
|
+
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
19
|
+
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
20
|
+
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
@@ -0,0 +1,31 @@
|
|
1
|
+
require 'open-uri'
|
2
|
+
require 'nokogiri'
|
3
|
+
require 'active_support/core_ext'
|
4
|
+
|
5
|
+
module PavlovRss
|
6
|
+
class Reader
|
7
|
+
def initialize(urls)
|
8
|
+
@urls = Array(urls)
|
9
|
+
end
|
10
|
+
|
11
|
+
def check
|
12
|
+
now = @urls.map {|url| Nokogiri.XML(open(url,&:read))}
|
13
|
+
@prev ||= now
|
14
|
+
result = @prev.zip(now).map do |p,n|
|
15
|
+
new_items p, n
|
16
|
+
end
|
17
|
+
@prev = now
|
18
|
+
return result
|
19
|
+
end
|
20
|
+
|
21
|
+
def item_to_json rss
|
22
|
+
result = Hash.from_xml(rss.to_xml)['rss']['channel']['item'] || []
|
23
|
+
return result if result.is_a? Array
|
24
|
+
return [result]
|
25
|
+
end
|
26
|
+
|
27
|
+
def new_items lhs, rhs
|
28
|
+
item_to_json(rhs) - item_to_json(lhs)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
data/lib/pavlov_rss.rb
ADDED
data/pavlov_rss.gemspec
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'pavlov_rss/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "pavlov_rss"
|
8
|
+
spec.version = PavlovRss::VERSION
|
9
|
+
spec.authors = ["Minwoo Lee", "Insu Yun"]
|
10
|
+
spec.email = ["ermaker@gmail.com", "wuninsu@gmail.com"]
|
11
|
+
spec.summary = %q{Pavlov's RSS}
|
12
|
+
spec.description = %q{}
|
13
|
+
spec.homepage = ""
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0")
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_dependency "nokogiri"
|
22
|
+
spec.add_dependency "activesupport"
|
23
|
+
spec.add_development_dependency "bundler", "~> 1.5"
|
24
|
+
spec.add_development_dependency "rake"
|
25
|
+
spec.add_development_dependency "rspec"
|
26
|
+
spec.add_development_dependency "guard"
|
27
|
+
spec.add_development_dependency "guard-rspec"
|
28
|
+
spec.add_development_dependency "fakeweb", "~> 1.3"
|
29
|
+
spec.add_development_dependency "metric_fu"
|
30
|
+
spec.add_development_dependency "simplecov"
|
31
|
+
spec.add_development_dependency "simplecov-rcov-text"
|
32
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
<?xml version="1.0" encoding="utf-8"?>
|
2
|
+
<rss version="2.0">
|
3
|
+
<channel>
|
4
|
+
<title>title</title>
|
5
|
+
<link>http://example.com</link>
|
6
|
+
<description>description</description>
|
7
|
+
<item>
|
8
|
+
<title>title1</title>
|
9
|
+
<link>http://example.com/title1</link>
|
10
|
+
<description>description1</description>
|
11
|
+
</item>
|
12
|
+
</channel>
|
13
|
+
</rss>
|
@@ -0,0 +1,18 @@
|
|
1
|
+
<?xml version="1.0" encoding="utf-8"?>
|
2
|
+
<rss version="2.0">
|
3
|
+
<channel>
|
4
|
+
<title>title</title>
|
5
|
+
<link>http://example.com</link>
|
6
|
+
<description>description</description>
|
7
|
+
<item>
|
8
|
+
<title>title2</title>
|
9
|
+
<link>http://example.com/title2</link>
|
10
|
+
<description>description2</description>
|
11
|
+
</item>
|
12
|
+
<item>
|
13
|
+
<title>title1</title>
|
14
|
+
<link>http://example.com/title1</link>
|
15
|
+
<description>description1</description>
|
16
|
+
</item>
|
17
|
+
</channel>
|
18
|
+
</rss>
|
@@ -0,0 +1,23 @@
|
|
1
|
+
<?xml version="1.0" encoding="utf-8"?>
|
2
|
+
<rss version="2.0">
|
3
|
+
<channel>
|
4
|
+
<title>title</title>
|
5
|
+
<link>http://example.com</link>
|
6
|
+
<description>description</description>
|
7
|
+
<item>
|
8
|
+
<title>title3</title>
|
9
|
+
<link>http://example.com/title3</link>
|
10
|
+
<description>description3</description>
|
11
|
+
</item>
|
12
|
+
<item>
|
13
|
+
<title>title2</title>
|
14
|
+
<link>http://example.com/title2</link>
|
15
|
+
<description>description2</description>
|
16
|
+
</item>
|
17
|
+
<item>
|
18
|
+
<title>title1</title>
|
19
|
+
<link>http://example.com/title1</link>
|
20
|
+
<description>description1</description>
|
21
|
+
</item>
|
22
|
+
</channel>
|
23
|
+
</rss>
|
@@ -0,0 +1,23 @@
|
|
1
|
+
<?xml version="1.0" encoding="utf-8"?>
|
2
|
+
<rss version="2.0">
|
3
|
+
<channel>
|
4
|
+
<title>title</title>
|
5
|
+
<link>http://example.com</link>
|
6
|
+
<description>description</description>
|
7
|
+
<item>
|
8
|
+
<title>title4</title>
|
9
|
+
<link>http://example.com/title4</link>
|
10
|
+
<description>description4</description>
|
11
|
+
</item>
|
12
|
+
<item>
|
13
|
+
<title>title3</title>
|
14
|
+
<link>http://example.com/title3</link>
|
15
|
+
<description>description3</description>
|
16
|
+
</item>
|
17
|
+
<item>
|
18
|
+
<title>title2</title>
|
19
|
+
<link>http://example.com/title2</link>
|
20
|
+
<description>description2</description>
|
21
|
+
</item>
|
22
|
+
</channel>
|
23
|
+
</rss>
|
@@ -0,0 +1,23 @@
|
|
1
|
+
<?xml version="1.0" encoding="utf-8"?>
|
2
|
+
<rss version="2.0">
|
3
|
+
<channel>
|
4
|
+
<title>title</title>
|
5
|
+
<link>http://example.com</link>
|
6
|
+
<description>description</description>
|
7
|
+
<item>
|
8
|
+
<title>title5</title>
|
9
|
+
<link>http://example.com/title5</link>
|
10
|
+
<description>description5</description>
|
11
|
+
</item>
|
12
|
+
<item>
|
13
|
+
<title>title4</title>
|
14
|
+
<link>http://example.com/title4</link>
|
15
|
+
<description>description4</description>
|
16
|
+
</item>
|
17
|
+
<item>
|
18
|
+
<title>title3</title>
|
19
|
+
<link>http://example.com/title3</link>
|
20
|
+
<description>description3</description>
|
21
|
+
</item>
|
22
|
+
</channel>
|
23
|
+
</rss>
|
@@ -0,0 +1,126 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'pavlov_rss'
|
3
|
+
require 'nokogiri'
|
4
|
+
require 'fake_web'
|
5
|
+
|
6
|
+
describe PavlovRss::Reader do
|
7
|
+
after do
|
8
|
+
FakeWeb.clean_registry
|
9
|
+
end
|
10
|
+
|
11
|
+
context "with an example reader" do
|
12
|
+
before do
|
13
|
+
@url = "http://example.com/rss.xml"
|
14
|
+
@reader = PavlovRss::Reader.new @url
|
15
|
+
end
|
16
|
+
|
17
|
+
describe "#check" do
|
18
|
+
context "with static rss" do
|
19
|
+
before do
|
20
|
+
FakeWeb.register_uri(:get, @url, body: feed('rss1.xml'))
|
21
|
+
end
|
22
|
+
|
23
|
+
it "returns [[]] at first time" do
|
24
|
+
@reader.check.should == [[]]
|
25
|
+
end
|
26
|
+
|
27
|
+
it "returns [[]] without changes" do
|
28
|
+
@reader.check
|
29
|
+
@reader.check.should == [[]]
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
it "does not return [[]] with any chagnes" do
|
34
|
+
FakeWeb.register_uri(:get, @url, [
|
35
|
+
{body: feed('rss1.xml')},
|
36
|
+
{body: feed('rss2.xml')},
|
37
|
+
])
|
38
|
+
@reader.check
|
39
|
+
@reader.check.should_not == [[]]
|
40
|
+
end
|
41
|
+
|
42
|
+
it "returns new items" do
|
43
|
+
FakeWeb.register_uri(:get, @url, [
|
44
|
+
{body: feed('rss0.xml')},
|
45
|
+
{body: feed('rss1.xml')},
|
46
|
+
{body: feed('rss2.xml')},
|
47
|
+
{body: feed('rss3.xml')},
|
48
|
+
{body: feed('rss4.xml')},
|
49
|
+
{body: feed('rss5.xml')},
|
50
|
+
])
|
51
|
+
@reader.check
|
52
|
+
@reader.check.should == [[
|
53
|
+
{
|
54
|
+
"title"=>"title1",
|
55
|
+
"link"=>"http://example.com/title1",
|
56
|
+
"description"=>"description1"
|
57
|
+
}]]
|
58
|
+
@reader.check.should == [[
|
59
|
+
{
|
60
|
+
"title"=>"title2",
|
61
|
+
"link"=>"http://example.com/title2",
|
62
|
+
"description"=>"description2"
|
63
|
+
}]]
|
64
|
+
@reader.check.should == [[
|
65
|
+
{
|
66
|
+
"title"=>"title3",
|
67
|
+
"link"=>"http://example.com/title3",
|
68
|
+
"description"=>"description3"
|
69
|
+
}]]
|
70
|
+
@reader.check.should == [[
|
71
|
+
{
|
72
|
+
"title"=>"title4",
|
73
|
+
"link"=>"http://example.com/title4",
|
74
|
+
"description"=>"description4"
|
75
|
+
}]]
|
76
|
+
@reader.check.should == [[
|
77
|
+
{
|
78
|
+
"title"=>"title5",
|
79
|
+
"link"=>"http://example.com/title5",
|
80
|
+
"description"=>"description5"
|
81
|
+
}]]
|
82
|
+
@reader.check.should == [[]]
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
describe "#new_items" do
|
87
|
+
it "returns empty with same rss" do
|
88
|
+
rss1 = Nokogiri.XML(feed('rss1.xml'))
|
89
|
+
rss2 = Nokogiri.XML(feed('rss1.xml'))
|
90
|
+
items = @reader.new_items rss1, rss2
|
91
|
+
items.should == []
|
92
|
+
end
|
93
|
+
|
94
|
+
it "returns empty with not same rss" do
|
95
|
+
rss1 = Nokogiri.XML(feed('rss1.xml'))
|
96
|
+
rss2 = Nokogiri.XML(feed('rss2.xml'))
|
97
|
+
items = @reader.new_items rss1, rss2
|
98
|
+
|
99
|
+
items.should == [
|
100
|
+
{
|
101
|
+
"title"=>"title2",
|
102
|
+
"link"=>"http://example.com/title2",
|
103
|
+
"description"=>"description2"
|
104
|
+
}]
|
105
|
+
end
|
106
|
+
end
|
107
|
+
|
108
|
+
describe "#item_to_json" do
|
109
|
+
it "works" do
|
110
|
+
rss = Nokogiri.XML(feed('rss1.xml'))
|
111
|
+
result = @reader.item_to_json rss
|
112
|
+
result.should == [
|
113
|
+
{
|
114
|
+
"title"=>"title1",
|
115
|
+
"link"=>"http://example.com/title1",
|
116
|
+
"description"=>"description1"
|
117
|
+
}]
|
118
|
+
end
|
119
|
+
it "works on 0-items rss" do
|
120
|
+
rss = Nokogiri.XML(feed('rss0.xml'))
|
121
|
+
result = @reader.item_to_json rss
|
122
|
+
result.should == []
|
123
|
+
end
|
124
|
+
end
|
125
|
+
end
|
126
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
# This file was generated by the `rspec --init` command. Conventionally, all
|
2
|
+
# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
|
3
|
+
# Require this file using `require "spec_helper"` to ensure that it is only
|
4
|
+
# loaded once.
|
5
|
+
#
|
6
|
+
# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
|
7
|
+
if ENV['COVERAGE']
|
8
|
+
require 'simplecov'
|
9
|
+
formatters = [SimpleCov::Formatter::HTMLFormatter]
|
10
|
+
begin
|
11
|
+
puts '[COVERAGE] Running with SimpleCov HTML Formatter'
|
12
|
+
require 'simplecov-rcov-text'
|
13
|
+
formatters << SimpleCov::Formatter::RcovTextFormatter
|
14
|
+
puts '[COVERAGE] Running with SimpleCov Rcov Formatter'
|
15
|
+
rescue LoadError
|
16
|
+
puts '[COVERAGE] SimpleCov Rcov formatter could not be loaded'
|
17
|
+
end
|
18
|
+
SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter[ *formatters ]
|
19
|
+
SimpleCov.start
|
20
|
+
end
|
21
|
+
|
22
|
+
RSpec.configure do |config|
|
23
|
+
config.treat_symbols_as_metadata_keys_with_true_values = true
|
24
|
+
config.run_all_when_everything_filtered = true
|
25
|
+
config.filter_run :focus
|
26
|
+
|
27
|
+
# Run specs in random order to surface order dependencies. If you find an
|
28
|
+
# order dependency and want to debug it, you can fix the order by providing
|
29
|
+
# the seed, which is printed after each run.
|
30
|
+
# --seed 1234
|
31
|
+
config.order = 'random'
|
32
|
+
end
|
33
|
+
|
34
|
+
def feed fn
|
35
|
+
File.read(File.join(File.dirname(__FILE__), 'fixtures', fn))
|
36
|
+
end
|
metadata
ADDED
@@ -0,0 +1,228 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: pavlov_rss
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Minwoo Lee
|
8
|
+
- Insu Yun
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2014-02-14 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: nokogiri
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
requirements:
|
18
|
+
- - ">="
|
19
|
+
- !ruby/object:Gem::Version
|
20
|
+
version: '0'
|
21
|
+
type: :runtime
|
22
|
+
prerelease: false
|
23
|
+
version_requirements: !ruby/object:Gem::Requirement
|
24
|
+
requirements:
|
25
|
+
- - ">="
|
26
|
+
- !ruby/object:Gem::Version
|
27
|
+
version: '0'
|
28
|
+
- !ruby/object:Gem::Dependency
|
29
|
+
name: activesupport
|
30
|
+
requirement: !ruby/object:Gem::Requirement
|
31
|
+
requirements:
|
32
|
+
- - ">="
|
33
|
+
- !ruby/object:Gem::Version
|
34
|
+
version: '0'
|
35
|
+
type: :runtime
|
36
|
+
prerelease: false
|
37
|
+
version_requirements: !ruby/object:Gem::Requirement
|
38
|
+
requirements:
|
39
|
+
- - ">="
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
version: '0'
|
42
|
+
- !ruby/object:Gem::Dependency
|
43
|
+
name: bundler
|
44
|
+
requirement: !ruby/object:Gem::Requirement
|
45
|
+
requirements:
|
46
|
+
- - "~>"
|
47
|
+
- !ruby/object:Gem::Version
|
48
|
+
version: '1.5'
|
49
|
+
type: :development
|
50
|
+
prerelease: false
|
51
|
+
version_requirements: !ruby/object:Gem::Requirement
|
52
|
+
requirements:
|
53
|
+
- - "~>"
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: '1.5'
|
56
|
+
- !ruby/object:Gem::Dependency
|
57
|
+
name: rake
|
58
|
+
requirement: !ruby/object:Gem::Requirement
|
59
|
+
requirements:
|
60
|
+
- - ">="
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: '0'
|
63
|
+
type: :development
|
64
|
+
prerelease: false
|
65
|
+
version_requirements: !ruby/object:Gem::Requirement
|
66
|
+
requirements:
|
67
|
+
- - ">="
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '0'
|
70
|
+
- !ruby/object:Gem::Dependency
|
71
|
+
name: rspec
|
72
|
+
requirement: !ruby/object:Gem::Requirement
|
73
|
+
requirements:
|
74
|
+
- - ">="
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: '0'
|
77
|
+
type: :development
|
78
|
+
prerelease: false
|
79
|
+
version_requirements: !ruby/object:Gem::Requirement
|
80
|
+
requirements:
|
81
|
+
- - ">="
|
82
|
+
- !ruby/object:Gem::Version
|
83
|
+
version: '0'
|
84
|
+
- !ruby/object:Gem::Dependency
|
85
|
+
name: guard
|
86
|
+
requirement: !ruby/object:Gem::Requirement
|
87
|
+
requirements:
|
88
|
+
- - ">="
|
89
|
+
- !ruby/object:Gem::Version
|
90
|
+
version: '0'
|
91
|
+
type: :development
|
92
|
+
prerelease: false
|
93
|
+
version_requirements: !ruby/object:Gem::Requirement
|
94
|
+
requirements:
|
95
|
+
- - ">="
|
96
|
+
- !ruby/object:Gem::Version
|
97
|
+
version: '0'
|
98
|
+
- !ruby/object:Gem::Dependency
|
99
|
+
name: guard-rspec
|
100
|
+
requirement: !ruby/object:Gem::Requirement
|
101
|
+
requirements:
|
102
|
+
- - ">="
|
103
|
+
- !ruby/object:Gem::Version
|
104
|
+
version: '0'
|
105
|
+
type: :development
|
106
|
+
prerelease: false
|
107
|
+
version_requirements: !ruby/object:Gem::Requirement
|
108
|
+
requirements:
|
109
|
+
- - ">="
|
110
|
+
- !ruby/object:Gem::Version
|
111
|
+
version: '0'
|
112
|
+
- !ruby/object:Gem::Dependency
|
113
|
+
name: fakeweb
|
114
|
+
requirement: !ruby/object:Gem::Requirement
|
115
|
+
requirements:
|
116
|
+
- - "~>"
|
117
|
+
- !ruby/object:Gem::Version
|
118
|
+
version: '1.3'
|
119
|
+
type: :development
|
120
|
+
prerelease: false
|
121
|
+
version_requirements: !ruby/object:Gem::Requirement
|
122
|
+
requirements:
|
123
|
+
- - "~>"
|
124
|
+
- !ruby/object:Gem::Version
|
125
|
+
version: '1.3'
|
126
|
+
- !ruby/object:Gem::Dependency
|
127
|
+
name: metric_fu
|
128
|
+
requirement: !ruby/object:Gem::Requirement
|
129
|
+
requirements:
|
130
|
+
- - ">="
|
131
|
+
- !ruby/object:Gem::Version
|
132
|
+
version: '0'
|
133
|
+
type: :development
|
134
|
+
prerelease: false
|
135
|
+
version_requirements: !ruby/object:Gem::Requirement
|
136
|
+
requirements:
|
137
|
+
- - ">="
|
138
|
+
- !ruby/object:Gem::Version
|
139
|
+
version: '0'
|
140
|
+
- !ruby/object:Gem::Dependency
|
141
|
+
name: simplecov
|
142
|
+
requirement: !ruby/object:Gem::Requirement
|
143
|
+
requirements:
|
144
|
+
- - ">="
|
145
|
+
- !ruby/object:Gem::Version
|
146
|
+
version: '0'
|
147
|
+
type: :development
|
148
|
+
prerelease: false
|
149
|
+
version_requirements: !ruby/object:Gem::Requirement
|
150
|
+
requirements:
|
151
|
+
- - ">="
|
152
|
+
- !ruby/object:Gem::Version
|
153
|
+
version: '0'
|
154
|
+
- !ruby/object:Gem::Dependency
|
155
|
+
name: simplecov-rcov-text
|
156
|
+
requirement: !ruby/object:Gem::Requirement
|
157
|
+
requirements:
|
158
|
+
- - ">="
|
159
|
+
- !ruby/object:Gem::Version
|
160
|
+
version: '0'
|
161
|
+
type: :development
|
162
|
+
prerelease: false
|
163
|
+
version_requirements: !ruby/object:Gem::Requirement
|
164
|
+
requirements:
|
165
|
+
- - ">="
|
166
|
+
- !ruby/object:Gem::Version
|
167
|
+
version: '0'
|
168
|
+
description: ''
|
169
|
+
email:
|
170
|
+
- ermaker@gmail.com
|
171
|
+
- wuninsu@gmail.com
|
172
|
+
executables: []
|
173
|
+
extensions: []
|
174
|
+
extra_rdoc_files: []
|
175
|
+
files:
|
176
|
+
- ".gitignore"
|
177
|
+
- ".rspec"
|
178
|
+
- Gemfile
|
179
|
+
- Gemfile.lock
|
180
|
+
- Guardfile
|
181
|
+
- LICENSE
|
182
|
+
- README.md
|
183
|
+
- Rakefile
|
184
|
+
- lib/pavlov_rss.rb
|
185
|
+
- lib/pavlov_rss/reader.rb
|
186
|
+
- lib/pavlov_rss/version.rb
|
187
|
+
- pavlov_rss.gemspec
|
188
|
+
- spec/fixtures/rss0.xml
|
189
|
+
- spec/fixtures/rss1.xml
|
190
|
+
- spec/fixtures/rss2.xml
|
191
|
+
- spec/fixtures/rss3.xml
|
192
|
+
- spec/fixtures/rss4.xml
|
193
|
+
- spec/fixtures/rss5.xml
|
194
|
+
- spec/lib/pavlov_rss/reader_spec.rb
|
195
|
+
- spec/spec_helper.rb
|
196
|
+
homepage: ''
|
197
|
+
licenses:
|
198
|
+
- MIT
|
199
|
+
metadata: {}
|
200
|
+
post_install_message:
|
201
|
+
rdoc_options: []
|
202
|
+
require_paths:
|
203
|
+
- lib
|
204
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
205
|
+
requirements:
|
206
|
+
- - ">="
|
207
|
+
- !ruby/object:Gem::Version
|
208
|
+
version: '0'
|
209
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
210
|
+
requirements:
|
211
|
+
- - ">="
|
212
|
+
- !ruby/object:Gem::Version
|
213
|
+
version: '0'
|
214
|
+
requirements: []
|
215
|
+
rubyforge_project:
|
216
|
+
rubygems_version: 2.2.1
|
217
|
+
signing_key:
|
218
|
+
specification_version: 4
|
219
|
+
summary: Pavlov's RSS
|
220
|
+
test_files:
|
221
|
+
- spec/fixtures/rss0.xml
|
222
|
+
- spec/fixtures/rss1.xml
|
223
|
+
- spec/fixtures/rss2.xml
|
224
|
+
- spec/fixtures/rss3.xml
|
225
|
+
- spec/fixtures/rss4.xml
|
226
|
+
- spec/fixtures/rss5.xml
|
227
|
+
- spec/lib/pavlov_rss/reader_spec.rb
|
228
|
+
- spec/spec_helper.rb
|