fluent_command_builder 0.8.18 → 0.9.0

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.
Files changed (88) hide show
  1. data/lib/fluent_command_builder.rb +2 -65
  2. data/lib/fluent_command_builder/command_builder.rb +2 -2
  3. data/lib/fluent_command_builder/command_builders/appcfg_python.rb +2 -1
  4. data/lib/fluent_command_builder/command_builders/appcfg_python_16.rb +5 -4
  5. data/lib/fluent_command_builder/command_builders/appcfg_python_17.rb +5 -4
  6. data/lib/fluent_command_builder/command_builders/aspnet_compiler.rb +2 -1
  7. data/lib/fluent_command_builder/command_builders/aspnet_compiler_20.rb +5 -4
  8. data/lib/fluent_command_builder/command_builders/aspnet_compiler_40.rb +5 -4
  9. data/lib/fluent_command_builder/command_builders/bundle.rb +2 -1
  10. data/lib/fluent_command_builder/command_builders/bundle_11.rb +5 -4
  11. data/lib/fluent_command_builder/command_builders/cucumber.rb +2 -1
  12. data/lib/fluent_command_builder/command_builders/cucumber_11.rb +5 -4
  13. data/lib/fluent_command_builder/command_builders/cucumber_12.rb +5 -4
  14. data/lib/fluent_command_builder/command_builders/dev_appserver_python.rb +2 -1
  15. data/lib/fluent_command_builder/command_builders/dev_appserver_python_16.rb +5 -4
  16. data/lib/fluent_command_builder/command_builders/dev_appserver_python_17.rb +5 -4
  17. data/lib/fluent_command_builder/command_builders/dotcover.rb +2 -1
  18. data/lib/fluent_command_builder/command_builders/dotcover_10.rb +5 -4
  19. data/lib/fluent_command_builder/command_builders/dotcover_11.rb +5 -4
  20. data/lib/fluent_command_builder/command_builders/dotcover_12.rb +5 -4
  21. data/lib/fluent_command_builder/command_builders/dotcover_20.rb +5 -4
  22. data/lib/fluent_command_builder/command_builders/fastlinkchecker.rb +2 -1
  23. data/lib/fluent_command_builder/command_builders/fastlinkchecker_21.rb +5 -4
  24. data/lib/fluent_command_builder/command_builders/installutil.rb +2 -1
  25. data/lib/fluent_command_builder/command_builders/installutil_11.rb +5 -4
  26. data/lib/fluent_command_builder/command_builders/installutil_20.rb +5 -4
  27. data/lib/fluent_command_builder/command_builders/installutil_35.rb +5 -4
  28. data/lib/fluent_command_builder/command_builders/installutil_40.rb +5 -4
  29. data/lib/fluent_command_builder/command_builders/msbuild.rb +2 -1
  30. data/lib/fluent_command_builder/command_builders/msbuild_20.rb +5 -4
  31. data/lib/fluent_command_builder/command_builders/msbuild_30.rb +5 -4
  32. data/lib/fluent_command_builder/command_builders/msbuild_35.rb +5 -4
  33. data/lib/fluent_command_builder/command_builders/msbuild_40.rb +5 -4
  34. data/lib/fluent_command_builder/command_builders/msdeploy.rb +2 -1
  35. data/lib/fluent_command_builder/command_builders/msdeploy_71.rb +5 -4
  36. data/lib/fluent_command_builder/command_builders/mstest.rb +2 -1
  37. data/lib/fluent_command_builder/command_builders/mstest_100.rb +5 -4
  38. data/lib/fluent_command_builder/command_builders/mstest_80.rb +5 -4
  39. data/lib/fluent_command_builder/command_builders/mstest_90.rb +5 -4
  40. data/lib/fluent_command_builder/command_builders/netsh.rb +2 -1
  41. data/lib/fluent_command_builder/command_builders/netsh_61.rb +5 -4
  42. data/lib/fluent_command_builder/command_builders/nuget.rb +2 -1
  43. data/lib/fluent_command_builder/command_builders/nuget_20.rb +5 -4
  44. data/lib/fluent_command_builder/command_builders/nunit.rb +2 -1
  45. data/lib/fluent_command_builder/command_builders/nunit_25.rb +5 -4
  46. data/lib/fluent_command_builder/command_builders/nunit_26.rb +5 -4
  47. data/lib/fluent_command_builder/command_builders/rake.rb +2 -1
  48. data/lib/fluent_command_builder/command_builders/rake_09.rb +5 -4
  49. data/lib/fluent_command_builder/command_builders/security_osx.rb +2 -1
  50. data/lib/fluent_command_builder/command_builders/security_osx_107.rb +5 -4
  51. data/lib/fluent_command_builder/command_builders/security_osx_108.rb +5 -4
  52. data/lib/fluent_command_builder/command_builders/sevenzip.rb +2 -1
  53. data/lib/fluent_command_builder/command_builders/sevenzip_920.rb +5 -4
  54. data/lib/fluent_command_builder/command_builders/simian.rb +2 -1
  55. data/lib/fluent_command_builder/command_builders/simian_23.rb +5 -4
  56. data/lib/fluent_command_builder/command_builders/team_foundation.rb +2 -1
  57. data/lib/fluent_command_builder/command_builders/team_foundation_100.rb +5 -4
  58. data/lib/fluent_command_builder/command_builders/team_foundation_tee.rb +2 -1
  59. data/lib/fluent_command_builder/command_builders/team_foundation_tee_100.rb +5 -4
  60. data/lib/fluent_command_builder/command_builders/team_foundation_tee_101.rb +5 -4
  61. data/lib/fluent_command_builder/command_builders/xcodebuild.rb +2 -1
  62. data/lib/fluent_command_builder/command_builders/xcodebuild_43.rb +5 -4
  63. data/lib/fluent_command_builder/command_builders/xcodebuild_44.rb +5 -4
  64. data/lib/fluent_command_builder/command_builders/xcodebuild_45.rb +331 -0
  65. data/lib/fluent_command_builder/execution_context.rb +2 -4
  66. data/lib/fluent_command_builder/{argument_formatter.rb → internal/argument_formatter.rb} +8 -6
  67. data/lib/fluent_command_builder/{command_base.rb → internal/command_base.rb} +0 -0
  68. data/lib/fluent_command_builder/internal/command_builder_config.rb +57 -0
  69. data/lib/fluent_command_builder/{path_finder.rb → internal/path_finder.rb} +19 -19
  70. data/lib/fluent_command_builder/{path_finders → internal/path_finders}/unix_path_finder.rb +12 -12
  71. data/lib/fluent_command_builder/{path_finders → internal/path_finders}/windows_path_finder.rb +13 -13
  72. data/lib/fluent_command_builder/internal/path_validator.rb +54 -0
  73. data/lib/fluent_command_builder/{printer.rb → internal/printer.rb} +5 -5
  74. data/lib/fluent_command_builder/{underlying_builder.rb → internal/underlying_builder.rb} +12 -6
  75. data/lib/fluent_command_builder/{version.rb → internal/version.rb} +12 -17
  76. data/lib/fluent_command_builder/internal/version_detectors.rb +1 -0
  77. data/lib/fluent_command_builder/{version_detectors → internal/version_detectors}/appengine_python_version_detector.rb +1 -0
  78. data/lib/fluent_command_builder/{version_detectors → internal/version_detectors}/default_version_detector.rb +1 -0
  79. data/lib/fluent_command_builder/{version_detectors → internal/version_detectors}/osx_version_detector.rb +0 -0
  80. data/lib/fluent_command_builder/{version_detectors → internal/version_detectors}/standard_version_detector.rb +9 -6
  81. data/lib/fluent_command_builder/{version_detectors → internal/version_detectors}/windows_version_detector.rb +0 -0
  82. data/lib/fluent_command_builder/{version_validator.rb → internal/version_validator.rb} +26 -23
  83. data/lib/fluent_command_builder/password_formatter.rb +22 -0
  84. metadata +25 -24
  85. data/lib/fluent_command_builder/command_builder_config.rb +0 -51
  86. data/lib/fluent_command_builder/command_formatters/hidden_password_formatter.rb +0 -17
  87. data/lib/fluent_command_builder/command_formatters/null_formatter.rb +0 -9
  88. data/lib/fluent_command_builder/path_validator.rb +0 -27
