more config loader and file processor work
This commit is contained in:
parent
ac31b5f98f
commit
480a911bf6
@ -1,3 +1,5 @@
|
||||
require File.dirname(__FILE__) + '/Scheduler.rb'
|
||||
|
||||
class ConfigLoader
|
||||
def load(file)
|
||||
config = load_yaml(file)
|
||||
@ -61,6 +63,15 @@ class ConfigLoader
|
||||
|
||||
config['Global'] = global
|
||||
|
||||
scheduler = Scheduler.instance
|
||||
config.each do |type, info|
|
||||
if type != "Global"
|
||||
if info['schedule']
|
||||
info['publish_dates'] = scheduler.schedule(info['schedule'], files.length)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
config
|
||||
end
|
||||
|
||||
|
@ -1,3 +1,4 @@
|
||||
require File.dirname(__FILE__) + '/../modules/PrintHandling.rb'
|
||||
require File.dirname(__FILE__) + '/InputFilter.rb'
|
||||
|
||||
class SVGToTempBitmap < InputFilter
|
||||
|
@ -1,3 +1,6 @@
|
||||
require File.dirname(__FILE__) + '/OutputFilter.rb'
|
||||
require File.dirname(__FILE__) + '/../modules/PrintHandling.rb'
|
||||
require File.dirname(__FILE__) + '/../modules/Pagination.rb'
|
||||
|
||||
#
|
||||
# Convert bitmap files to a paginated print-ready file
|
||||
|
@ -1,6 +1,8 @@
|
||||
require 'rubygems'
|
||||
require 'test/unit'
|
||||
require 'mocha'
|
||||
require File.dirname(__FILE__) + '/../classes/ConfigLoader.rb'
|
||||
require File.dirname(__FILE__) + '/../classes/Scheduler.rb'
|
||||
|
||||
class TestConfigLoader < Test::Unit::TestCase
|
||||
def setup
|
||||
@ -36,6 +38,9 @@ class TestConfigLoader < Test::Unit::TestCase
|
||||
'path' => '*.svg',
|
||||
'match' => '.*\.svg',
|
||||
'page_index_format' => '%02d'
|
||||
},
|
||||
'Web' => {
|
||||
'schedule' => 'schedule'
|
||||
}
|
||||
},
|
||||
{
|
||||
@ -45,6 +50,10 @@ class TestConfigLoader < Test::Unit::TestCase
|
||||
'page_index_format' => '%02d',
|
||||
'files' => [ Dir.pwd + '/test1.svg', Dir.pwd + '/test2.svg' ],
|
||||
'fileinfo_by_file' => {}
|
||||
},
|
||||
'Web' => {
|
||||
'schedule' => 'schedule',
|
||||
'publish_dates' => 'schedule'
|
||||
}
|
||||
},
|
||||
[],
|
||||
@ -143,6 +152,14 @@ class TestConfigLoader < Test::Unit::TestCase
|
||||
].each do |yaml, expected_result, expectations, files|
|
||||
@config_loader.expects(:load_yaml).with('file').returns(yaml)
|
||||
|
||||
yaml.each do |type, info|
|
||||
if type != "Global"
|
||||
if info['schedule']
|
||||
Scheduler.any_instance.expects(:schedule).with(info['schedule'], expected_result['Global']['files'].length).returns('schedule')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if expectations
|
||||
expectations.each do |expectation|
|
||||
e = @config_loader.expects(expectation[:expects])
|
||||
|
@ -1,6 +1,8 @@
|
||||
require 'rubygems'
|
||||
require 'test/unit'
|
||||
require File.dirname(__FILE__) + '/../classes/FileProcessor.rb'
|
||||
Dir[File.dirname(__FILE__) + '/../classes/*'].each do |f|
|
||||
require f
|
||||
end
|
||||
|
||||
class TestFileProcessor < Test::Unit::TestCase
|
||||
def test_verify_filename
|
||||
@ -79,6 +81,38 @@ class TestFileProcessor < Test::Unit::TestCase
|
||||
end
|
||||
|
||||
def test_construct_filters_and_targets
|
||||
match_data = 'test'
|
||||
|
||||
[
|
||||
[
|
||||
'test.svg',
|
||||
{ 'target' => 'test.png' },
|
||||
'test',
|
||||
[ SVGToTempBitmap, TempBitmapToWeb, 'target' ]
|
||||
],
|
||||
[
|
||||
'test.svg',
|
||||
{ 'target' => 'test.pdf' },
|
||||
'test',
|
||||
[ SVGToTempBitmap, TempBitmapToPrint, 'target' ]
|
||||
],
|
||||
[
|
||||
'test.svg',
|
||||
{ 'target' => 'test.pdf', 'is_paginated' => true },
|
||||
'test',
|
||||
[ SVGToTempBitmap, TempBitmapToPaginatedPrint, 'target' ]
|
||||
],
|
||||
].each do |filename, info, match_data, expected_return|
|
||||
file_processor = FileProcessor.new({})
|
||||
file_processor.expects(:build_filename_parts).with(match_data).returns('parts')
|
||||
|
||||
expected_return[0..1].each do |m|
|
||||
m.any_instance.stubs(:recalc_pixels)
|
||||
end
|
||||
|
||||
expected_return[1].any_instance.expects(:targets).with('parts').returns('target')
|
||||
|
||||
file_processor.construct_filters_and_targets(filename, info, match_data)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user