Module: Dapp::Dimg::Dapp::Dappfile

Included in:
Dapp
Defined in:
lib/dapp/dimg/dapp/dappfile.rb

Instance Method Summary collapse

Instance Method Details

#build_configsObject



23
24
25
26
27
28
29
30
31
# File 'lib/dapp/dimg/dapp/dappfile.rb', line 23

def build_configs
  @build_configs ||= begin
    config._dimg.select do |dimg|
      dimgs_patterns.any? { |pattern| dimg._name.nil? || File.fnmatch(pattern, dimg._name) }
    end.tap do |dimgs|
      raise ::Dapp::Error::Dapp, code: :no_such_dimg, data: { dimgs_patterns: dimgs_patterns.join('`, `') } if dimgs.empty?
    end
  end
end

#dimg_name!Object



9
10
11
12
# File 'lib/dapp/dimg/dapp/dappfile.rb', line 9

def dimg_name!
  one_dimg!
  build_configs.first._name
end

#dimgs_namesObject



19
20
21
# File 'lib/dapp/dimg/dapp/dappfile.rb', line 19

def dimgs_names
  build_configs.map(&:_name)
end

#dimgs_patternsObject



33
34
35
36
37
38
39
# File 'lib/dapp/dimg/dapp/dappfile.rb', line 33

def dimgs_patterns
  @dimgs_patterns ||= begin
    (options[:dimgs_patterns] || []).tap do |dimgs_patterns|
      dimgs_patterns << '*' unless dimgs_patterns.any?
    end
  end
end

#nameless_dimg?Boolean

Returns:

  • (Boolean)


5
6
7
# File 'lib/dapp/dimg/dapp/dappfile.rb', line 5

def nameless_dimg?
  dimgs_names.first.nil?
end

#one_dimg!Object



14
15
16
17
# File 'lib/dapp/dimg/dapp/dappfile.rb', line 14

def one_dimg!
  return if build_configs.one?
  raise ::Dapp::Error::Command, code: :command_unexpected_dimgs_number, data: { dimgs_names: dimgs_names.join('`, `') }
end