Sha256: e662038e41db09ca9468f789abd203a24fee5f8abad6ccd5bf636e5ccf6e33d4

Contents?: true

Size: 1.51 KB

Versions: 4

Compression:

Stored size: 1.51 KB

Contents

module VagrantPlugins
  module CommandServe
    class Mappers
      class NamedCapabilityProtoFromSpec < Mapper
        def initialize
          super(
            inputs: [
              Input.new(type: SDK::FuncSpec::Value) { |arg|
                arg.type == "hashicorp.vagrant.sdk.Args.NamedCapability" &&
                  !arg&.value&.value.nil?
              }
            ],
            output: SDK::Args::NamedCapability,
            func: method(:converter),
          )
        end

        def converter(fv)
          SDK::Args::NamedCapability.decode(fv.value.value)
        end
      end

      class NamedCapabilityFromProto < Mapper
        def initialize
          super(
            inputs: [Input.new(type: SDK::Args::NamedCapability)],
            output: Symbol,
            func: method(:converter),
          )
        end

        def converter(n)
          n.capability.to_s.to_sym
        end
      end

      # Build a machine client from a FuncSpec value
      class NamedCapabilityFromSpec < Mapper
        def initialize
          inputs = [].tap do |i|
            i << Input.new(type: SDK::FuncSpec::Value) { |arg|
              arg.type == "hashicorp.vagrant.sdk.Args.NamedCapability" &&
                !arg&.value&.value.nil?
            }
          end
          super(inputs: inputs, output: Symbol, func: method(:converter))
        end

        def converter(proto)
          SDK::Args::NamedCapability.decode(proto.value.value).
            capability.to_s.to_sym
        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/capabilities.rb
tamtam-vagrant-reload-1.2.1 vendor/cache/vagrant-2092df529ae7/plugins/commands/serve/mappers/capabilities.rb
vagrant-unbundled-2.3.3.0 plugins/commands/serve/mappers/capabilities.rb
vagrant-unbundled-2.3.2.0 plugins/commands/serve/mappers/capabilities.rb