lib/renuo/cli/app/toggl_redmine_comparator.rb in renuo-cli-3.1.7 vs lib/renuo/cli/app/toggl_redmine_comparator.rb in renuo-cli-4.2.0

- old
+ new

@@ -1,16 +1,19 @@ +# frozen_string_literal: true + require 'commander' require 'csv' -require_relative './environments' -require_relative './fetch_emails' +require_relative 'environments' +require_relative 'fetch_emails' require 'renuo/cli/app/toggl/workspace' require 'renuo/cli/app/toggl/detail' require 'renuo/cli/app/toggl/user' require 'terminal-table' require 'colorize' require 'active_support/core_ext/numeric/time' +# rubocop:disable Metrics/ClassLength class TogglRedmineComparator class << self def call(days_behind = 7) report = {} since_date = days_behind.days.before(Date.yesterday).strftime('%F') @@ -29,11 +32,11 @@ report.each do |date, value| rows << colorize_table_row(date, value) rows << :separator end rows.pop - table = Terminal::Table.new headings: %w[Day Redmine Toggl].map(&:cyan), rows: rows, + table = Terminal::Table.new headings: %w[Day Redmine Toggl].map(&:cyan), rows:, style: { padding_left: 2, padding_right: 2, border_x: '-'.blue, border_y: '|'.blue, border_i: '+'.blue } puts table end @@ -96,11 +99,11 @@ user_id = Toggl::User.me.id workspace_ids = Toggl::Workspace.all.map(&:id) workspace_ids.each do |workspace_id| time_entries = Toggl::Detail.where(since: since_date, until: until_date, - user_agent: 'renuo-cli', workspace_id: workspace_id, user_ids: user_id) + user_agent: 'renuo-cli', workspace_id:, user_ids: user_id) parse_toggl_entries(report, time_entries) end end def parse_toggl_entries(report, time_entries) @@ -119,11 +122,11 @@ def to_time(value) sec = value / 1000.0 min, _sec = sec.divmod(60.0) hour, min = min.divmod(60.0) - format('%02d:%02d', hour, min) + format('%<hour>02d:%<min>02d', hour:, min:) end def to_seconds(value) hours, minutes = value.to_d.divmod(1.0) (hours * 60 * 60 * 1000) + (minutes * 60 * 60 * 1000) @@ -142,5 +145,6 @@ def more_redmine?(value) (value[:redmine] - value[:toggl]) > BUFFER end end end +# rubocop:enable Metrics/ClassLength