class Docker::Dockerrun::Tag
Attributes
file[R]
original_json[R]
Public Class Methods
new(new_tag)
click to toggle source
# File lib/docker/dockerrun/tag.rb, line 7 def initialize(new_tag) @new_tag = new_tag end
Public Instance Methods
call()
click to toggle source
# File lib/docker/dockerrun/tag.rb, line 11 def call open read overwrite_with_new_tag close end
Private Instance Methods
close()
click to toggle source
# File lib/docker/dockerrun/tag.rb, line 67 def close file.close end
name_without_tag()
click to toggle source
# File lib/docker/dockerrun/tag.rb, line 42 def name_without_tag original_name_value.sub /:.*/, '' end
open()
click to toggle source
# File lib/docker/dockerrun/tag.rb, line 22 def open @file ||= File.open(FILE_NAME, 'r+') end
original_hash()
click to toggle source
# File lib/docker/dockerrun/tag.rb, line 30 def original_hash @original_hash ||= JSON.parse(original_json) end
original_image_value()
click to toggle source
# File lib/docker/dockerrun/tag.rb, line 34 def original_image_value original_hash.fetch 'Image', { } end
original_name_value()
click to toggle source
# File lib/docker/dockerrun/tag.rb, line 38 def original_name_value original_image_value.fetch 'Name', '' end
overwrite_with_new_tag()
click to toggle source
# File lib/docker/dockerrun/tag.rb, line 62 def overwrite_with_new_tag file.rewind file.write updated_json end
read()
click to toggle source
# File lib/docker/dockerrun/tag.rb, line 26 def read @original_json ||= file.read end
updated_hash()
click to toggle source
# File lib/docker/dockerrun/tag.rb, line 54 def updated_hash original_hash.merge 'Image' => updated_image_value end
updated_image_value()
click to toggle source
# File lib/docker/dockerrun/tag.rb, line 50 def updated_image_value original_image_value.merge 'Name' => updated_name end
updated_json()
click to toggle source
# File lib/docker/dockerrun/tag.rb, line 58 def updated_json JSON.pretty_generate updated_hash end
updated_name()
click to toggle source
# File lib/docker/dockerrun/tag.rb, line 46 def updated_name "#{name_without_tag}:#{@new_tag}" end