Class: Fig::Lock
- Inherits:
-
Object
- Object
- Fig::Lock
- Includes:
- Log
- Defined in:
- lib/fig/lock.rb,
lib/fig/lock.rb,
lib/fig/lock/version.rb
Defined Under Namespace
Modules: Log Classes: DockerClient
Constant Summary collapse
- VERSION =
"0.0.11"
Instance Attribute Summary collapse
-
#file ⇒ Object
readonly
Returns the value of attribute file.
-
#lock_file ⇒ Object
readonly
Returns the value of attribute lock_file.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(opts) ⇒ Lock
constructor
A new instance of Lock.
-
#install ⇒ Object
Install images from a lock file on the local system.
-
#update ⇒ Object
Update an existing lock file, or create if none exists.
Methods included from Log
Constructor Details
#initialize(opts) ⇒ Lock
Returns a new instance of Lock.
26 27 28 29 30 31 32 33 |
# File 'lib/fig/lock.rb', line 26 def initialize(opts) opts = merge_opts(opts) @file = opts[:file] @lock_file = lock_file_name(file) fail "File #{file} does not exist" unless File.exists?(file) fail "File #{file} is a directory" if File.directory?(file) end |
Instance Attribute Details
#file ⇒ Object (readonly)
Returns the value of attribute file.
24 25 26 |
# File 'lib/fig/lock.rb', line 24 def file @file end |
#lock_file ⇒ Object (readonly)
Returns the value of attribute lock_file.
24 25 26 |
# File 'lib/fig/lock.rb', line 24 def lock_file @lock_file end |
Class Method Details
.install(opts = {}) ⇒ Object
9 10 11 |
# File 'lib/fig/lock.rb', line 9 def install(opts={}) Lock.new(opts).install end |
.update(opts = {}) ⇒ Object
13 14 15 |
# File 'lib/fig/lock.rb', line 13 def update(opts={}) Lock.new(opts).update end |
Instance Method Details
#install ⇒ Object
Install images from a lock file on the local system
36 37 38 39 40 41 42 43 44 |
# File 'lib/fig/lock.rb', line 36 def install if File.exists?(lock_file) log.info "Lock file #{lock_file} found." fetch_images(YAML.load(File.read(lock_file))) else log.info "No lock file found." update end end |
#update ⇒ Object
Update an existing lock file, or create if none exists
47 48 49 50 51 52 53 54 55 56 |
# File 'lib/fig/lock.rb', line 47 def update log.info "Generating lock file for #{file} ..." hash = YAML.load(File.read(file)) select_latest(hash) log.info "Writing lock file #{lock_file} ..." File.write(lock_file, hash.to_yaml) log.info "Done." end |