Class: Stipa::Generators::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/stipa/generators/base.rb

Direct Known Subclasses

Api, Vue

Constant Summary collapse

GEM_JS =
File.expand_path('../../js', __dir__)
GEM_MEDIA =
File.expand_path('../../../media', __dir__)
GEM_ROOT =
File.expand_path('../..', GEM_JS)

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name) ⇒ Base

Returns a new instance of Base.



14
15
16
17
# File 'lib/stipa/generators/base.rb', line 14

def initialize(name)
  @name   = name
  @target = File.expand_path(name, Dir.pwd)
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



12
13
14
# File 'lib/stipa/generators/base.rb', line 12

def name
  @name
end

#targetObject (readonly)

Returns the value of attribute target.



12
13
14
# File 'lib/stipa/generators/base.rb', line 12

def target
  @target
end

Instance Method Details

#generateObject



19
20
21
22
23
24
25
26
27
28
# File 'lib/stipa/generators/base.rb', line 19

def generate
  abort "Error: '#{name}' already exists." if Dir.exist?(target)

  say "Creating #{name} (#{template_name})..."
  make_dirs
  write_files
  post_generate
  init_git
  say done_message
end