Class: GetVersion::ExecutionContext

Inherits:
Object
  • Object
show all
Defined in:
lib/getversion/execution_context.rb

Instance Method Summary collapse

Constructor Details

#initialize(path) ⇒ ExecutionContext

Returns a new instance of ExecutionContext.



8
9
10
# File 'lib/getversion/execution_context.rb', line 8

def initialize(path)
  @path = path
end

Instance Method Details

#execute(&block) ⇒ Object



12
13
14
# File 'lib/getversion/execution_context.rb', line 12

def execute(&block)
  instance_eval &block
end

#find_version_in_output(arg = nil) ⇒ Object



16
17
18
19
20
# File 'lib/getversion/execution_context.rb', line 16

def find_version_in_output(arg=nil)
  output = `"#{@path}" #{arg} 2>&1`
  v = Version.match output
  v ? v.version : nil
end

#google_appengine_versionObject



22
23
24
25
26
# File 'lib/getversion/execution_context.rb', line 22

def google_appengine_version
  path = File.dirname @path
  version_file = File.join path, 'VERSION'
  YAML::load_file(version_file)['release']
end

#osx_versionObject



28
29
30
# File 'lib/getversion/execution_context.rb', line 28

def osx_version
  Executable.version('sw_vers') { find_version_in_output '-productVersion' }
end

#windows_versionObject



32
33
34
# File 'lib/getversion/execution_context.rb', line 32

def windows_version
  Executable.version('ver') { find_version_in_output }
end