@@ -1,15 +1,13 @@
1
- require File.expand_path(File.dirname(__FILE__) + '/printer')
1
+ require File.expand_path(File.dirname(__FILE__) + '/internal/printer')
2
2
  require File.expand_path(File.dirname(__FILE__) + '/command_executors/system_executor')
3
- require File.expand_path(File.dirname(__FILE__) + '/command_formatters/null_formatter')
4
3
 
5
4
  module FluentCommandBuilder
6
5
  class ExecutionContext
7
6
 
8
- attr_accessor :executor, :formatter, :should_print_on_execute, :should_fail_on_error
7
+ attr_accessor :executor, :printer, :should_print_on_execute, :should_fail_on_error
9
8
 
10
9
  def initialize(executor)
11
10
  @executor = executor
12
- @formatter = NullFormatter.new
13
11
  @should_print_on_execute = true
14
12
  @should_fail_on_error = true
15
13
  @printer = FluentCommandBuilder::Printer.new
@@ -16,6 +16,14 @@ module FluentCommandBuilder
16
16
  end
17
17
  end
18
18
 
19
+ def format_password(value)
20
+ password = quote_if_includes_space value.to_s
21
+ @passwords << password
22
+ password
23
+ end
24
+
25
+ private
26
+
19
27
  def format_hash(hash, delimiter, key_value_separator)
