terrimporter 0.6.4 → 0.7.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -11,8 +11,7 @@ module TerrImporter
11
11
 
12
12
  class Application
13
13
  class Importer
14
- include Logging
15
-
14
+ include ImporterHelper
16
15
  attr_accessor :options, :config
17
16
 
18
17
  def initialize(options = {})
@@ -23,173 +22,126 @@ module TerrImporter
23
22
  end
24
23
 
25
24
  def run
26
-
27
-
28
25
  if options[:all] != nil and options[:all] == true
29
- puts "Import of everything started"
26
+ LOG.info "Import everything"
30
27
  import_js
31
28
  import_css
32
29
  import_images
30
+ import_modules
33
31
  else
34
32
  options.each do |option, value|
35
33
  if option.to_s =~ /^import_/ and value == true
36
- puts "Import of #{option.to_s.split('_').last} started"
34
+ LOG.info "Import of #{option.to_s.split('_').last} started"
37
35
  self.send option.to_s
38
36
  end
39
37
  end
40
38
  end
41
39
  end
42
40
 
43
- def determine_configuration_values_from_uri
44
- result = @downloader.download('')
45
- #result =~ /\/terrific\/base\/(.*?)\/public\/.*application=(.*?)(&|&)/
46
- #result =~ /(\/terrific\/base\/(.*?)\/public\/.*base.(css|js).php).*application=(.*?)(&|&)/
47
-
48
- css_result, js_result = result.scan(/(\/terrific\/base\/(.*?)\/public\/.*base.(css|js).php)\?.*application=(.*?)(&|&)/)
49
-
50
-
51
- if css_result.nil? or css_result.size < 5
52
- raise ConfigurationError, "Unable to extract css information from application url, content is: #{result}"
53
- end
54
- if js_result.nil? or js_result.size < 5
55
- raise ConfigurationError, "Unable to extract javascript information from application url, content is: #{result}"
56
- end
57
-
58
- css_export_path = css_result[0]
59
- js_export_path = js_result[0]
60
- terrific_version = css_result[1]
61
- application = css_result[3]
62
-
63
- raise ConfigurationError, "Unable to determine css export path from application url" if css_export_path.nil?
64
- raise ConfigurationError, "Unable to determine js export path from application url" if js_export_path.nil?
65
-
66
- puts "Determined the following configuration values from #{config['application_url']}:\n" +
67
- "terrific version: #{terrific_version} \n" +
68
- "application path: #{application}"
69
-
70
- config['version'] = terrific_version
71
- config['export_settings']['application'] = application
72
- config['export_path'] = {'css' => css_export_path, 'js' => js_export_path}
73
- end
74
-
75
41
  def import_css
76
- check_and_complete_config!
77
- unclean_suffix = "_unclean"
42
+ LOG.info("Importing stylesheets")
43
+ complete_config!
78
44
 
79
- check_and_create_dir config['stylesheets']['relative_destination_path']
80
-
81
- styles = config.stylesheets
45
+ unclean_suffix = "_unclean"
46
+ stylesheets = config.stylesheets
82
47
 
83
- styles.each do |css|
84
- relative_destination_path = File.join(config['stylesheets']['relative_destination_path'], css)
48
+ stylesheets.each do |css|
49
+ file_path = File.join(config['stylesheets']['destination_path'], css)
85
50
  options = {}
86
51
  options[:suffix] = $1 if css =~ /(ie.*).css$/ #add ie option if in array
87
-
88
- source_url = construct_export_path(:css, options)
89
-
90
- @downloader.download(source_url, relative_destination_path + unclean_suffix)
52
+ source_url = export_path(:css, options)
53
+ @downloader.download(source_url, file_path + unclean_suffix)
91
54
 
92
55
  if config.replace_style_strings?
93
- puts "Start css line replacements..."
94
- File.open(relative_destination_path, 'w') do |d|
95
- File.open(relative_destination_path + unclean_suffix, 'r') do |s|
56
+ LOG.debug "CSS line replacements"
57
+ File.open(file_path, 'w') do |d|
58
+ File.open(file_path + unclean_suffix, 'r') do |s|
96
59
  lines = s.readlines
97
60
  lines.each do |line|
98
- d.print stylesheet_replace_strings!(line)
61
+ d.print replace_stylesheet_lines!(line)
99
62
  end
100
63
  end
101
64
  end
102
65
  else
103
- puts "No css line replacements defined; skipping..."
66
+ LOG.debug "Skipping css line replacements"
104
67
  end
