Class: Js::Preflight::Lint

Inherits:
Object
  • Object
show all
Defined in:
lib/js-preflight/lint.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(filename, options = {}) ⇒ Lint

Returns a new instance of Lint.



5
6
7
8
# File 'lib/js-preflight/lint.rb', line 5

def initialize(filename, options = {})
  @filename = filename
  @executable_path = options[:executable_path] || File.join(::Js::Preflight::Basedir, "bin")
end

Instance Attribute Details

#executable_pathObject (readonly)

Returns the value of attribute executable_path.



4
5
6
# File 'lib/js-preflight/lint.rb', line 4

def executable_path
  @executable_path
end

#filenameObject (readonly)

Returns the value of attribute filename.



4
5
6
# File 'lib/js-preflight/lint.rb', line 4

def filename
  @filename
end

Class Method Details

.build(files) ⇒ Object



18
19
20
21
22
23
# File 'lib/js-preflight/lint.rb', line 18

def self.build(files)
  files.each do |file|
    lint = Lint.new(file)
    yield lint unless lint.clean?
  end
end

Instance Method Details

#clean?Boolean

Returns:

  • (Boolean)


14
15
16
# File 'lib/js-preflight/lint.rb', line 14

def clean?
  errors == "jslint: No problems found."
end

#errorsObject



10
11
12
# File 'lib/js-preflight/lint.rb', line 10

def errors
  @errors ||= lint
end