Skip to content

Commit

Permalink
Merge pull request #881 from prawnpdf/space-around-assignment
Browse files Browse the repository at this point in the history
Enforce space around argument default value assignments.
  • Loading branch information
packetmonkey committed May 31, 2015
2 parents 7094553 + 22ce682 commit 1ad016c
Show file tree
Hide file tree
Showing 26 changed files with 59 additions and 61 deletions.
2 changes: 0 additions & 2 deletions .rubocop.yml
Expand Up @@ -85,8 +85,6 @@ SpaceBeforeBlockBraces:
Enabled: false
SpaceInsideBrackets:
Enabled: false
SpaceAroundEqualsInParameterDefault:
Enabled: false
FormatString:
Enabled: false
SpaceInsideBlockBraces:
Expand Down
2 changes: 1 addition & 1 deletion bench/table_bench.rb
Expand Up @@ -17,7 +17,7 @@ def data_for_table(columns,rows,string_size)
rows.times.collect { columns.times.collect { String.random(string_size) }}
end

def benchmark_table_generation(columns,rows,string_size,options={})
def benchmark_table_generation(columns,rows,string_size,options = {})
data = data_for_table(columns,rows,string_size)
Benchmark.bm do |x|
x.report("#{columns}x#{rows} table (#{columns * rows} cells, with #{string_size} char string contents#{", options = #{options.inspect}" unless options.empty?})") do
Expand Down
6 changes: 3 additions & 3 deletions lib/prawn/document.rb
Expand Up @@ -137,7 +137,7 @@ def self.inherited(base)
# pdf.draw_text content, :at => [200,720], :size => 32
# end
#
def self.generate(filename,options={},&block)
def self.generate(filename,options = {},&block)
pdf = new(options,&block)
pdf.render_file(filename)
end
Expand Down Expand Up @@ -188,7 +188,7 @@ def self.generate(filename,options={},&block)
# # New document, with background
# pdf = Prawn::Document.new(:background => "#{Prawn::DATADIR}/images/pigs.jpg")
#
def initialize(options={},&block)
def initialize(options = {},&block)
options = options.dup

Prawn.verify_options VALID_OPTIONS, options
Expand Down Expand Up @@ -520,7 +520,7 @@ def indent(left, right = 0, &block)
# :size => 14}
# end
#
def number_pages(string, options={})
def number_pages(string, options = {})
opts = options.dup
start_count_at = opts.delete(:start_count_at).to_i

Expand Down
4 changes: 2 additions & 2 deletions lib/prawn/document/bounding_box.rb
Expand Up @@ -182,7 +182,7 @@ def canvas(&block)

private

def init_bounding_box(user_block, options={}, &init_block)
def init_bounding_box(user_block, options = {}, &init_block)
unless user_block
raise ArgumentError,
"bounding boxes require a block to be drawn within the box"
Expand Down Expand Up @@ -220,7 +220,7 @@ def init_bounding_box(user_block, options={}, &init_block)
# is used for.
#
class BoundingBox
def initialize(document, parent, point, options={}) # @private
def initialize(document, parent, point, options = {}) # @private
unless options[:width]
raise ArgumentError, "BoundingBox needs the :width option to be set"
end
Expand Down
4 changes: 2 additions & 2 deletions lib/prawn/document/column_box.rb
Expand Up @@ -36,7 +36,7 @@ def column_box(*args, &block)

private

def init_column_box(user_block, options={}, &init_block)
def init_column_box(user_block, options = {}, &init_block)
parent_box = @bounding_box

init_block.call(parent_box)
Expand All @@ -52,7 +52,7 @@ def init_column_box(user_block, options={}, &init_block)
# work.
#
class ColumnBox < BoundingBox
def initialize(document, parent, point, options={}) #:nodoc:
def initialize(document, parent, point, options = {}) #:nodoc:
super
@columns = options[:columns] || 3
@spacer = options[:spacer] || @document.font_size
Expand Down
2 changes: 1 addition & 1 deletion lib/prawn/document/span.rb
Expand Up @@ -26,7 +26,7 @@ class Document
# text "Here's some centered text in a 350 point column. " * 100
# end
#
def span(width, options={})
def span(width, options = {})
Prawn.verify_options [:position], options
original_position = self.y

Expand Down
18 changes: 9 additions & 9 deletions lib/prawn/font.rb
Expand Up @@ -47,7 +47,7 @@ class Document
# the :style option you need to map those font styles to their respective font files.
# See font_families for more information.
#
def font(name=nil, options={})
def font(name = nil, options = {})
return((defined?(@font) && @font) || font("Helvetica")) if name.nil?

if state.pages.empty? && !state.page.in_stamp_stream?
Expand Down Expand Up @@ -94,7 +94,7 @@ def font(name=nil, options={})
# When called without an argument, this method returns the current font
# size.
#
def font_size(points=nil)
def font_size(points = nil)
return @font_size unless points
size_before_yield = @font_size
@font_size = points
Expand Down Expand Up @@ -126,7 +126,7 @@ def font_size=(size)
# By putting width_of here, on Document itself, extensions may easily override
# it and redefine the width calculation behavior.
#++
def width_of(string, options={})
def width_of(string, options = {})
if p = options[:inline_format]
p = [] unless p.is_a?(Array)

Expand Down Expand Up @@ -191,7 +191,7 @@ def font_families
# Sets the font directly, given an actual Font object
# and size.
#
def set_font(font, size=nil) # :nodoc:
def set_font(font, size = nil) # :nodoc:
@font = font
@font_size = size if size
end
Expand Down Expand Up @@ -227,7 +227,7 @@ def save_font
# ++
#
# @private
def find_font(name, options={}) #:nodoc:
def find_font(name, options = {}) #:nodoc:
if font_families.key?(name)
family, name = name, font_families[name][options[:style] || :normal]
if name.is_a?(::Hash)
Expand All @@ -252,7 +252,7 @@ def font_registry #:nodoc:

private

def width_of_inline_formatted_string(string, options={})
def width_of_inline_formatted_string(string, options = {})
# Build up an Arranger with the entire string on one line, finalize it,
# and find its width.
arranger = Prawn::Text::Formatted::Arranger.new(self, options)
Expand All @@ -262,7 +262,7 @@ def width_of_inline_formatted_string(string, options={})
arranger.line_width
end

def width_of_string(string, options={})
def width_of_string(string, options = {})
font_metric_cache.width_of(string, options)
end
end
Expand All @@ -282,7 +282,7 @@ class Font
# Shortcut interface for constructing a font object. Filenames of the form
# *.ttf will call Font::TTF.new, *.dfont Font::DFont.new, and anything else
# will be passed through to Font::AFM.new()
def self.load(document, src, options={})
def self.load(document, src, options = {})
case font_format(src, options)
when 'ttf' then TTF.new(document, src, options)
when 'dfont' then DFont.new(document, src, options)
Expand All @@ -300,7 +300,7 @@ def self.font_format(src, options)
end
end

def initialize(document,name,options={}) #:nodoc:
def initialize(document,name,options = {}) #:nodoc:
@document = document
@name = name
@options = options
Expand Down
6 changes: 3 additions & 3 deletions lib/prawn/font/afm.rb
Expand Up @@ -43,7 +43,7 @@ def self.metrics_path

attr_reader :attributes #:nodoc:

def initialize(document, name, options={}) #:nodoc:
def initialize(document, name, options = {}) #:nodoc:
unless BUILT_INS.include?(name)
raise Prawn::Errors::UnknownFont, "#{name} is not a known font."
end
Expand Down Expand Up @@ -76,7 +76,7 @@ def bbox
end

# NOTE: String *must* be encoded as WinAnsi
def compute_width_of(string, options={}) #:nodoc:
def compute_width_of(string, options = {}) #:nodoc:
scale = (options[:size] || size) / 1000.0

if options[:kerning]
Expand Down Expand Up @@ -130,7 +130,7 @@ def character_count(str)
#
# The +text+ parameter must be in WinAnsi encoding (cp1252).
#
def encode_text(text, options={})
def encode_text(text, options = {})
[[0, options[:kerning] ? kern(text) : text]]
end

Expand Down
6 changes: 3 additions & 3 deletions lib/prawn/font/ttf.rb
Expand Up @@ -20,7 +20,7 @@ def unicode?
true
end

def initialize(document, name, options={})
def initialize(document, name, options = {})
super

@ttf = read_ttf_file
Expand All @@ -37,7 +37,7 @@ def initialize(document, name, options={})
end

# NOTE: +string+ must be UTF8-encoded.
def compute_width_of(string, options={}) #:nodoc:
def compute_width_of(string, options = {}) #:nodoc:
scale = (options[:size] || size) / 1000.0
if options[:kerning]
kern(string).inject(0) do |s,r|
Expand Down Expand Up @@ -73,7 +73,7 @@ def has_kerning_data?
#
# The +text+ parameter must be UTF8-encoded.
#
def encode_text(text,options={})
def encode_text(text,options = {})
text = text.chomp

if options[:kerning]
Expand Down
12 changes: 6 additions & 6 deletions lib/prawn/graphics.rb
Expand Up @@ -63,7 +63,7 @@ def line_to(*point)
#
# pdf.curve_to [100,100], :bounds => [[90,90],[75,75]]
#
def curve_to(dest,options={})
def curve_to(dest,options = {})
options[:bounds] or raise Prawn::Errors::InvalidGraphicsPath,
"Bounding points for bezier curve must be specified " \
"as :bounds => [[x1,y1],[x2,y2]]"
Expand Down Expand Up @@ -117,7 +117,7 @@ def line_width=(width)
# pdf.line_width(5)
# pdf.line_width #=> 5
#
def line_width(width=nil)
def line_width(width = nil)
if width
self.line_width = width
else
Expand All @@ -143,7 +143,7 @@ def line(*points)
# # draw a line from [25, 75] to [100, 75]
# horizontal_line 25, 100, :at => 75
#
def horizontal_line(x1,x2,options={})
def horizontal_line(x1,x2,options = {})
if options[:at]
y1 = options[:at]
else
Expand Down Expand Up @@ -174,7 +174,7 @@ def vertical_line(y1,y2,params)
#
# pdf.curve [50,100], [100,100], :bounds => [[90,90],[75,75]]
#
def curve(origin,dest, options={})
def curve(origin,dest, options = {})
move_to(*origin)
curve_to(dest,options)
end
Expand Down Expand Up @@ -361,7 +361,7 @@ def stroke_axis(options = {})
# will be used. See the PDF reference, "Graphics -> Path Construction and
# Painting -> Clipping Path Operators" for details on the difference.
#
def fill(options={})
def fill(options = {})
yield if block_given?
renderer.add_content(options[:fill_rule] == :even_odd ? "f*" : "f")
end
Expand All @@ -375,7 +375,7 @@ def fill(options={})
# will be used. See the PDF reference, "Graphics -> Path Construction and
# Painting -> Clipping Path Operators" for details on the difference.
#
def fill_and_stroke(options={})
def fill_and_stroke(options = {})
yield if block_given?
renderer.add_content(options[:fill_rule] == :even_odd ? "b*" : "b")
end
Expand Down
2 changes: 1 addition & 1 deletion lib/prawn/graphics/cap_style.rb
Expand Up @@ -19,7 +19,7 @@ module CapStyle
#
# NOTE: If this method is never called, :butt will be used by default.
#
def cap_style(style=nil)
def cap_style(style = nil)
return current_cap_style || :butt if style.nil?

self.current_cap_style = style
Expand Down
2 changes: 1 addition & 1 deletion lib/prawn/graphics/dash.rb
Expand Up @@ -52,7 +52,7 @@ module Dash
# Integers or Floats may be used for length and the option values.
# Dash units are in PDF points (1/72 inch).
#
def dash(length=nil, options={})
def dash(length = nil, options = {})
return current_dash_state if length.nil?

if length == 0 || length.kind_of?(Array) && length.any? { |e| e == 0 }
Expand Down
2 changes: 1 addition & 1 deletion lib/prawn/graphics/join_style.rb
Expand Up @@ -20,7 +20,7 @@ module JoinStyle
# NOTE: if this method is never called, :miter will be used for join style
# throughout the document
#
def join_style(style=nil)
def join_style(style = nil)
return current_join_style || :miter if style.nil?

self.current_join_style = style
Expand Down
4 changes: 2 additions & 2 deletions lib/prawn/graphics/transformation.rb
Expand Up @@ -40,7 +40,7 @@ module Transformation
# pdf.stroke_rectangle([x, y], width, height)
# end
#
def rotate(angle, options={}, &block)
def rotate(angle, options = {}, &block)
Prawn.verify_options(:origin, options)
rad = degree_to_rad(angle)
cos = Math.cos(rad)
Expand Down Expand Up @@ -112,7 +112,7 @@ def translate(x, y, &block)
# pdf.stroke_rectangle([x, y], width, height)
# end
#
def scale(factor, options={}, &block)
def scale(factor, options = {}, &block)
Prawn.verify_options(:origin, options)
if options[:origin].nil?
transformation_matrix(factor, 0, 0, factor, 0, 0, &block)
Expand Down
2 changes: 1 addition & 1 deletion lib/prawn/graphics/transparency.rb
Expand Up @@ -51,7 +51,7 @@ module Transparency
# pdf.fill_and_stroke_circle([x, y], 25)
# end
#
def transparent(opacity, stroke_opacity=opacity, &block)
def transparent(opacity, stroke_opacity = opacity, &block)
renderer.min_version(1.4)

opacity = [[opacity, 0.0].max, 1.0].min
Expand Down
2 changes: 1 addition & 1 deletion lib/prawn/images.rb
Expand Up @@ -59,7 +59,7 @@ module Images
# dimensions of an image object if needed.
# (See also: Prawn::Images::PNG , Prawn::Images::JPG)
#
def image(file, options={})
def image(file, options = {})
Prawn.verify_options [:at, :position, :vposition, :height,
:width, :scale, :fit], options

Expand Down
2 changes: 1 addition & 1 deletion lib/prawn/repeater.rb
Expand Up @@ -74,7 +74,7 @@ def repeaters
#
# end
#
def repeat(page_filter, options={}, &block)
def repeat(page_filter, options = {}, &block)
repeaters << Prawn::Repeater.new(self, page_filter, !!options[:dynamic], &block)
end
end
Expand Down
6 changes: 3 additions & 3 deletions lib/prawn/security.rb
Expand Up @@ -87,7 +87,7 @@ module Security
# not a limitation of Prawn, but is rather a built-in limitation of the
# PDF format.
#
def encrypt_document(options={})
def encrypt_document(options = {})
Prawn.verify_options [:user_password, :owner_password, :permissions],
options
@user_password = options.delete(:user_password) || ""
Expand Down Expand Up @@ -140,7 +140,7 @@ def encryption_dictionary

FullPermissions = 0b1111_1111_1111_1111_1111_1111_1111_1111

def permissions=(perms={})
def permissions=(perms = {})
@permissions ||= FullPermissions
perms.each do |key, value|
unless PermissionsBits[key]
Expand Down Expand Up @@ -209,7 +209,7 @@ module Core
# from the indirect object referencing obj.
#
# @private
def EncryptedPdfObject(obj, key, id, gen, in_content_stream=false)
def EncryptedPdfObject(obj, key, id, gen, in_content_stream = false)
case obj
when Array
"[" << obj.map { |e|
Expand Down

0 comments on commit 1ad016c

Please sign in to comment.