Implement basic Remote::Environment class:

Represent a registry for remote environment variables, will follow an
API similar to Hash except the constructor. Currently only #has_key? is
implemented.
This commit is contained in:
Thibault Jouan
2013-08-18 20:02:53 +00:00
parent ed99c191e0
commit 513ba4eedb
3 changed files with 62 additions and 0 deletions

View File

@@ -0,0 +1,27 @@
module Producer
module Core
class Remote
class Environment
require 'forwardable'
extend Forwardable
def_delegator :@variables, :has_key?
def initialize(variables)
case variables
when String
@variables = parse_from_string variables
else
@variables = variables
end
end
private
def parse_from_string(str)
Hash[str.each_line.map { |l| l.chomp.split '=', 2 }]
end
end
end
end
end