Class: Bosh::AwsCliPlugin::MigrationHelper::Template

Inherits:
Object
  • Object
show all
Defined in:
lib/bosh_cli_plugin_aws/migration_helper.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name) ⇒ Template

Returns a new instance of Template.


7
8
9
10
11
# File 'lib/bosh_cli_plugin_aws/migration_helper.rb', line 7

def initialize(name)
  @timestamp_string = Time.new.getutc.strftime("%Y%m%d%H%M%S")
  @name = name
  @class_name = MigrationHelper.to_class_name(name)
end

Instance Attribute Details

#class_nameObject (readonly)

Returns the value of attribute class_name.


5
6
7
# File 'lib/bosh_cli_plugin_aws/migration_helper.rb', line 5

def class_name
  @class_name
end

#nameObject (readonly)

Returns the value of attribute name.


5
6
7
# File 'lib/bosh_cli_plugin_aws/migration_helper.rb', line 5

def name
  @name
end

#timestamp_stringObject (readonly)

Returns the value of attribute timestamp_string.


5
6
7
# File 'lib/bosh_cli_plugin_aws/migration_helper.rb', line 5

def timestamp_string
  @timestamp_string
end

Instance Method Details

#file_prefixObject


13
14
15
# File 'lib/bosh_cli_plugin_aws/migration_helper.rb', line 13

def file_prefix
  "#{timestamp_string}_#{name}"
end

#render(template_name = "aws_migration") ⇒ Object


17
18
19
20
21
# File 'lib/bosh_cli_plugin_aws/migration_helper.rb', line 17

def render(template_name = "aws_migration")
  template_file_path = File.expand_path("../../templates/#{template_name}.erb", File.dirname(__FILE__))
  template = ERB.new(File.new(template_file_path).read(), 0, '<>%-')
  template.result(binding)
end