Class: Dapp::Dimg::Config::Directive::ArtifactBase::Export

Inherits:
Base show all
Defined in:
lib/dapp/dimg/config/directive/artifact_base.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#clone_to_artifact

Methods inherited from Config::Directive::Base

#clone, #encode_with

Constructor Details

#initialize(cwd, **kwargs, &blk) ⇒ Export

Returns a new instance of Export.



39
40
41
42
43
44
45
# File 'lib/dapp/dimg/config/directive/artifact_base.rb', line 39

def initialize(cwd, **kwargs, &blk)
  self._cwd = cwd
  @_include_paths ||= []
  @_exclude_paths ||= []

  super(**kwargs, &blk)
end

Instance Attribute Details

#_cwdObject

Returns the value of attribute _cwd.



37
38
39
# File 'lib/dapp/dimg/config/directive/artifact_base.rb', line 37

def _cwd
  @_cwd
end

#_exclude_pathsObject

Returns the value of attribute _exclude_paths.



37
38
39
# File 'lib/dapp/dimg/config/directive/artifact_base.rb', line 37

def _exclude_paths
  @_exclude_paths
end

#_groupObject

Returns the value of attribute _group.



37
38
39
# File 'lib/dapp/dimg/config/directive/artifact_base.rb', line 37

def _group
  @_group
end

#_include_pathsObject

Returns the value of attribute _include_paths.



37
38
39
# File 'lib/dapp/dimg/config/directive/artifact_base.rb', line 37

def _include_paths
  @_include_paths
end

#_ownerObject

Returns the value of attribute _owner.



37
38
39
# File 'lib/dapp/dimg/config/directive/artifact_base.rb', line 37

def _owner
  @_owner
end

#_toObject

Returns the value of attribute _to.



37
38
39
# File 'lib/dapp/dimg/config/directive/artifact_base.rb', line 37

def _to
  @_to
end

Instance Method Details

#_artifact_optionsObject



47
48
49
50
51
52
53
54
55
56
# File 'lib/dapp/dimg/config/directive/artifact_base.rb', line 47

def _artifact_options
  {
    to:            _to,
    cwd:           _cwd,
    include_paths: _include_paths,
    exclude_paths: _exclude_paths,
    owner:         _owner,
    group:         _group
  }
end

#exclude_paths(*relative_paths) ⇒ Object



80
81
82
83
84
85
86
87
# File 'lib/dapp/dimg/config/directive/artifact_base.rb', line 80

def exclude_paths(*relative_paths)
  sub_directive_eval do
    unless relative_paths.all? { |path| Pathname(path).relative? }
      raise ::Dapp::Error::Config, code: :export_exclude_paths_relative_path_required
    end
    _exclude_paths.concat(relative_paths.map(&method(:path_format)))
  end
end

#group(group) ⇒ Object



93
94
95
# File 'lib/dapp/dimg/config/directive/artifact_base.rb', line 93

def group(group)
  sub_directive_eval { @_group = group }
end

#include_paths(*relative_paths) ⇒ Object



71
72
73
74
75
76
77
78
# File 'lib/dapp/dimg/config/directive/artifact_base.rb', line 71

def include_paths(*relative_paths)
  sub_directive_eval do
    unless relative_paths.all? { |path| Pathname(path).relative? }
      raise ::Dapp::Error::Config, code: :export_include_paths_relative_path_required
    end
    _include_paths.concat(relative_paths.map(&method(:path_format)))
  end
end

#owner(owner) ⇒ Object



89
90
91
# File 'lib/dapp/dimg/config/directive/artifact_base.rb', line 89

def owner(owner)
  sub_directive_eval { @_owner = owner }
end

#to(absolute_path) ⇒ Object



64
65
66
67
68
69
# File 'lib/dapp/dimg/config/directive/artifact_base.rb', line 64

def to(absolute_path)
  sub_directive_eval do
    raise ::Dapp::Error::Config, code: :export_to_absolute_path_required unless Pathname(absolute_path).absolute?
    @_to = path_format(absolute_path)
  end
end

#validate!Object



97
98
99
# File 'lib/dapp/dimg/config/directive/artifact_base.rb', line 97

def validate!
  raise ::Dapp::Error::Config, code: :export_to_required if _to.nil?
end