Class: Gry::Option

Inherits:
Object
  • Object
show all
Defined in:
lib/gry/option.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(argv) ⇒ Option

Returns a new instance of Option.



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/gry/option.rb', line 5

def initialize(argv)
  opt = OptionParser.new
  @version = false
  @process = Parallel.processor_count
  @fast = true
  @max_count = 10
  @min_difference = 10
  @display_disabled_cops = false
  @metrics_percentile = 95
  @cache = true
  @raw = false

  opt.banner = 'Usage: gry [options] [Cop1, Cop2, ...]'

  opt.on('-d', '--debug', 'Output debug log.') {Gry.debug_mode!}
  opt.on('-p', '--process=VAL', 'Number of parallel processes.') {|v| @process = v.to_i}
  opt.on('-v', '--version', 'Display version.') {@version = true}
  opt.on('--[no-]fast', 'Run only fast cops. Default: true') {|v| @fast = v}
  opt.on('--max-count=10', 'Upper limit of issues.') {|v| @max_count = v.to_i}
  opt.on('--min-difference=10', 'Lower limit of issues number difference') {|v| @min_difference = v.to_i}
  opt.on('--metrics-percentile=95', 'Percentile for allowed complex code') {|v| @metrics_percentile = v.to_i}
  opt.on('--display-disabled-cops', 'Display disabled cops') {|v| @display_disabled_cops = v}
  opt.on('--[no-]cache', 'Run gry with cache. Default: true') {|v| @cache = v}
  opt.on('--raw', 'Display raw data(JSON). Default: false') {|v| @raw = v}

  @args = opt.parse(argv)
end

Instance Attribute Details

#argsObject (readonly)

Returns the value of attribute args.



3
4
5
# File 'lib/gry/option.rb', line 3

def args
  @args
end

#cacheObject (readonly)

Returns the value of attribute cache.



3
4
5
# File 'lib/gry/option.rb', line 3

def cache
  @cache
end

#display_disabled_copsObject (readonly)

Returns the value of attribute display_disabled_cops.



3
4
5
# File 'lib/gry/option.rb', line 3

def display_disabled_cops
  @display_disabled_cops
end

#fastObject (readonly)

Returns the value of attribute fast.



3
4
5
# File 'lib/gry/option.rb', line 3

def fast
  @fast
end

#max_countObject (readonly)

Returns the value of attribute max_count.



3
4
5
# File 'lib/gry/option.rb', line 3

def max_count
  @max_count
end

#metrics_percentileObject (readonly)

Returns the value of attribute metrics_percentile.



3
4
5
# File 'lib/gry/option.rb', line 3

def metrics_percentile
  @metrics_percentile
end

#min_differenceObject (readonly)

Returns the value of attribute min_difference.



3
4
5
# File 'lib/gry/option.rb', line 3

def min_difference
  @min_difference
end

#processObject (readonly)

Returns the value of attribute process.



3
4
5
# File 'lib/gry/option.rb', line 3

def process
  @process
end

#rawObject (readonly)

Returns the value of attribute raw.



3
4
5
# File 'lib/gry/option.rb', line 3

def raw
  @raw
end

#versionObject (readonly)

Returns the value of attribute version.



3
4
5
# File 'lib/gry/option.rb', line 3

def version
  @version
end