blackwinter-rss2mail 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
data/README CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  == VERSION
4
4
 
5
- This documentation refers to rss2mail version 0.0.2
5
+ This documentation refers to rss2mail version 0.0.3
6
6
 
7
7
 
8
8
  == DESCRIPTION
data/Rakefile CHANGED
@@ -15,7 +15,7 @@ begin
15
15
  :summary => %q{Send RSS feeds as e-mail},
16
16
  :homepage => %q{http://rss2mail.rubyforge.org/},
17
17
  :files => FileList['lib/**/*.rb', 'bin/*'].to_a,
18
- :extra_files => FileList['[A-Z]*', 'example/*'].to_a,
18
+ :extra_files => FileList['[A-Z]*', 'templates/*', 'example/*'].to_a,
19
19
  :dependencies => %w[simple-rss hpricot unidecode ruby-nuggets]
20
20
  }
21
21
  }}
data/example/feeds.yaml CHANGED
@@ -13,11 +13,13 @@
13
13
  - :url: http://www.heise.de/newsticker/heise-atom.xml
14
14
  :to: my.secret@e.mail
15
15
  :title: heise online News
16
- :body: heisetext
16
+ #:body: heisetext
17
+ :body: ['meta[@name=description]', 'content']
17
18
  :body_encoding: ISO-8859-1
18
19
  - :url: http://log.netbib.de/feed/
19
20
  :to: my.secret@e.mail
20
21
  :title: netbib weblog
22
+ :skip: true
21
23
  :daily:
22
24
  - :url: http://aktuell.de.selfhtml.org/weblog/rss-feed
23
25
  :to: my.secret@e.mail
data/lib/rss2mail/feed.rb CHANGED
@@ -28,6 +28,7 @@ require 'open-uri'
28
28
  require 'erb'
29
29
 
30
30
  require 'rubygems'
31
+ require 'nuggets/file/which'
31
32
  require 'nuggets/string/evaluate'
32
33
 
33
34
  require 'rss2mail/rss'
@@ -58,6 +59,10 @@ module RSS2Mail
58
59
  end
59
60
 
60
61
  def deliver(templates)
62
+ unless mail_cmd = File.which(_mail_cmd = 'mail')
63
+ raise "Mail command not found: #{_mail_cmd}"
64
+ end
65
+
61
66
  to = [*feed[:to]]
62
67
 
63
68
  if to.empty?
@@ -88,7 +93,7 @@ module RSS2Mail
88
93
  end
89
94
 
90
95
  cmd = [
91
- '/usr/bin/mail',
96
+ mail_cmd,
92
97
  '-e',
93
98
  "-a '#{content_type_header}'",
94
99
  "-a 'From: rss2mail@#{HOST}'",
data/lib/rss2mail/rss.rb CHANGED
@@ -158,9 +158,11 @@ module RSS2Mail
158
158
 
159
159
  def get_body(tag, encoding)
160
160
  body = case tag
161
- when nil then return
162
- when true then open(link).read
163
- else defined?(Hpricot) ? Hpricot(open(link)).at(tag).to_s : open(link).read
161
+ when nil then return
162
+ when true then open(link).read
163
+ when String then extract_body(tag)
164
+ when Array then extract_body(*tag)
165
+ else raise ArgumentError, "don't know how to handle tag of type #{tag.class}"
164
166
  end
165
167
 
166
168
  body.gsub!(/<\/?(.*?)>/) { |m| m if TAGS_TO_KEEP.include?($1.split.first.downcase) }
@@ -169,6 +171,15 @@ module RSS2Mail
169
171
  encoding ? Iconv.conv('UTF-8', encoding, body) : body
170
172
  end
171
173
 
174
+ def extract_body(expr, attribute = nil)
175
+ if defined?(Hpricot)
176
+ elem = Hpricot(open(link)).at(expr)
177
+ attribute ? elem[attribute] : elem.to_s
178
+ else
179
+ open(link).read
180
+ end
181
+ end
182
+
172
183
  def clean_subject(string)
173
184
  string.
174
185
  replace_diacritics.
@@ -4,7 +4,7 @@ module RSS2Mail
4
4
 
5
5
  MAJOR = 0
6
6
  MINOR = 0
7
- TINY = 2
7
+ TINY = 3
8
8
 
9
9
  class << self
10
10
 
@@ -0,0 +1,12 @@
1
+ <html>
2
+ <body>
3
+ <%= title %><% if date %> / <%= date %><% end %><% if author %> [<%= author %>]<% end %><br />
4
+ <% if description %><br />
5
+ <%= description %><br />
6
+ <% end %><br />
7
+ <% if body %><br />
8
+ <%= body %><br />
9
+ <% end %><br />
10
+ &lt;<%= link %>&gt;
11
+ </body>
12
+ </html>
@@ -0,0 +1,8 @@
1
+ <%= title %><% if date %> / <%= date %><% end %><% if author %> [<%= author %>]<% end %>
2
+ <% if description %>
3
+ <%= description %>
4
+ <% end %>
5
+ <% if body %>
6
+ <%= body %>
7
+ <% end %>
8
+ <<%= link %>>
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: blackwinter-rss2mail
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jens Wille
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-03-02 00:00:00 -08:00
12
+ date: 2009-04-02 00:00:00 -07:00
13
13
  default_executable: rss2mail
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -73,17 +73,19 @@ files:
73
73
  - COPYING
74
74
  - ChangeLog
75
75
  - README
76
+ - templates/plain.erb
77
+ - templates/html.erb
76
78
  - example/feeds.yaml
77
79
  has_rdoc: true
78
80
  homepage: http://rss2mail.rubyforge.org/
79
81
  post_install_message:
80
82
  rdoc_options:
81
83
  - --line-numbers
82
- - --main
83
- - README
84
84
  - --inline-source
85
85
  - --title
86
86
  - rss2mail Application documentation
87
+ - --main
88
+ - README
87
89
  - --charset
88
90
  - UTF-8
89
91
  - --all