send_to_kindle 0.0.1
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.
- data/CHANGELOG.md +0 -0
- data/README.md +0 -0
- data/bin/send_to_kindle +41 -0
- data/lib/send_to_kindle.rb +47 -0
- data/lib/send_to_kindle/notifications.rb +3 -0
- data/lib/send_to_kindle/notifications/base.rb +36 -0
- data/lib/send_to_kindle/notifications/creation.rb +13 -0
- data/lib/send_to_kindle/notifications/mediums/kindle.rb +37 -0
- data/lib/send_to_kindle/notifications/mediums/osx_notification_center.rb +14 -0
- data/lib/send_to_kindle/notifications/mediums/terminal.rb +14 -0
- data/lib/send_to_kindle/notifications/modification.rb +13 -0
- data/lib/send_to_kindle/version.rb +3 -0
- metadata +171 -0
data/CHANGELOG.md
ADDED
|
File without changes
|
data/README.md
ADDED
|
File without changes
|
data/bin/send_to_kindle
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
|
|
3
|
+
$:.push File.expand_path('../../lib', __FILE__)
|
|
4
|
+
|
|
5
|
+
require 'daemons'
|
|
6
|
+
require 'send_to_kindle'
|
|
7
|
+
require 'thor'
|
|
8
|
+
require 'yaml'
|
|
9
|
+
|
|
10
|
+
class SendToKindleDaemon < Thor
|
|
11
|
+
|
|
12
|
+
desc 'start', 'Run daemon to send document to kindle'
|
|
13
|
+
method_option :configuration, type: :string, required: true
|
|
14
|
+
def start
|
|
15
|
+
configuration_path = options[:configuration]
|
|
16
|
+
|
|
17
|
+
unless configuration_path && File.exists?(configuration_path)
|
|
18
|
+
puts %{configuration path does not exist: "#{configuration_path}"}
|
|
19
|
+
exit 1
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
configuration = YAML.load_file(configuration_path)
|
|
23
|
+
|
|
24
|
+
Daemons.daemonize
|
|
25
|
+
SendTokindle.listen(configuration)
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
desc 'stop', 'Stop daemon'
|
|
29
|
+
def stop
|
|
30
|
+
pid_path = 'daemons.rb.pid'
|
|
31
|
+
unless File.exist?(pid_path)
|
|
32
|
+
puts 'daemon not started'
|
|
33
|
+
exit 1
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
File.open(pid_path, 'rb') { |file| Process.kill('KILL', file.read.strip.to_i) }
|
|
37
|
+
File.delete(pid_path)
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
SendToKindleDaemon.start
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
require 'listen'
|
|
2
|
+
require 'net/smtp'
|
|
3
|
+
require 'send_to_kindle/notifications'
|
|
4
|
+
|
|
5
|
+
module SendTokindle
|
|
6
|
+
|
|
7
|
+
def self.default_options
|
|
8
|
+
{
|
|
9
|
+
paths: nil,
|
|
10
|
+
file_types: '\.pdf$',
|
|
11
|
+
notifications: {
|
|
12
|
+
mediums: {
|
|
13
|
+
kindle: true,
|
|
14
|
+
osx_notification_center: true,
|
|
15
|
+
terminal: false
|
|
16
|
+
},
|
|
17
|
+
sender: {
|
|
18
|
+
address: nil,
|
|
19
|
+
port: nil,
|
|
20
|
+
domain: nil,
|
|
21
|
+
user_name: nil,
|
|
22
|
+
password: nil,
|
|
23
|
+
authentication: nil,
|
|
24
|
+
enable_starttls_auto: false
|
|
25
|
+
},
|
|
26
|
+
from: nil,
|
|
27
|
+
kindle: nil
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
def self.listen(options={})
|
|
33
|
+
options = default_options.merge(options)
|
|
34
|
+
|
|
35
|
+
callback = Proc.new do |modified_paths, added_paths, removed_paths|
|
|
36
|
+
modified_paths.each { |path| SendToKindle::Notifications::Modification.new(path, options[:notifications]).send }
|
|
37
|
+
added_paths.each { |path| SendToKindle::Notifications::Creation.new(path, options[:notifications]).send }
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
Listen.to(options[:paths])
|
|
41
|
+
.filter(Regexp.new(options[:file_types]))
|
|
42
|
+
.latency(0.5)
|
|
43
|
+
.force_polling(true)
|
|
44
|
+
.change(&callback)
|
|
45
|
+
.start
|
|
46
|
+
end
|
|
47
|
+
end
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
require 'active_support/inflector'
|
|
2
|
+
require 'mail'
|
|
3
|
+
require 'terminal-notifier'
|
|
4
|
+
|
|
5
|
+
module SendToKindle
|
|
6
|
+
module Notifications
|
|
7
|
+
class Base
|
|
8
|
+
|
|
9
|
+
attr_accessor :file_path, :message, :options
|
|
10
|
+
|
|
11
|
+
def initialize(file_path, message, options={})
|
|
12
|
+
self.message = message
|
|
13
|
+
self.file_path = file_path
|
|
14
|
+
self.options = options
|
|
15
|
+
|
|
16
|
+
add_mediums
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def send
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
private
|
|
23
|
+
|
|
24
|
+
def add_mediums
|
|
25
|
+
self.options[:mediums].each do |medium, enabled|
|
|
26
|
+
next unless enabled
|
|
27
|
+
|
|
28
|
+
path = "send_to_kindle/notifications/mediums/#{medium}"
|
|
29
|
+
require path
|
|
30
|
+
self.extend(path.camelize.constantize)
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
end
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
module SendToKindle
|
|
2
|
+
module Notifications
|
|
3
|
+
module Mediums
|
|
4
|
+
module Kindle
|
|
5
|
+
|
|
6
|
+
def send
|
|
7
|
+
super
|
|
8
|
+
|
|
9
|
+
mail_configuration
|
|
10
|
+
send_mail
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
private
|
|
14
|
+
|
|
15
|
+
def send_mail
|
|
16
|
+
email_from = self.options[:from]
|
|
17
|
+
email_kindle = self.options[:kindle]
|
|
18
|
+
subject = message
|
|
19
|
+
file_attachment_path = file_path
|
|
20
|
+
|
|
21
|
+
Mail.deliver do
|
|
22
|
+
from email_from
|
|
23
|
+
to email_kindle
|
|
24
|
+
subject subject
|
|
25
|
+
add_file file_attachment_path
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
def mail_configuration
|
|
30
|
+
sender_options = self.options[:sender]
|
|
31
|
+
Mail.defaults { delivery_method :smtp, sender_options }
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: send_to_kindle
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.0.1
|
|
5
|
+
prerelease:
|
|
6
|
+
platform: ruby
|
|
7
|
+
authors:
|
|
8
|
+
- Kevin Disneur
|
|
9
|
+
autorequire:
|
|
10
|
+
bindir: bin
|
|
11
|
+
cert_chain: []
|
|
12
|
+
date: 2013-01-03 00:00:00.000000000 Z
|
|
13
|
+
dependencies:
|
|
14
|
+
- !ruby/object:Gem::Dependency
|
|
15
|
+
name: activesupport
|
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
|
17
|
+
none: false
|
|
18
|
+
requirements:
|
|
19
|
+
- - ! '>='
|
|
20
|
+
- !ruby/object:Gem::Version
|
|
21
|
+
version: '0'
|
|
22
|
+
type: :runtime
|
|
23
|
+
prerelease: false
|
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
25
|
+
none: false
|
|
26
|
+
requirements:
|
|
27
|
+
- - ! '>='
|
|
28
|
+
- !ruby/object:Gem::Version
|
|
29
|
+
version: '0'
|
|
30
|
+
- !ruby/object:Gem::Dependency
|
|
31
|
+
name: daemons
|
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
|
33
|
+
none: false
|
|
34
|
+
requirements:
|
|
35
|
+
- - ! '>='
|
|
36
|
+
- !ruby/object:Gem::Version
|
|
37
|
+
version: '0'
|
|
38
|
+
type: :runtime
|
|
39
|
+
prerelease: false
|
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
41
|
+
none: false
|
|
42
|
+
requirements:
|
|
43
|
+
- - ! '>='
|
|
44
|
+
- !ruby/object:Gem::Version
|
|
45
|
+
version: '0'
|
|
46
|
+
- !ruby/object:Gem::Dependency
|
|
47
|
+
name: listen
|
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
|
49
|
+
none: false
|
|
50
|
+
requirements:
|
|
51
|
+
- - ! '>='
|
|
52
|
+
- !ruby/object:Gem::Version
|
|
53
|
+
version: '0'
|
|
54
|
+
type: :runtime
|
|
55
|
+
prerelease: false
|
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
57
|
+
none: false
|
|
58
|
+
requirements:
|
|
59
|
+
- - ! '>='
|
|
60
|
+
- !ruby/object:Gem::Version
|
|
61
|
+
version: '0'
|
|
62
|
+
- !ruby/object:Gem::Dependency
|
|
63
|
+
name: mail
|
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
|
65
|
+
none: false
|
|
66
|
+
requirements:
|
|
67
|
+
- - ! '>='
|
|
68
|
+
- !ruby/object:Gem::Version
|
|
69
|
+
version: '0'
|
|
70
|
+
type: :runtime
|
|
71
|
+
prerelease: false
|
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
73
|
+
none: false
|
|
74
|
+
requirements:
|
|
75
|
+
- - ! '>='
|
|
76
|
+
- !ruby/object:Gem::Version
|
|
77
|
+
version: '0'
|
|
78
|
+
- !ruby/object:Gem::Dependency
|
|
79
|
+
name: terminal-notifier
|
|
80
|
+
requirement: !ruby/object:Gem::Requirement
|
|
81
|
+
none: false
|
|
82
|
+
requirements:
|
|
83
|
+
- - ! '>='
|
|
84
|
+
- !ruby/object:Gem::Version
|
|
85
|
+
version: '0'
|
|
86
|
+
type: :runtime
|
|
87
|
+
prerelease: false
|
|
88
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
89
|
+
none: false
|
|
90
|
+
requirements:
|
|
91
|
+
- - ! '>='
|
|
92
|
+
- !ruby/object:Gem::Version
|
|
93
|
+
version: '0'
|
|
94
|
+
- !ruby/object:Gem::Dependency
|
|
95
|
+
name: thor
|
|
96
|
+
requirement: !ruby/object:Gem::Requirement
|
|
97
|
+
none: false
|
|
98
|
+
requirements:
|
|
99
|
+
- - ! '>='
|
|
100
|
+
- !ruby/object:Gem::Version
|
|
101
|
+
version: '0'
|
|
102
|
+
type: :runtime
|
|
103
|
+
prerelease: false
|
|
104
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
105
|
+
none: false
|
|
106
|
+
requirements:
|
|
107
|
+
- - ! '>='
|
|
108
|
+
- !ruby/object:Gem::Version
|
|
109
|
+
version: '0'
|
|
110
|
+
- !ruby/object:Gem::Dependency
|
|
111
|
+
name: bundler
|
|
112
|
+
requirement: !ruby/object:Gem::Requirement
|
|
113
|
+
none: false
|
|
114
|
+
requirements:
|
|
115
|
+
- - ! '>='
|
|
116
|
+
- !ruby/object:Gem::Version
|
|
117
|
+
version: '0'
|
|
118
|
+
type: :development
|
|
119
|
+
prerelease: false
|
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
121
|
+
none: false
|
|
122
|
+
requirements:
|
|
123
|
+
- - ! '>='
|
|
124
|
+
- !ruby/object:Gem::Version
|
|
125
|
+
version: '0'
|
|
126
|
+
description:
|
|
127
|
+
email:
|
|
128
|
+
- kevin.disneur@gmail.com
|
|
129
|
+
executables:
|
|
130
|
+
- send_to_kindle
|
|
131
|
+
extensions: []
|
|
132
|
+
extra_rdoc_files: []
|
|
133
|
+
files:
|
|
134
|
+
- lib/send_to_kindle/notifications/base.rb
|
|
135
|
+
- lib/send_to_kindle/notifications/creation.rb
|
|
136
|
+
- lib/send_to_kindle/notifications/mediums/kindle.rb
|
|
137
|
+
- lib/send_to_kindle/notifications/mediums/osx_notification_center.rb
|
|
138
|
+
- lib/send_to_kindle/notifications/mediums/terminal.rb
|
|
139
|
+
- lib/send_to_kindle/notifications/modification.rb
|
|
140
|
+
- lib/send_to_kindle/notifications.rb
|
|
141
|
+
- lib/send_to_kindle/version.rb
|
|
142
|
+
- lib/send_to_kindle.rb
|
|
143
|
+
- bin/send_to_kindle
|
|
144
|
+
- CHANGELOG.md
|
|
145
|
+
- README.md
|
|
146
|
+
homepage: https://github.com/kdisneur/send_to_kindle
|
|
147
|
+
licenses: []
|
|
148
|
+
post_install_message:
|
|
149
|
+
rdoc_options: []
|
|
150
|
+
require_paths:
|
|
151
|
+
- lib
|
|
152
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
153
|
+
none: false
|
|
154
|
+
requirements:
|
|
155
|
+
- - ! '>='
|
|
156
|
+
- !ruby/object:Gem::Version
|
|
157
|
+
version: '0'
|
|
158
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
159
|
+
none: false
|
|
160
|
+
requirements:
|
|
161
|
+
- - ! '>='
|
|
162
|
+
- !ruby/object:Gem::Version
|
|
163
|
+
version: '0'
|
|
164
|
+
requirements: []
|
|
165
|
+
rubyforge_project:
|
|
166
|
+
rubygems_version: 1.8.24
|
|
167
|
+
signing_key:
|
|
168
|
+
specification_version: 3
|
|
169
|
+
summary: Listen to OS modification then send an email to your kindle account to add
|
|
170
|
+
documents
|
|
171
|
+
test_files: []
|