Sha256: 25fa914ccab07f6d8572bb3973bf76791ba479e1792c8511af9cf2d37c39874c

Contents?: true

Size: 1.61 KB

Versions: 4

Compression:

Stored size: 1.61 KB

Contents

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

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

      class VagrantfileFromProto < Mapper
        def initialize
          super(
            inputs: [
              Input.new(type: SDK::Args::Vagrantfile),
              Input.new(type: Broker),
              Input.new(type: Util::Cacher),
            ],
            output: Client::Vagrantfile,
            func: method(:converter)
          )
        end

        def converter(proto, broker, cacher)
          cid = proto.addr.to_s if proto.addr.to_s != ""
          return cacher.get(cid) if cid && cacher.registered?(cid)

          v = Client::Vagrantfile.load(proto, broker: broker)
          cacher.register(cid, v) if cid
          v
        end
      end

      class VagrantfileFromClient < Mapper
        def initialize
          super(
            inputs: [
              Input.new(type: Client::Vagrantfile),
            ],
            output: Vagrant::Vagrantfile,
            func: method(:converter),
          )
        end

        def converter(client)
          Vagrant::Vagrantfile.new(client: client)
        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/vagrantfile.rb
tamtam-vagrant-reload-1.2.1 vendor/cache/vagrant-2092df529ae7/plugins/commands/serve/mappers/vagrantfile.rb
vagrant-unbundled-2.3.3.0 plugins/commands/serve/mappers/vagrantfile.rb
vagrant-unbundled-2.3.2.0 plugins/commands/serve/mappers/vagrantfile.rb