feed2email 0.2.1 → 0.2.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 2c37536cc5633493536c5d46a079717773feb25a
4
+ data.tar.gz: af6456d9ac843c5e2972ae231ec8bebb39a2b0b6
5
+ SHA512:
6
+ metadata.gz: a967e6d52c3a5ec70ffe6772cc6b478776a61d21fc1c09e56cddc5d080f57544135b1fbee814d9b116ddbbe88def9c2e51c9bbbc47e355b9c716c6d0e9eb9814
7
+ data.tar.gz: c58f7436d84347b5e52e66ceef8d30674ba7905f8d1f5ee1e062cb234524604b4cd07042a310486cda8c6475acbe9cd5a53335cebee5587ff51ae8c33cd81b18
data/CHANGELOG.md CHANGED
@@ -1,3 +1,8 @@
1
+ ### 0.2.2
2
+
3
+ * Fix smtp_tls option never being false
4
+ * Use SMTP user@host as "from" address if entry author is missing
5
+
1
6
  ### 0.2.1
2
7
 
3
8
  * Add config option to delay mail sending
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- feed2email (0.2.1)
4
+ feed2email (0.2.2)
5
5
  feedzirra
6
6
  mail
7
7
 
data/LICENSE.txt CHANGED
@@ -2,8 +2,19 @@ The MIT License
2
2
 
3
3
  Copyright (c) 2013 Aggelos Orfanakos
4
4
 
5
- Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
6
+ this software and associated documentation files (the "Software"), to deal in
7
+ the Software without restriction, including without limitation the rights to
8
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9
+ the Software, and to permit persons to whom the Software is furnished to do so,
10
+ subject to the following conditions:
6
11
 
7
- The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
8
14
 
9
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
17
+ FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18
+ COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19
+ IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20
+ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md CHANGED
@@ -4,9 +4,11 @@ RSS/Atom feed updates in your email
4
4
 
5
5
  ## Why
6
6
 
7
- I don't like having a separate application for feeds when I'm already checking my email. I also never read a thing when feeds are kept in a separate place.
7
+ I don't like having a separate application for feeds when I'm already checking
8
+ my email. I also never read a thing when feeds are kept in a separate place.
8
9
 
9
- feed2email was written primarily as a replacement of [rss2email][] and aims to be simpler, faster, smaller and easier to use.
10
+ feed2email was written primarily as a replacement of [rss2email][] and aims to
11
+ be simpler, faster, smaller and easier to use.
10
12
 
11
13
  [rss2email]: http://www.allthingsrss.com/rss2email/
12
14
 
@@ -25,42 +27,54 @@ $ gem install feed2email
25
27
 
26
28
  Through a [YAML][] file at `~/.feed2email/config.yml`.
27
29
 
28
- There are two ways to send mail: SMTP and Sendmail. If `config.yml` contains options for both, feed2email will use SMTP.
30
+ It is possible to send email via SMTP or an [MTA][]. If `config.yml` contains
31
+ options for both, feed2email will use SMTP.
29
32
 
30
33
  [YAML]: http://en.wikipedia.org/wiki/YAML
34
+ [MTA]: http://en.wikipedia.org/wiki/Message_transfer_agent
31
35
 
32
36
  ### Format
33
37
 
34
- Each line in the configuration file contains a key-value pair. Each key-value pair is separated with a colon: `foo: bar`
38
+ Each line in the configuration file contains a key-value pair. Each key-value
39
+ pair is separated with a colon: `foo: bar`
35
40
 
36
41
  ### Generic options
37
42
 
38
43
  * `recipient` (required) is the email address to send email to
39
- * `send_delay` (optional) is the number of seconds to wait between each email to avoid SMTP server throttling errors (default is `10`; use `0` to turn off)
44
+ * `send_delay` (optional) is the number of seconds to wait between each email to
45
+ avoid SMTP server throttling errors (default is `10`; use `0` to turn off)
40
46
 
41
47
  ### SMTP
42
48
 
43
49
  * `smtp_host` is the SMTP service hostname to connect to
44
50
  * `smtp_port` is the SMTP service port to connect to
45
- * `smtp_user` is the username of your mail account
46
- * `smtp_pass` is the password of your mail account (see the warning below)
51
+ * `smtp_user` is the username of your email account
52
+ * `smtp_pass` is the password of your email account (see the warning below)
47
53
  * `smtp_tls` (optional) controls TLS (default is `true`; can also be `false`)
48
- * `smtp_auth` (optional) controls the authentication method (default is `login`; can also be `plain` or `cram_md5`)
54
+ * `smtp_auth` (optional) controls the authentication method (default is `login`;
55
+ can also be `plain` or `cram_md5`)
49
56
 
