working on making this actually work
This commit is contained in:
parent
d256b50516
commit
846920e7c2
@ -50,7 +50,7 @@ class ConfigLoader
|
|||||||
if global['match']
|
if global['match']
|
||||||
re = Regexp.new(global['match'])
|
re = Regexp.new(global['match'])
|
||||||
|
|
||||||
files = Dir[global['path']].sort.collect do |filename|
|
files = Dir[global['path'] + '/*'].sort.collect do |filename|
|
||||||
if matches = re.match(filename)
|
if matches = re.match(filename)
|
||||||
filename
|
filename
|
||||||
end
|
end
|
||||||
|
@ -7,11 +7,8 @@ class FileProcessor
|
|||||||
@paginated_source_files = {}
|
@paginated_source_files = {}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
def process
|
def process
|
||||||
rsync_files_by_target = {}
|
@config['Global']['files'].each do |filename|
|
||||||
|
|
||||||
files.each do |filename|
|
|
||||||
ok, fileinfo, filename = verify_filename(filename)
|
ok, fileinfo, filename = verify_filename(filename)
|
||||||
|
|
||||||
if ok
|
if ok
|
||||||
@ -23,7 +20,7 @@ class FileProcessor
|
|||||||
if type != "Global"
|
if type != "Global"
|
||||||
fileinfo_key = (filename.instance_of? Array) ? filename.join(",") : filename
|
fileinfo_key = (filename.instance_of? Array) ? filename.join(",") : filename
|
||||||
|
|
||||||
file_fileinfo = (fileinfo_by_file[fileinfo_key]) ? fileinfo_by_file[fileinfo_key] : {}
|
file_fileinfo = (@config['Global']['fileinfo_by_file'][fileinfo_key]) ? @config['Global']['fileinfo_by_file'][fileinfo_key] : {}
|
||||||
|
|
||||||
file_fileinfo = info.dup.merge(fileinfo).merge(file_fileinfo)
|
file_fileinfo = info.dup.merge(fileinfo).merge(file_fileinfo)
|
||||||
|
|
||||||
@ -36,11 +33,11 @@ class FileProcessor
|
|||||||
puts " Using #{filename} as a source"
|
puts " Using #{filename} as a source"
|
||||||
puts " and writing to #{targets.inspect}"
|
puts " and writing to #{targets.inspect}"
|
||||||
|
|
||||||
do_build(targets, filename)
|
do_build(targets, filename, input_obj, output_obj)
|
||||||
end
|
end
|
||||||
if info['is_paginated']
|
if info['is_paginated']
|
||||||
if !paginated_source_files[type]; paginated_source_files[type] = []; end
|
if !@paginated_source_files[type]; @paginated_source_files[type] = []; end
|
||||||
paginated_source_files[type] << targets
|
@paginated_source_files[type] << targets
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -58,10 +55,6 @@ class FileProcessor
|
|||||||
|
|
||||||
output_obj.paginate(paginated_source_files[type].flatten)
|
output_obj.paginate(paginated_source_files[type].flatten)
|
||||||
end
|
end
|
||||||
|
|
||||||
if info['rsync']
|
|
||||||
system("echo '#{rsync_files_by_target[info['rsync']].join("\n")}' | rsync -vru --files-from=- . #{info['rsync']}")
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -1,8 +1,9 @@
|
|||||||
require File.dirname(__FILE__) + '/../modules/PrintHandling.rb'
|
require File.dirname(__FILE__) + '/../modules/PrintHandling.rb'
|
||||||
|
require File.dirname(__FILE__) + '/../modules/ImageProcessing.rb'
|
||||||
require File.dirname(__FILE__) + '/InputFilter.rb'
|
require File.dirname(__FILE__) + '/InputFilter.rb'
|
||||||
|
|
||||||
class SVGToTempBitmap < InputFilter
|
class SVGToTempBitmap < InputFilter
|
||||||
include PrintHandling
|
include PrintHandling, ImageProcessing
|
||||||
|
|
||||||
#
|
#
|
||||||
# select which build method to use based on the number of provided images.
|
# select which build method to use based on the number of provided images.
|
||||||
@ -16,7 +17,7 @@ class SVGToTempBitmap < InputFilter
|
|||||||
#
|
#
|
||||||
def single(input)
|
def single(input)
|
||||||
filename = Dir.pwd + '/' + @output_filename
|
filename = Dir.pwd + '/' + @output_filename
|
||||||
inkscape(input, filename)
|
inkscape(Dir.pwd + '/' + input, filename)
|
||||||
@cleanup << filename
|
@cleanup << filename
|
||||||
|
|
||||||
if @config['spread']
|
if @config['spread']
|
||||||
|
@ -4,17 +4,6 @@ require File.dirname(__FILE__) + '/OutputFilter.rb'
|
|||||||
# Process an input file for the Web
|
# Process an input file for the Web
|
||||||
#
|
#
|
||||||
class TempBitmapToWeb < OutputFilter
|
class TempBitmapToWeb < OutputFilter
|
||||||
attr_accessor :schedule
|
|
||||||
|
|
||||||
def initialize
|
|
||||||
super
|
|
||||||
@schedule = nil
|
|
||||||
end
|
|
||||||
|
|
||||||
def requires_schedule(schedule)
|
|
||||||
@schedule = schedule
|
|
||||||
end
|
|
||||||
|
|
||||||
def build(input, output)
|
def build(input, output)
|
||||||
quality = @config['quality'] ? @config['quality'] : 80
|
quality = @config['quality'] ? @config['quality'] : 80
|
||||||
convert("\"#{input}\" -quality #{quality} \"#{output}\"")
|
convert("\"#{input}\" -quality #{quality} \"#{output}\"")
|
||||||
@ -22,7 +11,8 @@ class TempBitmapToWeb < OutputFilter
|
|||||||
|
|
||||||
def filename(info)
|
def filename(info)
|
||||||
index = info['index'].to_i
|
index = info['index'].to_i
|
||||||
info['date'] = @schedule[index].strftime(@config['date_format'])
|
|
||||||
|
info['date'] = @config['publish_dates'][index].strftime(@config['date_format'])
|
||||||
super(info)
|
super(info)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -3,12 +3,14 @@
|
|||||||
require 'yaml'
|
require 'yaml'
|
||||||
require 'time'
|
require 'time'
|
||||||
|
|
||||||
Dir[File.dirname(__FILE__) + "/classes/*.rb"].each do |file|
|
THIS_FILE = File.symlink?(__FILE__) ? File.readlink(__FILE__) : __FILE__
|
||||||
|
|
||||||
|
%w(classes modules).each do |which|
|
||||||
|
p File.dirname(THIS_FILE) + "/#{which}/*.rb"
|
||||||
|
Dir[File.dirname(THIS_FILE) + "/#{which}/*.rb"].each do |file|
|
||||||
require file
|
require file
|
||||||
end
|
end
|
||||||
|
end
|
||||||
any_rebuilt = false
|
|
||||||
any_rsync = false
|
|
||||||
|
|
||||||
if !ARGV[0]
|
if !ARGV[0]
|
||||||
puts "Usage: #{File.basename(__FILE__)} <path to YAML file>"
|
puts "Usage: #{File.basename(__FILE__)} <path to YAML file>"
|
||||||
@ -20,7 +22,8 @@ if !File.exists?(ARGV[0])
|
|||||||
exit 1
|
exit 1
|
||||||
end
|
end
|
||||||
|
|
||||||
if global['use_git']
|
config_loader = ConfigLoader.new
|
||||||
system("git add .")
|
config = config_loader.load(ARGV[0])
|
||||||
system("git commit -a")
|
|
||||||
end
|
file_processor = FileProcessor.new(config)
|
||||||
|
file_processor.process
|
||||||
|
Loading…
Reference in New Issue
Block a user