Class: Hyper::Generator

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

Instance Method Summary collapse

Constructor Details

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

Returns a new instance of Generator.



7
8
9
10
# File 'lib/hyper/generator.rb', line 7

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

Instance Method Details

#cannot_generate?Boolean

Returns:

  • (Boolean)


24
25
26
# File 'lib/hyper/generator.rb', line 24

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

#generateObject



12
13
14
15
16
17
18
19
20
21
22
# File 'lib/hyper/generator.rb', line 12

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