Browse Source

👮 fix space after comma

dev
Andy Meneely 10 years ago
parent
commit
8a9552126c
  1. 2
      Rakefile
  2. 6
      lib/squib/api/data.rb
  3. 2
      lib/squib/args/arg_loader.rb
  4. 10
      lib/squib/graphics/save_doc.rb
  5. 8
      lib/squib/graphics/showcase.rb
  6. 4
      lib/squib/layout_parser.rb
  7. 4
      samples/basic.rb
  8. 2
      samples/colors.rb
  9. 2
      samples/layouts.rb
  10. 8
      samples/ranges.rb
  11. 2
      samples/text_options.rb
  12. 8
      spec/graphics/cairo_context_wrapper_spec.rb
  13. 2
      spec/graphics/graphics_save_doc_spec.rb
  14. 2
      spec/layout_parser_spec.rb
  15. 310
      spec/spec_helper.rb

2
Rakefile

@ -10,7 +10,7 @@ task default: [:install, :spec]
# Useful for hooking up with SublimeText.
# e.g. rake sample[basic.rb]
desc 'Run a specific sample'
task :run,[:file] => :install do |t, args|
task :run, [:file] => :install do |t, args|
args.with_defaults(file: 'basic.rb')
Dir.chdir('samples') do
args[:file] << ".rb" unless args[:file].end_with? '.rb'

6
lib/squib/api/data.rb

@ -13,13 +13,13 @@ module Squib
s.default_sheet = s.sheets[input.sheet[0]]
data = {}
s.first_column.upto(s.last_column) do |col|
header = s.cell(s.first_row,col).to_s
header = s.cell(s.first_row, col).to_s
header.strip! if import.strip?
data[header] = []
(s.first_row + 1).upto(s.last_row) do |row|
cell = s.cell(row,col)
cell = s.cell(row, col)
# Roo hack for avoiding unnecessary .0's on whole integers (https://github.com/roo-rb/roo/issues/139)
cell = s.excelx_value(row,col) if s.excelx_type(row,col) == [:numeric_or_formula, 'General']
cell = s.excelx_value(row, col) if s.excelx_type(row, col) == [:numeric_or_formula, 'General']
cell.strip! if cell.respond_to?(:strip) && import.strip?
cell = yield(header, cell) if block_given?
data[header] << cell

2
lib/squib/args/arg_loader.rb

@ -87,7 +87,7 @@ module Squib
new_val = val.map.with_index{ |v, i| send(method, v, i) }
instance_variable_set(attribute, new_val)
else
instance_variable_set(attribute,send(method, val))
instance_variable_set(attribute, send(method, val))
end
end
end

10
lib/squib/graphics/save_doc.rb

@ -13,7 +13,7 @@ module Squib
@progress_bar.start("Saving PDF to #{file}", range.size) do |bar|
range.each do |i|
card = @cards[i]
cc.translate(x,y)
cc.translate(x, y)
cc.rectangle(sheet.trim, sheet.trim, card_width, card_height)
cc.clip
case card.backend.downcase.to_sym
@ -23,7 +23,7 @@ module Squib
when :svg
card.cairo_surface.finish
cc.save
cc.scale(0.8,0.8) # I really don't know why I needed to do this at all. But 0.8 is the magic number to get this to scale right
cc.scale(0.8, 0.8) # I really don't know why I needed to do this at all. But 0.8 is the magic number to get this to scale right
cc.render_rsvg_handle(RSVG::Handle.new_from_file(card.svgfile), nil)
cc.restore
else
@ -31,14 +31,14 @@ module Squib
end
bar.increment
cc.reset_clip
cc.translate(-x,-y)
cc.translate(-x, -y)
x += card.width + sheet.gap - 2*sheet.trim
if x > (sheet.width - card_width - sheet.margin)
x = sheet.margin
y += card.height + sheet.gap - 2*sheet.trim
if y > (sheet.height - card_height - sheet.margin)
cc.show_page # next page
x,y = sheet.margin,sheet.margin
x, y = sheet.margin, sheet.margin
end
end
end
@ -92,7 +92,7 @@ module Squib
if trim > 0
tmp = Cairo::ImageSurface.new(width-2*trim, height-2*trim)
cc = Cairo::Context.new(tmp)
cc.set_source(surface,-1*trim, -1*trim)
cc.set_source(surface, -1*trim, -1*trim)
cc.paint
surface = tmp
end

8
lib/squib/graphics/showcase.rb

