sfctl 1.0.2 → 1.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +23 -20
- data/lib/sfctl/commands/time/connections/add.rb +2 -2
- data/lib/sfctl/commands/time/sync.rb +2 -2
- data/lib/sfctl/harvest/sync.rb +5 -2
- data/lib/sfctl/toggl/sync.rb +19 -6
- data/lib/sfctl/version.rb +1 -1
- data/sfctl.gemspec +1 -1
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 36e137543a9eed8b4f2fd6c472fd5899d5dc94a3b98fd50d8ae527b79dd671b4
|
4
|
+
data.tar.gz: 2cb0c12ea7a79b7fefae5cbbffba604815a7a9629b002049530c165461d4a701
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f0e23db4406b9d253250398269a216a819e1a55afd11570f9515ab909e7b230b316cdbd8eedf28c910c78772e0aece324dc0adad1a4a0210b253b700a64e1df1
|
7
|
+
data.tar.gz: 292842c5de401507c927181a9c346e0a324a9944e5653fe4be752d8951dfc1bcac8e902d6e137eb0426ed0c6fa5636568fe2377a14361eb6a2d93d0a4c7a0d0a
|
data/Gemfile.lock
CHANGED
@@ -23,7 +23,7 @@ PATH
|
|
23
23
|
tty-progressbar (~> 0.17.0)
|
24
24
|
tty-prompt (~> 0.21.0)
|
25
25
|
tty-reader (~> 0.7.0)
|
26
|
-
tty-screen (~> 0.
|
26
|
+
tty-screen (~> 0.8.1)
|
27
27
|
tty-spinner (~> 0.9.3)
|
28
28
|
tty-table (~> 0.11.0)
|
29
29
|
tty-tree (~> 0.4.0)
|
@@ -34,12 +34,12 @@ GEM
|
|
34
34
|
specs:
|
35
35
|
addressable (2.7.0)
|
36
36
|
public_suffix (>= 2.0.2, < 5.0)
|
37
|
-
ast (2.4.
|
38
|
-
byebug (11.1.
|
39
|
-
coderay (1.1.
|
37
|
+
ast (2.4.1)
|
38
|
+
byebug (11.1.3)
|
39
|
+
coderay (1.1.3)
|
40
40
|
crack (0.4.3)
|
41
41
|
safe_yaml (~> 1.0.0)
|
42
|
-
diff-lcs (1.
|
42
|
+
diff-lcs (1.4.4)
|
43
43
|
docile (1.3.2)
|
44
44
|
equatable (0.6.1)
|
45
45
|
faraday (1.0.1)
|
@@ -48,15 +48,14 @@ GEM
|
|
48
48
|
rspec-core (~> 3.0)
|
49
49
|
ruby-progressbar (~> 1.4)
|
50
50
|
hashdiff (1.0.1)
|
51
|
-
jaro_winkler (1.5.4)
|
52
51
|
kramdown (1.16.2)
|
53
52
|
method_source (1.0.0)
|
54
53
|
multipart-post (2.1.1)
|
55
54
|
necromancer (0.5.1)
|
56
|
-
parallel (1.19.
|
57
|
-
parser (2.7.1.
|
58
|
-
ast (~> 2.4.
|
59
|
-
pastel (0.7.
|
55
|
+
parallel (1.19.2)
|
56
|
+
parser (2.7.1.4)
|
57
|
+
ast (~> 2.4.1)
|
58
|
+
pastel (0.7.4)
|
60
59
|
equatable (~> 0.6)
|
61
60
|
tty-color (~> 0.5)
|
62
61
|
pry (0.13.1)
|
@@ -65,32 +64,36 @@ GEM
|
|
65
64
|
pry-byebug (3.9.0)
|
66
65
|
byebug (~> 11.0)
|
67
66
|
pry (~> 0.13.0)
|
68
|
-
public_suffix (4.0.
|
67
|
+
public_suffix (4.0.5)
|
69
68
|
rainbow (3.0.0)
|
70
69
|
rake (12.3.3)
|
70
|
+
regexp_parser (1.7.1)
|
71
71
|
rexml (3.2.4)
|
72
|
-
rouge (3.
|
72
|
+
rouge (3.21.0)
|
73
73
|
rspec (3.9.0)
|
74
74
|
rspec-core (~> 3.9.0)
|
75
75
|
rspec-expectations (~> 3.9.0)
|
76
76
|
rspec-mocks (~> 3.9.0)
|
77
|
-
rspec-core (3.9.
|
78
|
-
rspec-support (~> 3.9.
|
79
|
-
rspec-expectations (3.9.
|
77
|
+
rspec-core (3.9.2)
|
78
|
+
rspec-support (~> 3.9.3)
|
79
|
+
rspec-expectations (3.9.2)
|
80
80
|
diff-lcs (>= 1.2.0, < 2.0)
|
81
81
|
rspec-support (~> 3.9.0)
|
82
82
|
rspec-mocks (3.9.1)
|
83
83
|
diff-lcs (>= 1.2.0, < 2.0)
|
84
84
|
rspec-support (~> 3.9.0)
|
85
|
-
rspec-support (3.9.
|
86
|
-
rubocop (0.
|
87
|
-
jaro_winkler (~> 1.5.1)
|
85
|
+
rspec-support (3.9.3)
|
86
|
+
rubocop (0.88.0)
|
88
87
|
parallel (~> 1.10)
|
89
|
-
parser (>= 2.7.
|
88
|
+
parser (>= 2.7.1.1)
|
90
89
|
rainbow (>= 2.2.2, < 4.0)
|
90
|
+
regexp_parser (>= 1.7)
|
91
91
|
rexml
|
92
|
+
rubocop-ast (>= 0.1.0, < 1.0)
|
92
93
|
ruby-progressbar (~> 1.7)
|
93
94
|
unicode-display_width (>= 1.4.0, < 2.0)
|
95
|
+
rubocop-ast (0.1.0)
|
96
|
+
parser (>= 2.7.0.1)
|
94
97
|
ruby-progressbar (1.10.1)
|
95
98
|
safe_yaml (1.0.5)
|
96
99
|
simplecov (0.18.5)
|
@@ -151,7 +154,7 @@ GEM
|
|
151
154
|
tty-cursor (~> 0.7)
|
152
155
|
tty-screen (~> 0.7)
|
153
156
|
wisper (~> 2.0.0)
|
154
|
-
tty-screen (0.
|
157
|
+
tty-screen (0.8.1)
|
155
158
|
tty-spinner (0.9.3)
|
156
159
|
tty-cursor (~> 0.7)
|
157
160
|
tty-table (0.11.0)
|
@@ -90,7 +90,7 @@ module Sfctl
|
|
90
90
|
@prompt.select('Rounding?', %w[on off])
|
91
91
|
end
|
92
92
|
|
93
|
-
def setup_toggl_connection!(output, assignment_obj) # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
|
93
|
+
def setup_toggl_connection!(output, assignment_obj) # rubocop:disable Metrics/AbcSize, Metrics/MethodLength, Metrics/CyclomaticComplexity
|
94
94
|
spinner = ::TTY::Spinner.new('[:spinner] Loading ...')
|
95
95
|
|
96
96
|
assignment_id = assignment_obj['id']
|
@@ -162,7 +162,7 @@ module Sfctl
|
|
162
162
|
clear_conf_and_print_success!(output)
|
163
163
|
end
|
164
164
|
|
165
|
-
def setup_harvest_connection!(output, assignment_obj) # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
|
165
|
+
def setup_harvest_connection!(output, assignment_obj) # rubocop:disable Metrics/AbcSize, Metrics/MethodLength, Metrics/CyclomaticComplexity
|
166
166
|
spinner = ::TTY::Spinner.new('[:spinner] Loading ...')
|
167
167
|
|
168
168
|
assignment_id = assignment_obj['id']
|
@@ -79,7 +79,7 @@ module Sfctl
|
|
79
79
|
end
|
80
80
|
end
|
81
81
|
|
82
|
-
def sync(output, assignment, connection) # rubocop:disable Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
|
82
|
+
def sync(output, assignment, connection) # rubocop:disable Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity, Metrics/AbcSize
|
83
83
|
output.puts "Synchronizing: #{@pastel.cyan("[#{assignment['name']} / #{assignment['service']}]")}"
|
84
84
|
|
85
85
|
success, next_report = Starfish::Client.next_report(@options['starfish-host'], access_token, assignment['id'])
|
@@ -92,7 +92,7 @@ module Sfctl
|
|
92
92
|
|
93
93
|
print_report_contains_data(output, next_report) && return if touchy?(next_report)
|
94
94
|
|
95
|
-
uploading_to_starfish(output, assignment, time_entries, connection)
|
95
|
+
uploading_to_starfish(output, assignment, time_entries, connection) if time_entries.any?
|
96
96
|
end
|
97
97
|
|
98
98
|
def report_interval(record)
|
data/lib/sfctl/harvest/sync.rb
CHANGED
@@ -68,10 +68,13 @@ module Sfctl
|
|
68
68
|
def self.assignment_items(time_entries, connection)
|
69
69
|
hours_field = hours_field(connection['rounding'])
|
70
70
|
time_entries.map do |te|
|
71
|
+
hours = te[hours_field]
|
72
|
+
time_seconds = hours * 60 * 60
|
71
73
|
{
|
72
|
-
|
74
|
+
time_seconds: time_seconds.round,
|
73
75
|
date: te['spent_date'].to_s,
|
74
|
-
comment: te['notes']
|
76
|
+
comment: te['notes'],
|
77
|
+
external_id: te['id'].to_s
|
75
78
|
}
|
76
79
|
end
|
77
80
|
end
|
data/lib/sfctl/toggl/sync.rb
CHANGED
@@ -10,9 +10,14 @@ module Sfctl
|
|
10
10
|
spinner = TTY::Spinner.new("Loaded data from #{Sfctl::Command::TOGGL_PROVIDER}: [:spinner]", format: :dots)
|
11
11
|
spinner.auto_spin
|
12
12
|
|
13
|
-
time_entries = get_time_entries(connection, toggl_config, report_interval)
|
13
|
+
time_entries, error = get_time_entries(connection, toggl_config, report_interval)
|
14
14
|
|
15
|
-
|
15
|
+
if error
|
16
|
+
spinner.error
|
17
|
+
output.puts pastel.red(error)
|
18
|
+
else
|
19
|
+
spinner.success(pastel.green('Done'))
|
20
|
+
end
|
16
21
|
|
17
22
|
table = TTY::Table.new %w[Date Comment Time], time_entries_table_rows(time_entries)
|
18
23
|
output.puts
|
@@ -38,14 +43,20 @@ module Sfctl
|
|
38
43
|
|
39
44
|
def self.get_time_entries(connection, toggl_config, report_interval)
|
40
45
|
entries_list = []
|
46
|
+
error = nil
|
41
47
|
|
42
48
|
page = 1
|
43
49
|
loop do
|
44
|
-
|
50
|
+
success, body = Toggl::Client.time_entries(
|
45
51
|
toggl_config['access_token'],
|
46
52
|
time_entries_params(connection, report_interval, page)
|
47
53
|
)
|
48
54
|
|
55
|
+
unless success
|
56
|
+
error = body.fetch('message', body)
|
57
|
+
break
|
58
|
+
end
|
59
|
+
|
49
60
|
entries_list << body['data']
|
50
61
|
entries_list.flatten!
|
51
62
|
entries_list.compact!
|
@@ -55,7 +66,7 @@ module Sfctl
|
|
55
66
|
page += 1
|
56
67
|
end
|
57
68
|
|
58
|
-
entries_list
|
69
|
+
[entries_list, error]
|
59
70
|
end
|
60
71
|
|
61
72
|
def self.time_entries_params(connection, report_interval, page = 1)
|
@@ -93,10 +104,12 @@ module Sfctl
|
|
93
104
|
|
94
105
|
def self.assignment_items(time_entries)
|
95
106
|
time_entries.map do |te|
|
107
|
+
milliseconds = te['dur'] || 0
|
96
108
|
{
|
97
|
-
|
109
|
+
time_seconds: milliseconds.div(1000),
|
98
110
|
date: Date.parse(te['start']).to_s,
|
99
|
-
comment: te['description']
|
111
|
+
comment: te['description'],
|
112
|
+
external_id: te['id'].to_s
|
100
113
|
}
|
101
114
|
end
|
102
115
|
end
|
data/lib/sfctl/version.rb
CHANGED
data/sfctl.gemspec
CHANGED
@@ -38,7 +38,7 @@ Gem::Specification.new do |spec|
|
|
38
38
|
spec.add_runtime_dependency 'tty-progressbar', '~> 0.17.0'
|
39
39
|
spec.add_runtime_dependency 'tty-prompt', '~> 0.21.0'
|
40
40
|
spec.add_runtime_dependency 'tty-reader', '~> 0.7.0'
|
41
|
-
spec.add_runtime_dependency 'tty-screen', '~> 0.
|
41
|
+
spec.add_runtime_dependency 'tty-screen', '~> 0.8.1'
|
42
42
|
spec.add_runtime_dependency 'tty-spinner', '~> 0.9.3'
|
43
43
|
spec.add_runtime_dependency 'tty-table', '~> 0.11.0'
|
44
44
|
spec.add_runtime_dependency 'tty-tree', '~> 0.4.0'
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sfctl
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Serhii Rudik
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: exe
|
11
11
|
cert_chain: []
|
12
|
-
date: 2020-
|
12
|
+
date: 2020-09-06 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: faraday
|
@@ -311,14 +311,14 @@ dependencies:
|
|
311
311
|
requirements:
|
312
312
|
- - "~>"
|
313
313
|
- !ruby/object:Gem::Version
|
314
|
-
version: 0.
|
314
|
+
version: 0.8.1
|
315
315
|
type: :runtime
|
316
316
|
prerelease: false
|
317
317
|
version_requirements: !ruby/object:Gem::Requirement
|
318
318
|
requirements:
|
319
319
|
- - "~>"
|
320
320
|
- !ruby/object:Gem::Version
|
321
|
-
version: 0.
|
321
|
+
version: 0.8.1
|
322
322
|
- !ruby/object:Gem::Dependency
|
323
323
|
name: tty-spinner
|
324
324
|
requirement: !ruby/object:Gem::Requirement
|
@@ -447,7 +447,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
447
447
|
- !ruby/object:Gem::Version
|
448
448
|
version: '0'
|
449
449
|
requirements: []
|
450
|
-
rubygems_version: 3.1.
|
450
|
+
rubygems_version: 3.1.4
|
451
451
|
signing_key:
|
452
452
|
specification_version: 4
|
453
453
|
summary: sfctl is a command line interface for the Starfish API.
|