From 65a0fdfd4756a891d69ed61ebe1712eb8a9ec92b Mon Sep 17 00:00:00 2001 From: Andy Meneely Date: Thu, 17 Mar 2016 23:47:32 -0400 Subject: [PATCH] :cop: leading space in comments --- Rakefile | 2 +- lib/squib/api/data.rb | 6 +++--- lib/squib/api/text.rb | 2 +- lib/squib/args/arg_loader.rb | 4 ++-- lib/squib/args/color_validator.rb | 2 +- lib/squib/args/dir_validator.rb | 2 +- lib/squib/args/typographer.rb | 4 ++-- lib/squib/args/unit_conversion.rb | 4 ++-- lib/squib/conf.rb | 2 +- lib/squib/graphics/shapes.rb | 2 +- lib/squib/graphics/showcase.rb | 2 +- lib/squib/graphics/text.rb | 6 +++--- lib/squib/layout_parser.rb | 8 ++++---- lib/squib/sample_helpers.rb | 2 +- samples/draw_shapes.rb | 2 +- samples/excel.rb | 4 ++-- samples/hand.rb | 2 +- samples/load_images.rb | 2 +- samples/ranges.rb | 2 +- spec/api/api_data_spec.rb | 4 ++-- spec/args/draw_spec.rb | 2 +- spec/args/typographer_spec.rb | 2 +- spec/graphics/graphics_save_doc_spec.rb | 6 +++--- spec/samples/sanity.rb | 2 +- 24 files changed, 38 insertions(+), 38 deletions(-) diff --git a/Rakefile b/Rakefile index eec0451..904a20a 100644 --- a/Rakefile +++ b/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 | diff --git a/lib/squib/api/data.rb b/lib/squib/api/data.rb index c6e86a8..6d93ba8 100644 --- a/lib/squib/api/data.rb +++ b/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 diff --git a/lib/squib/api/text.rb b/lib/squib/api/text.rb index 5387af3..bda6370 100644 --- a/lib/squib/api/text.rb +++ b/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 diff --git a/lib/squib/args/arg_loader.rb b/lib/squib/args/arg_loader.rb index 0a94c21..56e066a 100644 --- a/lib/squib/args/arg_loader.rb +++ b/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 diff --git a/lib/squib/args/color_validator.rb b/lib/squib/args/color_validator.rb index bdd8497..e823197 100644 --- a/lib/squib/args/color_validator.rb +++ b/lib/squib/args/color_validator.rb @@ -1,5 +1,5 @@ module Squib - #@api private + # @api private module Args module ColorValidator diff --git a/lib/squib/args/dir_validator.rb b/lib/squib/args/dir_validator.rb index b09d433..cb5aab2 100644 --- a/lib/squib/args/dir_validator.rb +++ b/lib/squib/args/dir_validator.rb @@ -1,5 +1,5 @@ module Squib - #@api private + # @api private module Args module DirValidator diff --git a/lib/squib/args/typographer.rb b/lib/squib/args/typographer.rb index c618e26..d624f21 100644 --- a/lib/squib/args/typographer.rb +++ b/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) diff --git a/lib/squib/args/unit_conversion.rb b/lib/squib/args/unit_conversion.rb index cee5af8..42a77cd 100644 --- a/lib/squib/args/unit_conversion.rb +++ b/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 diff --git a/lib/squib/conf.rb b/lib/squib/conf.rb index c9cb675..cb38c09 100644 --- a/lib/squib/conf.rb +++ b/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', diff --git a/lib/squib/graphics/shapes.rb b/lib/squib/graphics/shapes.rb index 6cf6f13..5b57eae 100644 --- a/lib/squib/graphics/shapes.rb +++ b/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 diff --git a/lib/squib/graphics/showcase.rb b/lib/squib/graphics/showcase.rb index 1d942c5..65c2e17 100644 --- a/lib/squib/graphics/showcase.rb +++ b/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 diff --git a/lib/squib/graphics/text.rb b/lib/squib/graphics/text.rb index 68a0ece..bd4510e 100644 --- a/lib/squib/graphics/text.rb +++ b/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, "aaa") 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) diff --git a/lib/squib/layout_parser.rb b/lib/squib/layout_parser.rb index 6787a8f..1841ad1 100644 --- a/lib/squib/layout_parser.rb +++ b/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 diff --git a/lib/squib/sample_helpers.rb b/lib/squib/sample_helpers.rb index e76353b..7421307 100644 --- a/lib/squib/sample_helpers.rb +++ b/lib/squib/sample_helpers.rb @@ -1,7 +1,7 @@ module Squib # Some helper methods specifically for samples - #@api private + # @api private #:nodoc: class Deck diff --git a/samples/draw_shapes.rb b/samples/draw_shapes.rb index ddcfbe8..2759eff 100644 --- a/samples/draw_shapes.rb +++ b/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 diff --git a/samples/excel.rb b/samples/excel.rb index 2f67588..9fc9099 100644 --- a/samples/excel.rb +++ b/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 diff --git a/samples/hand.rb b/samples/hand.rb index 45a043e..4897a1f 100644 --- a/samples/hand.rb +++ b/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 diff --git a/samples/load_images.rb b/samples/load_images.rb index eb1a862..078872e 100644 --- a/samples/load_images.rb +++ b/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 diff --git a/samples/ranges.rb b/samples/ranges.rb index 909c2c3..bcbb52d 100644 --- a/samples/ranges.rb +++ b/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| diff --git a/spec/api/api_data_spec.rb b/spec/api/api_data_spec.rb index ba748e7..d42fa98 100644 --- a/spec/api/api_data_spec.rb +++ b/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 diff --git a/spec/args/draw_spec.rb b/spec/args/draw_spec.rb index 1ce33df..d627725 100644 --- a/spec/args/draw_spec.rb +++ b/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 diff --git a/spec/args/typographer_spec.rb b/spec/args/typographer_spec.rb index cf0b268..bd0e7c2 100644 --- a/spec/args/typographer_spec.rb +++ b/spec/args/typographer_spec.rb @@ -63,7 +63,7 @@ it "single quotes inside double quotes" do context 'configured' do - #TODO + # TODO end diff --git a/spec/graphics/graphics_save_doc_spec.rb b/spec/graphics/graphics_save_doc_spec.rb index 7c381a9..bb0f793 100644 --- a/spec/graphics/graphics_save_doc_spec.rb +++ b/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) diff --git a/spec/samples/sanity.rb b/spec/samples/sanity.rb index 9812149..2fc3560 100644 --- a/spec/samples/sanity.rb +++ b/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