20
28
  hash.map { |k, v| quote_if_includes_space(k.to_s) + key_value_separator + quote_if_includes_space(v.to_s) }.join delimiter
21
29
  end
@@ -24,12 +32,6 @@ module FluentCommandBuilder
24
32
  array.map { |v| quote_if_includes_space v }.join delimiter
25
33
  end
26
34
 
27
- def format_password(value)
28
- password = quote_if_includes_space value.to_s
29
- @passwords << password
30
- password
31
- end
32
-
33
35
  def quote_if_includes_space(value)
34
36
  value.to_s.include?(' ') ? %Q["#{value}"] : value
35
37
  end
@@ -0,0 +1,57 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/path_validator')
2
+ require File.expand_path(File.dirname(__FILE__) + '/version_validator')
3
+ require File.expand_path(File.dirname(__FILE__) + '/version_detectors/default_version_detector')
4
+
5
+ module FluentCommandBuilder
6
+ class CommandBuilderConfig
7
+
8
+ attr_accessor :path, :command_name, :version, :version_detector,
9
+ :path_validation_level, :version_validation_level,
10
+ :path_validator, :version_validator,
11
+ :is_windows
12
+
13
+ def initialize(command_name, version=nil)
14
+ @path = nil
15
+ @command_name = command_name
16
+ @version = version
17
+ @version_detector = DefaultVersionDetector.new command_name
18
+ @path_validation_level = :fatal
19
+ @version_validation_level = :fatal
20
+ @path_validator = PathValidator.new self
21
+ @version_validator = VersionValidator.new self
22
+ @is_windows = !ENV['WINDIR'].nil?
23
+ end
24
+
25
+ def validate_path
26
+ @path_validator.validate
27
+ end
28
+
29
+ def validate_version
30
+ @version_validator.validate if @version
31
+ end
32
+
33
+ def executable
34
+ e = @path ? File.join(@path, @command_name) : @command_name
35
+ normalise_path e
36
+ end
37
+
38
+ def evaluated_executable
39
+ evaluate_path executable
40
+ end
41
+
42
+ def evaluated_path
43
+ evaluate_path @path if @path
44
+ end
45
+
46
+ private
47
+
48
+ def evaluate_path(path)
49
+ `echo #{normalise_path path}`.strip
50
+ end
51
+
52
+ def normalise_path(path)
53
+ @is_windows ? path.gsub('/', '\\') : path.gsub('\\', '/')
54
+ end
55
+
56
+ end
57
+ end
@@ -1,20 +1,20 @@
1
- require File.expand_path(File.dirname(__FILE__) + '/path_finders/unix_path_finder')
2
- require File.expand_path(File.dirname(__FILE__) + '/path_finders/windows_path_finder')
3
-
4
- module FluentCommandBuilder
5
-
6
- def self.path_finder
7
- @path_finder ||= is_windows? ? WindowsPathFinder.new : UnixPathFinder.new
8
- end
9
-
10
- def self.path_finder=(value)
11
- @path_finder = value
12
- end
13
-
14
- private
15
-
16
- def self.is_windows?
17
- !ENV['WINDIR'].nil?
18
- end
19
-
1
+ require File.expand_path(File.dirname(__FILE__) + '/path_finders/unix_path_finder')
2
+ require File.expand_path(File.dirname(__FILE__) + '/path_finders/windows_path_finder')
3
+
4
+ module FluentCommandBuilder
5
+
6
+ def self.path_finder
7
+ @path_finder ||= is_windows? ? WindowsPathFinder.new : UnixPathFinder.new
8
+ end
9
+
10
+ def self.path_finder=(value)
11
+ @path_finder = value
12
+ end
13
+
14
+ private
15
+
16
+ def self.is_windows?
17
+ !ENV['WINDIR'].nil?
18
+ end
19
+
20
20
  end
