Class: Butterfly::Stub::Base

Inherits:
RubiGen::Base
  • Object
show all
Defined in:
lib/base.rb

Overview

extend Base class wwith base functionality for the code stub generator generator

Direct Known Subclasses

StubGenerator

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(runtime_args, runtime_options = {}) ⇒ Base

Returns a new instance of Base.



60
61
62
63
64
65
66
67
68
# File 'lib/base.rb', line 60

def initialize(runtime_args, runtime_options = {})
  super
  @destination_root = File.expand_path(args.shift)
  @name = base_name
  @author = ENV['USER']
  @target = @destination_root
  @group = @destination_root.match(/\/(\w+)_generators\//)[1]
  @date = Time.now.strftime("%Y-%m-%d")
end

Instance Attribute Details

#authorObject (readonly)

Returns the value of attribute author.



58
59
60
# File 'lib/base.rb', line 58

def author
  @author
end

#dateObject (readonly)

Returns the value of attribute date.



58
59
60
# File 'lib/base.rb', line 58

def date
  @date
end

#groupObject (readonly)

Returns the value of attribute group.



58
59
60
# File 'lib/base.rb', line 58

def group
  @group
end

#nameObject (readonly)

Returns the value of attribute name.



58
59
60
# File 'lib/base.rb', line 58

def name
  @name
end

#targetObject (readonly)

Returns the value of attribute target.



58
59
60
# File 'lib/base.rb', line 58

def target
  @target
end

Instance Method Details

#after_generateObject

do some final things after generation



71
72
73
74
75
# File 'lib/base.rb', line 71

def after_generate
  info = File.read(File.join(spec.path, 'INFO')) rescue ''
  template = ERB.new(info, nil, '<>')
  puts "\n#{template.result(binding)}"
end