Class: RailsBestPractices::CLI

Inherits:
Object
  • Object
show all
Defined in:
lib/rails_best_practices/cli.rb

Class Method Summary collapse

Class Method Details

.run(argv) ⇒ Boolean

Run analyze with ruby code

Examples:

RailsBestPractices::CLI.run(['-d', '-o', 'path/to/file'])

Parameters:

  • argv (Array)

    command argments

Returns:

  • (Boolean)

    return true, if there is no violation.



10
11
12
13
14
15
16
17
18
19
20
# File 'lib/rails_best_practices/cli.rb', line 10

def self.run(argv)
  options = OptionParser.parse!(argv)
  if !argv.empty? && !File.exist?(argv.first)
    raise Errno::ENOENT, "#{argv.first} doesn't exist"
  end

  analyzer = Analyzer.new(argv.first, options)
  analyzer.analyze
  analyzer.output
  analyzer.runner.errors.empty?
end