actionmailer-markdown 0.4.1 → 0.4.3

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: 241e3bc0bc80195ce7c84277d26267685d9ec861e4eb457bd2dd690a7ed8d1e4
4
- data.tar.gz: c74e85daf173235889b016eb4c2ec9a4cfc8be79862a9581bc975eea16600fdb
3
+ metadata.gz: 3ebe1db37d8bd6b28e2831cb9d82b40588c8e941017b5f760bd2e2f05c8b89ce
4
+ data.tar.gz: 24f0b8c284ecbd0709914ad1b682fb2b24d5736f4e718a8bd9c4e1595faf47a5
5
5
  SHA512:
6
- metadata.gz: 707a0f1a494260968fea4ba24734b137da663cbc6db4894da83d58a8293845e134f3c382de9d29e52612925f0c7506e1b8511ab5debb2476cdc6fa83d066756d
7
- data.tar.gz: 9a143bb2bc4966b3c035d3e8f8b970a678bd328e9e4b0582482f887b0ded12509c4e8181f746b58794268bafe5ca58a5fbd5c3eb94fada913349f8f48c861490
6
+ metadata.gz: abb1f8588b16bcce4f51a63a51f24e91dc21d451e888791a1baa8c728c2a7ec0293359ac1c41731ce6aa0cef7eb618d73326252174ed0194f6285d26e833fdd5
7
+ data.tar.gz: 3a9a020648059ef34ac7be7f5add29efd8d9b4a95484ca6b8ffdbc868e37251850ebc4b58c141958e0f4eca441709436a01652642394e2f26c305f2f48677049
@@ -0,0 +1,3 @@
1
+ ---
2
+ github: [fnando]
3
+ custom: ["https://www.paypal.me/nandovieira/🍕"]
data/.rubocop.yml CHANGED
@@ -1,92 +1,21 @@
1
- AllCops:
2
- TargetRubyVersion: 2.6
3
-
4
- Exclude:
5
- - db/schema.rb
6
- - db/seeds.rb
7
- - config/environments/**/*.rb
8
- - bin/**/*
9
- - vendor/**/*
10
-
11
- Style/Documentation:
12
- Enabled: false
13
-
14
- Style/StringLiterals:
15
- EnforcedStyle: double_quotes
16
-
17
- Layout/SpaceInsideBlockBraces:
18
- EnforcedStyle: space
19
- EnforcedStyleForEmptyBraces: space
20
- SpaceBeforeBlockParameters: false
21
-
22
- Layout/SpaceInsideHashLiteralBraces:
23
- EnforcedStyle: no_space
24
- EnforcedStyleForEmptyBraces: no_space
25
-
26
- Layout/FirstArrayElementLineBreak:
27
- Enabled: true
28
-
29
- Layout/FirstHashElementLineBreak:
30
- Enabled: true
31
-
32
- Style/PercentLiteralDelimiters:
33
- PreferredDelimiters:
34
- "%": "[]"
35
- "%i": "[]"
36
- "%q": "[]"
37
- "%Q": "[]"
38
- "%r": "{}"
39
- "%s": "[]"
40
- "%w": "[]"
41
- "%W": "[]"
42
- "%x": "[]"
43
-
44
- Metrics/LineLength:
45
- Enabled: false
46
-
47
- Metrics/MethodLength:
48
- Enabled: false
49
-
50
- Style/EmptyMethod:
51
- EnforcedStyle: expanded
1
+ ---
2
+ inherit_gem:
3
+ rubocop-fnando: .rubocop.yml
52
4
 
53
- Layout/IndentFirstArrayElement:
54
- EnforcedStyle: consistent
55
-
56
- Style/AccessModifierDeclarations:
57
- EnforcedStyle: inline
58
-
59
- Naming/UncommunicativeMethodParamName:
60
- Enabled: false
61
-
62
- Style/Alias:
63
- EnforcedStyle: prefer_alias_method
64
-
65
- Metrics/CyclomaticComplexity:
66
- Enabled: false
67
-
68
- Metrics/AbcSize:
69
- Enabled: false
5
+ AllCops:
6
+ TargetRubyVersion: 2.7
7
+ NewCops: enable
70
8
 
71
- Metrics/PerceivedComplexity:
9
+ Layout/LineLength:
72
10
  Enabled: false
73
11
 
74
- Style/AsciiComments:
12
+ Metrics:
75
13
  Enabled: false
