getversion 0.0.10 → 0.0.11

Sign up to get free protection for your applications and to get access to all the features.
data/bin/getversion.rb CHANGED
@@ -1,7 +1,7 @@
1
- require_relative '../lib/getversion'
2
-
3
- name = ARGV[0]
4
- should_guess = ARGV[1] && ARGV[1] == '--guess'
5
-
6
- version = should_guess ? GetVersion.guess(name) : GetVersion[name]
1
+ require_relative '../lib/getversion'
2
+
3
+ name = ARGV[0]
4
+ should_guess = ARGV[1] && ARGV[1] == '--guess'
5
+
6
+ version = should_guess ? GetVersion.guess(name) : GetVersion[name]
7
7
  puts version || 'unknown'
data/lib/getversion.rb CHANGED
@@ -1,31 +1,31 @@
1
- require_relative 'getversion/executable_store'
2
- require_relative 'getversion/version_finder'
3
-
4
- module GetVersion
5
-
6
- @executable_store = ExecutableStore.new
7
-
8
- def self.[](path)
9
- version_finder(path).get_version
10
- end
11
-
12
- def self.guess(path)
13
- version_finder(path).guess_version
14
- end
15
-
16
- private
17
-
18
- def self.version_finder(path)
19
- VersionFinder.new(path, @executable_store)
20
- end
21
-
22
- def self.namespace(namespace)
23
- @namespace = namespace
24
- end
25
-
26
- def self.executable(name, &block)
27
- @executable_store.add_executable name, @namespace, &block
28
- end
29
-
30
- require_relative 'getversion/detectors'
1
+ require_relative 'getversion/executable_store'
2
+ require_relative 'getversion/version_finder'
3
+
4
+ module GetVersion
5
+
6
+ @executable_store = ExecutableStore.new
7
+
8
+ def self.[](path)
9
+ version_finder(path).get_version
10
+ end
11
+
12
+ def self.guess(path)
13
+ version_finder(path).guess_version
14
+ end
15
+
16
+ private
17
+
18
+ def self.version_finder(path)
19
+ VersionFinder.new(path, @executable_store)
20
+ end
21
+
22
+ def self.namespace(namespace)
23
+ @namespace = namespace
24
+ end
25
+
26
+ def self.executable(name, &block)
27
+ @executable_store.add_executable name, @namespace, &block
28
+ end
29
+
30
+ require_relative 'getversion/detectors'
31
31
  end
@@ -1,13 +1,13 @@
1
- module GetVersion
2
-
3
- namespace :apple
4
-
5
- executable :security do
6
- osx_version
7
- end
8
-
9
- executable :xcodebuild do
10
- find_version_in_output '-version'
11
- end
12
-
1
+ module GetVersion
2
+
3
+ namespace :apple
4
+
5
+ executable :security do
6
+ osx_version
7
+ end
8
+
9
+ executable :xcodebuild do
10
+ find_version_in_output '-version'
11
+ end
12
+
13
13
  end
@@ -1,13 +1,13 @@
1
- module GetVersion
2
-
3
- namespace :google
4
-
5
- executable :appcfg do
6
- google_appengine_version
7
- end
8
-
9
- executable :dev_appserver do
10
- google_appengine_version
11
- end
12
-
1
+ module GetVersion
2
+
3
+ namespace :google
4
+
5
+ executable :appcfg do
6
+ google_appengine_version
7
+ end
8
+
9
+ executable :dev_appserver do
10
+ google_appengine_version
11
+ end
12
+
13
13
  end
@@ -1,9 +1,9 @@
1
- module GetVersion
2
-
3
- namespace :jetbrains
4
-
5
- executable :dotcover do
6
- find_version_in_output
7
- end
8
-
1
+ module GetVersion
2
+
3
+ namespace :jetbrains
4
+
5
+ executable :dotcover do
6
+ find_version_in_output
7
+ end
8
+
9
9
  end
