module Dapp::Dimg::Config::Directive::Dimg::InstanceMethods

Attributes

_ansible[R]
_artifact[R]
_artifact_groups[R]
_builder[R]
_chef[R]
_docker[R]
_from_dimg[R]
_from_dimg_artifact[R]
_git_artifact[R]
_mount[R]
_shell[R]

Public Instance Methods

_context_artifact_groups() click to toggle source
# File lib/dapp/dimg/config/directive/dimg/instance_methods.rb, line 85
def _context_artifact_groups
  @_context_artifact_groups ||= []
end
_import_artifact() click to toggle source
# File lib/dapp/dimg/config/directive/dimg/instance_methods.rb, line 103
def _import_artifact
  _artifact.select(&:not_associated?)
end
artifact(name = nil, &blk) click to toggle source
# File lib/dapp/dimg/config/directive/dimg/instance_methods.rb, line 26
def artifact(name = nil, &blk)
  pass_to(ArtifactGroup.new(name, dapp: dapp), :clone_to_artifact).tap do |artifact_group|
    _context_artifact_groups << directive_eval(artifact_group, &blk)
    dapp.artifact_config(name, artifact_group._artifact_config) unless name.nil?
  end
end
artifacts_after_parsing!() click to toggle source
# File lib/dapp/dimg/config/directive/dimg/instance_methods.rb, line 146
def artifacts_after_parsing!
  _artifacts_auto_excluding!
  _artifact.map(&:_config).each(&:artifacts_after_parsing!)
end
chef(&blk) click to toggle source
# File lib/dapp/dimg/config/directive/dimg/instance_methods.rb, line 12
def chef(&blk)
  builder(:chef)
  directive_eval(_chef, &blk)
end
docker(&blk) click to toggle source
# File lib/dapp/dimg/config/directive/dimg/instance_methods.rb, line 22
def docker(&blk)
  directive_eval(_docker, &blk)
end
git(url = nil, &blk) click to toggle source
# File lib/dapp/dimg/config/directive/dimg/instance_methods.rb, line 40
def git(url = nil, &blk)
  type = url.nil? ? :local : :remote
  _git_artifact.public_send(type, url.to_s, &blk)
end
import(name, from = nil, &blk) click to toggle source
# File lib/dapp/dimg/config/directive/dimg/instance_methods.rb, line 33
def import(name, from = nil, &blk)
  ArtifactGroup.new(dapp: dapp).tap do |artifact_group|
    artifact_group._artifact_export(dapp.artifact_config_by_name(name), from, &blk)
    _context_artifact_groups << artifact_group
  end
end
mount(to, &blk) click to toggle source
# File lib/dapp/dimg/config/directive/dimg/instance_methods.rb, line 45
def mount(to, &blk)
  Mount.new(to, dapp: dapp, &blk).tap do |mount|
    _mount << mount
  end
end
shell(&blk) click to toggle source
# File lib/dapp/dimg/config/directive/dimg/instance_methods.rb, line 17
def shell(&blk)
  builder(:shell)
  directive_eval(_shell, &blk)
end

Protected Instance Methods

_artifacts_auto_excluding!() click to toggle source
# File lib/dapp/dimg/config/directive/dimg/instance_methods.rb, line 162
def _artifacts_auto_excluding!
  path_to_relative = proc { |path| path.reverse.chomp('/').reverse }

  all_artifacts.reduce({}) do |hash, artifact|
    unless artifact._to.nil?
      to_common = artifact._to[/^\/[^\/]*/]
      hash[to_common] ||= []
      hash[to_common] << artifact
    end
    hash
  end.each do |to_common, artifacts|
    include_paths_common = artifacts.reduce([]) do |arr, artifact|
      arr << artifact._to.sub(to_common, '')
      arr.concat(artifact._include_paths.map { |path| File.join(artifact._to.sub(to_common, ''), path) } )
      arr
    end.map(&path_to_relative).uniq

    artifacts.each do |artifact|
      artifact_include_shift = path_to_relative.call(artifact._to.sub(to_common, ''))

      include_paths_common.each do |path|
        next if artifact_include_shift.start_with? path

        path = path_to_relative.call(path.sub(artifact_include_shift, ''))
        unless artifact._include_paths.any? { |ipath| ipath.start_with? path } || artifact._exclude_paths.any? { |epath| path.start_with? epath }
          artifact._exclude_paths << path
        end
      end
    end
  end
end
all_artifacts() click to toggle source
# File lib/dapp/dimg/config/directive/dimg/instance_methods.rb, line 194
def all_artifacts
  _artifact + _git_artifact._local + _git_artifact._remote
end
builder(type) click to toggle source
# File lib/dapp/dimg/config/directive/dimg/instance_methods.rb, line 153
def builder(type)
  @_builder = type if _builder == :none
  raise ::Dapp::Error::Config, code: :builder_type_conflict unless @_builder == type
end
passed_directives() click to toggle source
# File lib/dapp/dimg/config/directive/dimg/instance_methods.rb, line 158
def passed_directives
  [:@_chef, :@_shell, :@_docker, :@_git_artifact, :@_mount, :@_artifact_groups, :@_builder]
end