news2kindle 0.1.2 → 0.1.3

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f2d8583e288f9e37f82d78ae57a839788c7ee2c1
4
- data.tar.gz: d4307ac419f022f2e9a3c97f10b10dda3f5f7ea4
3
+ metadata.gz: 251e39c5b4825a1c4b5f48c00830792afaf6afc0
4
+ data.tar.gz: 8342bbff08e27c297951a54e7bf940235cdc1e4c
5
5
  SHA512:
6
- metadata.gz: 70a6b9c437594f652c37e49199819f89cabf712e9ace976e10b2ecb7f1c1ab4fa3988907b7070a5e4ef10431a95f0088b0ef927c270a53e6ba1ca6ffdc2a5203
7
- data.tar.gz: e3b99b0404da2bc243229f7a16864d98bf8d8efa082ad904fc81121d7c6022148a01ab4bb9c63671563d7a4bbe3c1022829a6057a9bccc5633008b8ee6d64b85
6
+ metadata.gz: 42893d4d3dc64b2c1fd98b75a2f542ca7b1244f0d98950d426f64bd03b92da14911e70b3245f3ca85bd06f911a0a581d0ae18df5cf5064362e9e07cd317eb86e
7
+ data.tar.gz: 1ca795a9dac2540557d69789d1c503855d06afbd9b4130159566887fbed25b891ef570ea33bece0e8f16c8c759fd9a516e43794edc5ecbb18eff88b2c5452165
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- news2kindle (0.1.2)
4
+ news2kindle (0.1.3)
5
5
  dropbox_api
6
6
  kindlegen
7
7
  mail
data/exe/news2kindle CHANGED
@@ -10,24 +10,15 @@ require 'news2kindle'
10
10
  require 'optparse'
11
11
  require 'open-uri'
12
12
  require 'yaml'
13
+ require 'mail'
13
14
 
14
15
  module News2Kindle
15
-
16
16
  class CLI
17
17
  def run
18
18
  conf, tasks = parse_options
19
19
  News2Kindle.logger.level = Logger::DEBUG if conf[:verbose]
20
-
21
- if conf[:mongodb_uri]
22
- unless conf[:mongodb_uri] =~ %r|^mongodb://|
23
- conf[:mongodb_uri] = Pit::get('news2kindle', require: {
24
- mongodb_uri: 'MongoDB URI for Dupulicate Check starts with "mongodb://".'
25
- })[:mongodb_uri]
26
- end
27
- if conf[:mongodb_uri]
28
- DupChecker.setup({clients:{default:{uri:conf[:mongodb_uri]}}})
29
- end
30
- end
20
+ setup_mail(conf)
21
+ setup_dupcheck(conf)
31
22
 
32
23
  tasks.each do |name|
33
24
  task = conf[:tasks][name]
@@ -101,6 +92,32 @@ module News2Kindle
101
92
  end
102
93
  [conf, args]
103
94
  end
95
+
96
+ def setup_mail(conf)
97
+ settings = conf[:email]
98
+ if settings[:user_name] or settings[:password]
99
+ account = Pit::get('news2kindle', require: {
100
+ mail_user_name: 'your e-mail id',
101
+ mail_password: 'your e-mail password'
102
+ })
103
+ settings[:user_name] = account[:mail_user_name]
104
+ settings[:password] = account[:mail_password]
105
+ end
106
+ Mail.defaults{delivery_method :smtp, settings}
107
+ end
108
+
109
+ def setup_dupcheck(conf)
110
+ if conf[:mongodb_uri]
111
+ unless conf[:mongodb_uri] =~ %r|^mongodb://|
112
+ conf[:mongodb_uri] = Pit::get('news2kindle', require: {
113
+ mongodb_uri: 'MongoDB URI for Dupulicate Check starts with "mongodb://".'
114
+ })[:mongodb_uri]
115
+ end
116
+ if conf[:mongodb_uri]
117
+ DupChecker.setup({clients:{default:{uri:conf[:mongodb_uri]}}})
118
+ end
119
+ end
120
+ end
104
121
  end
105
122
  end
106
123
 
@@ -5,7 +5,6 @@
5
5
  #
6
6
  require 'pit'
7
7
  require 'kindlegen'
8
- require 'mail'
9
8
  require 'dropbox_api'
10
9
 
11
10
  class DropboxApi::Client
@@ -53,16 +52,6 @@ module News2Kindle
53
52
  def deliver_via_mail(to_address, from_address, mobi, opts)
54
53
  return if to_address.empty?
55
54
 
56
- settings = opts[:email]
57
- if settings[:user_name] or settings[:password]
58
- account = Pit::get('news2kindle', require: {
59
- mail_user_name: 'your e-mail id',
60
- mail_password: 'your e-mail password'
61
- })
62
- settings[:user_name] = account[:mail_user_name]
63
- settings[:password] = account[:mail_password]
64
- end
65
- Mail.defaults{delivery_method :smtp, settings}
66
55
  Mail.deliver do
67
56
  from from_address
68
57
  to to_address
@@ -1,3 +1,3 @@
1
1
  module News2Kindle
2
- VERSION = "0.1.2"
2
+ VERSION = "0.1.3"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: news2kindle
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - TADA Tadashi