Module: Scanny::CLI

Defined in:
lib/scanny/cli.rb

Instance Method Summary collapse

Instance Method Details

#build_pathsObject



3
4
5
6
7
8
9
10
11
# File 'lib/scanny/cli.rb', line 3

def build_paths
  paths = ARGV.map do |path|
    path += "/**/*.rb" if File.directory?(path)
    path
  end
  paths << "./app/**/*.rb" if paths.size == 0

  paths.map { |path| path.gsub('//', '/') }
end

#require_checks(checks) ⇒ Object



13
14
15
16
17
18
19
20
21
# File 'lib/scanny/cli.rb', line 13

def require_checks(checks)
  checks = checks.to_s.split(",").map(&:strip)

  checks.each do |directory|
    Dir[directory + "/**/*.rb"].each do |file|
      require File.expand_path(file, Dir.pwd)
    end
  end
end

#runner_with_custom_checks(runner, disabled_checks, strict = false) ⇒ Object



23
24
25
26
27
28
29
30
31
32
# File 'lib/scanny/cli.rb', line 23

def runner_with_custom_checks(runner, disabled_checks, strict = false)
  disabled_checks = disabled_checks.to_s.split(",").map(&:strip)

  runner.checks.reject! do |check|
    disabled_checks.any? { |ch| check.class.name == ch } ||
    (check.strict? && !strict)
  end

  runner
end

#use_parser(version) ⇒ Object



34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/scanny/cli.rb', line 34

def use_parser(version)
  return unless version
  case version
    when '18'
      Rubinius::Melbourne
    when '19'
      Rubinius::Melbourne19
    else
      $stderr.puts "I can not recognize the version of the parser: #{version}"
      exit 2
  end
end