Class: FluentCommandBuilder::UnderlyingBuilder

Inherits:
Object
  • Object
show all
Includes:
ArgumentFormatter
Defined in:
lib/fluent_command_builder/internal/underlying_builder.rb

Direct Known Subclasses

CommandBuilder

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from ArgumentFormatter

#format, #format_password

Constructor Details

#initialize(command_builder_config) ⇒ UnderlyingBuilder

Returns a new instance of UnderlyingBuilder.



12
13
14
15
16
17
18
# File 'lib/fluent_command_builder/internal/underlying_builder.rb', line 12

def initialize(command_builder_config)
  @c = command_builder_config
  @args = nil
  @passwords = []
  @password_formatter = FluentCommandBuilder.password_formatter
  @execution_context = FluentCommandBuilder.execution_context
end

Instance Attribute Details

#argsObject (readonly)

Returns the value of attribute args.



9
10
11
# File 'lib/fluent_command_builder/internal/underlying_builder.rb', line 9

def args
  @args
end

#execution_contextObject

Returns the value of attribute execution_context.



10
11
12
# File 'lib/fluent_command_builder/internal/underlying_builder.rb', line 10

def execution_context
  @execution_context
end

#password_formatterObject

Returns the value of attribute password_formatter.



10
11
12
# File 'lib/fluent_command_builder/internal/underlying_builder.rb', line 10

def password_formatter
  @password_formatter
end

#passwordsObject (readonly)

Returns the value of attribute passwords.



9
10
11
# File 'lib/fluent_command_builder/internal/underlying_builder.rb', line 9

def passwords
  @passwords
end

Instance Method Details

#append(value) ⇒ Object



20
21
22
23
24
# File 'lib/fluent_command_builder/internal/underlying_builder.rb', line 20

def append(value)
  v = value.to_s
  v = @args ? v : v.lstrip
  @args = @args.to_s + v
end

#executableObject



26
27
28
# File 'lib/fluent_command_builder/internal/underlying_builder.rb', line 26

def executable
  @c.executable
end

#executeObject



30
31
32
33
34
# File 'lib/fluent_command_builder/internal/underlying_builder.rb', line 30

def execute
  @c.validate_path
  @c.validate_version
  @execution_context.execute to_s, visible_command
end

#to_sObject



36
37
38
39
# File 'lib/fluent_command_builder/internal/underlying_builder.rb', line 36

def to_s
  p = Path.new @c.executable
  "#{quote_if_includes_space p.evaluated_path} #{@args}".strip
end