├── lib ├── mrml-rails.rb └── mrml │ ├── rails │ ├── version.rb │ ├── railtie.rb │ └── handler.rb │ └── rails.rb ├── .tool-versions ├── .rspec ├── spec ├── support │ ├── templates │ │ ├── mrml_test_mailer │ │ │ ├── _user_header.mjml │ │ │ ├── partial_email.mjml │ │ │ └── normal_email.mjml │ │ ├── mrml_layout_test_mailer │ │ │ ├── _user_header.mjml │ │ │ ├── partial_email.mjml │ │ │ └── normal_email.mjml │ │ └── layouts │ │ │ └── mailer.mjml │ └── mailers.rb ├── spec_helper.rb ├── rails_helper.rb └── mrml │ └── rails_spec.rb ├── Rakefile ├── bin ├── setup └── console ├── Gemfile ├── .github ├── dependabot.yml ├── workflows │ ├── release-drafter.yml │ ├── rubocop.yml │ └── ruby.yml └── release-drafter.yml ├── .gitignore ├── LICENSE ├── mrml-rails.gemspec ├── README.md ├── CODE_OF_CONDUCT.md └── .rubocop.yml /lib/mrml-rails.rb: -------------------------------------------------------------------------------- 1 | require 'mrml/rails' 2 | -------------------------------------------------------------------------------- /.tool-versions: -------------------------------------------------------------------------------- 1 | ruby 3.1.2 2 | rust 1.65.0 3 | -------------------------------------------------------------------------------- /.rspec: -------------------------------------------------------------------------------- 1 | --format documentation 2 | --color 3 | --require spec_helper 4 | -------------------------------------------------------------------------------- /lib/mrml/rails/version.rb: -------------------------------------------------------------------------------- 1 | module Mrml 2 | module Rails 3 | VERSION = "0.5.0" 4 | end 5 | end 6 | -------------------------------------------------------------------------------- /spec/support/templates/mrml_test_mailer/_user_header.mjml: -------------------------------------------------------------------------------- 1 | 2 | Welcome, <%= @username %>! 3 | 4 | -------------------------------------------------------------------------------- /Rakefile: -------------------------------------------------------------------------------- 1 | require "bundler/gem_tasks" 2 | require "rspec/core/rake_task" 3 | 4 | RSpec::Core::RakeTask.new(:spec) 5 | 6 | task :default => :spec 7 | -------------------------------------------------------------------------------- /spec/support/templates/mrml_layout_test_mailer/_user_header.mjml: -------------------------------------------------------------------------------- 1 | 2 | Welcome, <%= @username %>! 3 | 4 | -------------------------------------------------------------------------------- /bin/setup: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | set -euo pipefail 3 | IFS=$'\n\t' 4 | set -vx 5 | 6 | bundle install 7 | 8 | # Do any other automated setup that you need to do here 9 | -------------------------------------------------------------------------------- /Gemfile: -------------------------------------------------------------------------------- 1 | source "https://rubygems.org" 2 | 3 | # Specify your gem's dependencies in mrml-rails.gemspec 4 | gemspec 5 | 6 | gem "rake", "~> 13.0" 7 | gem "rspec", "~> 3.11" 8 | -------------------------------------------------------------------------------- /lib/mrml/rails.rb: -------------------------------------------------------------------------------- 1 | require "mrml/rails/handler" 2 | require "mrml/rails/railtie" 3 | require "mrml/rails/version" 4 | 5 | module Mrml 6 | module Rails 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | updates: 3 | - package-ecosystem: bundler 4 | directory: "/" 5 | schedule: 6 | interval: daily 7 | time: "04:00" 8 | open-pull-requests-limit: 10 9 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /.bundle/ 2 | /.yardoc 3 | /_yardoc/ 4 | /coverage/ 5 | /doc/ 6 | /pkg/ 7 | /spec/reports/ 8 | /tmp/ 9 | 10 | # rspec failure tracking 11 | .rspec_status 12 | *.gem 13 | Gemfile.lock 14 | -------------------------------------------------------------------------------- /spec/support/templates/mrml_layout_test_mailer/partial_email.mjml: -------------------------------------------------------------------------------- 1 | 2 | <%= render 'user_header' %> 3 | 4 | 5 | 6 |

We inform you about something

7 |

Please visit this link

8 |
9 |
10 | -------------------------------------------------------------------------------- /.github/workflows/release-drafter.yml: -------------------------------------------------------------------------------- 1 | name: Release Drafter 2 | 3 | on: 4 | push: 5 | branches: 6 | - master 7 | 8 | jobs: 9 | update_release_draft: 10 | runs-on: ubuntu-latest 11 | steps: 12 | - uses: release-drafter/release-drafter@v5 13 | id: release_drafter 14 | env: 15 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 16 | -------------------------------------------------------------------------------- /spec/support/templates/mrml_layout_test_mailer/normal_email.mjml: -------------------------------------------------------------------------------- 1 | 2 | 3 |

Welcome, <%= @username %>!

4 |
5 |
6 | 7 | 8 |

We inform you about something

9 |

Please visit this link

10 |
11 |
12 | -------------------------------------------------------------------------------- /lib/mrml/rails/railtie.rb: -------------------------------------------------------------------------------- 1 | require 'rails' 2 | 3 | module Mrml 4 | module Rails 5 | class Railtie < ::Rails::Railtie 6 | initializer 'mrml-rails.register_template_handler' do 7 | ActionView::Template.register_template_handler :mjml, Mrml::Rails::Handler.new 8 | Mime::Type.register_alias 'text/html', :mjml 9 | end 10 | end 11 | end 12 | end 13 | -------------------------------------------------------------------------------- /bin/console: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | 3 | require "bundler/setup" 4 | require "mrml/rails" 5 | 6 | # You can add fixtures and/or initialization code here to make experimenting 7 | # with your gem easier. You can also use a different console, if you like. 8 | 9 | # (If you use this, don't forget to add pry to your Gemfile!) 10 | # require "pry" 11 | # Pry.start 12 | 13 | require "irb" 14 | IRB.start(__FILE__) 15 | -------------------------------------------------------------------------------- /spec/support/templates/mrml_test_mailer/partial_email.mjml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | <%= render 'user_header' %> 5 | 6 | 7 | 8 |

