fluent_command_builder 0.8.7 → 0.8.8

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 (67) hide show
  1. data/lib/fluent_command_builder/command_builder_factory.rb +43 -0
  2. data/lib/fluent_command_builder/command_builders/appcfg_python.rb +3 -1
  3. data/lib/fluent_command_builder/command_builders/appcfg_python_16.rb +10 -8
  4. data/lib/fluent_command_builder/command_builders/appcfg_python_17.rb +10 -8
  5. data/lib/fluent_command_builder/command_builders/aspnet_compiler.rb +3 -1
  6. data/lib/fluent_command_builder/command_builders/aspnet_compiler_20.rb +10 -8
  7. data/lib/fluent_command_builder/command_builders/aspnet_compiler_40.rb +10 -8
  8. data/lib/fluent_command_builder/command_builders/bundle.rb +3 -1
  9. data/lib/fluent_command_builder/command_builders/bundle_11.rb +10 -8
  10. data/lib/fluent_command_builder/command_builders/cucumber.rb +3 -1
  11. data/lib/fluent_command_builder/command_builders/cucumber_11.rb +10 -8
  12. data/lib/fluent_command_builder/command_builders/cucumber_12.rb +10 -8
  13. data/lib/fluent_command_builder/command_builders/dev_appserver_python.rb +3 -1
  14. data/lib/fluent_command_builder/command_builders/dev_appserver_python_16.rb +10 -8
  15. data/lib/fluent_command_builder/command_builders/dev_appserver_python_17.rb +10 -8
  16. data/lib/fluent_command_builder/command_builders/dotcover.rb +3 -1
  17. data/lib/fluent_command_builder/command_builders/dotcover_10.rb +10 -8
  18. data/lib/fluent_command_builder/command_builders/dotcover_11.rb +10 -8
  19. data/lib/fluent_command_builder/command_builders/dotcover_12.rb +10 -8
  20. data/lib/fluent_command_builder/command_builders/dotcover_20.rb +10 -8
  21. data/lib/fluent_command_builder/command_builders/fastlinkchecker.rb +3 -1
  22. data/lib/fluent_command_builder/command_builders/fastlinkchecker_21.rb +10 -8
  23. data/lib/fluent_command_builder/command_builders/installutil.rb +3 -1
  24. data/lib/fluent_command_builder/command_builders/installutil_11.rb +10 -8
  25. data/lib/fluent_command_builder/command_builders/installutil_20.rb +10 -8
  26. data/lib/fluent_command_builder/command_builders/installutil_35.rb +10 -8
  27. data/lib/fluent_command_builder/command_builders/installutil_40.rb +10 -8
  28. data/lib/fluent_command_builder/command_builders/msbuild.rb +3 -1
  29. data/lib/fluent_command_builder/command_builders/msbuild_20.rb +10 -8
  30. data/lib/fluent_command_builder/command_builders/msbuild_30.rb +10 -8
  31. data/lib/fluent_command_builder/command_builders/msbuild_35.rb +10 -8
  32. data/lib/fluent_command_builder/command_builders/msbuild_40.rb +10 -8
  33. data/lib/fluent_command_builder/command_builders/msdeploy.rb +3 -1
  34. data/lib/fluent_command_builder/command_builders/msdeploy_71.rb +10 -8
  35. data/lib/fluent_command_builder/command_builders/mstest.rb +3 -1
  36. data/lib/fluent_command_builder/command_builders/mstest_100.rb +10 -8
  37. data/lib/fluent_command_builder/command_builders/mstest_80.rb +10 -8
  38. data/lib/fluent_command_builder/command_builders/mstest_90.rb +10 -8
  39. data/lib/fluent_command_builder/command_builders/netsh.rb +3 -1
  40. data/lib/fluent_command_builder/command_builders/netsh_61.rb +10 -8
  41. data/lib/fluent_command_builder/command_builders/nuget.rb +3 -1
  42. data/lib/fluent_command_builder/command_builders/nuget_20.rb +10 -8
  43. data/lib/fluent_command_builder/command_builders/nunit.rb +3 -1
  44. data/lib/fluent_command_builder/command_builders/nunit_25.rb +10 -8
  45. data/lib/fluent_command_builder/command_builders/nunit_26.rb +10 -8
  46. data/lib/fluent_command_builder/command_builders/rake.rb +3 -1
  47. data/lib/fluent_command_builder/command_builders/rake_09.rb +10 -8
  48. data/lib/fluent_command_builder/command_builders/security_osx.rb +3 -1
  49. data/lib/fluent_command_builder/command_builders/security_osx_107.rb +10 -8
  50. data/lib/fluent_command_builder/command_builders/sevenzip.rb +3 -1
  51. data/lib/fluent_command_builder/command_builders/sevenzip_920.rb +10 -8
  52. data/lib/fluent_command_builder/command_builders/simian.rb +3 -1
  53. data/lib/fluent_command_builder/command_builders/simian_23.rb +10 -8
  54. data/lib/fluent_command_builder/command_builders/team_foundation.rb +3 -1
  55. data/lib/fluent_command_builder/command_builders/team_foundation_100.rb +10 -8
  56. data/lib/fluent_command_builder/command_builders/team_foundation_tee.rb +3 -1
  57. data/lib/fluent_command_builder/command_builders/team_foundation_tee_100.rb +10 -8
  58. data/lib/fluent_command_builder/command_builders/team_foundation_tee_101.rb +10 -8
  59. data/lib/fluent_command_builder/command_builders/xcodebuild.rb +3 -1
  60. data/lib/fluent_command_builder/command_builders/xcodebuild_43.rb +10 -8
  61. data/lib/fluent_command_builder/command_builders/xcodebuild_44.rb +10 -8
  62. data/lib/fluent_command_builder/command_formatters/hidden_password_formatter.rb +3 -3
  63. data/lib/fluent_command_builder/default_path_validator.rb +33 -0
  64. data/lib/fluent_command_builder/execution_context.rb +3 -1
  65. data/lib/fluent_command_builder/version.rb +11 -16
  66. data/lib/fluent_command_builder/version_validator.rb +12 -7
  67. metadata +8 -6
