html_email_creator 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +2 -0
- data/Gemfile +4 -0
- data/Gemfile.lock +49 -0
- data/README.markdown +5 -0
- data/Rakefile +7 -0
- data/bin/html_email_creator +35 -0
- data/html_email_creator.gemspec +41 -0
- data/lib/html_email_creator/email.rb +93 -0
- data/lib/html_email_creator/email_creator.rb +45 -0
- data/lib/html_email_creator/email_version.rb +26 -0
- data/lib/html_email_creator/extensions.rb +46 -0
- data/lib/html_email_creator/filters.rb +9 -0
- data/lib/html_email_creator/formatter.rb +30 -0
- data/lib/html_email_creator/formatters/formatter.rb +31 -0
- data/lib/html_email_creator/formatters/html_email.rb +24 -0
- data/lib/html_email_creator/formatters/markdown.rb +24 -0
- data/lib/html_email_creator/formatters/plain_text_email.rb +22 -0
- data/lib/html_email_creator/formatters/unknown_formatter.rb +17 -0
- data/lib/html_email_creator/helper.rb +25 -0
- data/lib/html_email_creator/information.rb +4 -0
- data/lib/html_email_creator/layout.rb +15 -0
- data/lib/html_email_creator/processor.rb +125 -0
- data/lib/html_email_creator/settings.rb +95 -0
- data/lib/html_email_creator/tags/include_tag.rb +71 -0
- data/lib/html_email_creator/version.rb +3 -0
- data/lib/html_email_creator.rb +46 -0
- data/spec/fixtures/complex_with_config/.html_config.yaml +11 -0
- data/spec/fixtures/complex_with_config/Emails/polite_email.yaml +7 -0
- data/spec/fixtures/complex_with_config/Includes/Emails/love.md +1 -0
- data/spec/fixtures/complex_with_config/Includes/Footers/polite.md +3 -0
- data/spec/fixtures/complex_with_config/Layouts/.keep +0 -0
- data/spec/fixtures/complex_with_config/Layouts/basic.liquid +25 -0
- data/spec/fixtures/complex_with_config/Output/.keep +0 -0
- data/spec/fixtures/default_config/Emails/Newsletter/.keep +0 -0
- data/spec/fixtures/default_config/Layouts/.keep +0 -0
- data/spec/fixtures/default_config/Output/.keep +0 -0
- data/spec/fixtures/with_config/.html_config.yaml +11 -0
- data/spec/fixtures/with_config/Emails/first_email.yaml +7 -0
- data/spec/fixtures/with_config/Includes/Emails/barfoo.md +1 -0
- data/spec/fixtures/with_config/Includes/Emails/foobar.md +1 -0
- data/spec/fixtures/with_config/Includes/Quotes/henry_ford.txt +1 -0
- data/spec/fixtures/with_config/Layouts/.keep +0 -0
- data/spec/fixtures/with_config/Layouts/simple.liquid +7 -0
- data/spec/fixtures/with_config/Output/.keep +0 -0
- data/spec/html_email_creator/email_creator_spec.rb +119 -0
- data/spec/html_email_creator/email_spec.rb +29 -0
- data/spec/html_email_creator/formatter_spec.rb +40 -0
- data/spec/html_email_creator/layout_spec.rb +55 -0
- data/spec/html_email_creator/processor_spec.rb +111 -0
- data/spec/html_email_creator/settings_spec.rb +70 -0
- data/spec/html_email_creator/tags/include_tag_spec.rb +11 -0
- data/spec/spec_helper.rb +32 -0
- metadata +244 -0
@@ -0,0 +1,70 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), '..', 'spec_helper')
|
2
|
+
|
3
|
+
describe HtmlEmailCreator::Settings do
|
4
|
+
|
5
|
+
describe "default settings" do
|
6
|
+
before(:all) do
|
7
|
+
@home_directory = File.expand_path('~')
|
8
|
+
@default_settings = HtmlEmailCreator::Settings.new
|
9
|
+
end
|
10
|
+
|
11
|
+
it "should return user's home directory based email directory" do
|
12
|
+
@default_settings.emails_path.should eql(File.join(@home_directory, "Emails"))
|
13
|
+
end
|
14
|
+
|
15
|
+
it "should return user's home directory based layouts directory" do
|
16
|
+
@default_settings.layouts_path.should eql(File.join(@home_directory, "Layouts"))
|
17
|
+
end
|
18
|
+
|
19
|
+
it "should return user's home directory based output directory" do
|
20
|
+
@default_settings.output_path.should eql(File.join(@home_directory, "Output"))
|
21
|
+
end
|
22
|
+
|
23
|
+
it "should return empty CDN url" do
|
24
|
+
@default_settings.cdn_url.should eql("")
|
25
|
+
end
|
26
|
+
|
27
|
+
it "should return extension list" do
|
28
|
+
@default_settings.extension_data.should eql({})
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
describe "finding default directories" do
|
33
|
+
before(:all) do
|
34
|
+
@default_settings = HtmlEmailCreator::Settings.new(fixture_dir("default_config", "Emails", "Newsletter"))
|
35
|
+
end
|
36
|
+
|
37
|
+
it "should find Layout directory recursively" do
|
38
|
+
@default_settings.emails_path.should eql(fixture_dir("default_config", "Emails"))
|
39
|
+
end
|
40
|
+
|
41
|
+
it "should find Layout directory recursively" do
|
42
|
+
@default_settings.layouts_path.should eql(fixture_dir("default_config", "Layouts"))
|
43
|
+
end
|
44
|
+
|
45
|
+
it "should find Output directory recursively" do
|
46
|
+
@default_settings.output_path.should eql(fixture_dir("default_config", "Output"))
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
describe "finding settings from the file system" do
|
51
|
+
|
52
|
+
it "should find the configuration recursively from leaf to root" do
|
53
|
+
HtmlEmailCreator::Settings.new(fixture_dir).cdn_url.should eql("") # not found
|
54
|
+
HtmlEmailCreator::Settings.new(fixture_dir("with_config")).cdn_url.should eql("http://cdn.example.com") # found
|
55
|
+
HtmlEmailCreator::Settings.new(fixture_dir("with_config", "Layout")).cdn_url.should eql("http://cdn.example.com") # found
|
56
|
+
end
|
57
|
+
|
58
|
+
it "should find the configuration recursively from the current directory to root" do
|
59
|
+
Dir.chdir(fixture_dir("with_config"))
|
60
|
+
HtmlEmailCreator.update_settings
|
61
|
+
HtmlEmailCreator.settings.cdn_url.should eql("http://cdn.example.com") # found
|
62
|
+
end
|
63
|
+
|
64
|
+
it "should use defaults if the directory could not be found from the current directory or any root directories" do
|
65
|
+
Dir.chdir(File.dirname(__FILE__))
|
66
|
+
HtmlEmailCreator.update_settings
|
67
|
+
HtmlEmailCreator.settings.cdn_url.should eql("") # not found
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), '..', '..', 'spec_helper')
|
2
|
+
|
3
|
+
describe HtmlEmailCreator::IncludeTag do
|
4
|
+
|
5
|
+
it "should return user's home directory based email directory" do
|
6
|
+
run_in_fixture_dir("with_config") do
|
7
|
+
Liquid::Template.parse("{% include 'Quotes/henry_ford.txt' what: 'door' %}").render({}).should == "A bore is a person who opens his door and puts his feats in it."
|
8
|
+
Liquid::Template.parse("{% include 'Quotes/henry_ford.txt' what: 'car' %}").render({}).should == "A bore is a person who opens his car and puts his feats in it."
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), "..", "lib", "html_email_creator")
|
2
|
+
|
3
|
+
RSpec.configure do |config|
|
4
|
+
config.color_enabled = true
|
5
|
+
|
6
|
+
config.before :each do
|
7
|
+
ARGV.replace []
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
def fixture_dir(*pathparts)
|
12
|
+
File.join(File.dirname(__FILE__), 'fixtures', pathparts.flatten)
|
13
|
+
end
|
14
|
+
|
15
|
+
def read_fixture(*pathparts)
|
16
|
+
IO.read(fixture_dir(pathparts))
|
17
|
+
end
|
18
|
+
|
19
|
+
def clean_fixture_output
|
20
|
+
Dir.glob(File.join(fixture_dir, "**", "Output", "**", "*.{html,txt}")).each do |file|
|
21
|
+
File.delete(file)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
def run_in_fixture_dir(*pathparts, &block)
|
26
|
+
current_dir = Dir.pwd
|
27
|
+
Dir.chdir(fixture_dir(pathparts))
|
28
|
+
HtmlEmailCreator.update_settings
|
29
|
+
res = yield
|
30
|
+
Dir.chdir(current_dir)
|
31
|
+
res
|
32
|
+
end
|
metadata
ADDED
@@ -0,0 +1,244 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: html_email_creator
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease: false
|
5
|
+
segments:
|
6
|
+
- 1
|
7
|
+
- 0
|
8
|
+
- 0
|
9
|
+
version: 1.0.0
|
10
|
+
platform: ruby
|
11
|
+
authors:
|
12
|
+
- Pekka Mattila
|
13
|
+
autorequire:
|
14
|
+
bindir: bin
|
15
|
+
cert_chain: []
|
16
|
+
|
17
|
+
date: 2011-11-03 00:00:00 +02:00
|
18
|
+
default_executable: html_email_creator
|
19
|
+
dependencies:
|
20
|
+
- !ruby/object:Gem::Dependency
|
21
|
+
name: commander
|
22
|
+
prerelease: false
|
23
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
24
|
+
none: false
|
25
|
+
requirements:
|
26
|
+
- - ">="
|
27
|
+
- !ruby/object:Gem::Version
|
28
|
+
segments:
|
29
|
+
- 4
|
30
|
+
- 0
|
31
|
+
- 6
|
32
|
+
version: 4.0.6
|
33
|
+
type: :runtime
|
34
|
+
version_requirements: *id001
|
35
|
+
- !ruby/object:Gem::Dependency
|
36
|
+
name: kramdown
|
37
|
+
prerelease: false
|
38
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
39
|
+
none: false
|
40
|
+
requirements:
|
41
|
+
- - ">="
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
segments:
|
44
|
+
- 0
|
45
|
+
- 13
|
46
|
+
- 3
|
47
|
+
version: 0.13.3
|
48
|
+
type: :runtime
|
49
|
+
version_requirements: *id002
|
50
|
+
- !ruby/object:Gem::Dependency
|
51
|
+
name: liquid
|
52
|
+
prerelease: false
|
53
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
54
|
+
none: false
|
55
|
+
requirements:
|
56
|
+
- - ">="
|
57
|
+
- !ruby/object:Gem::Version
|
58
|
+
segments:
|
59
|
+
- 2
|
60
|
+
- 3
|
61
|
+
- 0
|
62
|
+
version: 2.3.0
|
63
|
+
type: :runtime
|
64
|
+
version_requirements: *id003
|
65
|
+
- !ruby/object:Gem::Dependency
|
66
|
+
name: nokogiri
|
67
|
+
prerelease: false
|
68
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
69
|
+
none: false
|
70
|
+
requirements:
|
71
|
+
- - ">="
|
72
|
+
- !ruby/object:Gem::Version
|
73
|
+
segments:
|
74
|
+
- 1
|
75
|
+
- 5
|
76
|
+
- 0
|
77
|
+
version: 1.5.0
|
78
|
+
type: :runtime
|
79
|
+
version_requirements: *id004
|
80
|
+
- !ruby/object:Gem::Dependency
|
81
|
+
name: inline-style
|
82
|
+
prerelease: false
|
83
|
+
requirement: &id005 !ruby/object:Gem::Requirement
|
84
|
+
none: false
|
85
|
+
requirements:
|
86
|
+
- - ">="
|
87
|
+
- !ruby/object:Gem::Version
|
88
|
+
segments:
|
89
|
+
- 0
|
90
|
+
- 5
|
91
|
+
- 0
|
92
|
+
version: 0.5.0
|
93
|
+
type: :runtime
|
94
|
+
version_requirements: *id005
|
95
|
+
- !ruby/object:Gem::Dependency
|
96
|
+
name: rspec
|
97
|
+
prerelease: false
|
98
|
+
requirement: &id006 !ruby/object:Gem::Requirement
|
99
|
+
none: false
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
segments:
|
104
|
+
- 0
|
105
|
+
version: "0"
|
106
|
+
type: :development
|
107
|
+
version_requirements: *id006
|
108
|
+
- !ruby/object:Gem::Dependency
|
109
|
+
name: rake
|
110
|
+
prerelease: false
|
111
|
+
requirement: &id007 !ruby/object:Gem::Requirement
|
112
|
+
none: false
|
113
|
+
requirements:
|
114
|
+
- - ">="
|
115
|
+
- !ruby/object:Gem::Version
|
116
|
+
segments:
|
117
|
+
- 0
|
118
|
+
- 9
|
119
|
+
- 2
|
120
|
+
version: 0.9.2
|
121
|
+
type: :development
|
122
|
+
version_requirements: *id007
|
123
|
+
description: An easy way to create HTML and plain text emails using Markdown markup and Liquid layouts.
|
124
|
+
email: pekka.mattila@gmail.com
|
125
|
+
executables:
|
126
|
+
- html_email_creator
|
127
|
+
extensions: []
|
128
|
+
|
129
|
+
extra_rdoc_files: []
|
130
|
+
|
131
|
+
files:
|
132
|
+
- .gitignore
|
133
|
+
- Gemfile
|
134
|
+
- Gemfile.lock
|
135
|
+
- README.markdown
|
136
|
+
- Rakefile
|
137
|
+
- bin/html_email_creator
|
138
|
+
- html_email_creator.gemspec
|
139
|
+
- lib/html_email_creator.rb
|
140
|
+
- lib/html_email_creator/email.rb
|
141
|
+
- lib/html_email_creator/email_creator.rb
|
142
|
+
- lib/html_email_creator/email_version.rb
|
143
|
+
- lib/html_email_creator/extensions.rb
|
144
|
+
- lib/html_email_creator/filters.rb
|
145
|
+
- lib/html_email_creator/formatter.rb
|
146
|
+
- lib/html_email_creator/formatters/formatter.rb
|
147
|
+
- lib/html_email_creator/formatters/html_email.rb
|
148
|
+
- lib/html_email_creator/formatters/markdown.rb
|
149
|
+
- lib/html_email_creator/formatters/plain_text_email.rb
|
150
|
+
- lib/html_email_creator/formatters/unknown_formatter.rb
|
151
|
+
- lib/html_email_creator/helper.rb
|
152
|
+
- lib/html_email_creator/information.rb
|
153
|
+
- lib/html_email_creator/layout.rb
|
154
|
+
- lib/html_email_creator/processor.rb
|
155
|
+
- lib/html_email_creator/settings.rb
|
156
|
+
- lib/html_email_creator/tags/include_tag.rb
|
157
|
+
- lib/html_email_creator/version.rb
|
158
|
+
- spec/fixtures/complex_with_config/.html_config.yaml
|
159
|
+
- spec/fixtures/complex_with_config/Emails/polite_email.yaml
|
160
|
+
- spec/fixtures/complex_with_config/Includes/Emails/love.md
|
161
|
+
- spec/fixtures/complex_with_config/Includes/Footers/polite.md
|
162
|
+
- spec/fixtures/complex_with_config/Layouts/.keep
|
163
|
+
- spec/fixtures/complex_with_config/Layouts/basic.liquid
|
164
|
+
- spec/fixtures/complex_with_config/Output/.keep
|
165
|
+
- spec/fixtures/default_config/Emails/Newsletter/.keep
|
166
|
+
- spec/fixtures/default_config/Layouts/.keep
|
167
|
+
- spec/fixtures/default_config/Output/.keep
|
168
|
+
- spec/fixtures/with_config/.html_config.yaml
|
169
|
+
- spec/fixtures/with_config/Emails/first_email.yaml
|
170
|
+
- spec/fixtures/with_config/Includes/Emails/barfoo.md
|
171
|
+
- spec/fixtures/with_config/Includes/Emails/foobar.md
|
172
|
+
- spec/fixtures/with_config/Includes/Quotes/henry_ford.txt
|
173
|
+
- spec/fixtures/with_config/Layouts/.keep
|
174
|
+
- spec/fixtures/with_config/Layouts/simple.liquid
|
175
|
+
- spec/fixtures/with_config/Output/.keep
|
176
|
+
- spec/html_email_creator/email_creator_spec.rb
|
177
|
+
- spec/html_email_creator/email_spec.rb
|
178
|
+
- spec/html_email_creator/formatter_spec.rb
|
179
|
+
- spec/html_email_creator/layout_spec.rb
|
180
|
+
- spec/html_email_creator/processor_spec.rb
|
181
|
+
- spec/html_email_creator/settings_spec.rb
|
182
|
+
- spec/html_email_creator/tags/include_tag_spec.rb
|
183
|
+
- spec/spec_helper.rb
|
184
|
+
has_rdoc: true
|
185
|
+
homepage: https://github.com/pekkaj/HTML-Email-Creator
|
186
|
+
licenses: []
|
187
|
+
|
188
|
+
post_install_message:
|
189
|
+
rdoc_options: []
|
190
|
+
|
191
|
+
require_paths:
|
192
|
+
- lib
|
193
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
194
|
+
none: false
|
195
|
+
requirements:
|
196
|
+
- - ">="
|
197
|
+
- !ruby/object:Gem::Version
|
198
|
+
segments:
|
199
|
+
- 1
|
200
|
+
- 9
|
201
|
+
- 2
|
202
|
+
version: 1.9.2
|
203
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
204
|
+
none: false
|
205
|
+
requirements:
|
206
|
+
- - ">="
|
207
|
+
- !ruby/object:Gem::Version
|
208
|
+
segments:
|
209
|
+
- 0
|
210
|
+
version: "0"
|
211
|
+
requirements: []
|
212
|
+
|
213
|
+
rubyforge_project: html_email_creator
|
214
|
+
rubygems_version: 1.3.7
|
215
|
+
signing_key:
|
216
|
+
specification_version: 3
|
217
|
+
summary: An easy way to create HTML and plain text emails!
|
218
|
+
test_files:
|
219
|
+
- spec/fixtures/complex_with_config/.html_config.yaml
|
220
|
+
- spec/fixtures/complex_with_config/Emails/polite_email.yaml
|
221
|
+
- spec/fixtures/complex_with_config/Includes/Emails/love.md
|
222
|
+
- spec/fixtures/complex_with_config/Includes/Footers/polite.md
|
223
|
+
- spec/fixtures/complex_with_config/Layouts/.keep
|
224
|
+
- spec/fixtures/complex_with_config/Layouts/basic.liquid
|
225
|
+
- spec/fixtures/complex_with_config/Output/.keep
|
226
|
+
- spec/fixtures/default_config/Emails/Newsletter/.keep
|
227
|
+
- spec/fixtures/default_config/Layouts/.keep
|
228
|
+
- spec/fixtures/default_config/Output/.keep
|
229
|
+
- spec/fixtures/with_config/.html_config.yaml
|
230
|
+
- spec/fixtures/with_config/Emails/first_email.yaml
|
231
|
+
- spec/fixtures/with_config/Includes/Emails/barfoo.md
|
232
|
+
- spec/fixtures/with_config/Includes/Emails/foobar.md
|
233
|
+
- spec/fixtures/with_config/Includes/Quotes/henry_ford.txt
|
234
|
+
- spec/fixtures/with_config/Layouts/.keep
|
235
|
+
- spec/fixtures/with_config/Layouts/simple.liquid
|
236
|
+
- spec/fixtures/with_config/Output/.keep
|
237
|
+
- spec/html_email_creator/email_creator_spec.rb
|
238
|
+
- spec/html_email_creator/email_spec.rb
|
239
|
+
- spec/html_email_creator/formatter_spec.rb
|
240
|
+
- spec/html_email_creator/layout_spec.rb
|
241
|
+
- spec/html_email_creator/processor_spec.rb
|
242
|
+
- spec/html_email_creator/settings_spec.rb
|
243
|
+
- spec/html_email_creator/tags/include_tag_spec.rb
|
244
|
+
- spec/spec_helper.rb
|