Class: BestPracticeProject

Inherits:
Object
  • Object
show all
Defined in:
lib/best_practice_project.rb

Defined Under Namespace

Classes: BaseHandler, CoffeeLintHandler, HamlLintHandler, RailsBestPracticesHandler, RubocopHandler, ScssLintHandler

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeBestPracticeProject

Returns a new instance of BestPracticeProject.



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# 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

Instance Attribute Details

#coffee_lint_handlerObject (readonly)

Returns the value of attribute coffee_lint_handler.



8
9
10
# File 'lib/best_practice_project.rb', line 8

def coffee_lint_handler
  @coffee_lint_handler
end

#haml_lint_handlerObject (readonly)

Returns the value of attribute haml_lint_handler.



8
9
10
# File 'lib/best_practice_project.rb', line 8

def haml_lint_handler
  @haml_lint_handler
end

#rails_best_practices_handlerObject (readonly)

Returns the value of attribute rails_best_practices_handler.



8
9
10
# File 'lib/best_practice_project.rb', line 8

def rails_best_practices_handler
  @rails_best_practices_handler
end

#rubocop_handlerObject (readonly)

Returns the value of attribute rubocop_handler.



8
9
10
# File 'lib/best_practice_project.rb', line 8

def rubocop_handler
  @rubocop_handler
end

#scss_lint_handlerObject (readonly)

Returns the value of attribute scss_lint_handler.



8
9
10
# File 'lib/best_practice_project.rb', line 8

def scss_lint_handler
  @scss_lint_handler
end

Class Method Details

.load_tasksObject



10
11
12
# File 'lib/best_practice_project.rb', line 10

def self.load_tasks
  load "#{File.dirname(__FILE__)}/tasks/best_practice_project.rake"
end

Instance Method Details

#executeObject



35
36
37
38
39
40
41
42
43
44
# 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_configsObject



46
47
48
49
50
# 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?Boolean

Returns:

  • (Boolean)


30
31
32
33
# File 'lib/best_practice_project.rb', line 30

def rails?
  @rails = Object.const_defined?(:Rails) if @rails == nil
  @rails
end