Skip to content

Commit

Permalink
update rubocop, make rubocop happy
Browse files Browse the repository at this point in the history
  • Loading branch information
mitosch committed Sep 11, 2024
1 parent 62cf8a0 commit 2ce2a31
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 13 deletions.
6 changes: 5 additions & 1 deletion .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ require:
AllCops:
TargetRubyVersion: 2.5
NewCops: enable
Exclude:
- prawn-swiss_qr_bill.gemspec

# Prawn is descriptive and needs more branches (methods)
Metrics/AbcSize:
Expand All @@ -21,9 +23,11 @@ RSpec/ExampleLength:

# Unlimited block length for specs
Metrics/BlockLength:
IgnoredMethods: ['describe']
AllowedMethods: ['describe']

Lint/AmbiguousBlockAssociation:
Exclude:
- 'spec/**/*'

RSpec/NoExpectationExample:
Enabled: false
14 changes: 7 additions & 7 deletions lib/prawn/swiss_qr_bill/qr/data.rb
Original file line number Diff line number Diff line change
Expand Up @@ -76,12 +76,12 @@ def initialize(fields = {}, options = {})

# set defaults
FIELDS.each_key do |field|
instance_variable_set("@#{field}", FIELDS[field].default)
instance_variable_set(:"@#{field}", FIELDS[field].default)
end

# set given
fields.each_key do |field|
instance_variable_set("@#{field}", fields[field])
instance_variable_set(:"@#{field}", fields[field])
end
end

Expand All @@ -90,7 +90,7 @@ def generate

stack = []
FIELDS.each_key do |k|
var = instance_variable_get("@#{k}")
var = instance_variable_get(:"@#{k}")

# TODO: fix possible wrong format if alt parameters (last one) is given
next if FIELDS[k][:skippable] && var.nil?
Expand All @@ -105,17 +105,17 @@ def generate

def process
FIELDS.each_key do |k|
var = instance_variable_get("@#{k}")
var = instance_variable_get(:"@#{k}")

instance_variable_set("@#{k}", FIELDS[k][:format].call(var)) if FIELDS[k][:format].is_a?(Proc)
instance_variable_set(:"@#{k}", FIELDS[k][:format].call(var)) if FIELDS[k][:format].is_a?(Proc)
end
end

def validate
FIELDS.each_key do |k|
next unless FIELDS[k][:validation]

var = instance_variable_get("@#{k}")
var = instance_variable_get(:"@#{k}")

call_validator(FIELDS[k][:validation], var)
end
Expand All @@ -133,7 +133,7 @@ def call_validator(validator, value)
validator.call(value)
# :nocov:
when Symbol
send("#{validator}_validator", value)
send(:"#{validator}_validator", value)
end
end

Expand Down
4 changes: 2 additions & 2 deletions lib/prawn/swiss_qr_bill/specifications.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ class Specifications
height: Spec.new(nil, ->(v) { from_mm(v) }),
content_font_size: Spec.new,
content_font_leading: Spec.new(0),
content_font_style: Spec.new(:normal, ->(v) { v.to_sym }),
content_font_style: Spec.new(:normal, lambda(&:to_sym)),
label_font_size: Spec.new,
label_font_leading: Spec.new(0),
label_font_style: Spec.new(:bold, ->(v) { v.to_sym })
label_font_style: Spec.new(:bold, lambda(&:to_sym))
}.freeze

def initialize
Expand Down
2 changes: 1 addition & 1 deletion spec/features/compatibility_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

describe '#swiss_qr_bill' do
context 'when one argument is given' do
it 'works' do
it 'works without arguments' do
document.swiss_qr_bill(bill_full)
end
end
Expand Down
2 changes: 1 addition & 1 deletion spec/features/pdf_generation_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
end

before do
FileUtils.rm(outfile) if File.exist?(outfile)
FileUtils.rm_f(outfile)
end

after do |spec|
Expand Down
2 changes: 1 addition & 1 deletion spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,4 @@
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].sort.each { |f| require f }

# Ensure tmp dir
FileUtils.mkdir(TMP_DIR) unless Dir.exist?(TMP_DIR)
FileUtils.mkdir_p(TMP_DIR)

0 comments on commit 2ce2a31

Please sign in to comment.