Sha256: af9bc76dacbb7778dd012a5c9d77a69b2bfc5ae3032408963048f3ac9fff4205

Contents?: true

Size: 893 Bytes

Versions: 27

Compression:

Stored size: 893 Bytes

Contents

# TODO: Send patches to Specinfra

module Specinfra
  module Backend
    class Base
      def receive_file(from, to = nil)
        raise NotImplementedError
      end
    end

    class Exec < Base
      def receive_file(from, to = nil)
        if to
          FileUtils.cp(from, to)
        else
          ::File.read(from)
        end
      end
    end

    class Docker < Exec
      def receive_file(from, to = nil)
        if to
          send_file(from, to)
        else
          run_command("cat #{from}").stdout
        end
      end
    end

    class Ssh < Exec
      def receive_file(from, to = nil)
        scp_download!(from, to)
      end

      private

      def scp_download!(from, to, opt={})
        if get_config(:scp).nil?
          set_config(:scp, create_scp)
        end

        scp = get_config(:scp)
        scp.download!(from, to, opt)
      end
    end
  end
end

Version data entries

27 entries across 27 versions & 1 rubygems

Version Path
itamae-1.14.1 lib/itamae/ext/specinfra.rb
itamae-1.14.0 lib/itamae/ext/specinfra.rb
itamae-1.13.1 lib/itamae/ext/specinfra.rb
itamae-1.13.0 lib/itamae/ext/specinfra.rb
itamae-1.12.6 lib/itamae/ext/specinfra.rb
itamae-1.12.5 lib/itamae/ext/specinfra.rb
itamae-1.12.4 lib/itamae/ext/specinfra.rb
itamae-1.12.3 lib/itamae/ext/specinfra.rb
itamae-1.12.2 lib/itamae/ext/specinfra.rb
itamae-1.12.1 lib/itamae/ext/specinfra.rb
itamae-1.12.0 lib/itamae/ext/specinfra.rb
itamae-1.11.2 lib/itamae/ext/specinfra.rb
itamae-1.11.1 lib/itamae/ext/specinfra.rb
itamae-1.11.0 lib/itamae/ext/specinfra.rb
itamae-1.10.10 lib/itamae/ext/specinfra.rb
itamae-1.10.9 lib/itamae/ext/specinfra.rb
itamae-1.10.8 lib/itamae/ext/specinfra.rb
itamae-1.10.7 lib/itamae/ext/specinfra.rb
itamae-1.10.6 lib/itamae/ext/specinfra.rb
itamae-1.10.5 lib/itamae/ext/specinfra.rb