Class: JslintRb::OptionParser

Inherits:
Object
  • Object
show all
Defined in:
lib/jslint-rb/option_parser.rb

Overview

Not sure what to call this class, but it basically parses the commandline args and puts them in instance vars. pass -h to see a list of valid command line opts

Constant Summary collapse

DEFAULT_OPT =

These are just some JSHINT defaults that I wanted. Part of the fun in writing software is imposing your opinions on people.

{ white: false,
  undef: true,
  bitwise: true,
  onevar: true,
  curly: true,
  latedef: true,
  newcap: true,
  noarg: true,
  trailing: true,
  eqeqeq: true,
  eqnull: true
}
DEFAULT_GLOBALS =

The default globals are tailored for some of my projects and ExtJS. Should probably turn this into something more generic

{
  Ext: true,
  console: true,
  Compass: true,
  currentUser: true
}

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeOptionParser

Returns a new instance of OptionParser.



48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
# File 'lib/jslint-rb/option_parser.rb', line 48

def initialize
  @filename = ARGV[0]

  @options = {
    #Location of the jslint.js file
    lint_location: File.expand_path("js/jshint.js", File.dirname(__FILE__)),
    #this is passed to JSLint so that it will not falsely call
    #an undefined error on them
    global_vars: {},
    #A hash of JSHINT options
    lint_options: {},
    #Formatter proc to use
    formatter_proc: nil
  }

  parse_config_file
  parse_cmdline_args
end

Instance Attribute Details

#filenameObject (readonly)

The file that we are executing JSHint against



16
17
18
# File 'lib/jslint-rb/option_parser.rb', line 16

def filename
  @filename
end

#optionsObject (readonly)

The options for JSHint and global vars to exclude from undef error reports



13
14
15
# File 'lib/jslint-rb/option_parser.rb', line 13

def options
  @options
end