desktop_delivery 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 09e3233b6603394d37eb64319a7d60b303905296
4
+ data.tar.gz: c6850501136e27e14ff334ae0cfbe3a974017647
5
+ SHA512:
6
+ metadata.gz: 6865372f6daf5575420577e3726bc2a5bea5975448aa60dd30adb39e388f1a3546bfbbdd8b22e90f369fada08d1cd82bad0fcd25426bb624ab1c9cc7fb1cc745
7
+ data.tar.gz: cb5b709fd77cd2bae189d24a572110864974b05723d73d483c7fcbd64c3bdcdbf7a45b9dcd4ffdf1f391550e8ac15914d45397d5e2c76bef40b4558f1f16be9e
@@ -0,0 +1,11 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+
11
+ .DS_Store
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source "https://rubygems.org"
2
+
3
+ gemspec
@@ -0,0 +1,29 @@
1
+ # DesktopDelivery
2
+
3
+ Open Rails emails in your desktop client
4
+
5
+ ## Installation
6
+
7
+ In you `Gemfile` :
8
+
9
+ ```ruby
10
+ gem "desktop_delivery"
11
+ ```
12
+
13
+ Or :
14
+
15
+ ```
16
+ gem install desktop_delivery
17
+ ```
18
+
19
+ ## Configuration
20
+
21
+ In `config/environments/development.rb` :
22
+
23
+ ```ruby
24
+ config.action_mailer.delivery_method = :desktop_delivery
25
+ ```
26
+
27
+ ## Licence
28
+
29
+ [WTFPL](https://en.wikipedia.org/wiki/WTFPL)
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
@@ -0,0 +1,27 @@
1
+ lib = File.expand_path("../lib", __FILE__)
2
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
+ require "desktop_delivery/version"
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = "desktop_delivery"
7
+ spec.version = DesktopDelivery::VERSION
8
+ spec.authors = ["Benoit MARTIN-CHAVE"]
9
+ spec.email = ["benoit@martin-chave.ch"]
10
+
11
+ spec.summary = %q{Open Rails emails in your desktop client}
12
+ spec.description = %q{Open Rails emails in your desktop client}
13
+ spec.homepage = "https://github.com/BenoitMC/desktop_delivery"
14
+
15
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
16
+ spec.bindir = "exe"
17
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
18
+ spec.require_paths = ["lib"]
19
+
20
+ spec.add_dependency "launchy"
21
+
22
+ spec.add_development_dependency "bundler", "~> 1.11"
23
+ spec.add_development_dependency "rake", "~> 10.0"
24
+ spec.add_development_dependency "rspec", "~> 3.0"
25
+ spec.add_development_dependency "timecop"
26
+ spec.add_development_dependency "mail"
27
+ end
@@ -0,0 +1,7 @@
1
+ require "etc"
2
+ require "fileutils"
3
+ require "launchy"
4
+
5
+ require "desktop_delivery/version"
6
+ require "desktop_delivery/delivery_method"
7
+ require "desktop_delivery/railtie" if defined?(Rails)
@@ -0,0 +1,48 @@
1
+ module DesktopDelivery
2
+ class DeliveryMethod
3
+ def initialize(options = {})
4
+ @path = options[:path] if options.key?(:path)
5
+ end
6
+
7
+ def deliver!(mail)
8
+ @mail = mail
9
+
10
+ create_path!
11
+ create_file!
12
+ open_file!
13
+ end
14
+
15
+ private
16
+
17
+ def path
18
+ @path ||= Etc.systmpdir
19
+ end
20
+
21
+ def mail
22
+ @mail
23
+ end
24
+
25
+ def file_name
26
+ prefix = Time.now.strftime("%Y-%m-%d_%H-%M-%S_%3N_")
27
+ name = mail.subject.to_s.split(/\W/).join("-")
28
+ ext = ".eml"
29
+ prefix + name + ext
30
+ end
31
+
32
+ def file_path
33
+ @file_path ||= File.join(path, file_name)
34
+ end
35
+
36
+ def create_path!
37
+ FileUtils.mkpath(path)
38
+ end
39
+
40
+ def create_file!
41
+ File.open(file_path, "w+") { |f| f.write(mail.to_s) }
42
+ end
43
+
44
+ def open_file!
45
+ Launchy.open(file_path)
46
+ end
47
+ end
48
+ end
@@ -0,0 +1,13 @@
1
+ module DesktopDelivery
2
+ class Railtie < Rails::Railtie
3
+ initializer "desktop_delivery.add_delivery_method" do
4
+ symbol = :desktop_delivery
5
+ klass = DesktopDelivery::DeliveryMethod
6
+ options = {
7
+ :path => Rails.root.join("tmp/emails"),
8
+ }
9
+
10
+ ActionMailer::Base.add_delivery_method(symbol, klass, options)
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,3 @@
1
+ module DesktopDelivery
2
+ VERSION = "1.0.0"
3
+ end
metadata ADDED
@@ -0,0 +1,137 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: desktop_delivery
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Benoit MARTIN-CHAVE
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2016-03-16 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: launchy
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.11'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.11'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '10.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '10.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rspec
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '3.0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '3.0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: timecop
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: mail
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ description: Open Rails emails in your desktop client
98
+ email:
99
+ - benoit@martin-chave.ch
100
+ executables: []
101
+ extensions: []
102
+ extra_rdoc_files: []
103
+ files:
104
+ - ".gitignore"
105
+ - ".rspec"
106
+ - Gemfile
107
+ - README.md
108
+ - Rakefile
109
+ - desktop_delivery.gemspec
110
+ - lib/desktop_delivery.rb
111
+ - lib/desktop_delivery/delivery_method.rb
112
+ - lib/desktop_delivery/railtie.rb
113
+ - lib/desktop_delivery/version.rb
114
+ homepage: https://github.com/BenoitMC/desktop_delivery
115
+ licenses: []
116
+ metadata: {}
117
+ post_install_message:
118
+ rdoc_options: []
119
+ require_paths:
120
+ - lib
121
+ required_ruby_version: !ruby/object:Gem::Requirement
122
+ requirements:
123
+ - - ">="
124
+ - !ruby/object:Gem::Version
125
+ version: '0'
126
+ required_rubygems_version: !ruby/object:Gem::Requirement
127
+ requirements:
128
+ - - ">="
129
+ - !ruby/object:Gem::Version
130
+ version: '0'
131
+ requirements: []
132
+ rubyforge_project:
133
+ rubygems_version: 2.4.5.1
134
+ signing_key:
135
+ specification_version: 4
136
+ summary: Open Rails emails in your desktop client
137
+ test_files: []