Class: JsonLint::CLI

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

Instance Method Summary collapse

Constructor Details

#initialize(argv, stdin = STDIN, stdout = STDOUT, stderr = STDERR, kernel = Kernel) ⇒ CLI

Returns a new instance of CLI.



3
4
5
# File 'lib/jsonlint/cli.rb', line 3

def initialize(argv, stdin = STDIN, stdout = STDOUT, stderr = STDERR, kernel = Kernel)
  @argv, @stdin, @stdout, @stderr, @kernel = argv, stdin, stdout, stderr, kernel
end

Instance Method Details

#execute!Object



7
8
9
10
11
12
13
14
15
16
17
# File 'lib/jsonlint/cli.rb', line 7

def execute!
  files_to_check = @argv

  linter = JsonLint::Linter.new
  linter.check_all(files_to_check)

  if linter.has_errors?
    linter.display_errors
    @kernel.exit(1)
  end
end