@@ -1,5 +1,6 @@
1
1
  # Generated code. Do not modify.
2
2
 
3
+ require File.expand_path(File.dirname(__FILE__) + '/../command_builder_factory')
3
4
  require File.expand_path(File.dirname(__FILE__) + '/../underlying_builder')
4
5
 
5
6
  module FluentCommandBuilder
@@ -18,7 +19,8 @@ module FluentCommandBuilder
18
19
  self.version_detector.version path
19
20
  end
20
21
  def self.create(&block)
21
- version_module(XCodeBuild).create &block
22
+ f = CommandBuilderFactory.new XCodeBuild
23
+ f.create &block
22
24
  end
23
25
  end
24
26
  end
@@ -1,7 +1,7 @@
1
1
  # Generated code. Do not modify.
2
2
 
3
3
  require File.expand_path(File.dirname(__FILE__) + '/../command_base')
4
- require File.expand_path(File.dirname(__FILE__) + '/../printer')
4
+ require File.expand_path(File.dirname(__FILE__) + '/../default_path_validator')
5
5
  require File.expand_path(File.dirname(__FILE__) + '/../underlying_builder')
6
6
 
7
7
  module FluentCommandBuilder
@@ -11,20 +11,22 @@ module FluentCommandBuilder
11
11
  module XCodeBuild
12
12
  module V43
13
13
  VERSION = '4.3'
14
+ def self.exact_version
15
+ @exact_version ||= VERSION
16
+ end
17
+ def self.exact_version=(value)
18
+ @exact_version = value
19
+ end
14
20
  def self.default_path
15
21
  @default_path ||= nil
16
22
  end
17
23
  def self.default_path=(value)
