drewolson-pipe 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/README.txt +1 -1
- data/lib/pipe.rb +11 -3
- metadata +2 -2
data/README.txt
CHANGED
data/lib/pipe.rb
CHANGED
@@ -3,7 +3,7 @@ require 'rubygems'
|
|
3
3
|
require 'hpricot'
|
4
4
|
|
5
5
|
class Pipe
|
6
|
-
VERSION = '0.1.
|
6
|
+
VERSION = '0.1.1'
|
7
7
|
HEADER = %q{<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"><channel>}
|
8
8
|
FOOTER = %q{</channel></rss>}
|
9
9
|
|
@@ -11,7 +11,13 @@ class Pipe
|
|
11
11
|
|
12
12
|
def self.create(&block)
|
13
13
|
pipe = Pipe.new
|
14
|
-
|
14
|
+
|
15
|
+
if block.arity.zero?
|
16
|
+
pipe.instance_eval(&block)
|
17
|
+
else
|
18
|
+
block.call(pipe)
|
19
|
+
end
|
20
|
+
|
15
21
|
HEADER + pipe.content + FOOTER
|
16
22
|
end
|
17
23
|
|
@@ -20,10 +26,12 @@ class Pipe
|
|
20
26
|
end
|
21
27
|
|
22
28
|
def feed(url,filters={})
|
29
|
+
enum = (filters[:combine_with] == :and ? :all? : :any?)
|
30
|
+
|
23
31
|
doc = Hpricot.XML(open(url))
|
24
32
|
|
25
33
|
@content += (doc/:item).select do |item|
|
26
|
-
filters.
|
34
|
+
filters.send(enum) { |field,pattern| (item/field).to_s =~ pattern }
|
27
35
|
end.to_s
|
28
36
|
end
|
29
37
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: drewolson-pipe
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Drew Olson
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2008-12-
|
12
|
+
date: 2008-12-12 00:00:00 -08:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|