50
- **Warning:** Unless it has correct restricted permissions, anyone with access in your system will be able to read `config.yml` and your password. To prevent this, feed2email will not run and complain if it detects the wrong permissions. You can set the correct permissions with `chmod 600 ~/.feed2email/config.yml`.
57
+ **Warning:** Unless it has correct restricted permissions, anyone with access in
58
+ your system will be able to read `config.yml` and your password. To prevent
59
+ this, feed2email will not run and complain if it detects the wrong permissions.
60
+ You can set the correct permissions with `chmod 600 ~/.feed2email/config.yml`.
51
61
 
52
- ### Sendmail
62
+ ### MTA
53
63
 
54
- For this method you need to have [Sendmail][] setup and working in your system. It is also possible to use [a program with a Sendmail-compatible interface][msmtp].
64
+ For this method you need to have an [MTA][] with a [Sendmail][]-compatible
65
+ interface setup and working in your system. I suggest [msmtp][] or [Postfix][].
55
66
 
56
- * `sendmail_path` (optional) is the path to the Sendmail binary (default is `/usr/sbin/sendmail`)
67
+ * `sendmail_path` (optional) is the path to the Sendmail binary (default is
68
+ `/usr/sbin/sendmail`)
57
69
 
58
70
  [Sendmail]: http://en.wikipedia.org/wiki/Sendmail
59
71
  [msmtp]: http://msmtp.sourceforge.net/
72
+ [Postfix]: http://en.wikipedia.org/wiki/Postfix_(software)
60
73
 
61
74
  ## Use
62
75
 
63
- Create `~/.feed2email/feeds.yml` and add the address of each feed you want to subscribe to, prefixed with a dash and a space.
76
+ Create `~/.feed2email/feeds.yml` and add the address of each feed you want to
77
+ subscribe to, prefixed with a dash and a space.
64
78
 
65
79
  Then run it:
66
80
 
@@ -68,12 +82,18 @@ Then run it:
68
82
  $ feed2email
69
83
  ~~~
70
84
 
71
- When run for the first time, feed2email enters "dry run" mode and exits almost immediately. During dry run mode:
85
+ When run for the first time, feed2email enters "dry run" mode and exits almost
86
+ immediately. During dry run mode:
72
87
 
73
- * No feeds are fetched and, thus, no email is sent (existing feed entries are considered already seen)
74
- * `~/.feed2email/state.yml` is created containing the timestamp of when each feed was last fetched
88
+ * No feeds are fetched and, thus, no email is sent (existing feed entries are
89
+ considered already seen)
90
+ * `~/.feed2email/state.yml` is created containing the timestamp of when each
91
+ feed was last fetched
75
92
 
76
- If you want to receive existing entries from a specific feed, you can manually alter the timestamp for that feed in `state.yml` to a value in the past. Next time you run feed2email, all entries published past that timestamp will be sent with email.
93
+ If you want to receive existing entries from a specific feed, you can manually
94
+ alter the timestamp for that feed in `state.yml` to a value in the past. Next
95
+ time you run feed2email, all entries published past that timestamp will be sent
96
+ with email.
77
97
 
78
98
  You can use [cron][] to run feed2email automatically e.g. once every hour.
79
99
 
data/feed2email.gemspec CHANGED
@@ -2,6 +2,7 @@
2
2
  lib = File.expand_path('../lib', __FILE__)
3
3
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
4
  require 'feed2email/version'
5
+ require 'date'
5
6
 
6
7
  Gem::Specification.new do |gem|
7
8
  gem.name = 'feed2email'
data/lib/feed2email.rb CHANGED
@@ -5,6 +5,7 @@ require 'mail'
5
5
  require 'net/smtp'
6
6
  require 'yaml'
7
7
 
8
+ require 'feed2email/config'
8
9
  require 'feed2email/version'
9
10
  require 'feed2email/core_ext'
10
11
  require 'feed2email/mail'
