class Spectra::Command::Init

Attributes

destination[RW]
source[RW]

Public Class Methods

new(argv) click to toggle source
Calls superclass method Spectra::Command::new
# File lib/spectra/commands.rb, line 76
def initialize(argv)
  super
  self.source = File.dirname(__FILE__) + '/template.rb'
  self.destination = "#{Dir.pwd}/spectrum.rb"
end

Public Instance Methods

run() click to toggle source
# File lib/spectra/commands.rb, line 87
def run
  begin
    IO.copy_stream(self.source, self.destination)
  rescue Exception => exception
    message  = 'Failed to create spectrum.rb'
    message += "\n#{exception}"
    raise Informative, message
  else
    Spectra.logger.info "[✓] Created #{self.destination}"
  end
end
validate!() click to toggle source
Calls superclass method
# File lib/spectra/commands.rb, line 82
def validate!
  super 
  raise Informative, "#{self.destination} already exists" if File.file?(self.destination) 
end