module Rocker::Docket

Constants

VERSION

Public Class Methods

build() click to toggle source
# File lib/rocker/docket.rb, line 9
def build
  update unless File.exists? dockerfile
  write(dockerfile, ERB.new(File.read(template)).result(binding))
  exec "docker build -t rocker-docket #{dir}"
end
dir() click to toggle source
# File lib/rocker/docket.rb, line 48
def dir
  "#{ENV['HOME']}/.rocker-docket"
end
dockerfile() click to toggle source
# File lib/rocker/docket.rb, line 36
def dockerfile
  "#{dir}/Dockerfile"
end
releases_string() click to toggle source
# File lib/rocker/docket.rb, line 32
def releases_string
  open("https://api.github.com/repos/coreos/rocket/releases"){ |f| f.read }
end
rocket_url() click to toggle source
# File lib/rocker/docket.rb, line 40
def rocket_url
  File.read rocket_url_file if File.exists? rocket_url_file
end
rocket_url_file() click to toggle source
# File lib/rocker/docket.rb, line 44
def rocket_url_file 
  "#{dir}/rocket_url"
end
template() click to toggle source
# File lib/rocker/docket.rb, line 15
def template
  "#{File.join(File.dirname(__FILE__), 'Dockerfile.erb')}"
end
update() click to toggle source
# File lib/rocker/docket.rb, line 19
def update
  release = JSON.parse(releases_string)[0]
  assets_url = release['assets_url']
  tag = release['tag_name']
  download_url = JSON.parse(open(assets_url){|f| f.read }).detect{ |a| a['name'] =~ /rocket.*.tar.gz/ }['browser_download_url']
  if download_url == rocket_url 
    nil
  else
    write(rocket_url_file, download_url)
    tag
  end
end

Private Class Methods

write(file, string) click to toggle source
# File lib/rocker/docket.rb, line 53
def write(file, string)
  File.open(file, 'w'){ |f| f.write(string) }
end