Class: RSwift::TemplateManager

Inherits:
Object
  • Object
show all
Includes:
Thor::Actions, Thor::Base
Defined in:
lib/rswift/template_manager.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



6
7
8
# File 'lib/rswift/template_manager.rb', line 6

def name
  @name
end

Class Method Details

.source_rootObject



8
9
10
# File 'lib/rswift/template_manager.rb', line 8

def self.source_root
  File.dirname(__FILE__)
end

Instance Method Details

#create_files_for_template(name, template) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/rswift/template_manager.rb', line 12

def create_files_for_template(name, template)
  @name = name
  current_directory_path = File.dirname(__FILE__)
  template_directory = File.join(current_directory_path, 'templates/app', template.to_s)
  Dir.glob("#{template_directory}/**/*.erb", File::FNM_DOTMATCH).each do |template_path|
    relative_template_path = template_path.sub(current_directory_path + '/', '')

    relative_erb_file_path = template_path.sub(template_directory, '')
    file_name = File.basename(relative_erb_file_path, '.erb')
    relative_directory_path = File.dirname(relative_erb_file_path)
    relative_file_path = File.join(name, relative_directory_path, file_name)

    template relative_template_path, relative_file_path
  end
end