From 4178682aa0f7ee00bab9b47ad7c0fb30b145a014 Mon Sep 17 00:00:00 2001 From: Vitaliy Kudryk Date: Sat, 2 Nov 2024 14:04:13 +0200 Subject: [PATCH] rubocop -A --- .../adapters/config_operator.rb | 12 +++++------ .../adapters/typst_compiler.rb | 2 +- .../adapters/typst_indexer.rb | 2 +- .../high_level/initialize_html_indexer.rb | 4 +++- .../high_level/initialize_indexer.rb | 2 ++ lib/latex_yearly_planner/planners/page.rb | 1 - .../planners/typst_mos/pages/daily_reflect.rb | 3 ++- .../planners/typst_mos/pages/face.rb | 21 +++++++++---------- .../calendar/month_spec.rb | 8 +++++-- 9 files changed, 31 insertions(+), 24 deletions(-) diff --git a/lib/latex_yearly_planner/adapters/config_operator.rb b/lib/latex_yearly_planner/adapters/config_operator.rb index 007ab2ac..a4eff400 100644 --- a/lib/latex_yearly_planner/adapters/config_operator.rb +++ b/lib/latex_yearly_planner/adapters/config_operator.rb @@ -31,11 +31,11 @@ def quarters end def weeks - @all_weeks ||= start_date.beginning_of_week(weekday_start) - .upto(end_date.end_of_month.end_of_week(weekday_start)) - .each_slice(7) - .map { |days| days.map { |day| Calendar::Day.new(moment: day, weekday_start:) } } - .map { |days| Calendar::Week.new(days:, weekday_start:) } + @weeks ||= start_date.beginning_of_week(weekday_start) + .upto(end_date.end_of_month.end_of_week(weekday_start)) + .each_slice(7) + .map { |days| days.map { |day| Calendar::Day.new(moment: day, weekday_start:) } } + .map { |days| Calendar::Week.new(days:, weekday_start:) } end def days @@ -49,7 +49,7 @@ def section_enabled?(section_name) def section!(section_name) @section ||= planner_config.sections.find { |s| s.name == section_name } - raise DevelopmentError, "Section #{section_name} not found" if @section == nil + raise DevelopmentError, "Section #{section_name} not found" if @section.nil? @section end diff --git a/lib/latex_yearly_planner/adapters/typst_compiler.rb b/lib/latex_yearly_planner/adapters/typst_compiler.rb index 4aa4517a..5ed37505 100644 --- a/lib/latex_yearly_planner/adapters/typst_compiler.rb +++ b/lib/latex_yearly_planner/adapters/typst_compiler.rb @@ -16,7 +16,7 @@ def initialize(workdir:, planner_config:) end def compile(text_document) - puts "Compiling generated document with Typst..." + puts 'Compiling generated document with Typst...' typst_compile_time = Benchmark.measure do `typst compile #{workdir}/#{text_document.name} #{workdir}/#{OUTPUT_FILE}` end diff --git a/lib/latex_yearly_planner/adapters/typst_indexer.rb b/lib/latex_yearly_planner/adapters/typst_indexer.rb index 604809b7..b7fca1f9 100644 --- a/lib/latex_yearly_planner/adapters/typst_indexer.rb +++ b/lib/latex_yearly_planner/adapters/typst_indexer.rb @@ -13,7 +13,7 @@ def initialize(planner_config:, i18n: I18n) end # `binding` uses the current scope to get the variables - #noinspection RubyUnusedLocalVariable + # noinspection RubyUnusedLocalVariable def index(text_documents) content = template.result(binding) [Entities::TextDocument.new(name: 'index.typ', content:)] diff --git a/lib/latex_yearly_planner/high_level/initialize_html_indexer.rb b/lib/latex_yearly_planner/high_level/initialize_html_indexer.rb index 3afd82cf..0953ea2a 100644 --- a/lib/latex_yearly_planner/high_level/initialize_html_indexer.rb +++ b/lib/latex_yearly_planner/high_level/initialize_html_indexer.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module LatexYearlyPlanner module HighLevel class InitializeHtmlIndexer @@ -16,4 +18,4 @@ def planner_config end end end -end \ No newline at end of file +end diff --git a/lib/latex_yearly_planner/high_level/initialize_indexer.rb b/lib/latex_yearly_planner/high_level/initialize_indexer.rb index f6bb28d9..0300625a 100644 --- a/lib/latex_yearly_planner/high_level/initialize_indexer.rb +++ b/lib/latex_yearly_planner/high_level/initialize_indexer.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module LatexYearlyPlanner module HighLevel class InitializeIndexer diff --git a/lib/latex_yearly_planner/planners/page.rb b/lib/latex_yearly_planner/planners/page.rb index f3a24f5c..15c0f58d 100644 --- a/lib/latex_yearly_planner/planners/page.rb +++ b/lib/latex_yearly_planner/planners/page.rb @@ -3,7 +3,6 @@ module LatexYearlyPlanner module Planners class Page < Base - def initialize(section_config:, i18n: I18n) super(section_config:, i18n:) end diff --git a/lib/latex_yearly_planner/planners/typst_mos/pages/daily_reflect.rb b/lib/latex_yearly_planner/planners/typst_mos/pages/daily_reflect.rb index 8a98964a..bc58d9f5 100644 --- a/lib/latex_yearly_planner/planners/typst_mos/pages/daily_reflect.rb +++ b/lib/latex_yearly_planner/planners/typst_mos/pages/daily_reflect.rb @@ -70,7 +70,8 @@ def my_goals end def my_best_thing - "jot(#{params.get(:pattern)}, #{params.get(:my_best_thing, :height)}, [#{i18n.t('daily_reflect.best_thing')}])" + "jot(#{params.get(:pattern)}, #{params.get(:my_best_thing, + :height)}, [#{i18n.t('daily_reflect.best_thing')}])" end def my_grateful diff --git a/lib/latex_yearly_planner/planners/typst_mos/pages/face.rb b/lib/latex_yearly_planner/planners/typst_mos/pages/face.rb index a03abd71..7d65b86d 100644 --- a/lib/latex_yearly_planner/planners/typst_mos/pages/face.rb +++ b/lib/latex_yearly_planner/planners/typst_mos/pages/face.rb @@ -122,8 +122,8 @@ def to_typst def side_menu_columns cols = ([mosnav[:quarter_width]] * params.quarters.size) - .append('auto') - .append([mosnav[:month_width]] * params.months.size) + .append('auto') + .append([mosnav[:month_width]] * params.months.size) cols.reverse! if mosnav[:reverse_arrays] @@ -228,14 +228,14 @@ def menu_items_layout def menu_items_content @menu_items_content ||= if heading[:put_extra_items] == 'left' - extra_menu_items - .push(annual_menu_item, todo_menu_item, note_menu_item) - .compact - else - [annual_menu_item, todo_menu_item, note_menu_item] - .concat(extra_menu_items) - .compact - end + extra_menu_items + .push(annual_menu_item, todo_menu_item, note_menu_item) + .compact + else + [annual_menu_item, todo_menu_item, note_menu_item] + .concat(extra_menu_items) + .compact + end end def annual_menu_item @@ -258,7 +258,6 @@ def annual_page_number(first_month) (annual_params.months.find_index(first_month) / months_per_page) + 1 end - def todo_menu_item return nil unless params.section_enabled?(:todo_index) return nil if hide_todo? diff --git a/spec/latex_yearly_planner/calendar/month_spec.rb b/spec/latex_yearly_planner/calendar/month_spec.rb index b8462f6c..fd6d246e 100644 --- a/spec/latex_yearly_planner/calendar/month_spec.rb +++ b/spec/latex_yearly_planner/calendar/month_spec.rb @@ -17,11 +17,15 @@ describe '#weeks' do let :weeks do [ - Week.new(days: [nil, nil, nil, nil] + (1..3).map { |day| Day.new(weekday_start:, moment: date.next_day(day)) }, weekday_start:), + Week.new(days: [nil, nil, nil, nil] + (1..3).map do |day| + Day.new(weekday_start:, moment: date.next_day(day)) + end, weekday_start:), Week.new(days: (4..10).map { |day| Day.new(weekday_start:, moment: date.next_day(day)) }, weekday_start:), Week.new(days: (11..17).map { |day| Day.new(weekday_start:, moment: date.next_day(day)) }, weekday_start:), Week.new(days: (18..24).map { |day| Day.new(weekday_start:, moment: date.next_day(day)) }, weekday_start:), - Week.new(days: (25..30).map { |day| Day.new(weekday_start:, moment: date.next_day(day)) } + [nil], weekday_start:) + Week.new(days: (25..30).map { |day| + Day.new(weekday_start:, moment: date.next_day(day)) + } + [nil], weekday_start:) ] end