Class: OsUp::Migration
- Inherits:
-
Object
- Object
- OsUp::Migration
- Defined in:
- lib/osup/migration.rb
Instance Attribute Summary collapse
-
#description ⇒ Object
readonly
Returns the value of attribute description.
-
#dirname ⇒ Object
readonly
Returns the value of attribute dirname.
-
#export_pool ⇒ Object
readonly
Returns the value of attribute export_pool.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
-
#snapshot ⇒ Object
readonly
Returns the value of attribute snapshot.
-
#stop_containers ⇒ Object
readonly
Returns the value of attribute stop_containers.
-
#summary ⇒ Object
readonly
Returns the value of attribute summary.
Class Method Summary collapse
Instance Method Summary collapse
- #<=>(other) ⇒ Object
- #action_script(action) ⇒ Object
-
#initialize(path, dirname, id, name) ⇒ Migration
constructor
A new instance of Migration.
- #load_spec ⇒ Object protected
- #spec_path ⇒ Object protected
Constructor Details
#initialize(path, dirname, id, name) ⇒ Migration
Returns a new instance of Migration.
16 17 18 19 20 21 22 |
# File 'lib/osup/migration.rb', line 16 def initialize(path, dirname, id, name) @path = File.join(path, dirname) @dirname = dirname @id = id @name = name @spec = load_spec end |
Instance Attribute Details
#description ⇒ Object (readonly)
Returns the value of attribute description.
5 6 7 |
# File 'lib/osup/migration.rb', line 5 def description @description end |
#dirname ⇒ Object (readonly)
Returns the value of attribute dirname.
5 6 7 |
# File 'lib/osup/migration.rb', line 5 def dirname @dirname end |
#export_pool ⇒ Object (readonly)
Returns the value of attribute export_pool.
5 6 7 |
# File 'lib/osup/migration.rb', line 5 def export_pool @export_pool end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
5 6 7 |
# File 'lib/osup/migration.rb', line 5 def id @id end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
5 6 7 |
# File 'lib/osup/migration.rb', line 5 def name @name end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
5 6 7 |
# File 'lib/osup/migration.rb', line 5 def path @path end |
#snapshot ⇒ Object (readonly)
Returns the value of attribute snapshot.
5 6 7 |
# File 'lib/osup/migration.rb', line 5 def snapshot @snapshot end |
#stop_containers ⇒ Object (readonly)
Returns the value of attribute stop_containers.
5 6 7 |
# File 'lib/osup/migration.rb', line 5 def stop_containers @stop_containers end |
#summary ⇒ Object (readonly)
Returns the value of attribute summary.
5 6 7 |
# File 'lib/osup/migration.rb', line 5 def summary @summary end |
Class Method Details
.load(path, dirname) ⇒ Object
8 9 10 11 12 13 14 |
# File 'lib/osup/migration.rb', line 8 def self.load(path, dirname) if /^(\d+)-(.+)$/ !~ dirname raise "'#{dirname}' is not a valid migration" end new(path, dirname, ::Regexp.last_match(1).to_i, ::Regexp.last_match(2).gsub('-', ' ').capitalize) end |
Instance Method Details
#<=>(other) ⇒ Object
28 29 30 |
# File 'lib/osup/migration.rb', line 28 def <=>(other) id <=> other.id end |
#action_script(action) ⇒ Object
24 25 26 |
# File 'lib/osup/migration.rb', line 24 def action_script(action) File.join(path, "#{action}.rb") end |
#load_spec ⇒ Object (protected)
34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/osup/migration.rb', line 34 def load_spec unless File.exist?(spec_path) @snapshot = [] return end spec = OsCtl::Lib::ConfigFile.load_yaml_file(spec_path) @name = spec['name'] || @name @description = spec['description'] @snapshot = spec['snapshot'].map(&:to_sym) @export_pool = spec.fetch('export_pool', true) @stop_containers = spec.fetch('stop_containers', true) end |
#spec_path ⇒ Object (protected)
48 49 50 |
# File 'lib/osup/migration.rb', line 48 def spec_path File.join(path, 'spec.yml') end |