more filter separation
This commit is contained in:
parent
2758239c1a
commit
8e16d7cc00
@ -1,7 +1,4 @@
|
||||
require 'singleton'
|
||||
|
||||
class Filter
|
||||
include Singleton
|
||||
@config = {}
|
||||
@cleanup = []
|
||||
|
||||
|
5
classes/InputFilter.rb
Normal file
5
classes/InputFilter.rb
Normal file
@ -0,0 +1,5 @@
|
||||
require 'filter'
|
||||
|
||||
class InputFilter < Filter
|
||||
OutputFilename = "tmp.png"
|
||||
end
|
17
classes/OutputFilter.rb
Normal file
17
classes/OutputFilter.rb
Normal file
@ -0,0 +1,17 @@
|
||||
require File.dirname(__FILE__) + '/Filter.rb'
|
||||
|
||||
class OutputFilter < Filter
|
||||
#
|
||||
# get the output filename for this filter
|
||||
#
|
||||
def filename(info)
|
||||
target = @config['target']
|
||||
info.each { |k,v| target = target.gsub("{#{k}}", v.to_s) }
|
||||
target
|
||||
end
|
||||
|
||||
#
|
||||
# get the output targets for this filter
|
||||
#
|
||||
def targets(info); filename(info); end
|
||||
end
|
@ -3,10 +3,8 @@
|
||||
require 'yaml'
|
||||
require 'time'
|
||||
|
||||
require File.dirname(__FILE__) + '/classes/Filter.rb'
|
||||
|
||||
class InputFilter < Filter
|
||||
OutputFilename = "tmp.png"
|
||||
Dir[File.dirname(__FILE__) + "/classes/*.rb"].each do |file|
|
||||
require file
|
||||
end
|
||||
|
||||
class OutputFilter < Filter
|
||||
|
@ -1,5 +1,3 @@
|
||||
#!/usr/bin/ruby
|
||||
|
||||
require 'rubygems'
|
||||
require 'test/unit'
|
||||
require 'mockfs/override'
|
||||
|
17
tests/TestOutputFilter.rb
Normal file
17
tests/TestOutputFilter.rb
Normal file
@ -0,0 +1,17 @@
|
||||
require 'rubygems'
|
||||
require 'test/unit'
|
||||
require 'mocha'
|
||||
require File.dirname(__FILE__) + '/../classes/OutputFilter.rb'
|
||||
|
||||
class TestOutputFilter < Test::Unit::TestCase
|
||||
def setup
|
||||
@of = OutputFilter.new
|
||||
@of.stubs(:recalc_pixels)
|
||||
end
|
||||
|
||||
def test_filename
|
||||
@of.config = { 'target' => 'test{test}{test2}test3' }
|
||||
assert_equal 'testtest4test5test3', @of.filename({ 'test' => 'test4', 'test2' => 'test5' })
|
||||
end
|
||||
end
|
||||
|
@ -1,5 +1,3 @@
|
||||
#!/usr/bin/ruby
|
||||
|
||||
require 'rubygems'
|
||||
require 'test/unit'
|
||||
require File.dirname(__FILE__) + '/../classes/Scheduler.rb'
|
||||
|
Loading…
Reference in New Issue
Block a user