Class: Airbrussh::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/airbrussh/configuration.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfiguration

Returns a new instance of Configuration.



10
11
12
13
14
15
16
17
18
19
# File 'lib/airbrussh/configuration.rb', line 10

def initialize
  self.log_file = nil
  self.monkey_patch_rake = false
  self.color = :auto
  self.truncate = :auto
  self.banner = :auto
  self.command_output = false
  self.task_prefix = nil
  self.context = Airbrussh::Rake::Context
end

Instance Attribute Details

Returns the value of attribute banner.



7
8
9
# File 'lib/airbrussh/configuration.rb', line 7

def banner
  @banner
end

#colorObject

Returns the value of attribute color.



7
8
9
# File 'lib/airbrussh/configuration.rb', line 7

def color
  @color
end

#command_outputObject

Returns the value of attribute command_output.



7
8
9
# File 'lib/airbrussh/configuration.rb', line 7

def command_output
  @command_output
end

#contextObject

Returns the value of attribute context.



7
8
9
# File 'lib/airbrussh/configuration.rb', line 7

def context
  @context
end

#log_fileObject

Returns the value of attribute log_file.



7
8
9
# File 'lib/airbrussh/configuration.rb', line 7

def log_file
  @log_file
end

#monkey_patch_rakeObject

Returns the value of attribute monkey_patch_rake.



7
8
9
# File 'lib/airbrussh/configuration.rb', line 7

def monkey_patch_rake
  @monkey_patch_rake
end

#task_prefixObject

Returns the value of attribute task_prefix.



7
8
9
# File 'lib/airbrussh/configuration.rb', line 7

def task_prefix
  @task_prefix
end

#truncateObject

Returns the value of attribute truncate.



7
8
9
# File 'lib/airbrussh/configuration.rb', line 7

def truncate
  @truncate
end

Instance Method Details

#apply_options(options) ⇒ Object



21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/airbrussh/configuration.rb', line 21

def apply_options(options)
  return self if options.nil?

  options.each do |key, value|
    if respond_to?(writer = "#{key}=")
      public_send(writer, value)
    else
      warn_unrecognized_key(key)
    end
  end
  self
end


34
35
36
37
38
39
40
41
42
43
# File 'lib/airbrussh/configuration.rb', line 34

def banner_message
  return nil unless banner
  return banner unless banner == :auto
  msg = "Using airbrussh format."
  if log_file
    msg << "\n"
    msg << "Verbose output is being written to #{Colors.blue(log_file)}."
  end
  msg
end

#formatters(io) ⇒ Object

This returns an array of formatters appropriate for the configuration. Depending on whether a log file is configured, this could be just the Airbrussh:ConsoleFormatter, or that plus the LogFileFormatter.



48
49
50
51
52
# File 'lib/airbrussh/configuration.rb', line 48

def formatters(io)
  fmts = [Airbrussh::ConsoleFormatter.new(io, self)]
  fmts.unshift(Airbrussh::LogFileFormatter.new(log_file)) if log_file
  fmts
end

#show_command_output?(sym) ⇒ Boolean

Returns:

  • (Boolean)


54
55
56
# File 'lib/airbrussh/configuration.rb', line 54

def show_command_output?(sym)
  command_output == true || Array(command_output).include?(sym)
end