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 +1 -1
- data/example/feeds.yaml +3 -1
- data/lib/rss2mail/feed.rb +6 -1
- data/lib/rss2mail/rss.rb +14 -3
- data/lib/rss2mail/version.rb +1 -1
- metadata +4 -4
data/README
CHANGED
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
|
-
|
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
|
-
|
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
|
162
|
-
when true
|
163
|
-
|
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.
|
data/lib/rss2mail/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rss2mail
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
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-
|
12
|
+
date: 2009-04-02 00:00:00 +02:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -81,11 +81,11 @@ homepage: http://rss2mail.rubyforge.org/
|
|
81
81
|
post_install_message:
|
82
82
|
rdoc_options:
|
83
83
|
- --line-numbers
|
84
|
-
- --main
|
85
|
-
- README
|
86
84
|
- --inline-source
|
87
85
|
- --title
|
88
86
|
- rss2mail Application documentation
|
87
|
+
- --main
|
88
|
+
- README
|
89
89
|
- --charset
|
90
90
|
- UTF-8
|
91
91
|
- --all
|