Class: Kamaze::DockerImage::Loader

Inherits:
Object
  • Object
show all
Defined in:
lib/kamaze/docker_image/loader.rb

Overview

Loader for tasks (using eval binding)

Defined Under Namespace

Modules: Context Classes: Helper

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(image) ⇒ Loader

Returns a new instance of Loader.

Parameters:



17
18
19
# File 'lib/kamaze/docker_image/loader.rb', line 17

def initialize(image)
  @image = image.clone.freeze
end

Instance Attribute Details

#imageKamaze::DockerImage (readonly, protected)

Returns:



43
44
45
# File 'lib/kamaze/docker_image/loader.rb', line 43

def image
  @image
end

Instance Method Details

#callself

Load tasks.

Returns:

  • (self)


24
25
26
27
28
29
30
31
32
33
# File 'lib/kamaze/docker_image/loader.rb', line 24

def call
  self.tap do
    if loadable?
      context.call do |b|
        b.local_variable_set(:image, image)
        b.eval(content)
      end
    end
  end
end

#contentString (protected)

Tasks file content (to eval)

Returns:

  • (String)


53
54
55
# File 'lib/kamaze/docker_image/loader.rb', line 53

def content
  file.read
end

#contextModule<Context> (protected)

Returns:



58
59
60
# File 'lib/kamaze/docker_image/loader.rb', line 58

def context
  Context
end

#filePathname (protected)

Returns:

  • (Pathname)


46
47
48
# File 'lib/kamaze/docker_image/loader.rb', line 46

def file
  Pathname.new(__dir__).join('loader', 'tasks.rb')
end

#loadable?Boolean

Returns:

  • (Boolean)


36
37
38
# File 'lib/kamaze/docker_image/loader.rb', line 36

def loadable?
  context.dsl?
end