Class: Kozo::Commands::State::Upgrade
- Inherits:
-
Kozo::Commands::State
- Object
- Kozo::Command
- Kozo::Commands::State
- Kozo::Commands::State::Upgrade
- Defined in:
- lib/kozo/commands/state/upgrade.rb
Instance Attribute Summary
Attributes inherited from Kozo::Commands::State
Attributes inherited from Kozo::Command
Instance Method Summary collapse
-
#initialize(configuration, *_args) ⇒ Upgrade
constructor
A new instance of Upgrade.
- #start ⇒ Object
- #state ⇒ Object
Constructor Details
#initialize(configuration, *_args) ⇒ Upgrade
Returns a new instance of Upgrade.
9 10 11 |
# File 'lib/kozo/commands/state/upgrade.rb', line 9 def initialize(configuration, *_args) @configuration = configuration end |
Instance Method Details
#start ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/kozo/commands/state/upgrade.rb', line 13 def start return Kozo.logger.info "State file already up to date." if state.compatible? ((state.version + 1)..Kozo::State::VERSION).each do |version| file = Dir[Kozo.root.join("lib/kozo/upgrade/#{version}_*")].first raise NotImplementedError, "upgrade file to version #{version} not found" unless file Kozo.logger.info "Upgrading state file to version #{version}" klass = File .basename(file, ".rb") .delete_prefix("#{version}_") .prepend("kozo/upgrade/") .camelize .constantize # Write state configuration.backend.state = klass .new(state) .upgrade end end |
#state ⇒ Object
37 38 39 40 41 |
# File 'lib/kozo/commands/state/upgrade.rb', line 37 def state @state ||= configuration .backend .state(verify: false) end |