drewolson-pipe 0.1.0 → 0.1.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.
Files changed (3) hide show
  1. data/README.txt +1 -1
  2. data/lib/pipe.rb +11 -3
  3. metadata +2 -2
data/README.txt CHANGED
@@ -17,7 +17,7 @@ plus patterns those tags must fit. Use with sinatra, easy as pie.
17
17
  Make a new file called ruby_pipe.rb:
18
18
 
19
19
  require 'rubygems'
20
- require 'pipes'
20
+ require 'pipe'
21
21
  require 'sinatra'
22
22
 
23
23
  get '/' do
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.0'
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
- pipe.instance_eval(&block)
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.all? { |field,pattern| (item/field).to_s =~ pattern }
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.0
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-10 00:00:00 -08:00
12
+ date: 2008-12-12 00:00:00 -08:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency