terrimporter 0.4.0 → 0.5.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gitignore +1 -0
- data/Gemfile.lock +6 -9
- data/Rakefile +69 -0
- data/bin/terrimporter +5 -1
- data/config/schema.yml +0 -3
- data/config/terrimporter.config.yml +4 -7
- data/lib/{app_logger.rb → terrimporter/app_logger.rb} +0 -0
- data/lib/terrimporter/config_helper.rb +46 -0
- data/lib/{config_validator.rb → terrimporter/config_validator.rb} +0 -0
- data/lib/terrimporter/configuration.rb +72 -0
- data/lib/terrimporter/downloader.rb +38 -0
- data/lib/terrimporter/importer.rb +185 -0
- data/lib/{options.rb → terrimporter/options.rb} +16 -8
- data/lib/terrimporter/version.rb +3 -2
- data/lib/terrimporter.rb +30 -26
- data/tasks/load_tasks.rb +3 -0
- data/tasks/version.rake +2 -0
- data/terrimporter.gemspec +7 -4
- data/test/fixtures/css/base.css +1 -0
- data/test/fixtures/css/ie.css +1 -0
- data/test/fixtures/html/img_backgrounds_dir.html +43 -0
- data/test/fixtures/html/img_dir.html +67 -0
- data/test/fixtures/html/js_dyn_dir.html +44 -0
- data/test/fixtures/img/background.jpg +0 -0
- data/test/fixtures/img/testimage.png +0 -0
- data/test/fixtures/invalid.config.yml +27 -0
- data/test/fixtures/js/base.js +1 -0
- data/test/fixtures/js/dynlib.js +1 -0
- data/test/fixtures/test.config.yml +64 -0
- data/test/helper.rb +0 -19
- data/test/terrimporter.config.yml +68 -0
- data/test/test/tmp/public/javascripts/base.js +1 -0
- data/test/test/tmp/public/javascripts/lib/dynlib.js +1 -0
- data/test/test/tmp/public/stylesheets/base.css +1 -0
- data/test/test/tmp/public/stylesheets/ie.css +1 -0
- data/test/test_helper.rb +47 -0
- data/test/test_terrimporter.rb +66 -4
- data/test/unit/test_app_logger.rb +51 -0
- data/test/unit/test_config_helper.rb +33 -0
- data/test/unit/test_config_validator.rb +20 -0
- data/test/unit/test_configuration.rb +30 -26
- data/test/unit/test_downloader.rb +38 -0
- data/test/unit/test_importer.rb +159 -23
- data/test/unit/test_options.rb +45 -7
- metadata +80 -24
- data/lib/configuration.rb +0 -93
- data/lib/importer.rb +0 -190
- data/public/javascripts/base.js +0 -0
- data/public/javascripts/pngfix.js +0 -0
- data/public/javascripts/warning.js +0 -0
- data/test/unit/test_terrimporter.rb +0 -23
@@ -0,0 +1,33 @@
|
|
1
|
+
require "test_helper"
|
2
|
+
|
3
|
+
|
4
|
+
class ConfigValidatorTest < Test::Unit::TestCase
|
5
|
+
include ConfigHelper
|
6
|
+
|
7
|
+
def teardown
|
8
|
+
FileUtils.remove(config_working_directory_path + '.bak') if File.exists? config_working_directory_path + '.bak'
|
9
|
+
FileUtils.remove(config_working_directory_path) if File.exists? config_working_directory_path
|
10
|
+
end
|
11
|
+
|
12
|
+
should 'create a configuration file and backup the old one' do
|
13
|
+
create_config_file
|
14
|
+
create_config_file(:backup)
|
15
|
+
assert File.exists?(config_working_directory_path + '.bak')
|
16
|
+
assert File.exists?(config_working_directory_path)
|
17
|
+
end
|
18
|
+
|
19
|
+
should 'create a configuration file and remove the old one' do
|
20
|
+
config_working_directory_path
|
21
|
+
create_config_file(:replace)
|
22
|
+
assert File.exists?(config_working_directory_path)
|
23
|
+
end
|
24
|
+
|
25
|
+
should 'create a configuration file' do
|
26
|
+
create_config_file
|
27
|
+
assert File.exists?(config_working_directory_path)
|
28
|
+
end
|
29
|
+
|
30
|
+
|
31
|
+
end
|
32
|
+
|
33
|
+
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require "test_helper"
|
2
|
+
|
3
|
+
|
4
|
+
class ConfigValidatorTest < Test::Unit::TestCase
|
5
|
+
include ConfigHelper
|
6
|
+
|
7
|
+
def setup
|
8
|
+
schema = Kwalify::Yaml.load_file(schema_file_path)
|
9
|
+
validator = ConfigValidator.new(schema)
|
10
|
+
@parser = Kwalify::Yaml::Parser.new(validator)
|
11
|
+
|
12
|
+
end
|
13
|
+
|
14
|
+
should 'collect validation errors on wrongly used configuration file' do
|
15
|
+
@parser.parse_file(invalid_test_config_file_path)
|
16
|
+
errors = @parser.errors()
|
17
|
+
assert !errors.empty?
|
18
|
+
assert errors.size >= 3
|
19
|
+
end
|
20
|
+
end
|
@@ -1,17 +1,16 @@
|
|
1
|
-
require "
|
2
|
-
|
1
|
+
require "test_helper"
|
2
|
+
|
3
3
|
|
4
4
|
class ConfigurationTest < Test::Unit::TestCase
|
5
|
+
include ConfigHelper
|
5
6
|
|
6
7
|
def setup
|
7
|
-
|
8
|
-
@configuration = TerrImporter::Application::Configuration.new @test_configuration_file
|
8
|
+
@configuration = TerrImporter::Application::Configuration.new test_config_file_path
|
9
9
|
@configuration.load_configuration
|
10
10
|
end
|
11
11
|
|
12
12
|
def teardown
|
13
13
|
puts "Cleaning up configuration files"
|
14
|
-
delete_test_configuration_file
|
15
14
|
end
|
16
15
|
|
17
16
|
should 'find a configuration in the local path and not raise an error' do
|
@@ -20,39 +19,44 @@ class ConfigurationTest < Test::Unit::TestCase
|
|
20
19
|
end
|
21
20
|
end
|
22
21
|
|
22
|
+
context 'no configuration file around' do
|
23
|
+
setup { @invalid_configuration = TerrImporter::Application::Configuration.new }
|
24
|
+
|
25
|
+
should 'not find a configuration in the local path and raise an error' do
|
26
|
+
assert_raise TerrImporter::ConfigurationError do
|
27
|
+
@invalid_configuration.load_configuration
|
28
|
+
@invalid_configuration
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
context 'invalid config file' do
|
34
|
+
setup do
|
35
|
+
@configuration = TerrImporter::Application::Configuration.new invalid_test_config_file_path
|
36
|
+
end
|
37
|
+
|
38
|
+
should 'throw an error on an invalid config file' do
|
39
|
+
assert_raise TerrImporter::ConfigurationError do
|
40
|
+
@configuration.load_configuration
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
23
45
|
context 'test config file independed functions' do
|
24
46
|
setup {
|
25
47
|
@configuration = TerrImporter::Application::Configuration.new
|
26
48
|
}
|
27
49
|
|
28
50
|
should 'get the current working directory as config file path' do
|
29
|
-
config_in_cwd = File.join(Dir.pwd,
|
51
|
+
config_in_cwd = File.join(Dir.pwd, config_default_name)
|
30
52
|
assert_equal config_in_cwd, @configuration.determine_config_file_path
|
31
53
|
end
|
32
54
|
|
33
55
|
should 'create a config file in the current directory' do
|
34
|
-
config_path = File.join(Dir.pwd,
|
56
|
+
config_path = File.join(Dir.pwd, config_default_name)
|
35
57
|
FileUtils.rm_f config_path if File.exists? config_path
|
36
|
-
@configuration.
|
58
|
+
@configuration.create_config_file
|
37
59
|
assert File.exists?(config_path)
|
38
60
|
end
|
39
61
|
end
|
40
|
-
|
41
|
-
def schema_file_path
|
42
|
-
File.join(File.dirname(__FILE__), '..', '..', 'config', TerrImporter::Application::Configuration::SCHEMA_DEFAULT_NAME)
|
43
|
-
end
|
44
|
-
|
45
|
-
def create_test_configuration_file
|
46
|
-
example_configuration_path = File.join(File.dirname(__FILE__), '..', '..', 'config', TerrImporter::Application::Configuration::CONFIG_DEFAULT_NAME)
|
47
|
-
tmp_dir_path = File.join(File.dirname(__FILE__), '..', 'tmp')
|
48
|
-
test_configuration_path = File.join(tmp_dir_path, TerrImporter::Application::Configuration::CONFIG_DEFAULT_NAME)
|
49
|
-
FileUtils.mkdir(tmp_dir_path) unless File.exist? tmp_dir_path
|
50
|
-
FileUtils.cp example_configuration_path, test_configuration_path
|
51
|
-
@test_configuration_file = test_configuration_path
|
52
|
-
end
|
53
|
-
|
54
|
-
def delete_test_configuration_file
|
55
|
-
FileUtils.rm_rf @test_configuration_file if File.exists? @test_configuration_file
|
56
|
-
end
|
57
|
-
|
58
62
|
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
require "test_helper"
|
2
|
+
|
3
|
+
class DownloaderTest < Test::Unit::TestCase
|
4
|
+
def setup
|
5
|
+
@base_uri = 'http://terrific.url'
|
6
|
+
@downloader = TerrImporter::Application::Downloader.new @base_uri
|
7
|
+
FakeWeb.register_uri(:get, "http://terrific.url/js/libraries/dynamic/dynlib.js", :body => File.expand_path('test/fixtures/js/dynlib.js'), :content_type => 'text/plain')
|
8
|
+
end
|
9
|
+
|
10
|
+
def teardown
|
11
|
+
FileUtils.rm_f @target_dir if not @target_dir.nil? and File.exists? @target_dir
|
12
|
+
end
|
13
|
+
|
14
|
+
should 'join relative and base paths to get fully valid uri' do
|
15
|
+
absolute_path = @downloader.send :absolute_path, 'first/test'
|
16
|
+
assert_equal absolute_path, URI.parse(@base_uri + '/first/test')
|
17
|
+
|
18
|
+
absolute_path = @downloader.send :absolute_path, '/second/test'
|
19
|
+
assert_equal absolute_path, URI.parse(@base_uri + '/second/test')
|
20
|
+
|
21
|
+
absolute_path = @downloader.send :absolute_path, '/third/test/'
|
22
|
+
assert_equal absolute_path, URI.parse(@base_uri + '/third/test/')
|
23
|
+
|
24
|
+
end
|
25
|
+
|
26
|
+
should 'download a remote uri to string' do
|
27
|
+
result = @downloader.download 'js/libraries/dynamic/dynlib.js'
|
28
|
+
assert result.include?('This file represents a dynamic js library'), "result wrong, contains #{result.to_s}"
|
29
|
+
end
|
30
|
+
|
31
|
+
should 'download a file to the tmp folder' do
|
32
|
+
@target_dir = File.expand_path('/tmp/dynlib.js')
|
33
|
+
@downloader.download @base_uri + '/js/libraries/dynamic/dynlib.js', @target_dir
|
34
|
+
assert File.exists?(@target_dir), "File doesn't exist #{@target_dir}"
|
35
|
+
end
|
36
|
+
|
37
|
+
|
38
|
+
end
|
data/test/unit/test_importer.rb
CHANGED
@@ -1,56 +1,192 @@
|
|
1
|
-
require "
|
1
|
+
require "test_helper"
|
2
2
|
|
3
3
|
class TestImporter < Test::Unit::TestCase
|
4
4
|
def setup
|
5
|
-
|
5
|
+
create_tmp_test_directory
|
6
|
+
@importer = TerrImporter::Application::Importer.new({:config_file => test_config_file_path})
|
7
|
+
FakeWeb.register_uri(:get, "http://terrific.url/terrific/base/0.5/public/css/base/base.css.php?appbaseurl=&application=/terrific/webapp/path&layout=project&debug=false&cache=false", :body => File.expand_path('test/fixtures/css/base.css'), :content_type => 'text/plain')
|
8
|
+
FakeWeb.register_uri(:get, "http://terrific.url/terrific/base/0.5/public/css/base/base.css.php?appbaseurl=&application=/terrific/webapp/path&layout=project&suffix=ie&debug=false&cache=false", :body => File.expand_path('test/fixtures/css/ie.css'), :content_type => 'text/plain')
|
9
|
+
FakeWeb.register_uri(:get, "http://terrific.url/terrific/base/0.5/public/js/base/base.js.php?layout=project&cache=false&application=/terrific/webapp/path&debug=false", :body => File.expand_path('test/fixtures/js/base.js'), :content_type => 'text/plain')
|
10
|
+
FakeWeb.register_uri(:get, "http://terrific.url/img", :body => File.expand_path('test/fixtures/html/img_dir.html'), :content_type => 'text/html')
|
11
|
+
FakeWeb.register_uri(:get, "http://terrific.url/img/", :body => File.expand_path('test/fixtures/html/img_dir.html'), :content_type => 'text/html')
|
12
|
+
FakeWeb.register_uri(:get, "http://terrific.url/img/testimage1.png", :body => File.expand_path('test/fixtures/img/testimage.png'), :content_type => 'image/png')
|
13
|
+
FakeWeb.register_uri(:get, "http://terrific.url/img/testimage2.png", :body => File.expand_path('test/fixtures/img/testimage.png'), :content_type => 'image/png')
|
14
|
+
FakeWeb.register_uri(:get, "http://terrific.url/img/testimage3.png", :body => File.expand_path('test/fixtures/img/testimage.png'), :content_type => 'image/png')
|
15
|
+
FakeWeb.register_uri(:get, "http://terrific.url/img/backgrounds", :body => File.expand_path('test/fixtures/html/img_backgrounds_dir.html'), :content_type => 'text/html')
|
16
|
+
FakeWeb.register_uri(:get, "http://terrific.url/img/backgrounds/", :body => File.expand_path('test/fixtures/html/img_backgrounds_dir.html'), :content_type => 'text/html')
|
17
|
+
FakeWeb.register_uri(:get, "http://terrific.url/img/backgrounds/background.jpg", :body => File.expand_path('test/fixtures/img/background.jpg'), :content_type => 'image/jpg')
|
18
|
+
FakeWeb.register_uri(:get, "http://terrific.url/js/libraries/dynamic", :body => File.expand_path('test/fixtures/html/js_dyn_dir.html'), :content_type => 'text/html')
|
19
|
+
FakeWeb.register_uri(:get, "http://terrific.url/js/libraries/dynamic/", :body => File.expand_path('test/fixtures/html/js_dyn_dir.html'), :content_type => 'text/html')
|
20
|
+
FakeWeb.register_uri(:get, "http://terrific.url/js/libraries/dynamic/dynlib.js", :body => File.expand_path('test/fixtures/js/dynlib.js'), :content_type => 'text/plain')
|
6
21
|
end
|
7
22
|
|
8
23
|
def teardown
|
9
|
-
|
24
|
+
delete_tmp_test_directory
|
10
25
|
end
|
11
26
|
|
12
27
|
should 'be a dummy test for more tests to follow....' do
|
13
28
|
assert true
|
14
29
|
end
|
15
30
|
|
31
|
+
context 'css string replacement' do
|
16
32
|
|
17
|
-
end
|
18
33
|
|
34
|
+
should 'replace a string in the stylesheet with the configured string' do
|
35
|
+
line = "this line should replace the /img/ string with images"
|
36
|
+
@importer.send(:stylesheet_replace_strings!, line)
|
37
|
+
assert line.include? "/images/"
|
38
|
+
end
|
19
39
|
|
20
|
-
|
21
|
-
|
40
|
+
should 'replace a string in the stylesheet with the configured regex' do
|
41
|
+
@importer.config['stylesheets']['replace'][0]['what'] = "r/(re.+ex)/"
|
42
|
+
line = "this line should replace the regex string with images"
|
43
|
+
@importer.send(:stylesheet_replace_strings!, line)
|
44
|
+
assert line.include?("/images/"), "result not expected, is #{line}"
|
45
|
+
end
|
46
|
+
end
|
22
47
|
|
23
|
-
|
48
|
+
context 'file creation' do
|
49
|
+
|
50
|
+
should 'create a directory if it doesn\'t exist' do
|
51
|
+
directory = File.join(File.dirname(__FILE__), '..', 'tmp', 'test_mkdir')
|
52
|
+
created_or_exists = @importer.send(:check_and_create_dir, directory)
|
53
|
+
assert File.directory? directory
|
54
|
+
assert created_or_exists
|
55
|
+
#cleanup
|
56
|
+
FileUtils.rmdir directory
|
57
|
+
end
|
58
|
+
|
59
|
+
should 'not create a directory if it doesnt exist and create isnt used' do
|
60
|
+
directory = File.join(File.dirname(__FILE__), '..', 'tmp', 'test_mkdir')
|
61
|
+
created_or_exists = @importer.send(:check_and_create_dir, directory, false)
|
62
|
+
assert_equal false, File.directory?(directory)
|
63
|
+
assert !created_or_exists
|
64
|
+
end
|
65
|
+
|
66
|
+
should 'not create a directory if it exists, but report that it exists' do
|
67
|
+
directory = File.join(File.dirname(__FILE__), '..', 'tmp')
|
68
|
+
created_or_exists= @importer.send(:check_and_create_dir, directory)
|
69
|
+
assert created_or_exists
|
70
|
+
end
|
24
71
|
|
25
|
-
|
72
|
+
end
|
26
73
|
|
27
|
-
|
74
|
+
context 'css and js export path construction' do
|
75
|
+
should 'raise an error on wrongly supplied arguments' do
|
76
|
+
assert_raise TerrImporter::DefaultError do
|
77
|
+
@importer.send(:construct_export_path, :invalid)
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
should 'construct a valid js path for the base.js file' do
|
82
|
+
path = @importer.send(:construct_export_path, :js)
|
83
|
+
assert path.include? 'base.js'
|
84
|
+
end
|
85
|
+
|
86
|
+
should 'construct a valid js path for the base.js file and merge supplied options' do
|
87
|
+
path = @importer.send(:construct_export_path, :js, {:additional => 'option'})
|
88
|
+
assert path.include? 'additional=option'
|
89
|
+
end
|
90
|
+
|
91
|
+
should 'construct a valid js path for the base.css file' do
|
92
|
+
path = @importer.send(:construct_export_path, :css)
|
93
|
+
assert path.include? 'base.css'
|
94
|
+
assert path.include? 'appbaseurl='
|
95
|
+
end
|
96
|
+
end
|
28
97
|
|
29
|
-
|
98
|
+
context 'file lists' do
|
99
|
+
should 'get a list of files from a directory html page' do
|
100
|
+
files = @importer.send(:html_directory_content_list, '/img')
|
101
|
+
assert files.size == 3
|
102
|
+
assert files.include?("testimage1.png")
|
103
|
+
assert files.include?("testimage2.png")
|
104
|
+
assert files.include?("testimage3.png")
|
105
|
+
assert files[0] == ("testimage1.png")
|
106
|
+
end
|
107
|
+
|
108
|
+
should 'not return subdirectories if included in file list' do
|
109
|
+
files = @importer.send(:html_directory_content_list, '/img')
|
110
|
+
assert_same false, files.include?("backgrounds/")
|
111
|
+
end
|
112
|
+
end
|
30
113
|
|
31
|
-
|
114
|
+
context 'batch download files' do
|
115
|
+
should 'download all images into the target folder' do
|
116
|
+
@importer.send(:batch_download, '/img', tmp_test_directory)
|
117
|
+
assert exists_in_tmp? 'testimage1.png'
|
118
|
+
assert exists_in_tmp? 'testimage2.png'
|
119
|
+
assert exists_in_tmp? 'testimage3.png'
|
120
|
+
end
|
32
121
|
|
33
|
-
|
122
|
+
should 'download only files specified by file extension' do
|
123
|
+
@importer.send(:batch_download, '/img/backgrounds/', tmp_test_directory, "doesntexist")
|
124
|
+
assert_same false, exists_in_tmp?('background.jpg')
|
125
|
+
end
|
34
126
|
|
35
|
-
|
127
|
+
should 'download only files specified by file multiple extension' do
|
128
|
+
@importer.send(:batch_download, '/img/backgrounds/', tmp_test_directory, "doesntexist jpg") #here broken
|
129
|
+
assert exists_in_tmp? 'background.jpg'
|
130
|
+
end
|
36
131
|
|
37
|
-
|
132
|
+
end
|
38
133
|
|
39
|
-
|
134
|
+
context 'test public grand import functions - everything is preconfigured' do
|
135
|
+
should 'import all images' do
|
136
|
+
@importer.import_images #here broken
|
40
137
|
|
41
|
-
|
138
|
+
assert exists_in_tmp?('public/images/testimage1.png')
|
139
|
+
assert exists_in_tmp?('public/images/testimage2.png')
|
140
|
+
assert exists_in_tmp?('public/images/testimage3.png')
|
141
|
+
assert exists_in_tmp?('public/images/backgrounds/background.jpg')
|
142
|
+
end
|
42
143
|
|
43
|
-
|
144
|
+
should 'import all css files' do
|
145
|
+
@importer.import_css
|
146
|
+
assert exists_in_tmp?('public/stylesheets/base.css')
|
147
|
+
assert exists_in_tmp?('public/stylesheets/ie.css')
|
148
|
+
end
|
44
149
|
|
150
|
+
should 'import all js files' do
|
151
|
+
@importer.import_js
|
152
|
+
assert exists_in_tmp?('public/javascripts/base.js')
|
153
|
+
assert exists_in_tmp?('public/javascripts/lib/dynlib.js')
|
154
|
+
end
|
45
155
|
|
46
|
-
|
156
|
+
end
|
47
157
|
|
48
|
-
|
158
|
+
context 'execute run and check for correct resolve of commands' do
|
159
|
+
setup do
|
160
|
+
@importer.options[:import_js] = true
|
161
|
+
@importer.options[:import_css] = true
|
162
|
+
@importer.options[:import_images] = true
|
163
|
+
end
|
164
|
+
|
165
|
+
should 'import js, css and images, not using the :all statement' do
|
166
|
+
@importer.run #here broken
|
167
|
+
#only cherry-pick tests
|
168
|
+
assert exists_in_tmp?('public/images/testimage1.png')
|
169
|
+
assert exists_in_tmp?('public/stylesheets/base.css')
|
170
|
+
assert exists_in_tmp?('public/javascripts/base.js')
|
171
|
+
end
|
172
|
+
end
|
49
173
|
|
50
|
-
|
174
|
+
context 'execute run with all possible options enabled' do
|
175
|
+
setup do
|
176
|
+
@importer.options[:all] = true
|
177
|
+
end
|
178
|
+
should 'import js, css and images, using the :all statement' do
|
179
|
+
@importer.run #here broken
|
180
|
+
#only cherry-pick tests
|
181
|
+
assert exists_in_tmp?('public/images/testimage1.png')
|
182
|
+
assert exists_in_tmp?('public/stylesheets/base.css')
|
183
|
+
assert exists_in_tmp?('public/javascripts/base.js')
|
184
|
+
end
|
51
185
|
|
52
|
-
|
186
|
+
end
|
53
187
|
|
54
|
-
|
188
|
+
def exists_in_tmp?(name)
|
189
|
+
File.exists? File.join(tmp_test_directory, name)
|
190
|
+
end
|
55
191
|
|
56
|
-
|
192
|
+
end
|
data/test/unit/test_options.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
require "
|
1
|
+
require "test_helper"
|
2
2
|
|
3
3
|
class TestOptions < Test::Unit::TestCase
|
4
4
|
|
@@ -29,14 +29,40 @@ class TestOptions < Test::Unit::TestCase
|
|
29
29
|
assert_nil @options[:import_images]
|
30
30
|
end
|
31
31
|
|
32
|
+
should 'show help if none of the required options are specified' do
|
33
|
+
@options.show_help_on_no_options
|
34
|
+
assert @options[:show_help]
|
35
|
+
|
36
|
+
#self[:show_help] = true unless self[:import_css] or self[:import_js] or self[:import_images] or self[:init] or self[:version]
|
37
|
+
end
|
38
|
+
|
39
|
+
should 'not show help if one of the required options is specified' do
|
40
|
+
@options[:import_css] = true
|
41
|
+
@options.show_help_on_no_options
|
42
|
+
assert_equal false, @options[:show_help]
|
43
|
+
#self[:show_help] = true unless self[:import_css] or self[:import_js] or self[:import_images] or self[:init] or self[:version]
|
44
|
+
end
|
45
|
+
|
32
46
|
end
|
33
47
|
|
34
48
|
for_options '--init' do
|
35
|
-
should 'initialize
|
49
|
+
should 'initialize configuration' do
|
36
50
|
assert @options[:init]
|
37
51
|
end
|
38
52
|
end
|
39
53
|
|
54
|
+
for_options '--init', 'replace' do
|
55
|
+
should 'initialize configuration and replace existing' do
|
56
|
+
assert_equal :replace, @options[:init]
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
for_options '--init', 'backup' do
|
61
|
+
should 'initialize configuration and backup existing' do
|
62
|
+
assert_equal :backup, @options[:init]
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
40
66
|
for_options '-c' do
|
41
67
|
should 'import css files' do
|
42
68
|
assert @options[:import_css]
|
@@ -101,25 +127,37 @@ class TestOptions < Test::Unit::TestCase
|
|
101
127
|
end
|
102
128
|
end
|
103
129
|
|
104
|
-
|
130
|
+
|
131
|
+
for_options '--version' do
|
105
132
|
should 'show version' do
|
106
|
-
|
107
|
-
#todo implement real test
|
108
|
-
assert true
|
133
|
+
assert @options[:show_version]
|
109
134
|
end
|
110
135
|
end
|
111
136
|
|
137
|
+
|
112
138
|
for_options '' do
|
113
139
|
should 'show help if no options supplied' do
|
114
140
|
assert @options[:show_help]
|
115
141
|
end
|
116
142
|
end
|
117
143
|
|
118
|
-
#todo test not working, code however is; find out the reason and correct possible bug
|
119
144
|
for_options '--config','param_config_file.yml', ' -a' do
|
120
145
|
should 'use supplied yml file for configuration' do
|
121
146
|
assert @options[:config_file].include?("param_config_file.yml")
|
122
147
|
end
|
123
148
|
end
|
124
149
|
|
150
|
+
for_options '--no-verbose', '-a' do
|
151
|
+
should 'use none verbose output' do
|
152
|
+
assert_equal false, @options[:verbose]
|
153
|
+
end
|
154
|
+
end
|
155
|
+
|
156
|
+
for_options '-invalidargumend' do
|
157
|
+
should 'show the invalid argument error message' do
|
158
|
+
assert !@options[:invalid_argument].nil?
|
159
|
+
end
|
160
|
+
end
|
161
|
+
|
162
|
+
|
125
163
|
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: terrimporter
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 3
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
|
+
- 5
|
8
9
|
- 4
|
9
|
-
|
10
|
-
version: 0.4.0
|
10
|
+
version: 0.5.4
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Daniel Kummer
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-08-
|
18
|
+
date: 2011-08-27 00:00:00 Z
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
21
21
|
name: kwalify
|
@@ -25,10 +25,12 @@ dependencies:
|
|
25
25
|
requirements:
|
26
26
|
- - ">="
|
27
27
|
- !ruby/object:Gem::Version
|
28
|
-
hash:
|
28
|
+
hash: 7
|
29
29
|
segments:
|
30
30
|
- 0
|
31
|
-
|
31
|
+
- 7
|
32
|
+
- 2
|
33
|
+
version: 0.7.2
|
32
34
|
type: :runtime
|
33
35
|
version_requirements: *id001
|
34
36
|
- !ruby/object:Gem::Dependency
|
@@ -62,19 +64,17 @@ dependencies:
|
|
62
64
|
type: :development
|
63
65
|
version_requirements: *id003
|
64
66
|
- !ruby/object:Gem::Dependency
|
65
|
-
name:
|
67
|
+
name: rake
|
66
68
|
prerelease: false
|
67
69
|
requirement: &id004 !ruby/object:Gem::Requirement
|
68
70
|
none: false
|
69
71
|
requirements:
|
70
|
-
- -
|
72
|
+
- - ">="
|
71
73
|
- !ruby/object:Gem::Version
|
72
|
-
hash:
|
74
|
+
hash: 3
|
73
75
|
segments:
|
74
|
-
-
|
75
|
-
|
76
|
-
- 4
|
77
|
-
version: 1.6.4
|
76
|
+
- 0
|
77
|
+
version: "0"
|
78
78
|
type: :development
|
79
79
|
version_requirements: *id004
|
80
80
|
- !ruby/object:Gem::Dependency
|
@@ -91,6 +91,20 @@ dependencies:
|
|
91
91
|
version: "0"
|
92
92
|
type: :development
|
93
93
|
version_requirements: *id005
|
94
|
+
- !ruby/object:Gem::Dependency
|
95
|
+
name: fakeweb
|
96
|
+
prerelease: false
|
97
|
+
requirement: &id006 !ruby/object:Gem::Requirement
|
98
|
+
none: false
|
99
|
+
requirements:
|
100
|
+
- - ">="
|
101
|
+
- !ruby/object:Gem::Version
|
102
|
+
hash: 3
|
103
|
+
segments:
|
104
|
+
- 0
|
105
|
+
version: "0"
|
106
|
+
type: :development
|
107
|
+
version_requirements: *id006
|
94
108
|
description: This gem allows terrific(http://terrifically.org/ ) project import of css, javascript and image files based on a command line tool and a configuration file.
|
95
109
|
email:
|
96
110
|
- daniel.kummer@gmail.com
|
@@ -112,23 +126,44 @@ files:
|
|
112
126
|
- bin/terrimporter
|
113
127
|
- config/schema.yml
|
114
128
|
- config/terrimporter.config.yml
|
115
|
-
- lib/app_logger.rb
|
116
|
-
- lib/config_validator.rb
|
117
|
-
- lib/configuration.rb
|
118
|
-
- lib/importer.rb
|
119
|
-
- lib/options.rb
|
120
129
|
- lib/terrimporter.rb
|
130
|
+
- lib/terrimporter/app_logger.rb
|
131
|
+
- lib/terrimporter/config_helper.rb
|
132
|
+
- lib/terrimporter/config_validator.rb
|
133
|
+
- lib/terrimporter/configuration.rb
|
134
|
+
- lib/terrimporter/downloader.rb
|
135
|
+
- lib/terrimporter/importer.rb
|
136
|
+
- lib/terrimporter/options.rb
|
121
137
|
- lib/terrimporter/version.rb
|
122
|
-
-
|
123
|
-
-
|
124
|
-
- public/javascripts/warning.js
|
138
|
+
- tasks/load_tasks.rb
|
139
|
+
- tasks/version.rake
|
125
140
|
- terrimporter.gemspec
|
141
|
+
- test/fixtures/css/base.css
|
142
|
+
- test/fixtures/css/ie.css
|
143
|
+
- test/fixtures/html/img_backgrounds_dir.html
|
144
|
+
- test/fixtures/html/img_dir.html
|
145
|
+
- test/fixtures/html/js_dyn_dir.html
|
146
|
+
- test/fixtures/img/background.jpg
|
147
|
+
- test/fixtures/img/testimage.png
|
148
|
+
- test/fixtures/invalid.config.yml
|
149
|
+
- test/fixtures/js/base.js
|
150
|
+
- test/fixtures/js/dynlib.js
|
151
|
+
- test/fixtures/test.config.yml
|
126
152
|
- test/helper.rb
|
153
|
+
- test/terrimporter.config.yml
|
154
|
+
- test/test/tmp/public/javascripts/base.js
|
155
|
+
- test/test/tmp/public/javascripts/lib/dynlib.js
|
156
|
+
- test/test/tmp/public/stylesheets/base.css
|
157
|
+
- test/test/tmp/public/stylesheets/ie.css
|
158
|
+
- test/test_helper.rb
|
127
159
|
- test/test_terrimporter.rb
|
160
|
+
- test/unit/test_app_logger.rb
|
161
|
+
- test/unit/test_config_helper.rb
|
162
|
+
- test/unit/test_config_validator.rb
|
128
163
|
- test/unit/test_configuration.rb
|
164
|
+
- test/unit/test_downloader.rb
|
129
165
|
- test/unit/test_importer.rb
|
130
166
|
- test/unit/test_options.rb
|
131
|
-
- test/unit/test_terrimporter.rb
|
132
167
|
homepage: ""
|
133
168
|
licenses: []
|
134
169
|
|
@@ -137,6 +172,7 @@ rdoc_options: []
|
|
137
172
|
|
138
173
|
require_paths:
|
139
174
|
- lib
|
175
|
+
- tasks
|
140
176
|
required_ruby_version: !ruby/object:Gem::Requirement
|
141
177
|
none: false
|
142
178
|
requirements:
|
@@ -158,14 +194,34 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
158
194
|
requirements: []
|
159
195
|
|
160
196
|
rubyforge_project: terrimporter
|
161
|
-
rubygems_version: 1.8.
|
197
|
+
rubygems_version: 1.8.3
|
162
198
|
signing_key:
|
163
199
|
specification_version: 3
|
164
200
|
summary: Import terrific javascripts, css files and images into a web project
|
165
201
|
test_files:
|
202
|
+
- test/fixtures/css/base.css
|
203
|
+
- test/fixtures/css/ie.css
|
204
|
+
- test/fixtures/html/img_backgrounds_dir.html
|
205
|
+
- test/fixtures/html/img_dir.html
|
206
|
+
- test/fixtures/html/js_dyn_dir.html
|
207
|
+
- test/fixtures/img/background.jpg
|
208
|
+
- test/fixtures/img/testimage.png
|
209
|
+
- test/fixtures/invalid.config.yml
|
210
|
+
- test/fixtures/js/base.js
|
211
|
+
- test/fixtures/js/dynlib.js
|
212
|
+
- test/fixtures/test.config.yml
|
166
213
|
- test/helper.rb
|
214
|
+
- test/terrimporter.config.yml
|
215
|
+
- test/test/tmp/public/javascripts/base.js
|
216
|
+
- test/test/tmp/public/javascripts/lib/dynlib.js
|
217
|
+
- test/test/tmp/public/stylesheets/base.css
|
218
|
+
- test/test/tmp/public/stylesheets/ie.css
|
219
|
+
- test/test_helper.rb
|
167
220
|
- test/test_terrimporter.rb
|
221
|
+
- test/unit/test_app_logger.rb
|
222
|
+
- test/unit/test_config_helper.rb
|
223
|
+
- test/unit/test_config_validator.rb
|
168
224
|
- test/unit/test_configuration.rb
|
225
|
+
- test/unit/test_downloader.rb
|
169
226
|
- test/unit/test_importer.rb
|
170
227
|
- test/unit/test_options.rb
|
171
|
-
- test/unit/test_terrimporter.rb
|