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,
lib/terrimporter/configuration_loader.rb
Defined Under Namespace
Classes: Configuration, ConfigurationLoader, Downloader, Importer, Options
Class Method Summary collapse
- .build_options(arguments) ⇒ Object
-
.run!(*arguments) ⇒ Object
todo refactor into smaller methods.
Methods included from ConfigurationHelper
backup_config_file, base_config_path, config_default_name, config_example_path, config_search_paths, config_working_directory_exists?, config_working_directory_path, create_config_file, remove_config_file, schema_default_name, schema_file_path
Class Method Details
.build_options(arguments) ⇒ Object
93 94 95 96 97 98 |
# File 'lib/terrimporter.rb', line 93 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
todo refactor into smaller methods
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 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 |
# File 'lib/terrimporter.rb', line 35 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 case [:init] when :backup backup_config_file when :replace remove_config_file end create_config_file([: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 STAT.print_summary return 0 rescue TerrImporter::ConfigurationError $stderr.puts %Q{Configuration Error #{ $!. }} return 1 rescue TerrImporter::DefaultError $stderr.puts %Q{Unspecified Error #{ $!. }} return 1 end end |