class Guard::RailsBP

Public Class Methods

new(options) click to toggle source
Calls superclass method
# File lib/guard/railsbp.rb, line 7
def initialize(options)
  super(default_options.merge!(options))
end

Public Instance Methods

reload() click to toggle source
# File lib/guard/railsbp.rb, line 19
def reload
  run_railsbp
end
run_all() click to toggle source
# File lib/guard/railsbp.rb, line 23
def run_all
  run_railsbp
end
run_on_changes(_) click to toggle source
# File lib/guard/railsbp.rb, line 27
def run_on_changes(_)
  run_railsbp
end
start() click to toggle source
# File lib/guard/railsbp.rb, line 11
def start
  run_railsbp if options[:run_on_start]
end
stop() click to toggle source
# File lib/guard/railsbp.rb, line 15
def stop
  true
end

Private Instance Methods

default_options() click to toggle source
# File lib/guard/railsbp.rb, line 52
def default_options
  {
      run_on_start: true,
      silent: false,
      vendor: false,
      spec: false,
      test: false,
      features: false,
      notify: true
  }
end
run_railsbp() click to toggle source
# File lib/guard/railsbp.rb, line 33
def run_railsbp
  UI.info "Running Rails Best Practices"

  args = options.map do |key, value|
    case key
    when :run_on_start, :notify
    when :exclude
      "--exclude #{value}"
    else
      "--#{key}" if value
    end
  end.compact.join(' ')

  result = system("rails_best_practices #{args}")
  ::Guard::Notifier.notify('Rails Best Practices run has failed!', image: :failed) if options[:notify] && !result

  result
end