Sha256: 6bafbcc1d5606182a1be7828e9bf467ff6b0d98e730a4d694d35a0ca2069d050

Contents?: true

Size: 1.46 KB

Versions: 4

Compression:

Stored size: 1.46 KB

Contents

module VagrantPlugins
  module CommandServe
    class Mappers
      # Build a communicator command arguments from a FuncSpec value
      class CommunicatorCommandArgumentsFromSpec < Mapper
        def initialize
          inputs = [].tap do |i|
            i << Input.new(type: SDK::FuncSpec::Value) { |arg|
              arg.type == "hashicorp.vagrant.sdk.Communicator.Command" &&
                !arg&.value&.value.nil?
            }
          end
          super(inputs: inputs, output: SDK::Communicator::Command, func: method(:converter))
        end

        def converter(proto)
          SDK::Communicator::Command.decode(proto.value.value)
        end
      end

      class CommunicatorCommandArgumentsFromProto < Mapper
        def initialize
          super(
            inputs: [Input.new(type: SDK::Communicator::Command)],
            output: Type::CommunicatorCommandArguments,
            func: method(:converter)
          )
        end

        def converter(proto)
          Type::CommunicatorCommandArguments.new(value: proto.command)
        end
      end

      class CommunicatorCommandArgumentsToProto < Mapper
        def initialize
          super(
            inputs: [Input.new(type: Type::CommunicatorCommandArguments)],
            output: SDK::Communicator::Command,
            func: method(:converter)
          )
        end

        def converter(args)
          SDK::Communicator::Command.new(command: args.value)
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 2 rubygems

Version Path
vagrant-unbundled-2.3.6.0 plugins/commands/serve/mappers/communicator.rb
tamtam-vagrant-reload-1.2.1 vendor/cache/vagrant-2092df529ae7/plugins/commands/serve/mappers/communicator.rb
vagrant-unbundled-2.3.3.0 plugins/commands/serve/mappers/communicator.rb
vagrant-unbundled-2.3.2.0 plugins/commands/serve/mappers/communicator.rb