rss-motor 0.0.9 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG CHANGED
@@ -8,6 +8,9 @@
8
8
  CHANGE-LOG
9
9
  =====================================================================
10
10
  =====================================================================
11
+ Changes from v0.0.9 to v0.1.0
12
+ [+] updating Rss::Motor.items to fetch also custom nodes or node-attribs
13
+ =====================================================================
11
14
  Changes from v0.0.8 to v0.0.9
12
15
  [+] updated to xml-motor v0.1.6 gaining enclosure value for URL
13
16
  =====================================================================
data/README CHANGED
@@ -26,6 +26,11 @@ An easy to use RSS library to get kickstarted with using RSS Feeds.
26
26
  puts Rss::Motor.rss_items 'http://news.ycombinator.com/rss'
27
27
  Output: [{'title1' => '....', ...}, {'title2' => '....', ...}, ...]
28
28
 
29
+ [+] passing a single RSS Link and fetching array of all items, with hash of nodes
30
+ puts Rss::Motor.rss_items 'http://news.ycombinator.com/rss', ['comments'], {'media:content' => 'url'}
31
+ Output: [{'title1' => '....', ...}, {'title2' => '....', ...}, ...]
32
+ This will fetch hash with set of node values per rss item, including node value for 'comment'; value for 'url' attribute for node 'media:content'
33
+
29
34
  [+] filtering items from multiple rss-links having any from set of given keywords
30
35
  #case in-sensitive filtering
31
36
  puts Rss::Motor.rss_grep 'http://news.ycombinator.com/rss', ['ruby', 'android']
data/lib/rss-motor.rb CHANGED
@@ -9,10 +9,14 @@ end
9
9
  module Rss
10
10
  module Motor
11
11
 
12
- def self.rss_items(rss_url)
12
+ def self.rss_items(rss_url, more_nodes=[], more_node_keys={})
13
13
  rss_data = Rss::WWW.rss_channel rss_url
14
14
  return [{}] if rss_data.empty?
15
- Rss::Proc.rss_hashr rss_data.join
15
+
16
+ xml_splitd = XMLMotor.splitter rss_data.join
17
+ xml_tags = XMLMotor.indexify xml_splitd
18
+ rss_items = XMLMotor.xmldata xml_splitd, xml_tags, 'item'
19
+ rss_hash = Rss::Proc.rss_hashr rss_items, more_nodes, more_node_keys
16
20
  end
17
21
 
18
22
  #Returned Array of Hashes, where the keys are given *filters*
@@ -62,6 +66,9 @@ module Rss
62
66
  end
63
67
  end
64
68
 
69
+ ###USAGE EXAMPLES
65
70
  #puts Rss::Motor.rss_items 'http://news.ycombinator.com/rss'
66
71
  #puts "*"*100, "#{Rss::Motor.rss_grep 'http://news.ycombinator.com/rss', ['ruby', 'android']}"
67
72
  #puts "*"*100, "#{Rss::Motor.rss_grep_link 'http://news.ycombinator.com/rss', ['ruby', 'android']}"
73
+ #puts Rss::Motor.rss_items 'http://news.ycombinator.com/rss', ['comments']
74
+ #puts Rss::Motor.rss_items 'http://feeds.feedburner.com/RubyRogues?format=xml', ['comments'], {'media:content' => 'url'}
@@ -1,11 +1,7 @@
1
1
  module Rss
2
2
  module Proc
3
3
 
4
- def self.rss_hashr(rss_data)
5
- splitd = XMLMotor.splitter rss_data
6
- tags = XMLMotor.indexify splitd
7
- items = XMLMotor.xmldata splitd, tags, 'item'
8
-
4
+ def self.rss_hashr(items, more_nodes, more_node_keys)
9
5
  rss_hash = []
10
6
  items.each_with_index do |item, idx|
11
7
  item_splitd = XMLMotor.splitter item
@@ -26,6 +22,14 @@ module Rss
26
22
  'author' => author.join,
27
23
  'enclosure' => enclosure.join
28
24
  }
25
+
26
+ [more_nodes].flatten.each do |node|
27
+ rss_hash[idx][node] = XMLMotor.xmldata(item_splitd, item_tags, node).join
28
+ end
29
+
30
+ more_node_keys.each_pair do |node, key|
31
+ rss_hash[idx][node] = XMLMotor.xmlattrib(key, item_splitd, item_tags, node).join
32
+ end
29
33
  end
30
34
  return rss_hash
31
35
  end
@@ -1,5 +1,5 @@
1
1
  module Rss
2
2
  module Motor
3
- VERSION = "0.0.9"
3
+ VERSION = "0.1.0"
4
4
  end
5
5
  end
data/rss-motor.gemspec CHANGED
@@ -18,6 +18,6 @@ Gem::Specification.new do |s|
18
18
  s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
19
19
  s.require_paths = ["lib"]
20
20
 
21
- s.add_runtime_dependency 'xml-motor', '>= 0.1.5'
22
- s.add_development_dependency 'xml-motor', '>= 0.1.5'
21
+ s.add_runtime_dependency 'xml-motor', '>= 0.1.6'
22
+ s.add_development_dependency 'xml-motor', '>= 0.1.6'
23
23
  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.9
4
+ version: 0.1.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,30 +9,30 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-08-20 00:00:00.000000000 Z
12
+ date: 2012-08-22 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: xml-motor
16
- requirement: &9896700 !ruby/object:Gem::Requirement
16
+ requirement: &7882920 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
20
20
  - !ruby/object:Gem::Version
21
- version: 0.1.5
21
+ version: 0.1.6
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *9896700
24
+ version_requirements: *7882920
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: xml-motor
27
- requirement: &9896200 !ruby/object:Gem::Requirement
27
+ requirement: &7882420 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
31
31
  - !ruby/object:Gem::Version
32
- version: 0.1.5
32
+ version: 0.1.6
33
33
  type: :development
34
34
  prerelease: false
35
- version_requirements: *9896200
35
+ version_requirements: *7882420
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