Class: Nomadize::FileGenerator

Inherits:
Object
  • Object
show all
Defined in:
lib/nomadize/file_generator.rb

Instance Method Summary collapse

Constructor Details

#initialize(path:, name:, timestamp: DateTime.now.new_offset(0).strftime("%Y%m%d%H%M%S")) ⇒ FileGenerator

Returns a new instance of FileGenerator.



9
10
11
12
13
# File 'lib/nomadize/file_generator.rb', line 9

def initialize(path:, name:, timestamp: DateTime.now.new_offset(0).strftime("%Y%m%d%H%M%S"))
  @path      = path
  @name      = name
  @timestamp = timestamp
end

Instance Method Details

#saveObject



15
16
17
18
19
20
# File 'lib/nomadize/file_generator.rb', line 15

def save
  FileUtils.mkdir_p path unless File.exists?(path)
  migration_file = File.join(path, timestamped_name)
  File.open(File.join(path, timestamped_name), "w") { |f| f.write(template_content) }
  migration_file
end