Browse Source

👮 leading space in comments

dev
Andy Meneely 10 years ago
parent
commit
65a0fdfd47
  1. 2
      Rakefile
  2. 6
      lib/squib/api/data.rb
  3. 2
      lib/squib/api/text.rb
  4. 4
      lib/squib/args/arg_loader.rb
  5. 2
      lib/squib/args/color_validator.rb
  6. 2
      lib/squib/args/dir_validator.rb
  7. 4
      lib/squib/args/typographer.rb
  8. 4
      lib/squib/args/unit_conversion.rb
  9. 2
      lib/squib/conf.rb
  10. 2
      lib/squib/graphics/shapes.rb
  11. 2
      lib/squib/graphics/showcase.rb
  12. 6
      lib/squib/graphics/text.rb
  13. 8
      lib/squib/layout_parser.rb
  14. 2
      lib/squib/sample_helpers.rb
  15. 2
      samples/draw_shapes.rb
  16. 4
      samples/excel.rb
  17. 2
      samples/hand.rb
  18. 2
      samples/load_images.rb
  19. 2
      samples/ranges.rb
  20. 4
      spec/api/api_data_spec.rb
  21. 2
      spec/args/draw_spec.rb
  22. 2
      spec/args/typographer_spec.rb
  23. 6
      spec/graphics/graphics_save_doc_spec.rb
  24. 2
      spec/samples/sanity.rb

2
Rakefile

@ -29,7 +29,7 @@ end
desc 'Run some performance benchmarks'
task benchmark: [:install] do
require 'squib'
Squib::logger.level = Logger::ERROR #silence warnings
Squib::logger.level = Logger::ERROR # silence warnings
Dir.chdir('benchmarks') do
Benchmark.bm(15) do |bm|
Dir['*.rb'].each do | script |

6
lib/squib/api/data.rb

@ -23,10 +23,10 @@ module Squib
cell.strip! if cell.respond_to?(:strip) && import.strip?
cell = yield(header, cell) if block_given?
data[header] << cell
end#row
end#col
end# row
end# col
explode_quantities(data, import.explode)
end#xlsx
end# xlsx
module_function :xlsx
# DSL method. See http://squib.readthedocs.org

2
lib/squib/api/text.rb

@ -15,7 +15,7 @@ module Squib
trans = Args::Transform.new.load!(opts, expand_by: size, layout: layout, dpi: dpi)
draw = Args::Draw.new(custom_colors, { stroke_width: 0.0 }).load!(opts, expand_by: size, layout: layout, dpi: dpi)
embed = TextEmbed.new(size, custom_colors, layout, dpi, img_dir)
yield(embed) if block_given? #store the opts for later use
yield(embed) if block_given? # store the opts for later use
extents = Array.new(@cards.size)
range.each { |i| extents[i] = @cards[i].text(embed, para[i], box[i], trans[i], draw[i]) }
return extents

4
lib/squib/args/arg_loader.rb

@ -122,9 +122,9 @@ module Squib
def convert_unit(arg, dpi)
case arg.to_s.rstrip
when /in$/ #ends with "in"
when /in$/ # ends with "in"
arg.rstrip[0..-2].to_f * dpi
when /cm$/ #ends with "cm"
when /cm$/ # ends with "cm"
arg.rstrip[0..-2].to_f * dpi * INCHES_IN_CM
else
arg

2
lib/squib/args/color_validator.rb

@ -1,5 +1,5 @@
module Squib
#@api private
# @api private
module Args
module ColorValidator

2
lib/squib/args/dir_validator.rb

@ -1,5 +1,5 @@
module Squib
#@api private
# @api private
module Args
module DirValidator

4
lib/squib/args/typographer.rb

@ -1,10 +1,10 @@
require_relative '../constants'
module Squib
#@api private
# @api private
module Args
# Internal class for handling arguments
#@api private
# @api private
class Typographer
def initialize(config = Conf::DEFAULTS)

4
lib/squib/args/unit_conversion.rb

@ -11,9 +11,9 @@ module Squib
module_function
def parse(arg, dpi=300)
case arg.to_s.rstrip
when /in$/ #ends with "in"
when /in$/ # ends with "in"
arg.rstrip[0..-2].to_f * dpi
when /cm$/ #ends with "cm"
when /cm$/ # ends with "cm"
arg.rstrip[0..-2].to_f * dpi * INCHES_IN_CM
else
arg

2
lib/squib/conf.rb

