Add mapping for pathnames

This commit is contained in:
Chris Roberts 2021-11-17 14:55:21 -08:00 committed by Paul Hinze
parent a0797da229
commit 3aa4e1bab4
No known key found for this signature in database
GPG Key ID: B69DEDF2D55501C0
2 changed files with 34 additions and 0 deletions

View File

@ -208,6 +208,7 @@ require Vagrant.source_root.join("plugins/commands/serve/mappers/environment.rb"
require Vagrant.source_root.join("plugins/commands/serve/mappers/guest.rb").to_s
require Vagrant.source_root.join("plugins/commands/serve/mappers/known_types.rb").to_s
require Vagrant.source_root.join("plugins/commands/serve/mappers/machine.rb").to_s
require Vagrant.source_root.join("plugins/commands/serve/mappers/pathname.rb").to_s
require Vagrant.source_root.join("plugins/commands/serve/mappers/project.rb").to_s
require Vagrant.source_root.join("plugins/commands/serve/mappers/state_bag.rb").to_s
require Vagrant.source_root.join("plugins/commands/serve/mappers/target.rb").to_s

View File

@ -0,0 +1,33 @@
module VagrantPlugins
module CommandServe
class Mappers
class PathnameToProto < Mapper
def initialize
super(
inputs: [Input.new(type: Pathname)],
output: SDK::Args::Path,
func: method(:converter),
)
end
def converter(path)
SDK::Args::Path.new(path: path.to_s)
end
end
class PathnameFromProto < Mapper
def initialize
super(
inputs: [Input.new(type: SDK::Args::Path)],
output: Pathname,
func: method(:converter),
)
end
def converter(path)
Pathname.new(path.path)
end
end
end
end
end