From b1e9dffbc63cbe808e3d98fadb78807935a182ac Mon Sep 17 00:00:00 2001 From: Colin Darie Date: Wed, 31 Aug 2022 11:23:25 +0200 Subject: [PATCH] chore(rubocop): enable on .prawn files --- .rubocop.yml | 6 +++++ .../attestation_templates/show.pdf.prawn | 10 ++++---- app/views/dossiers/dossier_vide.pdf.prawn | 24 +++++++++---------- app/views/dossiers/show.pdf.prawn | 8 +++---- app/views/users/dossiers/papertrail.pdf.prawn | 3 +-- 5 files changed, 28 insertions(+), 23 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index cd71f4db5..c506574b1 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -6,10 +6,16 @@ require: - ./lib/cops/application_name.rb - ./lib/cops/unscoped.rb +inherit_mode: + merge: + - Include + AllCops: TargetRubyVersion: 3.0 DisabledByDefault: true SuggestExtensions: false + Include: + - "app/**/*.prawn" Exclude: - "db/schema.rb" - "db/migrate/20190730153555_recreate_structure.rb" diff --git a/app/views/administrateurs/attestation_templates/show.pdf.prawn b/app/views/administrateurs/attestation_templates/show.pdf.prawn index cb3e64eae..da58ab65e 100644 --- a/app/views/administrateurs/attestation_templates/show.pdf.prawn +++ b/app/views/administrateurs/attestation_templates/show.pdf.prawn @@ -2,7 +2,7 @@ require 'prawn/measurement_extensions' #----- A4 page size page_size = 'A4' -page_height = 842 +# page_height = 842 page_width = 595 #----- margins @@ -11,7 +11,7 @@ top_margin = 50 bottom_margin = 20 footer_height = top_margin - bottom_margin -right_margin = (page_width - body_width)/2 +right_margin = (page_width - body_width) / 2 left_margin = right_margin #----- size of images @@ -32,7 +32,7 @@ logo = @attestation[:logo] signature = @attestation[:signature] prawn_document(margin: [top_margin, right_margin, bottom_margin, left_margin], page_size: page_size) do |pdf| - pdf.font_families.update( 'marianne' => { normal: Rails.root.join('lib/prawn/fonts/marianne/marianne-regular.ttf' )}) + pdf.font_families.update('marianne' => { normal: Rails.root.join('lib/prawn/fonts/marianne/marianne-regular.ttf') }) pdf.font 'marianne' grey = '555555' @@ -47,7 +47,7 @@ prawn_document(margin: [top_margin, right_margin, bottom_margin, left_margin], p else logo.rewind && logo.read end - pdf.image StringIO.new(logo_content), fit: [max_logo_width , max_logo_height], position: :center + pdf.image StringIO.new(logo_content), fit: [max_logo_width, max_logo_height], position: :center end pdf.fill_color grey @@ -66,7 +66,7 @@ prawn_document(margin: [top_margin, right_margin, bottom_margin, left_margin], p else signature.rewind && signature.read end - pdf.image StringIO.new(signature_content), fit: [max_signature_size , max_signature_size], position: :right + pdf.image StringIO.new(signature_content), fit: [max_signature_size, max_signature_size], position: :right end end end diff --git a/app/views/dossiers/dossier_vide.pdf.prawn b/app/views/dossiers/dossier_vide.pdf.prawn index 3630c5707..caef30168 100644 --- a/app/views/dossiers/dossier_vide.pdf.prawn +++ b/app/views/dossiers/dossier_vide.pdf.prawn @@ -21,8 +21,8 @@ end def format_in_2_lines(pdf, champ, nb_lines = 1) add_single_line(pdf, champ.libelle, 9, :bold) add_optionnal_description(pdf, champ) - height = 10 * (nb_lines+1) - pdf.bounding_box([0, pdf.cursor],:width => 460,:height => height) do + height = 10 * (nb_lines + 1) + pdf.bounding_box([0, pdf.cursor], :width => 460, :height => height) do pdf.stroke_bounds end pdf.text "\n" @@ -30,7 +30,7 @@ end def format_in_2_columns(pdf, label) pdf.text_box label, width: 200, height: 100, overflow: :expand, at: [0, pdf.cursor] - pdf.bounding_box([110, pdf.cursor+5],:width => 350,:height => 20) do + pdf.bounding_box([110, pdf.cursor + 5], :width => 350, :height => 20) do pdf.stroke_bounds end @@ -51,7 +51,7 @@ def format_with_checkbox(pdf, option, offset = 0) render_expanding_text_box(pdf, label, at: [15, pdf.cursor]) if value == Champs::DropDownListChamp::OTHER - pdf.bounding_box([110, pdf.cursor + 3],:width => 350,:height => 20) do + pdf.bounding_box([110, pdf.cursor + 3], :width => 350, :height => 20) do pdf.stroke_bounds end end @@ -64,14 +64,14 @@ def add_page_numbering(pdf) # do not have page numbering string = ' / ' options = { - at: [0, -15], - align: :right + at: [0, -15], + align: :right } pdf.number_pages string, options end def add_procedure(pdf, dossier) - pdf.repeat(lambda {|page| page > 1 }) do + pdf.repeat(lambda { |page| page > 1 }) do pdf.draw_text dossier.procedure.libelle, :at => pdf.bounds.top_left end end @@ -186,7 +186,7 @@ def add_champs(pdf, champs) champs.each do |champ| if champ.type == 'Champs::RepetitionChamp' add_libelle(pdf, champ) - (1..3).each do + 3.times do champ.rows.each do |row| row.each do |inner_champ| render_single_champ(pdf, inner_champ) @@ -200,10 +200,10 @@ def add_champs(pdf, champs) end prawn_document(page_size: "A4") do |pdf| - pdf.font_families.update( 'marianne' => { - normal: Rails.root.join('lib/prawn/fonts/marianne/marianne-regular.ttf' ), - bold: Rails.root.join('lib/prawn/fonts/marianne/marianne-bold.ttf' ), - italic: Rails.root.join('lib/prawn/fonts/marianne/marianne-thin.ttf' ), + pdf.font_families.update('marianne' => { + normal: Rails.root.join('lib/prawn/fonts/marianne/marianne-regular.ttf'), + bold: Rails.root.join('lib/prawn/fonts/marianne/marianne-bold.ttf'), + italic: Rails.root.join('lib/prawn/fonts/marianne/marianne-thin.ttf') }) pdf.font 'marianne' pdf.image DOSSIER_PDF_EXPORT_LOGO_SRC, width: 300, position: :center diff --git a/app/views/dossiers/show.pdf.prawn b/app/views/dossiers/show.pdf.prawn index e93c91f12..d364ec7d3 100644 --- a/app/views/dossiers/show.pdf.prawn +++ b/app/views/dossiers/show.pdf.prawn @@ -29,7 +29,7 @@ def format_in_2_lines(pdf, label, text) maybe_start_new_page(pdf, min_height) pdf.pad_bottom(2) do - pdf.font 'marianne', style: :bold, size: 12 do + pdf.font 'marianne', style: :bold, size: 12 do pdf.text label end end @@ -211,9 +211,9 @@ def add_etats_dossier(pdf, dossier) end prawn_document(page_size: "A4") do |pdf| - pdf.font_families.update( 'marianne' => { - normal: Rails.root.join('lib/prawn/fonts/marianne/marianne-regular.ttf' ), - bold: Rails.root.join('lib/prawn/fonts/marianne/marianne-bold.ttf' ), + pdf.font_families.update('marianne' => { + normal: Rails.root.join('lib/prawn/fonts/marianne/marianne-regular.ttf'), + bold: Rails.root.join('lib/prawn/fonts/marianne/marianne-bold.ttf') }) pdf.font 'marianne' diff --git a/app/views/users/dossiers/papertrail.pdf.prawn b/app/views/users/dossiers/papertrail.pdf.prawn index 593ce3b64..5b2b4976e 100644 --- a/app/views/users/dossiers/papertrail.pdf.prawn +++ b/app/views/users/dossiers/papertrail.pdf.prawn @@ -10,7 +10,6 @@ right_margin = 20 bottom_margin = 20 left_margin = 20 -header_width = page_width - left_margin - right_margin body_width = 400 body_left_margin = (page_width - body_width - left_margin - right_margin) / 2 @@ -66,7 +65,7 @@ prawn_document(margin: [top_margin, right_margin, bottom_margin, left_margin], p pdf.fill_color grey pdf.pad_top(7) do - pdf.text "#{Dossier.human_attribute_name(:id)} : #{@dossier.id.to_s}", size: 10, character_spacing: -0.2, align: :justify + pdf.text "#{Dossier.human_attribute_name(:id)} : #{@dossier.id}", size: 10, character_spacing: -0.2, align: :justify pdf.text t('.file_submitted_at') + ' : ' + l(@dossier.depose_at, format: '%e %B %Y'), size: 10, character_spacing: -0.2, align: :justify pdf.text t('.dossier_state') + ' : ' + papertrail_dossier_state(@dossier), size: 10, character_spacing: -0.2, align: :justify end