Class: Qrpm::Fragment::CommandFragment

Inherits:
FragmentContainer show all
Defined in:
lib/qrpm/fragment.rb

Overview

$(COMMAND)

Instance Attribute Summary collapse

Attributes inherited from Fragment

#fragments, #source

Instance Method Summary collapse

Methods inherited from Fragment

#is_nil?, parse, #signature, #to_s, #variables

Constructor Details

#initialize(string) ⇒ CommandFragment

Returns a new instance of CommandFragment.



148
149
150
151
# File 'lib/qrpm/fragment.rb', line 148

def initialize(string)
  super(string)
  @command = string[2..-2]
end

Instance Attribute Details

#commandObject (readonly)

Command line excl. ‘$()’



146
147
148
# File 'lib/qrpm/fragment.rb', line 146

def command
  @command
end

Instance Method Details

#interpolate(dict) ⇒ Object



153
154
155
156
157
158
# File 'lib/qrpm/fragment.rb', line 153

def interpolate(dict)
  cmd = "set -eo pipefail; #{super}"
  stdout, stderr, status = Open3.capture3(cmd)
  status == 0 or raise Error.new "Failed expanding '$(#{cmd})'\n#{stderr}"
  stdout.chomp
end