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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3f78b09e0fce401909a35e596e6d8628b8b2a79199884de8a27c90ac0145ac18
4
- data.tar.gz: 307f2c713e151db5069195446b3fdf2918f108144a64bfffae477afb0902fe08
3
+ metadata.gz: eac065491013a9a2c051a9c35e24bdf06dab0df7a5e99b4c5e94c90611207d4b
4
+ data.tar.gz: 4a461d58c903499e753d86563b315c43e4067a53bff47d39a134b575b8bf6f76
5
5
  SHA512:
6
- metadata.gz: b2ce8cefc4c2f9fb1b4465cfbf1c1fd94a584e41691c894c9ec983ab750676a73676778f9f7bb02ae21090ab569967f27ea573bd4531dccfb3fb569f7481c99d
7
- data.tar.gz: 26cc8dddb9911e40e00f64e3423e288e968e7c4617a817e1ed0be007048bc6fa6935cf3aba7555f7dfacb57c36a91549e5b7360727a017206fd004e75ce0c536
6
+ metadata.gz: 86639e64193989056fe756a73602823431d7d6d4efd86f7fa02e52c4f09f707ee94b94640be9fbd79fe5092b3fe603357dae11bc01b816ebc8019fa3ec39d18b
7
+ data.tar.gz: '06669f2e153895afc3db34e147b63d017e7930c68c09cd464dc2e2ff0ff185462b7e9562244f3834fa6f47b19301368c8328f9c3752cd0d6ae5f3f4d22cf04b7'
data/config/routes.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  EffectiveEmailTemplates::Engine.routes.draw do
2
2
  namespace :admin do
3
- resources :email_templates
3
+ resources :email_templates, only: [:index, :edit, :update, :destroy]
4
4
  end
5
5
  end
6
6
 
@@ -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 "SKIPPED #{filename(filepath)}"; next
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 "SUCCESS #{filename(filepath)}"
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
@@ -1,3 +1,3 @@
1
1
  module EffectiveEmailTemplates
2
- VERSION = '1.0.1'.freeze
2
+ VERSION = '1.0.2'.freeze
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: effective_email_templates
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Code and Effect