Module: ThorSCMVersion::Perforce
- Defined in:
- lib/thor-scmversion/p4_version.rb
Class Method Summary collapse
Class Method Details
.check_environment ⇒ Object
20 21 22 23 24 |
# File 'lib/thor-scmversion/p4_version.rb', line 20 def check_environment ["P4PORT","P4USER", "P4PASSWD", "P4CLIENT"].each {|config| raise MissingP4ConfigException.new(config) if ENV[config].nil? or ENV[config].empty? } end |
.connection ⇒ Object
42 43 44 45 46 47 48 49 |
# File 'lib/thor-scmversion/p4_version.rb', line 42 def connection parse_and_set_p4_set check_environment ShellUtils.sh "echo #{ENV["P4PASSWD"]} | p4 login" yield ensure ShellUtils.sh "p4 logout" end |
.parse_and_set_p4_set ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/thor-scmversion/p4_version.rb', line 30 def parse_and_set_p4_set p4_set = set parsed_p4_config = p4_set.split("\n").inject({}) do |p4_config, line| key, value = line.split('=') value = value.gsub(/\(.*/, '').strip unless value.nil? p4_config[key] = value p4_config end parsed_p4_config.each {|key,value| ENV[key] = value} end |
.set ⇒ Object
26 27 28 |
# File 'lib/thor-scmversion/p4_version.rb', line 26 def set ShellUtils.sh "p4 set" end |