diff --git a/.rubocop.yml b/.rubocop.yml index fe81d71..2f54469 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -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: @@ -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 diff --git a/Gemfile.lock b/Gemfile.lock index 40fd8fd..d72e6e6 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -10,9 +10,10 @@ PATH GEM remote: http://rubygems.org/ specs: - Ascii85 (1.1.0) + Ascii85 (1.1.1) afm (0.2.2) ast (2.4.2) + bigdecimal (3.1.8) chunky_png (1.4.0) concurrent-ruby (1.3.4) diff-lcs (1.5.0) @@ -20,20 +21,25 @@ GEM hashery (2.1.2) i18n (1.14.5) concurrent-ruby (~> 1.0) + json (2.7.2) + language_server-protocol (3.17.0.3) matrix (0.4.2) - parallel (1.21.0) - parser (3.1.0.0) + parallel (1.26.3) + parser (3.3.5.0) ast (~> 2.4.1) - pdf-core (0.9.0) - pdf-reader (2.9.1) + racc + pdf-core (0.10.0) + pdf-reader (2.12.0) Ascii85 (~> 1.0) afm (~> 0.2.1) hashery (~> 2.0) ruby-rc4 ttfunk - prawn (2.4.0) - pdf-core (~> 0.9.0) - ttfunk (~> 1.7) + prawn (2.5.0) + matrix (~> 0.4) + pdf-core (~> 0.10.0) + ttfunk (~> 1.8) + racc (1.8.1) rainbow (3.1.1) regexp_parser (2.2.0) rexml (3.2.5) @@ -41,48 +47,61 @@ GEM chunky_png (~> 1.0) rqrcode_core (~> 1.0) rqrcode_core (1.2.0) - rspec (3.11.0) - rspec-core (~> 3.11.0) - rspec-expectations (~> 3.11.0) - rspec-mocks (~> 3.11.0) - rspec-core (3.11.0) - rspec-support (~> 3.11.0) - rspec-expectations (3.11.0) + rspec (3.13.0) + rspec-core (~> 3.13.0) + rspec-expectations (~> 3.13.0) + rspec-mocks (~> 3.13.0) + rspec-core (3.13.1) + rspec-support (~> 3.13.0) + rspec-expectations (3.13.3) diff-lcs (>= 1.2.0, < 2.0) - rspec-support (~> 3.11.0) - rspec-mocks (3.11.0) + rspec-support (~> 3.13.0) + rspec-mocks (3.13.1) diff-lcs (>= 1.2.0, < 2.0) - rspec-support (~> 3.11.0) - rspec-support (3.11.0) - rubocop (1.25.1) + rspec-support (~> 3.13.0) + rspec-support (3.13.1) + rubocop (1.66.1) + json (~> 2.3) + language_server-protocol (>= 3.17.0) parallel (~> 1.10) - parser (>= 3.1.0.0) + parser (>= 3.3.0.2) rainbow (>= 2.2.2, < 4.0) - regexp_parser (>= 1.8, < 3.0) - rexml - rubocop-ast (>= 1.15.1, < 2.0) + regexp_parser (>= 2.4, < 3.0) + rubocop-ast (>= 1.32.2, < 2.0) ruby-progressbar (~> 1.7) - unicode-display_width (>= 1.4.0, < 3.0) - rubocop-ast (1.15.1) - parser (>= 3.0.1.1) - rubocop-performance (1.13.2) - rubocop (>= 1.7.0, < 2.0) - rubocop-ast (>= 0.4.0) - rubocop-rspec (2.8.0) - rubocop (~> 1.19) - ruby-progressbar (1.11.0) + unicode-display_width (>= 2.4.0, < 3.0) + rubocop-ast (1.32.3) + parser (>= 3.3.1.0) + rubocop-capybara (2.21.0) + rubocop (~> 1.41) + rubocop-factory_bot (2.26.1) + rubocop (~> 1.61) + rubocop-performance (1.21.1) + rubocop (>= 1.48.1, < 2.0) + rubocop-ast (>= 1.31.1, < 2.0) + rubocop-rake (0.6.0) + rubocop (~> 1.0) + rubocop-rspec (2.31.0) + rubocop (~> 1.40) + rubocop-capybara (~> 2.17) + rubocop-factory_bot (~> 2.22) + rubocop-rspec_rails (~> 2.28) + rubocop-rspec_rails (2.29.1) + rubocop (~> 1.61) + ruby-progressbar (1.13.0) ruby-rc4 (0.1.5) - simplecov (0.21.2) + simplecov (0.22.0) docile (~> 1.1) simplecov-html (~> 0.11) simplecov_json_formatter (~> 0.1) simplecov-cobertura (2.1.0) rexml simplecov (~> 0.19) - simplecov-html (0.12.3) - simplecov_json_formatter (0.1.3) - ttfunk (1.7.0) - unicode-display_width (2.1.0) + simplecov-html (0.13.1) + simplecov_json_formatter (0.1.4) + ttfunk (1.8.0) + bigdecimal (~> 3.1) + unicode-display_width (2.5.0) PLATFORMS x86_64-linux @@ -93,9 +112,10 @@ DEPENDENCIES rspec (~> 3.0) rubocop (~> 1.0) rubocop-performance (~> 1.5) + rubocop-rake (~> 0.6.0) rubocop-rspec (~> 2.8) simplecov (~> 0.16) simplecov-cobertura (~> 2.0) BUNDLED WITH - 2.3.7 + 2.4.19 diff --git a/lib/prawn/swiss_qr_bill/qr/data.rb b/lib/prawn/swiss_qr_bill/qr/data.rb index 565dc76..3dba47e 100644 --- a/lib/prawn/swiss_qr_bill/qr/data.rb +++ b/lib/prawn/swiss_qr_bill/qr/data.rb @@ -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 @@ -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? @@ -105,9 +105,9 @@ 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 @@ -115,7 +115,7 @@ 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 @@ -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 diff --git a/lib/prawn/swiss_qr_bill/specifications.rb b/lib/prawn/swiss_qr_bill/specifications.rb index 6cdb4d8..b6537e5 100644 --- a/lib/prawn/swiss_qr_bill/specifications.rb +++ b/lib/prawn/swiss_qr_bill/specifications.rb @@ -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 diff --git a/prawn-swiss_qr_bill.gemspec b/prawn-swiss_qr_bill.gemspec index af59b77..fbf612b 100644 --- a/prawn-swiss_qr_bill.gemspec +++ b/prawn-swiss_qr_bill.gemspec @@ -32,6 +32,7 @@ Gem::Specification.new do |spec| spec.add_development_dependency 'rubocop', '~> 1.0' spec.add_development_dependency 'rubocop-performance', '~> 1.5' spec.add_development_dependency 'rubocop-rspec', '~> 2.8' + spec.add_development_dependency 'rubocop-rake', '~> 0.6.0' spec.add_development_dependency 'simplecov', '~> 0.16' spec.add_development_dependency 'simplecov-cobertura', '~> 2.0' diff --git a/spec/features/compatibility_spec.rb b/spec/features/compatibility_spec.rb index 3d3851e..c31bee1 100644 --- a/spec/features/compatibility_spec.rb +++ b/spec/features/compatibility_spec.rb @@ -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 diff --git a/spec/features/pdf_generation_spec.rb b/spec/features/pdf_generation_spec.rb index ffeb60e..61df30a 100644 --- a/spec/features/pdf_generation_spec.rb +++ b/spec/features/pdf_generation_spec.rb @@ -11,7 +11,7 @@ end before do - FileUtils.rm(outfile) if File.exist?(outfile) + FileUtils.rm_f(outfile) end after do |spec| diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 928585e..0b73469 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -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)