@@ -1,37 +1,37 @@
1
- module GetVersion
2
-
3
- namespace :microsoft
4
-
5
- executable :aspnet_compiler do
6
- GetVersion['msbuild']
7
- end
8
-
9
- executable :installutil do
10
- find_version_in_output
11
- end
12
-
13
- executable :msbuild do
14
- find_version_in_output '/version'
15
- end
16
-
17
- executable :msdeploy do
18
- find_version_in_output
19
- end
20
-
21
- executable :mstest do
22
- find_version_in_output '/help'
23
- end
24
-
25
- executable :netsh do
26
- windows_version
27
- end
28
-
29
- executable :nuget do
30
- find_version_in_output
31
- end
32
-
33
- executable :tf do
34
- find_version_in_output
35
- end
36
-
1
+ module GetVersion
2
+
3
+ namespace :microsoft
4
+
5
+ executable :aspnet_compiler do
6
+ GetVersion['msbuild']
7
+ end
8
+
9
+ executable :installutil do
10
+ find_version_in_output
11
+ end
12
+
13
+ executable :msbuild do
14
+ find_version_in_output '/version'
15
+ end
16
+
17
+ executable :msdeploy do
18
+ find_version_in_output
19
+ end
20
+
21
+ executable :mstest do
22
+ find_version_in_output '/help'
23
+ end
24
+
25
+ executable :netsh do
26
+ windows_version
27
+ end
28
+
29
+ executable :nuget do
30
+ find_version_in_output
31
+ end
32
+
33
+ executable :tf do
34
+ find_version_in_output
35
+ end
36
+
37
37
  end
@@ -1,17 +1,17 @@
1
- module GetVersion
2
-
3
- namespace :rubygems
4
-
5
- executable :bundle do
6
- find_version_in_output '--version'
7
- end
8
-
9
- executable :cucumber do
10
- find_version_in_output '--version'
11
- end
12
-
13
- executable :rake do
14
- find_version_in_output '--version'
15
- end
16
-
1
+ module GetVersion
2
+
3
+ namespace :rubygems
4
+
5
+ executable :bundle do
6
+ find_version_in_output '--version'
7
+ end
8
+
9
+ executable :cucumber do
10
+ find_version_in_output '--version'
11
+ end
12
+
13
+ executable :rake do
14
+ find_version_in_output '--version'
15
+ end
16
+
17
17
  end
@@ -1,19 +1,19 @@
1
- module GetVersion
2
-
3
- executable :conlinkchecker do
4
- find_version_in_output
5
- end
6
-
7
- executable :nunit do
8
- find_version_in_output '/help'
9
- end
10
-
11
- executable '7z' do
12
- find_version_in_output
13
- end
14
-
15
- executable '7za' do
16
- find_version_in_output
17
- end
18
-
1
+ module GetVersion
2
+
3
+ executable :conlinkchecker do
4
+ find_version_in_output
5
+ end
6
+
7
+ executable 'nunit-console' do
8
+ find_version_in_output '/help'
9
+ end
10
+
11
+ executable '7z' do
12
+ find_version_in_output
13
+ end
14
+
15
+ executable '7za' do
16
+ find_version_in_output
17
+ end
18
+
19
19
  end
@@ -1,22 +1,22 @@
1
- require 'wicked_witch'
2
- require_relative 'execution_context'
3
-
4
- module GetVersion
5
- class Executable
6
-
7
- attr_reader :block
8
-
9
- def initialize(&block)
10
- @block = block || Proc.new {}
11
- end
12
-
13
- def version(path)
14
- ExecutionContext.execute path, &@block
15
- end
16
-
17
- def self.version(path, &block)
18
- Executable.new(&block).version(path)
19
- end
20
-
21
- end
1
+ require 'wicked_witch'
2
+ require_relative 'execution_context'
3
+
4
+ module GetVersion
5
+ class Executable
6
+
7
+ attr_reader :block
8
+
9
+ def initialize(&block)
10
+ @block = block || Proc.new {}
11
+ end
12
+
13
+ def version(path)
14
+ ExecutionContext.execute path, &@block
15
+ end
16
+
17
+ def self.version(path, &block)
18
+ Executable.new(&block).version(path)
19
+ end
20
+
21
+ end
22
22
  end
