tempest_time 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (78) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +10 -0
  3. data/.ruby-version +1 -0
  4. data/.travis.yml +5 -0
  5. data/Gemfile +6 -0
  6. data/Gemfile.lock +133 -0
  7. data/LICENSE +21 -0
  8. data/README.md +8 -0
  9. data/Rakefile +10 -0
  10. data/bin/console +14 -0
  11. data/bin/setup +8 -0
  12. data/bin/tempest +18 -0
  13. data/lib/tempest_time/api/authorization.rb +17 -0
  14. data/lib/tempest_time/api/jira_api/authorization.rb +27 -0
  15. data/lib/tempest_time/api/jira_api/models/issue.rb +28 -0
  16. data/lib/tempest_time/api/jira_api/request.rb +40 -0
  17. data/lib/tempest_time/api/jira_api/requests/get_issue.rb +29 -0
  18. data/lib/tempest_time/api/jira_api/requests/get_user_issues.rb +36 -0
  19. data/lib/tempest_time/api/jira_api/response.rb +5 -0
  20. data/lib/tempest_time/api/jira_api/responses/get_issue.rb +16 -0
  21. data/lib/tempest_time/api/jira_api/responses/get_user_issues.rb +14 -0
  22. data/lib/tempest_time/api/request.rb +87 -0
  23. data/lib/tempest_time/api/response.rb +34 -0
  24. data/lib/tempest_time/api/tempo_api/authorization.rb +23 -0
  25. data/lib/tempest_time/api/tempo_api/models/worklog.rb +36 -0
  26. data/lib/tempest_time/api/tempo_api/request.rb +35 -0
  27. data/lib/tempest_time/api/tempo_api/requests/create_worklog.rb +51 -0
  28. data/lib/tempest_time/api/tempo_api/requests/delete_worklog.rb +29 -0
  29. data/lib/tempest_time/api/tempo_api/requests/get_worklog.rb +29 -0
  30. data/lib/tempest_time/api/tempo_api/requests/list_worklogs.rb +41 -0
  31. data/lib/tempest_time/api/tempo_api/requests/report.rb +0 -0
  32. data/lib/tempest_time/api/tempo_api/requests/submit_timesheet.rb +49 -0
  33. data/lib/tempest_time/api/tempo_api/response.rb +5 -0
  34. data/lib/tempest_time/api/tempo_api/responses/create_worklog.rb +28 -0
  35. data/lib/tempest_time/api/tempo_api/responses/delete_worklog.rb +8 -0
  36. data/lib/tempest_time/api/tempo_api/responses/get_worklog.rb +22 -0
  37. data/lib/tempest_time/api/tempo_api/responses/list_worklogs.rb +40 -0
  38. data/lib/tempest_time/api/tempo_api/responses/submit_timesheet.rb +13 -0
  39. data/lib/tempest_time/cli.rb +92 -0
  40. data/lib/tempest_time/command.rb +60 -0
  41. data/lib/tempest_time/commands/config/edit.rb +38 -0
  42. data/lib/tempest_time/commands/config/setup.rb +55 -0
  43. data/lib/tempest_time/commands/config.rb +30 -0
  44. data/lib/tempest_time/commands/delete.rb +31 -0
  45. data/lib/tempest_time/commands/issues.rb +37 -0
  46. data/lib/tempest_time/commands/list.rb +32 -0
  47. data/lib/tempest_time/commands/report.rb +83 -0
  48. data/lib/tempest_time/commands/submit.rb +26 -0
  49. data/lib/tempest_time/commands/teams/add.rb +29 -0
  50. data/lib/tempest_time/commands/teams/delete.rb +32 -0
  51. data/lib/tempest_time/commands/teams/edit.rb +49 -0
  52. data/lib/tempest_time/commands/teams.rb +30 -0
  53. data/lib/tempest_time/commands/track.rb +70 -0
  54. data/lib/tempest_time/helpers/formatting_helper.rb +16 -0
  55. data/lib/tempest_time/helpers/time_helper.rb +63 -0
  56. data/lib/tempest_time/models/report.rb +58 -0
  57. data/lib/tempest_time/services/generate_report.rb +54 -0
  58. data/lib/tempest_time/setting.rb +47 -0
  59. data/lib/tempest_time/settings/authorization.rb +19 -0
  60. data/lib/tempest_time/settings/teams.rb +19 -0
  61. data/lib/tempest_time/templates/config/.gitkeep +1 -0
  62. data/lib/tempest_time/templates/config/auth/.gitkeep +1 -0
  63. data/lib/tempest_time/templates/config/setup/.gitkeep +1 -0
  64. data/lib/tempest_time/templates/config/teams/.gitkeep +1 -0
  65. data/lib/tempest_time/templates/delete/.gitkeep +1 -0
  66. data/lib/tempest_time/templates/issue/.gitkeep +1 -0
  67. data/lib/tempest_time/templates/issues/.gitkeep +1 -0
  68. data/lib/tempest_time/templates/list/.gitkeep +1 -0
  69. data/lib/tempest_time/templates/report/.gitkeep +1 -0
  70. data/lib/tempest_time/templates/setup/.gitkeep +1 -0
  71. data/lib/tempest_time/templates/submit/.gitkeep +1 -0
  72. data/lib/tempest_time/templates/teams/.gitkeep +1 -0
  73. data/lib/tempest_time/templates/track/.gitkeep +1 -0
  74. data/lib/tempest_time/templates/view/.gitkeep +1 -0
  75. data/lib/tempest_time/version.rb +3 -0
  76. data/lib/tempest_time.rb +4 -0
  77. data/tempest_time.gemspec +55 -0
  78. metadata +513 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 173351f3339229c247bb0cd2698f6b23802a01b23eeb756559726682297de0d7
