Sha256: a5f631d20fa30e22837485f5ccbda8149b00c51a9a85941ef1cbee5dae5fdbd5
Contents?: true
Size: 1.33 KB
Versions: 1
Compression:
Stored size: 1.33 KB
Contents
require 'colored' ## # CoffeeLint Checker looks for smells in your Coffeescript code # # @author dmasur class CoffeeLintChecker ## # Gives the Checkresult # # @return [Hash] Checkresult # @author dmasur def result @shell_output = begin config_file = File.exists?("clint_config.json") ? '-f clint_config.json' : '' `coffeelint -r . #{config_file}` rescue Errno::ENOENT "CoffeeLint not found" end { type: :coffeelint, check_output: @shell_output, status: status } end private ## # Gives the Check Status # # @return [String] Checkstatus # @author dmasur def status return 'No CoffeeScript Files found' if @shell_output == "" @violations = violation_count if @violations > 0 print_violations elsif @violations == 0 'OK'.green else 'N/A' end end def violation_count @shell_output.scan(/(\d*) errors? and (\d*) warnings? in .+ files?/).flatten. map(&:to_i).inject(0){ |sum, value| sum += value } end def print_violations color_violations "#{@violations} Style Violations" end ## # Color Code Validation Count # # @return [String] Colored Validation Count # @author dmasur def color_violations color = :red color = :yellow if @violations.between?(1, 9) @violations = @violations.to_s.send color end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
rake_check-0.2.2 | lib/rake_check/coffee_lint_checker.rb |