@@ -0,0 +1,32 @@
1
+ module Feed2Email
2
+ CONFIG_DIR = File.expand_path('~/.feed2email')
3
+
4
+ class Config
5
+ include Singleton
6
+
7
+ CONFIG_FILE = File.join(CONFIG_DIR, 'config.yml')
8
+
9
+ attr_reader :config
10
+
11
+ def read!
12
+ FileUtils.mkdir_p(CONFIG_DIR)
13
+
14
+ @config = YAML.load(open(CONFIG_FILE)) rescue nil
15
+
16
+ if !@config.is_a? Hash
17
+ STDERR.puts "Error: missing or invalid config file #{CONFIG_FILE}"
18
+ exit 1
19
+ end
20
+
21
+ if '%o' % (File.stat(CONFIG_FILE).mode & 0777) != '600'
22
+ STDERR.puts "Error: invalid permissions for config file #{CONFIG_FILE}"
23
+ exit 2
24
+ end
25
+
26
+ if @config['recipient'].nil?
27
+ STDERR.puts "Error: recipient missing from config file #{CONFIG_FILE}"
28
+ exit 3
29
+ end
30
+ end
31
+ end
32
+ end
@@ -1,34 +1,14 @@
1
1
  module Feed2Email
2
- CONFIG_DIR = File.expand_path('~/.feed2email')
3
- CONFIG_FILE = File.join(CONFIG_DIR, 'config.yml')
4
- FEEDS_FILE = File.join(CONFIG_DIR, 'feeds.yml')
5
- STATE_FILE = File.join(CONFIG_DIR, 'state.yml')
6
- USER_AGENT = "feed2email/#{VERSION}"
7
-
8
2
  class Feed
3
+ FEEDS_FILE = File.join(CONFIG_DIR, 'feeds.yml')
4
+ STATE_FILE = File.join(CONFIG_DIR, 'state.yml')
5
+
9
6
  def self.process(uri)
10
7
  Feed.new(uri).process
11
8
  end
12
9
 
13
10
  def self.process_all
14
- FileUtils.mkdir_p(CONFIG_DIR)
15
-
16
- $config = YAML.load(open(CONFIG_FILE)) rescue nil
17
-
18
- if !$config.is_a? Hash
19
- $stderr.puts "Error: missing or invalid config file #{CONFIG_FILE}"
20
- exit 1
21
- end
22
-
23
- if '%o' % (File.stat(CONFIG_FILE).mode & 0777) != '600'
24
- $stderr.puts "Error: invalid permissions for config file #{CONFIG_FILE}"
25
- exit 2
26
- end
27
-
28
- if $config['recipient'].nil?
29
- $stderr.puts "Error: recipient missing from config file #{CONFIG_FILE}"
30
- exit 3
31
- end
11
+ Feed2Email::Config.instance.read!
32
12
 
33
13
  feed_uris = YAML.load(open(FEEDS_FILE)) rescue nil
34
14
 
@@ -64,9 +44,15 @@ module Feed2Email
64
44
  private
65
45
 
66
46
  def data
67
- @fetched_at ||= Time.now
68
- fetch_opts = { :user_agent => USER_AGENT, :compress => true }
69
- @data ||= Feedzirra::Feed.fetch_and_parse(@uri, fetch_opts)
47
+ if @data.nil?
48
+ @data = Feedzirra::Feed.fetch_and_parse(@uri,
49
+ :user_agent => "feed2email/#{VERSION}",
50
+ :compress => true
51
+ )
52
+ @fetched_at = Time.now
53
+ end
54
+
55
+ @data
70
56
  end
71
57
 
72
58
  def entries
@@ -5,9 +5,9 @@ module Feed2Email
5
5
  end
6
6
 
7
7
  def send
8
- sleep $config['send_delay'] || 10 # avoid Net::SMTPServerBusy errors
8
+ sleep config['send_delay'] || 10 # avoid Net::SMTPServerBusy errors
9
9
 
10
- if smtp_config_present?
10
+ if send_with_smtp?
11
11
  send_with_smtp
12
12
  else
13
13
  send_with_sendmail
@@ -36,6 +36,10 @@ module Feed2Email
36
36
  }.gsub(/^\s+/, '') % body_data
37
37
  end
38
38
 
39
+ def config
40
+ Feed2Email::Config.instance.config
41
+ end
42
+
39
43
  def from
