class Reviewer::Command::String::Env
Assembles tool environment variables into a single string or array
Attributes
env_pairs[R]
Public Class Methods
new(env_pairs)
click to toggle source
# File lib/reviewer/command/string/env.rb, line 10 def initialize(env_pairs) @env_pairs = env_pairs end
Public Instance Methods
to_a()
click to toggle source
# File lib/reviewer/command/string/env.rb, line 18 def to_a env = [] env_pairs.each { |key, value| env << env(key, value) } env end
to_s()
click to toggle source
# File lib/reviewer/command/string/env.rb, line 14 def to_s to_a.compact.join(' ') end
Private Instance Methods
env(key, value)
click to toggle source
# File lib/reviewer/command/string/env.rb, line 26 def env(key, value) return nil if key.to_s.strip.empty? || value.to_s.strip.empty? value = needs_quotes?(value) ? "'#{value}'" : value "#{key.to_s.strip.upcase}=#{value.to_s.strip}" end
needs_quotes?(value)
click to toggle source
# File lib/reviewer/command/string/env.rb, line 34 def needs_quotes?(value) value.is_a?(::String) && value.include?(' ') end