class Contentful::Importer::Command
Attributes
config[R]
converter[R]
importer[R]
json_validator[R]
Public Class Methods
data_options()
click to toggle source
# File lib/contentful/importer/command.rb, line 44 def self.data_options [['--data_dir=data', 'The directory to use for input, temporary data and logs.']] end
new(args)
click to toggle source
Calls superclass method
# File lib/contentful/importer/command.rb, line 59 def initialize(args) super(args) @settings = {} settings_file = args.option('configuration') @settings.merge!(YAML.load_file(settings_file)) if settings_file # CLI options can override settings of the same name self.class.options.map { |opt| opt.first.split('=').first.split('-').last }.each do |opt| arg = args.option(opt) arg &&= arg.to_i if opt == 'threads' @settings[opt] = arg if arg end @settings = @settings.with_indifferent_access @settings[:threads] = 1 if @settings[:threads].nil? end
options()
click to toggle source
Calls superclass method
# File lib/contentful/importer/command.rb, line 39 def self.options [['--configuration=config.yaml', 'Use the given configuration file.'], ['--access_token=XXX', 'The CMA access token to be used.']].concat(super).sort end
space_options()
click to toggle source
# File lib/contentful/importer/command.rb, line 48 def self.space_options [['--organization_id=YYY', 'Select organization if you are member of more than one.'], ['--space_id=ZZZ', 'Import into an existing space.'], ['--space_name=ZZZ', 'Import into a new space with the given name.'], ['--default_locale=de-DE', 'Locale to use if a new space is being created.']] end
thread_options()
click to toggle source
# File lib/contentful/importer/command.rb, line 55 def self.thread_options [['--threads=1', 'Number of threads to be used, can be either 1 or 2.']] end
Public Instance Methods
run()
click to toggle source
# File lib/contentful/importer/command.rb, line 78 def run @config = Configuration.new(@settings) @importer = ParallelImporter.new(@config) @converter = ContentfulModelToJson.new(@config) @json_validator = JsonSchemaValidator.new(@config) json_validator.validate_schemas end