diff --git a/lib/squib/graphics/save_doc.rb b/lib/squib/graphics/save_doc.rb index 1f603de..106ab3e 100644 --- a/lib/squib/graphics/save_doc.rb +++ b/lib/squib/graphics/save_doc.rb @@ -4,17 +4,17 @@ module Squib def save_pdf(opts = {}) p = needs(opts, [:file_to_save, :prefix, :margin, :gap, :trim]) width = 11 * @dpi ; height = 8.5 * @dpi #TODO: allow this to be specified too - cc = Cairo::Context.new(Cairo::PDFSurface.new("#{dir}/#{file}", width, height)) + cc = Cairo::Context.new(Cairo::PDFSurface.new("#{p[:dir]}/#{p[:file]}", width, height)) x = p[:margin] ; y = p[:margin] @cards.each_with_index do |card, i| surface = trim(card.cairo_surface, p[:trim], @width, @height) cc.set_source(surface, x, y) cc.paint - x += surface.width + gap - if x > (width - surface.width - margin) + x += surface.width + p[:gap] + if x > (width - surface.width - p[:margin]) x = p[:margin] y += surface.height + p[:gap] - if y > (height - surface.height - margin) + if y > (height - surface.height - p[:margin]) x = p[:margin] ; y = p[:margin] cc.show_page #next page end diff --git a/lib/squib/input_helpers.rb b/lib/squib/input_helpers.rb index 57bb4e6..bda0192 100644 --- a/lib/squib/input_helpers.rb +++ b/lib/squib/input_helpers.rb @@ -44,7 +44,7 @@ module Squib opts[:file] = [opts[:file]] * @cards.size if expand_singletons files = [opts[:file]].flatten files.each do |file| - unless File.exists? file || allow_non_exist + unless File.exists?(file) || allow_non_exist raise "File #{File.expand_path(file)} does not exist!" end end @@ -53,7 +53,6 @@ module Squib module_function :fileify def dirify(opts, allow_create=false) - puts opts[:dir] return opts if Dir.exists?(opts[:dir]) if allow_create Squib.logger.warn "Dir #{opts[:dir]} does not exist, creating it." diff --git a/spec/samples_run_spec.rb b/spec/samples_run_spec.rb index 50137f2..b56cb41 100644 --- a/spec/samples_run_spec.rb +++ b/spec/samples_run_spec.rb @@ -3,13 +3,13 @@ require 'squib' describe Squib do - # it "should execute all examples with no errors" do - # samples = File.expand_path('../samples', File.dirname(__FILE__)) - # Dir["#{samples}/**/*.rb"].each do |sample| - # Dir.chdir(samples) do #to save to _output - # require_relative "../samples/#{File.basename(sample)}" - # end - # end - # end + it "should execute all examples with no errors" do + samples = File.expand_path('../samples', File.dirname(__FILE__)) + Dir["#{samples}/**/*.rb"].each do |sample| + Dir.chdir(samples) do #to save to _output + require_relative "../samples/#{File.basename(sample)}" + end + end + end end \ No newline at end of file