Class: RubyDuplicates

Inherits:
Object
  • Object
show all
Defined in:
lib/ruby_duplicates/cli.rb,
lib/ruby_duplicates/version.rb

Defined Under Namespace

Classes: CLI

Constant Summary collapse

DEFAULT_IGNORES =
%w[
  .git
  .bundle
  .burndown-swarm
  coverage
  log
  node_modules
  tmp
  vendor/bundle
].freeze
TOKEN_GROUPS =
{
  :@ident => :identifier,
  :@const => :constant,
  :@ivar => :ivar,
  :@cvar => :cvar,
  :@gvar => :gvar,
  :@label => :label,
  :@int => :number,
  :@float => :number,
  :@rational => :number,
  :@imaginary => :number,
  :@CHAR => :string,
  :@tstring_content => :string,
  :@regexp_beg => :regexp,
  :@regexp_end => :regexp,
  :@period => :dot,
  :@op => :operator
}.freeze
VERSION =
"0.1.0"

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ RubyDuplicates

Returns a new instance of RubyDuplicates.



53
54
55
56
57
58
59
60
61
# File 'lib/ruby_duplicates/cli.rb', line 53

def initialize(options)
  @threshold = options.fetch(:threshold)
  @min_lines = options.fetch(:min_lines)
  @min_nodes = options.fetch(:min_nodes)
  @max_results = options.fetch(:max_results)
  @format = options.fetch(:format)
  @paths = options.fetch(:paths)
  @ignore_dirs = options.fetch(:ignore_dirs)
end

Instance Method Details

#runObject



63
64
65
66
67
68
69
70
71
72
# File 'lib/ruby_duplicates/cli.rb', line 63

def run
  candidates = collect_candidates
  matches = find_matches(candidates)

  if @format == "json"
    puts JSON.pretty_generate(json_payload(matches, candidates.length))
  else
    print_text(matches, candidates.length)
  end
end