class Bunto::Commands::Import
Constants
- IMPORTERS
Public Class Methods
abort_on_invalid_migrator(migrator)
click to toggle source
# File lib/bunto/commands/import.rb, line 69 def abort_on_invalid_migrator(migrator) $stderr.puts "Sorry, '#{migrator}' isn't a valid migrator. Valid choices:" IMPORTERS.keys.each { |k| $stderr.puts "* #{k}" } raise RuntimeError.new("'#{migrator}' is not a valid migrator.") end
init_with_program(prog)
click to toggle source
# File lib/bunto/commands/import.rb, line 36 def init_with_program(prog) prog.command(:import) do |c| c.syntax 'import <platform> [options]' c.description 'Import your old blog to Bunto' importers = BuntoImport.add_importer_commands(c) c.action do |args, options| if args.empty? Bunto.logger.warn "You must specify an importer." Bunto.logger.info "Valid options are:" importers.each { |i| Bunto.logger.info "*", "#{i}" } end end end end
process(migrator, options)
click to toggle source
# File lib/bunto/commands/import.rb, line 52 def process(migrator, options) migrator = migrator.to_s.downcase if IMPORTERS.keys.include?(migrator.to_sym) if BuntoImport::Importers.const_defined?(IMPORTERS[migrator.to_sym]) klass = BuntoImport::Importers.const_get(IMPORTERS[migrator.to_sym]) if options.respond_to?(:__hash__) klass.run(options.__hash__) else klass.run(options) end end else abort_on_invalid_migrator(migrator) end end