We inform you about something

9 |

Please visit this link

10 |
11 |
12 |
13 |
14 | -------------------------------------------------------------------------------- /.github/workflows/rubocop.yml: -------------------------------------------------------------------------------- 1 | --- 2 | name: runner 3 | on: [pull_request] 4 | jobs: 5 | rubocop: 6 | name: rubocop 7 | runs-on: ubuntu-latest 8 | steps: 9 | - name: Check out code 10 | uses: actions/checkout@v2 11 | - name: Set up Ruby 12 | uses: ruby/setup-ruby@v1 13 | - name: rubocop 14 | uses: reviewdog/action-rubocop@v1 15 | with: 16 | github_token: ${{ secrets.github_token }} 17 | reporter: github-pr-review 18 | -------------------------------------------------------------------------------- /spec/support/templates/mrml_test_mailer/normal_email.mjml: -------------------------------------------------------------------------------- 1 | <% 2 | text = 'something' 3 | %> 4 | 5 | 6 | 7 | 8 | 9 |

Welcome, <%= @username %>!

10 |
11 |
12 | 13 | 14 |

We inform you about <%= text %>

15 |

Please visit this link

16 |
17 |
18 |
19 |
20 | -------------------------------------------------------------------------------- /.github/release-drafter.yml: -------------------------------------------------------------------------------- 1 | name-template: 'v$NEXT_PATCH_VERSION 🌈' 2 | tag-template: 'v$NEXT_PATCH_VERSION' 3 | categories: 4 | - title: '🚀 Features' 5 | labels: 6 | - 'feature' 7 | - 'enhancement' 8 | - title: '🐛 Bug Fixes' 9 | labels: 10 | - 'fix' 11 | - 'bugfix' 12 | - 'bug' 13 | - title: '🧰 Maintenance' 14 | labels: 15 | - 'dependencies' 16 | - 'documentation' 17 | change-template: '- $TITLE @$AUTHOR (#$NUMBER)' 18 | template: | 19 | ## Changes 20 | $CHANGES 21 | -------------------------------------------------------------------------------- /spec/spec_helper.rb: -------------------------------------------------------------------------------- 1 | require "bundler/setup" 2 | require "mrml/rails" 3 | 4 | Dir[File.join('spec', 'support', '**', '*.rb')].sort.each { |f| require_relative "../#{f}" } 5 | 6 | RSpec.configure do |config| 7 | # Enable flags like --only-failures and --next-failure 8 | config.example_status_persistence_file_path = ".rspec_status" 9 | 10 | # Disable RSpec exposing methods globally on `Module` and `main` 11 | config.disable_monkey_patching! 12 | 13 | config.expect_with :rspec do |c| 14 | c.syntax = :expect 15 | end 16 | end 17 | -------------------------------------------------------------------------------- /spec/support/templates/layouts/mailer.mjml: -------------------------------------------------------------------------------- 1 | <% 2 | @font_family = 'Helvetica Neue' 3 | %> 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | ul { 19 | list-style: none; 20 | margin: 0; 21 | padding: 0; 22 | } 23 | 24 | @media (max-width:640px) { 25 | .hidden { 26 | display: none !important; 27 | } 28 | } 29 | 30 | 31 | 32 | 33 | <%= yield %> 34 | 35 | 36 | -------------------------------------------------------------------------------- /lib/mrml/rails/handler.rb: -------------------------------------------------------------------------------- 1 | require 'action_view' 2 | require 'action_view/template' 3 | require 'rails/version' 4 | require 'mrml' 5 | 6 | module Mrml 7 | module Rails 8 | class Handler 9 | def template_handler 10 | @template_handler ||= ActionView::Template.registered_template_handler(:erb) 11 | end 12 | 13 | # Optional second source parameter to make it work with Rails >= 6: 14 | # Beginning with Rails 6 template handlers get the source of the template as the second 15 | # parameter. 16 | def call(template, source = nil) 17 | compiled_source = if ::Rails::VERSION::MAJOR >= 6 18 | template_handler.call(template, source) 19 | else 20 | template_handler.call(template) 21 | end 22 | 23 | if compiled_source =~ //i 24 | # "MRML.to_html(begin;#{compiled_source};end).html_safe" 25 | "MRML::Template.new(begin;#{compiled_source};end).to_html" 26 | else 27 | compiled_source 28 | end 29 | end 30 | end 31 | end 32 | end 33 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2021-2022 Joakim Nylén, Odd Camp AB 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. 22 | -------------------------------------------------------------------------------- /mrml-rails.gemspec: -------------------------------------------------------------------------------- 1 | require_relative 'lib/mrml/rails/version' 2 | 3 | Gem::Specification.new do |spec| 4 | spec.name = 'mrml-rails' 5 | spec.version = Mrml::Rails::VERSION 6 | spec.authors = ['Joakim Nylén'] 7 | spec.email = ['hello@oddcamp.com'] 8 | 9 | spec.summary = 'Rails Template Engine for MJML (Rust-variant called MRML)' 10 | spec.description = spec.summary 11 | spec.homepage = 'https://github.com/oddcamp/mrml-rails' 12 | spec.license = 'MIT' 13 | 14 | spec.files = Dir['README.md', 'lib/**/*'] 15 | spec.require_paths = ['lib'] 16 | 17 | spec.required_ruby_version = Gem::Requirement.new('>= 2.3.0') 18 | 19 | spec.metadata['homepage_uri'] = spec.homepage 20 | spec.metadata['source_code_uri'] = 'https://github.com/oddcamp/mrml-rails' 21 | spec.metadata['changelog_uri'] = 'https://github.com/oddcamp/mrml-rails/releases' 22 | 23 | spec.add_runtime_dependency 'actionmailer', '>= 3.1' 24 | spec.add_runtime_dependency 'mrml', '~> 1.0' 25 | spec.add_runtime_dependency 'railties', '>= 3.1' 26 | spec.add_development_dependency 'rspec', '~> 3.10' 27 | spec.add_development_dependency 'rspec-rails', '>= 4.0.2', '~> 5.0' 28 | end 29 | -------------------------------------------------------------------------------- /spec/support/mailers.rb: -------------------------------------------------------------------------------- 1 | require 'action_mailer' 2 | require 'action_view' 3 | 4 | ActionMailer::Base.delivery_method = :test 5 | ActionMailer::Base.prepend_view_path File.join(File.dirname(__FILE__), "templates") 6 | ActionView::Template.register_template_handler :mjml, Mrml::Rails::Handler.new 7 | Mime::Type.register_alias "text/html", :mjml 8 | 9 | class MrmlTestMailer < ActionMailer::Base 10 | layout false 11 | 12 | default from: 'example@mailer.com' 13 | 14 | def normal_email(username) 15 | @username = username 16 | 17 | mail to: 'user@example.org', subject: 'Welcome!' do |format| 18 | format.mjml { render 'normal_email' } 19 | end 20 | end 21 | 22 | def partial_email(username) 23 | @username = username 24 | 25 | mail to: 'user@example.org', subject: 'Welcome!' do |format| 26 | format.mjml { render 'partial_email' } 27 | end 28 | end 29 | end 30 | 31 | class MrmlLayoutTestMailer < ActionMailer::Base 32 | layout 'mailer' 33 | 34 | default from: 'example@mailer.com' 35 | 36 | def normal_email(username) 37 | @username = username 38 | 39 | mail to: 'user@example.org', subject: 'Welcome!' do |format| 40 | format.mjml { render 'normal_email' } 41 | end 42 | end 43 | 44 | def partial_email(username) 45 | @username = username 46 | 47 | mail to: 'user@example.org', subject: 'Welcome!' do |format| 48 | format.mjml { render 'partial_email' } 49 | end 50 | end 51 | end 52 | -------------------------------------------------------------------------------- /.github/workflows/ruby.yml: -------------------------------------------------------------------------------- 1 | --- 2 | name: ci 3 | on: 4 | push: 5 | branches: [master] 6 | pull_request: 7 | branches: [master] 8 | 9 | jobs: 10 | build: 11 | name: ruby 12 | strategy: 13 | matrix: 14 | os: [ubuntu-latest, macos-latest] 15 | ruby: ["2.7", "3.0", "3.1"] 16 | rust: ["1.51.0", "1.54.0", "1.60.0", "1.62.1", "1.65.0"] 17 | runs-on: ${{ matrix.os }} 18 | 19 | steps: 20 | - uses: actions/checkout@v2 21 | with: 22 | persist-credentials: false 23 | - name: Set up Ruby 24 | uses: ruby/setup-ruby@v1 25 | with: 26 | ruby-version: ${{ matrix.ruby }} 27 | - name: Set up Rust 28 | uses: hecrj/setup-rust-action@v1 29 | with: 30 | rust-version: ${{ matrix.rust }} 31 | - name: Cache gems 32 | uses: actions/cache@v1 33 | with: 34 | path: vendor/bundle 35 | key: ${{ runner.os }}-gems-${{ hashFiles('.tool-versions') }}-${{ hashFiles('**/Gemfile.lock') }} 36 | restore-keys: | 37 | ${{ runner.os }}-gems-${{ hashFiles('.tool-versions') }}-${{ hashFiles('**/Gemfile.lock') }} 38 | - name: Run yarn 39 | run: yarn 40 | - name: Install dependencies 41 | run: | 42 | gem install bundler 43 | bundle config path vendor/bundle 44 | bundle install --jobs 4 --retry 3 45 | env: 46 | RAILS_ENV: test 47 | - name: Run tests 48 | run: bundle exec rake spec 49 | env: 50 | RAILS_ENV: test 51 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Mrml::Rails 2 | 3 | `mrml-rails` is a ActionMailer templating engine that uses the Rust-based MRML compiler in order to compile MJML files into pure HTML. 4 | 5 | **Minimum Rust version supported is `1.51.0`** 6 | 7 | ## Installation 8 | 9 | Add this line to your application's Gemfile: 10 | 11 | ```ruby 12 | gem 'mrml-rails' 13 | ``` 14 | 15 | And then execute: 16 | 17 | $ bundle install 18 | 19 | Or install it yourself as: 20 | 21 | $ gem install mrml-rails 22 | 23 | ## Usage 24 | 25 | All you need to do is to have the file extension `mjml` on the specific views. 26 | 27 | I.e.: `sign_up.mjml`, `notification.mjml` 28 | 29 | ## Development 30 | 31 | 1. Setup the tools with: `asdf install` (make sure you have the Ruby and Rust asdf plugins installed) 32 | 2. Run `bundle install` 33 | 3. For rspec run: `bundle exec rspec` 34 | 35 | ## Heroku Rust Setup 36 | 37 | 1. Add the rust buildpack to the app (and app.json): `https://buildpack-registry.s3.amazonaws.com/buildpacks/emk/rust.tgz` 38 | 2. Add a RustConfig with: 39 | 40 | ``` 41 | VERSION=1.65.0 42 | RUST_SKIP_BUILD=1 43 | ``` 44 | 45 | 3. Deploy 46 | 47 | ## Contributing 48 | 49 | Bug reports and pull requests are welcome on GitHub at https://github.com/oddcamp/mrml-rails. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/oddcamp/mrml-rails/blob/master/CODE_OF_CONDUCT.md). 50 | 51 | ## License 52 | 53 | The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT). 54 | 55 | ## Code of Conduct 56 | 57 | Everyone interacting in the Mrml::Rails project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/oddcamp/mrml-rails/blob/master/CODE_OF_CONDUCT.md). 58 | -------------------------------------------------------------------------------- /spec/rails_helper.rb: -------------------------------------------------------------------------------- 1 | # This file is copied to spec/ when you run 'rails generate rspec:install' 2 | require 'spec_helper' 3 | ENV['RAILS_ENV'] ||= 'test' 4 | # Prevent database truncation if the environment is production 5 | abort("The Rails environment is running in production mode!") if Rails.env.production? 6 | require 'rspec/rails' 7 | # Add additional requires below this line. Rails is not loaded until this point! 8 | 9 | # Requires supporting ruby files with custom matchers and macros, etc, in 10 | # spec/support/ and its subdirectories. Files matching `spec/**/*_spec.rb` are 11 | # run as spec files by default. This means that files in spec/support that end 12 | # in _spec.rb will both be required and run as specs, causing the specs to be 13 | # run twice. It is recommended that you do not name files matching this glob to 14 | # end with _spec.rb. You can configure this pattern with the --pattern 15 | # option on the command line or in ~/.rspec, .rspec or `.rspec-local`. 16 | # 17 | # The following line is provided for convenience purposes. It has the downside 18 | # of increasing the boot-up time by auto-requiring all files in the support 19 | # directory. Alternatively, in the individual `*_spec.rb` files, manually 20 | # require only the support files necessary. 21 | # 22 | Dir[Rails.root.join('spec', 'support', '**', '*.rb')].sort.each { |f| require f } 23 | 24 | RSpec.configure do |config| 25 | # RSpec Rails can automatically mix in different behaviours to your tests 26 | # based on their file location, for example enabling you to call `get` and 27 | # `post` in specs under `spec/controllers`. 28 | # 29 | # You can disable this behaviour by removing the line below, and instead 30 | # explicitly tag your specs with their type, e.g.: 31 | # 32 | # RSpec.describe UsersController, type: :controller do 33 | # # ... 34 | # end 35 | # 36 | # The different available types are documented in the features, such as in 37 | # https://relishapp.com/rspec/rspec-rails/docs 38 | config.infer_spec_type_from_file_location! 39 | 40 | # Filter lines from Rails gems in backtraces. 41 | config.filter_rails_from_backtrace! 42 | # arbitrary gems may also be filtered via: 43 | # config.filter_gems_from_backtrace("gem name") 44 | end 45 | -------------------------------------------------------------------------------- /CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | # Contributor Covenant Code of Conduct 2 | 3 | ## Our Pledge 4 | 5 | In the interest of fostering an open and welcoming environment, we as 6 | contributors and maintainers pledge to making participation in our project and 7 | our community a harassment-free experience for everyone, regardless of age, body 8 | size, disability, ethnicity, gender identity and expression, level of experience, 9 | nationality, personal appearance, race, religion, or sexual identity and 10 | orientation. 11 | 12 | ## Our Standards 13 | 14 | Examples of behavior that contributes to creating a positive environment 15 | include: 16 | 17 | * Using welcoming and inclusive language 18 | * Being respectful of differing viewpoints and experiences 19 | * Gracefully accepting constructive criticism 20 | * Focusing on what is best for the community 21 | * Showing empathy towards other community members 22 | 23 | Examples of unacceptable behavior by participants include: 24 | 25 | * The use of sexualized language or imagery and unwelcome sexual attention or 26 | advances 27 | * Trolling, insulting/derogatory comments, and personal or political attacks 28 | * Public or private harassment 29 | * Publishing others' private information, such as a physical or electronic 30 | address, without explicit permission 31 | * Other conduct which could reasonably be considered inappropriate in a 32 | professional setting 33 | 34 | ## Our Responsibilities 35 | 36 | Project maintainers are responsible for clarifying the standards of acceptable 37 | behavior and are expected to take appropriate and fair corrective action in 38 | response to any instances of unacceptable behavior. 39 | 40 | Project maintainers have the right and responsibility to remove, edit, or 41 | reject comments, commits, code, wiki edits, issues, and other contributions 42 | that are not aligned to this Code of Conduct, or to ban temporarily or 43 | permanently any contributor for other behaviors that they deem inappropriate, 44 | threatening, offensive, or harmful. 45 | 46 | ## Scope 47 | 48 | This Code of Conduct applies both within project spaces and in public spaces 49 | when an individual is representing the project or its community. Examples of 50 | representing a project or community include using an official project e-mail 51 | address, posting via an official social media account, or acting as an appointed 52 | representative at an online or offline event. Representation of a project may be 53 | further defined and clarified by project maintainers. 54 | 55 | ## Enforcement 56 | 57 | Instances of abusive, harassing, or otherwise unacceptable behavior may be 58 | reported by contacting the project team at hello@oddcamp.com. All 59 | complaints will be reviewed and investigated and will result in a response that 60 | is deemed necessary and appropriate to the circumstances. The project team is 61 | obligated to maintain confidentiality with regard to the reporter of an incident. 62 | Further details of specific enforcement policies may be posted separately. 63 | 64 | Project maintainers who do not follow or enforce the Code of Conduct in good 65 | faith may face temporary or permanent repercussions as determined by other 66 | members of the project's leadership. 67 | 68 | ## Attribution 69 | 70 | This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, 71 | available at [https://contributor-covenant.org/version/1/4][version] 72 | 73 | [homepage]: https://contributor-covenant.org 74 | [version]: https://contributor-covenant.org/version/1/4/ 75 | -------------------------------------------------------------------------------- /spec/mrml/rails_spec.rb: -------------------------------------------------------------------------------- 1 | require "mrml/rails" 2 | require "spec_helper" 3 | 4 | RSpec.describe Mrml::Rails, type: :mailer do 5 | describe 'without layout' do 6 | describe '#normal_email' do 7 | let!(:mail) { MrmlTestMailer.normal_email('Random User').deliver_now } 8 | 9 | it "renders the headers" do 10 | expect(ActionMailer::Base.deliveries).to_not be_empty 11 | 12 | # Test the body of the sent email contains what we expect it to 13 | expect(mail.from).to eq(["example@mailer.com"]) 14 | expect(mail.to).to eq(["user@example.org"]) 15 | 16 | expect(mail.subject).to eq("Welcome!") 17 | end 18 | 19 | it "renders the body" do 20 | expect(mail.body.raw_source).not_to match(%r{}) 21 | expect(mail.body.raw_source).to match(/We inform you about something}) 24 | expect(mail.body.raw_source).to match(%r{this link}) 25 | expect(mail.body.raw_source).to match(/We inform you about something/) 26 | end 27 | end 28 | 29 | describe '#partial_email' do 30 | let!(:mail) { MrmlTestMailer.partial_email('Random User').deliver_now } 31 | 32 | it "renders the headers" do 33 | expect(ActionMailer::Base.deliveries).to_not be_empty 34 | 35 | # Test the body of the sent email contains what we expect it to 36 | expect(mail.from).to eq(["example@mailer.com"]) 37 | expect(mail.to).to eq(["user@example.org"]) 38 | 39 | expect(mail.subject).to eq("Welcome!") 40 | end 41 | 42 | it "renders the body" do 43 | expect(mail.body.raw_source).not_to match(%r{}) 44 | expect(mail.body.raw_source).to match(/We inform you about something}) 47 | expect(mail.body.raw_source).to match(%r{this link}) 48 | expect(mail.body.raw_source).to match(/We inform you about something/) 49 | end 50 | end 51 | end 52 | describe 'with layout' do 53 | describe '#normal_email' do 54 | let!(:mail) { MrmlLayoutTestMailer.normal_email('Random User').deliver_now } 55 | 56 | it "renders the headers" do 57 | expect(ActionMailer::Base.deliveries).to_not be_empty 58 | 59 | # Test the body of the sent email contains what we expect it to 60 | expect(mail.from).to eq(["example@mailer.com"]) 61 | expect(mail.to).to eq(["user@example.org"]) 62 | 63 | expect(mail.subject).to eq("Welcome!") 64 | end 65 | 66 | it "renders the body" do 67 | expect(mail.body.raw_source).not_to match(%r{}) 68 | expect(mail.body.raw_source).to match(/We inform you about something}) 71 | expect(mail.body.raw_source).to match(%r{this link}) 72 | expect(mail.body.raw_source).to match(/We inform you about something/) 73 | end 74 | end 75 | 76 | describe '#partial_email' do 77 | let!(:mail) { MrmlLayoutTestMailer.partial_email('Random User').deliver_now } 78 | 79 | it "renders the headers" do 80 | expect(ActionMailer::Base.deliveries).to_not be_empty 81 | 82 | # Test the body of the sent email contains what we expect it to 83 | expect(mail.from).to eq(["example@mailer.com"]) 84 | expect(mail.to).to eq(["user@example.org"]) 85 | 86 | expect(mail.subject).to eq("Welcome!") 87 | end 88 | 89 | it "renders the body" do 90 | expect(mail.body.raw_source).not_to match(%r{}) 91 | expect(mail.body.raw_source).to match(/We inform you about something}) 94 | expect(mail.body.raw_source).to match(%r{this link}) 95 | expect(mail.body.raw_source).to match(/We inform you about something/) 96 | end 97 | end 98 | end 99 | end 100 | -------------------------------------------------------------------------------- /.rubocop.yml: -------------------------------------------------------------------------------- 1 | AllCops: 2 | Exclude: 3 | - 'db/*' 4 | - 'tmp/**/*' 5 | - 'node_modules/**/*' 6 | - 'vendor/**/*' 7 | 8 | require: 9 | - rubocop-rails 10 | - rubocop-performance 11 | 12 | Naming/AccessorMethodName: 13 | Description: Check the naming of accessor methods for get_/set_. 14 | Enabled: false 15 | 16 | Style/Alias: 17 | Description: 'Use alias_method instead of alias.' 18 | StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#alias-method' 19 | Enabled: false 20 | 21 | Style/ArrayJoin: 22 | Description: 'Use Array#join instead of Array#*.' 23 | StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#array-join' 24 | Enabled: false 25 | 26 | Style/AsciiComments: 27 | Description: 'Use only ascii symbols in comments.' 28 | StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#english-comments' 29 | Enabled: false 30 | 31 | Naming/AsciiIdentifiers: 32 | Description: 'Use only ascii symbols in identifiers.' 33 | StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#english-identifiers' 34 | Enabled: false 35 | 36 | Style/Attr: 37 | Description: 'Checks for uses of Module#attr.' 38 | StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#attr' 39 | Enabled: false 40 | 41 | Metrics/BlockNesting: 42 | Description: 'Avoid excessive block nesting' 43 | StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#three-is-the-number-thou-shalt-count' 44 | Enabled: false 45 | 46 | Style/CaseEquality: 47 | Description: 'Avoid explicit use of the case equality operator(===).' 48 | StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-case-equality' 49 | Enabled: false 50 | 51 | Style/CharacterLiteral: 52 | Description: 'Checks for uses of character literals.' 53 | StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-character-literals' 54 | Enabled: false 55 | 56 | Style/ClassAndModuleChildren: 57 | Description: 'Checks style of children classes and modules.' 58 | Enabled: true 59 | EnforcedStyle: nested 60 | 61 | Metrics/ClassLength: 62 | Description: 'Avoid classes longer than 100 lines of code.' 63 | Enabled: false 64 | 65 | Metrics/ModuleLength: 66 | Description: 'Avoid modules longer than 100 lines of code.' 67 | Enabled: false 68 | 69 | Style/ClassVars: 70 | Description: 'Avoid the use of class variables.' 71 | StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-class-vars' 72 | Enabled: false 73 | 74 | Style/CollectionMethods: 75 | Enabled: true 76 | PreferredMethods: 77 | find: detect 78 | inject: reduce 79 | collect: map 80 | find_all: select 81 | 82 | Style/ColonMethodCall: 83 | Description: 'Do not use :: for method call.' 84 | StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#double-colons' 85 | Enabled: false 86 | 87 | Style/CommentAnnotation: 88 | Description: >- 89 | Checks formatting of special comments 90 | (TODO, FIXME, OPTIMIZE, HACK, REVIEW). 91 | StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#annotate-keywords' 92 | Enabled: false 93 | 94 | Metrics/AbcSize: 95 | Description: >- 96 | A calculated magnitude based on number of assignments, 97 | branches, and conditions. 98 | Enabled: false 99 | 100 | Metrics/BlockLength: 101 | CountComments: true # count full line comments? 102 | Max: 25 103 | ExcludedMethods: [] 104 | Exclude: 105 | - 'spec/**/*' 106 | 107 | Metrics/CyclomaticComplexity: 108 | Description: >- 109 | A complexity metric that is strongly correlated to the number 110 | of test cases needed to validate a method. 111 | Enabled: false 112 | 113 | Rails/Delegate: 114 | Description: 'Prefer delegate method for delegations.' 115 | Enabled: false 116 | 117 | Style/PreferredHashMethods: 118 | Description: 'Checks use of `has_key?` and `has_value?` Hash methods.' 119 | StyleGuide: '#hash-key' 120 | Enabled: false 121 | 122 | Style/Documentation: 123 | Description: 'Document classes and non-namespace modules.' 124 | Enabled: false 125 | 126 | Style/DoubleNegation: 127 | Description: 'Checks for uses of double negation (!!).' 128 | StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-bang-bang' 129 | Enabled: false 130 | 131 | Style/EachWithObject: 132 | Description: 'Prefer `each_with_object` over `inject` or `reduce`.' 133 | Enabled: false 134 | 135 | Style/EmptyLiteral: 136 | Description: 'Prefer literals to Array.new/Hash.new/String.new.' 137 | StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#literal-array-hash' 138 | Enabled: false 139 | 140 | # Checks whether the source file has a utf-8 encoding comment or not 141 | # AutoCorrectEncodingComment must match the regex 142 | # /#.*coding\s?[:=]\s?(?:UTF|utf)-8/ 143 | Style/Encoding: 144 | Enabled: false 145 | 146 | Style/EvenOdd: 147 | Description: 'Favor the use of Fixnum#even? && Fixnum#odd?' 148 | StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#predicate-methods' 149 | Enabled: false 150 | 151 | Naming/FileName: 152 | Description: 'Use snake_case for source file names.' 153 | StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#snake-case-files' 154 | Enabled: false 155 | 156 | Style/FrozenStringLiteralComment: 157 | Description: >- 158 | Add the frozen_string_literal comment to the top of files 159 | to help transition from Ruby 2.3.0 to Ruby 3.0. 160 | Enabled: false 161 | 162 | Lint/FlipFlop: 163 | Description: 'Checks for flip flops' 164 | StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-flip-flops' 165 | Enabled: false 166 | 167 | Style/FormatString: 168 | Description: 'Enforce the use of Kernel#sprintf, Kernel#format or String#%.' 169 | StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#sprintf' 170 | Enabled: false 171 | 172 | Style/GlobalVars: 173 | Description: 'Do not introduce global variables.' 174 | StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#instance-vars' 175 | Reference: 'http://www.zenspider.com/Languages/Ruby/QuickRef.html' 176 | Enabled: false 177 | 178 | Style/GuardClause: 179 | Description: 'Check for conditionals that can be replaced with guard clauses' 180 | StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-nested-conditionals' 181 | Enabled: false 182 | 183 | Style/IfUnlessModifier: 184 | Description: >- 185 | Favor modifier if/unless usage when you have a 186 | single-line body. 187 | StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#if-as-a-modifier' 188 | Enabled: false 189 | 190 | Style/IfWithSemicolon: 191 | Description: 'Do not use if x; .... Use the ternary operator instead.' 192 | StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-semicolon-ifs' 193 | Enabled: false 194 | 195 | Style/InlineComment: 196 | Description: 'Avoid inline comments.' 197 | Enabled: false 198 | 199 | Style/Lambda: 200 | Description: 'Use the new lambda literal syntax for single-line blocks.' 201 | StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#lambda-multi-line' 202 | Enabled: false 203 | 204 | Style/LambdaCall: 205 | Description: 'Use lambda.call(...) instead of lambda.(...).' 206 | StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#proc-call' 207 | Enabled: false 208 | 209 | Style/LineEndConcatenation: 210 | Description: >- 211 | Use \ instead of + or << to concatenate two string literals at 212 | line end. 213 | Enabled: false 214 | 215 | Metrics/MethodLength: 216 | Description: 'Avoid methods longer than 10 lines of code.' 217 | StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#short-methods' 218 | Enabled: false 219 | 220 | Style/ModuleFunction: 221 | Description: 'Checks for usage of `extend self` in modules.' 222 | StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#module-function' 223 | Enabled: false 224 | 225 | Style/MultilineBlockChain: 226 | Description: 'Avoid multi-line chains of blocks.' 227 | StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#single-line-blocks' 228 | Enabled: false 229 | 230 | Style/NegatedIf: 231 | Description: >- 232 | Favor unless over if for negative conditions 233 | (or control flow or). 234 | StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#unless-for-negatives' 235 | Enabled: false 236 | 237 | Style/NegatedWhile: 238 | Description: 'Favor until over while for negative conditions.' 239 | StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#until-for-negatives' 240 | Enabled: false 241 | 242 | Style/Next: 243 | Description: 'Use `next` to skip iteration instead of a condition at the end.' 244 | StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-nested-conditionals' 245 | Enabled: false 246 | 247 | Style/NilComparison: 248 | Description: 'Prefer x.nil? to x == nil.' 249 | StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#predicate-methods' 250 | Enabled: false 251 | 252 | Style/Not: 253 | Description: 'Use ! instead of not.' 254 | StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#bang-not-not' 255 | Enabled: false 256 | 257 | Style/NumericLiterals: 258 | Description: >- 259 | Add underscores to large numeric literals to improve their 260 | readability. 261 | StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#underscores-in-numerics' 262 | Enabled: false 263 | 264 | Style/OneLineConditional: 265 | Description: >- 266 | Favor the ternary operator(?:) over 267 | if/then/else/end constructs. 268 | StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#ternary-operator' 269 | Enabled: false 270 | 271 | Naming/BinaryOperatorParameterName: 272 | Description: 'When defining binary operators, name the argument other.' 273 | StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#other-arg' 274 | Enabled: false 275 | 276 | Metrics/ParameterLists: 277 | Description: 'Avoid parameter lists longer than three or four parameters.' 278 | StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#too-many-params' 279 | Enabled: false 280 | 281 | Style/PercentLiteralDelimiters: 282 | Description: 'Use `%`-literal delimiters consistently' 283 | StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#percent-literal-braces' 284 | Enabled: false 285 | 286 | Style/PerlBackrefs: 287 | Description: 'Avoid Perl-style regex back references.' 288 | StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-perl-regexp-last-matchers' 289 | Enabled: false 290 | 291 | Naming/PredicateName: 292 | Description: 'Check the names of predicate methods.' 293 | StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#bool-methods-qmark' 294 | ForbiddenPrefixes: 295 | - is_ 296 | Exclude: 297 | - spec/**/* 298 | 299 | Style/Proc: 300 | Description: 'Use proc instead of Proc.new.' 301 | StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#proc' 302 | Enabled: false 303 | 304 | Style/RaiseArgs: 305 | Description: 'Checks the arguments passed to raise/fail.' 306 | StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#exception-class-messages' 307 | Enabled: false 308 | 309 | Style/RegexpLiteral: 310 | Description: 'Use / or %r around regular expressions.' 311 | StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#percent-r' 312 | Enabled: false 313 | 314 | Style/Sample: 315 | Description: >- 316 | Use `sample` instead of `shuffle.first`, 317 | `shuffle.last`, and `shuffle[Fixnum]`. 318 | Reference: 'https://github.com/JuanitoFatas/fast-ruby#arrayshufflefirst-vs-arraysample-code' 319 | Enabled: false 320 | 321 | Style/SelfAssignment: 322 | Description: >- 323 | Checks for places where self-assignment shorthand should have 324 | been used. 325 | StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#self-assignment' 326 | Enabled: false 327 | 328 | Style/SingleLineBlockParams: 329 | Description: 'Enforces the names of some block params.' 330 | StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#reduce-blocks' 331 | Enabled: false 332 | 333 | Style/SingleLineMethods: 334 | Description: 'Avoid single-line methods.' 335 | StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-single-line-methods' 336 | Enabled: false 337 | 338 | Style/SignalException: 339 | Description: 'Checks for proper usage of fail and raise.' 340 | StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#fail-method' 341 | Enabled: false 342 | 343 | Style/SpecialGlobalVars: 344 | Description: 'Avoid Perl-style global variables.' 345 | StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-cryptic-perlisms' 346 | Enabled: false 347 | 348 | Style/StringLiterals: 349 | Description: 'Checks if uses of quotes match the configured preference.' 350 | StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#consistent-string-literals' 351 | EnforcedStyle: single_quotes 352 | Enabled: true 353 | 354 | Style/TrailingCommaInArguments: 355 | Description: 'Checks for trailing comma in argument lists.' 356 | StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-trailing-array-commas' 357 | EnforcedStyleForMultiline: no_comma 358 | SupportedStylesForMultiline: 359 | - comma 360 | - consistent_comma 361 | - no_comma 362 | Enabled: true 363 | 364 | Style/TrailingCommaInArrayLiteral: 365 | Description: 'Checks for trailing comma in array literals.' 366 | StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-trailing-array-commas' 367 | EnforcedStyleForMultiline: no_comma 368 | SupportedStylesForMultiline: 369 | - comma 370 | - consistent_comma 371 | - no_comma 372 | Enabled: true 373 | 374 | Style/TrailingCommaInHashLiteral: 375 | Description: 'Checks for trailing comma in hash literals.' 376 | StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-trailing-array-commas' 377 | EnforcedStyleForMultiline: no_comma 378 | SupportedStylesForMultiline: 379 | - comma 380 | - consistent_comma 381 | - no_comma 382 | Enabled: true 383 | 384 | Style/TrivialAccessors: 385 | Description: 'Prefer attr_* methods to trivial readers/writers.' 386 | StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#attr_family' 387 | Enabled: false 388 | 389 | Style/VariableInterpolation: 390 | Description: >- 391 | Don't interpolate global, instance and class variables 392 | directly in strings. 393 | StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#curlies-interpolate' 394 | Enabled: false 395 | 396 | Style/WhenThen: 397 | Description: 'Use when x then ... for one-line cases.' 398 | StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#one-line-cases' 399 | Enabled: false 400 | 401 | Style/WhileUntilModifier: 402 | Description: >- 403 | Favor modifier while/until usage when you have a 404 | single-line body. 405 | StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#while-as-a-modifier' 406 | Enabled: false 407 | 408 | Style/WordArray: 409 | Description: 'Use %w or %W for arrays of words.' 410 | StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#percent-w' 411 | Enabled: false 412 | 413 | # Layout 414 | 415 | Layout/ParameterAlignment: 416 | Description: 'Here we check if the parameters on a multi-line method call or definition are aligned.' 417 | StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-double-indent' 418 | Enabled: false 419 | 420 | Layout/ConditionPosition: 421 | Description: >- 422 | Checks for condition placed in a confusing position relative to 423 | the keyword. 424 | StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#same-line-condition' 425 | Enabled: false 426 | 427 | Layout/DotPosition: 428 | Description: 'Checks the position of the dot in multi-line method calls.' 429 | StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#consistent-multi-line-chains' 430 | EnforcedStyle: leading 431 | 432 | Layout/ExtraSpacing: 433 | Description: 'Do not use unnecessary spacing.' 434 | Enabled: true 435 | 436 | Layout/MultilineOperationIndentation: 437 | Description: >- 438 | Checks indentation of binary operations that span more than 439 | one line. 440 | Enabled: true 441 | EnforcedStyle: indented 442 | 443 | Layout/MultilineMethodCallIndentation: 444 | Description: >- 445 | Checks indentation of method calls with the dot operator 446 | that span more than one line. 447 | Enabled: true 448 | EnforcedStyle: indented 449 | 450 | Layout/InitialIndentation: 451 | Description: >- 452 | Checks the indentation of the first non-blank non-comment line in a file. 453 | Enabled: false 454 | 455 | Layout/LineLength: 456 | Description: 'Limit lines to 80 characters.' 457 | StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#80-character-limits' 458 | Max: 120 459 | 460 | # Lint 461 | 462 | Lint/AmbiguousOperator: 463 | Description: >- 464 | Checks for ambiguous operators in the first argument of a 465 | method invocation without parentheses. 466 | StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#parens-as-args' 467 | Enabled: false 468 | 469 | Lint/AmbiguousRegexpLiteral: 470 | Description: >- 471 | Checks for ambiguous regexp literals in the first argument of 472 | a method invocation without parenthesis. 473 | Enabled: false 474 | 475 | Lint/AssignmentInCondition: 476 | Description: "Don't use assignment in conditions." 477 | StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#safe-assignment-in-condition' 478 | Enabled: false 479 | 480 | Lint/CircularArgumentReference: 481 | Description: "Don't refer to the keyword argument in the default value." 482 | Enabled: false 483 | 484 | Lint/DeprecatedClassMethods: 485 | Description: 'Check for deprecated class method calls.' 486 | Enabled: false 487 | 488 | Lint/DuplicateHashKey: 489 | Description: 'Check for duplicate keys in hash literals.' 490 | Enabled: false 491 | 492 | Lint/EachWithObjectArgument: 493 | Description: 'Check for immutable argument given to each_with_object.' 494 | Enabled: false 495 | 496 | Lint/ElseLayout: 497 | Description: 'Check for odd code arrangement in an else block.' 498 | Enabled: false 499 | 500 | Lint/FormatParameterMismatch: 501 | Description: 'The number of parameters to format/sprint must match the fields.' 502 | Enabled: false 503 | 504 | Lint/SuppressedException: 505 | Description: "Don't suppress exception." 506 | StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#dont-hide-exceptions' 507 | Enabled: false 508 | 509 | Lint/LiteralAsCondition: 510 | Description: 'Checks of literals used in conditions.' 511 | Enabled: false 512 | 513 | Lint/LiteralInInterpolation: 514 | Description: 'Checks for literals used in interpolation.' 515 | Enabled: false 516 | 517 | Lint/Loop: 518 | Description: >- 519 | Use Kernel#loop with break rather than begin/end/until or 520 | begin/end/while for post-loop tests. 521 | StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#loop-with-break' 522 | Enabled: false 523 | 524 | Lint/NestedMethodDefinition: 525 | Description: 'Do not use nested method definitions.' 526 | StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-nested-methods' 527 | Enabled: false 528 | 529 | Lint/NonLocalExitFromIterator: 530 | Description: 'Do not use return in iterator to cause non-local exit.' 531 | Enabled: false 532 | 533 | Lint/ParenthesesAsGroupedExpression: 534 | Description: >- 535 | Checks for method calls with a space before the opening 536 | parenthesis. 537 | StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#parens-no-spaces' 538 | Enabled: false 539 | 540 | Lint/RequireParentheses: 541 | Description: >- 542 | Use parentheses in the method call to avoid confusion 543 | about precedence. 544 | Enabled: false 545 | 546 | Lint/UnderscorePrefixedVariableName: 547 | Description: 'Do not use prefix `_` for a variable that is used.' 548 | Enabled: false 549 | 550 | Lint/RedundantCopDisableDirective: 551 | Description: >- 552 | Checks for rubocop:disable comments that can be removed. 553 | Note: this cop is not disabled when disabling all cops. 554 | It must be explicitly disabled. 555 | Enabled: false 556 | 557 | Lint/Void: 558 | Description: 'Possible use of operator/literal/variable in void context.' 559 | Enabled: false 560 | 561 | # Performance 562 | 563 | Performance/CaseWhenSplat: 564 | Description: >- 565 | Place `when` conditions that use splat at the end 566 | of the list of `when` branches. 567 | Enabled: false 568 | 569 | Performance/Count: 570 | Description: >- 571 | Use `count` instead of `select...size`, `reject...size`, 572 | `select...count`, `reject...count`, `select...length`, 573 | and `reject...length`. 574 | Enabled: false 575 | 576 | Performance/Detect: 577 | Description: >- 578 | Use `detect` instead of `select.first`, `find_all.first`, 579 | `select.last`, and `find_all.last`. 580 | Reference: 'https://github.com/JuanitoFatas/fast-ruby#enumerabledetect-vs-enumerableselectfirst-code' 581 | Enabled: false 582 | 583 | Performance/FlatMap: 584 | Description: >- 585 | Use `Enumerable#flat_map` 586 | instead of `Enumerable#map...Array#flatten(1)` 587 | or `Enumberable#collect..Array#flatten(1)` 588 | Reference: 'https://github.com/JuanitoFatas/fast-ruby#enumerablemaparrayflatten-vs-enumerableflat_map-code' 589 | Enabled: false 590 | 591 | Performance/ReverseEach: 592 | Description: 'Use `reverse_each` instead of `reverse.each`.' 593 | Reference: 'https://github.com/JuanitoFatas/fast-ruby#enumerablereverseeach-vs-enumerablereverse_each-code' 594 | Enabled: false 595 | 596 | Performance/Size: 597 | Description: >- 598 | Use `size` instead of `count` for counting 599 | the number of elements in `Array` and `Hash`. 600 | Reference: 'https://github.com/JuanitoFatas/fast-ruby#arraycount-vs-arraysize-code' 601 | Enabled: false 602 | 603 | Performance/StringReplacement: 604 | Description: >- 605 | Use `tr` instead of `gsub` when you are replacing the same 606 | number of characters. Use `delete` instead of `gsub` when 607 | you are deleting characters. 608 | Reference: 'https://github.com/JuanitoFatas/fast-ruby#stringgsub-vs-stringtr-code' 609 | Enabled: false 610 | 611 | # Rails 612 | 613 | Rails/ActionFilter: 614 | Description: 'Enforces consistent use of action filter methods.' 615 | Enabled: false 616 | 617 | Rails/Date: 618 | Description: >- 619 | Checks the correct usage of date aware methods, 620 | such as Date.today, Date.current etc. 621 | Enabled: false 622 | 623 | Rails/FindBy: 624 | Description: 'Prefer find_by over where.first.' 625 | Enabled: false 626 | 627 | Rails/FindEach: 628 | Description: 'Prefer all.find_each over all.find.' 629 | Enabled: false 630 | 631 | Rails/HasAndBelongsToMany: 632 | Description: 'Prefer has_many :through to has_and_belongs_to_many.' 633 | Enabled: false 634 | 635 | Rails/Output: 636 | Description: 'Checks for calls to puts, print, etc.' 637 | Enabled: false 638 | 639 | Rails/ReadWriteAttribute: 640 | Description: >- 641 | Checks for read_attribute(:attr) and 642 | write_attribute(:attr, val). 643 | Enabled: false 644 | 645 | Rails/ScopeArgs: 646 | Description: 'Checks the arguments of ActiveRecord scopes.' 647 | Enabled: false 648 | 649 | Rails/TimeZone: 650 | Description: 'Checks the correct usage of time zone aware methods.' 651 | StyleGuide: 'https://github.com/bbatsov/rails-style-guide#time' 652 | Reference: 'http://danilenko.org/2012/7/6/rails_timezones' 653 | Enabled: false 654 | 655 | Rails/Validation: 656 | Description: 'Use validates :attribute, hash of validations.' 657 | Enabled: false 658 | --------------------------------------------------------------------------------