@@ -1,13 +1,13 @@
1
- module FluentCommandBuilder
2
- class UnixPathFinder
3
-
4
- def find_path(executable_name)
5
- executable = `which #{executable_name}`
6
- real_executable = `readlink #{executable}`.strip
7
- result = real_executable == '' ? executable : real_executable
8
- return unless result
9
- File.dirname result
10
- end
11
-
12
- end
1
+ module FluentCommandBuilder
2
+ class UnixPathFinder
3
+
4
+ def find_path(executable_name)
5
+ executable = `which #{executable_name}`
6
+ real_executable = `readlink #{executable}`.strip
7
+ result = real_executable == '' ? executable : real_executable
8
+ return unless result
9
+ File.dirname result
10
+ end
11
+
12
+ end
13
13
  end
@@ -1,14 +1,14 @@
1
- module FluentCommandBuilder
2
- class WindowsPathFinder
3
-
4
- def find_path(executable_name)
5
- paths = ENV['PATH'].split ';'
6
- extensions = ENV['PATHEXT'].split ';'
7
- possibilities = paths.map { |path| extensions.map { |ext| File.join(path, executable_name + ext.downcase).gsub('/', '\\') } }.flatten
8
- executable = possibilities.select { |exe| File.exist? exe }.first
9
- return unless executable
10
- File.dirname executable
11
- end
12
-
13
- end
1
+ module FluentCommandBuilder
2
+ class WindowsPathFinder
3
+
4
+ def find_path(executable_name)
5
+ paths = ENV['PATH'].split ';'
6
+ extensions = ENV['PATHEXT'].split ';'
7
+ possibilities = paths.map { |path| extensions.map { |ext| File.join(path, executable_name + ext.downcase).gsub('/', '\\') } }.flatten
8
+ executable = possibilities.select { |exe| File.exist? exe }.first
9
+ return unless executable
10
+ File.dirname executable
11
+ end
12
+
13
+ end
14
14
  end
