Class: Dtf::Command::SetupDtf

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

Overview

Copies Thor task(s) into any project which require’s the DTF master gem (this gem) and then calls ‘setup_dtf’ sub-command. e.g bundle exec dtf setup_dtf

Instance Method Summary collapse

Constructor Details

#initialize(cmd_name, options) ⇒ SetupDtf

Returns a new instance of SetupDtf.



21
22
23
24
# File 'lib/dtf.rb', line 21

def initialize(cmd_name, options)
  @cmd_name = cmd_name
  @cmd_opts = options
end

Instance Method Details

#executeObject



26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/dtf.rb', line 26

def execute
  if "#{Gem.loaded_specs['dtf'].gem_dir}" == "#{Dir.pwd}"
    $stderr.puts "Copying files over themselves is not usually good. Aborting!"
    abort()
  elsif ! File.exists?("#{Dir.pwd}/lib/tasks/setup.thor")
    puts "Installing DTF tasks"
    FileUtils.cp(Dir.glob("#{File.join("#{Gem.loaded_specs['dtf'].gem_dir}", 'lib/tasks/*')}"), "#{Dir.pwd}/lib/tasks/")
  else
    $stderr.puts "Copying files over themselves is not usually good. Aborting!"
    abort()
  end
end