Sha256: d1c117b1a6af4ee748b9fdc116b27b55c34a2e30ebf2336cf3c6fe4de6d41cd4

Contents?: true

Size: 1012 Bytes

Versions: 3

Compression:

Stored size: 1012 Bytes

Contents

class BestPracticeProject::CoffeeLintHandler < BestPracticeProject::BaseHandler
  def command
    "bundle exec coffeelint.rb -f coffeelint.json -r app/assets/javascripts/" if rails?
  end

  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

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

  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

private

  def config_path
    @config_path ||= "coffeelint.json"
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
best_practice_project-0.0.10 lib/best_practice_project/coffee_lint_handler.rb
best_practice_project-0.0.9 lib/best_practice_project/coffee_lint_handler.rb
best_practice_project-0.0.8 lib/best_practice_project/coffee_lint_handler.rb