@@ -0,0 +1,54 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/printer')
2
+
3
+ module FluentCommandBuilder
4
+ class PathValidator
5
+
6
+ attr_accessor :path_finder, :printer, :should_abort_on_fatal
7
+
8
+ def initialize(command_builder_config)
9
+ @c = command_builder_config
10
+ @path_finder = FluentCommandBuilder.path_finder
11
+ @printer = Printer.new
12
+ @should_abort_on_fatal = true
13
+ end
14
+
15
+ def validate
16
+ validate_validation_level
17
+ return if validation_level == :off
18
+
19
+ if @c.path
20
+ path = @c.evaluated_path
21
+ return if File.exist? path
22
+ message = %Q[Path for command "#{@c.command_name}", version "#{@c.version}" does not exist. Path: #{path}]
23
+ else
24
+ return if @path_finder.find_path @c.command_name
25
+ message = %Q[Command "#{@c.command_name}" was not found on the PATH.]
26
+ end
27
+
28
+ case validation_level
29
+ when :warn
30
+ @printer.print_warning message
31
+ when :fatal
32
+ @printer.print_error message
33
+ abort if @should_abort_on_fatal
34
+ else
35
+ # do nothing
36
+ end
37
+ end
38
+
39
+ private
40
+
41
+ def validation_level
42
+ @c.path_validation_level
43
+ end
44
+
45
+ def validate_validation_level
46
+ raise %Q[Validation level "#{validation_level}" is not supported.] unless validation_level_valid?
47
+ end
48
+
49
+ def validation_level_valid?
50
+ [:off, :warn, :fatal].include? validation_level
51
+ end
52
+
53
+ end
54
+ end
@@ -5,18 +5,18 @@ module FluentCommandBuilder
5
5
  include Term::ANSIColor
6
6
 
7
7
  def print_warning(message)
8
- print yellow, 'WARNING: ', message, reset, "\n"
9
- STDOUT.flush
8
+ $stderr.print yellow, 'Warning: ', message, reset, "\n"
9
+ $stderr.flush
10
10
  end
11
11
 
12
12
  def print_error(message)
13
- print red, 'ERROR: ', message, reset, "\n"
14
- STDOUT.flush
13
+ $stderr.print red, 'Error: ', message, reset, "\n"
14
+ $stderr.flush
15
15
  end
16
16
 
17
17
  def print_command(command)
18
18
  print magenta, command, reset, "\n"
19
- STDOUT.flush
19
+ $stdout.flush
20
20
  end
21
21
 
22
22
  end
@@ -1,16 +1,18 @@
1
1
  require File.expand_path(File.dirname(__FILE__) + '/argument_formatter')
2
- require File.expand_path(File.dirname(__FILE__) + '/execution_context')
2
+ require File.expand_path(File.dirname(__FILE__) + '/../execution_context')
3
3
 
4
4
  module FluentCommandBuilder
5
5
  class UnderlyingBuilder
6
6
  include ArgumentFormatter
7
7
 
8
8
  attr_reader :args, :passwords
9
+ attr_accessor :password_formatter, :execution_context
9
10
 
10
11
  def initialize(command_builder_config)
11
12
  @c = command_builder_config
12
13
  @args = nil
13
14
  @passwords = []
15
+ @password_formatter = FluentCommandBuilder.password_formatter
14
16
  @execution_context = FluentCommandBuilder.execution_context
15
17
  end
16
18
 
@@ -21,19 +23,23 @@ module FluentCommandBuilder
21
23
  end
22
24
 
23
25
  def executable
24
- @c.path ? File.join(@c.tidy_path, @c.command_name) : @c.command_name
26
+ @c.executable
25
27
  end
26
28
 
27
29
  def execute
28
- @c.validate_path :fatal
30
+ @c.validate_path
29
31
  @c.validate_version
30
- visible_command = @execution_context.formatter.format self
31
32
  @execution_context.execute to_s, visible_command
32
33
  end
33
34
 
34
35
  def to_s
35
- quoted_executable = @c.evaluated_path.to_s.include?(' ') ? %Q["#{executable}"] : executable
36
- "#{quoted_executable} #{@args}".strip
36
+ "#{quote_if_includes_space @c.evaluated_executable} #{@args}".strip
37
+ end
38
+
39
+ private
40
+
41
+ def visible_command
42
+ @password_formatter.format to_s, @passwords
37
43
  end
38
44
 
39
45
  end
@@ -2,7 +2,7 @@ module FluentCommandBuilder
2
2
  class Version
3
3
 
4
4
  VERSION_REGEX = '(?:\d+\.)+(?:\d+)'
5
- SEQUENCE_SEPARATOR = '.'
5
+ DELIMITER = '.'
6
6
 
7
7
  attr_accessor :version
8
8
 
@@ -12,20 +12,19 @@ module FluentCommandBuilder
12
12
  end
13
13
 
14
14
  def compact
15
- to_a.first(2).join
15
+ first 2, ''
16
16
  end
17
17
 
18
- def to_s(count=nil)
19
- count ? truncate(count) : @version
20
- end
18
+ def first(count, delimiter=DELIMITER)
19
+ to_a.first(count).join(delimiter)
20
+ end
21
21
 
22
- def to_a
23
- @version.split SEQUENCE_SEPARATOR
22
+ def to_s
23
+ @version
24
24
  end
25
25
 
26
- def self.is_valid?(version)
27
- exp = Regexp.new "^#{VERSION_REGEX}$"
28
- version.scan(exp)[0] != nil
26
+ def to_a
27
+ @version.split DELIMITER
29
28
  end
30
29
 
31
30
  def self.match(value)
@@ -35,15 +34,11 @@ module FluentCommandBuilder
35
34
  Version.new(version)
36
35
  end
37
36
 
38
- def self.version_or_nil(version)
39
- return unless version
40
- is_valid?(version) ? Version.new(version) : nil
41
- end
42
-
43
37
  private
44
38
 
45
- def truncate(count)
46
- to_a.first(count).join(SEQUENCE_SEPARATOR)
39
+ def self.is_valid?(version)
40
+ exp = Regexp.new "^#{VERSION_REGEX}$"
41
+ version.scan(exp)[0] != nil
47
42
  end
48
43
 
49
44
  end
@@ -0,0 +1 @@
1
+ Dir[File.expand_path(File.dirname(__FILE__) + '/version_detectors/*.rb')].each { |f| require f }
@@ -1,4 +1,5 @@
1
1
  require 'yaml'
2
+ require File.expand_path(File.dirname(__FILE__) + '/../path_finder')
2
3
 
3
4
  module FluentCommandBuilder
4
5
  class AppEnginePythonVersionDetector
@@ -1,3 +1,4 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/../path_finder')
1
2
  require File.expand_path(File.dirname(__FILE__) + '/../version')
2
3
  require File.expand_path(File.dirname(__FILE__) + '/standard_version_detector')
3
4
 
@@ -1,5 +1,6 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/../path_finder')
1
2
  require File.expand_path(File.dirname(__FILE__) + '/../version')
2
- require File.expand_path(File.dirname(__FILE__) + '/../command_executors/backticks_executor')
3
+ require File.expand_path(File.dirname(__FILE__) + '/../../command_executors/backticks_executor')
3
4
 
4
5
  module FluentCommandBuilder
5
6
  class StandardVersionDetector
@@ -15,11 +16,13 @@ module FluentCommandBuilder
15
16
  def version(path=nil)
16
17
  path ||= FluentCommandBuilder.path_finder.find_path @command_name
17
18
  return unless path
18
- executable = File.join path, @command_name
19
- command = %Q["#{executable}" #{@command_arg} 2>&1]
20
- output = @backticks_executor.execute command
21
- v = Version.match(output)
22
- v ? v.version : nil
19
+ return unless File.exist? path
20
+ Dir.chdir path do
21
+ command = %Q["#{@command_name}" #{@command_arg} 2>&1]
22
+ output = @backticks_executor.execute command
23
+ v = Version.match(output)
24
+ v ? v.version : nil
25
+ end
23
26
  end
24
27
 
25
28
  end
@@ -3,15 +3,19 @@ require File.expand_path(File.dirname(__FILE__) + '/printer')
3
3
  module FluentCommandBuilder
4
4
  class VersionValidator
5
5
 
6
+ attr_accessor :printer, :should_abort_on_fatal
7
+
6
8
  def initialize(command_builder_config)
7
- @command_builder_config = command_builder_config
9
+ @c = command_builder_config
8
10
  @printer = Printer.new
11
+ @should_abort_on_fatal = true
9
12
  end
10
13
 
11
- def validate(validation_level)
14
+ def validate
15
+ validate_validation_level
12
16
  return if validation_level == :off
13
17
 
14
- @actual_version_string = version_detector.version(path)
18
+ @actual_version_string = @c.version_detector.version(@c.evaluated_path)
15
19
 
16
20
  unless actual_version
17
21
  @printer.print_warning error_message('unable to determine actual version')
@@ -19,52 +23,51 @@ module FluentCommandBuilder
19
23
  end
20
24
 
21
25
  unless is_valid?
22
- message = error_message actual_version.to_s(expected_version.to_a.length)
26
+ message = error_message actual_version.first(expected_version.to_a.length)
23
27
 
24
28
  case validation_level
25
29
  when :warn
26
30
  @printer.print_warning message
27
31
  when :fatal
28
32
  @printer.print_error message
29
- abort
33
+ abort if @should_abort_on_fatal
30
34
  else
31
- @printer.print_warning %Q[Version validation failed. Validation level "#{validation_level}" is not supported.]
35
+ # do nothing
32
36
  end
33
37
  end
34
38
  end
35
39
 
36
40
  private
37
41
 
38
- def is_valid?
39
- actual_version.to_a.first(expected_version.to_a.length) == expected_version.to_a
42
+ def validation_level
43
+ @c.version_validation_level
40
44
  end
41
45
 
42
- def expected_version
43
- @expected_version ||= Version.new(expected_version_string)
46
+ def validate_validation_level
47
+ raise %Q[Validation level "#{validation_level}" is not supported.] unless validation_level_valid?
44
48
  end
45
49
 
46
- def actual_version
47
- @actual_version ||= Version.new(@actual_version_string) if @actual_version_string
50
+ def validation_level_valid?
51
+ [:off, :warn, :fatal].include? validation_level
48
52
  end
49
53
 
50
- def error_message(actual_version)
51
- %Q[Version validation for command "#{command_name}" failed. Expected version #{expected_version} but was #{actual_version}.]
52
- end
53
54
 
54
- def path
55
- @command_builder_config.path
55
+
56
+
57
+ def is_valid?
58
+ actual_version.to_a.first(expected_version.to_a.length) == expected_version.to_a
56
59
  end
57
60
 
58
- def command_name
59
- @command_builder_config.command_name
61
+ def expected_version
62
+ @expected_version ||= Version.new(@c.version)
60
63
  end
61
64
 
62
- def expected_version_string
63
- @command_builder_config.version
65
+ def actual_version
66
+ @actual_version ||= Version.new(@actual_version_string) if @actual_version_string
64
67
  end
65
68
 
66
- def version_detector
67
- @command_builder_config.version_detector
69
+ def error_message(actual_version)
70
+ %Q[Version validation for command "#{@c.command_name}" failed. Expected version #{expected_version} but was #{actual_version}.]
68
71
  end
69
72
 
70
73
  end