sprues: rename "template" to "sprue"
Also: * Move stuff around to a builtin/ folder * Separate out classes to follow my one-class-per-file convention * Samples are renamed to the underscore convention I just like the word "sprue", and it's more descriptive than our original choice of "template". If I had to start Squib all over again, I would probably name it "Sprue" :P
This commit is contained in:
@@ -6,6 +6,8 @@ describe Squib::Commands::New do
|
||||
describe '#process' do
|
||||
before(:all) do
|
||||
@old_stderr = $stderr
|
||||
@old_stdout = $stdout
|
||||
$stdout = StringIO.new
|
||||
$stderr = StringIO.new
|
||||
@oldpwd = Dir.pwd
|
||||
Dir.chdir(output_dir)
|
||||
@@ -41,6 +43,7 @@ describe Squib::Commands::New do
|
||||
|
||||
after(:all) do
|
||||
$stderr = @old_stderr
|
||||
$stdout = @old_stdout
|
||||
Dir.chdir(@oldpwd)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -62,7 +62,7 @@ describe 'Squib samples' do
|
||||
Dir.chdir(File.dirname("#{samples_dir}/#{sample}")) do
|
||||
load full_sample_path
|
||||
end
|
||||
# overwrite_sample(sample, log) # Use TEMPORARILY once happy with the new sample log
|
||||
overwrite_sample(sample, log) # Use TEMPORARILY once happy with the new sample log
|
||||
test_file_str = File.open(sample_regression_file(sample), 'r:UTF-8').read
|
||||
expect(log.string).to eq(test_file_str)
|
||||
end
|
||||
|
||||
+3
-3
@@ -50,8 +50,8 @@ def yaml_file(file)
|
||||
"#{File.expand_path(File.dirname(__FILE__))}/data/yaml/#{file}"
|
||||
end
|
||||
|
||||
def template_file(file)
|
||||
"#{File.expand_path(File.dirname(__FILE__))}/data/templates/#{file}"
|
||||
def sprue_file(file)
|
||||
"#{File.expand_path(File.dirname(__FILE__))}/data/sprues/#{file}"
|
||||
end
|
||||
|
||||
def project_template(file)
|
||||
@@ -127,7 +127,7 @@ def mock_cairo(strio)
|
||||
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
|
||||
arc arc_negative).each do |m|
|
||||
arc arc_negative new_path new_sub_path).each do |m|
|
||||
allow(cxt).to receive(m) { |*args| strio << scrub_hex("cairo: #{m}(#{args})\n") }
|
||||
end
|
||||
|
||||
|
||||
@@ -1,22 +1,23 @@
|
||||
require 'spec_helper'
|
||||
require 'squib/sprues/sprue'
|
||||
|
||||
describe Squib::Template do
|
||||
it 'loads a template' do
|
||||
tmpl = Squib::Template.load(template_file('basic.yml'), 100)
|
||||
describe Squib::Sprue do
|
||||
it 'loads a sprue' do
|
||||
tmpl = Squib::Sprue.load(sprue_file('basic.yml'), 100)
|
||||
expect(tmpl.sheet_width).to eq(850)
|
||||
expect(tmpl.sheet_height).to eq(1100)
|
||||
expect(tmpl.card_width).to eq(250)
|
||||
expect(tmpl.card_height).to eq(350)
|
||||
expect(tmpl.dpi).to eq(100)
|
||||
expect(tmpl.crop_line_overlay).to eq(
|
||||
Squib::Template::DEFAULTS['crop_line']['overlay']
|
||||
Squib::Sprue::DEFAULTS['crop_line']['overlay']
|
||||
)
|
||||
expect(tmpl.crop_lines).to eq([])
|
||||
expect(tmpl.cards).to eq([{ 'x' => 50, 'y' => 100, 'rotate' => 0 }])
|
||||
end
|
||||
|
||||
it 'loads from the default templates if none exists' do
|
||||
tmpl = Squib::Template.load('a4_poker_card_9up.yml', 100)
|
||||
tmpl = Squib::Sprue.load('a4_poker_card_9up.yml', 100)
|
||||
expect(tmpl.sheet_width).to eq(826.7716527)
|
||||
expect(tmpl.sheet_height).to eq(1169.2913373899999)
|
||||
expect(tmpl.card_width).to eq(248.03149580999997)
|
||||
@@ -77,7 +78,7 @@ describe Squib::Template do
|
||||
end
|
||||
|
||||
it 'loads a template with the coordinates specifying the middle of cards' do
|
||||
tmpl = Squib::Template.load(template_file('card_center_coord.yml'), 100)
|
||||
tmpl = Squib::Sprue.load(sprue_file('card_center_coord.yml'), 100)
|
||||
expect(tmpl.sheet_width).to eq(850)
|
||||
expect(tmpl.sheet_height).to eq(1100)
|
||||
expect(tmpl.card_width).to eq(200)
|
||||
@@ -94,7 +95,7 @@ describe Squib::Template do
|
||||
end
|
||||
|
||||
it 'loads a template with customized crop lines' do
|
||||
tmpl = Squib::Template.load(template_file('custom_crop_lines.yml'), 100)
|
||||
tmpl = Squib::Sprue.load(sprue_file('custom_crop_lines.yml'), 100)
|
||||
expect(tmpl.sheet_width).to eq(850)
|
||||
expect(tmpl.sheet_height).to eq(1100)
|
||||
expect(tmpl.card_width).to eq(200)
|
||||
@@ -130,7 +131,7 @@ describe Squib::Template do
|
||||
end
|
||||
|
||||
it 'loads a template with rotated cards' do
|
||||
tmpl = Squib::Template.load(template_file('card_rotation.yml'), 100)
|
||||
tmpl = Squib::Sprue.load(sprue_file('card_rotation.yml'), 100)
|
||||
expect(tmpl.sheet_width).to eq(850)
|
||||
expect(tmpl.sheet_height).to eq(1100)
|
||||
expect(tmpl.card_width).to eq(250)
|
||||
@@ -145,7 +146,7 @@ describe Squib::Template do
|
||||
|
||||
it 'fails when sheet_width is not defined' do
|
||||
expect do
|
||||
Squib::Template.load(template_file('fail_no_sheet_width.yml'), 100)
|
||||
Squib::Sprue.load(sprue_file('fail_no_sheet_width.yml'), 100)
|
||||
end.to raise_error(
|
||||
RuntimeError,
|
||||
'"sheet_width" is not a String matching /^(\d*[.])?\d+(in|cm|mm)$/'
|
||||
@@ -154,7 +155,7 @@ describe Squib::Template do
|
||||
|
||||
it 'fails when sheet_height is not defined' do
|
||||
expect do
|
||||
Squib::Template.load(template_file('fail_no_sheet_height.yml'), 100)
|
||||
Squib::Sprue.load(sprue_file('fail_no_sheet_height.yml'), 100)
|
||||
end.to raise_error(
|
||||
RuntimeError,
|
||||
'"sheet_height" is not a String matching /^(\d*[.])?\d+(in|cm|mm)$/'
|
||||
@@ -163,7 +164,7 @@ describe Squib::Template do
|
||||
|
||||
it 'fails when card_width is not defined' do
|
||||
expect do
|
||||
Squib::Template.load(template_file('fail_no_card_width.yml'), 100)
|
||||
Squib::Sprue.load(sprue_file('fail_no_card_width.yml'), 100)
|
||||
end.to raise_error(
|
||||
RuntimeError,
|
||||
'"card_width" is not a String matching /^(\d*[.])?\d+(in|cm|mm)$/'
|
||||
@@ -172,7 +173,7 @@ describe Squib::Template do
|
||||
|
||||
it 'fails when card_height is not defined' do
|
||||
expect do
|
||||
Squib::Template.load(template_file('fail_no_card_height.yml'), 100)
|
||||
Squib::Sprue.load(sprue_file('fail_no_card_height.yml'), 100)
|
||||
end.to raise_error(
|
||||
RuntimeError,
|
||||
'"card_height" is not a String matching /^(\d*[.])?\d+(in|cm|mm)$/'
|
||||
Reference in New Issue
Block a user