Class: Docks::List

Inherits:
Object
  • Object
show all
Defined in:
lib/docks/list.rb

Instance Method Summary collapse

Instance Method Details

#add_file(f) ⇒ Object



13
14
15
16
# File 'lib/docks/list.rb', line 13

def add_file(f)
  from_yaml = YAML::load(File.read(f))
  handle_yaml_hash(from_yaml)
end

#body(name) ⇒ Object



46
47
48
49
# File 'lib/docks/list.rb', line 46

def body(name)
  url = hash[name].tap { |x| raise "nothing for #{name}" unless x }
  open(url).read
end

#expand_dock_path(path) ⇒ Object



23
24
25
26
27
28
29
30
# File 'lib/docks/list.rb', line 23

def expand_dock_path(path)
  if path =~ /http/i
    path
  else
    
    get_remote_path path
  end
end

#get_remote_path(path) ⇒ Object



18
19
20
21
# File 'lib/docks/list.rb', line 18

def get_remote_path(path)
  dir = "https://raw.github.com/mharris717/docks/master/dockerfiles"
  "#{dir}/#{path}"
end

#handle_yaml_hash(from_yaml, prefixes = []) ⇒ Object



32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/docks/list.rb', line 32

def handle_yaml_hash(from_yaml,prefixes=[])
  res = {}
  from_yaml.each do |k,v|
    if v.kind_of?(Hash)
      temp = handle_yaml_hash v, prefixes+[k]
      res = res.merge(temp)
    else
      full_key = (prefixes+[k]).join("/")
      res[full_key] = expand_dock_path(v)
    end
  end
  res
end