feed2email 0.8.0 → 0.9.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 51069bce6917475aa8499384d330396eebde34c1
4
- data.tar.gz: cde703782a959046c866aa459123d050e6df5fc2
3
+ metadata.gz: e90ae1ad818a1966844926f7653f068a284a13d3
4
+ data.tar.gz: 1f6ed9ac284fc677ca57d89cbcbf6a29543a1a19
5
5
  SHA512:
6
- metadata.gz: 702e5ab54cd401d097b572bfdea2acfc48af045382ddc988135a1f93d8b100790c950b1cf1c32a0405feab4ae8d746c289fffd3ed328ff6974e2418eef87f383
7
- data.tar.gz: 271c7c5d97acbc461dcdf24ac481255d0ddd6a387535c8fb9dc1fef58fcb6783aed9235c87d7a089de6e625036e06ae6399ec2f3b861486af257c697bb526f0f
6
+ metadata.gz: 7654f7a35ae49c97c79e39b4141d0e2ef52aa952db6c953a4d31550ea50606937ff3c862b94617e1132e64fd42c82ab84dadceb7dfbadc43e6b5a852acdb44e9
7
+ data.tar.gz: 685064935abc8fbe1a6ec02be6fb2223dfdf7d8ed192cc1262839650f1f61538e6f760c90bb368f298fdb0127e5e9c895dcb08c01bd539993b5ccc703daa0a1e
data/CHANGELOG.md CHANGED
@@ -1,15 +1,26 @@
1
+ ### 0.9.0
2
+
3
+ * Change data backend from YAML to SQLite3
4
+ * Add `send_method` config option to send emails with
5
+ * Add `file` send method for writing emails to a file
6
+ * Add `backend` command to open an SQLite3 db shell
7
+ * Add `config` command to open config with `$EDITOR`
8
+ * Add `import`/`export` command to import/export feed subscriptions as OPML
9
+ * Remove `history` command
10
+ * Provide a single script for migrating (`feed2email-migrate`)
11
+
1
12
  ### 0.8.0
2
13
 
3
- * Command-line interface for managing feeds (c20bf0c, e5c6dec)
4
- * Perform feed autodiscovery in `add` command (46523ee)
5
- * Store feed metadata in feed list, so no more feed files (cfbd725)
6
- * Add `f2e` symlink to `feed2email` binary for running convenience (6add6b9)
7
- * Improve send delay between entry processing (2118aef)
8
- * Fix feed fetching exception handling (8eb68cf)
9
- * Sync feed metadata only if all entries are processed (73f0947)
10
- * Record entry to history only if email was sent (db59e77)
11
- * Always fetch feed when permanently redirected (4fb147f)
12
- * Ignore redirections to the same location (26513d1e)
14
+ * Command-line interface for managing feeds
15
+ * Perform feed autodiscovery in `add` command
16
+ * Store feed metadata in feed list, so no more feed files
17
+ * Add `f2e` symlink to `feed2email` binary for running convenience
18
+ * Improve send delay between entry processing
19
+ * Fix feed fetching exception handling
20
+ * Sync feed metadata only if all entries are processed
21
+ * Record entry to history only if email was sent
22
+ * Always fetch feed when permanently redirected
23
+ * Ignore redirections to the same location
13
24
  * Major rewrite of README file with new instructions
14
25
 
15
26
  ### 0.7.0
data/README.md CHANGED
@@ -9,13 +9,18 @@ to be simple, fast and easy to use.
9
9
 
10
10
  ## Features
11
11
 
