Sha256: 4ce95e8cb387d13b47e1db83b9cee4fb1dac79cf3bb0fa58b8596f1678634bbd

Contents?: true

Size: 653 Bytes

Versions: 4

Compression:

Stored size: 653 Bytes

Contents

module Rundock
  module Operation
    class Command < Base
      def run(backend, attributes = {})
        @instruction.each do |i|
          if i.is_a?(Hash)
            attributes.merge!(i)
            next
          end

          logging(i, 'info')

          backend.run_commands(
            assign_args(i, attributes[:task_args]), attributes
          )
        end
      end

      private

      def assign_args(cmd, args)
        return cmd unless args
        cmd.gsub(/\$#/, args.length.to_s)
           .gsub(/\$@/, args.join(' '))
           .gsub(/\$[1-9]*/) { |arg_n| args[arg_n.chars[1..-1].join.to_i - 1] }
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
rundock-1.0.8 lib/rundock/operation/command.rb
rundock-1.0.7 lib/rundock/operation/command.rb
rundock-1.0.6 lib/rundock/operation/command.rb
rundock-1.0.5 lib/rundock/operation/command.rb