40
44
  from_data = {
41
45
  :name => @entry.feed.title,
@@ -47,8 +51,13 @@ module Feed2Email
47
51
  def from_address
48
52
  if @entry.author && @entry.author['@']
49
53
  @entry.author
54
+ elsif send_with_smtp?
55
+ '%{user}@%{host}' % {
56
+ :user => config['smtp_user'],
57
+ :host => config['smtp_host']
58
+ }
50
59
  else
51
- to
60
+ to # recipient as a last resort
52
61
  end
53
62
  end
54
63
 
@@ -75,12 +84,12 @@ module Feed2Email
75
84
  end
76
85
 
77
86
  def send_with_smtp
78
- host = $config['smtp_host']
79
- port = $config['smtp_port']
80
- user = $config['smtp_user']
81
- pass = $config['smtp_pass']
82
- tls = $config['smtp_tls'] || $config['smtp_tls'].nil? # on by default
83
- auth = ($config['smtp_auth'] || 'login').to_sym # login by default
87
+ host = config['smtp_host']
88
+ port = config['smtp_port']
89
+ user = config['smtp_user']
90
+ pass = config['smtp_pass']
91
+ tls = config['smtp_tls'].nil? ? true : config['smtp_tls'] # default: true
92
+ auth = (config['smtp_auth'] || 'login').to_sym # default: 'login'
84
93
 
85
94
  smtp = Net::SMTP.new(host, port)
86
95
  smtp.enable_starttls if tls
@@ -89,15 +98,15 @@ module Feed2Email
89
98
  end
90
99
  end
91
100
 
92
- def sendmail_bin
93
- $config['sendmail_path'] || '/usr/sbin/sendmail'
101
+ def send_with_smtp?
102
+ config['smtp_host'] &&
103
+ config['smtp_port'] &&
104
+ config['smtp_user'] &&
105
+ config['smtp_pass']
94
106
  end
95
107
 
96
- def smtp_config_present?
97
- $config['smtp_host'] &&
98
- $config['smtp_port'] &&
99
- $config['smtp_user'] &&
100
- $config['smtp_pass']
108
+ def sendmail_bin
109
+ config['sendmail_path'] || '/usr/sbin/sendmail'
101
110
  end
102
111
 
103
112
  def subject
@@ -105,7 +114,7 @@ module Feed2Email
105
114
  end
106
115
 
107
116
  def to
108
- $config['recipient']
117
+ config['recipient']
109
118
  end
110
119
  end
111
120
  end
@@ -1,3 +1,3 @@
1
1
  module Feed2Email
2
- VERSION = '0.2.1'
2
+ VERSION = '0.2.2'
3
3
  end
metadata CHANGED
@@ -1,46 +1,41 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: feed2email
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
5
- prerelease:
4
+ version: 0.2.2
6
5
  platform: ruby
7
6
  authors:
8
7
  - Aggelos Orfanakos
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2013-06-09 00:00:00.000000000 Z
11
+ date: 2013-07-06 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: feedzirra
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
- - - ! '>='
17
+ - - '>='
20
18
  - !ruby/object:Gem::Version
21
19
  version: '0'
22
20
  type: :runtime
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
- - - ! '>='
24
+ - - '>='
28
25
  - !ruby/object:Gem::Version
29
26
  version: '0'
30
27
  - !ruby/object:Gem::Dependency
31
28
  name: mail
32
29
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
30
  requirements:
35
- - - ! '>='
31
+ - - '>='
36
32
  - !ruby/object:Gem::Version
37
33
  version: '0'
38
34
  type: :runtime
39
35
  prerelease: false
40
36
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
37
  requirements:
43
- - - ! '>='
38
+ - - '>='
44
39
  - !ruby/object:Gem::Version
45
40
  version: '0'
46
41
  description: RSS/Atom feed updates in your email
@@ -62,6 +57,7 @@ files:
62
57
  - feed2email.gemspec
63
58
  - feeds.yml.sample
64
59
  - lib/feed2email.rb
60
+ - lib/feed2email/config.rb
65
61
  - lib/feed2email/core_ext.rb
66
62
  - lib/feed2email/entry.rb
67
63
  - lib/feed2email/feed.rb
@@ -69,32 +65,25 @@ files:
69
65
  - lib/feed2email/version.rb
70
66
  homepage: http://github.com/agorf/feed2email
71
67
  licenses: []
68
+ metadata: {}
72
69
  post_install_message:
73
70
  rdoc_options: []
74
71
  require_paths:
75
72
  - lib
76
73
  required_ruby_version: !ruby/object:Gem::Requirement
77
- none: false
78
74
  requirements:
79
- - - ! '>='
75
+ - - '>='
80
76
  - !ruby/object:Gem::Version
81
77
  version: '0'
82
- segments:
83
- - 0
84
- hash: 1285304786354070987
85
78
  required_rubygems_version: !ruby/object:Gem::Requirement
86
- none: false
87
79
  requirements:
88
- - - ! '>='
80
+ - - '>='
89
81
  - !ruby/object:Gem::Version
90
82
  version: '0'
91
- segments:
92
- - 0
93
- hash: 1285304786354070987
94
83
  requirements: []
95
84
  rubyforge_project:
96
- rubygems_version: 1.8.23
85
+ rubygems_version: 2.0.3
97
86
  signing_key:
98
- specification_version: 3
87
+ specification_version: 4
99
88
  summary: RSS/Atom feed updates in your email
100
89
  test_files: []