fluent_command_builder 0.8.17 → 0.8.18

Sign up to get free protection for your applications and to get access to all the features.
@@ -27,5 +27,25 @@ module FluentCommandBuilder
27
27
  v.validate validation_level
28
28
  end
29
29
 
30
+ def tidy_path
31
+ return unless @path
32
+ is_windows? ? @path.gsub('/', '\\') : @path.gsub('\\', '/')
33
+ end
34
+
35
+ def evaluated_path
36
+ return unless @path
37
+ is_windows? ? windows_path : @path
38
+ end
39
+
40
+ private
41
+
42
+ def windows_path
43
+ `echo #{tidy_path}`.strip
44
+ end
45
+
46
+ def is_windows?
47
+ !ENV['WINDIR'].nil?
48
+ end
49
+
30
50
  end
31
51
  end
@@ -4,13 +4,13 @@ module FluentCommandBuilder
4
4
  class PathValidator
5
5
 
6
6
  def initialize(command_builder_config)
7
- @command_builder_config = command_builder_config
7
+ @c = command_builder_config
8
8
  @printer = Printer.new
9
9
  end
10
10
 
11
11
  def validate(validation_level=:warn)
12
- return if File.exist? path
13
- message = %Q[Path for command "#{command_name}", version "#{version}" does not exist. Path: #{path}]
12
+ return if File.exist? @c.evaluated_path
13
+ message = %Q[Path for command "#{@c.command_name}", version "#{@c.version}" does not exist. Path: #{@c.evaluated_path}]
14
14
 
15
15
  case validation_level
16
16
  when :warn
@@ -23,27 +23,5 @@ module FluentCommandBuilder
23
23
  end
24
24
  end
25
25
 
26
- private
27
-
28
- def path
29
- is_windows? ? windows_path : @command_builder_config.path
30
- end
31
-
32
- def windows_path
33
- `echo #{@command_builder_config.path}`.strip
34
- end
35
-
36
- def command_name
37
- @command_builder_config.command_name
38
- end
39
-
40
- def version
41
- @command_builder_config.version
42
- end
43
-
44
- def is_windows?
45
- !ENV['WINDIR'].nil?
46
- end
47
-
48
26
  end
49
27
  end
@@ -5,10 +5,10 @@ module FluentCommandBuilder
5
5
  class UnderlyingBuilder
6
6
  include ArgumentFormatter
7
7
 
8
- attr_reader :command_builder_config, :args, :passwords
8
+ attr_reader :args, :passwords
9
9
 
10
10
  def initialize(command_builder_config)
11
- @command_builder_config = command_builder_config
11
+ @c = command_builder_config
12
12
  @args = nil
13
13
  @passwords = []
14
14
  @execution_context = FluentCommandBuilder.execution_context
@@ -21,45 +21,20 @@ module FluentCommandBuilder
21
21
  end
22
22
 
23
23
  def executable
24
- e = path ? File.join(path, command_name) : command_name
25
- e.gsub! '/', '\\' if is_windows?
26
- e
24
+ @c.path ? File.join(@c.tidy_path, @c.command_name) : @c.command_name
27
25
  end
28
26
 
29
27
  def execute
30
- @command_builder_config.validate_path :fatal
31
- @command_builder_config.validate_version
28
+ @c.validate_path :fatal
29
+ @c.validate_version
32
30
  visible_command = @execution_context.formatter.format self
33
31
  @execution_context.execute to_s, visible_command
34
32
  end
35
33
 
36
34
  def to_s
37
- quoted_executable = evaluated_path.to_s.include?(' ') ? %Q["#{executable}"] : executable
35
+ quoted_executable = @c.evaluated_path.to_s.include?(' ') ? %Q["#{executable}"] : executable
38
36
  "#{quoted_executable} #{@args}".strip
39
37
  end
40
38
 
41
- private
42
-
43
- def path
44
- @command_builder_config.path
45
- end
46
-
47
- def command_name
48
- @command_builder_config.command_name
49
- end
50
-
51
- def evaluated_path
52
- return unless path
53
- is_windows? ? windows_path : @command_builder_config.path
54
- end
55
-
56
- def windows_path
57
- `echo #{@command_builder_config.path}`.strip
58
- end
59
-
60
- def is_windows?
61
- !ENV['WINDIR'].nil?
62
- end
63
-
64
39
  end
65
40
  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.17
4
+ version: 0.8.18
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -13,7 +13,7 @@ date: 2012-09-20 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rake
16
- requirement: &70287098551400 !ruby/object:Gem::Requirement
16
+ requirement: &70335087153820 !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: *70287098551400
24
+ version_requirements: *70335087153820
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: term-ansicolor
27
- requirement: &70287098550960 !ruby/object:Gem::Requirement
27
+ requirement: &70335087153380 !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: *70287098550960
35
+ version_requirements: *70335087153380
36
36
  description: Fluent Command Builder makes building command lines easy and clean.
37
37
  email: matthew-github@matthewriley.name
38
38
  executables: []