4
+ data.tar.gz: db820a7f9fdcae95667c278f286b507916bf6e1378ba74e3a3e4f9c08adf24d8
5
+ SHA512:
6
+ metadata.gz: f12ae7ad40e9465494f8675f7f88140f3556d567b587cf03e5b05facd3353f9a27ddb1fd0cfc899015bcda847b45bddfc88866790662fe97438420d8e2983721
7
+ data.tar.gz: 8feb29badfeab6fa1c0908c17d10947b3172e792cb3b4c5f27f7841941b4b61287a61fc2d8c5af0fd27e8ec4a3b5d4e1bf92e4b1dc5eeb7887c204cf88737126
data/.gitignore ADDED
@@ -0,0 +1,10 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+ .byebug_history
10
+ *.gem
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ 2.5.0
data/.travis.yml ADDED
@@ -0,0 +1,5 @@
1
+ sudo: false
2
+ language: ruby
3
+ rvm:
4
+ - 2.5.0
5
+ before_install: gem install bundler -v 1.16.1
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source "https://rubygems.org"
2
+
3
+ git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
4
+
5
+ # Specify your gem's dependencies in tempest_time.gemspec
6
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,133 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ tempest_time (0.5.0)
5
+ git (~> 1.5)
6
+ httparty (~> 0.16)
7
+ pastel (~> 0.7.2)
8
+ ruby-git (~> 0.2)
9
+ thor (~> 0.20.0)
10
+ tty-box (~> 0.3.0)
11
+ tty-color (~> 0.4)
12
+ tty-command (~> 0.8.0)
13
+ tty-config (~> 0.3.0)
14
+ tty-cursor (~> 0.6)
15
+ tty-editor (~> 0.5.0)
16
+ tty-file (~> 0.7.0)
17
+ tty-font (~> 0.2.0)
18
+ tty-markdown (~> 0.5.0)
19
+ tty-pager (~> 0.12.0)
20
+ tty-pie (~> 0.1.0)
21
+ tty-platform (~> 0.2.0)
22
+ tty-progressbar (~> 0.16.0)
23
+ tty-prompt (~> 0.18.0)
24
+ tty-screen (~> 0.6)
25
+ tty-spinner (~> 0.9.0)
26
+ tty-table (~> 0.10.0)
27
+ tty-tree (~> 0.2.0)
28
+ tty-which (~> 0.4)
29
+
30
+ GEM
31
+ remote: https://rubygems.org/
32
+ specs:
33
+ byebug (10.0.2)
34
+ diff-lcs (1.3)
35
+ equatable (0.5.0)
36
+ git (1.5.0)
37
+ httparty (0.16.3)
38
+ mime-types (~> 3.0)
39
+ multi_xml (>= 0.5.2)
40
+ kramdown (1.16.2)
41
+ mime-types (3.2.2)
42
+ mime-types-data (~> 3.2015)
43
+ mime-types-data (3.2018.0812)
44
+ minitest (5.11.3)
45
+ multi_xml (0.6.0)
46
+ necromancer (0.4.0)
47
+ pastel (0.7.2)
48
+ equatable (~> 0.5.0)
49
+ tty-color (~> 0.4.0)
50
+ rake (10.5.0)
51
+ rouge (3.3.0)
52
+ ruby-git (0.2.2)
53
+ strings (0.1.4)
54
+ strings-ansi (~> 0.1.0)
55
+ unicode-display_width (~> 1.4.0)
56
+ unicode_utils (~> 1.4.0)
57
+ strings-ansi (0.1.0)
58
+ thor (0.20.3)
59
+ timers (4.3.0)
60
+ tty-box (0.3.0)
61
+ pastel (~> 0.7.2)
62
+ strings (~> 0.1.4)
63
+ tty-cursor (~> 0.6.0)
64
+ tty-color (0.4.3)
65
+ tty-command (0.8.2)
66
+ pastel (~> 0.7.0)
67
+ tty-config (0.3.1)
68
+ tty-cursor (0.6.0)
69
+ tty-editor (0.5.0)
70
+ tty-prompt (~> 0.18)
71
+ tty-which (~> 0.4)
72
+ tty-file (0.7.0)
73
+ diff-lcs (~> 1.3)
74
+ pastel (~> 0.7.2)
75
+ tty-prompt (~> 0.18)
76
+ tty-font (0.2.0)
77
+ tty-markdown (0.5.0)
78
+ kramdown (~> 1.16.2)
79
+ pastel (~> 0.7.2)
80
+ rouge (~> 3.3)
81
+ strings (~> 0.1.4)
82
+ tty-color (~> 0.4)
83
+ tty-screen (~> 0.6)
84
+ tty-pager (0.12.0)
85
+ strings (~> 0.1.4)
86
+ tty-screen (~> 0.6)
87
+ tty-which (~> 0.4)
88
+ tty-pie (0.1.0)
89
+ pastel (~> 0.7.2)
90
+ tty-cursor (~> 0.6.0)
91
+ tty-platform (0.2.0)
92
+ tty-progressbar (0.16.0)
93
+ strings-ansi (~> 0.1.0)
94
+ tty-cursor (~> 0.6.0)
95
+ tty-screen (~> 0.6.4)
96
+ unicode-display_width (~> 1.3)
97
+ tty-prompt (0.18.1)
98
+ necromancer (~> 0.4.0)
99
+ pastel (~> 0.7.0)
100
+ timers (~> 4.0)
101
+ tty-cursor (~> 0.6.0)
102
+ tty-reader (~> 0.5.0)
103
+ tty-reader (0.5.0)
104
+ tty-cursor (~> 0.6.0)
105
+ tty-screen (~> 0.6.4)
106
+ wisper (~> 2.0.0)
107
+ tty-screen (0.6.5)
108
+ tty-spinner (0.9.0)
109
+ tty-cursor (~> 0.6.0)
110
+ tty-table (0.10.0)
111
+ equatable (~> 0.5.0)
112
+ necromancer (~> 0.4.0)
113
+ pastel (~> 0.7.2)
114
+ strings (~> 0.1.0)
115
+ tty-screen (~> 0.6.4)
116
+ tty-tree (0.2.0)
117
+ tty-which (0.4.0)
118
+ unicode-display_width (1.4.1)
119
+ unicode_utils (1.4.0)
120
+ wisper (2.0.0)
121
+
122
+ PLATFORMS
123
+ ruby
124
+
125
+ DEPENDENCIES
126
+ bundler (~> 1.16)
127
+ byebug (~> 10.0)
128
+ minitest (~> 5.0)
129
+ rake (~> 10.0)
130
+ tempest_time!
131
+
132
+ BUNDLED WITH
133
+ 1.16.1
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ Copyright (c) Devan Hurst, 2019.
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,8 @@
1
+ # Tempest
2
+
3
+ Track Tempo hours, directly from command line!
4
+
5
+ For more info...
6
+ ```
7
+ tempest help
8
+ ```
data/Rakefile ADDED
@@ -0,0 +1,10 @@
1
+ require "bundler/gem_tasks"
2
+ require "rake/testtask"
3
+
4
+ Rake::TestTask.new(:test) do |t|
5
+ t.libs << "test"
6
+ t.libs << "lib"
7
+ t.test_files = FileList["test/**/*_test.rb"]
8
+ end
9
+
10
+ task :default => :test
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "tempest"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start(__FILE__)
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
data/bin/tempest ADDED
@@ -0,0 +1,18 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ lib_path = File.expand_path('../lib', __dir__)
5
+ $:.unshift(lib_path) if !$:.include?(lib_path)
6
+ require 'tempest_time/cli'
7
+
8
+ Signal.trap('INT') do
9
+ warn("\n#{caller.join("\n")}: interrupted")
10
+ exit(1)
11
+ end
12
+
13
+ begin
14
+ TempestTime::CLI.start
15
+ rescue TempestTime::CLI::Error => err
16
+ puts "ERROR: #{err.message}"
17
+ exit 1
18
+ end
@@ -0,0 +1,17 @@
1
+ require_relative '../settings/authorization'
2
+
3
+ module TempestTime
4
+ module API
5
+ class Authorization
6
+ def credentials
7
+ { url: url, user: user, email: email, token: token }
8
+ end
9
+
10
+ private
11
+
12
+ def settings
13
+ TempestTime::Settings::Authorization
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,27 @@
1
+ require_relative '../authorization'
2
+
3
+ module JiraAPI
4
+ class Authorization < TempestTime::API::Authorization
5
+ private
6
+
7
+ def url
8
+ "https://#{subdomain}.atlassian.net/rest/api/3"
9
+ end
10
+
11
+ def subdomain
12
+ settings.read('subdomain')
13
+ end
14
+
15
+ def user
16
+ settings.read('username')
17
+ end
18
+
19
+ def email
20
+ settings.read('email')
21
+ end
22
+
23
+ def token
24
+ settings.read('jira_token')
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,28 @@
1
+ require_relative '../../../helpers/formatting_helper'
2
+
3
+ module JiraAPI
4
+ module Models
5
+ class Issue
6
+ include TempestTime::Helpers::FormattingHelper
7
+
8
+ attr_reader :fields, :summary, :key
9
+
10
+ def initialize(issue)
11
+ @key = issue['key']
12
+ @fields = issue['fields']
13
+ end
14
+
15
+ def remaining_estimate
16
+ @remaining_estimate ||= fields.dig('timetracking', 'remainingEstimateSeconds')
17
+ end
18
+
19
+ def summary
20
+ @summary ||= fields.dig('summary')
21
+ end
22
+
23
+ def status
24
+ @status ||= fields.dig('status', 'name')
25
+ end
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,40 @@
1
+ require 'httparty'
2
+ require 'json'
3
+
4
+ require_relative './authorization'
5
+ require_relative './response'
6
+ require_relative '../request'
7
+
8
+ module JiraAPI
9
+ class Request < TempestTime::API::Request
10
+ def send_request
11
+ @raw_response = self.class.send(
12
+ request_method,
13
+ request_path,
14
+ headers: headers,
15
+ body: request_body,
16
+ query: query_params,
17
+ basic_auth: basic_auth
18
+ )
19
+ response
20
+ end
21
+
22
+ private
23
+
24
+ def authorization_klass
25
+ Authorization
26
+ end
27
+
28
+ def response_klass
29
+ Response
30
+ end
31
+
32
+ def user
33
+ credentials.fetch(:email, nil)
34
+ end
35
+
36
+ def username
37
+ credentials.fetch(:user, nil)
38
+ end
39
+ end
40
+ end
@@ -0,0 +1,29 @@
1
+ require_relative '../request'
2
+ require_relative '../responses/get_issue'
3
+
4
+ module JiraAPI
5
+ module Requests
6
+ class GetIssue < JiraAPI::Request
7
+ attr_reader :issue
8
+
9
+ def initialize(issue)
10
+ super
11
+ @issue = issue
12
+ end
13
+
14
+ private
15
+
16
+ def request_method
17
+ 'get'
18
+ end
19
+
20
+ def request_path
21
+ "/issue/#{issue}"
22
+ end
23
+
24
+ def response_klass
25
+ JiraAPI::Responses::GetIssue
26
+ end
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,36 @@
1
+ require_relative '../request'
2
+ require_relative '../responses/get_user_issues'
3
+
4
+ module JiraAPI
5
+ module Requests
6
+ class GetUserIssues < JiraAPI::Request
7
+ attr_reader :requested_user
8
+
9
+ def initialize(requested_user = nil)
10
+ super
11
+ @requested_user = requested_user || username
12
+ end
13
+
14
+ private
15
+
16
+ def request_method
17
+ 'get'
18
+ end
19
+
20
+ def request_path
21
+ "/search"
22
+ end
23
+
24
+ def query_params
25
+ {
26
+ 'jql' => "assignee=#{requested_user} AND resolution is EMPTY",
27
+ 'maxResults' => 100
28
+ }
29
+ end
30
+
31
+ def response_klass
32
+ JiraAPI::Responses::GetUserIssues
33
+ end
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,5 @@
1
+ require_relative '../response'
2
+
3
+ module JiraAPI
4
+ class Response < TempestTime::API::Response; end
5
+ end
@@ -0,0 +1,16 @@
1
+ require_relative '../response'
2
+ require_relative '../models/issue'
3
+
4
+ module JiraAPI
5
+ module Responses
6
+ class GetIssue < JiraAPI::Response
7
+ def message
8
+ puts issue.to_s
9
+ end
10
+
11
+ def issue
12
+ @issue ||= JiraAPI::Models::Issue.new(raw_response)
13
+ end
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,14 @@
1
+ require_relative '../response'
2
+ require_relative '../models/issue'
3
+
4
+ module JiraAPI
5
+ module Responses
6
+ class GetUserIssues < JiraAPI::Response
7
+ def issues
8
+ @issues ||= raw_response['issues'].map do |issue|
9
+ JiraAPI::Models::Issue.new(issue)
10
+ end.reverse
11
+ end
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,87 @@
1
+ require 'httparty'
2
+ require 'json'
3
+
4
+ require_relative './authorization'
5
+ require_relative './response'
6
+
7
+ module TempestTime
8
+ module API
9
+ class Request
10
+ include HTTParty
11
+
12
+ DATE_FORMAT = "%Y-%m-%d".freeze
13
+
14
+ def initialize(*args)
15
+ self.class.base_uri credentials.fetch(:url)
16
+ end
17
+
18
+ # @abstract Subclass is expected to implement #send_request
19
+ # @!method send_request
20
+ # HTTParty call to API
21
+
22
+ def response
23
+ @response ||= response_klass.new(raw_response, self)
24
+ end
25
+
26
+ def response_message
27
+ response.message
28
+ end
29
+
30
+ private
31
+
32
+ attr_reader :raw_response
33
+
34
+ # @abstract Subclass is expected to implement #request_method
35
+ # @!method request_method
36
+ # RESTful operation: one of 'get', 'post', 'put', 'delete'
37
+
38
+ # @abstract Subclass is expected to implement #request_path
39
+ # @!method request_path
40
+ # Path for the operation. i.e. /users
41
+
42
+ # @abstract Subclass is expected to implement #response_klass
43
+ # @!method request_klass
44
+ # The class used to parse the response object.
45
+
46
+ # @abstract Subclass is expected to implement #authorization_klass
47
+ # @!method authorization_klass
48
+ # Define as Authorization.new in each subclass so class is dynamic.
49
+
50
+ def request_body
51
+ {}
52
+ end
53
+
54
+ def query_params
55
+ {}
56
+ end
57
+
58
+ def credentials
59
+ authorization_klass.new.credentials
60
+ end
61
+
62
+ def user
63
+ credentials.fetch(:user, nil)
64
+ end
65
+
66
+ def token
67
+ credentials.fetch(:token, nil)
68
+ end
69
+
70
+ def headers
71
+ content_type_header
72
+ end
73
+
74
+ def content_type_header
75
+ { 'Content-Type' => 'application/json' }
76
+ end
77
+
78
+ def authorization_header
79
+ { 'Authorization' => "Bearer #{token}" }
80
+ end
81
+
82
+ def basic_auth
83
+ { username: user, password: token }
84
+ end
85
+ end
86
+ end
87
+ end
@@ -0,0 +1,34 @@
1
+ module TempestTime
2
+ module API
3
+ class Response
4
+ def initialize(raw_response, request)
5
+ @raw_response = raw_response
6
+ @request = request
7
+ end
8
+
9
+ def success?
10
+ raw_response.success?
11
+ end
12
+
13
+ def failure?
14
+ !success?
15
+ end
16
+
17
+ def message
18
+ raw_response.success? ? success_message : failure_message
19
+ end
20
+
21
+ private
22
+
23
+ attr_reader :raw_response, :request
24
+
25
+ def success_message
26
+ 'Success!'
27
+ end
28
+
29
+ def failure_message
30
+ 'Failed!'
31
+ end
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,23 @@
1
+ require_relative '../authorization'
2
+
3
+ module TempoAPI
4
+ class Authorization < TempestTime::API::Authorization
5
+ private
6
+
7
+ def url
8
+ 'https://api.tempo.io/2'
9
+ end
10
+
11
+ def user
12
+ settings.read('username')
13
+ end
14
+
15
+ def email
16
+ settings.read('email')
17
+ end
18
+
19
+ def token
20
+ settings.read('tempo_token')
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,36 @@
1
+ module TempoAPI
2
+ module Models
3
+ class Worklog
4
+ attr_reader :id, :issue, :seconds, :description
5
+
6
+ def initialize(options)
7
+ @id = options.fetch(:id)
8
+ @issue = options.fetch(:issue)
9
+ @seconds = options.fetch(:seconds)
10
+ @description = options.fetch(:description)
11
+ end
12
+
13
+ def to_s
14
+ "#{id}: #{issue}: #{time_output}: #{description}"
15
+ end
16
+
17
+ def project
18
+ issue.split('-').first
19
+ end
20
+
21
+ def minutes
22
+ seconds / 60.to_f
23
+ end
24
+
25
+ def hours
26
+ minutes / 60.to_f
27
+ end
28
+
29
+ private
30
+
31
+ def time_output
32
+ minutes < 60 ? "#{minutes.to_i}m" : "#{hours.to_i}h"
33
+ end
34
+ end
35
+ end
36
+ end