class BestPracticeProject

Attributes

coffee_lint_handler[R]
haml_lint_handler[R]
rails_best_practices_handler[R]
rubocop_handler[R]
scss_lint_handler[R]

Public Class Methods

load_tasks() click to toggle source
# File lib/best_practice_project.rb, line 10
def self.load_tasks
  load "#{File.dirname(__FILE__)}/tasks/best_practice_project.rake"
end
new() click to toggle source
# File lib/best_practice_project.rb, line 14
def initialize
  @rubocop_handler = BestPracticeProject::RubocopHandler.new(best_practice_project: self)
  @haml_lint_handler = BestPracticeProject::HamlLintHandler.new(best_practice_project: self)
  @scss_lint_handler = BestPracticeProject::ScssLintHandler.new(best_practice_project: self)
  @coffee_lint_handler = BestPracticeProject::CoffeeLintHandler.new(best_practice_project: self)
  @rails_best_practices_handler = BestPracticeProject::RailsBestPracticesHandler.new(best_practice_project: self)

  @handlers = [
    @rubocop_handler,
    @haml_lint_handler,
    @scss_lint_handler,
    @coffee_lint_handler,
    @rails_best_practices_handler
  ]
end

Public Instance Methods

execute() click to toggle source
# File lib/best_practice_project.rb, line 35
def execute
  process_status = true

  @handlers.select(&:installed?).each do |handler|
    handler_result = handler.execute
    process_status = false unless handler_result
  end

  process_status
end
generate_configs() click to toggle source
# File lib/best_practice_project.rb, line 46
def generate_configs
  puts "Handlers: #{@handlers.select(&:installed?).map(&:class).map(&:name)}"

  @handlers.select(&:installed?).map(&:generate_config)
end
rails?() click to toggle source
# File lib/best_practice_project.rb, line 30
def rails?
  @rails = Object.const_defined?(:Rails) if @rails == nil
  @rails
end

Private Instance Methods

commands() click to toggle source
# File lib/best_practice_project.rb, line 54
def commands
  unless @commands
    @commands = []

    if rails?
      @commands << @scss_lint_handler.command if @scss_lint_handler.installed?
      @commands << @rails_best_practices_handler.command if @rails_best_practices_handler.installed?
    end

    @commands << proc { @rubocop_handler.execute }
  end

  @commands
end