Class: Quay::State
- Inherits:
-
Object
- Object
- Quay::State
- Defined in:
- lib/quay/state.rb
Instance Method Summary collapse
- #_load ⇒ Object
- #_save ⇒ Object
- #_state ⇒ Object
- #containers ⇒ Object
-
#initialize(file = ".quay.yml") ⇒ State
constructor
A new instance of State.
- #remove_container(name) ⇒ Object
- #save_container(name, id) ⇒ Object
Constructor Details
#initialize(file = ".quay.yml") ⇒ State
Returns a new instance of State.
3 4 5 |
# File 'lib/quay/state.rb', line 3 def initialize(file = ".quay.yml") @file = file end |
Instance Method Details
#_load ⇒ Object
32 33 34 35 36 37 38 39 40 |
# File 'lib/quay/state.rb', line 32 def _load if File.exists?(@file) @state = YAML.load_file(@file) else @state = {} end @state.default_proc = proc { |hash, key| hash[key] = {} } @state end |
#_save ⇒ Object
26 27 28 29 30 |
# File 'lib/quay/state.rb', line 26 def _save File.open(@file, "w") do |file| YAML.dump(@state, file) end end |
#_state ⇒ Object
21 22 23 24 |
# File 'lib/quay/state.rb', line 21 def _state _load if @state.nil? @state end |
#containers ⇒ Object
7 8 9 |
# File 'lib/quay/state.rb', line 7 def containers _state["containers"] end |
#remove_container(name) ⇒ Object
16 17 18 19 |
# File 'lib/quay/state.rb', line 16 def remove_container(name) containers.delete(name) _save end |
#save_container(name, id) ⇒ Object
11 12 13 14 |
# File 'lib/quay/state.rb', line 11 def save_container(name, id) containers[name] = id _save end |