Class: Ufo::DSL::Helper

Inherits:
Object
  • Object
show all
Defined in:
lib/ufo/dsl/helper.rb

Overview

provides some helperally context variables

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Helper

Returns a new instance of Helper.



11
12
13
14
# File 'lib/ufo/dsl/helper.rb', line 11

def initialize(options={})
  @options = options
  @project_root = options[:project_root] || '.'
end

Instance Method Details

#dockerfile_portObject

helper variables



18
19
20
21
22
23
# File 'lib/ufo/dsl/helper.rb', line 18

def dockerfile_port
  dockerfile_path = "#{@project_root}/Dockerfile"
  if File.exist?(dockerfile_path)
    parse_for_dockerfile_port(dockerfile_path)
  end
end

#full_image_nameObject



25
26
27
# File 'lib/ufo/dsl/helper.rb', line 25

def full_image_name
  DockerBuilder.new(@options).full_image_name
end

#parse_for_dockerfile_port(dockerfile_path) ⇒ Object



35
36
37
38
39
40
41
42
43
# File 'lib/ufo/dsl/helper.rb', line 35

def parse_for_dockerfile_port(dockerfile_path)
  lines = IO.read(dockerfile_path).split("\n")
  expose_line = lines.find { |l| l =~ /^EXPOSE / }
  if expose_line
    md = expose_line.match(/EXPOSE (\d+)/)
    port = md[1] if md
  end
  port.to_i if port
end

#settingsObject

helper methods



31
32
33
# File 'lib/ufo/dsl/helper.rb', line 31

def settings
  @settings ||= Settings.new(@project_root)
end