Class: TerrImporter::Application
- Inherits:
-
Object
- Object
- TerrImporter::Application
- Extended by:
- ConfigurationHelper, Shellwords
- Defined in:
- lib/terrimporter.rb,
lib/terrimporter/options.rb,
lib/terrimporter/importer.rb,
lib/terrimporter/downloader.rb,
lib/terrimporter/configuration.rb
Defined Under Namespace
Classes: Configuration, Downloader, Importer, Options
Class Method Summary collapse
Methods included from ConfigurationHelper
config_default_name, config_example_path, config_working_directory_exists?, config_working_directory_path, create_config_file, schema_default_name, schema_file_path
Class Method Details
.build_options(arguments) ⇒ Object
77 78 79 80 81 82 |
# File 'lib/terrimporter.rb', line 77 def (arguments) env_opts_string = ENV['TERRIMPORTER_OPTS'] || "" env_opts = TerrImporter::Application::Options.new(shellwords(env_opts_string)) argument_opts = TerrImporter::Application::Options.new(arguments) env_opts.merge(argument_opts) end |
.run!(*arguments) ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/terrimporter.rb', line 25 def run!(*arguments) = (arguments) begin if ![:init].nil? if config_working_directory_exists? and [:init] != :backup and [:init] != :replace raise TerrImporter::ConfigurationError, "Configuration already exists, use the override or backup option" end create_config_file([:init], [:application_url]) return 0 end case [:verbose] when true LOG.level = :debug when false LOG.level = :info end if [:invalid_argument] $stderr.puts [:invalid_argument] [:show_help] = true end if [:invalid_option] $stderr.puts [:invalid_option] [:show_help] = true end if [:show_help] $stderr.puts .opts return 1 end if [:show_version] puts TerrImporter::VERSION return 0 end importer = TerrImporter::Application::Importer.new() importer.run return 0 rescue TerrImporter::ConfigurationError $stderr.puts %Q{Configuration Error #{ $!. }} return 1 rescue TerrImporter::DefaultError $stderr.puts %Q{Unspecified Error #{ $!. }} return 1 end end |