Represent a registry for remote environment variables, will follow an API similar to Hash except the constructor. Currently only #has_key? is implemented.
		
			
				
	
	
		
			28 lines
		
	
	
		
			541 B
		
	
	
	
		
			Ruby
		
	
	
	
	
	
			
		
		
	
	
			28 lines
		
	
	
		
			541 B
		
	
	
	
		
			Ruby
		
	
	
	
	
	
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
 |