@@ -1,23 +1,23 @@
1
- require_relative 'executable'
2
-
3
- module GetVersion
4
- class ExecutableStore
5
-
6
- def initialize
7
- @executables = []
8
- end
9
-
10
- def add_executable(name, namespace, &block)
11
- @executables << {name: name.to_sym, namespace: namespace.to_sym, value: Executable.new(&block)}
12
- end
13
-
14
- def get_executable(path)
15
- basename = File.basename path
16
- name = basename == path ? path : basename
17
- possibilities = [name, File.basename(name, '.*')]
18
- executable = @executables.find { |e| possibilities.find { |p| p.casecmp(e[:name].to_s) == 0 } }
19
- executable[:value] if executable
20
- end
21
-
22
- end
1
+ require_relative 'executable'
2
+
3
+ module GetVersion
4
+ class ExecutableStore
5
+
6
+ def initialize
7
+ @executables = []
8
+ end
9
+
10
+ def add_executable(name, namespace, &block)
11
+ @executables << {name: name.to_sym, namespace: namespace.to_sym, value: Executable.new(&block)}
12
+ end
13
+
14
+ def get_executable(path)
15
+ basename = File.basename path
16
+ name = basename == path ? path : basename
17
+ possibilities = [name, File.basename(name, '.*')]
18
+ executable = @executables.find { |e| possibilities.find { |p| p.casecmp(e[:name].to_s) == 0 } }
19
+ executable[:value] if executable
20
+ end
21
+
22
+ end
23
23
  end
@@ -1,25 +1,26 @@
1
- require_relative 'platform_versions'
2
-
3
- module GetVersion
4
- class ExecutionContext
5
-
6
- include PlatformVersions
7
-
8
- def initialize(path)
9
- @path = path
10
- end
11
-
12
- def execute(&block)
13
- instance_eval &block
14
- end
15
-
16
- def self.execute(path, &block)
17
- ExecutionContext.new(path).execute(&block)
18
- end
19
-
20
- def find_version_in_output(arg=nil)
21
- `"#{@path}" #{arg} 2>&1`[/(\d+\.)+\d+/]
22
- end
23
-
24
- end
1
+ require_relative 'platform_versions'
2
+
3
+ module GetVersion
4
+ class ExecutionContext
5
+
6
+ include PlatformVersions
7
+
8
+ def initialize(path)
9
+ @path = path
10
+ end
11
+
12
+ def execute(&block)
13
+ instance_eval &block
14
+ end
15
+
16
+ def self.execute(path, &block)
17
+ ExecutionContext.new(path).execute(&block)
18
+ end
19
+
20
+ def find_version_in_output(arg=nil)
21
+ path = @path.include?(' ') ? %Q["#{@path}"] : @path
22
+ `#{path} #{arg} 2>&1`[/(\d+\.)+\d+/]
23
+ end
24
+
25
+ end
25
26
  end
@@ -1,26 +1,26 @@
1
- require 'pathname'
2
- require 'yaml'
3
- require 'wicked_witch'
4
- require_relative 'executable'
5
-
6
- module GetVersion
7
- module PlatformVersions
8
-
9
- def google_appengine_version
10
- has_dir = File.basename(@path) != @path
11
- realpath = has_dir ? Pathname.new(@path).realpath.to_s : WickedWitch[@path]
12
- dir = File.dirname realpath
13
- version_file = File.join dir, 'VERSION'
14
- YAML::load_file(version_file)['release']
15
- end
16
-
17
- def osx_version
18
- Executable.version('sw_vers') { find_version_in_output '-productVersion' }
19
- end
20
-
21
- def windows_version
22
- Executable.version('ver') { find_version_in_output }
23
- end
24
-
25
- end
1
+ require 'pathname'
2
+ require 'yaml'
3
+ require 'wicked_witch'
4
+ require_relative 'executable'
5
+
6
+ module GetVersion
7
+ module PlatformVersions
8
+
9
+ def google_appengine_version
10
+ has_dir = File.basename(@path) != @path
11
+ realpath = has_dir ? Pathname.new(@path).realpath.to_s : WickedWitch[@path]
12
+ dir = File.dirname realpath
13
+ version_file = File.join dir, 'VERSION'
14
+ YAML::load_file(version_file)['release']
15
+ end
16
+
17
+ def osx_version
18
+ Executable.version('sw_vers') { find_version_in_output '-productVersion' }
19
+ end
20
+
21
+ def windows_version
22
+ Executable.version('ver') { find_version_in_output }
23
+ end
24
+
25
+ end
26
26
  end
