👮 string literals should be single-quoted
parent
65a0fdfd47
commit
0cbcc0c683
4
Rakefile
4
Rakefile
|
|
@ -13,7 +13,7 @@ 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')
|
args.with_defaults(file: 'basic.rb')
|
||||||
Dir.chdir('samples') do
|
Dir.chdir('samples') do
|
||||||
args[:file] << ".rb" unless args[:file].end_with? '.rb'
|
args[:file] << '.rb' unless args[:file].end_with? '.rb'
|
||||||
puts "Running samples/#{args[:file]}"
|
puts "Running samples/#{args[:file]}"
|
||||||
load args[:file]
|
load args[:file]
|
||||||
end
|
end
|
||||||
|
|
@ -23,7 +23,7 @@ end
|
||||||
RSpec::Core::RakeTask.new(:spec)
|
RSpec::Core::RakeTask.new(:spec)
|
||||||
|
|
||||||
RSpec::Core::RakeTask.new(:spec_fastonly) do |t|
|
RSpec::Core::RakeTask.new(:spec_fastonly) do |t|
|
||||||
t.rspec_opts = "--tag ~slow"
|
t.rspec_opts = '--tag ~slow'
|
||||||
end
|
end
|
||||||
|
|
||||||
desc 'Run some performance benchmarks'
|
desc 'Run some performance benchmarks'
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@ require 'squib'
|
||||||
|
|
||||||
Squib::Deck.new(cards: 200) do
|
Squib::Deck.new(cards: 200) do
|
||||||
background color: :white
|
background color: :white
|
||||||
text str: "Hello, world!", y: 500, width: 825, font: 'Sans bold 72', align: :center
|
text str: 'Hello, world!', y: 500, width: 825, font: 'Sans bold 72', align: :center
|
||||||
rect x: 10, y: 10, width: 20, height: 20
|
rect x: 10, y: 10, width: 20, height: 20
|
||||||
circle x: 40, y: 40, radius: 25
|
circle x: 40, y: 40, radius: 25
|
||||||
triangle x1: 50, y1: 15, x2: 60, y2: 25, x3: 75, y3: 25
|
triangle x1: 50, y1: 15, x2: 60, y2: 25, x3: 75, y3: 25
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@ require 'squib'
|
||||||
|
|
||||||
Squib::Deck.new(cards: 200, config: 'backend-svg.yml') do
|
Squib::Deck.new(cards: 200, config: 'backend-svg.yml') do
|
||||||
background color: :white
|
background color: :white
|
||||||
text str: "Hello, world!", y: 500, width: 825, font: 'Sans bold 72', align: :center
|
text str: 'Hello, world!', y: 500, width: 825, font: 'Sans bold 72', align: :center
|
||||||
rect x: 10, y: 10, width: 20, height: 20
|
rect x: 10, y: 10, width: 20, height: 20
|
||||||
circle x: 40, y: 40, radius: 25
|
circle x: 40, y: 40, radius: 25
|
||||||
triangle x1: 50, y1: 15, x2: 60, y2: 25, x3: 75, y3: 25
|
triangle x1: 50, y1: 15, x2: 60, y2: 25, x3: 75, y3: 25
|
||||||
|
|
|
||||||
|
|
@ -167,10 +167,10 @@ module Squib
|
||||||
begin
|
begin
|
||||||
embed_draws.each { |ed| ed[:draw].call(self, ed[:x], ed[:y] + vertical_start) }
|
embed_draws.each { |ed| ed[:draw].call(self, ed[:x], ed[:y] + vertical_start) }
|
||||||
rescue Exception => e
|
rescue Exception => e
|
||||||
puts "====EXCEPTION!===="
|
puts '====EXCEPTION!===='
|
||||||
puts e
|
puts e
|
||||||
puts "If this was a non-invertible matrix error, this is a known issue with a potential workaround. Please report it at: https://github.com/andymeneely/squib/issues/55"
|
puts 'If this was a non-invertible matrix error, this is a known issue with a potential workaround. Please report it at: https://github.com/andymeneely/squib/issues/55'
|
||||||
puts "=================="
|
puts '=================='
|
||||||
raise e
|
raise e
|
||||||
end
|
end
|
||||||
draw_text_hint(cc, box.x, box.y, layout, para.hint)
|
draw_text_hint(cc, box.x, box.y, layout, para.hint)
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@ Squib::Deck.new(cards: 2, config: 'backend-config.yml') do
|
||||||
|
|
||||||
# These are all supported by the SVG backend
|
# These are all supported by the SVG backend
|
||||||
background color: :gray
|
background color: :gray
|
||||||
text str: "Hello, world!", y: 500, width: 825, font: 'Sans bold 72', align: :center
|
text str: 'Hello, world!', y: 500, width: 825, font: 'Sans bold 72', align: :center
|
||||||
rect x: 38, y: 38, width: 750, height: 1050, x_radius: 38, y_radius: 38
|
rect x: 38, y: 38, width: 750, height: 1050, x_radius: 38, y_radius: 38
|
||||||
circle x: 100, y: 400, radius: 25
|
circle x: 100, y: 400, radius: 25
|
||||||
triangle x1: 100, y1: 425, x2: 125, y2: 475, x3: 75, y3: 475
|
triangle x1: 100, y1: 425, x2: 125, y2: 475, x3: 75, y3: 475
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@ Squib::Deck.new(config: 'config_text_markup.yml') do
|
||||||
x: 10, y: 10, width: 300, height: 200, font: 'Serif 20',
|
x: 10, y: 10, width: 300, height: 200, font: 'Serif 20',
|
||||||
markup: true, hint: :cyan
|
markup: true, hint: :cyan
|
||||||
|
|
||||||
text str: "Notice also the antialiasing method.",
|
text str: 'Notice also the antialiasing method.',
|
||||||
x: 320, y: 10, width: 300, height: 200, font: 'Arial Bold 20'
|
x: 320, y: 10, width: 300, height: 200, font: 'Arial Bold 20'
|
||||||
|
|
||||||
save_png prefix: 'config_text_'
|
save_png prefix: 'config_text_'
|
||||||
|
|
|
||||||
|
|
@ -46,7 +46,7 @@ end
|
||||||
Squib::Deck.new(layout: 'playing-card.yml') do
|
Squib::Deck.new(layout: 'playing-card.yml') do
|
||||||
text str: "A\u2660", layout: :bonus_ul, font: 'Sans bold 100', hint: :red
|
text str: "A\u2660", layout: :bonus_ul, font: 'Sans bold 100', hint: :red
|
||||||
text str: "A\u2660", layout: :bonus_lr, font: 'Sans bold 100', hint: :red
|
text str: "A\u2660", layout: :bonus_lr, font: 'Sans bold 100', hint: :red
|
||||||
text str: "artwork here", layout: :art, hint: :red
|
text str: 'artwork here', layout: :art, hint: :red
|
||||||
save_png prefix: 'layout_builtin_playing_card_'
|
save_png prefix: 'layout_builtin_playing_card_'
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -79,15 +79,15 @@ Squib::Deck.new(width: 825, height: 1125, cards: 3) do
|
||||||
embed.svg key: ':health:', width: 28, height: 28, file: 'glass-heart.svg'
|
embed.svg key: ':health:', width: 28, height: 28, file: 'glass-heart.svg'
|
||||||
end
|
end
|
||||||
|
|
||||||
text str: "Fill n <span fgcolor=\"\#ff0000\">stroke</span>",
|
text str: 'Fill n <span fgcolor="#ff0000">stroke</span>',
|
||||||
color: :green, stroke_width: 2.0, stroke_color: :blue,
|
color: :green, stroke_width: 2.0, stroke_color: :blue,
|
||||||
x: '1.8in', y: '2.9in', width: '0.85in', font: 'Sans Bold 26', markup: true
|
x: '1.8in', y: '2.9in', width: '0.85in', font: 'Sans Bold 26', markup: true
|
||||||
|
|
||||||
text str: "Stroke n <span fgcolor=\"\#ff0000\">fill</span>",
|
text str: 'Stroke n <span fgcolor="#ff0000">fill</span>',
|
||||||
color: :green, stroke_width: 2.0, stroke_color: :blue, stroke_strategy: :stroke_first,
|
color: :green, stroke_width: 2.0, stroke_color: :blue, stroke_strategy: :stroke_first,
|
||||||
x: '1.8in', y: '3.0in', width: '0.85in', font: 'Sans Bold 26', markup: true
|
x: '1.8in', y: '3.0in', width: '0.85in', font: 'Sans Bold 26', markup: true
|
||||||
|
|
||||||
text str: "Dotted",
|
text str: 'Dotted',
|
||||||
color: :white, stroke_width: 2.0, dash: '4 2', stroke_color: :black,
|
color: :white, stroke_width: 2.0, dash: '4 2', stroke_color: :black,
|
||||||
x: '1.8in', y: '3.1in', width: '0.85in', font: 'Sans Bold 26', markup: true
|
x: '1.8in', y: '3.1in', width: '0.85in', font: 'Sans Bold 26', markup: true
|
||||||
#
|
#
|
||||||
|
|
|
||||||
|
|
@ -24,40 +24,40 @@ describe Squib::Args::Typographer do
|
||||||
expect(t.process(%{"foo"})).to eq(%{\u201Cfoo\u201D})
|
expect(t.process(%{"foo"})).to eq(%{\u201Cfoo\u201D})
|
||||||
end
|
end
|
||||||
|
|
||||||
it "quotes in the middle of the string" do
|
it 'quotes in the middle of the string' do
|
||||||
expect(t.process(%{hello "foo" world})).to eq(%{hello \u201Cfoo\u201D world})
|
expect(t.process(%{hello "foo" world})).to eq(%{hello \u201Cfoo\u201D world})
|
||||||
end
|
end
|
||||||
|
|
||||||
it "single left quotes at the beginning" do
|
it 'single left quotes at the beginning' do
|
||||||
expect(t.process(%{'foo})).to eq(%{\u2018foo})
|
expect(t.process(%{'foo})).to eq(%{\u2018foo})
|
||||||
end
|
end
|
||||||
|
|
||||||
it "single right quotes at the end" do
|
it 'single right quotes at the end' do
|
||||||
expect(t.process(%{foo'})).to eq(%{foo\u2019})
|
expect(t.process(%{foo'})).to eq(%{foo\u2019})
|
||||||
end
|
end
|
||||||
|
|
||||||
it "single quotes in the middle" do
|
it 'single quotes in the middle' do
|
||||||
expect(t.process(%{a 'foo' bar})).to eq(%{a \u2018foo\u2019 bar})
|
expect(t.process(%{a 'foo' bar})).to eq(%{a \u2018foo\u2019 bar})
|
||||||
end
|
end
|
||||||
|
|
||||||
it "handles apostraphes" do
|
it 'handles apostraphes' do
|
||||||
expect(t.process(%{can't})).to eq(%{can\u2019t})
|
expect(t.process(%{can't})).to eq(%{can\u2019t})
|
||||||
end
|
end
|
||||||
|
|
||||||
it "single quotes inside double quotes" do
|
it 'single quotes inside double quotes' do
|
||||||
expect(t.process(%{"'I can't do that', he said"})).to eq(%{\u201C\u2018I can\u2019t do that\u2019, he said\u201D})
|
expect(t.process(%{"'I can't do that', he said"})).to eq(%{\u201C\u2018I can\u2019t do that\u2019, he said\u201D})
|
||||||
end
|
end
|
||||||
|
|
||||||
it "replaces the straightforward ones" do
|
it 'replaces the straightforward ones' do
|
||||||
expect(t.process(%{``hi...'' -- ---})).to eq(%{\u201Chi\u2026\u201D \u2013 \u2014})
|
expect(t.process(%{``hi...'' -- ---})).to eq(%{\u201Chi\u2026\u201D \u2013 \u2014})
|
||||||
end
|
end
|
||||||
|
|
||||||
it "does nothing on lone quotes" do
|
it 'does nothing on lone quotes' do
|
||||||
expect(t.process(%{"})).to eq(%{"})
|
expect(t.process(%{"})).to eq(%{"})
|
||||||
expect(t.process(%{'})).to eq(%{'})
|
expect(t.process(%{'})).to eq(%{'})
|
||||||
end
|
end
|
||||||
|
|
||||||
it "ignores stuff in <tags>" do
|
it 'ignores stuff in <tags>' do
|
||||||
expect(t.process(%{<span weight="bold">"can't"</span>})).to eq(%{<span weight="bold">\u201Ccan\u2019t\u201D</span>})
|
expect(t.process(%{<span weight="bold">"can't"</span>})).to eq(%{<span weight="bold">\u201Ccan\u2019t\u201D</span>})
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@ describe Squib.logger do
|
||||||
Squib.logger = nil
|
Squib.logger = nil
|
||||||
oldstdout = $stdout
|
oldstdout = $stdout
|
||||||
$stdout = StringIO.new
|
$stdout = StringIO.new
|
||||||
Squib::logger.warn "Test warn"
|
Squib::logger.warn 'Test warn'
|
||||||
expect($stdout.string).to match /WARN: Test warn/
|
expect($stdout.string).to match /WARN: Test warn/
|
||||||
$stdout = oldstdout
|
$stdout = oldstdout
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@ require 'spec_helper'
|
||||||
require 'squib'
|
require 'squib'
|
||||||
require 'pp'
|
require 'pp'
|
||||||
|
|
||||||
describe "Squib samples" do
|
describe 'Squib samples' do
|
||||||
|
|
||||||
Dir["#{samples_dir}/**/*.rb"].each do |sample|
|
Dir["#{samples_dir}/**/*.rb"].each do |sample|
|
||||||
it "executes #{sample} with no errors", slow: true do
|
it "executes #{sample} with no errors", slow: true do
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@ require 'spec_helper'
|
||||||
require 'squib'
|
require 'squib'
|
||||||
require 'pp'
|
require 'pp'
|
||||||
|
|
||||||
describe "Squib samples" do
|
describe 'Squib samples' do
|
||||||
|
|
||||||
around(:each) do |example|
|
around(:each) do |example|
|
||||||
Dir.chdir(samples_dir) do
|
Dir.chdir(samples_dir) do
|
||||||
|
|
|
||||||
|
|
@ -14,14 +14,14 @@ class Sanity
|
||||||
|
|
||||||
def images
|
def images
|
||||||
images = []
|
images = []
|
||||||
exp_pngs = Dir[@@EXPECTED_DIR + "/**/*.png"]
|
exp_pngs = Dir[@@EXPECTED_DIR + '/**/*.png']
|
||||||
bar = ProgressBar.create(title: 'Diffing images', total: exp_pngs.size)
|
bar = ProgressBar.create(title: 'Diffing images', total: exp_pngs.size)
|
||||||
exp_pngs.each do |exp_png|
|
exp_pngs.each do |exp_png|
|
||||||
row = []
|
row = []
|
||||||
actual_png = @@OUTPUT_DIR + File.basename(exp_png)
|
actual_png = @@OUTPUT_DIR + File.basename(exp_png)
|
||||||
row << "file:///" + exp_png
|
row << 'file:///' + exp_png
|
||||||
row << "file:///" + actual_png # actual
|
row << 'file:///' + actual_png # actual
|
||||||
row << "file:///" + diff_image(exp_png, actual_png)
|
row << 'file:///' + diff_image(exp_png, actual_png)
|
||||||
images << row
|
images << row
|
||||||
bar.increment
|
bar.increment
|
||||||
end
|
end
|
||||||
|
|
@ -30,11 +30,11 @@ class Sanity
|
||||||
end
|
end
|
||||||
|
|
||||||
def run
|
def run
|
||||||
puts "Building sanity test..."
|
puts 'Building sanity test...'
|
||||||
sanity_template = File.read(@@SANITY_ERB)
|
sanity_template = File.read(@@SANITY_ERB)
|
||||||
process_erb(sanity_template)
|
process_erb(sanity_template)
|
||||||
Launchy.open("file:///" + @@SANITY_HTML)
|
Launchy.open('file:///' + @@SANITY_HTML)
|
||||||
puts "Done."
|
puts 'Done.'
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
@ -51,7 +51,7 @@ class Sanity
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
out = Cairo::ImageSurface.new(new_data.pack('c*'), exp.format, exp.width, exp.height, exp.stride)
|
out = Cairo::ImageSurface.new(new_data.pack('c*'), exp.format, exp.width, exp.height, exp.stride)
|
||||||
out_file = @@DIFF_DIR + exp_file[exp_file.rindex("/")..-1]
|
out_file = @@DIFF_DIR + exp_file[exp_file.rindex('/')..-1]
|
||||||
out.write_to_png(out_file)
|
out.write_to_png(out_file)
|
||||||
out_file
|
out_file
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -101,7 +101,7 @@ def mock_cairo(strio)
|
||||||
allow(pango).to receive(:extents).and_return([Pango::Rectangle.new(0, 0, 0, 0)] * 2)
|
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(:iter).and_return(iter)
|
||||||
allow(pango).to receive(:alignment).and_return(Pango::Layout::Alignment::LEFT)
|
allow(pango).to receive(:alignment).and_return(Pango::Layout::Alignment::LEFT)
|
||||||
allow(pango).to receive(:text).and_return("foo")
|
allow(pango).to receive(:text).and_return('foo')
|
||||||
allow(pango).to receive(:context).and_return(pango_cxt)
|
allow(pango).to receive(:context).and_return(pango_cxt)
|
||||||
allow(pango_cxt).to receive(:font_options=)
|
allow(pango_cxt).to receive(:font_options=)
|
||||||
allow(iter).to receive(:next_char!).and_return(false)
|
allow(iter).to receive(:next_char!).and_return(false)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue