Class: BestPracticeProject::CoffeeLintHandler

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

Instance Method Summary collapse

Methods inherited from BaseHandler

#initialize, #rails?

Constructor Details

This class inherits a constructor from BestPracticeProject::BaseHandler

Instance Method Details

#commandObject



2
3
4
# File 'lib/best_practice_project/coffee_lint_handler.rb', line 2

def command
  "bundle exec coffeelint.rb -f coffeelint.json -r app/assets/javascripts/" if rails?
end

#executeObject



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/best_practice_project/coffee_lint_handler.rb', line 6

def execute
  require "coffeelint"

  dirs = ENV["DIRS"].split(":").map(&:strip) if ENV["DIRS"]
  dirs ||= ["app/assets/javascripts"]
  status = true

  dirs.each do |dir|
    dir = dir.strip

    puts "Running CoffeeLint on: #{dir}"
    result = Coffeelint.run_test_suite(dir)

    puts "Result: #{result}"
    status = false if result > 0
  end

  status
end

#generate_configObject



33
34
35
36
37
38
# File 'lib/best_practice_project/coffee_lint_handler.rb', line 33

def generate_config
  return unless @coffee_lint_config_path
  return puts "Coffee-Lint config already exists in #{@coffee_lint_config_path}" if File.exist?(@coffee_lint_config_path)

  puts "CoffeeLintHandler: FIXME: Generate Coffee-Lint configuration!"
end

#installed?Boolean



26
27
28
29
30
31
# File 'lib/best_practice_project/coffee_lint_handler.rb', line 26

def installed?
  require "coffeelint"
  true
rescue LoadError
  false
end