Sha256: 8380ba6a3e39b267ec376c2f877fdb817306ab0e472a8cf8ad4072daed5964f9

Contents?: true

Size: 783 Bytes

Versions: 4

Compression:

Stored size: 783 Bytes

Contents

module Dude
  module Gitlab
    class AddSpendTime < Dude::Gitlab::Base
      def call
        if duration_exists?
          add_spend_time
          print_success_message
        else
          print_error_message
        end
      end

      def add_spend_time
        ::Gitlab.add_time_spent_on_issue(
          project_id, options[:issue_id], "#{options[:duration]}s"
        )
      end

      def duration_exists?
        options[:duration] > 0
      end

      def print_success_message
        puts "Added #{formatted_time} to spent time"
      end

      def print_error_message
        puts "Nothing to add".colorize(:yellow)
      end

      def formatted_time
        Time.at(options[:duration]).utc.strftime('%H:%M:%S').to_s.colorize(:green)
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
dude-cli-1.0.2 lib/dude/gitlab/add_spend_time.rb
dude-cli-1.0.1 lib/dude/gitlab/add_spend_time.rb
dude-cli-1.0.0 lib/dude/gitlab/add_spend_time.rb
dude-cli-0.6.2.pre.rc1 lib/dude/gitlab/add_spend_time.rb