html_email_creator 1.0.9 → 1.0.10

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.
@@ -19,6 +19,12 @@ module HtmlEmailCreator
19
19
  'after_5_days' => '{!date dayname+5}',
20
20
  'after_6_days' => '{!date dayname+6}',
21
21
  'after_7_days' => '{!date dayname+7}'
22
+ },
23
+ 'mailchimp' => {
24
+ 'email' => '*|EMAIL|*',
25
+ 'first_name' => '*|FNAME|*',
26
+ 'last_name' => '*|LNAME|*',
27
+ 'unsubscribe_url' => '*|UNSUBSCRIBE|*'
22
28
  }
23
29
  }
24
30
 
@@ -1,3 +1,3 @@
1
1
  module HtmlEmailCreator
2
- VERSION = "1.0.9" unless defined?(::HtmlEmailCreator::VERSION)
2
+ VERSION = "1.0.10" unless defined?(::HtmlEmailCreator::VERSION)
3
3
  end
@@ -0,0 +1,11 @@
1
+ layouts_path: "../../Layouts"
2
+ output_path: "../../Output/Aweber"
3
+ emails_path: "../../Emails"
4
+ includes_path: "../../Includes"
5
+ cdn_url: "http://cdn.example.com"
6
+ extensions:
7
+ built_in:
8
+ - "aweber"
9
+ custom:
10
+ logo: "**Logo**: WOHOO."
11
+ great: "GREAT!"
@@ -0,0 +1,11 @@
1
+ layouts_path: "../../Layouts"
2
+ output_path: "../../Output/Mailchimp"
3
+ emails_path: "../../Emails"
4
+ includes_path: "../../Includes"
5
+ cdn_url: "http://cdn.example.com"
6
+ extensions:
7
+ built_in:
8
+ - "mailchimp"
9
+ custom:
10
+ logo: "**Logo**: WOHOO."
11
+ great: "GREAT!"
@@ -0,0 +1,7 @@
1
+ config:
2
+ output: "cool/basic_text"
3
+ layout: "basic.liquid"
4
+ data:
5
+ title_content: "A variant"
6
+ header_1_content: "{{ logo }}"
7
+ header_2_content: "{% include 'Emails/love.md' what: 'iPhone' %}"
@@ -1 +1 @@
1
- I really love {{ what }}. {{ great }}
1
+ {{ first_name }}, I really love {{ what }}. {{ great }}
@@ -13,7 +13,7 @@ ul{margin: 5px 5px 5px 5px}
13
13
 
14
14
  <h1>Header 1 starts</h1>
15
15
 
16
- Hi {{ full_name }},
16
+ Hi {{ first_name }},
17
17
 
18
18
  {{ header_1_content }}
19
19
 
@@ -2,8 +2,9 @@ require File.join(File.dirname(__FILE__), '..', 'spec_helper')
2
2
 
3
3
  describe HtmlEmailCreator::EmailCreator do
4
4
  let(:creator) { HtmlEmailCreator::EmailCreator.new }
