rss-motor 0.0.1

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/.gitignore ADDED
@@ -0,0 +1,4 @@
1
+ *.gem
2
+ .bundle
3
+ Gemfile.lock
4
+ pkg/*
data/CHANGELOG ADDED
@@ -0,0 +1,18 @@
1
+ =====================================================================
2
+
3
+ ||}} //\ //\ _ ||\/|| ||@|| ~++~ ||@|| ||))
4
+ ||\\ _\\ _\\ || || ||_|| || ||_|| ||\\
5
+
6
+ =====================================================================
7
+ =====================================================================
8
+ CHANGE-LOG
9
+ =====================================================================
10
+ =====================================================================
11
+ Changes from v0.0.0 to v0.0.1
12
+ [+] 2 RSS Motors Available
13
+ |[+] passing a single RSS Link and fetching array of all items, with hash of nodes
14
+ | Rss::Motor.rss_items '<SINGLE_RSS_LINK>'
15
+ |[+] filtering items from multiple rss-links having any from set of given keywords
16
+ | Rss::Motor.rss_grep ['<RSS_LINKS>'], [<KEYWORDS_ARR>]
17
+ =====================================================================
18
+ =====================================================================
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "http://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in rss-motor.gemspec
4
+ gemspec
data/README ADDED
@@ -0,0 +1,32 @@
1
+ ======================================================================
2
+
3
+ ||}} //\ //\ _ ||\/|| ||@|| ~++~ ||@|| ||))
4
+ ||\\ _\\ _\\ || || ||_|| || ||_|| ||\\
5
+
6
+ ======================================================================
7
+ v 0.0.1
8
+
9
+ @GitHub: https://github.com/abhishekkr/rubygem_rss_motor
10
+ @RubyGems: http://rubygems.org/gems/rss-motor
11
+
12
+ for support contact:
13
+ mail: abhikumar163@gmail.com
14
+ http://www.twitter.com/aBionic
15
+ ======================================================================
16
+
17
+ An easy to use RSS library to get kickstarted with using RSS Feeds.
18
+
19
+ [How To Use]:
20
+ Loading:
21
+ + $ gem install rss-motor
22
+ + 'require' the 'rss-motor'
23
+
24
+ Usage:
25
+ [+] passing a single RSS Link and fetching array of all items, with hash of nodes
26
+ puts Rss::Motor.rss_items 'http://news.ycombinator.com/rss'
27
+
28
+ [+] filtering items from multiple rss-links having any from set of given keywords
29
+ puts Rss::Motor.rss_grep 'http://news.ycombinator.com/rss', ['ruby', 'android']
30
+
31
+ =====================================================================
32
+ =====================================================================
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,32 @@
1
+ module Rss
2
+ module Proc
3
+
4
+ def self.rss_hashr(rss_data)
5
+ splitd = XMLMotor.splitter rss_data
6
+ tags = XMLMotor.indexify splitd
7
+
8
+ items = XMLMotor.xmldata splitd, tags, 'item'
9
+ titles = XMLMotor.xmldata splitd, tags, 'title'
10
+ links = XMLMotor.xmldata splitd, tags, 'link'
11
+ guids = XMLMotor.xmldata splitd, tags, 'guid'
12
+ descriptions = XMLMotor.xmldata splitd, tags, 'description'
13
+ pubDates = XMLMotor.xmldata splitd, tags, 'pubDate'
14
+ authors = XMLMotor.xmldata splitd, tags, 'author'
15
+ enclosures = XMLMotor.xmldata splitd, tags, 'enclosure'
16
+
17
+ rss_hash = []
18
+ for idx in 0..(items.count - 1)
19
+ rss_hash[idx] = {
20
+ 'title' => titles[idx] || '',
21
+ 'link' => links[idx] || '',
22
+ 'guid' => guids[idx] || '',
23
+ 'description' => descriptions[idx] || '',
24
+ 'date' => pubDates[idx] || '',
25
+ 'author' => authors[idx] || '',
26
+ 'enclosure' => enclosures[idx] || ''
27
+ }
28
+ end
29
+ return rss_hash
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,5 @@
1
+ module Rss
2
+ module Motor
3
+ VERSION = "0.0.1"
4
+ end
5
+ end
@@ -0,0 +1,31 @@
1
+ require "rubygems"
2
+ require "net/http"
3
+ require "net/https"
4
+ require "uri"
5
+ require "xml-motor"
6
+
7
+ module Rss
8
+ module WWW
9
+
10
+ def self.rss_items(rssurl)
11
+ rss_data = http_requester rssurl, "rss.channel.item"
12
+ Rss::Proc.rss_hashr rss_data
13
+ end
14
+
15
+ def self.http_requester(httpurl, node)
16
+ begin
17
+ uri = URI.parse(httpurl)
18
+ http = Net::HTTP.new(uri.host, uri.port)
19
+ if httpurl.match(/^https:\/\//)
20
+ http.use_ssl = true
21
+ http.verify_mode = OpenSSL::SSL::VERIFY_NONE
22
+ end
23
+ request = Net::HTTP::Get.new(uri.request_uri)
24
+ response = http.request(request)
25
+ rescue
26
+ response = nil
27
+ end
28
+ XMLMotor.get_node_from_content response.body, node
29
+ end
30
+ end
31
+ end
data/lib/rss-motor.rb ADDED
@@ -0,0 +1,41 @@
1
+ # rss-motor : the motor to speed up your rss interactions
2
+
3
+ rss_motor_libs = File.join(File.dirname(File.expand_path __FILE__), 'rss-motor', '*.rb')
4
+ Dir.glob(rss_motor_libs).each do |lib|
5
+ require lib
6
+ end
7
+
8
+
9
+ module Rss
10
+ module Motor
11
+
12
+ def self.rss_items(rss_url)
13
+ rss_data = Rss::WWW.http_requester rss_url, 'rss.channel'
14
+ Rss::Proc.rss_hashr rss_data.join
15
+ end
16
+
17
+ def self.rss_grep(rss_urls, filters)
18
+ rss_items = []
19
+ [rss_urls].flatten.each do |rss_url|
20
+ rss = rss_items rss_url
21
+ rss.each do |item|
22
+ [filters].flatten.each do |filter|
23
+ rss_items.push item if
24
+ item['title'].match(/#{filter}/) or
25
+ item['link'].match(/#{filter}/) or
26
+ item['guid'].match(/#{filter}/) or
27
+ item['description'].match(/#{filter}/) or
28
+ item['date'].match(/#{filter}/) or
29
+ item['author'].match(/#{filter}/) or
30
+ item['enclosure'].match(/#{filter}/)
31
+ end
32
+ end
33
+ end
34
+ rss_items
35
+ end
36
+
37
+ end
38
+ end
39
+
40
+ #p Rss::Motor.rss_items 'http://news.ycombinator.com/rss'
41
+ p Rss::Motor.rss_grep 'http://news.ycombinator.com/rss', ['ruby', 'android']
data/make_my_gem.sh ADDED
@@ -0,0 +1,2 @@
1
+ echo "Building GEM File"
2
+ gem build rss-motor.gemspec
data/rss-motor.gemspec ADDED
@@ -0,0 +1,22 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "rss-motor/version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "rss-motor"
7
+ s.version = Rss::Motor::VERSION
8
+ s.authors = ["AbhishekKr"]
9
+ s.email = ["abhikumar163@gmail.com"]
10
+ s.homepage = "https://github.com/abhishekkr/rubygem_rss_motor"
11
+ s.summary = %q{wanna use RSS in your code easily, its here to aid}
12
+ s.description = %q{boost up your RSS related applications with the motor available: https://github.com/abhishekkr/rubygem_rss_motor/blob/master/README}
13
+
14
+ s.rubyforge_project = "rss-motor"
15
+
16
+ s.files = `git ls-files`.split("\n")
17
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
18
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
19
+ s.require_paths = ["lib"]
20
+
21
+ s.add_development_dependency 'xml-motor', '>= 0.1.4'
22
+ end
metadata ADDED
@@ -0,0 +1,67 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rss-motor
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - AbhishekKr
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-06-04 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: xml-motor
16
+ requirement: &16425080 !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: 0.1.4
22
+ type: :development
23
+ prerelease: false
24
+ version_requirements: *16425080
25
+ description: ! 'boost up your RSS related applications with the motor available: https://github.com/abhishekkr/rubygem_rss_motor/blob/master/README'
26
+ email:
27
+ - abhikumar163@gmail.com
28
+ executables: []
29
+ extensions: []
30
+ extra_rdoc_files: []
31
+ files:
32
+ - .gitignore
33
+ - CHANGELOG
34
+ - Gemfile
35
+ - README
36
+ - Rakefile
37
+ - lib/rss-motor.rb
38
+ - lib/rss-motor/rss-proc.rb
39
+ - lib/rss-motor/version.rb
40
+ - lib/rss-motor/www.rb
41
+ - make_my_gem.sh
42
+ - rss-motor.gemspec
43
+ homepage: https://github.com/abhishekkr/rubygem_rss_motor
44
+ licenses: []
45
+ post_install_message:
46
+ rdoc_options: []
47
+ require_paths:
48
+ - lib
49
+ required_ruby_version: !ruby/object:Gem::Requirement
50
+ none: false
51
+ requirements:
52
+ - - ! '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ required_rubygems_version: !ruby/object:Gem::Requirement
56
+ none: false
57
+ requirements:
58
+ - - ! '>='
59
+ - !ruby/object:Gem::Version
60
+ version: '0'
61
+ requirements: []
62
+ rubyforge_project: rss-motor
63
+ rubygems_version: 1.8.17
64
+ signing_key:
65
+ specification_version: 3
66
+ summary: wanna use RSS in your code easily, its here to aid
67
+ test_files: []