12
- * Easy command-line feed management (add, remove, enable/disable)
13
- * Feed fetching caching
14
- * Feed autodiscovery
15
- * Support for sending email with SMTP or a local MTA (e.g. sendmail)
12
+ * Command-line feed management (add, remove, enable/disable)
13
+ * Feed fetching caching (_Last-Modified_ and _ETag_ HTTP headers)
14
+ * [Feed autodiscovery](http://www.rssboard.org/rss-autodiscovery)
15
+ * [OPML][] import/export of feed subscriptions
16
+ * Email sending with SMTP, [Sendmail][] (or compatible [MTA][]) or by writing to
17
+ a file
16
18
  * _text/html_ and _text/plain_ (Markdown) multipart emails
17
- * Support for feed permanent redirections
18
- * Auto-fixing relative feed entry permalinks
19
+ * Permanent redirection support for feed URLs
20
+
21
+ [OPML]: http://en.wikipedia.org/wiki/OPML
22
+ [Sendmail]: http://en.wikipedia.org/wiki/Sendmail
23
+ [MTA]: http://en.wikipedia.org/wiki/Message_transfer_agent
19
24
 
20
25
  ## Installation
21
26
 
@@ -25,22 +30,46 @@ As a [gem][] from [RubyGems][]:
25
30
  $ gem install feed2email
26
31
  ~~~
27
32
 
33
+ If the above command fails due to missing headers, make sure the following
34
+ packages for [curb][] and [sqlite3][] gems are installed:
35
+
36
+ ~~~ sh
37
+ $ sudo apt-get install libcurl4-openssl-dev libsqlite3-dev
38
+ ~~~
39
+
40
+ **Warning:** If you are updating from an earlier version of feed2email, make
41
+ sure you run `feed2email-migrate` to migrate its data before using it.
42
+
28
43
  [gem]: http://rubygems.org/gems/feed2email
29
44
  [RubyGems]: http://rubygems.org/
45
+ [curb]: https://rubygems.org/gems/curb
46
+ [sqlite3]: https://rubygems.org/gems/sqlite3
30
47
 
31
48
  ## Configuration
32
49
 
33
- Through a [YAML][] file that you create at `~/.feed2email/config.yml`.
50
+ Through a [YAML][] file at `~/.feed2email/config.yml`.
34
51
 
35
- [YAML]: http://en.wikipedia.org/wiki/YAML
52
+ Edit it with the `config` command:
53
+
54
+ ~~~ sh
55
+ $ # same as "f2e c"
56
+ $ feed2email config
57
+ ~~~
58
+
59
+ **Note:** The command will fail if the `EDITOR` environmental variable is not
60
+ set.
36
61
 
37
62
  Each line in the configuration file contains a key-value pair. Each key-value
38
63
  pair is separated with a colon, e.g.: `foo: bar`
39
64
 
65
+ [YAML]: http://en.wikipedia.org/wiki/YAML
66
+
40
67
  ### General options
41
68
 
42
69
  * `recipient` (required) is the email address to send email to
43
70
  * `sender` (required) is the email address to send email from (can be any)
71
+ * `send_method` (optional) is the method to send email with and can be `file`
72
+ (default), `sendmail` or `smtp`
44
73
  * `send_delay` (optional) is the number of seconds to wait between each email to
45
74
  avoid SMTP server throttling errors (default is `10`; use `0` to disable)
46
75
  * `max_entries` (optional) is the maximum number of entries to process per feed
@@ -51,7 +80,7 @@ pair is separated with a colon, e.g.: `foo: bar`
51
80
  * `log_path` (optional) is the _absolute_ path to the log file (default is
52
81
  `true` which logs to standard output; use `false` to disable logging)
53
82
  * `log_level` (optional) is the logging verbosity level and can be `fatal`
54
- (least verbose), `error`, `warn`, `info` (default) and `debug` (most verbose)
83
+ (least verbose), `error`, `warn`, `info` (default) or `debug` (most verbose)
55
84
  * `log_shift_age` (optional) is the number of _old_ log files to keep or the
56
85
  frequency of rotation (`daily`, `weekly`, `monthly`; default is `0` so only
57
86
  the current log file is kept)
@@ -59,12 +88,26 @@ pair is separated with a colon, e.g.: `foo: bar`
59
88
  only applies when `log_shift_age` is a number greater than zero (default is
60
89
  `1`)
61
90
 
62
- ### Delivery options
91
+ ### Sending options
63
92
 
64
- It is possible to send email via SMTP or an [MTA][] (default). If `config.yml`
65
- contains options for both, feed2email will use SMTP.
93
+ #### File
66
94
 
67
- [MTA]: http://en.wikipedia.org/wiki/Message_transfer_agent
95
+ This method simply writes emails to a file (named after the `recipient` config
96
+ option) in a path that you specify.
97
+
98
+ * `mail_path` (optional) is the path to write emails in (default is `~/Mail/`)
99
+
100
+ #### Sendmail
101
+
102
+ For this method you need to have [Sendmail][] or an [MTA][] with a
103
+ Sendmail-compatible interface (e.g. [msmtp][], [Postfix][]) set up and working
104
+ in your system.
105
+
106
+ * `sendmail_path` (optional) is the path to the Sendmail binary (default is
107
+ `/usr/sbin/sendmail`)
108
+
109
+ [msmtp]: http://msmtp.sourceforge.net/
110
+ [Postfix]: http://en.wikipedia.org/wiki/Postfix_(software)
68
111
 
69
112
  #### SMTP
70
113
 
@@ -88,145 +131,154 @@ To set the correct permissions, issue `chmod 600 ~/.feed2email/config.yml`.
88
131
 
89
132
  [Mailgun]: http://www.mailgun.com/
90
133
 
91
- #### MTA
92
-
93
- For this method you need to have an [MTA][] with a [Sendmail][]-compatible
94
- interface set up and working in your system like [msmtp][] or [Postfix][].
95
-
96
- * `sendmail_path` (optional) is the path to the Sendmail binary (default is
97
- `/usr/sbin/sendmail`)
98
-
99
- [Sendmail]: http://en.wikipedia.org/wiki/Sendmail
100
- [msmtp]: http://msmtp.sourceforge.net/
101
- [Postfix]: http://en.wikipedia.org/wiki/Postfix_(software)
102
-
103
134
  ## Use
104
135
 
105
136
  ### Managing feeds
106
137
 
107
- First, add some feeds:
138
+ Add some feeds:
108
139
 
109
140
  ~~~ sh
110
- $ feed2email add https://github.com/agorf.atom
111
- Added feed https://github.com/agorf.atom at index 0
112
141
  $ feed2email add https://github.com/agorf/feed2email/commits.atom
113
- Added feed https://github.com/agorf/feed2email/commits.atom at index 1
142
+ Added feed: 1 https://github.com/agorf/feed2email/commits.atom
143
+ $ # same as "feed2email add https://github.com/agorf.atom"
144
+ $ f2e a https://github.com/agorf.atom
145
+ Added feed: 2 https://github.com/agorf.atom
114
146
  ~~~
115
147
 
116
- **Tip:** You only have to type a feed2email command until it is unambiguous e.g.
117
- instead of `feed2email list`, you can simply issue `feed2email l` as long as
118
- there is no other command beginning with an `l`.
119
-
120
- It is also possible to pass a website URL and let feed2email autodiscover any
121
- feeds:
148
+ Passing a website URL to the `add` command will have feed2email autodiscover any
149
+ feeds in that page:
122
150
 
123
151
  ~~~ sh
124
- $ feed2email add http://www.rubyinside.com/
152
+ $ f2e add http://www.rubyinside.com/
125
153
  0: http://www.rubyinside.com/feed/ "Ruby Inside" (application/rss+xml)
126
154
  Please enter a feed to subscribe to: 0
127
- Added feed http://www.rubyinside.com/feed/ at index 2
128
- $ feed2email add http://thechangelog.com/137/
155
+ Added feed: 3 http://www.rubyinside.com/feed/
156
+ $ f2e add http://thechangelog.com/137/
129
157
  0: http://thechangelog.com/137/feed/ "The Changelog » #137: Better GitHub Issues with HuBoard and Ryan Rauh Comments Feed" (application/rss+xml)
130
158
  1: http://thechangelog.com/feed/ "RSS 2.0 Feed" (application/rss+xml)
131
159
  Please enter a feed to subscribe to: 1
132
- Added feed http://thechangelog.com/feed/ at index 3
133
- $ feed2email add http://thechangelog.com/137/
160
+ Added feed: 4 http://thechangelog.com/feed/
161
+ $ # cancel autodiscovery by pressing Ctrl-C
162
+ $ f2e add http://thechangelog.com/137/
134
163
  0: http://thechangelog.com/137/feed/ "The Changelog » #137: Better GitHub Issues with HuBoard and Ryan Rauh Comments Feed" (application/rss+xml)
135
164
  Please enter a feed to subscribe to: ^C
136
165
  ~~~
137
166
 
138
- Note that on the last command, feed2email autodiscovers the same two feeds as in
139
- the second command, but only lists the ones that haven't been already added.
140
- Autodiscovery is then cancelled by pressing `Ctrl-C`.
167
+ **Note:** When autodiscovering feeds, feed2email lists only those that don't
168
+ already exist in your feed subscriptions.
141
169
 
142
170
  The feed list so far:
143
171
 
144
172
  ~~~ sh
173
+ $ # same as "f2e l"
145
174
  $ feed2email list
146
- 0: https://github.com/agorf.atom
147
- 1: https://github.com/agorf/feed2email/commits.atom
148
- 2: http://www.rubyinside.com/feed/
149
- 3: http://thechangelog.com/feed/
175
+ 1 https://github.com/agorf/feed2email/commits.atom
176
+ 2 https://github.com/agorf.atom
177
+ 3 http://www.rubyinside.com/feed/
178
+ 4 http://thechangelog.com/feed/
150
179
  ~~~
151
180
 
152
- To disable a feed so that it is not processed with `feed2email process`, toggle
153
- it:
181
+ A feed can be disabled so that it is not processed when `feed2email process`
182
+ runs with the `toggle` command:
154
183
 
155
184
  ~~~ sh
185
+ $ # same as "f2e t 1"
156
186
  $ feed2email toggle 1
157
- Disabled feed at index 1
158
- $ feed2email list
159
- 0: https://github.com/agorf.atom
160
- 1: DISABLED https://github.com/agorf/feed2email/commits.atom
161
- 2: http://www.rubyinside.com/feed/
162
- 3: http://thechangelog.com/feed/
187
+ Toggled feed: 1 DISABLED https://github.com/agorf/feed2email/commits.atom
163
188
  ~~~
164
189
 
165
- It is also possible to remove it from the list:
190
+ It can be enabled with the `toggle` command again:
166
191
 
167
192
  ~~~ sh
193
+ $ # same as "feed2email toggle 1"
194
+ $ f2e t 1
195
+ Toggled feed: 1 https://github.com/agorf/feed2email/commits.atom
196
+ ~~~
197
+
198
+ It can also be removed from feed subscriptions permanently:
199
+
200
+ ~~~ sh
201
+ $ # same as "f2e r 1"
168
202
  $ feed2email remove 1
169
- Removed feed at index 1
170
- Warning: Feed list indices have changed!
203
+ Removed feed: 1 https://github.com/agorf/feed2email/commits.atom
171
204
  ~~~
172
205
 
173
- It has been removed, but what is that weird warning?
206
+ ### Migrating to/from feed2email
174
207
 
175
- Since the feed that got removed was at index 1, every feed below it got
176
- reindexed. So feed2email warns you that the feed indices have changed: the feed
177
- at index 2 is now at index 1 and the feed at index 3 is now at index 2.
208
+ feed2email supports importing and exporting feed subscriptions as [OPML][]. This
209
+ makes it easy to migrate to and away from feed2email anytime you want.
178
210
 
179
- Indeed:
211
+ Export feed subscriptions to `feeds.xml`:
180
212
 
181
213
  ~~~ sh
182
- $ feed2email list
183
- 0: https://github.com/agorf.atom
184
- 1: http://www.rubyinside.com/feed/
185
- 2: http://thechangelog.com/feed/
214
+ $ # same as "f2e e feeds.xml"
215
+ $ feed2email export feeds.xml
216
+ This may take a bit. Please wait...
217
+ Exported 3 feed subscriptions to feeds.xml
218
+ ~~~
219
+
220
+ Import feed subscriptions from `feeds.xml`:
221
+
222
+ ~~~ sh
223
+ $ # same as "f2e i feeds.xml"
224
+ $ feed2email import feeds.xml
225
+ Importing...
226
+ Feed already exists: 2 https://github.com/agorf.atom
227
+ Feed already exists: 3 http://www.rubyinside.com/feed/
228
+ Feed already exists: 4 http://thechangelog.com/feed/
186
229
  ~~~
187
230
 
188
- **Tip:** feed2email installs `f2e` as a symbolic link to the feed2email binary,
189
- so you can use that to avoid typing the whole name every time, e.g.: `f2e list`
190
- or even `f2e l`.
231
+ Nothing was imported since all feeds already exist. Let's remove them first and
232
+ then try again:
233
+
234
+ ~~~ sh
235
+ $ f2e r 2
236
+ Removed feed: 2 https://github.com/agorf.atom
237
+ $ f2e r 3
238
+ Removed feed: 3 http://www.rubyinside.com/feed/
239
+ $ f2e r 4
240
+ Removed feed: 4 http://thechangelog.com/feed/
241
+ $ f2e l
242
+ No feeds
243
+ $ feed2email import feeds.xml
244
+ Importing...
245
+ Imported feed: 1 https://github.com/agorf.atom
246
+ Imported feed: 2 http://www.rubyinside.com/feed/
247
+ Imported feed: 3 http://thechangelog.com/feed/
248
+ Imported 3 feed subscriptions from feeds.xml
249
+ ~~~
191
250
 
192
251
  ### Running
193
252
 
194
253
  ~~~ sh
254
+ $ # same as "f2e p"
195
255
  $ feed2email process
196
256
  ~~~
197
257
 
198
258
  When run, feed2email will go through your feed list, fetch each feed (if
199
- necessary) and send an email for each new entry. Any output is logged to the
259
+ necessary) and send an email for each new entry. Output is logged to the
200
260
  standard output, unless configured otherwise.