@@ -1,39 +1,39 @@
1
- require_relative 'executable'
2
-
3
- module GetVersion
4
- class VersionFinder
5
-
6
- def initialize(executable_path, executable_store)
7
- @path = executable_path
8
- @executable_store = executable_store
9
- end
10
-
11
- def get_version
12
- get null_executable
13
- end
14
-
15
- def guess_version
16
- get executable_for_guessing
17
- end
18
-
19
- private
20
-
21
- def get(executable_if_nil)
22
- executable = @executable_store.get_executable(@path) || executable_if_nil
23
- executable.version @path
24
- end
25
-
26
- def null_executable
27
- Executable.new
28
- end
29
-
30
- def executable_for_guessing
31
- Executable.new do
32
- args = %w(--version -version /version version --help -help /help help) << nil
33
- versions = args.map { |arg| find_version_in_output arg }.compact.uniq
34
- versions[0] if versions.length == 1
35
- end
36
- end
37
-
38
- end
1
+ require_relative 'executable'
2
+
3
+ module GetVersion
4
+ class VersionFinder
5
+
6
+ def initialize(executable_path, executable_store)
7
+ @path = executable_path
8
+ @executable_store = executable_store
9
+ end
10
+
11
+ def get_version
12
+ get null_executable
13
+ end
14
+
15
+ def guess_version
16
+ get executable_for_guessing
17
+ end
18
+
19
+ private
20
+
21
+ def get(executable_if_nil)
22
+ executable = @executable_store.get_executable(@path) || executable_if_nil
23
+ executable.version @path
24
+ end
25
+
26
+ def null_executable
27
+ Executable.new
28
+ end
29
+
30
+ def executable_for_guessing
31
+ Executable.new do
32
+ args = %w(--version -version /version version --help -help /help help) << nil
33
+ versions = args.map { |arg| find_version_in_output arg }.compact.uniq
34
+ versions[0] if versions.length == 1
35
+ end
36
+ end
37
+
38
+ end
39
39
  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.10
4
+ version: 0.0.11
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-08-03 00:00:00.000000000 Z
12
+ date: 2013-08-07 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: wicked_witch
16
- requirement: &70232585889500 !ruby/object:Gem::Requirement
16
+ requirement: !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ~>
@@ -21,10 +21,15 @@ dependencies:
21
21
  version: 0.0.3
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70232585889500
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ~>
28
+ - !ruby/object:Gem::Version
29
+ version: 0.0.3
25
30
  - !ruby/object:Gem::Dependency
26
31
  name: test-unit
27
- requirement: &70232585905400 !ruby/object:Gem::Requirement
32
+ requirement: !ruby/object:Gem::Requirement
28
33
  none: false
29
34
  requirements:
30
35
  - - ~>
@@ -32,7 +37,12 @@ dependencies:
32
37
  version: 2.5.5
33
38
  type: :development
34
39
  prerelease: false
35
- version_requirements: *70232585905400
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ~>
44
+ - !ruby/object:Gem::Version
45
+ version: 2.5.5
36
46
  description: Provides a standard interface for obtaining CLI application version numbers.
37
47
  email: matthew@matthewriley.name
38
48
  executables:
@@ -53,8 +63,7 @@ files:
53
63
  - lib/getversion/platform_versions.rb
54
64
  - lib/getversion/version_finder.rb
55
65
  - lib/getversion.rb
56
- - !binary |-
57
- YmluL2dldHZlcnNpb24ucmI=
66
+ - bin/getversion.rb
58
67
  homepage: http://rubygems.org/gems/getversion
59
68
  licenses: []
60
69
  post_install_message:
@@ -75,7 +84,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
75
84
  version: '0'
76
85
  requirements: []
77
86
  rubyforge_project:
78
- rubygems_version: 1.8.15
87
+ rubygems_version: 1.8.24
79
88
  signing_key:
80
89
  specification_version: 3
81
90
  summary: Provides a standard interface for obtaining CLI application version numbers.