5
- let(:email) { fixture_dir("complex_with_config", "Emails", "polite_email.yaml") }
6
- let(:expected_basic_text_html) {
5
+ let(:aweber_email) { fixture_dir("complex_with_config", "Emails", "Aweber", "polite_email.yaml") }
6
+ let(:mailchimp_email) { fixture_dir("complex_with_config", "Emails", "Mailchimp", "polite_email.yaml") }
7
+ let(:expected_basic_text_html_aweber) {
7
8
  html = <<eos
8
9
  <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
9
10
  <html>
@@ -15,36 +16,78 @@ describe HtmlEmailCreator::EmailCreator do
15
16
 
16
17
  <div class="h1"><div style="font-family: Helvetica;">Header 1 starts</div></div>
17
18
 
18
- Hi {!name_fix},
19
+ Hi {!firstname_fix},
19
20
 
20
21
  **Logo**: WOHOO.
21
22
 
22
23
  <div class="h2"><div>Header 2 starts</div></div>
23
24
 
24
- <p>I really love iPhone. GREAT!</p>
25
+ <p>{!firstname_fix}, I really love iPhone. GREAT!</p>
25
26
 
26
27
  </body>
27
28
  </html>
28
29
  eos
29
30
  }
30
-
31
- let(:expected_basic_text_txt) {
31
+
32
+ let(:expected_basic_text_html_mailchimp) {
33
+ html = <<eos
34
+ <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
35
+ <html>
36
+ <head>
37
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
38
+ <title>A variant</title>
39
+ </head>
40
+ <body>
41
+
42
+ <div class="h1"><div style="font-family: Helvetica;">Header 1 starts</div></div>
43
+
44
+ Hi *|FNAME|*,
45
+
46
+ **Logo**: WOHOO.
47
+
48
+ <div class="h2"><div>Header 2 starts</div></div>
49
+
50
+ <p>*|FNAME|*, I really love iPhone. GREAT!</p>
51
+
52
+ </body>
53
+ </html>
54
+ eos
55
+ }
56
+
57
+ let(:expected_basic_text_txt_aweber) {
32
58
  text = <<eos
33
59
  =============================================================================
34
60
  Header 1 starts
35
61
 
36
- Hi {!name_fix},
62
+ Hi {!firstname_fix},
37
63
 
38
64
  **Logo**: WOHOO.
39
65
 
40
66
  -----------------------------------------------------------------------------
41
67
  Header 2 starts
42
68
 
43
- I really love iPhone. GREAT!
69
+ {!firstname_fix}, I really love iPhone. GREAT!
44
70
  eos
45
71
  text.strip
46
72
  }
47
-
73
+
74
+ let(:expected_basic_text_txt_mailchimp) {
75
+ text = <<eos
76
+ =============================================================================
77
+ Header 1 starts
78
+
79
+ Hi *|FNAME|*,
80
+
81
+ **Logo**: WOHOO.
82
+
83
+ -----------------------------------------------------------------------------
84
+ Header 2 starts
85
+
86
+ *|FNAME|*, I really love iPhone. GREAT!
87
+ eos
88
+ text.strip
89
+ }
90
+
48
91
  let(:expected_first_html) {
49
92
  html = <<eos
50
93
  <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
@@ -60,7 +103,7 @@ eos
60
103
  </body></html>
61
104
  eos
62
105
  }
63
-
106
+
64
107
  let(:expected_first_txt) {
65
108
  text = <<eos
66
109
  This is simple template.
@@ -73,45 +116,56 @@ alt text (http://cdn.example.com/foo/bar)
73
116
  eos
74
117
  text.strip
75
118
  }
76
-
119
+
77
120
  describe "HTML mail" do
78
- it "should create well formed and expected HTML mail" do
79
- creator.create_html_email(email).get.should == expected_basic_text_html
80
- creator.create_email(email, HtmlEmailCreator::Formatters::HtmlEmail.id).get.should == expected_basic_text_html
121
+ it "should create well formed and expected HTML mail for Aweber" do
122
+ creator.create_html_email(aweber_email).get.should == expected_basic_text_html_aweber
123
+ creator.create_email(aweber_email, HtmlEmailCreator::Formatters::HtmlEmail.id).get.should == expected_basic_text_html_aweber
124
+ end
125
+
126
+ it "should create well formed and expected HTML mail for Mailchimp" do
127
+ creator.create_html_email(mailchimp_email).get.should == expected_basic_text_html_mailchimp
128
+ creator.create_email(mailchimp_email, HtmlEmailCreator::Formatters::HtmlEmail.id).get.should == expected_basic_text_html_mailchimp
81
129
  end
82
130
  end
83
-
131
+
84
132
  describe "Plain text mail" do
85
- it "should create well formed and expected plain text email" do
86
- creator.create_plain_text_email(email).get.should == expected_basic_text_txt
133
+ it "should create well formed and expected plain text email for Aweber" do
134
+ creator.create_plain_text_email(aweber_email).get.should == expected_basic_text_txt_aweber
135
+ end
136
+
137
+ it "should create well formed and expected plain text email for Mailchimp" do
138
+ creator.create_plain_text_email(mailchimp_email).get.should == expected_basic_text_txt_mailchimp
87
139
  end
88
140
  end
89
-
141
+
90
142
  describe "Saving email to a filesystem" do
91
143
  after(:each) { clean_fixture_output }
92
-
144
+
93
145
  it "should be possible to store emails recursively" do
94
146
  creator.save_emails(".").should be_empty
95
147
  creator.save_emails(".", true).should_not be_empty
96
148
  end
97
-
149
+
98
150
  it "should store all correct versions of emails recursively" do
99
151
  emails = creator.save_emails(".", true)
100
-
101
- read_fixture("complex_with_config", "Output", "cool", "basic_text.html").should == expected_basic_text_html
102
- read_fixture("complex_with_config", "Output", "cool", "basic_text.txt").should == expected_basic_text_txt
152
+
153
+ read_fixture("complex_with_config", "Output", "Aweber", "cool", "basic_text.html").should == expected_basic_text_html_aweber
154
+ read_fixture("complex_with_config", "Output", "Aweber", "cool", "basic_text.txt").should == expected_basic_text_txt_aweber
155
+ read_fixture("complex_with_config", "Output", "Mailchimp", "cool", "basic_text.html").should == expected_basic_text_html_mailchimp
156
+ read_fixture("complex_with_config", "Output", "Mailchimp", "cool", "basic_text.txt").should == expected_basic_text_txt_mailchimp
103
157
  read_fixture("with_config", "Output", "first.html").should == expected_first_html
104
158
  read_fixture("with_config", "Output", "first.txt").should == expected_first_txt
105
159
  end
106
-
160
+
107
161
  it "should store only one file if needed using absolute paths" do
108
- IO.read(creator.create_html_email(fixture_dir("complex_with_config", "Emails", "polite_email.yaml")).save).should == expected_basic_text_html
162
+ IO.read(creator.create_html_email(fixture_dir("complex_with_config", "Emails", "Aweber", "polite_email.yaml")).save).should == expected_basic_text_html_aweber
109
163
  end
110
-
164
+
111
165
  it "should store only one file if needed using relative paths" do
112
166
  run_in_fixture_dir("complex_with_config") do
113
167
  email_creator = HtmlEmailCreator::EmailCreator.new
114
- IO.read(email_creator.create_html_email(File.join("Emails", "polite_email.yaml")).save).should == expected_basic_text_html
168
+ IO.read(email_creator.create_html_email(File.join("Emails", "Aweber", "polite_email.yaml")).save).should == expected_basic_text_html_aweber
115
169
  end
116
170
  end
117
171
  end
@@ -29,6 +29,16 @@ describe HtmlEmailCreator::Layout do
29
29
  end
30
30
  end
31
31
  end
32
+
33
+ describe "mailchimp" do
34
+ let(:mailchimp) { HtmlEmailCreator::Extensions.new.built_in("mailchimp") }
35
+ let(:none) { {} }
36
+
37
+ it "should replace Mailchimp extension keys correctly if aweber extension is being used" do
38
+ HtmlEmailCreator::Layout.new("{{ first_name }}", mailchimp).to_html.should eql('*|FNAME|*')
39
+ HtmlEmailCreator::Layout.new("{{ last_name }}", none).to_html.should eql('')
40
+ end
41
+ end
32
42
  end
33
43
 
34
44
  describe "with custom extensions" do
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 1
7
7
  - 0
8
- - 9
9
- version: 1.0.9
8
+ - 10
9
+ version: 1.0.10
10
10
  platform: ruby
11
11
  authors:
12
12
  - Pekka Mattila
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2011-11-21 00:00:00 +02:00
17
+ date: 2011-12-08 00:00:00 +02:00
18
18
  default_executable: html_email_creator
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
@@ -155,8 +155,10 @@ files:
155
155
  - lib/html_email_creator/settings.rb
156
156
  - lib/html_email_creator/tags/include_tag.rb
157
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
158
+ - spec/fixtures/complex_with_config/Emails/Aweber/.html_config.yaml
159
+ - spec/fixtures/complex_with_config/Emails/Aweber/polite_email.yaml
160
+ - spec/fixtures/complex_with_config/Emails/Mailchimp/.html_config.yaml
161
+ - spec/fixtures/complex_with_config/Emails/Mailchimp/polite_email.yaml
160
162
  - spec/fixtures/complex_with_config/Includes/Emails/love.md
161
163
  - spec/fixtures/complex_with_config/Includes/Footers/polite.md
162
164
  - spec/fixtures/complex_with_config/Layouts/.keep
@@ -216,8 +218,10 @@ signing_key:
216
218
  specification_version: 3
217
219
  summary: An easy way to create HTML and plain text emails!
218
220
  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/Emails/Aweber/.html_config.yaml
222
+ - spec/fixtures/complex_with_config/Emails/Aweber/polite_email.yaml
223
+ - spec/fixtures/complex_with_config/Emails/Mailchimp/.html_config.yaml
224
+ - spec/fixtures/complex_with_config/Emails/Mailchimp/polite_email.yaml
221
225
  - spec/fixtures/complex_with_config/Includes/Emails/love.md
222
226
  - spec/fixtures/complex_with_config/Includes/Footers/polite.md
223
227
  - spec/fixtures/complex_with_config/Layouts/.keep
@@ -1,11 +0,0 @@
1
- layouts_path: "Layouts"
2
- output_path: "Output"
3
- emails_path: "Emails"
4
- includes_path: "Includes"
5
- cdn_url: "http://cdn.example.com"
6
- extensions:
7
- built_in:
8
- - "aweber"
9
- custom:
10
- logo: "**Logo**: WOHOO."
11
- great: "GREAT!"