Class: Beaker::SedCommand
Instance Attribute Summary
Attributes inherited from Command
#args, #command, #environment, #options
Instance Method Summary collapse
-
#initialize(platform, expression, filename, opts = {}) ⇒ Object
constructor
sets up a SedCommand for a particular platform.
Methods inherited from Command
#args_string, #cmd_line, #options_string
Constructor Details
#initialize(platform, expression, filename, opts = {}) ⇒ Object
sets up a SedCommand for a particular platform
the purpose is to abstract away platform-dependent details of the sed command
151 152 153 154 155 156 157 158 159 160 161 |
# File 'lib/beaker/command.rb', line 151 def initialize platform, expression, filename, opts = {} command = "sed -i -e \"#{expression}\" #{filename}" if /solaris|aix|osx|openbsd/.match?(platform) command.slice! '-i ' temp_file = opts[:temp_file] ? opts[:temp_file] : "#{filename}.tmp" command << " > #{temp_file} && mv #{temp_file} #{filename} && rm -f #{temp_file}" end args = [] opts['ENV'] ||= {} super(command, args, opts) end |