Class: JSHint4r::Config

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path = nil) ⇒ Config

Returns a new instance of Config.



3
4
5
6
7
8
9
10
11
12
13
14
# File 'lib/jshint4r/config.rb', line 3

def initialize( path = nil )
  @excludes = []
  @opts     = {}
  @path     = nil
  @reporter = :text
  @targets  = []
  @verbose  = false

  if path and read_config_file( path )
    @path = path
  end
end

Instance Attribute Details

#excludesObject

Returns the value of attribute excludes.



15
16
17
# File 'lib/jshint4r/config.rb', line 15

def excludes
  @excludes
end

#optsObject

Returns the value of attribute opts.



15
16
17
# File 'lib/jshint4r/config.rb', line 15

def opts
  @opts
end

#pathObject (readonly)

Returns the value of attribute path.



15
16
17
# File 'lib/jshint4r/config.rb', line 15

def path
  @path
end

#reporterObject

Returns the value of attribute reporter.



16
17
18
# File 'lib/jshint4r/config.rb', line 16

def reporter
  @reporter
end

#targetsObject

Returns the value of attribute targets.



15
16
17
# File 'lib/jshint4r/config.rb', line 15

def targets
  @targets
end

#verboseObject

Returns the value of attribute verbose.



16
17
18
# File 'lib/jshint4r/config.rb', line 16

def verbose
  @verbose
end

Instance Method Details

#read_config_file(path) ⇒ Object

param

String path

return

Boolean



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/jshint4r/config.rb', line 22

def read_config_file( path )
  r = false

  if File.exist?( path )
    conf = YAML.load_file( path )
    if ( conf.is_a? Hash )
      self.excludes = conf['excludes'] if conf.has_key? 'excludes'
      self.opts     = conf['options']  if conf.has_key? 'options'
      self.reporter = conf['reporter'] if conf.has_key? 'reporter'
      self.targets  = conf['src']      if conf.has_key? 'src'
      self.verbose  = conf['verbose']  if conf.has_key? 'verbose'

      r = true
    end
  end

  return r
end