terrimporter 0.6.4 → 0.7.0
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/Gemfile.lock +1 -1
- data/config/schema.yml +28 -5
- data/config/{terrimporter.config.yml → terrimporter.yml} +24 -6
- data/lib/terrimporter/app_logger.rb +39 -30
- data/lib/terrimporter/configuration.rb +39 -10
- data/lib/terrimporter/{config_helper.rb → configuration_helper.rb} +6 -6
- data/lib/terrimporter/download_helper.rb +8 -0
- data/lib/terrimporter/downloader.rb +42 -15
- data/lib/terrimporter/importer.rb +64 -139
- data/lib/terrimporter/importer_helper.rb +9 -0
- data/lib/terrimporter/options.rb +13 -30
- data/lib/terrimporter/version.rb +2 -2
- data/lib/terrimporter.rb +17 -2
- data/test/fixtures/html/application_root.html +1 -0
- data/test/fixtures/html/application_root_css_error.html +13 -0
- data/test/fixtures/html/application_root_js_error.html +14 -0
- data/test/fixtures/html/module.html +9 -0
- data/test/fixtures/html/modulecontent.html +7 -0
- data/test/fixtures/invalid.config.yml +3 -1
- data/test/fixtures/minimal.test.config.yml +3 -2
- data/test/fixtures/test.config.yml +14 -5
- data/test/test_helper.rb +24 -1
- data/test/test_terrimporter.rb +21 -4
- data/test/unit/test_app_logger.rb +19 -36
- data/test/unit/test_config_helper.rb +1 -1
- data/test/unit/test_configuration.rb +45 -3
- data/test/unit/test_downloader.rb +68 -3
- data/test/unit/test_importer.rb +38 -78
- data/test/unit/test_options.rb +23 -3
- metadata +18 -9
- data/terrimporter.config.yml.bak +0 -47
@@ -1,51 +1,34 @@
|
|
1
1
|
require 'test_helper'
|
2
2
|
|
3
|
-
|
4
3
|
class LoggingTest < Test::Unit::TestCase
|
5
|
-
include Logging
|
6
|
-
|
7
|
-
def wrapped_log(message)
|
8
|
-
original_stdout = $stdout
|
9
|
-
original_stderr = $stderr
|
10
|
-
|
11
|
-
fake_stdout = StringIO.new
|
12
|
-
fake_stderr = StringIO.new
|
13
|
-
|
14
|
-
$stdout = fake_stdout
|
15
|
-
$stderr = fake_stderr
|
16
|
-
|
17
|
-
begin
|
18
|
-
log message
|
19
|
-
ensure
|
20
|
-
$stdout = original_stdout
|
21
|
-
$stderr = original_stderr
|
22
|
-
end
|
23
|
-
|
24
|
-
@stdout = fake_stdout.string
|
25
|
-
@stderr = fake_stderr.string
|
26
4
|
|
5
|
+
def setup
|
6
|
+
@message = "This is a test message"
|
27
7
|
end
|
28
8
|
|
29
|
-
context "supported logging operations" do
|
30
|
-
should "log info to stdout" do
|
31
|
-
wrapped_log :info => "hello world"
|
32
|
-
assert @stdout.grep(/INFO.*hello world/)
|
33
|
-
end
|
34
9
|
|
35
|
-
|
36
|
-
|
37
|
-
|
10
|
+
should 'log info to stdout' do
|
11
|
+
out = capture_stdout do
|
12
|
+
LOG.info(@message)
|
38
13
|
end
|
14
|
+
assert out.string.include? @message
|
15
|
+
assert out.string.include? "INFO"
|
16
|
+
end
|
39
17
|
|
40
|
-
|
41
|
-
|
42
|
-
|
18
|
+
should 'log debug to stdout' do
|
19
|
+
out = capture_stdout do
|
20
|
+
LOG.debug(@message)
|
43
21
|
end
|
22
|
+
assert out.string.include? @message
|
23
|
+
assert out.string.include? "DEBUG"
|
44
24
|
end
|
45
25
|
|
46
|
-
should
|
47
|
-
|
48
|
-
|
26
|
+
should 'log error to stdout' do
|
27
|
+
out = capture_stderr do
|
28
|
+
LOG.error(@message)
|
29
|
+
end
|
30
|
+
assert out.string.include? @message
|
31
|
+
assert out.string.include? "ERROR"
|
49
32
|
end
|
50
33
|
|
51
34
|
end
|
@@ -2,7 +2,7 @@ require "test_helper"
|
|
2
2
|
|
3
3
|
|
4
4
|
class ConfigurationTest < Test::Unit::TestCase
|
5
|
-
include
|
5
|
+
include ConfigurationHelper
|
6
6
|
|
7
7
|
def setup
|
8
8
|
@configuration = TerrImporter::Application::Configuration.new test_config_file_path
|
@@ -23,6 +23,15 @@ class ConfigurationTest < Test::Unit::TestCase
|
|
23
23
|
assert @configuration.additional_dynamic_javascripts?
|
24
24
|
end
|
25
25
|
|
26
|
+
should 'have modules' do
|
27
|
+
assert @configuration.modules?
|
28
|
+
end
|
29
|
+
|
30
|
+
should 'use the normal libraries path if no dynamic libraries are specified' do
|
31
|
+
@configuration['javascripts']['libraries_destination_path'] = nil
|
32
|
+
assert @configuration['javascripts']['destination_path'], @configuration.libraries_destination_path
|
33
|
+
end
|
34
|
+
|
26
35
|
should 'have style replacement strings' do
|
27
36
|
assert @configuration.replace_style_strings?
|
28
37
|
end
|
@@ -79,7 +88,7 @@ class ConfigurationTest < Test::Unit::TestCase
|
|
79
88
|
@configuration['export_settings'] = {'application' => 'present'}
|
80
89
|
@configuration['application_url'] = 'present'
|
81
90
|
|
82
|
-
assert @configuration.
|
91
|
+
assert @configuration.mandatory_present?
|
83
92
|
end
|
84
93
|
end
|
85
94
|
|
@@ -114,10 +123,43 @@ class ConfigurationTest < Test::Unit::TestCase
|
|
114
123
|
assert_equal ["base.css"], @configuration.stylesheets
|
115
124
|
end
|
116
125
|
|
126
|
+
should 'not have additional modules' do
|
127
|
+
assert !@configuration.modules?
|
128
|
+
end
|
129
|
+
|
130
|
+
context 'read additional configuration values from parent page' do
|
131
|
+
|
132
|
+
should 'extract version and app path from parent page' do
|
133
|
+
raw_html = File.open(File.expand_path('test/fixtures/html/application_root.html')).read
|
134
|
+
assert_nothing_raised do
|
135
|
+
@configuration.determine_configuration_values_from_html raw_html
|
136
|
+
end
|
137
|
+
|
138
|
+
assert !@configuration['version'].nil?
|
139
|
+
assert !@configuration['export_settings']['application'].nil?
|
140
|
+
assert !@configuration['export_path']['js'].nil?
|
141
|
+
assert !@configuration['export_path']['css'].nil?
|
142
|
+
end
|
143
|
+
|
144
|
+
should 'throw a configuration error if the parent pages js values can\'t be read correctly' do
|
145
|
+
raw_html = File.open(File.expand_path('test/fixtures/html/application_root_js_error.html')).read
|
146
|
+
assert_raises TerrImporter::ConfigurationError do
|
147
|
+
@configuration.determine_configuration_values_from_html raw_html
|
148
|
+
end
|
149
|
+
end
|
150
|
+
|
151
|
+
should 'throw a configuration error if the parent pages css values can\'t be read correctly' do
|
152
|
+
raw_html = File.open(File.expand_path('test/fixtures/html/application_root_css_error.html')).read
|
153
|
+
assert_raises TerrImporter::ConfigurationError do
|
154
|
+
@configuration.determine_configuration_values_from_html raw_html
|
155
|
+
end
|
156
|
+
end
|
157
|
+
end
|
158
|
+
|
117
159
|
#todo why is this failing?
|
118
160
|
=begin
|
119
161
|
should 'return javascript destination path if libraries destination path is undefined' do
|
120
|
-
assert_equal @configuration['javascripts']['
|
162
|
+
assert_equal @configuration['javascripts']['destination_path'], @configuration.libraries_destination_path
|
121
163
|
end
|
122
164
|
=end
|
123
165
|
end
|
@@ -2,23 +2,35 @@ require "test_helper"
|
|
2
2
|
|
3
3
|
class DownloaderTest < Test::Unit::TestCase
|
4
4
|
def setup
|
5
|
+
create_tmp_test_directory
|
5
6
|
@base_uri = 'http://terrific.url'
|
6
7
|
@downloader = TerrImporter::Application::Downloader.new @base_uri
|
7
8
|
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')
|
9
|
+
FakeWeb.register_uri(:get, "http://terrific.url/img", :body => File.expand_path('test/fixtures/html/img_dir.html'), :content_type => 'text/html')
|
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/", :body => File.expand_path('test/fixtures/html/img_dir.html'), :content_type => 'text/html')
|
13
|
+
FakeWeb.register_uri(:get, "http://terrific.url/img/testimage1.png", :body => File.expand_path('test/fixtures/img/testimage.png'), :content_type => 'image/png')
|
14
|
+
FakeWeb.register_uri(:get, "http://terrific.url/img/testimage2.png", :body => File.expand_path('test/fixtures/img/testimage.png'), :content_type => 'image/png')
|
15
|
+
FakeWeb.register_uri(:get, "http://terrific.url/img/testimage3.png", :body => File.expand_path('test/fixtures/img/testimage.png'), :content_type => 'image/png')
|
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/", :body => File.expand_path('test/fixtures/html/img_backgrounds_dir.html'), :content_type => 'text/html')
|
18
|
+
FakeWeb.register_uri(:get, "http://terrific.url/img/backgrounds/background.jpg", :body => File.expand_path('test/fixtures/img/background.jpg'), :content_type => 'image/jpg')
|
8
19
|
end
|
9
20
|
|
10
21
|
def teardown
|
11
22
|
FileUtils.rm_f @target_dir if not @target_dir.nil? and File.exists? @target_dir
|
23
|
+
delete_tmp_test_directory
|
12
24
|
end
|
13
25
|
|
14
26
|
should 'join relative and base paths to get fully valid uri' do
|
15
|
-
absolute_path = @downloader.send :
|
27
|
+
absolute_path = @downloader.send :url, 'first/test'
|
16
28
|
assert_equal absolute_path, URI.parse(@base_uri + '/first/test')
|
17
29
|
|
18
|
-
absolute_path = @downloader.send :
|
30
|
+
absolute_path = @downloader.send :url, '/second/test'
|
19
31
|
assert_equal absolute_path, URI.parse(@base_uri + '/second/test')
|
20
32
|
|
21
|
-
absolute_path = @downloader.send :
|
33
|
+
absolute_path = @downloader.send :url, '/third/test/'
|
22
34
|
assert_equal absolute_path, URI.parse(@base_uri + '/third/test/')
|
23
35
|
|
24
36
|
end
|
@@ -41,5 +53,58 @@ class DownloaderTest < Test::Unit::TestCase
|
|
41
53
|
end
|
42
54
|
end
|
43
55
|
|
56
|
+
context 'batch download files' do
|
57
|
+
should 'download all images into the target folder' do
|
58
|
+
@downloader.batch_download '/img', tmp_test_directory
|
59
|
+
assert exists_in_tmp? 'testimage1.png'
|
60
|
+
assert exists_in_tmp? 'testimage2.png'
|
61
|
+
assert exists_in_tmp? 'testimage3.png'
|
62
|
+
end
|
63
|
+
|
64
|
+
should 'download only files specified by file extension' do
|
65
|
+
@downloader.batch_download '/img/backgrounds/', tmp_test_directory, "doesntexist"
|
66
|
+
assert_same false, exists_in_tmp?('background.jpg')
|
67
|
+
end
|
68
|
+
|
69
|
+
should 'download only files specified by file multiple extension' do
|
70
|
+
@downloader.batch_download '/img/backgrounds/', tmp_test_directory, "doesntexist jpg"
|
71
|
+
assert exists_in_tmp? 'background.jpg'
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
context 'file lists' do
|
76
|
+
should 'get a list of files from a directory html page' do
|
77
|
+
files = @downloader.send(:html_directory_list, '/img')
|
78
|
+
assert files.size == 3
|
79
|
+
assert files.include?("testimage1.png")
|
80
|
+
assert files.include?("testimage2.png")
|
81
|
+
assert files.include?("testimage3.png")
|
82
|
+
assert files[0] == ("testimage1.png")
|
83
|
+
end
|
84
|
+
|
85
|
+
should 'not return subdirectories if included in file list' do
|
86
|
+
files = @downloader.send(:html_directory_list, '/img')
|
87
|
+
assert_same false, files.include?("backgrounds/")
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
context 'file creation' do
|
92
|
+
|
93
|
+
should 'create a directory if it doesn\'t exist' do
|
94
|
+
directory = File.join(File.dirname(__FILE__), '..', 'tmp', 'test_mkdir')
|
95
|
+
created_or_exists = @downloader.create_dir_path directory
|
96
|
+
assert File.directory? directory
|
97
|
+
assert created_or_exists
|
98
|
+
#cleanup
|
99
|
+
FileUtils.rmdir directory
|
100
|
+
end
|
101
|
+
|
102
|
+
should 'not create a directory if it exists, but report that it exists' do
|
103
|
+
directory = File.join(File.dirname(__FILE__), '..', 'tmp')
|
104
|
+
created_or_exists= @downloader.create_dir_path directory
|
105
|
+
assert created_or_exists
|
106
|
+
end
|
107
|
+
|
108
|
+
end
|
44
109
|
|
45
110
|
end
|
data/test/unit/test_importer.rb
CHANGED
@@ -20,6 +20,11 @@ class TestImporter < Test::Unit::TestCase
|
|
20
20
|
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')
|
21
21
|
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')
|
22
22
|
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')
|
23
|
+
FakeWeb.register_uri(:get, "http://terrific.url/js/libraries/dynamic/", :body => File.expand_path('test/fixtures/html/module.html'), :content_type => 'text/html')
|
24
|
+
FakeWeb.register_uri(:get, "http://terrific.url/terrific/module/details/moduleName/moduleTemplate//format/modulecontent", :body => File.expand_path('test/fixtures/html/modulecontent.html'), :content_type => 'text/html')
|
25
|
+
FakeWeb.register_uri(:get, "http://terrific.url/terrific/module/details/moduleName/moduleTemplate//format/module", :body => File.expand_path('test/fixtures/html/module.html'), :content_type => 'text/html')
|
26
|
+
FakeWeb.register_uri(:get, "http://terrific.url/terrific/module/details/moduleName/moduleTemplate/moduleSkin/format/modulecontent", :body => File.expand_path('test/fixtures/html/modulecontent.html'), :content_type => 'text/html')
|
27
|
+
FakeWeb.register_uri(:get, "http://terrific.url/terrific/module/details/moduleName/moduleTemplate/moduleSkin/format/module", :body => File.expand_path('test/fixtures/html/module.html'), :content_type => 'text/html')
|
23
28
|
end
|
24
29
|
|
25
30
|
def teardown
|
@@ -30,14 +35,14 @@ class TestImporter < Test::Unit::TestCase
|
|
30
35
|
context 'css string replacement' do
|
31
36
|
should 'replace a string in the stylesheet with the configured string' do
|
32
37
|
line = "this line should replace the /img/ string with images"
|
33
|
-
@importer.send(:
|
38
|
+
@importer.send(:replace_stylesheet_lines!, line)
|
34
39
|
assert line.include? "/images/"
|
35
40
|
end
|
36
41
|
|
37
42
|
should 'replace a string in the stylesheet with the configured regex' do
|
38
43
|
@importer.config['stylesheets']['replace_strings'][0]['what'] = "r/(re.+ex)/"
|
39
44
|
line = "this line should replace the regex string with images"
|
40
|
-
@importer.send(:
|
45
|
+
@importer.send(:replace_stylesheet_lines!, line)
|
41
46
|
assert line.include?("/images/"), "result not expected, is #{line}"
|
42
47
|
end
|
43
48
|
|
@@ -45,36 +50,11 @@ class TestImporter < Test::Unit::TestCase
|
|
45
50
|
should 'not do any string replacement if not configured' do
|
46
51
|
@importer.config['stylesheets']['replace_strings'] = nil
|
47
52
|
@importer.import_css
|
53
|
+
|
48
54
|
assert true
|
49
55
|
end
|
50
56
|
end
|
51
57
|
|
52
|
-
context 'file creation' do
|
53
|
-
|
54
|
-
should 'create a directory if it doesn\'t exist' do
|
55
|
-
directory = File.join(File.dirname(__FILE__), '..', 'tmp', 'test_mkdir')
|
56
|
-
created_or_exists = @importer.send(:check_and_create_dir, directory)
|
57
|
-
assert File.directory? directory
|
58
|
-
assert created_or_exists
|
59
|
-
#cleanup
|
60
|
-
FileUtils.rmdir directory
|
61
|
-
end
|
62
|
-
|
63
|
-
should 'not create a directory if it doesnt exist and create isnt used' do
|
64
|
-
directory = File.join(File.dirname(__FILE__), '..', 'tmp', 'test_mkdir')
|
65
|
-
created_or_exists = @importer.send(:check_and_create_dir, directory, false)
|
66
|
-
assert_equal false, File.directory?(directory)
|
67
|
-
assert !created_or_exists
|
68
|
-
end
|
69
|
-
|
70
|
-
should 'not create a directory if it exists, but report that it exists' do
|
71
|
-
directory = File.join(File.dirname(__FILE__), '..', 'tmp')
|
72
|
-
created_or_exists= @importer.send(:check_and_create_dir, directory)
|
73
|
-
assert created_or_exists
|
74
|
-
end
|
75
|
-
|
76
|
-
end
|
77
|
-
|
78
58
|
context 'css and js export path construction' do
|
79
59
|
setup do
|
80
60
|
@importer.config['export_path'] = {'css' => 'base.css', 'js' => 'base.js'}
|
@@ -82,63 +62,27 @@ class TestImporter < Test::Unit::TestCase
|
|
82
62
|
|
83
63
|
should 'raise an error on wrongly supplied arguments' do
|
84
64
|
assert_raise TerrImporter::DefaultError do
|
85
|
-
@importer.send(:
|
65
|
+
@importer.send(:export_path, :invalid)
|
86
66
|
end
|
87
67
|
end
|
88
68
|
|
89
69
|
should 'construct a valid js path for the base.js file' do
|
90
|
-
path = @importer.send(:
|
70
|
+
path = @importer.send(:export_path, :js)
|
91
71
|
assert path.include? 'base.js'
|
92
72
|
end
|
93
73
|
|
94
74
|
should 'construct a valid js path for the base.js file and merge supplied options' do
|
95
|
-
path = @importer.send(:
|
75
|
+
path = @importer.send(:export_path, :js, {:additional => 'option'})
|
96
76
|
assert path.include? 'additional=option'
|
97
77
|
end
|
98
78
|
|
99
79
|
should 'construct a valid js path for the base.css file' do
|
100
|
-
path = @importer.send(:
|
80
|
+
path = @importer.send(:export_path, :css)
|
101
81
|
assert path.include? 'base.css'
|
102
82
|
assert path.include? 'appbaseurl='
|
103
83
|
end
|
104
84
|
end
|
105
85
|
|
106
|
-
context 'file lists' do
|
107
|
-
should 'get a list of files from a directory html page' do
|
108
|
-
files = @importer.send(:html_directory_content_list, '/img')
|
109
|
-
assert files.size == 3
|
110
|
-
assert files.include?("testimage1.png")
|
111
|
-
assert files.include?("testimage2.png")
|
112
|
-
assert files.include?("testimage3.png")
|
113
|
-
assert files[0] == ("testimage1.png")
|
114
|
-
end
|
115
|
-
|
116
|
-
should 'not return subdirectories if included in file list' do
|
117
|
-
files = @importer.send(:html_directory_content_list, '/img')
|
118
|
-
assert_same false, files.include?("backgrounds/")
|
119
|
-
end
|
120
|
-
end
|
121
|
-
|
122
|
-
context 'batch download files' do
|
123
|
-
should 'download all images into the target folder' do
|
124
|
-
@importer.send(:batch_download, '/img', tmp_test_directory)
|
125
|
-
assert exists_in_tmp? 'testimage1.png'
|
126
|
-
assert exists_in_tmp? 'testimage2.png'
|
127
|
-
assert exists_in_tmp? 'testimage3.png'
|
128
|
-
end
|
129
|
-
|
130
|
-
should 'download only files specified by file extension' do
|
131
|
-
@importer.send(:batch_download, '/img/backgrounds/', tmp_test_directory, "doesntexist")
|
132
|
-
assert_same false, exists_in_tmp?('background.jpg')
|
133
|
-
end
|
134
|
-
|
135
|
-
should 'download only files specified by file multiple extension' do
|
136
|
-
@importer.send(:batch_download, '/img/backgrounds/', tmp_test_directory, "doesntexist jpg") #here broken
|
137
|
-
assert exists_in_tmp? 'background.jpg'
|
138
|
-
end
|
139
|
-
|
140
|
-
end
|
141
|
-
|
142
86
|
context 'test public grand import functions - everything is preconfigured' do
|
143
87
|
should 'import all images' do
|
144
88
|
@importer.import_images
|
@@ -160,6 +104,12 @@ class TestImporter < Test::Unit::TestCase
|
|
160
104
|
assert exists_in_tmp?('public/javascripts/lib/dynlib.js')
|
161
105
|
end
|
162
106
|
|
107
|
+
should 'import all module files' do
|
108
|
+
@importer.import_modules
|
109
|
+
assert exists_in_tmp?('modules/moduleName.html')
|
110
|
+
assert exists_in_tmp?('modules/moduleName_moduleSkin.html')
|
111
|
+
end
|
112
|
+
|
163
113
|
end
|
164
114
|
|
165
115
|
context 'execute run and check for correct resolve of commands' do
|
@@ -192,22 +142,32 @@ class TestImporter < Test::Unit::TestCase
|
|
192
142
|
|
193
143
|
end
|
194
144
|
|
195
|
-
context '
|
196
|
-
should '
|
145
|
+
context 'missing configuration values' do
|
146
|
+
should 'run through but not throw an error if the servers library path is not specified' do
|
147
|
+
@importer.config['libraries_server_path'] = nil
|
197
148
|
assert_nothing_raised do
|
198
|
-
@importer.
|
149
|
+
@importer.import_js
|
199
150
|
end
|
151
|
+
end
|
200
152
|
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
153
|
+
should 'run through but not throw an error if the images path is not specified' do
|
154
|
+
@importer.config['images'] = nil
|
155
|
+
assert_nothing_raised do
|
156
|
+
@importer.import_images
|
157
|
+
end
|
158
|
+
end
|
159
|
+
|
160
|
+
should 'run through but not throw an error if no modules are specified' do
|
161
|
+
@importer.config['modules'] = nil
|
162
|
+
assert_nothing_raised do
|
163
|
+
@importer.import_modules
|
164
|
+
end
|
205
165
|
end
|
206
|
-
end
|
207
166
|
|
167
|
+
end
|
208
168
|
|
209
|
-
|
210
|
-
|
169
|
+
context 'module import' do
|
170
|
+
#todo tests missing
|
211
171
|
end
|
212
172
|
|
213
173
|
end
|
data/test/unit/test_options.rb
CHANGED
@@ -19,8 +19,8 @@ class TestOptions < Test::Unit::TestCase
|
|
19
19
|
context "default options" do
|
20
20
|
setup { setup_options }
|
21
21
|
|
22
|
-
should "be in verbose mode" do
|
23
|
-
assert_equal
|
22
|
+
should "not be in verbose mode" do
|
23
|
+
assert_equal false, @options[:verbose]
|
24
24
|
end
|
25
25
|
|
26
26
|
should "have no default import statement" do
|
@@ -90,6 +90,7 @@ class TestOptions < Test::Unit::TestCase
|
|
90
90
|
assert @options[:import_css]
|
91
91
|
assert @options[:import_js]
|
92
92
|
assert @options[:import_images]
|
93
|
+
assert @options[:import_modules]
|
93
94
|
end
|
94
95
|
end
|
95
96
|
|
@@ -98,6 +99,7 @@ class TestOptions < Test::Unit::TestCase
|
|
98
99
|
assert @options[:import_css]
|
99
100
|
assert @options[:import_js]
|
100
101
|
assert @options[:import_images]
|
102
|
+
assert @options[:import_modules]
|
101
103
|
end
|
102
104
|
end
|
103
105
|
|
@@ -131,12 +133,30 @@ class TestOptions < Test::Unit::TestCase
|
|
131
133
|
end
|
132
134
|
end
|
133
135
|
|
134
|
-
for_options '-
|
136
|
+
for_options '-invalidoption' do
|
137
|
+
should 'show the invalid option error message' do
|
138
|
+
assert !@options[:invalid_option].nil?
|
139
|
+
end
|
140
|
+
end
|
141
|
+
|
142
|
+
for_options '--init', 'BACKUP' do
|
135
143
|
should 'show the invalid argument error message' do
|
136
144
|
assert !@options[:invalid_argument].nil?
|
137
145
|
end
|
138
146
|
end
|
139
147
|
|
148
|
+
for_options '-m' do
|
149
|
+
should 'import all modules' do
|
150
|
+
assert @options[:import_modules]
|
151
|
+
end
|
152
|
+
end
|
153
|
+
|
154
|
+
for_options '--module' do
|
155
|
+
should 'import all modules' do
|
156
|
+
assert @options[:import_modules]
|
157
|
+
end
|
158
|
+
end
|
159
|
+
|
140
160
|
context 'use application uri' do
|
141
161
|
setup do
|
142
162
|
@uri = 'http://terrific.app.uri'
|
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
|
-
-
|
9
|
-
-
|
10
|
-
version: 0.
|
8
|
+
- 7
|
9
|
+
- 0
|
10
|
+
version: 0.7.0
|
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-
|
18
|
+
date: 2011-09-15 00:00:00 Z
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
21
21
|
name: kwalify
|
@@ -125,25 +125,30 @@ files:
|
|
125
125
|
- Rakefile
|
126
126
|
- bin/terrimporter
|
127
127
|
- config/schema.yml
|
128
|
-
- config/terrimporter.
|
128
|
+
- config/terrimporter.yml
|
129
129
|
- lib/terrimporter.rb
|
130
130
|
- lib/terrimporter/app_logger.rb
|
131
131
|
- lib/terrimporter/array_monkeypatch.rb
|
132
|
-
- lib/terrimporter/config_helper.rb
|
133
132
|
- lib/terrimporter/configuration.rb
|
133
|
+
- lib/terrimporter/configuration_helper.rb
|
134
|
+
- lib/terrimporter/download_helper.rb
|
134
135
|
- lib/terrimporter/downloader.rb
|
135
136
|
- lib/terrimporter/importer.rb
|
137
|
+
- lib/terrimporter/importer_helper.rb
|
136
138
|
- lib/terrimporter/options.rb
|
137
139
|
- lib/terrimporter/string_monkeypatch.rb
|
138
140
|
- lib/terrimporter/version.rb
|
139
|
-
- terrimporter.config.yml.bak
|
140
141
|
- terrimporter.gemspec
|
141
142
|
- test/fixtures/css/base.css
|
142
143
|
- test/fixtures/css/ie.css
|
143
144
|
- test/fixtures/html/application_root.html
|
145
|
+
- test/fixtures/html/application_root_css_error.html
|
146
|
+
- test/fixtures/html/application_root_js_error.html
|
144
147
|
- test/fixtures/html/img_backgrounds_dir.html
|
145
148
|
- test/fixtures/html/img_dir.html
|
146
149
|
- test/fixtures/html/js_dyn_dir.html
|
150
|
+
- test/fixtures/html/module.html
|
151
|
+
- test/fixtures/html/modulecontent.html
|
147
152
|
- test/fixtures/img/background.jpg
|
148
153
|
- test/fixtures/img/testimage.png
|
149
154
|
- test/fixtures/invalid.config.yml
|
@@ -196,7 +201,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
196
201
|
requirements: []
|
197
202
|
|
198
203
|
rubyforge_project: terrimporter
|
199
|
-
rubygems_version: 1.8.
|
204
|
+
rubygems_version: 1.8.9
|
200
205
|
signing_key:
|
201
206
|
specification_version: 3
|
202
207
|
summary: Import terrific javascripts, css files and images into a web project
|
@@ -204,9 +209,13 @@ test_files:
|
|
204
209
|
- test/fixtures/css/base.css
|
205
210
|
- test/fixtures/css/ie.css
|
206
211
|
- test/fixtures/html/application_root.html
|
212
|
+
- test/fixtures/html/application_root_css_error.html
|
213
|
+
- test/fixtures/html/application_root_js_error.html
|
207
214
|
- test/fixtures/html/img_backgrounds_dir.html
|
208
215
|
- test/fixtures/html/img_dir.html
|
209
216
|
- test/fixtures/html/js_dyn_dir.html
|
217
|
+
- test/fixtures/html/module.html
|
218
|
+
- test/fixtures/html/modulecontent.html
|
210
219
|
- test/fixtures/img/background.jpg
|
211
220
|
- test/fixtures/img/testimage.png
|
212
221
|
- test/fixtures/invalid.config.yml
|
data/terrimporter.config.yml.bak
DELETED
@@ -1,47 +0,0 @@
|
|
1
|
-
#-------------------------------------------------------------------------------
|
2
|
-
# terrimporter configuration, adjust as needed. Don't mess with indentation!
|
3
|
-
#-------------------------------------------------------------------------------
|
4
|
-
# url: Terrific base url
|
5
|
-
application_url: test
|
6
|
-
|
7
|
-
# STYLESHEETS
|
8
|
-
stylesheets:
|
9
|
-
# The destination directory, relative from the current running directory
|
10
|
-
relative_destination_path: public/stylesheets/
|
11
|
-
# Additional stylesheets, you can but don't have to add the .css extension
|
12
|
-
# styles: ie, ie6, ie7.css
|
13
|
-
# replace_strings: Define string replacements in css files
|
14
|
-
# (use multiple replacements by repeating the '-what: with:' statements)
|
15
|
-
replace_strings:
|
16
|
-
# - what: /img/ # What to replace, format: [string] or [r/regex/]
|
17
|
-
# with: /images/ # Replace with [string]
|
18
|
-
|
19
|
-
# JAVASCRIPTS
|
20
|
-
javascripts:
|
21
|
-
# Destination path of the javascript base.js file
|
22
|
-
relative_destination_path: public/javascripts/
|
23
|
-
# Dynamic libraries definition, you can but don't have to add the .js extension
|
24
|
-
# dynamic_libraries: foo_lib.js bar_lib.js
|
25
|
-
# Destination path of the dynamic libraries relative
|
26
|
-
# libraries_relative_destination_path: public/javascripts/libraries/
|
27
|
-
|
28
|
-
# IMAGES - multiple entries allowed
|
29
|
-
images:
|
30
|
-
# - server_path: / # The server path is appended to the image_server_path
|
31
|
-
# relative_destination_path: public/images/ # The relative destination path
|
32
|
-
# file_types: jpg, png, gif # Image file endings to be downloaded
|
33
|
-
|
34
|
-
#-------------------------------------------------------------------------------
|
35
|
-
# ADVANCED EDITING - Only edit the following if you know what you're doing...
|
36
|
-
# ------------------------------------------------------------------------------
|
37
|
-
# The settings below are added as query string parameters to the export path
|
38
|
-
export_settings:
|
39
|
-
debug: false # False compacts the base.js and base.css files
|
40
|
-
cache: false # You most probably won't have to change this
|
41
|
-
layout: project # You most probably won't have to change this
|
42
|
-
|
43
|
-
# The server side library source path for the dynamic libraries
|
44
|
-
libraries_server_path: /js/libraries/dynamic
|
45
|
-
|
46
|
-
# The server side image base path
|
47
|
-
image_server_path: /img
|