From 3aa4e1bab4c479aeb3dbb7c8ba9af7665119b089 Mon Sep 17 00:00:00 2001 From: Chris Roberts Date: Wed, 17 Nov 2021 14:55:21 -0800 Subject: [PATCH] Add mapping for pathnames --- plugins/commands/serve/mappers.rb | 1 + plugins/commands/serve/mappers/pathname.rb | 33 ++++++++++++++++++++++ 2 files changed, 34 insertions(+) create mode 100644 plugins/commands/serve/mappers/pathname.rb diff --git a/plugins/commands/serve/mappers.rb b/plugins/commands/serve/mappers.rb index 5a06f1ffa..07e18c1ad 100644 --- a/plugins/commands/serve/mappers.rb +++ b/plugins/commands/serve/mappers.rb @@ -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 diff --git a/plugins/commands/serve/mappers/pathname.rb b/plugins/commands/serve/mappers/pathname.rb new file mode 100644 index 000000000..04d36b460 --- /dev/null +++ b/plugins/commands/serve/mappers/pathname.rb @@ -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