Sha256: f1f5a8ec62dcb2bc0b1f16e20fba511301218dfddf8962003b982da80c5661e0

Contents?: true

Size: 1.12 KB

Versions: 5

Compression:

Stored size: 1.12 KB

Contents

require 'rspec-system'

module RSpecSystem::Helpers
  # Helper object behind RSpecSystem::Helpers#shell
  class Rcp < RSpecSystem::Helper
    name 'rcp'
    properties :success

    def initialize(opts, clr, &block)
      ns = RSpecSystem::NodeSet.create
      opts = {
        :source_path => opts[:sp],
        :destination_path => opts[:dp],
        :dp => opts[:destination_path],
        :sp => opts[:source_path],
        :destination_node => ns.default_node,
        :d => ns.default_node,
        :source_node => nil,
        :s => nil,
      }.merge(opts)

      # Try to figure out :*_node using the node helper if a string is passed
      if opts[:destination_node].is_a? String
        opts[:d] = opts[:destination_node] = get_node_by_name(opts[:destination_node])
      end
      if opts[:source_node].is_a? String
        opts[:s] = opts[:source_node] = get_node_by_name(opts[:source_node])
      end

      super(opts, clr, &block)
    end

    # Gathers new results by executing the resource action
    def execute
      ns = RSpecSystem::NodeSet.create

      result = ns.rcp(opts)
      { :success => result }
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
rspec-system-2.8.0 lib/rspec-system/helpers/rcp.rb
rspec-system-2.7.2 lib/rspec-system/helpers/rcp.rb
rspec-system-2.7.1 lib/rspec-system/helpers/rcp.rb
rspec-system-2.7.0 lib/rspec-system/helpers/rcp.rb
rspec-system-2.6.0 lib/rspec-system/helpers/rcp.rb