getversion 0.0.1 → 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/getversion/detectors/apple.rb +1 -1
- data/lib/getversion/detectors/google.rb +2 -2
- data/lib/getversion/detectors/jetbrains.rb +1 -1
- data/lib/getversion/detectors/microsoft.rb +6 -6
- data/lib/getversion/detectors/rubygems.rb +3 -3
- data/lib/getversion/detectors/uncategorised.rb +4 -4
- data/lib/getversion/executable.rb +29 -0
- data/lib/getversion/execution_context.rb +43 -0
- data/lib/getversion.rb +17 -9
- metadata +3 -2
- data/lib/getversion/helpers.rb +0 -25
@@ -7,19 +7,19 @@ module GetVersion
|
|
7
7
|
end
|
8
8
|
|
9
9
|
executable 'installutil' do
|
10
|
-
find_version_in_output
|
10
|
+
find_version_in_output
|
11
11
|
end
|
12
12
|
|
13
13
|
executable 'msbuild' do
|
14
|
-
find_version_in_output
|
14
|
+
find_version_in_output '/version'
|
15
15
|
end
|
16
16
|
|
17
17
|
executable 'msdeploy' do
|
18
|
-
find_version_in_output
|
18
|
+
find_version_in_output
|
19
19
|
end
|
20
20
|
|
21
21
|
executable 'mstest' do
|
22
|
-
find_version_in_output
|
22
|
+
find_version_in_output '/help'
|
23
23
|
end
|
24
24
|
|
25
25
|
executable 'netsh' do
|
@@ -27,11 +27,11 @@ module GetVersion
|
|
27
27
|
end
|
28
28
|
|
29
29
|
executable 'nuget' do
|
30
|
-
find_version_in_output
|
30
|
+
find_version_in_output
|
31
31
|
end
|
32
32
|
|
33
33
|
executable 'tf' do
|
34
|
-
find_version_in_output
|
34
|
+
find_version_in_output
|
35
35
|
end
|
36
36
|
|
37
37
|
end
|
@@ -3,15 +3,15 @@ module GetVersion
|
|
3
3
|
namespace :rubygems
|
4
4
|
|
5
5
|
executable 'bundle' do
|
6
|
-
find_version_in_output
|
6
|
+
find_version_in_output '--version'
|
7
7
|
end
|
8
8
|
|
9
9
|
executable 'cucumber' do
|
10
|
-
find_version_in_output
|
10
|
+
find_version_in_output '--version'
|
11
11
|
end
|
12
12
|
|
13
13
|
executable 'rake' do
|
14
|
-
find_version_in_output
|
14
|
+
find_version_in_output '--version'
|
15
15
|
end
|
16
16
|
|
17
17
|
end
|
@@ -1,19 +1,19 @@
|
|
1
1
|
module GetVersion
|
2
2
|
|
3
3
|
executable 'conlinkchecker' do
|
4
|
-
find_version_in_output
|
4
|
+
find_version_in_output
|
5
5
|
end
|
6
6
|
|
7
7
|
executable 'nunit' do
|
8
|
-
find_version_in_output
|
8
|
+
find_version_in_output '/help'
|
9
9
|
end
|
10
10
|
|
11
11
|
executable '7z' do
|
12
|
-
find_version_in_output
|
12
|
+
find_version_in_output
|
13
13
|
end
|
14
14
|
|
15
15
|
executable '7za' do
|
16
|
-
find_version_in_output
|
16
|
+
find_version_in_output
|
17
17
|
end
|
18
18
|
|
19
19
|
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
require_relative 'execution_context'
|
2
|
+
require_relative 'path_finder'
|
3
|
+
require_relative 'path'
|
4
|
+
|
5
|
+
module GetVersion
|
6
|
+
class Executable
|
7
|
+
|
8
|
+
attr_reader :name, :namespace, :block
|
9
|
+
|
10
|
+
def initialize(name, namespace, &block)
|
11
|
+
@name = name
|
12
|
+
@namespace = namespace
|
13
|
+
@block = block
|
14
|
+
end
|
15
|
+
|
16
|
+
def version
|
17
|
+
c = ExecutionContext.new path
|
18
|
+
c.execute &@block
|
19
|
+
end
|
20
|
+
|
21
|
+
def path
|
22
|
+
dir = PathFinder.find_path @name
|
23
|
+
exclusions = %w(.)
|
24
|
+
exclusions.include?(dir) ? nil : dir
|
25
|
+
dir ? Path.new(dir, name).evaluated_path : @name
|
26
|
+
end
|
27
|
+
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
require_relative 'version'
|
2
|
+
|
3
|
+
module GetVersion
|
4
|
+
class ExecutionContext
|
5
|
+
|
6
|
+
def initialize(path)
|
7
|
+
@path = path
|
8
|
+
end
|
9
|
+
|
10
|
+
def execute(&block)
|
11
|
+
instance_eval &block
|
12
|
+
end
|
13
|
+
|
14
|
+
def path
|
15
|
+
@path
|
16
|
+
end
|
17
|
+
|
18
|
+
def find_version_in_output(arg=nil)
|
19
|
+
ExecutionContext.find_version_in_output @path, arg
|
20
|
+
end
|
21
|
+
|
22
|
+
def self.find_version_in_output(path, arg=nil)
|
23
|
+
output = `"#{path}" #{arg} 2>&1`
|
24
|
+
v = Version.match output
|
25
|
+
v ? v.version : nil
|
26
|
+
end
|
27
|
+
|
28
|
+
def google_appengine_version(path=@path)
|
29
|
+
path = File.dirname path
|
30
|
+
version_file = File.join path, 'VERSION'
|
31
|
+
YAML::load_file(version_file)['release']
|
32
|
+
end
|
33
|
+
|
34
|
+
def osx_version
|
35
|
+
ExecutionContext.find_version_in_output 'sw_vers', '-productVersion'
|
36
|
+
end
|
37
|
+
|
38
|
+
def windows_version
|
39
|
+
find_version_in_output 'ver'
|
40
|
+
end
|
41
|
+
|
42
|
+
end
|
43
|
+
end
|
data/lib/getversion.rb
CHANGED
@@ -1,28 +1,36 @@
|
|
1
|
-
require_relative 'getversion/
|
2
|
-
require_relative 'getversion/path'
|
3
|
-
require_relative 'getversion/helpers'
|
1
|
+
require_relative 'getversion/executable'
|
4
2
|
|
5
3
|
module GetVersion
|
6
4
|
|
7
5
|
@executables = []
|
8
6
|
|
9
7
|
def self.[](name)
|
10
|
-
executable =
|
11
|
-
|
12
|
-
path = nil if path == '.'
|
13
|
-
@exe = path ? Path.new(path, name).evaluated_path : name
|
14
|
-
instance_eval &executable[:block]
|
8
|
+
executable = find_executable(name) || executable_for_guessing(name)
|
9
|
+
executable.version
|
15
10
|
end
|
16
11
|
|
17
12
|
private
|
18
13
|
|
14
|
+
def self.executable_for_guessing(name)
|
15
|
+
Executable.new name, nil do
|
16
|
+
args = %w(--version -version /version version --help -help /help help) << nil
|
17
|
+
versions = args.map { |arg| find_version_in_output arg }.compact.uniq
|
18
|
+
versions[0] if versions.length == 1
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
def self.find_executable(name)
|
23
|
+
@executables.find { |e| e.name == name }
|
24
|
+
end
|
25
|
+
|
19
26
|
def self.namespace(namespace)
|
20
27
|
@namespace = namespace
|
21
28
|
yield if block_given?
|
22
29
|
end
|
23
30
|
|
24
31
|
def self.executable(name, &block)
|
25
|
-
|
32
|
+
executable = Executable.new name, @namespace, &block
|
33
|
+
@executables << executable
|
26
34
|
end
|
27
35
|
|
28
36
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: getversion
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -25,7 +25,8 @@ files:
|
|
25
25
|
- lib/getversion/detectors/rubygems.rb
|
26
26
|
- lib/getversion/detectors/uncategorised.rb
|
27
27
|
- lib/getversion/detectors.rb
|
28
|
-
- lib/getversion/
|
28
|
+
- lib/getversion/executable.rb
|
29
|
+
- lib/getversion/execution_context.rb
|
29
30
|
- lib/getversion/path.rb
|
30
31
|
- lib/getversion/path_finder.rb
|
31
32
|
- lib/getversion/path_finders/unix_path_finder.rb
|
data/lib/getversion/helpers.rb
DELETED
@@ -1,25 +0,0 @@
|
|
1
|
-
require_relative 'version'
|
2
|
-
|
3
|
-
module GetVersion
|
4
|
-
|
5
|
-
def self.find_version_in_output(executable, args=nil)
|
6
|
-
output = `"#{executable}" #{args} 2>&1`
|
7
|
-
v = Version.match output
|
8
|
-
v ? v.version : nil
|
9
|
-
end
|
10
|
-
|
11
|
-
def self.google_appengine_version(executable)
|
12
|
-
path = File.dirname executable
|
13
|
-
version_file = File.join path, 'VERSION'
|
14
|
-
YAML::load_file(version_file)['release']
|
15
|
-
end
|
16
|
-
|
17
|
-
def self.osx_version
|
18
|
-
find_version_in_output 'sw_vers', '-productVersion'
|
19
|
-
end
|
20
|
-
|
21
|
-
def self.windows_version
|
22
|
-
find_version_in_output 'ver'
|
23
|
-
end
|
24
|
-
|
25
|
-
end
|