class PhilColumns::Command::Generator
Protected Instance Methods
erb_template_to_file( template_filepath, dest_filepath, namespace )
click to toggle source
# File lib/phil_columns/command/generator.rb, line 15 def erb_template_to_file( template_filepath, dest_filepath, namespace ) template_filepath = template_filepath.is_a?( Pathname ) ? template_filepath : Pathname.new( template_filepath ) namespace = OpenStruct.new( namespace ) File.open( dest_filepath, 'w' ) do |f| result = ERB.new( template_filepath.read ).result( namespace.instance_eval { binding } ) f.write( result ) end end
seed_class_name()
click to toggle source
# File lib/phil_columns/command/generator.rb, line 31 def seed_class_name @seed_class_name ||= config.seed_name.camelize end
seed_filepath()
click to toggle source
# File lib/phil_columns/command/generator.rb, line 27 def seed_filepath @seed_filepath ||= File.join( config.seeds_path, seed_name ) end
seed_name()
click to toggle source
# File lib/phil_columns/command/generator.rb, line 35 def seed_name @seed_name ||= "#{timestamp}_#{config.seed_name}.rb" end
template_filepath()
click to toggle source
# File lib/phil_columns/command/generator.rb, line 11 def template_filepath raise NotImplementedError end
timestamp()
click to toggle source
# File lib/phil_columns/command/generator.rb, line 39 def timestamp @timestamp ||= Time.now.strftime( '%Y%m%d%H%M%S' ) end