tempest_time 0.7.3 → 0.7.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.rubocop.yml +1 -0
- data/git-hooks/install.sh +5 -0
- data/git-hooks/pre-commit +45 -0
- data/lib/tempest_time/api/jira_api/requests/get_current_user.rb +25 -0
- data/lib/tempest_time/api/jira_api/responses/get_current_user.rb +10 -0
- data/lib/tempest_time/api/tempo_api/requests/list_worklogs.rb +5 -2
- data/lib/tempest_time/commands/config/setup.rb +73 -27
- data/lib/tempest_time/version.rb +1 -1
- metadata +6 -2
- data/lib/tempest_time/api/tempo_api/requests/report.rb +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e9063e95fed5afa9e1fc6737a7411ef662ce7d67468dad0d7aa755d5c95e0fe2
|
4
|
+
data.tar.gz: d2553e4623e3f70881b082f74fc506b50bf219dc6fe28ab59918b34614330439
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f1d085090a5274bd8a65db7b23a33f4ce9703ce530586b177f14b0759391565a88deb2c2a414f36e9b5643757657544acafc37083e91226c879dcc915509a8a8
|
7
|
+
data.tar.gz: 833ed9330dacef6e846de522985fc06e6b31b11bb517ff9d040c2774b024f1a3a9f60e12f6fd9c8ce89fb831a31d94d1372e1427e8a3cb59c7f83456fd8a066e
|
data/.rubocop.yml
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
---
|
@@ -0,0 +1,45 @@
|
|
1
|
+
#!/bin/sh
|
2
|
+
#
|
3
|
+
# Check for ruby style errors
|
4
|
+
red='\033[0;31m'
|
5
|
+
green='\033[0;32m'
|
6
|
+
yellow='\033[0;33m'
|
7
|
+
NC='\033[0m'
|
8
|
+
|
9
|
+
RUBY_FAIL=0
|
10
|
+
|
11
|
+
# Check if rubocop is installed for the current project
|
12
|
+
rubocop -v >/dev/null 2>&1 || { echo >&2 "${red}[Ruby Style][Fatal]: Add rubocop to your Gemfile"; exit 1; }
|
13
|
+
|
14
|
+
# Get only the staged files
|
15
|
+
RUBY_FILES="$(git diff --cached --name-only --diff-filter=AMC | grep -e "\.rb$" -e "\.decorator$" | tr '\n' ' ')"
|
16
|
+
echo "${green}[Ruby Style][Info]: Checking Ruby Style${NC}"
|
17
|
+
|
18
|
+
if [ -n "$RUBY_FILES" ]
|
19
|
+
then
|
20
|
+
echo "${green}[Ruby Style][Info]: ${RUBY_FILES}${NC}"
|
21
|
+
|
22
|
+
# Run rubocop on the staged files
|
23
|
+
rubocop --auto-correct --fail-level A --format quiet ${RUBY_FILES}
|
24
|
+
if [ $? -ne 0 ]; then
|
25
|
+
echo "${red}[Ruby Style][Error]: Errors found, autofix attempted. Check the diff and commit again${NC}"
|
26
|
+
git add $RUBY_FILES
|
27
|
+
RUBY_FAIL=1
|
28
|
+
fi
|
29
|
+
else
|
30
|
+
echo "${green}[Ruby Style][Info]: No files to check${NC}"
|
31
|
+
fi
|
32
|
+
|
33
|
+
if [ $RUBY_FAIL == 0 ]
|
34
|
+
then
|
35
|
+
echo "${yellow}[Ruby Style][Info]: Rubocop is pleased!${NC}"
|
36
|
+
fi
|
37
|
+
|
38
|
+
sleep 1
|
39
|
+
|
40
|
+
if [ $RUBY_FAIL == 0 ]
|
41
|
+
then
|
42
|
+
exit 0
|
43
|
+
else
|
44
|
+
exit 1
|
45
|
+
fi
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative '../request'
|
4
|
+
require_relative '../responses/get_current_user'
|
5
|
+
|
6
|
+
module JiraAPI
|
7
|
+
module Requests
|
8
|
+
# :no-doc:
|
9
|
+
class GetCurrentUser < JiraAPI::Request
|
10
|
+
private
|
11
|
+
|
12
|
+
def request_method
|
13
|
+
'get'
|
14
|
+
end
|
15
|
+
|
16
|
+
def request_path
|
17
|
+
'/myself'
|
18
|
+
end
|
19
|
+
|
20
|
+
def response_klass
|
21
|
+
JiraAPI::Responses::GetCurrentUser
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -1,12 +1,15 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require_relative '../request'
|
2
4
|
require_relative '../responses/list_worklogs'
|
3
5
|
|
4
6
|
module TempoAPI
|
5
7
|
module Requests
|
8
|
+
# :no-doc:
|
6
9
|
class ListWorklogs < TempoAPI::Request
|
7
10
|
attr_reader :start_date, :end_date
|
8
11
|
|
9
|
-
def initialize(start_date, end_date, requested_user)
|
12
|
+
def initialize(start_date, end_date = nil, requested_user = nil)
|
10
13
|
super
|
11
14
|
@start_date = start_date
|
12
15
|
@end_date = end_date || start_date
|
@@ -38,4 +41,4 @@ module TempoAPI
|
|
38
41
|
end
|
39
42
|
end
|
40
43
|
end
|
41
|
-
end
|
44
|
+
end
|
@@ -2,52 +2,98 @@
|
|
2
2
|
|
3
3
|
require_relative '../../command'
|
4
4
|
require_relative '../../settings/authorization'
|
5
|
+
require_relative '../../api/jira_api/requests/get_current_user'
|
6
|
+
require_relative '../../api/tempo_api/requests/list_worklogs'
|
5
7
|
|
6
8
|
module TempestTime
|
7
9
|
module Commands
|
8
10
|
class Config
|
11
|
+
# :no-doc:
|
9
12
|
class Setup < TempestTime::Command
|
10
13
|
def initialize(options)
|
11
14
|
@options = options
|
12
15
|
end
|
13
16
|
|
14
|
-
def execute
|
15
|
-
|
17
|
+
def execute
|
18
|
+
check_for_completion
|
19
|
+
set_authorization_values
|
20
|
+
with_spinner('Checking credentials...') do |spinner|
|
21
|
+
check_for_validity
|
22
|
+
spinner.stop(pastel.green("Success! You're ready to go!"))
|
23
|
+
rescue StandardError
|
24
|
+
spinner.stop(
|
25
|
+
pastel.red("Something isn't right... please re-run setup.")
|
26
|
+
)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
private
|
31
|
+
|
32
|
+
def credentials
|
33
|
+
@credentials ||= {
|
34
|
+
'email' => email,
|
35
|
+
'username' => username,
|
36
|
+
'subdomain' => subdomain,
|
37
|
+
'jira_token' => jira_token,
|
38
|
+
'tempo_token' => tempo_token
|
39
|
+
}
|
40
|
+
end
|
41
|
+
|
42
|
+
def authorization
|
43
|
+
@authorization ||= TempestTime::Settings::Authorization.new
|
44
|
+
end
|
45
|
+
|
46
|
+
def check_for_completion
|
47
|
+
return true unless credentials.any? { |_, value| value.nil? }
|
48
|
+
abort(
|
49
|
+
pastel.red('Setup failed!') + ' ' \
|
50
|
+
'One or more credentials were missing. Please try again.'
|
51
|
+
)
|
52
|
+
end
|
53
|
+
|
54
|
+
def set_authorization_values
|
55
|
+
credentials.map { |key, value| authorization.set(key, value) }
|
56
|
+
end
|
57
|
+
|
58
|
+
def check_for_validity
|
59
|
+
jira = JiraAPI::Requests::GetCurrentUser.new
|
60
|
+
tempo = TempoAPI::Requests::ListWorklogs.new(Date.today)
|
61
|
+
raise StandardError unless jira.send_request.success?
|
62
|
+
raise StandardError unless tempo.send_request.success?
|
63
|
+
end
|
64
|
+
|
65
|
+
def email
|
66
|
+
prompt.ask(
|
16
67
|
'Please enter your Atlassian ID. '\
|
17
68
|
'This is typically your login email.'
|
18
69
|
)
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
70
|
+
end
|
71
|
+
|
72
|
+
def username
|
73
|
+
prompt.ask('Please enter your Atlassian username.')
|
74
|
+
end
|
75
|
+
|
76
|
+
def subdomain
|
77
|
+
prompt.ask(
|
23
78
|
'Please enter your Atlassian subdomain. '\
|
24
79
|
'i.e. [THIS VALUE].atlassian.net'
|
25
80
|
)
|
26
|
-
|
81
|
+
end
|
82
|
+
|
83
|
+
def jira_token
|
84
|
+
prompt.ask(
|
27
85
|
'Please enter your Atlassian API token. '\
|
28
|
-
'Your token can be generated at
|
86
|
+
'Your token can be generated at '\
|
87
|
+
'https://id.atlassian.com/manage/api-tokens'
|
29
88
|
)
|
30
|
-
|
89
|
+
end
|
90
|
+
|
91
|
+
def tempo_token
|
92
|
+
prompt.ask(
|
31
93
|
'Please enter your Tempo API token. '\
|
32
|
-
|
94
|
+
'Your token can be generated through '\
|
95
|
+
"your worksheet's settings page."
|
33
96
|
)
|
34
|
-
|
35
|
-
if [email, username, subdomain, jira_token, tempo_token].any?(&:nil?)
|
36
|
-
abort(
|
37
|
-
pastel.red('Setup failed!') + ' ' +
|
38
|
-
'One or more credentials were missing. Please try again.'
|
39
|
-
)
|
40
|
-
end
|
41
|
-
|
42
|
-
authorization = TempestTime::Settings::Authorization.new
|
43
|
-
|
44
|
-
authorization.set('email', email)
|
45
|
-
authorization.set('username', username)
|
46
|
-
authorization.set('subdomain', subdomain)
|
47
|
-
authorization.set('jira_token', jira_token)
|
48
|
-
authorization.set('tempo_token', tempo_token)
|
49
|
-
|
50
|
-
puts pastel.green('Setup complete!')
|
51
97
|
end
|
52
98
|
end
|
53
99
|
end
|
data/lib/tempest_time/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tempest_time
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.7.
|
4
|
+
version: 0.7.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Devan Hurst
|
@@ -215,6 +215,7 @@ extensions: []
|
|
215
215
|
extra_rdoc_files: []
|
216
216
|
files:
|
217
217
|
- ".gitignore"
|
218
|
+
- ".rubocop.yml"
|
218
219
|
- ".ruby-version"
|
219
220
|
- ".travis.yml"
|
220
221
|
- Gemfile
|
@@ -224,14 +225,18 @@ files:
|
|
224
225
|
- bin/console
|
225
226
|
- bin/setup
|
226
227
|
- bin/tempest
|
228
|
+
- git-hooks/install.sh
|
229
|
+
- git-hooks/pre-commit
|
227
230
|
- lib/tempest_time.rb
|
228
231
|
- lib/tempest_time/api/authorization.rb
|
229
232
|
- lib/tempest_time/api/jira_api/authorization.rb
|
230
233
|
- lib/tempest_time/api/jira_api/models/issue.rb
|
231
234
|
- lib/tempest_time/api/jira_api/request.rb
|
235
|
+
- lib/tempest_time/api/jira_api/requests/get_current_user.rb
|
232
236
|
- lib/tempest_time/api/jira_api/requests/get_issue.rb
|
233
237
|
- lib/tempest_time/api/jira_api/requests/get_user_issues.rb
|
234
238
|
- lib/tempest_time/api/jira_api/response.rb
|
239
|
+
- lib/tempest_time/api/jira_api/responses/get_current_user.rb
|
235
240
|
- lib/tempest_time/api/jira_api/responses/get_issue.rb
|
236
241
|
- lib/tempest_time/api/jira_api/responses/get_user_issues.rb
|
237
242
|
- lib/tempest_time/api/request.rb
|
@@ -243,7 +248,6 @@ files:
|
|
243
248
|
- lib/tempest_time/api/tempo_api/requests/delete_worklog.rb
|
244
249
|
- lib/tempest_time/api/tempo_api/requests/get_worklog.rb
|
245
250
|
- lib/tempest_time/api/tempo_api/requests/list_worklogs.rb
|
246
|
-
- lib/tempest_time/api/tempo_api/requests/report.rb
|
247
251
|
- lib/tempest_time/api/tempo_api/requests/submit_timesheet.rb
|
248
252
|
- lib/tempest_time/api/tempo_api/response.rb
|
249
253
|
- lib/tempest_time/api/tempo_api/responses/create_worklog.rb
|
File without changes
|