@ -52,9 +52,9 @@ module Squib
tmp_cc.transform(matrix) # flips the coordinate system
top_y = src.height # top of the reflection
bottom_y = src.height * (1.0 - rpercent) + roffset # bottom of the reflection
gradient = Cairo::LinearPattern.new(0,top_y, 0,bottom_y)
gradient.add_color_stop_rgba(0.0, 0,0,0, rstrength) # start a little reflected
gradient.add_color_stop_rgba(1.0, 0,0,0, 0.0) # fade to nothing
gradient = Cairo::LinearPattern.new(0, top_y, 0, bottom_y)
gradient.add_color_stop_rgba(0.0, 0, 0, 0, rstrength) # start a little reflected
gradient.add_color_stop_rgba(1.0, 0, 0, 0, 0.0) # fade to nothing
tmp_cc.set_source(src, 0, 0)
tmp_cc.mask(gradient)
return tmp_cc.target
@ -74,7 +74,7 @@ module Squib
dest_cxt.translate 0, src.height / 2.0 * (1.0 - factor)
dest_cxt.scale factor * scale, factor
dest_cxt.set_source src, 0, 0
dest_cxt.rounded_rectangle i, 0, out_thickness, src.height, 0,0
dest_cxt.rounded_rectangle i, 0, out_thickness, src.height, 0, 0
dest_cxt.fill
dest_cxt.restore
end

4
lib/squib/layout_parser.rb

@ -43,9 +43,9 @@ module Squib
parent_keys.each do |parent_key|
from_extends = yml[key].merge(recurse_extends(yml, parent_key, visited)) do |key, child_val, parent_val|
if child_val.to_s.strip.start_with?('+=')
parent_val + child_val.sub('+=','').strip.to_f
parent_val + child_val.sub('+=', '').strip.to_f
elsif child_val.to_s.strip.start_with?('-=')
parent_val - child_val.sub('-=','').strip.to_f
parent_val - child_val.sub('-=', '').strip.to_f
else
child_val #child overrides parent when merging, no +=
end

4
samples/basic.rb

@ -1,7 +1,7 @@
require 'squib'
data = {'name' => ['Thief', 'Grifter', 'Mastermind'],
'level' => [1,2,3]}
'level' => [1, 2, 3]}
Squib::Deck.new(width: 825, height: 1125, cards: 3) do
background color: :white
@ -12,7 +12,7 @@ Squib::Deck.new(width: 825, height: 1125, cards: 3) do
text str: data['level'], x: 75, y: 85, width: 128,
font: 'Arial 72', align: :center
png range: [0,2], file: 'shiny-purse.png', x: 620, y: 75
png range: [0, 2], file: 'shiny-purse.png', x: 620, y: 75
svg range: 1..2, file: 'spanner.svg', x: 620, y: 218
save prefix: 'basic_', format: :png

2
samples/colors.rb

@ -22,7 +22,7 @@ end
Squib::Deck.new(width: 3000, height: 1500) do
colors = (Cairo::Color.constants - %i(HEX_RE Base RGB CMYK HSV X11))
colors.sort_by! {|c| Cairo::Color.parse(c).to_s}
x,y,w,h = 0,0,300,50
x, y, w, h = 0, 0, 300, 50
colors.each_with_index do |color, i|
rect x: x, y: y, width: w, height: h, fill_color: color
text str: color.to_s, x: x + 5, y: y+13, font: 'Sans Bold 16',

2
samples/layouts.rb

@ -67,6 +67,6 @@ Squib::Deck.new do
use_layout file: 'custom-layout.yml'
use_layout file: 'custom-layout2.yml'
text str: 'The Title', layout: :title # from custom-layout.yml
text str: 'The Subtitle',layout: :subtitle # redefined in custom-layout2.yml
text str: 'The Subtitle', layout: :subtitle # redefined in custom-layout2.yml
save_png prefix: 'layout3_'
end

8
samples/ranges.rb

