Browse Source

save_pdf: flush to file

Fixes #150
dev
Andy Meneely 10 years ago
parent
commit
2329a069d1
  1. 3
      CHANGELOG.md
  2. 1
      lib/squib/graphics/save_doc.rb
  3. 1
      spec/data/samples/custom_config.rb.txt
  4. 2
      spec/data/samples/saves.rb.txt
  5. 8
      spec/graphics/graphics_save_doc_spec.rb
  6. 2
      spec/samples/samples_regression_spec.rb
  7. 2
      spec/spec_helper.rb

3
CHANGELOG.md

@ -9,6 +9,9 @@ Features:
* The `csv` method now supports all of the Ruby CSV options (e.g. `col_sep`, `quote_char`). These options simply get passed through to Ruby, so as they change in Ruby, so the support changes in Squib. (#149) Special thanks to Qgel's initial pull request (#146).
* New `use_layout` method will allow you to load a layout file as a DSL method instead of in the constructor. Useful in conjunction with build groups! (#141)
Bugs:
* The `save_pdf` method will flush to file upon exit so that the PDF is available immediately. (#150, thanks for the bug report Qgel!)
Chores:
* Switched to `require_relative` internally throughout the codebase to be more pry-friendly (#130)
* Rewrote the entire API doc and placed it on [squib.readthedocs.org](http://squib.readthedocs.org). :tada:

1
lib/squib/graphics/save_doc.rb

@ -43,6 +43,7 @@ module Squib
end
end
end
cc.target.finish
end
# :nodoc:

1
spec/data/samples/custom_config.rb.txt

@ -55,3 +55,4 @@ cairo: set_source([MockDouble, 0, 0])
cairo: paint([])
cairo: reset_clip([])
cairo: translate([-75, -75])
surface: finish([])

2
spec/data/samples/saves.rb.txt

@ -634,6 +634,7 @@ cairo: paint([])
cairo: reset_clip([])
cairo: translate([-2343, -1131])
cairo: show_page([])
surface: finish([])
cairo: scale([0.24, 0.24])
cairo: translate([75, 75])
cairo: rectangle([0, 0, 825, 1125])
@ -650,6 +651,7 @@ cairo: paint([])
cairo: reset_clip([])
cairo: translate([-900, -75])
cairo: show_page([])
surface: finish([])
surface: write_to_png(["_output/saves_notrim_01.png"])
cairo: set_source([MockDouble, -37, -37])
cairo: paint([])

8
spec/graphics/graphics_save_doc_spec.rb

@ -4,7 +4,8 @@ require 'squib'
describe Squib::Deck, '#save_pdf' do
context 'typical inputs' do
let(:cxt) { double(Cairo::Context) }
let(:cxt) { double(Cairo::Context) }
let(:target) { double(Cairo::PDFSurface) }
def expect_card_place(x, y)
expect(cxt).to receive(:translate).with(x, y).once
@ -41,6 +42,8 @@ describe Squib::Deck, '#save_pdf' do
expect_card_place(2343, 1131)
expect(cxt).to receive(:show_page).once
expect_card_place(75, 75)
expect(cxt).to receive(:target).and_return(target)
expect(target).to receive(:finish).once
args = { file: 'foo.pdf', dir: '_out', margin: 75, gap: 5, trim: 37 }
deck.save_pdf(args)
@ -59,6 +62,9 @@ describe Squib::Deck, '#save_pdf' do
expect_card_place(831, 75)
expect_card_place(1587, 75)
expect(cxt).to receive(:target).and_return(target)
expect(target).to receive(:finish).once
deck.save_pdf(args)
end

2
spec/samples/samples_regression_spec.rb

@ -3,7 +3,7 @@ require 'squib'
require 'pp'
describe 'Squib samples' do
around(:each) do |example|
Dir.chdir(samples_dir) do
example.run

2
spec/spec_helper.rb

@ -128,7 +128,7 @@ def mock_cairo(strio)
allow(font).to receive(m) { |*args| strio << scrub_hex("pango font: #{m}(#{args})\n") }
end
%w(write_to_png).each do |m|
%w(write_to_png finish).each do |m|
allow(surface).to receive(m) { |*args| strio << scrub_hex("surface: #{m}(#{args})\n") }
end

Loading…
Cancel
Save