Class: Andy::Api::Install
- Inherits:
-
Object
- Object
- Andy::Api::Install
- Defined in:
- lib/andy/api/install_api.rb
Instance Method Summary collapse
-
#initialize(config) ⇒ Install
constructor
A new instance of Install.
- #install(pint_name, project_name, dir_name, project_parent_location) ⇒ Object
Constructor Details
#initialize(config) ⇒ Install
Returns a new instance of Install.
7 8 9 |
# File 'lib/andy/api/install_api.rb', line 7 def initialize(config) @config = config end |
Instance Method Details
#install(pint_name, project_name, dir_name, project_parent_location) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/andy/api/install_api.rb', line 11 def install(pint_name, project_name, dir_name, project_parent_location) project_path = File.join(project_parent_location, dir_name) Dir::mkdir(project_path) pint = @config.get_pint(pint_name) pint.source_files.each do |relative_source_file| source_file = File.join(pint.location, relative_source_file) destination_file = File.join(project_path, relative_source_file) is_template = relative_source_file.end_with?('.erb') destination_file = destination_file[0..-5] unless !is_template body = File.open(source_file).read if ( relative_source_file.end_with?('.erb') ) erb = ERB.new(body) body = erb.result(binding) end destination_dir = Pathname.new(destination_file).dirname Dir::mkdir(destination_dir) unless File.directory?(destination_dir) output = File.open(destination_file, 'w') output.puts body output.close end end |