18
- printer = FluentCommandBuilder::Printer.new
19
- begin
20
- printer.print_warning %Q[Default Path for command "#{FluentCommandBuilder::XCodeBuild::COMMAND_NAME}", version "#{VERSION}" does not exist. Path: #{value}] unless File.exist? value
21
- rescue
22
- printer.print_warning %Q[Failed to determine whether Default Path for command "#{FluentCommandBuilder::XCodeBuild::COMMAND_NAME}", version "#{VERSION}" exists. An internal error occurred.]
23
- end
24
+ validator = DefaultPathValidator.new value, FluentCommandBuilder::XCodeBuild::COMMAND_NAME, exact_version
25
+ validator.validate
24
26
  @default_path = value
25
27
  end
26
28
  def self.create
27
- b = UnderlyingBuilder.new FluentCommandBuilder::XCodeBuild::COMMAND_NAME, VERSION
29
+ b = UnderlyingBuilder.new FluentCommandBuilder::XCodeBuild::COMMAND_NAME, self.exact_version
28
30
  b.path = self.default_path
29
31
  b.actual_version_lambda = lambda { |path| FluentCommandBuilder::XCodeBuild.version path }
30
32
  c = XCodeBuild.new(b)
@@ -1,7 +1,7 @@
1
1
  # Generated code. Do not modify.
2
2
 
3
3
  require File.expand_path(File.dirname(__FILE__) + '/../command_base')
4
- require File.expand_path(File.dirname(__FILE__) + '/../printer')
4
+ require File.expand_path(File.dirname(__FILE__) + '/../default_path_validator')
5
5
  require File.expand_path(File.dirname(__FILE__) + '/../underlying_builder')
6
6
 
7
7
  module FluentCommandBuilder
@@ -11,20 +11,22 @@ module FluentCommandBuilder
11
11
  module XCodeBuild
12
12
  module V44
13
13
  VERSION = '4.4'
14
+ def self.exact_version
15
+ @exact_version ||= VERSION
16
+ end
17
+ def self.exact_version=(value)
18
+ @exact_version = value
19
+ end
14
20
  def self.default_path
15
21
  @default_path ||= nil
16
22
  end
17
23
  def self.default_path=(value)
18
- printer = FluentCommandBuilder::Printer.new
19
- begin
20
- printer.print_warning %Q[Default Path for command "#{FluentCommandBuilder::XCodeBuild::COMMAND_NAME}", version "#{VERSION}" does not exist. Path: #{value}] unless File.exist? value
21
- rescue
22
- printer.print_warning %Q[Failed to determine whether Default Path for command "#{FluentCommandBuilder::XCodeBuild::COMMAND_NAME}", version "#{VERSION}" exists. An internal error occurred.]
23
- end
24
+ validator = DefaultPathValidator.new value, FluentCommandBuilder::XCodeBuild::COMMAND_NAME, exact_version
25
+ validator.validate
24
26
  @default_path = value
25
27
  end
26
28
  def self.create
27
- b = UnderlyingBuilder.new FluentCommandBuilder::XCodeBuild::COMMAND_NAME, VERSION
29
+ b = UnderlyingBuilder.new FluentCommandBuilder::XCodeBuild::COMMAND_NAME, self.exact_version
28
30
  b.path = self.default_path
29
31
  b.actual_version_lambda = lambda { |path| FluentCommandBuilder::XCodeBuild.version path }
30
32
  c = XCodeBuild.new(b)
@@ -8,9 +8,9 @@ module FluentCommandBuilder
8
8
  end
9
9
 
10
10
  def format(underlying_builder)
11
- command = underlying_builder.to_s
12
- underlying_builder.passwords.each { |p| command.gsub! p, @password_replacement }
13
- command
11
+ c = underlying_builder.to_s
12
+ underlying_builder.passwords.each { |p| c.gsub! p, @password_replacement }
13
+ c
14
14
  end
15
15
 
16
16
  end
@@ -0,0 +1,33 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/printer')
2
+
3
+ module FluentCommandBuilder
4
+ class DefaultPathValidator
5
+
6
+ def initialize(default_path, command_name, version)
7
+ @default_path = default_path.to_s
8
+ @command_name = command_name
9
+ @version = version
10
+ @printer = Printer.new
11
+ end
12
+
13
+ def validate
14
+ return unless can_validate?
15
+ return if is_valid?
16
+ version = @version || '(unknown)'
17
+ message = %Q[Default Path for command "#{@command_name}", version "#{version}" does not exist. Path: #{@default_path}]
18
+ @printer.print_warning message
19
+ end
20
+
21
+ private
22
+
23
+ def can_validate?
24
+ !@default_path.nil?
25
+ end
26
+
27
+ def is_valid?
28
+ File.exist? @default_path
29
+ end
30
+
31
+ end
32
+ end
33
+
@@ -7,13 +7,14 @@ require File.expand_path(File.dirname(__FILE__) + '/command_formatters/null_form
7
7
  module FluentCommandBuilder
8
8
  class ExecutionContext
9
9
 
10
- attr_accessor :executor, :formatter, :should_print_on_execute, :should_fail_on_error
10
+ attr_accessor :executor, :formatter, :should_print_on_execute, :should_fail_on_error, :should_fail_on_unexpected_version
11
11
 
12
12
  def initialize(executor)
13
13
  @executor = executor
14
14
  @formatter = NullFormatter.new
15
15
  @should_print_on_execute = true
16
16
  @should_fail_on_error = true
17
+ @should_fail_on_unexpected_version = false
17
18
  @printer = FluentCommandBuilder::Printer.new
18
19
  end
19
20
 
@@ -41,6 +42,7 @@ module FluentCommandBuilder
41
42
 
42
43
  def validate_version(underlying_builder)
43
44
  v = VersionValidator.new underlying_builder
45
+ v.should_fail_on_unexpected_version = @should_fail_on_unexpected_version
44
46
  v.validate
45
47
  end
46
48
 
@@ -12,13 +12,17 @@ module FluentCommandBuilder
12
12
  end
13
13
 
14
14
  def compact
15
- sequences(2).join
15
+ to_a.first(2).join
16
16
  end
17
17
 
18
18
  def to_s(count=nil)
19
19
  count ? truncate(count) : @version
20
20
  end
21
21
 
22
+ def to_a
23
+ @version.split SEQUENCE_SEPARATOR
24
+ end
25
+
22
26
  def self.is_valid?(version)
23
27
  exp = Regexp.new "^#{VERSION_REGEX}$"
24
28
  version.scan(exp)[0] != nil
@@ -31,25 +35,16 @@ module FluentCommandBuilder
31
35
  Version.new(version)
32
36
  end
33
37
 
34
- private
35
-
36
- def sequences(count)
37
- @version.split(SEQUENCE_SEPARATOR).first(count)
38
+ def self.version_or_nil(version)
39
+ return unless version
40
+ is_valid?(version) ? Version.new(version) : nil
38
41
  end
39
42
 
43
+ private
44
+
40
45
  def truncate(count)
41
- sequences(count).join(SEQUENCE_SEPARATOR)
46
+ to_a.first(count).join(SEQUENCE_SEPARATOR)
42
47
  end
43
- end
44
48
 
45
- def version_module(command_module)
46
- version = command_module.respond_to?(:version) ? Version.new(command_module.version) : nil
47
- raise "Unable to determine version for #{command_module::COMMAND_NAME}." unless version
48
- module_name = "#{command_module.name}::V#{version.compact}"
49
- begin
50
- eval module_name
51
- rescue
52
- raise "Unable to load #{module_name}. Please consider contributing."
53
- end
54
49
  end
55
50
  end
@@ -3,21 +3,26 @@ require File.expand_path(File.dirname(__FILE__) + '/printer')
3
3
  module FluentCommandBuilder
4
4
  class VersionValidator
5
5
 
6
+ attr_accessor :should_fail_on_unexpected_version
7
+
6
8
  def initialize(underlying_builder)
7
9
  @underlying_builder = underlying_builder
8
10
  @printer = Printer.new
11
+ @should_fail_on_unexpected_version = false
9
12
  end
10
13
 
11
14
  def validate
12
15
  return unless can_validate?
13
16
 
14
17
  unless actual_version
15
- print_warning 'unable to determine actual version'
18
+ @printer.print_warning error_message('unable to determine actual version')
16
19
  return
17
20
  end
18
21
 
19
22
  unless is_valid?
20
- print_warning actual_version.to_s(2)
23
+ message = error_message actual_version.to_s(expected_version.to_a.length)
24
+ @should_fail_on_unexpected_version ? @printer.print_error(message) : @printer.print_warning(message)
25
+ raise message if @should_fail_on_unexpected_version
21
26
  end
22
27
  end
23
28
 
@@ -28,19 +33,19 @@ module FluentCommandBuilder
28
33
  end
29
34
 
30
35
  def is_valid?
31
- actual_version.compact == expected_version.compact
36
+ actual_version.to_a.first(expected_version.to_a.length) == expected_version.to_a
32
37
  end
33
38
 
34
39
  def expected_version
35
- Version.new(@underlying_builder.version)
40
+ @expected_version ||= Version.new(@underlying_builder.version)
36
41
  end
37
42
 
38
43
  def actual_version
39
- Version.new(@underlying_builder.actual_version) if @underlying_builder.actual_version
44
+ @actual_version ||= Version.new(@underlying_builder.actual_version) if @underlying_builder.actual_version
40
45
  end
41
46
 
42
- def print_warning(message)
43
- @printer.print_warning %Q[Version validation for command "#{@underlying_builder.command_name}" failed. Expected version #{expected_version} but was #{message}.]
47
+ def error_message(actual_version)
48
+ %Q[Version validation for command "#{@underlying_builder.command_name}" failed. Expected version #{expected_version} but was #{actual_version}.]
44
49
  end
45
50
 
46
51
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fluent_command_builder
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.7
4
+ version: 0.8.8
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: 2012-08-29 00:00:00.000000000 Z
12
+ date: 2012-09-10 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rake
16
- requirement: &70347631048860 !ruby/object:Gem::Requirement
16
+ requirement: &70171055089580 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '0'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70347631048860
24
+ version_requirements: *70171055089580
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: term-ansicolor
27
- requirement: &70347631048420 !ruby/object:Gem::Requirement
27
+ requirement: &70171055089140 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,7 +32,7 @@ dependencies:
32
32
  version: '0'
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *70347631048420
35
+ version_requirements: *70171055089140
36
36
  description: Fluent Command Builder makes building command lines easy and clean.
37
37
  email: matthew-github@matthewriley.name
38
38
  executables: []
@@ -41,6 +41,7 @@ extra_rdoc_files: []
41
41
  files:
42
42
  - lib/fluent_command_builder/argument_formatter.rb
43
43
  - lib/fluent_command_builder/command_base.rb
44
+ - lib/fluent_command_builder/command_builder_factory.rb
44
45
  - lib/fluent_command_builder/command_builders/appcfg_python.rb
45
46
  - lib/fluent_command_builder/command_builders/appcfg_python_16.rb
46
47
  - lib/fluent_command_builder/command_builders/appcfg_python_17.rb
@@ -108,6 +109,7 @@ files:
108
109
  - lib/fluent_command_builder/command_executors/system_executor.rb
109
110
  - lib/fluent_command_builder/command_formatters/hidden_password_formatter.rb
110
111
  - lib/fluent_command_builder/command_formatters/null_formatter.rb
112
+ - lib/fluent_command_builder/default_path_validator.rb
111
113
  - lib/fluent_command_builder/execution_context.rb
112
114
  - lib/fluent_command_builder/path_finder.rb
113
115
  - lib/fluent_command_builder/path_finders/unix_path_finder.rb