class Goku::CLI

Public Instance Methods

c(raw_path) click to toggle source
# File lib/goku/cli.rb, line 5
def c(raw_path)
  path = Goku::Path.new(raw_path)
  factory = Goku::ElementFactory.new(path)

  implementation = factory.create_class.to_s
  spec = factory.create_spec.to_s

  save(path, implementation, spec)
end
m(raw_path) click to toggle source
# File lib/goku/cli.rb, line 16
def m(raw_path)
  path = Goku::Path.new(raw_path)
  factory = Goku::ElementFactory.new(path)

  implementation = factory.create_module.to_s
  spec = factory.create_spec.to_s

  save(path, implementation, spec)
end

Private Instance Methods

failure(message) click to toggle source
# File lib/goku/cli.rb, line 42
def failure(message)
  puts message

  exit(1)
end
save(path, implementation, spec) click to toggle source
# File lib/goku/cli.rb, line 31
def save(path, implementation, spec)
  failure("File #{path.full.colorize(:red)} already exists") if path.exists?
  failure("Spec #{path.to_spec.full.colorize(:red)} already exists") if path.to_spec.exists?

  puts "Creating #{path.full.colorize(:green)}"
  path.write(implementation)

  puts "Creating #{path.to_spec.full.colorize(:green)}"
  path.to_spec.write(spec)
end