@ -2,7 +2,7 @@ require 'squib'
data = {'name' => ['Thief', 'Grifter', 'Mastermind'],
'type' => ['Thug', 'Thinker', 'Thinker'],
'level' => [1,2,3]}
'level' => [1, 2, 3]}
Squib::Deck.new(width: 825, height: 1125, cards: 3) do
# Default range is :all
@ -26,7 +26,7 @@ Squib::Deck.new(width: 825, height: 1125, cards: 3) do
text range: -2..-1, str: 'Grifter and Mastermind only!', x: 25, y: 650
# We can use Arrays too!
text range: [0,2], str: 'Thief and Mastermind only!!', x: 25, y:300
text range: [0, 2], str: 'Thief and Mastermind only!!', x: 25, y:300
# Just about everything in Squib can be given an array that
# corresponds to the deck's cards. This allows for each card to be styled differently
@ -38,13 +38,13 @@ Squib::Deck.new(width: 825, height: 1125, cards: 3) do
# Useful idiom: construct a hash from card names back to its index (ID),
# then use a range. No need to memorize IDs, and you can add cards easily
id = {} ; data['name'].each_with_index{ |name,i| id[name] = i}
id = {} ; data['name'].each_with_index{ |name, i| id[name] = i}
text range: id['Thief']..id['Grifter'],
str: 'Thief through Grifter with id lookup!!',
x:25, y: 400
# Useful idiom: generate arrays from a column called 'type'
type = {}; data['type'].each_with_index{ |t,i| (type[t] ||= []) << i}
type = {}; data['type'].each_with_index{ |t, i| (type[t] ||= []) << i}
text range: type['Thinker'],
str: 'Only for Thinkers!',
x:25, y: 500

2
samples/text_options.rb

@ -2,7 +2,7 @@
require 'squib'
data = {'name' => ['Thief', 'Grifter', 'Mastermind'],
'level' => [1,2,3]}
'level' => [1, 2, 3]}
longtext = "This is left-justified text, with newlines.\nWhat do you know about tweetle beetles? well... When tweetle beetles fight, it's called a tweetle beetle battle. And when they battle in a puddle, it's a tweetle beetle puddle battle. AND when tweetle beetles battle with paddles in a puddle, they call it a tweetle beetle puddle paddle battle. AND... When beetles battle beetles in a puddle paddle battle and the beetle battle puddle is a puddle in a bottle... ..they call this a tweetle beetle bottle puddle paddle battle muddle."
Squib::Deck.new(width: 825, height: 1125, cards: 3) do

8
spec/graphics/cairo_context_wrapper_spec.rb

@ -32,7 +32,7 @@ describe Squib::Graphics::CairoContextWrapper do
before(:each) do
dbl = double(Cairo::LinearPattern)
mtx = double(Cairo::Matrix)
expect(Cairo::LinearPattern).to receive(:new).with(1,2,3,4).and_return(dbl)
expect(Cairo::LinearPattern).to receive(:new).with(1, 2, 3, 4).and_return(dbl)
expect(dbl).to receive(:add_color_stop).with(0.0, 'blue')
expect(dbl).to receive(:add_color_stop).with(1.0, 'red')
expect(cairo).to receive(:matrix).and_return(mtx)
@ -50,7 +50,7 @@ describe Squib::Graphics::CairoContextWrapper do
before(:each) do
dbl = double(Cairo::RadialPattern)
mtx = double(Cairo::Matrix)
expect(Cairo::RadialPattern).to receive(:new).with(1,2,5,3,4,6).and_return(dbl)
expect(Cairo::RadialPattern).to receive(:new).with(1, 2, 5, 3, 4, 6).and_return(dbl)
expect(dbl).to receive(:add_color_stop).with(0.0, 'blue')
expect(dbl).to receive(:add_color_stop).with(1.0, 'red')
expect(cairo).to receive(:matrix).and_return(mtx)
@ -68,7 +68,7 @@ describe Squib::Graphics::CairoContextWrapper do
it 'on radial patterns' do
dbl = double(Cairo::RadialPattern)
mtx = double(Cairo::Matrix)
expect(Cairo::RadialPattern).to receive(:new).with(1,2,5,3,4,6).and_return(dbl)
expect(Cairo::RadialPattern).to receive(:new).with(1, 2, 5, 3, 4, 6).and_return(dbl)
expect(dbl).to receive(:add_color_stop).with(0.0, '#def')
expect(dbl).to receive(:add_color_stop).with(1.0, '#112233')
expect(cairo).to receive(:matrix).and_return(mtx)
@ -80,7 +80,7 @@ describe Squib::Graphics::CairoContextWrapper do
it 'on linear patterns' do
dbl = double(Cairo::LinearPattern)
mtx = double(Cairo::Matrix)
expect(Cairo::LinearPattern).to receive(:new).with(1,2,3,4).and_return(dbl)
expect(Cairo::LinearPattern).to receive(:new).with(1, 2, 3, 4).and_return(dbl)
expect(dbl).to receive(:add_color_stop).with(0.0, '#def')
expect(dbl).to receive(:add_color_stop).with(1.0, '#112233')
expect(cairo).to receive(:matrix).and_return(mtx)

