Browse Source

👮 string literals should be single-quoted

dev
Andy Meneely 10 years ago
parent
commit
0cbcc0c683
  1. 4
      Rakefile
  2. 2
      benchmarks/backend_memory.rb
  3. 2
      benchmarks/backend_svg.rb
  4. 6
      lib/squib/graphics/text.rb
  5. 2
      samples/backend.rb
  6. 2
      samples/config_text_markup.rb
  7. 2
      samples/layouts.rb
  8. 6
      samples/text_options.rb
  9. 18
      spec/args/typographer_spec.rb
  10. 2
      spec/logger_spec.rb
  11. 2
      spec/samples/run_samples_spec.rb
  12. 2
      spec/samples/samples_regression_spec.rb
  13. 16
      spec/samples/sanity.rb
  14. 2
      spec/spec_helper.rb

4
Rakefile

@ -13,7 +13,7 @@ desc 'Run a specific sample'
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'
args[:file] << '.rb' unless args[:file].end_with? '.rb'
puts "Running samples/#{args[:file]}"
load args[:file]
end
@ -23,7 +23,7 @@ end
RSpec::Core::RakeTask.new(:spec)
RSpec::Core::RakeTask.new(:spec_fastonly) do |t|
t.rspec_opts = "--tag ~slow"
t.rspec_opts = '--tag ~slow'
end
desc 'Run some performance benchmarks'

2
benchmarks/backend_memory.rb

@ -2,7 +2,7 @@ require 'squib'
Squib::Deck.new(cards: 200) do
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
circle x: 40, y: 40, radius: 25
triangle x1: 50, y1: 15, x2: 60, y2: 25, x3: 75, y3: 25

2
benchmarks/backend_svg.rb

@ -2,7 +2,7 @@ require 'squib'
Squib::Deck.new(cards: 200, config: 'backend-svg.yml') do
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
circle x: 40, y: 40, radius: 25
triangle x1: 50, y1: 15, x2: 60, y2: 25, x3: 75, y3: 25

6
lib/squib/graphics/text.rb

@ -167,10 +167,10 @@ module Squib
begin
embed_draws.each { |ed| ed[:draw].call(self, ed[:x], ed[:y] + vertical_start) }
rescue Exception => e
puts "====EXCEPTION!===="
puts '====EXCEPTION!===='
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 "=================="
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 '=================='
raise e
end
draw_text_hint(cc, box.x, box.y, layout, para.hint)

2
samples/backend.rb

@ -5,7 +5,7 @@ Squib::Deck.new(cards: 2, config: 'backend-config.yml') do
# These are all supported by the SVG backend
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
circle x: 100, y: 400, radius: 25
triangle x1: 100, y1: 425, x2: 125, y2: 475, x3: 75, y3: 475

2
samples/config_text_markup.rb

@ -6,7 +6,7 @@ Squib::Deck.new(config: 'config_text_markup.yml') do
x: 10, y: 10, width: 300, height: 200, font: 'Serif 20',
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'
save_png prefix: 'config_text_'

2
samples/layouts.rb

@ -46,7 +46,7 @@ end
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_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_'
end

6
samples/text_options.rb

@ -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'
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,
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,
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,
x: '1.8in', y: '3.1in', width: '0.85in', font: 'Sans Bold 26', markup: true
#

18
spec/args/typographer_spec.rb

@ -24,40 +24,40 @@ describe Squib::Args::Typographer do
expect(t.process(%{"foo"})).to eq(%{\u201Cfoo\u201D})
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})
end
it "single left quotes at the beginning" do
it 'single left quotes at the beginning' do
expect(t.process(%{'foo})).to eq(%{\u2018foo})
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})
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})
end
it "handles apostraphes" do
it 'handles apostraphes' do
expect(t.process(%{can't})).to eq(%{can\u2019t})
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})
end
it "replaces the straightforward ones" do
it 'replaces the straightforward ones' do
expect(t.process(%{``hi...'' -- ---})).to eq(%{\u201Chi\u2026\u201D \u2013 \u2014})
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(%{'})
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>})
end

2
spec/logger_spec.rb

@ -5,7 +5,7 @@ describe Squib.logger do
Squib.logger = nil
oldstdout = $stdout
$stdout = StringIO.new
Squib::logger.warn "Test warn"
Squib::logger.warn 'Test warn'
expect($stdout.string).to match /WARN: Test warn/
$stdout = oldstdout
end

2
spec/samples/run_samples_spec.rb

@ -2,7 +2,7 @@ require 'spec_helper'
require 'squib'
require 'pp'
describe "Squib samples" do
describe 'Squib samples' do
Dir["#{samples_dir}/**/*.rb"].each do |sample|
it "executes #{sample} with no errors", slow: true do

2
spec/samples/samples_regression_spec.rb

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

16
spec/samples/sanity.rb

@ -14,14 +14,14 @@ class Sanity
def images
images = []
exp_pngs = Dir[@@EXPECTED_DIR + "/**/*.png"]
exp_pngs = Dir[@@EXPECTED_DIR + '/**/*.png']
bar = ProgressBar.create(title: 'Diffing images', total: exp_pngs.size)
exp_pngs.each do |exp_png|
row = []
actual_png = @@OUTPUT_DIR + File.basename(exp_png)
row << "file:///" + exp_png
row << "file:///" + actual_png # actual
row << "file:///" + diff_image(exp_png, actual_png)
row << 'file:///' + exp_png
row << 'file:///' + actual_png # actual
row << 'file:///' + diff_image(exp_png, actual_png)
images << row
bar.increment
end
@ -30,11 +30,11 @@ class Sanity
end
def run
puts "Building sanity test..."
puts 'Building sanity test...'
sanity_template = File.read(@@SANITY_ERB)
process_erb(sanity_template)
Launchy.open("file:///" + @@SANITY_HTML)
puts "Done."
Launchy.open('file:///' + @@SANITY_HTML)
puts 'Done.'
end
private
@ -51,7 +51,7 @@ class Sanity
end
end
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_file
end

2
spec/spec_helper.rb

@ -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(: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(: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)

Loading…
Cancel
Save