terrimporter 0.7.3 → 0.7.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/Gemfile.lock +1 -1
- data/README.rdoc +4 -0
- data/config/schema.yml +10 -0
- data/config/terrimporter.yml +5 -1
- data/lib/terrimporter/app_logger.rb +14 -11
- data/lib/terrimporter/array_monkeypatch.rb +1 -1
- data/lib/terrimporter/configuration.rb +60 -87
- data/lib/terrimporter/configuration_helper.rb +31 -22
- data/lib/terrimporter/configuration_loader.rb +85 -0
- data/lib/terrimporter/download_helper.rb +1 -1
- data/lib/terrimporter/downloader.rb +19 -10
- data/lib/terrimporter/error.rb +10 -0
- data/lib/terrimporter/importer.rb +57 -49
- data/lib/terrimporter/statistic.rb +37 -0
- data/lib/terrimporter/stylesheet_importer.rb +56 -0
- data/lib/terrimporter/version.rb +2 -2
- data/lib/terrimporter.rb +12 -2
- data/test/fixtures/invalid.config.yml +1 -0
- data/test/fixtures/js/dynplugin.js +1 -0
- data/test/fixtures/minimal.test.config.yml +1 -0
- data/test/fixtures/test.config.yml +3 -0
- data/test/unit/test_arraymonkeypatch.rb +1 -1
- data/test/unit/test_configuration.rb +14 -107
- data/test/unit/{test_config_helper.rb → test_configuration_helper.rb} +7 -6
- data/test/unit/test_configuration_loader.rb +86 -0
- data/test/unit/test_downloader.rb +16 -5
- data/test/unit/test_importer.rb +3 -1
- data/test/unit/test_statistics.rb +44 -0
- metadata +16 -6
@@ -1,52 +1,54 @@
|
|
1
1
|
module TerrImporter
|
2
|
-
|
3
|
-
class DefaultError < StandardError
|
4
|
-
end
|
5
|
-
|
6
|
-
class ConfigurationError < StandardError
|
7
|
-
end
|
8
|
-
|
9
|
-
class ConfigurationMissingError < StandardError
|
10
|
-
end
|
11
|
-
|
12
2
|
class Application
|
3
|
+
#todo split importer into css_importer, image_importer, module_importer, js_importer
|
13
4
|
class Importer
|
14
5
|
include ImporterHelper
|
15
6
|
attr_accessor :options, :config
|
16
7
|
|
17
8
|
def initialize(options = {})
|
18
9
|
self.options = options
|
19
|
-
|
20
|
-
self.config.load_configuration
|
21
|
-
|
10
|
+
loader = ConfigurationLoader.new(options[:config_file])
|
11
|
+
self.config = loader.load_configuration
|
12
|
+
initialize_downloader
|
13
|
+
end
|
14
|
+
|
15
|
+
def initialize_downloader
|
16
|
+
@downloader = Downloader.new(config.application_url)
|
22
17
|
end
|
23
18
|
|
24
19
|
def run
|
25
20
|
if options[:all] != nil and options[:all] == true
|
26
|
-
|
27
|
-
import_js
|
28
|
-
import_css
|
29
|
-
import_images
|
30
|
-
import_modules
|
21
|
+
run_all_imports
|
31
22
|
else
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
23
|
+
run_specific_imports
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
def run_all_imports
|
28
|
+
LOG.info "Import everything"
|
29
|
+
import_js
|
30
|
+
import_css
|
31
|
+
import_images
|
32
|
+
import_modules
|
33
|
+
end
|
34
|
+
|
35
|
+
def run_specific_imports
|
36
|
+
options.each do |option, value|
|
37
|
+
if option.to_s =~ /^import_/ and value == true
|
38
|
+
LOG.info "Import of #{option.to_s.split('_').last} started"
|
39
|
+
self.send option.to_s
|
37
40
|
end
|
38
41
|
end
|
39
42
|
end
|
40
43
|
|
41
44
|
def import_css
|
42
45
|
LOG.info("Importing stylesheets")
|
43
|
-
complete_config!
|
44
46
|
|
45
47
|
unclean_suffix = "_unclean"
|
46
48
|
stylesheets = config.stylesheets
|
47
49
|
|
48
50
|
stylesheets.each do |css|
|
49
|
-
file_path = File.join(config
|
51
|
+
file_path = File.join(config.stylesheets_destination, css)
|
50
52
|
options = {}
|
51
53
|
options[:suffix] = $1 if css =~ /(ie.*).css$/ #add ie option if in array
|
52
54
|
source_url = export_path(:css, options)
|
@@ -74,7 +76,7 @@ module TerrImporter
|
|
74
76
|
FileUtils.remove unclean_file_path
|
75
77
|
end
|
76
78
|
else
|
77
|
-
|
79
|
+
FileUtils.remove(file_path)
|
78
80
|
LOG.debug "Deleting empty"
|
79
81
|
end
|
80
82
|
end
|
@@ -82,32 +84,44 @@ module TerrImporter
|
|
82
84
|
|
83
85
|
def import_js
|
84
86
|
LOG.info("Importing javascripts")
|
85
|
-
|
86
|
-
file_path = File.join(config['javascripts']['destination_path'], "base.js")
|
87
|
+
file_path = File.join(config.javascripts_destination, "base.js")
|
87
88
|
js_source_url = export_path(:js)
|
88
89
|
LOG.debug "Import base.js from #{js_source_url} to #{file_path}"
|
89
90
|
@downloader.download(js_source_url, file_path)
|
90
91
|
|
91
|
-
if config.
|
92
|
-
if config
|
92
|
+
if config.has_dynamic_javascripts?
|
93
|
+
if config.libraries_server_path.nil?
|
93
94
|
LOG.info "Define 'libraries_server_path' in configuration file"
|
94
95
|
else
|
95
96
|
libraries_file_path = config.libraries_destination_path
|
96
|
-
LOG.info "Import libraries from #{config
|
97
|
+
LOG.info "Import libraries from #{config.libraries_server_path} to #{libraries_file_path}"
|
97
98
|
js_libraries = config.dynamic_libraries
|
98
99
|
js_libraries.each do |lib|
|
99
|
-
@downloader.download(File.join(config
|
100
|
+
@downloader.download(File.join(config.libraries_server_path, lib), File.join(libraries_file_path, lib))
|
100
101
|
end
|
101
102
|
end
|
102
103
|
end
|
104
|
+
|
105
|
+
if config.has_dynamic_plugins?
|
106
|
+
if config.plugins_server_path.nil?
|
107
|
+
LOG.info "Define 'plugins_server_path' in configuration file"
|
108
|
+
else
|
109
|
+
plugins_file_path = config.plugins_destination_path
|
110
|
+
LOG.info "Import plugins from #{config.plugins_server_path} to #{plugins_file_path}"
|
111
|
+
js_plugins = config.dynamic_plugins
|
112
|
+
js_plugins.each do |lib|
|
113
|
+
@downloader.download(File.join(config.plugins_server_path, lib), File.join(plugins_file_path, lib))
|
114
|
+
end
|
115
|
+
end
|
116
|
+
end
|
103
117
|
end
|
104
118
|
|
105
119
|
def import_images
|
106
|
-
|
107
|
-
if config.
|
120
|
+
|
121
|
+
if config.has_images?
|
108
122
|
LOG.info "Import images"
|
109
|
-
config
|
110
|
-
image_source_path = File.join(config
|
123
|
+
config.images.each do |image|
|
124
|
+
image_source_path = File.join(config.images_server_path, image['server_path'])
|
111
125
|
@downloader.batch_download(image_source_path, image['destination_path'], image['file_types'])
|
112
126
|
end
|
113
127
|
else
|
@@ -115,17 +129,11 @@ module TerrImporter
|
|
115
129
|
end
|
116
130
|
end
|
117
131
|
|
118
|
-
def complete_config!
|
119
|
-
unless config.mandatory_present?
|
120
|
-
config.determine_configuration_values_from_html @downloader.download('')
|
121
|
-
end
|
122
|
-
end
|
123
|
-
|
124
132
|
def import_modules
|
125
|
-
|
126
|
-
if config.
|
133
|
+
|
134
|
+
if config.has_modules?
|
127
135
|
LOG.info "Module import"
|
128
|
-
config
|
136
|
+
config.modules.each do |mod|
|
129
137
|
name = mod['name']
|
130
138
|
skin = mod['skin']
|
131
139
|
module_source_url = module_path(name, mod['module_template'], skin, mod['template_only'])
|
@@ -142,7 +150,7 @@ module TerrImporter
|
|
142
150
|
skin = '' if skin.nil?
|
143
151
|
raise ConfigurationError, "Name cannot be empty for template" if name.nil?
|
144
152
|
raise ConfigurationError, "Module template missing in configuration for template #{name}" if module_template.nil?
|
145
|
-
export_path = config
|
153
|
+
export_path = config.application_url.clone
|
146
154
|
export_path << "/terrific/module/details/#{name}/#{module_template}/#{skin}/format/module#{"content" if template}"
|
147
155
|
export_path
|
148
156
|
end
|
@@ -151,17 +159,17 @@ module TerrImporter
|
|
151
159
|
|
152
160
|
def export_path(for_what = :js, options={})
|
153
161
|
raise DefaultError, "Specify js or css url" unless for_what == :js or for_what == :css
|
154
|
-
export_settings = config
|
162
|
+
export_settings = config.export_settings.clone
|
155
163
|
export_settings.merge!(options)
|
156
164
|
export_settings['appbaseurl'] = "" if for_what == :css
|
157
165
|
|
158
|
-
export_path = config
|
166
|
+
export_path = for_what == :js ? config.js_export_path.clone : config.css_export_path.clone
|
159
167
|
export_path << '?' << export_settings.map { |k, v| "#{URI.escape(k.to_s)}=#{URI.escape(v.to_s)}" }.join("&")
|
160
168
|
export_path
|
161
169
|
end
|
162
170
|
|
163
171
|
def replace_stylesheet_lines!(line)
|
164
|
-
config
|
172
|
+
config.stylesheet_replace_strings.each do |replace|
|
165
173
|
replace_line!(line, replace['what'], replace['with'])
|
166
174
|
end
|
167
175
|
line
|
@@ -0,0 +1,37 @@
|
|
1
|
+
class Statistic
|
2
|
+
attr_accessor :statistics, :times
|
3
|
+
|
4
|
+
def initialize
|
5
|
+
@header = ["-------------------------------",
|
6
|
+
" SUMMARY ",
|
7
|
+
"-------------------------------"]
|
8
|
+
|
9
|
+
self.statistics = {
|
10
|
+
:download => {:count => 0, :message => ""},
|
11
|
+
:js => {:count => 0, :message => ""},
|
12
|
+
:css => {:count => 0, :message => ""},
|
13
|
+
:image => {:count => 0, :message => ""},
|
14
|
+
:error => {:count => 0, :message => ""}
|
15
|
+
}
|
16
|
+
end
|
17
|
+
|
18
|
+
def add_message(type, message)
|
19
|
+
self.statistics[type][:message] = message
|
20
|
+
end
|
21
|
+
|
22
|
+
def add(type, count)
|
23
|
+
self.statistics[type][:count] += count
|
24
|
+
end
|
25
|
+
|
26
|
+
def print_summary
|
27
|
+
@header.each do |h|
|
28
|
+
puts h
|
29
|
+
end
|
30
|
+
self.statistics.each do |key, value|
|
31
|
+
puts "#{key.to_s.upcase}: [#{value[:count]}] #{value[:message]}" unless value[:count] == 0
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
end
|
36
|
+
|
37
|
+
STAT = Statistic.new
|
@@ -0,0 +1,56 @@
|
|
1
|
+
#major todo!!
|
2
|
+
=begin
|
3
|
+
module TerrImporter
|
4
|
+
class Application
|
5
|
+
class StylesheetImporter
|
6
|
+
include ImporterHelper
|
7
|
+
attr_accessor :config
|
8
|
+
|
9
|
+
def initialize(configuration)
|
10
|
+
self.config = configuration
|
11
|
+
end
|
12
|
+
|
13
|
+
def import!
|
14
|
+
LOG.info("Importing stylesheets")
|
15
|
+
unclean_suffix = "_unclean"
|
16
|
+
stylesheets = config.stylesheets
|
17
|
+
|
18
|
+
stylesheets.each do |css|
|
19
|
+
file_path = File.join(config.stylesheets_destination, css)
|
20
|
+
options = {}
|
21
|
+
options[:suffix] = $1 if css =~ /(ie.*).css$/ #add ie option if in array
|
22
|
+
source_url = export_path(:css, options)
|
23
|
+
unclean_file_path = file_path + unclean_suffix;
|
24
|
+
constructed_file_path = (config.replace_style_strings? ? unclean_file_path : file_path)
|
25
|
+
@downloader.download(source_url, constructed_file_path)
|
26
|
+
|
27
|
+
if file_contains_valid_css?(constructed_file_path)
|
28
|
+
if config.replace_style_strings?
|
29
|
+
LOG.info "CSS line replacements"
|
30
|
+
File.open(file_path, 'w') do |d|
|
31
|
+
File.open(constructed_file_path, 'r') do |s|
|
32
|
+
lines = s.readlines
|
33
|
+
lines.each do |line|
|
34
|
+
d.print replace_stylesheet_lines!(line)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
else
|
39
|
+
LOG.debug "Skipping css line replacements"
|
40
|
+
end
|
41
|
+
|
42
|
+
if File.exists?(unclean_file_path)
|
43
|
+
LOG.debug "Deleting unclean css files"
|
44
|
+
FileUtils.remove unclean_file_path
|
45
|
+
end
|
46
|
+
else
|
47
|
+
File.remove(file_path)
|
48
|
+
LOG.debug "Deleting empty"
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
=end
|
data/lib/terrimporter/version.rb
CHANGED
data/lib/terrimporter.rb
CHANGED
@@ -1,4 +1,6 @@
|
|
1
1
|
require 'shellwords'
|
2
|
+
require 'terrimporter/error'
|
3
|
+
require 'terrimporter/statistic'
|
2
4
|
require 'terrimporter/version'
|
3
5
|
require 'terrimporter/download_helper'
|
4
6
|
require 'terrimporter/app_logger'
|
@@ -6,6 +8,7 @@ require 'terrimporter/options'
|
|
6
8
|
require 'terrimporter/importer_helper'
|
7
9
|
require 'terrimporter/importer'
|
8
10
|
require 'terrimporter/configuration_helper'
|
11
|
+
require 'terrimporter/configuration_loader'
|
9
12
|
require 'terrimporter/configuration'
|
10
13
|
require 'terrimporter/downloader'
|
11
14
|
require 'terrimporter/string_monkeypatch'
|
@@ -22,6 +25,7 @@ module TerrImporter
|
|
22
25
|
include Shellwords
|
23
26
|
include ConfigurationHelper
|
24
27
|
|
28
|
+
#todo refactor into smaller methods
|
25
29
|
def run!(*arguments)
|
26
30
|
options = build_options(arguments)
|
27
31
|
|
@@ -30,7 +34,13 @@ module TerrImporter
|
|
30
34
|
if config_working_directory_exists? and options[:init] != :backup and options[:init] != :replace
|
31
35
|
raise TerrImporter::ConfigurationError, "Configuration already exists, use the override or backup option"
|
32
36
|
end
|
33
|
-
|
37
|
+
case options[:init]
|
38
|
+
when :backup
|
39
|
+
backup_config_file
|
40
|
+
when :replace
|
41
|
+
remove_config_file
|
42
|
+
end
|
43
|
+
create_config_file(options[:application_url])
|
34
44
|
return 0
|
35
45
|
end
|
36
46
|
|
@@ -41,7 +51,6 @@ module TerrImporter
|
|
41
51
|
LOG.level = :info
|
42
52
|
end
|
43
53
|
|
44
|
-
|
45
54
|
if options[:invalid_argument]
|
46
55
|
$stderr.puts options[:invalid_argument]
|
47
56
|
options[:show_help] = true
|
@@ -64,6 +73,7 @@ module TerrImporter
|
|
64
73
|
|
65
74
|
importer = TerrImporter::Application::Importer.new(options)
|
66
75
|
importer.run
|
76
|
+
STAT.print_summary
|
67
77
|
return 0
|
68
78
|
rescue TerrImporter::ConfigurationError
|
69
79
|
$stderr.puts %Q{Configuration Error #{ $!.message }}
|
@@ -0,0 +1 @@
|
|
1
|
+
This file represents a dynamic js library.
|
@@ -1,5 +1,6 @@
|
|
1
1
|
application_url: http://terrific.url
|
2
2
|
libraries_server_path: /js/libraries/dynamic
|
3
|
+
plugins_server_path: /js/plugins/dynamic
|
3
4
|
image_server_path: /img
|
4
5
|
export_settings:
|
5
6
|
layout: project
|
@@ -15,6 +16,8 @@
|
|
15
16
|
destination_path: test/tmp/public/javascripts/
|
16
17
|
dynamic_libraries: dynlib
|
17
18
|
libraries_destination_path: test/tmp/public/javascripts/lib
|
19
|
+
dynamic_plugins: dynplugin
|
20
|
+
plugins_destination_path: test/tmp/public/javascripts/plugins
|
18
21
|
images:
|
19
22
|
- server_path: /
|
20
23
|
destination_path: test/tmp/public/images/
|
@@ -5,7 +5,7 @@ class TestArrayMonkeypatch < Test::Unit::TestCase
|
|
5
5
|
testarray = ["file1.css", "file2", "file3", "file4.css"]
|
6
6
|
expected = ["file1.css", "file2.css", "file3.css", "file4.css"]
|
7
7
|
|
8
|
-
assert_equal expected, testarray.
|
8
|
+
assert_equal expected, testarray.add_missing_extension!('.css')
|
9
9
|
assert_equal expected, expected.join(" ").robust_split
|
10
10
|
end
|
11
11
|
|
@@ -5,31 +5,25 @@ class ConfigurationTest < Test::Unit::TestCase
|
|
5
5
|
include ConfigurationHelper
|
6
6
|
|
7
7
|
def setup
|
8
|
-
|
9
|
-
@configuration.load_configuration
|
10
|
-
end
|
11
|
-
|
12
|
-
should 'find a configuration in the local path and not raise an error' do
|
13
|
-
assert_nothing_raised do
|
14
|
-
@configuration.determine_config_file_path
|
15
|
-
end
|
8
|
+
FakeWeb.register_uri(:get, "http://terrific.url", :body => File.expand_path('test/fixtures/html/application_root.html'), :content_type => 'text/plain')
|
9
|
+
@configuration = TerrImporter::Application::ConfigurationLoader.new(test_config_file_path).load_configuration
|
16
10
|
end
|
17
11
|
|
18
12
|
should 'have an image configuration' do
|
19
|
-
assert @configuration.
|
13
|
+
assert @configuration.has_images?
|
20
14
|
end
|
21
15
|
|
22
16
|
should 'have dynamic libraries' do
|
23
|
-
assert @configuration.
|
17
|
+
assert @configuration.has_dynamic_javascripts?
|
24
18
|
end
|
25
19
|
|
26
20
|
should 'have modules' do
|
27
|
-
assert @configuration.
|
21
|
+
assert @configuration.has_modules?
|
28
22
|
end
|
29
23
|
|
30
24
|
should 'use the normal libraries path if no dynamic libraries are specified' do
|
31
25
|
@configuration['javascripts']['libraries_destination_path'] = nil
|
32
|
-
assert
|
26
|
+
assert @configuration['javascripts']['destination_path'], @configuration.libraries_destination_path
|
33
27
|
end
|
34
28
|
|
35
29
|
should 'have style replacement strings' do
|
@@ -37,78 +31,27 @@ class ConfigurationTest < Test::Unit::TestCase
|
|
37
31
|
end
|
38
32
|
|
39
33
|
should 'have additional stylesheets configured' do
|
40
|
-
assert @configuration.
|
41
|
-
end
|
42
|
-
|
43
|
-
context 'no configuration file around' do
|
44
|
-
setup { @invalid_configuration = TerrImporter::Application::Configuration.new }
|
45
|
-
|
46
|
-
should 'not find a configuration in the local path and raise an error' do
|
47
|
-
assert_raise TerrImporter::ConfigurationError do
|
48
|
-
@invalid_configuration.load_configuration
|
49
|
-
@invalid_configuration
|
50
|
-
end
|
51
|
-
end
|
52
|
-
end
|
53
|
-
|
54
|
-
context 'invalid config file' do
|
55
|
-
setup do
|
56
|
-
@configuration = TerrImporter::Application::Configuration.new invalid_test_config_file_path
|
57
|
-
end
|
58
|
-
|
59
|
-
should 'throw an error on an invalid config file' do
|
60
|
-
assert_raise TerrImporter::ConfigurationError do
|
61
|
-
@configuration.load_configuration
|
62
|
-
end
|
63
|
-
end
|
64
|
-
end
|
65
|
-
|
66
|
-
context 'test config file independent functions' do
|
67
|
-
setup {
|
68
|
-
@configuration = TerrImporter::Application::Configuration.new
|
69
|
-
}
|
70
|
-
|
71
|
-
should 'get the current working directory as config file path' do
|
72
|
-
config_in_cwd = File.join(Dir.pwd, config_default_name)
|
73
|
-
assert_equal config_in_cwd, @configuration.determine_config_file_path
|
74
|
-
end
|
75
|
-
|
76
|
-
should 'create a config file in the current directory' do
|
77
|
-
config_path = File.join(Dir.pwd, config_default_name)
|
78
|
-
FileUtils.rm_f config_path if File.exists? config_path
|
79
|
-
@configuration.create_config_file
|
80
|
-
assert File.exists?(config_path)
|
81
|
-
end
|
82
|
-
end
|
83
|
-
|
84
|
-
context 'required configurations' do
|
85
|
-
should 'test for all the required configurations needed to function properly' do
|
86
|
-
#these values are set by the downloader
|
87
|
-
@configuration['export_path'] = 'present'
|
88
|
-
@configuration['export_settings'] = {'application' => 'present'}
|
89
|
-
@configuration['application_url'] = 'present'
|
90
|
-
|
91
|
-
assert @configuration.mandatory_present?
|
92
|
-
end
|
34
|
+
assert @configuration.has_stylesheets?
|
93
35
|
end
|
94
36
|
|
95
37
|
context 'minimal working configuration' do
|
96
38
|
setup do
|
97
|
-
@
|
39
|
+
@loader = TerrImporter::Application::ConfigurationLoader.new min_test_config_file_path
|
40
|
+
@configuration = @loader.load_configuration
|
98
41
|
end
|
99
42
|
|
100
43
|
should 'not raise an error when loading the minimal configuration' do
|
101
44
|
assert_nothing_raised do
|
102
|
-
@
|
45
|
+
@loader.load_configuration
|
103
46
|
end
|
104
47
|
end
|
105
48
|
|
106
49
|
should 'not have an image configuration' do
|
107
|
-
assert !@configuration.
|
50
|
+
assert !@configuration.has_images?
|
108
51
|
end
|
109
52
|
|
110
53
|
should 'not have dynamic libraries' do
|
111
|
-
assert !@configuration.
|
54
|
+
assert !@configuration.has_dynamic_javascripts?
|
112
55
|
end
|
113
56
|
|
114
57
|
should 'not have style replacement strings' do
|
@@ -116,7 +59,7 @@ class ConfigurationTest < Test::Unit::TestCase
|
|
116
59
|
end
|
117
60
|
|
118
61
|
should 'not have additional stylesheets configured' do
|
119
|
-
assert !@configuration.
|
62
|
+
assert !@configuration.has_stylesheets?
|
120
63
|
end
|
121
64
|
|
122
65
|
should 'only get the base.css file' do
|
@@ -124,43 +67,7 @@ class ConfigurationTest < Test::Unit::TestCase
|
|
124
67
|
end
|
125
68
|
|
126
69
|
should 'not have additional modules' do
|
127
|
-
assert !@configuration.
|
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
|
-
|
159
|
-
#todo why is this failing?
|
160
|
-
=begin
|
161
|
-
should 'return javascript destination path if libraries destination path is undefined' do
|
162
|
-
assert_equal @configuration['javascripts']['destination_path'], @configuration.libraries_destination_path
|
70
|
+
assert !@configuration.has_modules?
|
163
71
|
end
|
164
|
-
=end
|
165
72
|
end
|
166
73
|
end
|
@@ -11,15 +11,16 @@ class ConfigValidatorTest < Test::Unit::TestCase
|
|
11
11
|
|
12
12
|
should 'create a configuration file and backup the old one' do
|
13
13
|
create_config_file
|
14
|
-
|
14
|
+
backup_config_file
|
15
15
|
assert File.exists?(config_working_directory_path + '.bak')
|
16
|
-
|
16
|
+
assert_same false, File.exists?(config_working_directory_path)
|
17
17
|
end
|
18
18
|
|
19
19
|
should 'create a configuration file and remove the old one' do
|
20
|
-
config_working_directory_path
|
21
|
-
create_config_file
|
22
|
-
|
20
|
+
config_working_directory_path #todo whats this?
|
21
|
+
create_config_file
|
22
|
+
remove_config_file
|
23
|
+
assert_same false, File.exists?(config_working_directory_path)
|
23
24
|
end
|
24
25
|
|
25
26
|
should 'create a configuration file' do
|
@@ -29,7 +30,7 @@ class ConfigValidatorTest < Test::Unit::TestCase
|
|
29
30
|
|
30
31
|
should 'create a configuration file and replace the application url' do
|
31
32
|
application_url = "http://test.url"
|
32
|
-
create_config_file(
|
33
|
+
create_config_file(application_url)
|
33
34
|
configuration = File.read(config_working_directory_path)
|
34
35
|
assert configuration.include?("application_url: #{application_url}")
|
35
36
|
end
|