76
14
 
77
- Style/HashSyntax:
78
- Exclude:
79
- - Rakefile
80
- - "**/*.rake"
81
-
82
- Style/SymbolArray:
83
- Exclude:
84
- - Rakefile
85
- - "**/*.rake"
86
-
87
15
  Naming/FileName:
88
16
  Exclude:
89
17
  - lib/actionmailer-markdown.rb
90
18
 
91
- Lint/AmbiguousRegexpLiteral:
92
- Enabled: false
19
+ Style/OpenStructUse:
20
+ Exclude:
21
+ - test/**/*.rb
data/README.md CHANGED
@@ -1,8 +1,5 @@
1
1
  # ActionMailer::Markdown
2
2
 
3
- [![Travis-CI](https://travis-ci.org/fnando/actionmailer-markdown.png)](https://travis-ci.org/fnando/actionmailer-markdown)
4
- [![Code Climate](https://codeclimate.com/github/fnando/actionmailer-markdown/badges/gpa.svg)](https://codeclimate.com/github/fnando/actionmailer-markdown)
5
- [![Test Coverage](https://codeclimate.com/github/fnando/actionmailer-markdown/badges/coverage.svg)](https://codeclimate.com/github/fnando/actionmailer-markdown/coverage)
6
3
  [![Gem](https://img.shields.io/gem/v/actionmailer-markdown.svg)](https://rubygems.org/gems/actionmailer-markdown)
7
4
  [![Gem](https://img.shields.io/gem/dt/actionmailer-markdown.svg)](https://rubygems.org/gems/actionmailer-markdown)
8
5
 
@@ -26,7 +23,9 @@ Or install it yourself as:
26
23
 
27
24
  ## Usage
28
25
 
29
- Imagine that you have a mail named `UserMailer#welcome`. Instead of manually defining your subjects like the following, you can create the subject by defining the `user_mailer.welcome.subject` translation.
26
+ Imagine that you have a mail named `UserMailer#welcome`. Instead of manually
27
+ defining your subjects like the following, you can create the subject by
28
+ defining the `user_mailer.welcome.subject` translation.
30
29
 
31
30
  ```ruby
32
31
  # app/mailers/user_mailer.rb
@@ -45,7 +44,9 @@ en:
45
44
  subject: Welcome to my app
46
45
  ```
47
46
 
48
- Since I really like defining everything I can in I18n files, I always extend this behavior to the message's body, through the `user_mailer.welcome.body` translation.
47
+ Since I really like defining everything I can in I18n files, I always extend
48
+ this behavior to the message's body, through the `user_mailer.welcome.body`
49
+ translation.
49
50
 
50
51
  ```yaml
51
52
  # config/locales/en.yml
@@ -60,7 +61,8 @@ en:
60
61
  Myapp team
61
62
  ```
62
63
 
63
- Did you notice that `|`? That allows YAML strings to be multiline. And on your e-mail class you can do something like this:
64
+ Did you notice that `|`? That allows YAML strings to be multiline. And on your
65
+ e-mail class you can do something like this:
64
66
 
65
67
  ```ruby
66
68
  # app/mailers/user_mailer.rb
@@ -71,7 +73,8 @@ class UserMailer < ApplicationMailer
71
73
  end
72
74
  ```
73
75
 
74
- And if you want to render HTML and text-plain from this string, you may have to do something like this (Markdown class not shown).
76
+ And if you want to render HTML and text-plain from this string, you may have to
77
+ do something like this (Markdown class not shown).
75
78
 
76
79
  ```ruby
77
80
  # app/mailers/user_mailer.rb
@@ -87,7 +90,8 @@ class UserMailer < ApplicationMailer
87
90
  end
88
91
  ```
89
92
 
90
- This idea is really nice, but you have too much things to deal with. Not anymore!
93
+ This idea is really nice, but you have too much things to deal with. Not
94
+ anymore!
91
95
 
92
96
  With ActionMailer::Markdown you can just define your mailer action like this:
93
97
 
@@ -100,17 +104,20 @@ class UserMailer < ApplicationMailer
100
104
  end
101
105
  ```
102
106
 
103
- That's right! This gem automatically uses `user_mailer.welcome.{subject,body}` from your translation files. And the best part: it evens supports Markdown.
107
+ That's right! This gem automatically uses `user_mailer.welcome.{subject,body}`
108
+ from your translation files. And the best part: it evens supports Markdown.
104
109
 
105
110
  ### Passing variables
106
111
 
107
- You're likely to pass in variables to your messages. To do this, just define instance variables. Imagine you want to parse the user's name on your subject and message. Let's suppose you have your translation file defined like this:
112
+ You're likely to pass in variables to your messages. To do this, just define
113
+ instance variables. Imagine you want to parse the user's name on your subject
114
+ and message. Let's suppose you have your translation file defined like this:
108
115
 
109
116
  ```yaml
110
117
  en:
111
118
  user_mailer:
112
119
  welcome:
113
- subject: 'Welcome to Myapp, %{name}'
120
+ subject: "Welcome to Myapp, %{name}"
114
121
  body: |
115
122
  Hello, %{name}. And welcome to Myapp.
116
123
  ```
@@ -156,7 +163,8 @@ en:
156
163
  Myapp team
157
164
  ```
158
165
 
159
- You may be wondering what happens with the mail's text part. Don't worry! ActionMailer::Markdown will take care of that. That message will be rendered as:
166
+ You may be wondering what happens with the mail's text part. Don't worry!
167
+ ActionMailer::Markdown will take care of that. That message will be rendered as:
160
168
 
161
169
  ```text
162
170
  Hello, John!
@@ -172,11 +180,16 @@ Myapp team
172
180
 
173
181
  Lists and other elements are also exported to a more friendly text version.
174
182
 
175
- **PROTIP:** Use [i18n-dot_lookup](https://github.com/fnando/i18n-dot_lookup) if you want to access properties from an object, like `%{user.name}`
183
+ **PROTIP:** Use [i18n-dot_lookup](https://github.com/fnando/i18n-dot_lookup) if
184
+ you want to access properties from an object, like `%{user.name}`
176
185
 
177
186
  ### Replacing the Markdown engine
178
187
 
179
- [redcarpet](https://github.com/vmg/redcarpet) is the default Markdown parser. You may want to specify different options or even switch out to a different Markdown library. All you have to do is defining a processor that responds to `.call`. Let's say you want to use [kramdown](http://kramdown.gettalong.org/) as your Markdown engine.
188
+ [redcarpet](https://github.com/vmg/redcarpet) is the default Markdown parser.
189
+ You may want to specify different options or even switch out to a different
190
+ Markdown library. All you have to do is defining a processor that responds to
191
+ `.call`. Let's say you want to use [kramdown](http://kramdown.gettalong.org/) as
192
+ your Markdown engine.
180
193
 
181
194
  ```ruby
182
195
  ActionMailer::Markdown.processor = -> text { Kramdown::Document.new(text).to_html }
@@ -184,23 +197,36 @@ ActionMailer::Markdown.processor = -> text { Kramdown::Document.new(text).to_htm
184
197
 
185
198
  ### Falling back to ActionMailer's default behavior
186
199
 
187
- You can use templates if you want. Just don't define the `.body` part of your translation. Also, if you pass a block to the `mail()` method, it will skip this functionally completely.
200
+ You can use templates if you want. Just don't define the `.body` part of your
201
+ translation. Also, if you pass a block to the `mail()` method, it will skip this
202
+ functionally completely.
188
203
 
189
204
  ### Using markdown files
190
205
 
191
- If you want to use Markdown files instead of I18n translations, this gem is not for you. Consider using [maildown](https://github.com/schneems/maildown) or [markerb](https://github.com/plataformatec/markerb).
206
+ If you want to use Markdown files instead of I18n translations, this gem is not
207
+ for you. Consider using [maildown](https://github.com/schneems/maildown) or
208
+ [markerb](https://github.com/plataformatec/markerb).
192
209
 
193
210
  ## Development
194
211
 
195
- After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
212
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run
213
+ `rake test` to run the tests. You can also run `bin/console` for an interactive
214
+ prompt that will allow you to experiment.
196
215
 
197
- To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
216
+ To install this gem onto your local machine, run `bundle exec rake install`. To
217
+ release a new version, update the version number in `version.rb`, and then run
218
+ `bundle exec rake release`, which will create a git tag for the version, push
219
+ git commits and tags, and push the `.gem` file to
220
+ [rubygems.org](https://rubygems.org).
198
221
 
199
222
  ## Contributing
200
223
 
201
- Bug reports and pull requests are welcome on GitHub at https://github.com/fnando/actionmailer-markdown. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](contributor-covenant.org) code of conduct.
202
-
224
+ Bug reports and pull requests are welcome on GitHub at
225
+ https://github.com/fnando/actionmailer-markdown. This project is intended to be
226
+ a safe, welcoming space for collaboration, and contributors are expected to
227
+ adhere to the [Contributor Covenant](contributor-covenant.org) code of conduct.
203
228
 
204
229
  ## License
205
230
 
206
- The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
231
+ The gem is available as open source under the terms of the
232
+ [MIT License](http://opensource.org/licenses/MIT).
data/Rakefile CHANGED
@@ -17,4 +17,4 @@ Rake::TestTask.new(:test) do |t|
17
17
  t.warning = false
18
18
  end
19
19
 
20
- task :default => [:test, :rubocop]
20
+ task default: %i[test rubocop]
@@ -11,6 +11,7 @@ Gem::Specification.new do |spec|
11
11
  spec.description = spec.summary
12
12
  spec.homepage = "https://github.com/fnando/actionmailer-markdown"
13
13
  spec.license = "MIT"
14
+ spec.required_ruby_version = Gem::Requirement.new(">= 2.7.0")
14
15
 
15
16
  spec.files = `git ls-files -z`.split("\x0").reject {|f| f.match(%r{^(test|spec|features)/}) }
16
17
  spec.executables = spec.files.grep(%r{^exe/}) {|f| File.basename(f) }
@@ -27,6 +28,10 @@ Gem::Specification.new do |spec|
27
28
  spec.add_development_dependency "rails"
28
29
  spec.add_development_dependency "rake"
29
30
  spec.add_development_dependency "rubocop"
31
+ spec.add_development_dependency "rubocop-fnando"
30
32
  spec.add_development_dependency "simplecov"
31
33
  spec.add_development_dependency "simplecov-console"
34
+ spec.metadata = {
35
+ "rubygems_mfa_required" => "true"
36
+ }
32
37
  end
@@ -7,19 +7,18 @@ ActionMailer::Base.class_eval do
7
7
  options = variables_set_by_user
8
8
  subject = get_translation_for("subject", options)
9
9
  headers[:subject] ||= subject
10
- headers[:locals] = {a: 1}
11
- mail_method.bind(self).call(headers, &block)
10
+ mail_method.bind_call(self, headers, &block)
12
11
  end
13
12
 
14
13
  def get_translation_for(key, options)
15
- I18n.t(key, options.merge(scope: [mailer_scope, action_name], raise: true))
14
+ I18n.t(key, **options.merge(scope: [mailer_scope, action_name], raise: true))
16
15
  rescue I18n::MissingTranslationData
17
16
  nil
18
17
  end
19
18
 
20
19
  def variables_set_by_user
21
20
  instance_variables.each_with_object({}) do |name, buffer|
22
- next if name =~ /^@_/
21
+ next if /^@_/.match?(name)
23
22
 
24
23
  name = name.to_s[/^@(.*?)$/, 1]
25
24
  buffer[name.to_sym] = instance_variable_get("@#{name}")
@@ -8,7 +8,13 @@ module ActionMailer
8
8
  html: :md
9
9
  }.freeze
10
10
 
11
- def find_templates(name, prefix, _partial, details, _outside_app_allowed = false)
11
+ def find_templates(
12
+ name,
13
+ prefix,
14
+ _partial,
15
+ details,
16
+ _outside_app_allowed = false # rubocop:disable Style/OptionalBooleanParameter
17
+ )
12
18
  contents = find_contents(name, prefix, details)
13
19
  return [] unless contents
14
20
 
@@ -2,6 +2,6 @@
2
2
 
3
3
  module ActionMailer
4
4
  module Markdown
5
- VERSION = "0.4.1"
5
+ VERSION = "0.4.3"
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: actionmailer-markdown
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.1
4
+ version: 0.4.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nando Vieira
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-10-19 00:00:00.000000000 Z
11
+ date: 2023-01-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: actionmailer
@@ -150,6 +150,20 @@ dependencies:
150
150
  - - ">="
151
151
  - !ruby/object:Gem::Version
152
152
  version: '0'
153
+ - !ruby/object:Gem::Dependency
154
+ name: rubocop-fnando
155
+ requirement: !ruby/object:Gem::Requirement
156
+ requirements:
157
+ - - ">="
158
+ - !ruby/object:Gem::Version
159
+ version: '0'
160
+ type: :development
161
+ prerelease: false
162
+ version_requirements: !ruby/object:Gem::Requirement
163
+ requirements:
164
+ - - ">="
165
+ - !ruby/object:Gem::Version
166
+ version: '0'
153
167
  - !ruby/object:Gem::Dependency
154
168
  name: simplecov
155
169
  requirement: !ruby/object:Gem::Requirement
@@ -185,9 +199,9 @@ executables: []
185
199
  extensions: []
186
200
  extra_rdoc_files: []
187
201
  files:
202
+ - ".github/FUNDING.yml"
188
203
  - ".gitignore"
189
204
  - ".rubocop.yml"
190
- - ".travis.yml"
191
205
  - CODE_OF_CONDUCT.md
192
206
  - Gemfile
193
207
  - LICENSE.txt
@@ -207,8 +221,9 @@ files:
207
221
  homepage: https://github.com/fnando/actionmailer-markdown
208
222
  licenses:
209
223
  - MIT
210
- metadata: {}
211
- post_install_message:
224
+ metadata:
225
+ rubygems_mfa_required: 'true'
226
+ post_install_message:
212
227
  rdoc_options: []
213
228
  require_paths:
214
229
  - lib
@@ -216,15 +231,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
216
231
  requirements:
217
232
  - - ">="
218
233
  - !ruby/object:Gem::Version
219
- version: '0'
234
+ version: 2.7.0
220
235
  required_rubygems_version: !ruby/object:Gem::Requirement
221
236
  requirements:
222
237
  - - ">="
223
238
  - !ruby/object:Gem::Version
224
239
  version: '0'
225
240
  requirements: []
226
- rubygems_version: 3.0.3
227
- signing_key:
241
+ rubygems_version: 3.4.1
242
+ signing_key:
228
243
  specification_version: 4
229
244
  summary: A different take on using ActionMailer, Markdown and I18n.
230
245
  test_files: []
data/.travis.yml DELETED
@@ -1,19 +0,0 @@
1
- language: ruby
2
- cache: bundler
3
- sudo: false
4
- rvm:
5
- - 2.6.1
6
- - 2.5.3
7
- - 2.4.1
8
- script: bundle exec rake
9
- before_script:
10
- - curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
11
- - chmod +x ./cc-test-reporter
12
- - "./cc-test-reporter before-build"
13
- after_script:
14
- - "./cc-test-reporter after-build --exit-code $TRAVIS_TEST_RESULT"
15
- notifications:
16
- email: false
17
- env:
18
- global:
19
- secure: pSJLckgoZMZ67Le7TgjbX1ptaeRtPW+IhORZvxoiAR1nVmLCFHOq1ZHSJiw3J0t1A2GMdsTbXH/JDBcrbUzuKgJ3+XIyoAuUa1Hz1UjDkXh4RjwZrG/71hU3x0fVU1JXWDjFkGlqYJqwBYXkX1RK8K30NMnRGi7cr9wOLi0OI7fQ4ImrjIrh7m2hx1mZ97jeZt2HewomPO5OVK4hEDCxKFEzcThE8qOjr1eJRM9yYkwUGvO4Lw7louT95RKbJgjmndKEzbgJ4ggt2wGMvMarOqkM3QNCenp7JaaeaeQNt/szGNYH7bwjDEBNi8bSIIx+jFFpaCoIr/lp12XLDYPgw9dzSeQKLWwXHRDl6GmLNYldXaFfF4OnCaOq68L+0PNz0vD808W3SoTosE7jb5cS3ufRJUMujLRI1Kk2EuG2V0wFpmtCXtBV/LVkhUSqotvjI+ymO1zqyGcPbxVGO6WpIxMhiFC7+ZGsdOm0aliAMd6dAZ/6UPWGTSdMR6MECaCDtqBFv8JCnybWr5xxG3gnR9vqanA3sgrGjWxEIJrtF59vcPgrI6SUM7d4a7FBWHMU0AZSRvVX2umiTZVy/DOJEL/j0COunbcogCbTuAN1/gSNWTUTmF6kIV4BYUYEYx4HnpegIKcYKHKv74nbV4bhaSNuj+M/xOVPb2+Ms5kuG8E=