Sha256: 8147368d89587de6dc3e246f3a291f2b2de8f9f8cd5c4d346a476b7c1e0b3594

Contents?: true

Size: 780 Bytes

Versions: 20

Compression:

Stored size: 780 Bytes

Contents

require 'fileutils'

class Indocker::Containers::RestartPolicy
  TIMESTAMPS_DIR = 'timestamps'

  def initialize(configuration, logger)
    @configuration = configuration
    @logger = logger
  end

  def restart?(container, timestamp)
    file = timestamp_file(container)
    return true if !File.exists?(file)

    last_timestamp = File.read(file).strip
    timestamp != last_timestamp
  end

  def update(container, timestamp)
    FileUtils.mkdir_p(timestamp_folder)

    File.open(timestamp_file(container), 'w') do |f|
      f.write(timestamp)
    end
  end

  private

  def timestamp_folder
    timestamp = File.join(File.expand_path(Indocker.deploy_dir), TIMESTAMPS_DIR)
  end

  def timestamp_file(container)
    File.join(timestamp_folder, container.name.to_s)
  end
end

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
indocker-0.1.18 lib/indocker/containers/restart_policy.rb
indocker-0.3.0 lib/indocker/containers/restart_policy.rb
indocker-0.1.17 lib/indocker/containers/restart_policy.rb
indocker-0.1.16 lib/indocker/containers/restart_policy.rb
indocker-0.1.15 lib/indocker/containers/restart_policy.rb
indocker-0.1.14 lib/indocker/containers/restart_policy.rb
indocker-0.1.13 lib/indocker/containers/restart_policy.rb
indocker-0.1.12 lib/indocker/containers/restart_policy.rb
indocker-0.1.11 lib/indocker/containers/restart_policy.rb
indocker-0.1.10 lib/indocker/containers/restart_policy.rb
indocker-0.1.9 lib/indocker/containers/restart_policy.rb
indocker-0.1.8 lib/indocker/containers/restart_policy.rb
indocker-0.1.7 lib/indocker/containers/restart_policy.rb
indocker-0.1.6 lib/indocker/containers/restart_policy.rb
indocker-0.1.5 lib/indocker/containers/restart_policy.rb
indocker-0.1.4 lib/indocker/containers/restart_policy.rb
indocker-0.1.3 lib/indocker/containers/restart_policy.rb
indocker-0.1.2 lib/indocker/containers/restart_policy.rb
indocker-0.1.1 lib/indocker/containers/restart_policy.rb
indocker-0.1.0 lib/indocker/containers/restart_policy.rb