Class: DK::UserCommand

Inherits:
Object
  • Object
show all
Defined in:
lib/draftking/cli/commands/user_command.rb

Overview

User Defined Command

Constant Summary collapse

REQUIRED_FIELDS =
%w(command).freeze

Instance Method Summary collapse

Constructor Details

#initialize(opts) ⇒ UserCommand

Returns a new instance of UserCommand.



5
6
7
8
9
10
11
# File 'lib/draftking/cli/commands/user_command.rb', line 5

def initialize(opts)
  opts.each_pair do |k, v|
    singleton_class.class_eval { attr_accessor k.to_s }
    send("#{k}=", v)
  end
  check_required_fields
end

Instance Method Details

#exec!Object

Replace current process with execution of @command



14
15
16
17
18
19
20
# File 'lib/draftking/cli/commands/user_command.rb', line 14

def exec!
  # Prefix test commands
  command = prefix_command('bin/', Dir.pwd.include?('tumblr_draftking'))
  command = add_config_name(command)
  puts "User Command: #{command}"
  exec(command)
end