lib/balboa/cli/command/punch_command.rb in balboa-0.1.6 vs lib/balboa/cli/command/punch_command.rb in balboa-0.1.7

- old
+ new

@@ -12,31 +12,38 @@ end def execute punch_dates.reject! { |date| skip_date?(date) } - punch_dates.each do |date| - $stdout.print("\n#{date.strftime('%d/%m/%Y')}") - @interactor.punch(date) - end + punch_dates.each { |date| @interactor.punch(date) } + + command_output end private def punch_dates - yesterday = Date.today - 1 - - (last_punch_date..yesterday).map do |date| - PunchDate.new(date, @cli) + @punch_dates ||= (last_punch_date..(Date.today - 1)).map do |date| + Balboa::PunchDate.new(date, @cli) end end - def skip_date?(date) - !date.punchable? || skips_include?(date) + def command_output + punch_dates.map do |date| + "\n#{date.strftime('%d/%m/%Y')}" + end.join end - def skips_include?(date) - @interactor.options['skips'].include?(date) + def skip_date?(punch_date) + !punch_date.punchable? || skips_include?(punch_date) + end + + def skips_include?(punch_date) + skipped_dates.include?(punch_date.to_date) + end + + def skipped_dates + @interactor.options['skips'] end def last_punch_date Date.parse(@interactor.last) + 1 end