drewolson-pipe 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (6) hide show
  1. data/History.txt +6 -0
  2. data/Manifest.txt +5 -0
  3. data/README.txt +69 -0
  4. data/Rakefile +13 -0
  5. data/lib/pipe.rb +30 -0
  6. metadata +78 -0
data/History.txt ADDED
@@ -0,0 +1,6 @@
1
+ === 0.1.0 / 2008-12-10
2
+
3
+ * 1 major enhancement
4
+
5
+ * RSS aggregator with filters
6
+
data/Manifest.txt ADDED
@@ -0,0 +1,5 @@
1
+ History.txt
2
+ Manifest.txt
3
+ README.txt
4
+ Rakefile
5
+ lib/pipe.rb
data/README.txt ADDED
@@ -0,0 +1,69 @@
1
+ = pipe
2
+
3
+ * http://github.com/drewolson/pipe
4
+
5
+ == DESCRIPTION:
6
+
7
+ Pipe lets you aggregate a bunch of RSS feeds based on filters. Tell
8
+ pipe the url of the feed, and then give it a hash of xml tag names
9
+ plus patterns those tags must fit. Use with sinatra, easy as pie.
10
+
11
+ == FEATURES/PROBLEMS:
12
+
13
+ * Create an aggregate RSS feed with filters
14
+
15
+ == SYNOPSIS:
16
+
17
+ Make a new file called ruby_pipe.rb:
18
+
19
+ require 'rubygems'
20
+ require 'pipes'
21
+ require 'sinatra'
22
+
23
+ get '/' do
24
+ Pipe.create do
25
+ feed "http://news.ycombinator.com/rss", :title => /ruby/i
26
+ feed "http://reddit.com/r/ruby/.rss"
27
+ end
28
+ end
29
+
30
+ Now fire up your new pipe:
31
+
32
+ ruby ruby_pipe.rb
33
+
34
+ Now enjoy some RSS goodness personally tailored to you at
35
+ http://localhost:4567
36
+
37
+ == REQUIREMENTS:
38
+
39
+ * pipe
40
+
41
+ == INSTALL:
42
+
43
+ * gem source -a http://gems.github.com
44
+ * sudo gem install drewolson-pipe
45
+
46
+ == LICENSE:
47
+
48
+ (The MIT License)
49
+
50
+ Copyright (c) 2008 FIX
51
+
52
+ Permission is hereby granted, free of charge, to any person obtaining
53
+ a copy of this software and associated documentation files (the
54
+ 'Software'), to deal in the Software without restriction, including
55
+ without limitation the rights to use, copy, modify, merge, publish,
56
+ distribute, sublicense, and/or sell copies of the Software, and to
57
+ permit persons to whom the Software is furnished to do so, subject to
58
+ the following conditions:
59
+
60
+ The above copyright notice and this permission notice shall be
61
+ included in all copies or substantial portions of the Software.
62
+
63
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
64
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
65
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
66
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
67
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
68
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
69
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/Rakefile ADDED
@@ -0,0 +1,13 @@
1
+ # -*- ruby -*-
2
+
3
+ require 'rubygems'
4
+ require 'hoe'
5
+ require './lib/pipe.rb'
6
+
7
+ Hoe.new('pipe', Pipe::VERSION) do |p|
8
+ p.developer('Drew Olson', 'olsonas@gmail.com')
9
+ p.remote_rdoc_dir = ''
10
+ p.extra_deps << ['hpricot','>= 0.6.164']
11
+ end
12
+
13
+ # vim: syntax=Ruby
data/lib/pipe.rb ADDED
@@ -0,0 +1,30 @@
1
+ require 'open-uri'
2
+ require 'rubygems'
3
+ require 'hpricot'
4
+
5
+ class Pipe
6
+ VERSION = '0.1.0'
7
+ HEADER = %q{<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"><channel>}
8
+ FOOTER = %q{</channel></rss>}
9
+
10
+ attr_reader :content
11
+
12
+ def self.create(&block)
13
+ pipe = Pipe.new
14
+ pipe.instance_eval(&block)
15
+ HEADER + pipe.content + FOOTER
16
+ end
17
+
18
+ def initialize
19
+ @content = ""
20
+ end
21
+
22
+ def feed(url,filters={})
23
+ doc = Hpricot.XML(open(url))
24
+
25
+ @content += (doc/:item).select do |item|
26
+ filters.all? { |field,pattern| (item/field).to_s =~ pattern }
27
+ end.to_s
28
+ end
29
+ end
30
+
metadata ADDED
@@ -0,0 +1,78 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: drewolson-pipe
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Drew Olson
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2008-12-10 00:00:00 -08:00
13
+ default_executable:
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: hpricot
17
+ version_requirement:
18
+ version_requirements: !ruby/object:Gem::Requirement
19
+ requirements:
20
+ - - ">="
21
+ - !ruby/object:Gem::Version
22
+ version: 0.6.164
23
+ version:
24
+ - !ruby/object:Gem::Dependency
25
+ name: hoe
26
+ version_requirement:
27
+ version_requirements: !ruby/object:Gem::Requirement
28
+ requirements:
29
+ - - ">="
30
+ - !ruby/object:Gem::Version
31
+ version: 1.8.2
32
+ version:
33
+ description: Pipe lets you aggregate a bunch of RSS feeds based on filters. Tell pipe the url of the feed, and then give it a hash of xml tag names plus patterns those tags must fit. Use with sinatra, easy as pie.
34
+ email:
35
+ - olsonas@gmail.com
36
+ executables: []
37
+
38
+ extensions: []
39
+
40
+ extra_rdoc_files:
41
+ - History.txt
42
+ - Manifest.txt
43
+ - README.txt
44
+ files:
45
+ - History.txt
46
+ - Manifest.txt
47
+ - README.txt
48
+ - Rakefile
49
+ - lib/pipe.rb
50
+ has_rdoc: true
51
+ homepage: http://github.com/drewolson/pipe
52
+ post_install_message:
53
+ rdoc_options:
54
+ - --main
55
+ - README.txt
56
+ require_paths:
57
+ - lib
58
+ required_ruby_version: !ruby/object:Gem::Requirement
59
+ requirements:
60
+ - - ">="
61
+ - !ruby/object:Gem::Version
62
+ version: "0"
63
+ version:
64
+ required_rubygems_version: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: "0"
69
+ version:
70
+ requirements: []
71
+
72
+ rubyforge_project: pipe
73
+ rubygems_version: 1.2.0
74
+ signing_key:
75
+ specification_version: 2
76
+ summary: Pipe lets you aggregate a bunch of RSS feeds based on filters
77
+ test_files: []
78
+