Class: HammerCLIForeman::TaskHelper::PluginDraft

Inherits:
Object
  • Object
show all
Defined in:
lib/hammer_cli_foreman/task_helper.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, path, options = {}) ⇒ PluginDraft

Returns a new instance of PluginDraft.



8
9
10
11
12
13
14
15
16
# File 'lib/hammer_cli_foreman/task_helper.rb', line 8

def initialize(name, path, options = {})
  @plain_name = name
  @name = "hammer_cli_foreman_#{name}"
  @path = File.expand_path(@name.tr('_', '-'), path)
  @capitalized_bits = name.split('_').map(&:capitalize)
  @plugin_namespace = "HammerCLIForeman#{@capitalized_bits.join}"
  @core_location = File.expand_path('../../', File.dirname(__FILE__))
  @options = options
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



6
7
8
# File 'lib/hammer_cli_foreman/task_helper.rb', line 6

def name
  @name
end

#pathObject (readonly)

Returns the value of attribute path.



6
7
8
# File 'lib/hammer_cli_foreman/task_helper.rb', line 6

def path
  @path
end

Instance Method Details

#buildObject



18
19
20
21
22
23
# File 'lib/hammer_cli_foreman/task_helper.rb', line 18

def build
  FileUtils.mkpath("#{@path}/lib/#{@name}")
  FileUtils.mkpath("#{@path}/config")
  FileUtils.mkpath("#{@path}/test")
  FileUtils.mkpath("#{@path}/locale")
end

#fill(&block) ⇒ Object



25
26
27
28
29
# File 'lib/hammer_cli_foreman/task_helper.rb', line 25

def fill(&block)
  FileUtils.cd(@path) do
    self.instance_exec(&block)
  end
end