rss-motor 0.0.6 → 0.0.7
Sign up to get free protection for your applications and to get access to all the features.
- data/.rspec +1 -0
- data/CHANGELOG +4 -0
- data/Gemfile.lock +1 -1
- data/README +2 -0
- data/Rakefile +27 -1
- data/lib/rss-motor.rb +2 -3
- data/lib/rss-motor/version.rb +1 -1
- data/spec/rss-motor_spec.rb +88 -0
- data/spec/rss-proc_spec.rb +9 -0
- data/spec/spec_helper.rb +6 -0
- data/spec/www_spec.rb +29 -0
- metadata +15 -6
data/.rspec
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--color
|
data/CHANGELOG
CHANGED
@@ -8,6 +8,10 @@
|
|
8
8
|
CHANGE-LOG
|
9
9
|
=====================================================================
|
10
10
|
=====================================================================
|
11
|
+
Changes from v0.0.6 to v0.0.7
|
12
|
+
[+] rss_grep, rss_grep_link's filter match made case in-sensitive
|
13
|
+
[+] RSpec Added [ @fntzr ]
|
14
|
+
=====================================================================
|
11
15
|
Changes from v0.0.5 to v0.0.6
|
12
16
|
[+] pull request
|
13
17
|
|[+] https://github.com/fntzr/rubygem_rss_motor/commit/3a49b68167f1e148753224c869a04b9be330e1c1
|
data/Gemfile.lock
CHANGED
data/README
CHANGED
@@ -27,12 +27,14 @@ An easy to use RSS library to get kickstarted with using RSS Feeds.
|
|
27
27
|
Output: [{'title1' => '....', ...}, {'title2' => '....', ...}, ...]
|
28
28
|
|
29
29
|
[+] filtering items from multiple rss-links having any from set of given keywords
|
30
|
+
#case in-sensitive filtering
|
30
31
|
puts Rss::Motor.rss_grep 'http://news.ycombinator.com/rss', ['ruby', 'android']
|
31
32
|
Output: ['ruby' => [ {'title1' => '....', ...}, {'title2' => '....', ...}, ...]
|
32
33
|
'android' => [ {'title1' => '....', ...}, {'title2' => '....', ...}, ...] ]
|
33
34
|
|
34
35
|
[+] filtering items from multiple rss-links having any from set of given keywords,
|
35
36
|
also grabbing entire rss item's link content and check it for filter
|
37
|
+
#case in-sensitive filtering
|
36
38
|
puts Rss::Motor.rss_grep_link 'http://news.ycombinator.com/rss', ['ruby', 'android']
|
37
39
|
Output: ['ruby' => [ {'title1' => '....', ...}, {'title2' => '....', ...}, ...]
|
38
40
|
'android' => [ {'title1' => '....', ...}, {'title2' => '....', ...}, ...] ]
|
data/Rakefile
CHANGED
@@ -1 +1,27 @@
|
|
1
|
-
require
|
1
|
+
require 'rubygems'
|
2
|
+
require 'bundler/gem_tasks'
|
3
|
+
|
4
|
+
require 'rake'
|
5
|
+
require 'rspec/core/rake_task'
|
6
|
+
|
7
|
+
desc "Run RSpec"
|
8
|
+
task :default => :spec
|
9
|
+
RSpec::Core::RakeTask.new do |t|
|
10
|
+
t.pattern = "./spec/*_spec.rb"
|
11
|
+
end
|
12
|
+
|
13
|
+
namespace :lint do
|
14
|
+
|
15
|
+
desc 'remove tailing whitespace'
|
16
|
+
task :notail do
|
17
|
+
Dir.glob(File.join Dir.pwd, '*.rb').each do |fyl|
|
18
|
+
%x{sed -i 's/\ *$//g' #{fyl}}
|
19
|
+
end
|
20
|
+
Dir.glob(File.join Dir.pwd, '*', '*.rb').each do |fyl|
|
21
|
+
%x{sed -i 's/\ *$//g' #{fyl}}
|
22
|
+
end
|
23
|
+
Dir.glob(File.join Dir.pwd, '*', '*', '*.rb').each do |fyl|
|
24
|
+
%x{sed -i 's/\ *$//g' #{fyl}}
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
data/lib/rss-motor.rb
CHANGED
@@ -56,9 +56,8 @@ module Rss
|
|
56
56
|
|
57
57
|
|
58
58
|
def self.item_filter(item, filter)
|
59
|
-
return false if item.empty? || filter.nil?
|
60
|
-
return !item.values.select{|v| v.match(/#{filter}/)}.empty?
|
61
|
-
false
|
59
|
+
return false if item.empty? || filter.nil? || filter.strip.empty?
|
60
|
+
return !item.values.select{|v| v.match(/#{filter}/i)}.empty?
|
62
61
|
end
|
63
62
|
end
|
64
63
|
end
|
data/lib/rss-motor/version.rb
CHANGED
@@ -0,0 +1,88 @@
|
|
1
|
+
require 'spec_helper.rb'
|
2
|
+
|
3
|
+
describe Rss::Motor do
|
4
|
+
before(:all) {
|
5
|
+
@url = "http://example.com"
|
6
|
+
}
|
7
|
+
|
8
|
+
describe "rss_items" do
|
9
|
+
before(:all) do
|
10
|
+
@response = {
|
11
|
+
'title' => 'FooBar title',
|
12
|
+
'link' => 'some url_link',
|
13
|
+
'description' => 'Lorem ipsum dolor sit amet.',
|
14
|
+
'author' => 'Doctor Who'
|
15
|
+
}
|
16
|
+
Rss::WWW.stubs(:rss_channel).returns([""])
|
17
|
+
Rss::Proc.stubs(:rss_hashr).returns(@response)
|
18
|
+
end
|
19
|
+
|
20
|
+
it "should return Array of Hashes" do
|
21
|
+
data = Rss::Motor.rss_items(@url)
|
22
|
+
data.should eq(@response)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
describe "rss_grep" do
|
27
|
+
|
28
|
+
before(:each) do
|
29
|
+
@response = {
|
30
|
+
'title' => 'item2',
|
31
|
+
'link' => 'some url_link',
|
32
|
+
'description' => 'Lorem ipsum dolor sit amet.',
|
33
|
+
'author' => 'Doctor Who'
|
34
|
+
}
|
35
|
+
Rss::Motor.stubs(:rss_items).returns([@response])
|
36
|
+
end
|
37
|
+
|
38
|
+
it "should return Array of Hashes with the keys are filters" do
|
39
|
+
data = Rss::Motor.rss_grep(@url, ['itme1', 'item2'])
|
40
|
+
data.size.should eq(2)
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
describe "rss_grep_link" do
|
45
|
+
before(:each) do
|
46
|
+
@response = {
|
47
|
+
'title' => 'item2',
|
48
|
+
'link' => 'some url_link',
|
49
|
+
'description' => 'Lorem ipsum dolor sit amet.',
|
50
|
+
'author' => 'Doctor Who'
|
51
|
+
}
|
52
|
+
Rss::Motor.stubs(:rss_items).returns([@response])
|
53
|
+
end
|
54
|
+
|
55
|
+
it "should return Array of Hashes with the keys are filters" do
|
56
|
+
data = Rss::Motor.rss_grep_link(@url, ['itme1', 'item2'])
|
57
|
+
data.size.should eq(2)
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
describe "item_filter" do
|
62
|
+
it "should return true if filter value founded" do
|
63
|
+
res = Rss::Motor.item_filter({"title" => "some value"}, "value")
|
64
|
+
res.should eq(true)
|
65
|
+
end
|
66
|
+
it "should return true if filter value founded case-insensitive" do
|
67
|
+
res = Rss::Motor.item_filter({"title" => "Some Value"}, "value")
|
68
|
+
res.should eq(true)
|
69
|
+
end
|
70
|
+
it "should return false if filter value not founded" do
|
71
|
+
res = Rss::Motor.item_filter({"title" => "some value"}, "lorem")
|
72
|
+
res.should eq(false)
|
73
|
+
end
|
74
|
+
it "should return true if item is empty" do
|
75
|
+
res = Rss::Motor.item_filter({}, "value")
|
76
|
+
res.should eq(false)
|
77
|
+
end
|
78
|
+
it "should return false if filter is nil" do
|
79
|
+
res = Rss::Motor.item_filter({"title" => "some value"}, nil)
|
80
|
+
res.should eq(false)
|
81
|
+
end
|
82
|
+
it "should return false if filter is empty" do
|
83
|
+
res = Rss::Motor.item_filter({"title" => "some value"}, " ")
|
84
|
+
res.should eq(false)
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
end
|
@@ -0,0 +1,9 @@
|
|
1
|
+
require 'spec_helper.rb'
|
2
|
+
|
3
|
+
describe Rss::Proc do
|
4
|
+
it "should returned Hash" do
|
5
|
+
data = "<item><title>FooBar</title></item>"
|
6
|
+
response = Rss::Proc.rss_hashr(data)
|
7
|
+
response.should eq([{"title" => "FooBar", "link"=>"", "guid"=>"", "description"=>"", "date"=>"", "author"=>"", "enclosure"=>""}])
|
8
|
+
end
|
9
|
+
end
|
data/spec/spec_helper.rb
ADDED
data/spec/www_spec.rb
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
require 'spec_helper.rb'
|
2
|
+
|
3
|
+
describe Rss::WWW do
|
4
|
+
before(:all) {
|
5
|
+
@url = 'http://www.example.com'
|
6
|
+
}
|
7
|
+
describe "http_requester" do
|
8
|
+
it "should return nothing if request rescue" do
|
9
|
+
stub_request(:any, @url).to_raise(StandardError)
|
10
|
+
response = Rss::WWW.http_requester(@url)
|
11
|
+
response.should eq("")
|
12
|
+
end
|
13
|
+
it "should return nothing if response code > 500" do
|
14
|
+
stub_request(:any, @url).to_return(:status => [500, "Internal Server Error"])
|
15
|
+
response = Rss::WWW.http_requester(@url)
|
16
|
+
response.should eq("")
|
17
|
+
end
|
18
|
+
it "should return nothing if response code > 400" do
|
19
|
+
stub_request(:any, @url).to_return(:status => [404, "Not Found"])
|
20
|
+
response = Rss::WWW.http_requester(@url)
|
21
|
+
response.should eq("")
|
22
|
+
end
|
23
|
+
it "should return response" do
|
24
|
+
stub_request(:any, @url).to_return(:body => "abc")
|
25
|
+
response = Rss::WWW.http_requester(@url)
|
26
|
+
response.should eq("abc")
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rss-motor
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.7
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -13,7 +13,7 @@ date: 2012-06-10 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: xml-motor
|
16
|
-
requirement: &
|
16
|
+
requirement: &9202620 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: 0.1.4
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *9202620
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: xml-motor
|
27
|
-
requirement: &
|
27
|
+
requirement: &9218520 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,7 +32,7 @@ dependencies:
|
|
32
32
|
version: 0.1.4
|
33
33
|
type: :development
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *9218520
|
36
36
|
description: ! 'boost up your RSS related applications with the motor available: https://github.com/abhishekkr/rubygem_rss_motor/blob/master/README'
|
37
37
|
email:
|
38
38
|
- abhikumar163@gmail.com
|
@@ -41,6 +41,7 @@ extensions: []
|
|
41
41
|
extra_rdoc_files: []
|
42
42
|
files:
|
43
43
|
- .gitignore
|
44
|
+
- .rspec
|
44
45
|
- CHANGELOG
|
45
46
|
- Gemfile
|
46
47
|
- Gemfile.lock
|
@@ -52,6 +53,10 @@ files:
|
|
52
53
|
- lib/rss-motor/www.rb
|
53
54
|
- make_my_gem.sh
|
54
55
|
- rss-motor.gemspec
|
56
|
+
- spec/rss-motor_spec.rb
|
57
|
+
- spec/rss-proc_spec.rb
|
58
|
+
- spec/spec_helper.rb
|
59
|
+
- spec/www_spec.rb
|
55
60
|
homepage: https://github.com/abhishekkr/rubygem_rss_motor
|
56
61
|
licenses: []
|
57
62
|
post_install_message:
|
@@ -76,4 +81,8 @@ rubygems_version: 1.8.17
|
|
76
81
|
signing_key:
|
77
82
|
specification_version: 3
|
78
83
|
summary: wanna use RSS in your code easily, its here to aid
|
79
|
-
test_files:
|
84
|
+
test_files:
|
85
|
+
- spec/rss-motor_spec.rb
|
86
|
+
- spec/rss-proc_spec.rb
|
87
|
+
- spec/spec_helper.rb
|
88
|
+
- spec/www_spec.rb
|