mail_generator 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +4 -0
- data/Gemfile +4 -0
- data/Rakefile +1 -0
- data/lib/mail_generator.rb +15 -0
- data/lib/mail_generator/action_mailer.rb +15 -0
- data/lib/mail_generator/generator.rb +32 -0
- data/lib/mail_generator/version.rb +3 -0
- data/lib/tasks/mail_generator.rake +9 -0
- data/mail_generator.gemspec +23 -0
- data/spec/mail_generator_spec.rb +5 -0
- metadata +106 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require 'bundler/gem_tasks'
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require "mail_generator/version"
|
2
|
+
require "mail_generator/generator"
|
3
|
+
require "mail_generator/action_mailer"
|
4
|
+
require 'action_mailer'
|
5
|
+
|
6
|
+
module MailGenerator
|
7
|
+
|
8
|
+
class Railtie < ::Rails::Railtie
|
9
|
+
::ActionMailer::Base.send :include, MailGenerator::ActionMailer
|
10
|
+
rake_tasks do
|
11
|
+
load "tasks/mail_generator.rake"
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
require 'fileutils'
|
2
|
+
|
3
|
+
module MailGenerator
|
4
|
+
|
5
|
+
class Generator
|
6
|
+
attr_accessor :output_dir
|
7
|
+
|
8
|
+
def initialize(mailer, &block)
|
9
|
+
output_dir = Rails.root.join('mail_examples')
|
10
|
+
FileUtils.rm_rf output_dir
|
11
|
+
Dir.mkdir output_dir
|
12
|
+
|
13
|
+
@mailer = mailer
|
14
|
+
instance_eval &block
|
15
|
+
end
|
16
|
+
def mail(action, *args)
|
17
|
+
result = @mailer.send(action, *args)
|
18
|
+
|
19
|
+
parts = {}
|
20
|
+
parts['html'] = result.html_part if result.html_part
|
21
|
+
parts['txt'] = result.text_part if result.text_part
|
22
|
+
|
23
|
+
parts.each_pair do |type, part|
|
24
|
+
path = "#{output_dir}/#{action}.#{type}"
|
25
|
+
|
26
|
+
File.open(path, 'w') {|f| f.write(part.body.decoded) }
|
27
|
+
# `open #{path}`
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require "mail_generator/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = "mail_generator"
|
7
|
+
s.version = MailGenerator::VERSION
|
8
|
+
s.authors = ["Adam Howard"]
|
9
|
+
s.email = ["adz@skatty.me"]
|
10
|
+
s.homepage = "http://skatty.me"
|
11
|
+
s.summary = %q{Compile your mail templates to html/txt files}
|
12
|
+
s.description = %q{Compile your mail templates to html/txt files}
|
13
|
+
|
14
|
+
s.rubyforge_project = "mail_generator"
|
15
|
+
|
16
|
+
s.files = `git ls-files`.split("\n")
|
17
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
18
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
19
|
+
s.require_paths = ["lib"]
|
20
|
+
|
21
|
+
s.add_development_dependency "rspec", "~> 2.0.0.beta.22"
|
22
|
+
s.add_dependency "actionmailer"
|
23
|
+
end
|
metadata
ADDED
@@ -0,0 +1,106 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: mail_generator
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 29
|
5
|
+
prerelease:
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 0
|
9
|
+
- 1
|
10
|
+
version: 0.0.1
|
11
|
+
platform: ruby
|
12
|
+
authors:
|
13
|
+
- Adam Howard
|
14
|
+
autorequire:
|
15
|
+
bindir: bin
|
16
|
+
cert_chain: []
|
17
|
+
|
18
|
+
date: 2011-06-24 00:00:00 Z
|
19
|
+
dependencies:
|
20
|
+
- !ruby/object:Gem::Dependency
|
21
|
+
name: rspec
|
22
|
+
prerelease: false
|
23
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
24
|
+
none: false
|
25
|
+
requirements:
|
26
|
+
- - ~>
|
27
|
+
- !ruby/object:Gem::Version
|
28
|
+
hash: 62196431
|
29
|
+
segments:
|
30
|
+
- 2
|
31
|
+
- 0
|
32
|
+
- 0
|
33
|
+
- beta
|
34
|
+
- 22
|
35
|
+
version: 2.0.0.beta.22
|
36
|
+
type: :development
|
37
|
+
version_requirements: *id001
|
38
|
+
- !ruby/object:Gem::Dependency
|
39
|
+
name: actionmailer
|
40
|
+
prerelease: false
|
41
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
42
|
+
none: false
|
43
|
+
requirements:
|
44
|
+
- - ">="
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
hash: 3
|
47
|
+
segments:
|
48
|
+
- 0
|
49
|
+
version: "0"
|
50
|
+
type: :runtime
|
51
|
+
version_requirements: *id002
|
52
|
+
description: Compile your mail templates to html/txt files
|
53
|
+
email:
|
54
|
+
- adz@skatty.me
|
55
|
+
executables: []
|
56
|
+
|
57
|
+
extensions: []
|
58
|
+
|
59
|
+
extra_rdoc_files: []
|
60
|
+
|
61
|
+
files:
|
62
|
+
- .gitignore
|
63
|
+
- Gemfile
|
64
|
+
- Rakefile
|
65
|
+
- lib/mail_generator.rb
|
66
|
+
- lib/mail_generator/action_mailer.rb
|
67
|
+
- lib/mail_generator/generator.rb
|
68
|
+
- lib/mail_generator/version.rb
|
69
|
+
- lib/tasks/mail_generator.rake
|
70
|
+
- mail_generator.gemspec
|
71
|
+
- spec/mail_generator_spec.rb
|
72
|
+
homepage: http://skatty.me
|
73
|
+
licenses: []
|
74
|
+
|
75
|
+
post_install_message:
|
76
|
+
rdoc_options: []
|
77
|
+
|
78
|
+
require_paths:
|
79
|
+
- lib
|
80
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
81
|
+
none: false
|
82
|
+
requirements:
|
83
|
+
- - ">="
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
hash: 3
|
86
|
+
segments:
|
87
|
+
- 0
|
88
|
+
version: "0"
|
89
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
90
|
+
none: false
|
91
|
+
requirements:
|
92
|
+
- - ">="
|
93
|
+
- !ruby/object:Gem::Version
|
94
|
+
hash: 3
|
95
|
+
segments:
|
96
|
+
- 0
|
97
|
+
version: "0"
|
98
|
+
requirements: []
|
99
|
+
|
100
|
+
rubyforge_project: mail_generator
|
101
|
+
rubygems_version: 1.8.5
|
102
|
+
signing_key:
|
103
|
+
specification_version: 3
|
104
|
+
summary: Compile your mail templates to html/txt files
|
105
|
+
test_files:
|
106
|
+
- spec/mail_generator_spec.rb
|