105
- puts "Deleting unclean css files"
106
- FileUtils.remove relative_destination_path + unclean_suffix
68
+ LOG.debug "Deleting unclean css files"
69
+ FileUtils.remove file_path + unclean_suffix
107
70
  end
108
71
  end
109
72
 
110
73
  def import_js
111
- check_and_complete_config!
112
- check_and_create_dir config['javascripts']['relative_destination_path']
113
- relative_destination_path = File.join(config['javascripts']['relative_destination_path'], "base.js")
114
- js_source_url = construct_export_path :js
115
-
116
- puts "Importing base.js from #{js_source_url} to #{relative_destination_path}"
117
-
118
- @downloader.download(js_source_url, relative_destination_path)
119
-
74
+ LOG.info("Importing javascripts")
75
+ complete_config!
76
+ file_path = File.join(config['javascripts']['destination_path'], "base.js")
77
+ js_source_url = export_path(:js)
78
+ LOG.debug "Import base.js from #{js_source_url} to #{file_path}"
79
+ @downloader.download(js_source_url, file_path)
120
80
 
121
81
  if config.additional_dynamic_javascripts?
122
-
123
- libraries_destination_path = config.libraries_destination_path
124
- check_and_create_dir libraries_destination_path
125
- js_libraries = config.dynamic_libraries
126
-
127
- puts "Importing libraries from #{config['libraries_server_path']} to #{libraries_destination_path}"
128
-
129
82
  if config['libraries_server_path'].nil?
130
- puts "Please define 'libraries_server_path' in configuration file"
83
+ LOG.info "Define 'libraries_server_path' in configuration file"
131
84
  else
85
+ libraries_file_path = config.libraries_destination_path
86
+ LOG.info "Import libraries from #{config['libraries_server_path']} to #{libraries_file_path}"
87
+ js_libraries = config.dynamic_libraries
132
88
  js_libraries.each do |lib|
133
- @downloader.download(File.join(config['libraries_server_path'], lib), File.join(libraries_destination_path, lib))
89
+ @downloader.download(File.join(config['libraries_server_path'], lib), File.join(libraries_file_path, lib))
134
90
  end
135
-
136
91
  end
137
-
138
92
  end
139
93
  end
140
94
 
141
95
  def import_images
142
- check_and_complete_config!
96
+ complete_config!
143
97
  if config.images?
144
- puts "Start importing images..."
145
-
98
+ LOG.info "Import images"
146
99
  config['images'].each do |image|
147
- check_and_create_dir image['relative_destination_path']
148
100
  image_source_path = File.join(config['image_server_path'], image['server_path'])
149
- batch_download(image_source_path, image['relative_destination_path'], image['file_types'])
101
+ @downloader.batch_download(image_source_path, image['destination_path'], image['file_types'])
150
102
  end
151
103
  else
152
- puts "No image configuration found, skipping image import..."
104
+ LOG.debug "Skipping image import"
153
105
  end
154
106
  end
155
107
 
156
- private
157
-
158
- def batch_download(relative_source_path, relative_dest_path, type_filter = "")
159
- source_path = relative_source_path
160
-
161
- puts "Downloading multiple files from #{config['application_url']}#{source_path} to #{relative_dest_path} #{"allowed extensions: " + type_filter unless type_filter.empty?}"
162
-
163
- files = html_directory_content_list(source_path)
164
-
165
- unless type_filter.empty?
166
- puts "Appling type filter: #{type_filter}"
167
- files = files.find_all { |file| file =~ Regexp.new(".*" + type_filter.robust_split.join("|") + "$") }
108
+ def complete_config!
109
+ unless config.mandatory_present?
110
+ config.determine_configuration_values_from_html @downloader.download('')
168
111
  end
112
+ end
169
113
 
170
- puts "Downloading #{files.size} files..."
171
- files.each do |file|
172
- relative_destination_path = File.join(relative_dest_path, file)
173
- @downloader.download(File.join(source_path, file), relative_destination_path)
114
+ def import_modules
115
+ complete_config!
116
+ if config.modules?
117
+ LOG.info "Module import"
118
+ config['modules'].each do |mod|
119
+ name = mod['name']
120
+ skin = mod['skin']
121
+ module_source_url = module_path(name, mod['module_template'], skin, mod['template_only'])
122
+ filename = name.clone
123
+ filename << "_#{skin}" unless skin.to_s.strip.length == 0
124
+ @downloader.download(module_source_url, File.join(mod['destination_path'], filename + '.html'))
125
+ end
126
+ else
127
+ LOG.debug "Skipping module import"
174
128
  end
