Class: ArelConverter::Command

Inherits:
Object
  • Object
show all
Defined in:
lib/arel_converter/command.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(*args) ⇒ Command

Returns a new instance of Command.



9
10
11
12
13
14
# File 'lib/arel_converter/command.rb', line 9

def initialize(*args)
  args << '--help' if args.empty?
  @translators = ['scope','finder','association']
  @options = {}
  parse_argv(*args)
end

Instance Attribute Details

#optionsObject

Returns the value of attribute options.



7
8
9
# File 'lib/arel_converter/command.rb', line 7

def options
  @options
end

Instance Method Details

#run!Object



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/arel_converter/command.rb', line 16

def run!
  if @translators.include?('association')
    puts "== Checking Associations"
    ArelConverter::Association.new(options[:path], options).run!
  end

  if @translators.include?('scope')
    puts "\n== Checking Scopes"
    ArelConverter::Scope.new(options[:path], options).run!
  end

  if @translators.include?('finder')
    puts "\n== Checking Finders"
    ArelConverter::ActiveRecordFinder.new(options[:path], options).run!
  end
end