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:
27
lib/producer/core/remote/environment.rb
Normal file
27
lib/producer/core/remote/environment.rb
Normal 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
|
Reference in New Issue
Block a user