PageRenderTime 17ms CodeModel.GetById 13ms app.highlight 2ms RepoModel.GetById 2ms app.codeStats 0ms

/lib/rails_best_practices/reviews/dry_bundler_in_capistrano_review.rb

http://github.com/flyerhzm/rails_best_practices
Ruby | 29 lines | 14 code | 2 blank | 13 comment | 4 complexity | b712d3c9a9cbe8cd2a5ca6991e13f070 MD5 | raw file
 1# frozen_string_literal: true
 2
 3module RailsBestPractices
 4  module Reviews
 5    # Review config/deploy.rb file to make sure using the bundler's capistrano recipe.
 6    #
 7    # See the best practice details here https://rails-bestpractices.com/posts/2010/09/02/dry-bundler-in-capistrano/
 8    #
 9    # Implementation:
10    #
11    # Review process:
12    #   only check the command nodes to see if there is bundler namespace in config/deploy.rb file,
13    #
14    #   if the message of command node is "namespace" and the first argument  is "bundler",
15    #   then it should use bundler's capistrano recipe.
16    class DryBundlerInCapistranoReview < Review
17      interesting_nodes :command
18      interesting_files DEPLOY_FILES
19      url 'https://rails-bestpractices.com/posts/2010/09/02/dry-bundler-in-capistrano/'
20
21      # check call node to see if it is with message "namespace" and argument "bundler".
22      add_callback :start_command do |node|
23        if node.message.to_s == 'namespace' && node.arguments.all[0].to_s == 'bundler'
24          add_error 'dry bundler in capistrano'
25        end
26      end
27    end
28  end
29end