201
261
 
202
- **Warning:** Prior to version 0.8.0 where a command-line interface was
203
- introduced, the way to run feed2email was simply `feed2email`. Now this will
204
- just print helpful text on how to use it.
205
-
206
262
  When a new feed is detected (which is the case when feed2email runs for the
207
263
  first time on your feed list), all of its entries are skipped and no email is
208
264
  sent. This is so that you don't get spammed when you add a feed for the first
209
265
  time.
210
266
 
211
- If you want to receive a specific entry from a newly added feed, edit the feed's
212
- history file with `feed2email history` and remove the entry. Then issue
213
- `feed2email fetch` to clear the feed's fetch cache. Next time
214
- `feed2email process` runs, the entry will be treated as new and will be
215
- processed.
216
-
217
267
  ### Getting help
218
268
 
219
- Issue `feed2email` or `feed2email help` at any point to get helpful text on how
220
- to use feed2email.
269
+ Issue `feed2email help` (`f2e h`) or just `feed2email` (`f2e`) at any point to
270
+ get helpful text on how to use feed2email.
221
271
 
222
272
  ## Contributing
223
273
 
224
- Using feed2email and want to help? Just [contact me](http://agorf.gr/) and
225
- describe how you use it and if you have any ideas on how it can be improved.
274
+ Using feed2email and want to help? [Let me know](http://agorf.gr/) how you use
275
+ it and if you have any ideas on how to improve it.
226
276
 
227
277
  ## License
228
278
 
229
- Licensed under the MIT license (see `LICENSE.txt`).
279
+ Licensed under the MIT license (see [LICENSE.txt][license]).
280
+
281
+ [license]: https://github.com/agorf/feed2email/blob/master/LICENSE.txt
230
282
 
231
283
  ## Author
232
284
 
data/bin/f2e CHANGED
@@ -1,9 +1,11 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- if File.new('/tmp/feed2email.lock', 'w').flock(File::LOCK_NB | File::LOCK_EX)
4
- require 'feed2email/cli'
5
- Feed2Email::Cli.start(ARGV)
6
- else
3
+ LOCK_FILE = '/tmp/feed2email.lock'
4
+
5
+ unless File.new(LOCK_FILE, 'w').flock(File::LOCK_NB | File::LOCK_EX)
7
6
  abort 'An instance of feed2email is already running. Exiting...'
8
7
  end
9
8
 
9
+ require 'feed2email/cli'
10
+
11
+ Feed2Email::Cli.start(ARGV)
data/bin/feed2email CHANGED
@@ -1,9 +1,11 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- if File.new('/tmp/feed2email.lock', 'w').flock(File::LOCK_NB | File::LOCK_EX)
4
- require 'feed2email/cli'
5
- Feed2Email::Cli.start(ARGV)
6
- else
3
+ LOCK_FILE = '/tmp/feed2email.lock'
4
+
5
+ unless File.new(LOCK_FILE, 'w').flock(File::LOCK_NB | File::LOCK_EX)
7
6
  abort 'An instance of feed2email is already running. Exiting...'
8
7
  end
9
8
 
9
+ require 'feed2email/cli'
10
+
11
+ Feed2Email::Cli.start(ARGV)
@@ -0,0 +1,23 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'feed2email/migrate/convert_feeds_migration'
4
+ require 'feed2email/migrate/feeds_import_migration'
5
+ require 'feed2email/migrate/history_import_migration'
6
+ require 'feed2email/migrate/split_history_migration'
7
+
8
+ include Feed2Email::Migrate
9
+
10
+ [
11
+ SplitHistoryMigration,
12
+ ConvertFeedsMigration,
13
+ FeedsImportMigration,
14
+ HistoryImportMigration
15
+ ].each do |klass|
16
+ if klass.new.apply
17
+ print 'Applied '
18
+ else
19
+ print 'Skipped '
20
+ end
21
+
22
+ puts klass.to_s
23
+ end
data/lib/feed2email.rb CHANGED
@@ -1,17 +1,14 @@
1
+ require 'pathname'
1
2
  require 'feed2email/config'
2
- require 'feed2email/feed_list'
3
- require 'feed2email/lazy_smtp_connection'
4
3
  require 'feed2email/logger'
5
4
 
6
5
  module Feed2Email
7
- CONFIG_DIR = File.join(ENV['HOME'], '.feed2email')
8
-
9
6
  def self.config
10
- @config ||= Config.new(File.join(CONFIG_DIR, 'config.yml'))
7
+ @config ||= Config.new(config_path)
11
8
  end
12
9
 
13
- def self.feed_list
14
- @feed_list ||= FeedList.new(File.join(CONFIG_DIR, 'feeds.yml'))
10
+ def self.config_path
11
+ root.join('config.yml').to_s
15
12
  end
16
13
 
17
14
  def self.logger
@@ -21,7 +18,7 @@ module Feed2Email
21
18
  ).logger
22
19
  end
23
20
 
24
- def self.smtp_connection
25
- @smtp_connection ||= LazySMTPConnection.new
21
+ def self.root
22
+ @root ||= Pathname.new(ENV['HOME']).join('.feed2email')
26
23
  end
27
24
  end