@ -28,7 +28,7 @@ module Squib
'warn_png_scale' => true,
}
#Translate the hints to the methods.
# Translate the hints to the methods.
ANTIALIAS_OPTS = {
nil => 'subpixel',
'best' => 'subpixel',

2
lib/squib/graphics/shapes.rb

@ -101,7 +101,7 @@ module Squib
inner_radius, outer_radius = poly.inner_radius, poly.outer_radius
use_cairo do |cc|
cc.rotate_about(x, y, trans.angle)
cc.move_to(x + outer_radius, y) #i = 0, so cos(0)=1 and sin(0)=0
cc.move_to(x + outer_radius, y) # i = 0, so cos(0)=1 and sin(0)=0
theta = Math::PI / n.to_f # i.e. (2*pi) / (2*n)
0.upto(2 * n) do |i|
radius = i.even? ? outer_radius : inner_radius

2
lib/squib/graphics/showcase.rb

@ -69,7 +69,7 @@ module Squib
(0..src.width).step(in_thickness) do |i|
percentage = i / src.width.to_f
i = src.width - i if face_right
factor = scale + (percentage * (1.0 - scale)) #linear interpolation
factor = scale + (percentage * (1.0 - scale)) # linear interpolation
dest_cxt.save
dest_cxt.translate 0, src.height / 2.0 * (1.0 - factor)
dest_cxt.scale factor * scale, factor

6
lib/squib/graphics/text.rb

@ -25,7 +25,7 @@ module Squib
def compute_valign(layout, valign, embed_h)
return 0 unless layout.height > 0
ink_extents = layout.extents[1]
ink_extents.height = embed_h * Pango::SCALE if ink_extents.height == 0 #JUST embed, bug #134
ink_extents.height = embed_h * Pango::SCALE if ink_extents.height == 0 # JUST embed, bug #134
case valign.to_s.downcase
when 'middle'
Pango.pixels((layout.height - ink_extents.height) / 2)
@ -94,7 +94,7 @@ module Squib
rule = embed.rules[key]
spacing = rule[:box].width[@index] * Pango::SCALE
kindex = clean_str.index(key)
kindex = clean_str[0..kindex].bytesize #convert to byte index (bug #57)
kindex = clean_str[0..kindex].bytesize # convert to byte index (bug #57)
str = str.sub(key, "<span size=\"#{ZERO_WIDTH_CHAR_SIZE}\">a<span letter_spacing=\"#{spacing.to_i}\">a</span>a</span>")
layout.markup = str
clean_str = layout.text
@ -158,7 +158,7 @@ module Squib
embed_draws = process_embeds(embed, para.str, layout)
vertical_start = compute_valign(layout, para.valign, max_embed_height(embed_draws))
cc.move_to(0, vertical_start) #TODO clean this up a bit
cc.move_to(0, vertical_start) # TODO clean this up a bit
stroke_outline!(cc, layout, draw) if draw.stroke_strategy == :stroke_first
cc.move_to(0, vertical_start)

8
lib/squib/layout_parser.rb

@ -2,7 +2,7 @@ require 'yaml'
module Squib
# Internal class for handling layouts
#@api private
# @api private
class LayoutParser
# Load the layout file(s), if exists
@ -14,7 +14,7 @@ module Squib
thefile = file
thefile = builtin(file) unless File.exists?(file)
if File.exists? thefile
yml = layout.merge(YAML.load_file(thefile) || {}) #load_file returns false on empty file
yml = layout.merge(YAML.load_file(thefile) || {}) # load_file returns false on empty file
yml.each do |key, value|
layout[key] = recurse_extends(yml, key, {})
end
@ -47,11 +47,11 @@ module Squib
elsif child_val.to_s.strip.start_with?('-=')
parent_val - child_val.sub('-=', '').strip.to_f
else
child_val #child overrides parent when merging, no +=
child_val # child overrides parent when merging, no +=
end
end
h = h.merge(from_extends) do |key, older_sibling, younger_sibling|
younger_sibling #when two siblings have the same entry, the "younger" (lower one) overrides
younger_sibling # when two siblings have the same entry, the "younger" (lower one) overrides
end
end
return h

2
lib/squib/sample_helpers.rb

@ -1,7 +1,7 @@
module Squib
# Some helper methods specifically for samples
#@api private
# @api private
#:nodoc:
class Deck

2
samples/draw_shapes.rb

@ -36,7 +36,7 @@ Squib::Deck.new do
star x: 300, y: 1000, n: 5, inner_radius: 15, outer_radius: 40,
fill_color: :cyan, stroke_color: :burgundy, stroke_width: 5
#default draw is fill-then-stroke. Can be changed to stroke-then-fill
# default draw is fill-then-stroke. Can be changed to stroke-then-fill
star x: 375, y: 1000, n: 5, inner_radius: 15, outer_radius: 40,
fill_color: :cyan, stroke_color: :burgundy,
stroke_width: 5, stroke_strategy: :stroke_first

4
samples/excel.rb

@ -11,7 +11,7 @@ Squib::Deck.new(cards: 3) do
text str: data['Level'], x: 65, y: 65, font: 'Arial 72'
text str: data['Description'], x: 65, y: 600, font: 'Arial 36'
save format: :png, prefix: 'sample_excel_' #save to individual pngs
save format: :png, prefix: 'sample_excel_' # save to individual pngs
end
# xlsx is also a Squib-module-level function, so this also works:
@ -51,5 +51,5 @@ Squib::Deck.new(cards: resource_data['Name'].size) do
rect width: :deck, height: :deck
text str: resource_data['Name'], align: :center, width: :deck, hint: 'red'
text str: resource_data['Cost'], align: :right, width: :deck, hint: 'red'
save_sheet prefix: 'sample_excel_resources_' #save to a whole sheet
save_sheet prefix: 'sample_excel_resources_' # save to a whole sheet
end

2
samples/hand.rb

@ -7,7 +7,7 @@ Squib::Deck.new(cards: 8, layout: 'playing-card.yml') do
text str: ('A'..'Z').to_a, layout: :bonus_ul, font: 'Sans bold 100'
# Defaults are sensible
hand #saves to _output/hand.png
hand # saves to _output/hand.png
# Here's a prettier version:
# - Each card is trimmed with rounded corners

2
samples/load_images.rb

@ -10,7 +10,7 @@ Squib::Deck.new(width: 825, height: 1125, cards: 1, config: 'load_images_config.
# Can be scaled if width and height are set
svg file: 'spanner.svg', x: 50, y: 50, width: 250, height: 250
png file: 'shiny-purse.png', x: 305, y: 50, width: 250, height: 250
#...but PNGs will warn if it's an upscale, unless you disable them in config.yml
# ...but PNGs will warn if it's an upscale, unless you disable them in config.yml
# Can be scaled using just width or height, if one of them is set to :scale
svg file: 'spanner.svg', x: 200, y: 350, width: 35, height: :scale

2
samples/ranges.rb

@ -50,7 +50,7 @@ Squib::Deck.new(width: 825, height: 1125, cards: 3) do
x:25, y: 500
# Useful idiom: draw a different number of images for different cards
hearts = [nil, 1, 2] #i.e. card 0 has no hearts, card 2 has 2 hearts drawn
hearts = [nil, 1, 2] # i.e. card 0 has no hearts, card 2 has 2 hearts drawn
1.upto(2).each do |n|
range = hearts.each_index.select { |i| hearts[i] == n}
n.times do |i|

4
spec/api/api_data_spec.rb

@ -64,8 +64,8 @@ describe Squib::Deck do
it 'loads basic xlsx data' do
expect(Squib.xlsx(file: xlsx_file('basic.xlsx'))).to eq({
'Name' => %w(Larry Curly Mo),
'General Number' => %w(1 2 3), #general types always get loaded as strings with no conversion
'Actual Number' => [4.0, 5.0, 6.0], #numbers get auto-converted to integers
'General Number' => %w(1 2 3), # general types always get loaded as strings with no conversion
'Actual Number' => [4.0, 5.0, 6.0], # numbers get auto-converted to integers
})
end

2
spec/args/draw_spec.rb

@ -20,7 +20,7 @@ describe Squib::Args::Draw do
it 'works when specified' do
draw.load!({}) # go right to defaults
expect(draw.stroke_width).to eq([0.0]) #ordinarily a non-zero according
expect(draw.stroke_width).to eq([0.0]) # ordinarily a non-zero according
end
end

2
spec/args/typographer_spec.rb

@ -63,7 +63,7 @@ it "single quotes inside double quotes" do
context 'configured' do
#TODO
# TODO
end

6
spec/graphics/graphics_save_doc_spec.rb

@ -18,7 +18,7 @@ describe Squib::Deck, '#save_pdf' do
end
before(:each) do
allow(Cairo::PDFSurface).to receive(:new).and_return(nil) #don't create the file
allow(Cairo::PDFSurface).to receive(:new).and_return(nil) # don't create the file
allow(Cairo::Context).to receive(:new).and_return(cxt)
allow(cxt).to receive(:antialias=)
end
@ -27,7 +27,7 @@ describe Squib::Deck, '#save_pdf' do
num_cards = 9
deck = Squib::Deck.new(cards: 9, width: 825, height: 1125)
expect(Squib.logger).to receive(:debug).at_least(:once)
expect(Squib.logger).to receive(:warn).exactly(:once) #warn about making the dir
expect(Squib.logger).to receive(:warn).exactly(:once) # warn about making the dir
expect(Dir).to receive(:mkdir) {} # don't actually make the dir
expect(cxt).to receive(:scale).with(0.24, 0.24)
@ -51,7 +51,7 @@ describe Squib::Deck, '#save_pdf' do
args = { range: 2..4, file: 'foo.pdf', dir: '_out', margin: 75, gap: 5, trim: 37 }
deck = Squib::Deck.new(cards: num_cards, width: 825, height: 1125)
expect(Squib.logger).to receive(:debug).at_least(:once)
expect(Squib.logger).to receive(:warn).exactly(:once) #warn about making the dir
expect(Squib.logger).to receive(:warn).exactly(:once) # warn about making the dir
expect(Dir).to receive(:mkdir) {} # don't actually make the dir
expect(cxt).to receive(:scale).with(0.24, 0.24)

2
spec/samples/sanity.rb

@ -20,7 +20,7 @@ class Sanity
row = []
actual_png = @@OUTPUT_DIR + File.basename(exp_png)
row << "file:///" + exp_png
row << "file:///" + actual_png #actual
row << "file:///" + actual_png # actual
row << "file:///" + diff_image(exp_png, actual_png)
images << row
bar.increment

Loading…
Cancel
Save