Class: Penman::SeedFileGenerator
- Inherits:
-
Object
- Object
- Penman::SeedFileGenerator
- Defined in:
- lib/penman/seed_file_generator.rb
Instance Attribute Summary collapse
-
#file_name ⇒ Object
readonly
Returns the value of attribute file_name.
-
#seed_code ⇒ Object
readonly
Returns the value of attribute seed_code.
-
#timestamp ⇒ Object
readonly
Returns the value of attribute timestamp.
Instance Method Summary collapse
-
#initialize(file_name, timestamp, seed_code) ⇒ SeedFileGenerator
constructor
A new instance of SeedFileGenerator.
- #write_seed ⇒ Object
Constructor Details
#initialize(file_name, timestamp, seed_code) ⇒ SeedFileGenerator
Returns a new instance of SeedFileGenerator.
7 8 9 10 11 |
# File 'lib/penman/seed_file_generator.rb', line 7 def initialize(file_name, , seed_code) @seed_code = seed_code @file_name = file_name @timestamp = end |
Instance Attribute Details
#file_name ⇒ Object (readonly)
Returns the value of attribute file_name.
4 5 6 |
# File 'lib/penman/seed_file_generator.rb', line 4 def file_name @file_name end |
#seed_code ⇒ Object (readonly)
Returns the value of attribute seed_code.
3 4 5 |
# File 'lib/penman/seed_file_generator.rb', line 3 def seed_code @seed_code end |
#timestamp ⇒ Object (readonly)
Returns the value of attribute timestamp.
5 6 7 |
# File 'lib/penman/seed_file_generator.rb', line 5 def @timestamp end |
Instance Method Details
#write_seed ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/penman/seed_file_generator.rb', line 13 def write_seed erb = ERB.new(File.read(Penman.config.seed_template_file)) seed_file_name = "#{@timestamp}_#{@file_name}.rb" full_seed_file_path = File.join(Penman.config.seed_path, seed_file_name) IO.write(full_seed_file_path, erb.result(binding)) if Penman.config.after_generate.present? Penman.config.after_generate.call(@timestamp, @file_name) end full_seed_file_path end |