maily 0.7.2 → 0.8.0

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
  SHA1:
3
- metadata.gz: 50e254d6048356a08a30e2175e4bc1809c9cccc7
4
- data.tar.gz: 799e7de87f596fe17ed4981f8025ee1156639e4f
3
+ metadata.gz: 06aac472a02c56536bdeddfaef8de5c3b273f645
4
+ data.tar.gz: 7beb443286274be5d2a5dccc1c987d9ea4ccf08c
5
5
  SHA512:
6
- metadata.gz: 1c870ea516edd08cfb71cb46519784009e0945b905ff6e85fdb559468042bffae144bf7c8227e9555cb4415164481f6b3c3d76f22124a7bc61905db3ad91236f
7
- data.tar.gz: 17dd9afc7e7b4024bb1789771c07a0946e32d8a70b150560b1ec365c31b4cb46661bcb3a87d11ce10e595bbfd814e9dfd5f4f8de01d12c97d2a34d04bd2d7560
6
+ metadata.gz: 4e3b8549a478516f18455592986e6d7ddf850035db3f6a7afb1c5f5dc44974ed47a79c3abb0686749d5026747b33c45adfea1fc61619392e4973fcd81b9d42da
7
+ data.tar.gz: d4129159e44325534a217e7083f212c8951c7e965d6ed44aefb7d8235fe5d46c10b49506d8a2197ff8138556d55b70845dd828789cffbb72876b95a628545d00
@@ -2,6 +2,12 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file.
4
4
 
