add support for subdirectory deneration

This commit is contained in:
John Bintz 2010-03-23 21:24:27 -04:00
parent e69c9dcd9a
commit ef5fba806f
6 changed files with 18 additions and 5 deletions

2
.gitignore vendored
View File

@ -3,3 +3,5 @@
.project .project
.DS_Store .DS_Store
coverage/ coverage/
minicomic-backend

View File

@ -4,6 +4,6 @@ test :
testrb `find tests -name '*.rb'` testrb `find tests -name '*.rb'`
test-coverage : test-coverage :
rcov -x '\/jruby\/lib\/' -x '\/tests\/data\/' `find tests -name '*.rb'` rcov -x '\/.rvm\/' -x '\/tests\/data\/' `find tests -name '*.rb'`
sed 's#<td class="left_align"><a href="<script>.html"><script></a></td>#<td></td>#' coverage/index.html > coverage/index.html.new sed 's#<td class="left_align"><a href="<script>.html"><script></a></td>#<td></td>#' coverage/index.html > coverage/index.html.new
mv coverage/index.html.new coverage/index.html mv coverage/index.html.new coverage/index.html

View File

@ -1,5 +1,6 @@
require File.dirname(__FILE__) + '/OutputFilter.rb' require File.dirname(__FILE__) + '/OutputFilter.rb'
require File.dirname(__FILE__) + '/../modules/ImageProcessing.rb' require File.dirname(__FILE__) + '/../modules/ImageProcessing.rb'
require 'fileutils'
# #
# Process an input file for the Web # Process an input file for the Web
@ -8,12 +9,23 @@ class TempBitmapToWeb < OutputFilter
include ImageProcessing include ImageProcessing
def build(input, output) def build(input, output)
FileUtils.mkdir_p(File.split(output).first)
quality = @config['quality'] ? @config['quality'] : 80 quality = @config['quality'] ? @config['quality'] : 80
convert("\"#{input}\" -quality #{quality} \"#{output}\"") convert("\"#{input}\" -quality #{quality} \"#{output}\"")
end end
def filename(info) def filename(info)
info['date'] = @config['publish_dates'][info['index'].to_i - 1].strftime(@config['date_format']) info['date'] = @config['publish_dates'][info['index'].to_i - 1].strftime(@config['date_format'])
info['subdir'] = ''
if @config['subdirs']
@config['subdirs'].each do |dir, subdir_info|
if Range.new(subdir_info['from'].to_i, subdir_info['to'].to_i).include? info['index'].to_i
info['subdir'] = dir + File::SEPARATOR
break
end
end
end
super(info) super(info)
end end
end end

View File

@ -3,10 +3,9 @@
require 'yaml' require 'yaml'
require 'time' require 'time'
THIS_FILE = File.symlink?(__FILE__) ? File.readlink(__FILE__) : __FILE__ THIS_FILE = File.symlink?(__FILE__) ? File.expand_path(File.readlink(__FILE__)) : File.expand_path(__FILE__)
%w(classes modules).each do |which| %w(classes modules).each do |which|
p File.dirname(THIS_FILE) + "/#{which}/*.rb"
Dir[File.dirname(THIS_FILE) + "/#{which}/*.rb"].each do |file| Dir[File.dirname(THIS_FILE) + "/#{which}/*.rb"].each do |file|
require file require file
end end

View File

@ -1,7 +1,7 @@
require 'rubygems' require 'rubygems'
require 'test/unit' require 'test/unit'
require 'fakefs/safe' require 'fakefs/safe'
Dir[File.dirname(__FILE__) + '/../classes/*'].each do |f| Dir[File.dirname(__FILE__) + '/../classes/*.rb'].each do |f|
require f require f
end end