Class: PicoApi::Generators::FileCreator

Inherits:
Object
  • Object
show all
Defined in:
lib/pico_api/generators/file_creator.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(project_name_data_mapper) ⇒ FileCreator

Returns a new instance of FileCreator.



15
16
17
# File 'lib/pico_api/generators/file_creator.rb', line 15

def initialize(project_name_data_mapper)
  @project_name_data_mapper = project_name_data_mapper
end

Class Method Details

.build(project_name) ⇒ Object



9
10
11
12
13
# File 'lib/pico_api/generators/file_creator.rb', line 9

def self.build(project_name)
  project_name_data_mapper = ProjectNameDataMapper.new(project_name)

  new(project_name_data_mapper)
end

Instance Method Details

#create(template_file_path, destination_path) ⇒ Object



19
20
21
22
23
# File 'lib/pico_api/generators/file_creator.rb', line 19

def create(template_file_path, destination_path)
  File.open("#{snakecased_name}#{destination_path}", 'w') do |file|
    file.write(template(template_file_path))
  end
end