effective_email_templates 1.0.1 → 1.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/config/routes.rb +1 -1
- data/lib/effective_email_templates/importer.rb +10 -9
- data/lib/effective_email_templates/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: eac065491013a9a2c051a9c35e24bdf06dab0df7a5e99b4c5e94c90611207d4b
|
4
|
+
data.tar.gz: 4a461d58c903499e753d86563b315c43e4067a53bff47d39a134b575b8bf6f76
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 86639e64193989056fe756a73602823431d7d6d4efd86f7fa02e52c4f09f707ee94b94640be9fbd79fe5092b3fe603357dae11bc01b816ebc8019fa3ec39d18b
|
7
|
+
data.tar.gz: '06669f2e153895afc3db34e147b63d017e7930c68c09cd464dc2e2ff0ff185462b7e9562244f3834fa6f47b19301368c8328f9c3752cd0d6ae5f3f4d22cf04b7'
|
data/config/routes.rb
CHANGED
@@ -1,29 +1,30 @@
|
|
1
1
|
module EffectiveEmailTemplates
|
2
2
|
class Importer
|
3
|
-
def self.import
|
4
|
-
new().execute(overwrite: false)
|
3
|
+
def self.import(quiet: false)
|
4
|
+
new().execute(overwrite: false, quiet: quiet)
|
5
5
|
end
|
6
6
|
|
7
|
-
def self.overwrite
|
8
|
-
new().execute(overwrite: true)
|
7
|
+
def self.overwrite(quiet: false)
|
8
|
+
new().execute(overwrite: true, quiet: quiet)
|
9
9
|
end
|
10
10
|
|
11
|
-
def execute(overwrite:)
|
11
|
+
def execute(overwrite:, quiet: false)
|
12
12
|
Dir[Rails.root.join('app', 'views', '**', '*.liquid')].each do |filepath|
|
13
13
|
name = File.basename(filepath, '.liquid')
|
14
14
|
email_template = Effective::EmailTemplate.find_or_initialize_by(template_name: name)
|
15
15
|
|
16
16
|
if email_template.persisted? && !overwrite
|
17
|
-
puts
|
17
|
+
puts("SKIPPED #{filename(filepath)}") unless quiet
|
18
|
+
next
|
18
19
|
end
|
19
20
|
|
20
|
-
save(email_template, filepath)
|
21
|
+
save(email_template, filepath, quiet: quiet)
|
21
22
|
end
|
22
23
|
end
|
23
24
|
|
24
25
|
private
|
25
26
|
|
26
|
-
def save(email_template, filepath)
|
27
|
+
def save(email_template, filepath, quiet:)
|
27
28
|
file = File.new(filepath, 'r')
|
28
29
|
|
29
30
|
attributes = begin
|
@@ -41,7 +42,7 @@ module EffectiveEmailTemplates
|
|
41
42
|
email_template.assign_attributes(body: body)
|
42
43
|
|
43
44
|
if email_template.save
|
44
|
-
puts
|
45
|
+
puts("SUCCESS #{filename(filepath)}") unless quiet
|
45
46
|
else
|
46
47
|
puts "ERROR #{filename(filepath)}: #{email_template.errors.full_messages.to_sentence}"
|
47
48
|
end
|