Class: Kurgan::Extend

Inherits:
Thor::Group
  • Object
show all
Includes:
Thor::Actions
Defined in:
lib/kurgan/extend.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.source_rootObject



10
11
12
# File 'lib/kurgan/extend.rb', line 10

def self.source_root
  File.dirname(__FILE__)
end

Instance Method Details

#add_componentObject



41
42
43
# File 'lib/kurgan/extend.rb', line 41

def add_component
  insert_into_file @cfhighlander_template, "\tComponent name: '#{@name}', template: '#{@name}'\n\n", :before => /^end/
end

#create_cfhighlander_filesObject



34
35
36
37
38
39
# File 'lib/kurgan/extend.rb', line 34

def create_cfhighlander_files
  opts = {template: @template, name: @name}
  template('templates/cfhighlander.extend.rb.tt', "#{@name}/#{@name}.cfhighlander.rb", opts)
  template('templates/config.yaml.tt', "#{@name}/#{@name}.config.yaml")
  template('templates/cfndsl.rb.tt', "#{@name}/#{@name}.cfndsl.rb")
end

#create_sub_dir_for_extended_componentObject



25
26
27
# File 'lib/kurgan/extend.rb', line 25

def create_sub_dir_for_extended_component
  empty_directory @name
end

#get_cfhighlander_templateObject



14
15
16
17
18
19
# File 'lib/kurgan/extend.rb', line 14

def get_cfhighlander_template
  @cfhighlander_template = Dir['*.cfhighlander.rb'][0]
  if @cfhighlander_template.nil?
    raise "No cfhighlander.rb file found in #{Dir.pwd}, are you in a cfhighlander project folder?"
  end
end

#get_component_nameObject



21
22
23
# File 'lib/kurgan/extend.rb', line 21

def get_component_name
  @name = options[:name] || component
end

#get_template_versionObject



29
30
31
32
# File 'lib/kurgan/extend.rb', line 29

def get_template_version
  @template = options[:version] ? "#{component}@#{options[:version]}" : component
  say "extending #{@template} to the #{@cfhighlander_template.split('.')[0]} project"
end