lib/tailor/configuration.rb in tailor-1.1.5 vs lib/tailor/configuration.rb in tailor-1.2.0
- old
+ new
@@ -26,21 +26,28 @@
# @return [Hash]
def self.default
new
end
+ # @return [Hash]
attr_reader :file_sets
+
+ # @return [Array]
attr_reader :formatters
+ # @return [String]
+ attr_reader :output_file
+
# @param [Array] runtime_file_list
# @param [OpenStruct] options
# @option options [String] config_file
# @option options [Array] formatters
# @option options [Hash] style
def initialize(runtime_file_list=nil, options=nil)
- @formatters = ['text']
+ @formatters = %w[text]
@file_sets = {}
+ @output_file = ''
@runtime_file_list = runtime_file_list
log "Got runtime file list: #{@runtime_file_list}"
@options = options
log "Got options: #{@options}"
@@ -63,10 +70,11 @@
else
log "Creating default file set..."
@file_sets = { default: FileSet.new(@runtime_file_list) }
end
+ get_output_file_from_cli_opts
get_formatters_from_cli_opts
get_file_sets_from_cli_opts
get_style_from_cli_opts
end
@@ -116,11 +124,11 @@
if @file_sets[label]
log "label already exists. Updating..."
@file_sets[label].update_file_list(file_set[:file_list])
@file_sets[label].update_style(file_set[:style])
else
- log "Creating new label..."
+ log "Creating new label: #{label}"
@file_sets[label] =
FileSet.new(file_set[:file_list], file_set[:style])
end
end
end
@@ -160,14 +168,21 @@
else
@file_sets = { default: FileSet.new(@runtime_file_list) }
end
end
+ def get_output_file_from_cli_opts
+ unless @options.nil? || @options.output_file.empty? || @options.output_file.nil?
+ @output_file = @options.output_file
+ log "@output_file is now: '#{@output_file}'"
+ end
+ end
+
def get_formatters_from_cli_opts
unless @options.nil? || @options.formatters.empty? || @options.formatters.nil?
@formatters = @options.formatters
- log "@formatters is now #{@formatters}"
+ log "@formatters is now: '#{@formatters}'"
end
end
# @return [Array] The list of formatters.
def formatters(*new_formatters)
@@ -205,9 +220,10 @@
def show
table = Text::Table.new(horizontal_padding: 4)
table.head = [{ value: 'Configuration', colspan: 2, align: :center }]
table.rows << :separator
table.rows << ['Formatters', @formatters]
+ table.rows << ['Output File', @output_file]
@file_sets.each do |label, file_set|
table.rows << :separator
table.rows << ['Label', label]
table.rows << ['Style', '']