more filter separation
This commit is contained in:
parent
2758239c1a
commit
8e16d7cc00
|
@ -1,7 +1,4 @@
|
||||||
require 'singleton'
|
|
||||||
|
|
||||||
class Filter
|
class Filter
|
||||||
include Singleton
|
|
||||||
@config = {}
|
@config = {}
|
||||||
@cleanup = []
|
@cleanup = []
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,5 @@
|
||||||
|
require 'filter'
|
||||||
|
|
||||||
|
class InputFilter < Filter
|
||||||
|
OutputFilename = "tmp.png"
|
||||||
|
end
|
|
@ -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 'yaml'
|
||||||
require 'time'
|
require 'time'
|
||||||
|
|
||||||
require File.dirname(__FILE__) + '/classes/Filter.rb'
|
Dir[File.dirname(__FILE__) + "/classes/*.rb"].each do |file|
|
||||||
|
require file
|
||||||
class InputFilter < Filter
|
|
||||||
OutputFilename = "tmp.png"
|
|
||||||
end
|
end
|
||||||
|
|
||||||
class OutputFilter < Filter
|
class OutputFilter < Filter
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
#!/usr/bin/ruby
|
|
||||||
|
|
||||||
require 'rubygems'
|
require 'rubygems'
|
||||||
require 'test/unit'
|
require 'test/unit'
|
||||||
require 'mockfs/override'
|
require 'mockfs/override'
|
||||||
|
|
|
@ -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 'rubygems'
|
||||||
require 'test/unit'
|
require 'test/unit'
|
||||||
require File.dirname(__FILE__) + '/../classes/Scheduler.rb'
|
require File.dirname(__FILE__) + '/../classes/Scheduler.rb'
|
||||||
|
|
Loading…
Reference in New Issue