Class: Hyper::Generator

Inherits:
Object
  • Object
show all
Includes:
Term::ANSIColor
Defined in:
lib/hyper/generator.rb

Constant Summary collapse

TEMPLATE_PATH =

Path to template directory

File.expand_path(File.dirname(__FILE__) + '/../../template')

Instance Method Summary collapse

Constructor Details

#initialize(name, options = {}) ⇒ Generator

Returns a new instance of Generator.



10
11
12
13
# File 'lib/hyper/generator.rb', line 10

def initialize(name, options = {})
  @name    = name
  @options = options
end

Instance Method Details

#cannot_generate?Boolean

Returns:

  • (Boolean)


27
28
29
# File 'lib/hyper/generator.rb', line 27

def cannot_generate?
  File.directory?(destination_folder) && !@options[:force]
end

#generateObject



15
16
17
18
19
20
21
22
23
24
25
# File 'lib/hyper/generator.rb', line 15

def generate
  if cannot_generate?
    error "#{@name} exists (use --force to overwrite)"
  else
    create_destination_folder
  
    template_contents.each do |path|
      generate_component(path)
    end
  end
end