Method: Traject::CommandLine#assemble_settings_hash

Defined in:
lib/traject/command_line.rb

#assemble_settings_hash(options) ⇒ Object



192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
# File 'lib/traject/command_line.rb', line 192

def assemble_settings_hash(options)
  settings = {}

  # `-s key=value` command line
  (options[:setting] || []).each do |setting_pair|
    if m  = /\A([^=]+)\=(.*)\Z/.match(setting_pair)
      key, value = m[1], m[2]
      settings[key] = value
    else
      self.console.puts "Unrecognized setting argument '#{setting_pair}':"
      self.console.puts "Should be of format -s key=value"
      exit 3
    end
  end

  # other command line shortcuts for settings
  if options[:debug]
    settings["log.level"] = "debug"
  end
  if options[:'debug-mode']
    require 'traject/debug_writer'
    settings["writer_class_name"] = "Traject::DebugWriter"
    settings["log.level"] = "debug"
    settings["processing_thread_pool"] = 0
  end
  if options[:writer]
    settings["writer_class_name"] = options[:writer]
  end
  if options[:reader]
    settings["reader_class_name"] = options[:reader]
  end
  if options[:solr]
    settings["solr.url"] = options[:solr]
  end
  if options[:marc_type]
    settings["marc_source.type"] = options[:marc_type]
  end
  if options[:output_file]
    settings["output_file"] = options[:output_file]
  end

  return settings
end