2
spec/graphics/graphics_save_doc_spec.rb

@ -13,7 +13,7 @@ describe Squib::Deck, '#save_pdf' do
expect(cxt).to receive(:set_source) # place the card
.with(instance_of(Cairo::ImageSurface), 0, 0).once
expect(cxt).to receive(:paint).once # paint placed card
expect(cxt).to receive(:translate).with(-x,-y).once
expect(cxt).to receive(:translate).with(-x, -y).once
expect(cxt).to receive(:reset_clip).once
end

2
spec/layout_parser_spec.rb

@ -81,7 +81,7 @@ describe Squib::LayoutParser do
'b' => 106,
},
'child' => {
'extends' => ['uncle','aunt'],
'extends' => ['uncle', 'aunt'],
'a' => 107, # my own
'b' => 102, # from the younger aunt
'c' => 103, # from aunt

310
spec/spec_helper.rb

@ -1,155 +1,155 @@
require 'simplecov'
require 'coveralls'
# require 'byebug'
SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter.new([
SimpleCov::Formatter::HTMLFormatter,
Coveralls::SimpleCov::Formatter
])
SimpleCov.start
require 'squib'
RSpec.configure do |config|
config.mock_with :rspec do |mocks|
mocks.verify_partial_doubles = true
end
config.tty = true
config.color = true
end
def tmp_dir
"#{File.expand_path(File.dirname(__FILE__))}/../tmp"
end
def samples_dir
File.expand_path("#{File.dirname(__FILE__)}/../samples")
end
def layout_file(str)
"#{File.expand_path(File.dirname(__FILE__))}/data/layouts/#{str}"
end
def sample_file(file)
"#{File.expand_path(File.dirname(__FILE__))}/../samples/#{file}"
end
def sample_regression_file(file)
"#{File.expand_path(File.dirname(__FILE__))}/data/samples/#{file}.txt"
end
def csv_file(file)
"#{File.expand_path(File.dirname(__FILE__))}/data/csv/#{file}"
end
def xlsx_file(file)
"#{File.expand_path(File.dirname(__FILE__))}/data/xlsx/#{file}"
end
def project_template(file)
"#{File.expand_path(File.dirname(__FILE__))}/../lib/squib/project_template/#{file}"
end
def conf(file)
"#{File.expand_path(File.dirname(__FILE__))}/data/conf/#{file}"
end
def overwrite_sample(sample_name, log)
# Use this to overwrite the regression with current state
File.open(sample_regression_file(sample_name), 'w+:UTF-8') do |f|
f.write(log.string)
end
end
def scrub_hex(str)
str.gsub(/0x\w{1,8}/,'')
.gsub(/ptr=\w{1,8}/,'')
.gsub(/#<Pango::FontDescription:.*>/,'')
.gsub(/#<Cairo::ImageSurface:.*>/,'ImageSurface')
.gsub(/#<Cairo::LinearPattern:.*>/,'LinearPattern')
.gsub(/#<Cairo::RadialPattern:.*>/,'RadialPattern')
.gsub(/#<Cairo::Matrix:.*>/,'Matrix')
.gsub(/#<RSVG::Handle.*>/,'RSVG::Handle')
.gsub(/#<RSpec::Mocks::Double:.*>/,'MockDouble')
.gsub(/#<Double .*>/,'MockDouble')
.gsub(/RGB:\w{1,8}/,'RGB:')
end
# Build a mock cairo instance that allows basically any method
# and logs that call to the string buffer
def mock_cairo(strio)
cxt = double(Cairo::Context)
surface = double(Cairo::ImageSurface)
pango = double(Pango::Layout)
font = double(Pango::FontDescription)
iter = double('pango_iter')
pango_cxt = double('pango_cxt')
allow(Squib.logger).to receive(:warn) {}
allow(ProgressBar).to receive(:create).and_return(Squib::DoNothing.new)
allow(Cairo::ImageSurface).to receive(:new).and_return(surface)
allow(surface).to receive(:width).and_return(100)
allow(surface).to receive(:height).and_return(101)
allow(surface).to receive(:ink_extents).and_return([0,0,100,100])
allow(Cairo::Context).to receive(:new).and_return(cxt)
allow(cxt).to receive(:create_pango_layout).and_return(pango)
allow(cxt).to receive(:target).and_return(surface)
allow(cxt).to receive(:matrix).and_return(Cairo::Matrix.new(1,0,0,1,0,0))
allow(pango).to receive(:height).and_return(25)
allow(pango).to receive(:width).and_return(25)
allow(pango).to receive(:index_to_pos).and_return(Pango::Rectangle.new(0,0,0,0))
allow(pango).to receive(:extents).and_return([Pango::Rectangle.new(0,0,0,0)]*2)
allow(pango).to receive(:iter).and_return(iter)
allow(pango).to receive(:alignment).and_return(Pango::Layout::Alignment::LEFT)
allow(pango).to receive(:text).and_return("foo")
allow(pango).to receive(:context).and_return(pango_cxt)
allow(pango_cxt).to receive(:font_options=)
allow(iter).to receive(:next_char!).and_return(false)
allow(iter).to receive(:char_extents).and_return(Pango::Rectangle.new(5,5,5,5))
allow(iter).to receive(:index).and_return(1000)
allow(Pango::FontDescription).to receive(:new).and_return(font)
allow(Cairo::PDFSurface).to receive(:new).and_return(nil)
%w(save set_source_color paint restore translate rotate move_to
update_pango_layout width height show_pango_layout rounded_rectangle
set_line_width stroke fill set_source scale render_rsvg_handle circle
triangle line_to operator= show_page clip transform mask rectangle
reset_clip antialias= curve_to matrix= pango_layout_path stroke_preserve
fill_preserve close_path set_dash set_line_cap set_line_join).each do |m|
allow(cxt).to receive(m) { |*args| strio << scrub_hex("cairo: #{m}(#{args})\n") }
end
%w(font_description= text= width= height= wrap= ellipsize= alignment=
justify= spacing= markup= ellipsized?).each do |m|
allow(pango).to receive(m) {|*args| strio << scrub_hex("pango: #{m}(#{args})\n") }
end
%w(size=).each do |m|
allow(font).to receive(m) { |*args| strio << scrub_hex("pango font: #{m}(#{args})\n") }
end
%w(write_to_png).each do |m|
allow(surface).to receive(m) { |*args| strio << scrub_hex("surface: #{m}(#{args})\n") }
end
%w(next_char!).each do |m|
allow(iter).to receive(m) { |*args| strio << scrub_hex("pango_iter: #{m}(#{args})\n") }
end
end
# Refine Squib to allow setting the logger and progress bar
module Squib
def logger=(l)
@logger = l
end
module_function :logger=
class Deck
attr_accessor :progress_bar
end
end
def output_dir
File.expand_path('../samples/_output', File.dirname(__FILE__))
end
require 'simplecov'
require 'coveralls'
# require 'byebug'
SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter.new([
SimpleCov::Formatter::HTMLFormatter,
Coveralls::SimpleCov::Formatter
])
SimpleCov.start
require 'squib'
RSpec.configure do |config|
config.mock_with :rspec do |mocks|
mocks.verify_partial_doubles = true
end
config.tty = true
config.color = true
end
def tmp_dir
"#{File.expand_path(File.dirname(__FILE__))}/../tmp"
end
def samples_dir
File.expand_path("#{File.dirname(__FILE__)}/../samples")
end
def layout_file(str)
"#{File.expand_path(File.dirname(__FILE__))}/data/layouts/#{str}"
end
def sample_file(file)
"#{File.expand_path(File.dirname(__FILE__))}/../samples/#{file}"
end
def sample_regression_file(file)
"#{File.expand_path(File.dirname(__FILE__))}/data/samples/#{file}.txt"
end
def csv_file(file)
"#{File.expand_path(File.dirname(__FILE__))}/data/csv/#{file}"
end
def xlsx_file(file)
"#{File.expand_path(File.dirname(__FILE__))}/data/xlsx/#{file}"
end
def project_template(file)
"#{File.expand_path(File.dirname(__FILE__))}/../lib/squib/project_template/#{file}"
end
def conf(file)
"#{File.expand_path(File.dirname(__FILE__))}/data/conf/#{file}"
end
def overwrite_sample(sample_name, log)
# Use this to overwrite the regression with current state
File.open(sample_regression_file(sample_name), 'w+:UTF-8') do |f|
f.write(log.string)
end
end
def scrub_hex(str)
str.gsub(/0x\w{1,8}/, '')
.gsub(/ptr=\w{1,8}/, '')
.gsub(/#<Pango::FontDescription:.*>/, '')
.gsub(/#<Cairo::ImageSurface:.*>/, 'ImageSurface')
.gsub(/#<Cairo::LinearPattern:.*>/, 'LinearPattern')
.gsub(/#<Cairo::RadialPattern:.*>/, 'RadialPattern')
.gsub(/#<Cairo::Matrix:.*>/, 'Matrix')
.gsub(/#<RSVG::Handle.*>/, 'RSVG::Handle')
.gsub(/#<RSpec::Mocks::Double:.*>/, 'MockDouble')
.gsub(/#<Double .*>/, 'MockDouble')
.gsub(/RGB:\w{1,8}/, 'RGB:')
end
# Build a mock cairo instance that allows basically any method
# and logs that call to the string buffer
def mock_cairo(strio)
cxt = double(Cairo::Context)
surface = double(Cairo::ImageSurface)
pango = double(Pango::Layout)
font = double(Pango::FontDescription)
iter = double('pango_iter')
pango_cxt = double('pango_cxt')
allow(Squib.logger).to receive(:warn) {}
allow(ProgressBar).to receive(:create).and_return(Squib::DoNothing.new)
allow(Cairo::ImageSurface).to receive(:new).and_return(surface)
allow(surface).to receive(:width).and_return(100)
allow(surface).to receive(:height).and_return(101)
allow(surface).to receive(:ink_extents).and_return([0, 0, 100, 100])
allow(Cairo::Context).to receive(:new).and_return(cxt)
allow(cxt).to receive(:create_pango_layout).and_return(pango)
allow(cxt).to receive(:target).and_return(surface)
allow(cxt).to receive(:matrix).and_return(Cairo::Matrix.new(1, 0, 0, 1, 0, 0))
allow(pango).to receive(:height).and_return(25)
allow(pango).to receive(:width).and_return(25)
allow(pango).to receive(:index_to_pos).and_return(Pango::Rectangle.new(0, 0, 0, 0))
allow(pango).to receive(:extents).and_return([Pango::Rectangle.new(0, 0, 0, 0)]*2)
allow(pango).to receive(:iter).and_return(iter)
allow(pango).to receive(:alignment).and_return(Pango::Layout::Alignment::LEFT)
allow(pango).to receive(:text).and_return("foo")
allow(pango).to receive(:context).and_return(pango_cxt)
allow(pango_cxt).to receive(:font_options=)
allow(iter).to receive(:next_char!).and_return(false)
allow(iter).to receive(:char_extents).and_return(Pango::Rectangle.new(5, 5, 5, 5))
allow(iter).to receive(:index).and_return(1000)
allow(Pango::FontDescription).to receive(:new).and_return(font)
allow(Cairo::PDFSurface).to receive(:new).and_return(nil)
%w(save set_source_color paint restore translate rotate move_to
update_pango_layout width height show_pango_layout rounded_rectangle
set_line_width stroke fill set_source scale render_rsvg_handle circle
triangle line_to operator= show_page clip transform mask rectangle
reset_clip antialias= curve_to matrix= pango_layout_path stroke_preserve
fill_preserve close_path set_dash set_line_cap set_line_join).each do |m|
allow(cxt).to receive(m) { |*args| strio << scrub_hex("cairo: #{m}(#{args})\n") }
end
%w(font_description= text= width= height= wrap= ellipsize= alignment=
justify= spacing= markup= ellipsized?).each do |m|
allow(pango).to receive(m) {|*args| strio << scrub_hex("pango: #{m}(#{args})\n") }
end
%w(size=).each do |m|
allow(font).to receive(m) { |*args| strio << scrub_hex("pango font: #{m}(#{args})\n") }
end
%w(write_to_png).each do |m|
allow(surface).to receive(m) { |*args| strio << scrub_hex("surface: #{m}(#{args})\n") }
end
%w(next_char!).each do |m|
allow(iter).to receive(m) { |*args| strio << scrub_hex("pango_iter: #{m}(#{args})\n") }
end
end
# Refine Squib to allow setting the logger and progress bar
module Squib
def logger=(l)
@logger = l
end
module_function :logger=
class Deck
attr_accessor :progress_bar
end
end
def output_dir
File.expand_path('../samples/_output', File.dirname(__FILE__))
end

Loading…
Cancel
Save