5
+ ## [0.8.0]
6
+
7
+ - Inherited emails support (#28)
8
+ - `Maily.available_locales` defaults to Rails
9
+ available_locales `config.i18n.available_locales` (#27)
10
+
5
11
  ## [0.7.2]
6
12
 
7
13
  - Definitive fix for newer apps using `webpacker` and without `sass-rails` (#22)
@@ -85,6 +91,7 @@ All notable changes to this project will be documented in this file.
85
91
 
86
92
  - First real usable release :tada:
87
93
 
94
+ [0.8.0]: https://github.com/markets/maily/compare/v0.7.2...v0.8.0
88
95
  [0.7.2]: https://github.com/markets/maily/compare/v0.7.1...v0.7.2
89
96
  [0.7.1]: https://github.com/markets/maily/compare/v0.7.0...v0.7.1
90
97
  [0.7.0]: https://github.com/markets/maily/compare/v0.6.3...v0.7.0
data/README.md CHANGED
@@ -66,7 +66,7 @@ Maily.setup do |config|
66
66
  # Allow deliveries
67
67
  # config.allow_delivery = Rails.env.production? ? false : true
68
68
 
69
- # I18n.available_locales by default
69
+ # Your application available_locales (or I18n.available_locales) by default
70
70
  # config.available_locales = [:en, :es, :pt, :fr]
71
71
 
72
72
  # Run maily under different controller ('ActionController::Base' by default)
@@ -48,12 +48,12 @@ header.header, footer.footer {
48
48
  position: fixed;
49
49
  left: 0;
50
50
  z-index: 99;
51
- padding: .5em 1em;
52
51
  width: 100%;
53
52
  background-color: rgba(255,255,255, .95);
54
53
  }
55
54
 
56
55
  header.header {
56
+ padding: 1em;
57
57
  top: 0;
58
58
  box-shadow: 0 .0625em .3125em rgba(0,0,0, .15);
59
59
 
@@ -63,13 +63,14 @@ header.header {
63
63
  margin-left: 10px;
64
64
 
65
65
  img, span {
66
- vertical-align: middle;
66
+ vertical-align: text-bottom;
67
67
  }
68
68
  }
69
69
  }
70
70
 
71
71
  /* Footer */
72
72
  footer.footer {
73
+ padding: 0 1em;
73
74
  bottom: 0;
74
75
  box-shadow: 0 -.0625em .3125em rgba(0,0,0, .15);
75
76
  font-family: "Helvetica Neue", Helvetica, sans-serif;
@@ -181,6 +182,7 @@ footer.footer {
181
182
  border: none;
182
183
  border-top: solid 1px $grey;
183
184
  border-radius: 2px;
185
+ min-height: 100px;
184
186
  }
185
187
  }
186
188
 
@@ -1,6 +1,6 @@
1
1
  <header class="header">
2
2
  <a href="<%= root_path %>" class="logo_link">
3
- <%= image_tag 'maily/logo.png', align: 'center', width: 45 %>
3
+ <%= image_tag 'maily/logo.png', align: 'center', width: 40 %>
4
4
  <span>Maily</span>
5
5
  </a>
6
6
  </header>
@@ -8,7 +8,7 @@ Maily.setup do |config|
8
8
  # Allow deliveries
9
9
  # config.allow_delivery = Rails.env.production? ? false : true
10
10
 
11
- # I18n.available_locales by default
11
+ # Your application available_locales (or I18n.available_locales) by default
12
12
  # config.available_locales = [:en, :es, :pt, :fr]
13
13
 
14
14
  # Run maily under different controller ('ActionController::Base' by default)
@@ -13,7 +13,7 @@ module Maily
13
13
  self.enabled = Rails.env.production? ? false : true
14
14
  self.allow_edition = Rails.env.production? ? false : true
15
15
  self.allow_delivery = Rails.env.production? ? false : true
16
- self.available_locales = I18n.available_locales
16
+ self.available_locales = Rails.application.config.i18n.available_locales || I18n.available_locales
17
17
  self.base_controller = 'ActionController::Base'
18
18
  self.http_authorization = nil
19
19
  self.hooks_path = "lib/maily_hooks.rb"
@@ -7,14 +7,20 @@ module Maily
7
7
  hooks = []
8
8
 
9
9
  Maily::Mailer.list.each do |mailer|
10
- hooks << "\nMaily.hooks_for('#{mailer.name.classify}') do |mailer|"
10
+ _hooks = []
11
+
11
12
  mailer.emails_list.each do |email|
12
13
  if email.require_hook?
13
14
  fixtures << email.required_arguments
14
- hooks << " mailer.register_hook(:#{email.name}, #{email.required_arguments.join(', ')})"
15
+ _hooks << " mailer.register_hook(:#{email.name}, #{email.required_arguments.join(', ')})"
15
16
  end
16
17
  end
17
- hooks << "end"
18
+
19
+ if _hooks.present?
20
+ hooks << "\nMaily.hooks_for('#{mailer.name.classify}') do |mailer|"
21
+ hooks << _hooks
22
+ hooks << "end"
23
+ end
18
24
  end
19
25
 
20
26
  fixtures = fixtures.flatten.uniq.map { |f| "#{f.to_s} = ''" }.join("\n")
@@ -40,7 +40,7 @@ module Maily
40
40
  end
41
41
 
42
42
  def register_hook(email_name, *args)
43
- email = find_email(email_name)
43
+ email = find_email(email_name) || add_email(email_name)
44
44
  email && email.register_hook(args)
45
45
  end
46
46
 
@@ -55,9 +55,14 @@ module Maily
55
55
  def parse_emails
56
56
  _emails = klass.send(:public_instance_methods, false)
57
57
 
58
- _emails.map(&:to_s).each do |email|
59
- self.emails[email] = Maily::Email.new(email, self)
58
+ _emails.each do |email|
59
+ add_email(email)
60
60
  end
61
61
  end
62
+
63
+ def add_email(email_name)
64
+ email = Maily::Email.new(email_name.to_s, self)
65
+ self.emails[email.name] = email
66
+ end
62
67
  end
63
68
  end
@@ -1,3 +1,3 @@
1
1
  module Maily
2
- VERSION = "0.7.2"
2
+ VERSION = "0.8.0"
3
3
  end
@@ -0,0 +1,7 @@
1
+ class ApplicationMailer < ActionMailer::Base
2
+ default from: 'foo@foo.com', to: 'bar@bar.com'
3
+
4
+ def generic_welcome
5
+ mail
6
+ end
7
+ end
@@ -1,6 +1,4 @@
1
- class Notifier < ActionMailer::Base
2
- default from: 'foo@foo.com', to: 'bar@bar.com'
3
-
1
+ class Notifier < ApplicationMailer
4
2
  def welcome
5
3
  mail
6
4
  end
@@ -0,0 +1 @@
1
+ <h1>Generic Welcome</h1>
@@ -22,6 +22,7 @@ module Dummy
22
22
  # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
23
23
  # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
24
24
  # config.i18n.default_locale = :de
25
+ config.i18n.available_locales = [:en, :es, :pt, :fr]
25
26
  end
26
27
  end
27
28
 
@@ -4,6 +4,7 @@ Maily.hooks_for('Notifier') do |mailer|
4
4
  mailer.register_hook(:invitation, email)
5
5
  mailer.register_hook(:recommendation, template_path: 'notifications', description: 'description')
6
6
  mailer.register_hook(:custom_template_name, template_name: 'invitation')
7
+ mailer.register_hook(:generic_welcome)
7
8
 
8
9
  mailer.hide_email(:hidden)
9
10
  end
@@ -1,14 +1,14 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe Maily::Mailer do
4
+ let(:mailer) { Maily::Mailer.find('notifier') }
5
+
4
6
  it "should load mailers" do
5
- expect(Maily::Mailer.all.keys).to eq(['notifier'])
7
+ expect(Maily::Mailer.all.keys).to eq(['application_mailer', 'notifier'])
6
8
  end
7
9
 
8
10
  it "should build emails" do
9
- mailer = Maily::Mailer.find('notifier')
10
-
11
- expect(mailer.emails.size).to eq(6)
11
+ expect(mailer.emails.size).to eq(7)
12
12
  end
13
13
 
14
14
  it "should find mailers by name" do
@@ -16,14 +16,14 @@ describe Maily::Mailer do
16
16
  end
17
17
 
18
18
  it "should find emails by name" do
19
- mailer = Maily::Mailer.find('notifier')
20
-
21
19
  expect(mailer.find_email('welcome').name).to eq('welcome')
22
20
  end
23
21
 
24
- it "allows to hide email" do
25
- mailer = Maily::Mailer.find('notifier')
22
+ it "allow to add inherited emails via a hook" do
23
+ expect(mailer.find_email('generic_welcome').name).to eq('generic_welcome')
24
+ end
26
25
 
26
+ it "allows to hide email" do
27
27
  expect(mailer.find_email('hidden')).to be nil
28
28
  end
29
29
 
@@ -35,8 +35,6 @@ describe Maily::Mailer do
35
35
  end
36
36
 
37
37
  it "#emails_list returns an array with all emails" do
38
- mailer = Maily::Mailer.find('notifier')
39
-
40
38
  expect(mailer.emails_list).to be_an_instance_of(Array)
41
39
  expect(mailer.emails_list.sample).to be_an_instance_of(Maily::Email)
42
40
  end
@@ -7,7 +7,7 @@ describe Maily do
7
7
  expect(Maily.enabled).to be true
8
8
  expect(Maily.allow_edition).to be true
9
9
  expect(Maily.allow_delivery).to be true
10
- expect(Maily.available_locales).to eq(I18n.available_locales)
10
+ expect(Maily.available_locales).to eq([:en, :es, :pt, :fr])
11
11
  expect(Maily.base_controller).to eq('ActionController::Base')
12
12
  expect(Maily.http_authorization).to be nil
13
13
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: maily
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.2
4
+ version: 0.8.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - markets
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-06-22 00:00:00.000000000 Z
11
+ date: 2018-07-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -139,11 +139,13 @@ files:
139
139
  - spec/dummy/app/controllers/application_controller.rb
140
140
  - spec/dummy/app/controllers/concerns/.keep
141
141
  - spec/dummy/app/helpers/application_helper.rb
142
+ - spec/dummy/app/mailers/application_mailer.rb
142
143
  - spec/dummy/app/mailers/notifier.rb
143
144
  - spec/dummy/app/models/.keep
144
145
  - spec/dummy/app/models/concerns/.keep
145
146
  - spec/dummy/app/views/layouts/application.html.erb
146
147
  - spec/dummy/app/views/notifications/recommendation.html.erb
148
+ - spec/dummy/app/views/notifier/generic_welcome.html.erb
147
149
  - spec/dummy/app/views/notifier/invitation.html.erb
148
150
  - spec/dummy/app/views/notifier/multipart.html.erb
149
151
  - spec/dummy/app/views/notifier/multipart.text.erb
@@ -214,11 +216,13 @@ test_files:
214
216
  - spec/dummy/app/controllers/application_controller.rb
215
217
  - spec/dummy/app/controllers/concerns/.keep
216
218
  - spec/dummy/app/helpers/application_helper.rb
219
+ - spec/dummy/app/mailers/application_mailer.rb
217
220
  - spec/dummy/app/mailers/notifier.rb
218
221
  - spec/dummy/app/models/.keep
219
222
  - spec/dummy/app/models/concerns/.keep
220
223
  - spec/dummy/app/views/layouts/application.html.erb
221
224
  - spec/dummy/app/views/notifications/recommendation.html.erb
225
+ - spec/dummy/app/views/notifier/generic_welcome.html.erb
222
226
  - spec/dummy/app/views/notifier/invitation.html.erb
223
227
  - spec/dummy/app/views/notifier/multipart.html.erb
224
228
  - spec/dummy/app/views/notifier/multipart.text.erb