175
129
  end
176
130
 
177
- def html_directory_content_list(source_path)
178
- puts "Getting html directory list"
179
- output = @downloader.download(source_path)
180
- files = []
181
-
182
- output.scan(/<a\shref=\"([^\"]+)\"/) do |res|
183
- files << res[0] if not res[0] =~ /^\?/ and not res[0] =~ /.*\/$/ and res[0].size > 1
184
- end
185
- puts "Found #{files.size} files"
186
- files
131
+ def module_path(name, module_template, skin = nil, template = nil)
132
+ skin = '' if skin.nil?
133
+ raise ConfigurationError, "Name cannot be empty for template" if name.nil?
134
+ raise ConfigurationError, "Module template missing in configuration for template #{name}" if module_template.nil?
135
+ export_path = config['application_url'].clone
136
+ export_path << "/terrific/module/details/#{name}/#{module_template}/#{skin}/format/module#{"content" if template}"
137
+ export_path
187
138
  end
188
139
 
189
- def construct_export_path(for_what = :js, options={})
140
+ private
141
+
142
+ def export_path(for_what = :js, options={})
190
143
  raise DefaultError, "Specify js or css url" unless for_what == :js or for_what == :css
191
144
  export_settings = config['export_settings'].clone
192
-
193
145
  export_settings.merge!(options)
194
146
  export_settings['appbaseurl'] = "" if for_what == :css
195
147
 
@@ -198,39 +150,12 @@ module TerrImporter
198
150
  export_path
199
151
  end
200
152
 
201
- def check_and_create_dir(dir, create = true)
202
- created_or_exists = false
203
- unless File.directory?(dir)
204
- puts "Directory #{dir} does not exists... it will #{"not" unless create} be created"
205
- if create
206
- FileUtils.mkpath(dir)
207
- created_or_exists = true
208
- end
209
- else
210
- created_or_exists = true
211
- end
212
- created_or_exists
213
- end
214
-
215
- #todo refactor config access away
216
- def stylesheet_replace_strings!(line)
153
+ def replace_stylesheet_lines!(line)
217
154
  config['stylesheets']['replace_strings'].each do |replace|
218
- what = replace['what']
219
- with = replace['with']
220
- what = Regexp.new "#{$1}" if what.match(/^r\/(.*)\//)
221
-
222
- puts "Replacing #{what.to_s} with #{with}"
223
-
224
- line.gsub! what, with
155
+ replace_line!(line, replace['what'], replace['with'])
225
156
  end
226
157
  line
227
158
  end
228
-
229
- def check_and_complete_config!
230
- unless config.required_present?
231
- determine_configuration_values_from_uri
232
- end
233
- end
234
159
  end
235
160
  end
236
161
  end
@@ -0,0 +1,9 @@
1
+ module ImporterHelper
2
+
3
+ def replace_line!(line, what, with)
4
+ what = Regexp.new "#{$1}" if what.match(/^r\/(.*)\//)
5
+ LOG.info "Replacing #{what.to_s} with #{with}"
6
+ line.gsub! what, with
7
+ end
8
+
9
+ end
@@ -5,51 +5,32 @@ module TerrImporter
5
5
 
6
6
  def initialize(args)
7
7
  super()
8
-
9
8
  @orig_args = args.clone
10
-
11
- self[:verbose] = true
9
+ self[:verbose] = false
12
10
  self[:show_help] = false
13
11
 
14
12
  require 'optparse'
15
13
  @opts = OptionParser.new do |o|
16
14
  o.banner = "Usage: #{File.basename($0)} [options] \n" +
17
15
  "Use #{File.basename($0)} [application_url] --init to initialize importer before first usage."
18
-
19
16
  o.separator ''
20
17
  o.separator 'Common options:'
21
-
22
- o.on('-a', '--all', 'export everything configured; javascripts, css files and images') do
18
+ o.on('-a', '--all', 'import everything configured; javascripts, css files and images') do
23
19
  self[:import_css] = true
24
20
  self[:import_js] = true
25
21
  self[:import_images] = true
22
+ self[:import_modules] = true
26
23
  end
27
-
28
- o.on('-c', '--css', 'export configured css files') { self[:import_css] = true }
29
-
30
- o.on('-i', '--img', 'export configured image files') { self[:import_images] = true }
31
-
32
- o.on('-j', '--js', 'export configured javascript files') { self[:import_js] = true }
33
-
34
- o.on('--init [CONFIG_EXISTS]', [:backup, :replace], 'create configuration file in current working directory. use optional argument to force file replacement (backup, replace)') do |init|
35
- self[:init] = init || true
36
- end
37
-
38
- o.on('-f', '--config CONFIG_FILE', 'use alternative configuration file') do |config_file|
39
- self[:config_file] = config_file
40
- end
41
-
24
+ o.on('-c', '--css', 'import configured css files') { self[:import_css] = true }
25
+ o.on('-i', '--img', 'import configured image files') { self[:import_images] = true }
26
+ o.on('-j', '--js', 'import configured javascript files') { self[:import_js] = true }
27
+ o.on('-m', '--module', 'import configured module files') { self[:import_modules] = true }
28
+ o.on('--init [CONFIG_EXISTS]', [:backup, :replace], 'create configuration file in current working directory. use optional argument to force file replacement (backup, replace)') { |init| self[:init] = init || true }
29
+ o.on('-f', '--config CONFIG_FILE', 'use alternative configuration file') { |config_file| self[:config_file] = config_file }
42
30
  o.separator ''
43
31
  o.separator 'Additional configuration:'
44
-
45
- o.on('-v', '--[no-]verbose', 'run verbosely') do |v|
46
- self[:verbose] = v
47
- end
48
-
49
- o.on('--version', 'Show version') do
50
- self[:show_version] = true
51
- end
52
-
32
+ o.on('-v', '--[no-]verbose', 'run verbosely') { |v| self[:verbose] = v }
33
+ o.on('--version', 'Show version') { self[:show_version] = true }
53
34
  o.on_tail('-h', '--help', 'display this help and exit') { self[:show_help] = true }
54
35
  end
55
36
 
@@ -57,6 +38,8 @@ module TerrImporter
57
38
  @opts.parse!(args)
58
39
  self[:application_url] = args.shift
59
40
  rescue OptionParser::InvalidOption => e
41
+ self[:invalid_option] = e.message
42
+ rescue OptionParser::InvalidArgument => e
60
43
  self[:invalid_argument] = e.message
61
44
  end
62
45
  end
@@ -1,4 +1,4 @@
1
- #Generated by rake task, last bump: minor6patch4major0
1
+ #Generated by rake task, last bump: minor6patch6major0
2
2
  module TerrImporter
3
- VERSION = "0.6.4"
3
+ VERSION = "0.7.0"
4
4
  end
data/lib/terrimporter.rb CHANGED
@@ -1,9 +1,11 @@
1
1
  require 'shellwords'
2
2
  require 'terrimporter/version'
3
+ require 'terrimporter/download_helper'
3
4
  require 'terrimporter/app_logger'
4
5
  require 'terrimporter/options'
6
+ require 'terrimporter/importer_helper'
5
7
  require 'terrimporter/importer'
6
- require 'terrimporter/config_helper'
8
+ require 'terrimporter/configuration_helper'
7
9
  require 'terrimporter/configuration'
8
10
  require 'terrimporter/downloader'
9
11
  require 'terrimporter/string_monkeypatch'
@@ -18,7 +20,7 @@ module TerrImporter
18
20
  class Application
19
21
  class << self
20
22
  include Shellwords
21
- include ConfigHelper
23
+ include ConfigurationHelper
22
24
 
23
25
  def run!(*arguments)
24
26
  options = build_options(arguments)
@@ -32,11 +34,24 @@ module TerrImporter
32
34
  return 0
33
35
  end
34
36
 
37
+ case options[:verbose]
38
+ when true
39
+ LOG.level = :debug
40
+ when false
41
+ LOG.level = :info
42
+ end
43
+
44
+
35
45
  if options[:invalid_argument]
36
46
  $stderr.puts options[:invalid_argument]
37
47
  options[:show_help] = true
38
48
  end
39
49
 
50
+ if options[:invalid_option]
51
+ $stderr.puts options[:invalid_option]
52
+ options[:show_help] = true
53
+ end
54
+
40
55
  if options[:show_help]
41
56
  $stderr.puts options.opts
42
57
  return 1
@@ -1,4 +1,5 @@
1
1
  <!DOCTYPE html>
2
+ <html>
2
3
  <head>
3
4
  <title>Some title</title>
4
5
  <meta http-equiv="content-type" content="text/html; charset=utf-8"/>
@@ -0,0 +1,13 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>Some title</title>
5
+ <meta http-equiv="content-type" content="text/html; charset=utf-8"/>
6
+ <meta name="language" content="de-ch, de"/>
7
+ <link href="/img/favicon.png" rel="apple-touch-icon"/>
8
+ <link href="/img/favicon.ico" rel="shortcut icon"/>
9
+ </head>
10
+ <body>
11
+ <p>this is not as is should be...</p>
12
+ </body>
13
+ </html>
@@ -0,0 +1,14 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>Some title</title>
5
+ <meta http-equiv="content-type" content="text/html; charset=utf-8"/>
6
+ <meta name="language" content="de-ch, de"/>
7
+ <link href="/img/favicon.png" rel="apple-touch-icon"/>
8
+ <link href="/img/favicon.ico" rel="shortcut icon"/>
9
+ <link href="/terrific/base/0.5/public/css/base/base.css.php?appbaseurl=&amp;application=/terrific/webapp/path&amp;layout=project&amp;debug=true&amp;cache=false&amp;t=1314606536" media="all" rel="stylesheet" type="text/css"/>
10
+ </head>
11
+ <body>
12
+ <p>this is not as is should be...</p>
13
+ </body>
14
+ </html>
@@ -0,0 +1,9 @@
1
+ <div class="mod modList"><div class="inner">
2
+ <!-- tpl List-sublist -->
3
+ <div class="class1">
4
+ <div class="class2">
5
+ <p>this is a terrific module</p>
6
+ </div>
7
+ </div>
8
+ <!-- /tpl List-sublist -->
9
+ </div></div><!-- /mod List -->
@@ -0,0 +1,7 @@
1
+ <!-- tpl List-sublist -->
2
+ <div class="class1">
3
+ <div class="class2">
4
+ <p>this is a terrific module content</p>
5
+ </div>
6
+ </div>
7
+ <!-- /tpl List-sublist -->
@@ -14,7 +14,7 @@
14
14
  javascripts:
15
15
  dest: test/tmp/public/javascripts/
16
16
  dynamic_libraries: dynlib.js
17
- libraries_relative_destination_path: /lib
17
+ libraries_destination_path: /lib
18
18
  images:
19
19
  - server_path: /
20
20
  dest: test/tmp/public/images/
@@ -22,3 +22,5 @@
22
22
  - server_path: /backgrounds
23
23
  dest: test/tmp/public/images/backgrounds/
24
24
  file_types: jpg
25
+ modules:
26
+ - name:
@@ -6,8 +6,9 @@ export_settings:
6
6
  debug: false
7
7
  cache: false
8
8
  stylesheets:
9
- relative_destination_path: test/tmp/public/stylesheets/
9
+ destination_path: test/tmp/public/stylesheets/
10
10
  javascripts:
11
- relative_destination_path: test/tmp/public/javascripts/
11
+ destination_path: test/tmp/public/javascripts/
12
12
  images:
13
+ modules:
13
14
 
@@ -6,20 +6,29 @@
6
6
  debug: false
7
7
  cache: false
8
8
  stylesheets:
9
- relative_destination_path: test/tmp/public/stylesheets/
9
+ destination_path: test/tmp/public/stylesheets/
10
10
  styles: ie.css
11
11
  replace_strings:
12
12
  - what: /img/
13
13
  with: /images/
14
14
  javascripts:
15
- relative_destination_path: test/tmp/public/javascripts/
15
+ destination_path: test/tmp/public/javascripts/
16
16
  dynamic_libraries: dynlib
17
- libraries_relative_destination_path: test/tmp/public/javascripts/lib
17
+ libraries_destination_path: test/tmp/public/javascripts/lib
18
18
  images:
19
19
  - server_path: /
20
- relative_destination_path: test/tmp/public/images/
20
+ destination_path: test/tmp/public/images/
21
21
  file_types: jpg, png, gif
22
22
  - server_path: /backgrounds
23
- relative_destination_path: test/tmp/public/images/backgrounds/
23
+ destination_path: test/tmp/public/images/backgrounds/
24
24
  file_types: jpg
25
+ modules:
26
+ - name: moduleName
27
+ skin: moduleSkin
28
+ destination_path: test/tmp/modules/
29
+ module_template: moduleTemplate
30
+ - name: moduleName
31
+ destination_path: test/tmp/modules/
32
+ module_template: moduleTemplate
33
+ template_only: true
25
34
 
data/test/test_helper.rb CHANGED
@@ -17,6 +17,27 @@ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib', 'terrimporter'
17
17
  $LOAD_PATH.unshift(File.dirname(__FILE__))
18
18
  require 'terrimporter'
19
19
 
20
+ require 'stringio'
21
+ module Kernel
22
+ def capture_stdout
23
+ out = StringIO.new
24
+ $stdout = out
25
+ yield
26
+ return out
27
+ ensure
28
+ $stdout = STDOUT
29
+ end
30
+
31
+ def capture_stderr
32
+ out = StringIO.new
33
+ $stderr = out
34
+ yield
35
+ return out
36
+ ensure
37
+ $stderr = STDERR
38
+ end
39
+ end
40
+
20
41
  class Test::Unit::TestCase
21
42
  def schema_file_path
22
43
  File.join(File.dirname(__FILE__), '..', 'config', schema_default_name)
@@ -46,6 +67,8 @@ class Test::Unit::TestCase
46
67
  FileUtils.rm_rf tmp_test_directory
47
68
  end
48
69
 
49
-
70
+ def exists_in_tmp?(name)
71
+ File.exists? File.join(tmp_test_directory, name)
72
+ end
50
73
 
51
74
  end
@@ -1,7 +1,7 @@
1
1
  require 'test_helper'
2
2
 
3
3
  class TestTerrimporter < Test::Unit::TestCase
4
- include ConfigHelper
4
+ include ConfigurationHelper
5
5
 
6
6
  def setup
7
7
  ENV['TERRIMPORTER_OPTS'] = nil
@@ -9,6 +9,7 @@ class TestTerrimporter < Test::Unit::TestCase
9
9
 
10
10
  def teardown
11
11
  File.delete config_file if File.exists? config_file
12
+ File.delete config_file + ".bak" if File.exists? config_file + ".bak"
12
13
  end
13
14
 
14
15
  should 'build options as a combination form argument options and environment options' do
@@ -19,7 +20,7 @@ class TestTerrimporter < Test::Unit::TestCase
19
20
  assert merged_options.include?(:import_css)
20
21
  end
21
22
 
22
- should 'merge environment and argument options' do
23
+ should 'merge environment and argument options' do
23
24
  ENV['TERRIMPORTER_OPTS'] = '-j -c'
24
25
  merged_options = TerrImporter::Application.build_options([''] + ['-i', '--verbose'])
25
26
  expected_options = {:application_url => "",
@@ -45,7 +46,7 @@ class TestTerrimporter < Test::Unit::TestCase
45
46
 
46
47
  should 'run the importer with the init command and a non existing configuration file' do
47
48
  TerrImporter::Application.run!(["test"], '--init')
48
- TerrImporter::Application.run!(["test"], '--init','backup')
49
+ TerrImporter::Application.run!(["test"], '--init', 'backup')
49
50
  assert File.exists? config_file
50
51
  end
51
52
 
@@ -55,8 +56,13 @@ class TestTerrimporter < Test::Unit::TestCase
55
56
  assert return_code == 1
56
57
  end
57
58
 
59
+ should 'run the importer with an invalid option, display help and return error code' do
60
+ return_code = TerrImporter::Application.run!(["test"], '--invalidoption')
61
+ assert return_code == 1
62
+ end
63
+
58
64
  should 'run the importer with an invalid argument, display help and return error code' do
59
- return_code = TerrImporter::Application.run!(["test"], '--invalid')
65
+ return_code = TerrImporter::Application.run!(["test"], '--init', 'INVALID')
60
66
  assert return_code == 1
61
67
  end
62
68
 
@@ -68,6 +74,17 @@ class TestTerrimporter < Test::Unit::TestCase
68
74
  should 'run the importer show version and return' do
69
75
  return_code = TerrImporter::Application.run!(["test"], '--version')
70
76
  assert return_code == 0
77
+ end
78
+
79
+ should 'run the importer in verbose mode' do
80
+ return_code = TerrImporter::Application.run!(["test"], '-v')
81
+ assert return_code == 1 #configuration missing because not initialized
82
+ end
83
+
84
+ should 'run the importer with the init command and a non existing configuration file' do
85
+ TerrImporter::Application.run!(["http://terrific.url"], '--init')
86
+ return_code = TerrImporter::Application.run!(["http://terrific.url"], '-a') #full run
87
+ assert return_code == 0
71
88
  end
72
89
 
73
90
  def config_file