toggl-jobcan 0.3.0 → 0.4.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +16 -0
- data/.travis.yml +4 -2
- data/CHANGELOG.md +41 -3
- data/Gemfile.lock +151 -51
- data/README.md +3 -0
- data/Rakefile +8 -0
- data/exe/toggl-jobcan +3 -55
- data/lib/toggl/jobcan/cli.rb +126 -0
- data/lib/toggl/jobcan/toggl_support.rb +1 -0
- data/lib/toggl/jobcan/version.rb +1 -1
- data/lib/toggl/jobcan.rb +1 -0
- data/toggl-jobcan.gemspec +6 -4
- metadata +42 -14
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f549868d642cadbb452675b66e0bba6b15eab0de95a430d27f5ff4ba6d0479fb
|
4
|
+
data.tar.gz: bbb07c91eb043092e59ef38d4be3cbe8b93dce4c875072f4737d3fa370a794ca
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fb901f928de7bc0697b38c2a60c323a43d54b84bb7a286033004461985cdb3bd141d69c639e3809b904b9c31519a1f67c63f0a7ed223da8048abb87392cb0340
|
7
|
+
data.tar.gz: 5d9ce4ef3e3a34971c68e402ff3e8d8c552ab25aab02f9a5e78d0a54c057f84b7c49fa3cb41669b416d8275c8d5b0ec1f52f01ddaa71e63b06c7326561bd226a
|
data/.rubocop.yml
CHANGED
@@ -3,3 +3,19 @@ AllCops:
|
|
3
3
|
|
4
4
|
Metrics/AbcSize:
|
5
5
|
Max: 20
|
6
|
+
|
7
|
+
Metrics/BlockLength:
|
8
|
+
Exclude:
|
9
|
+
- spec/**/*.rb
|
10
|
+
|
11
|
+
Style/EvalWithLocation:
|
12
|
+
Exclude:
|
13
|
+
- spec/**/*.rb
|
14
|
+
|
15
|
+
Style/AccessModifierDeclarations:
|
16
|
+
Exclude:
|
17
|
+
- spec/**/*.rb
|
18
|
+
|
19
|
+
Security/Eval:
|
20
|
+
Exclude:
|
21
|
+
- spec/**/*.rb
|
data/.travis.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,6 +1,44 @@
|
|
1
|
-
#
|
1
|
+
# Changelog
|
2
|
+
|
3
|
+
## [0.4.1](https://github.com/limitusus/toggl-jobcan/tree/0.4.1) (2021-07-01)
|
4
|
+
|
5
|
+
[Full Changelog](https://github.com/limitusus/toggl-jobcan/compare/v0.4.0...0.4.1)
|
6
|
+
|
7
|
+
**Merged pull requests:**
|
8
|
+
|
9
|
+
- Newer version of toggl-worktime is required for new Toggl API endpoint [\#14](https://github.com/limitusus/toggl-jobcan/pull/14) ([limitusus](https://github.com/limitusus))
|
10
|
+
- Update rake requirement from ~\> 10.0 to ~\> 13.0 [\#12](https://github.com/limitusus/toggl-jobcan/pull/12) ([dependabot[bot]](https://github.com/apps/dependabot))
|
11
|
+
- Bump nokogiri from 1.10.3 to 1.10.8 [\#10](https://github.com/limitusus/toggl-jobcan/pull/10) ([dependabot[bot]](https://github.com/apps/dependabot))
|
12
|
+
|
13
|
+
## [v0.4.0](https://github.com/limitusus/toggl-jobcan/tree/v0.4.0) (2019-05-22)
|
14
|
+
|
15
|
+
[Full Changelog](https://github.com/limitusus/toggl-jobcan/compare/v0.3.1...v0.4.0)
|
16
|
+
|
17
|
+
**Merged pull requests:**
|
18
|
+
|
19
|
+
- webdrivers [\#8](https://github.com/limitusus/toggl-jobcan/pull/8) ([limitusus](https://github.com/limitusus))
|
20
|
+
- Use main as a default action [\#7](https://github.com/limitusus/toggl-jobcan/pull/7) ([limitusus](https://github.com/limitusus))
|
21
|
+
- Use Thor as CLI testing preparation [\#6](https://github.com/limitusus/toggl-jobcan/pull/6) ([limitusus](https://github.com/limitusus))
|
22
|
+
- Add minimum tests [\#5](https://github.com/limitusus/toggl-jobcan/pull/5) ([limitusus](https://github.com/limitusus))
|
23
|
+
|
24
|
+
## [v0.3.1](https://github.com/limitusus/toggl-jobcan/tree/v0.3.1) (2019-02-01)
|
25
|
+
|
26
|
+
[Full Changelog](https://github.com/limitusus/toggl-jobcan/compare/v0.3.0...v0.3.1)
|
27
|
+
|
28
|
+
**Merged pull requests:**
|
29
|
+
|
30
|
+
- Fix bug from 2019 [\#4](https://github.com/limitusus/toggl-jobcan/pull/4) ([limitusus](https://github.com/limitusus))
|
31
|
+
|
32
|
+
## [v0.3.0](https://github.com/limitusus/toggl-jobcan/tree/v0.3.0) (2018-09-26)
|
33
|
+
|
34
|
+
[Full Changelog](https://github.com/limitusus/toggl-jobcan/compare/v0.2.0...v0.3.0)
|
35
|
+
|
36
|
+
**Merged pull requests:**
|
37
|
+
|
38
|
+
- Switch to Jobcan ID [\#3](https://github.com/limitusus/toggl-jobcan/pull/3) ([limitusus](https://github.com/limitusus))
|
2
39
|
|
3
40
|
## [v0.2.0](https://github.com/limitusus/toggl-jobcan/tree/v0.2.0) (2018-08-01)
|
41
|
+
|
4
42
|
[Full Changelog](https://github.com/limitusus/toggl-jobcan/compare/v0.1.1...v0.2.0)
|
5
43
|
|
6
44
|
**Merged pull requests:**
|
@@ -9,9 +47,9 @@
|
|
9
47
|
- Add dryrun feature [\#1](https://github.com/limitusus/toggl-jobcan/pull/1) ([limitusus](https://github.com/limitusus))
|
10
48
|
|
11
49
|
## [v0.1.1](https://github.com/limitusus/toggl-jobcan/tree/v0.1.1) (2018-04-02)
|
50
|
+
|
12
51
|
[Full Changelog](https://github.com/limitusus/toggl-jobcan/compare/v0.1.0...v0.1.1)
|
13
52
|
|
14
|
-
## [v0.1.0](https://github.com/limitusus/toggl-jobcan/tree/v0.1.0) (2018-04-02)
|
15
53
|
|
16
54
|
|
17
|
-
\* *This
|
55
|
+
\* *This Changelog was automatically generated by [github_changelog_generator](https://github.com/github-changelog-generator/github-changelog-generator)*
|
data/Gemfile.lock
CHANGED
@@ -1,78 +1,178 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
toggl-jobcan (0.
|
5
|
-
chromedriver-helper
|
4
|
+
toggl-jobcan (0.4.2)
|
6
5
|
selenium-webdriver
|
7
|
-
|
6
|
+
thor
|
7
|
+
toggl-worktime (~> 0.4.0, >= 0.4.1)
|
8
|
+
webdrivers
|
8
9
|
|
9
10
|
GEM
|
10
11
|
remote: https://rubygems.org/
|
11
12
|
specs:
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
13
|
+
activesupport (6.1.4.1)
|
14
|
+
concurrent-ruby (~> 1.0, >= 1.0.2)
|
15
|
+
i18n (>= 1.6, < 2)
|
16
|
+
minitest (>= 5.1)
|
17
|
+
tzinfo (~> 2.0)
|
18
|
+
zeitwerk (~> 2.3)
|
19
|
+
addressable (2.8.0)
|
20
|
+
public_suffix (>= 2.0.2, < 5.0)
|
21
|
+
async (1.30.1)
|
22
|
+
console (~> 1.10)
|
23
|
+
nio4r (~> 2.3)
|
24
|
+
timers (~> 4.1)
|
25
|
+
async-http (0.56.5)
|
26
|
+
async (>= 1.25)
|
27
|
+
async-io (>= 1.28)
|
28
|
+
async-pool (>= 0.2)
|
29
|
+
protocol-http (~> 0.22.0)
|
30
|
+
protocol-http1 (~> 0.14.0)
|
31
|
+
protocol-http2 (~> 0.14.0)
|
32
|
+
async-http-faraday (0.11.0)
|
33
|
+
async-http (~> 0.42)
|
34
|
+
faraday
|
35
|
+
async-io (1.32.2)
|
36
|
+
async
|
37
|
+
async-pool (0.3.8)
|
38
|
+
async (>= 1.25)
|
39
|
+
awesome_print (1.9.2)
|
40
|
+
byebug (11.1.3)
|
41
|
+
childprocess (3.0.0)
|
42
|
+
coderay (1.1.3)
|
43
|
+
concurrent-ruby (1.1.9)
|
44
|
+
console (1.13.1)
|
45
|
+
fiber-local
|
46
|
+
diff-lcs (1.4.4)
|
47
|
+
faraday (1.8.0)
|
48
|
+
faraday-em_http (~> 1.0)
|
49
|
+
faraday-em_synchrony (~> 1.0)
|
50
|
+
faraday-excon (~> 1.1)
|
51
|
+
faraday-httpclient (~> 1.0.1)
|
52
|
+
faraday-net_http (~> 1.0)
|
53
|
+
faraday-net_http_persistent (~> 1.1)
|
54
|
+
faraday-patron (~> 1.0)
|
55
|
+
faraday-rack (~> 1.0)
|
24
56
|
multipart-post (>= 1.2, < 3)
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
57
|
+
ruby2_keywords (>= 0.0.4)
|
58
|
+
faraday-em_http (1.0.0)
|
59
|
+
faraday-em_synchrony (1.0.0)
|
60
|
+
faraday-excon (1.1.0)
|
61
|
+
faraday-http-cache (2.2.0)
|
62
|
+
faraday (>= 0.8)
|
63
|
+
faraday-httpclient (1.0.1)
|
64
|
+
faraday-net_http (1.0.1)
|
65
|
+
faraday-net_http_persistent (1.2.0)
|
66
|
+
faraday-patron (1.0.0)
|
67
|
+
faraday-rack (1.0.0)
|
68
|
+
fiber-local (1.0.0)
|
69
|
+
github_changelog_generator (1.16.4)
|
70
|
+
activesupport
|
71
|
+
async (>= 1.25.0)
|
72
|
+
async-http-faraday
|
73
|
+
faraday-http-cache
|
74
|
+
multi_json
|
75
|
+
octokit (~> 4.6)
|
76
|
+
rainbow (>= 2.2.1)
|
77
|
+
rake (>= 10.0)
|
78
|
+
i18n (1.8.10)
|
79
|
+
concurrent-ruby (~> 1.0)
|
80
|
+
logger (1.4.3)
|
81
|
+
method_source (1.0.0)
|
82
|
+
mini_portile2 (2.6.1)
|
83
|
+
minitest (5.14.4)
|
84
|
+
multi_json (1.15.0)
|
85
|
+
multipart-post (2.1.1)
|
86
|
+
nio4r (2.5.8)
|
87
|
+
nokogiri (1.12.5)
|
88
|
+
mini_portile2 (~> 2.6.1)
|
89
|
+
racc (~> 1.4)
|
90
|
+
octokit (4.21.0)
|
91
|
+
faraday (>= 0.9)
|
92
|
+
sawyer (~> 0.8.0, >= 0.5.3)
|
93
|
+
oj (3.13.8)
|
94
|
+
pastel (0.8.0)
|
95
|
+
tty-color (~> 0.5)
|
96
|
+
protocol-hpack (1.4.2)
|
97
|
+
protocol-http (0.22.5)
|
98
|
+
protocol-http1 (0.14.2)
|
99
|
+
protocol-http (~> 0.22)
|
100
|
+
protocol-http2 (0.14.2)
|
101
|
+
protocol-hpack (~> 1.4)
|
102
|
+
protocol-http (~> 0.18)
|
103
|
+
pry (0.14.1)
|
104
|
+
coderay (~> 1.1)
|
105
|
+
method_source (~> 1.0)
|
106
|
+
pry-byebug (3.8.0)
|
107
|
+
byebug (~> 11.0)
|
39
108
|
pry (~> 0.10)
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
rspec-
|
47
|
-
|
109
|
+
public_suffix (4.0.6)
|
110
|
+
racc (1.5.2)
|
111
|
+
rainbow (3.0.0)
|
112
|
+
rake (13.0.6)
|
113
|
+
rspec (3.10.0)
|
114
|
+
rspec-core (~> 3.10.0)
|
115
|
+
rspec-expectations (~> 3.10.0)
|
116
|
+
rspec-mocks (~> 3.10.0)
|
117
|
+
rspec-core (3.10.1)
|
118
|
+
rspec-support (~> 3.10.0)
|
119
|
+
rspec-expectations (3.10.1)
|
48
120
|
diff-lcs (>= 1.2.0, < 2.0)
|
49
|
-
rspec-support (~> 3.
|
50
|
-
rspec-mocks (3.
|
121
|
+
rspec-support (~> 3.10.0)
|
122
|
+
rspec-mocks (3.10.2)
|
51
123
|
diff-lcs (>= 1.2.0, < 2.0)
|
52
|
-
rspec-support (~> 3.
|
53
|
-
rspec-support (3.
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
124
|
+
rspec-support (~> 3.10.0)
|
125
|
+
rspec-support (3.10.2)
|
126
|
+
ruby2_keywords (0.0.5)
|
127
|
+
rubyzip (2.3.2)
|
128
|
+
sawyer (0.8.2)
|
129
|
+
addressable (>= 2.3.5)
|
130
|
+
faraday (> 0.8, < 2.0)
|
131
|
+
selenium-webdriver (3.142.7)
|
132
|
+
childprocess (>= 0.5, < 4.0)
|
133
|
+
rubyzip (>= 1.2.2)
|
134
|
+
strings (0.2.1)
|
135
|
+
strings-ansi (~> 0.2)
|
136
|
+
unicode-display_width (>= 1.5, < 3.0)
|
137
|
+
unicode_utils (~> 1.4)
|
138
|
+
strings-ansi (0.2.0)
|
139
|
+
thor (1.1.0)
|
140
|
+
timers (4.3.3)
|
141
|
+
toggl-worktime (0.4.1)
|
59
142
|
awesome_print
|
60
|
-
togglv8
|
61
|
-
|
143
|
+
togglv8-limitusus
|
144
|
+
tty-table
|
145
|
+
togglv8-limitusus (1.2.1)
|
62
146
|
faraday
|
63
147
|
logger
|
64
148
|
oj
|
149
|
+
tty-color (0.6.0)
|
150
|
+
tty-screen (0.8.1)
|
151
|
+
tty-table (0.12.0)
|
152
|
+
pastel (~> 0.8)
|
153
|
+
strings (~> 0.2.0)
|
154
|
+
tty-screen (~> 0.8)
|
155
|
+
tzinfo (2.0.4)
|
156
|
+
concurrent-ruby (~> 1.0)
|
157
|
+
unicode-display_width (2.1.0)
|
158
|
+
unicode_utils (1.4.0)
|
159
|
+
webdrivers (4.6.1)
|
160
|
+
nokogiri (~> 1.6)
|
161
|
+
rubyzip (>= 1.3.0)
|
162
|
+
selenium-webdriver (>= 3.0, < 4.0)
|
163
|
+
zeitwerk (2.4.2)
|
65
164
|
|
66
165
|
PLATFORMS
|
67
166
|
ruby
|
68
167
|
|
69
168
|
DEPENDENCIES
|
70
|
-
bundler (~>
|
169
|
+
bundler (~> 2.2.0)
|
170
|
+
github_changelog_generator
|
71
171
|
pry
|
72
172
|
pry-byebug
|
73
|
-
rake (~>
|
173
|
+
rake (~> 13.0)
|
74
174
|
rspec (~> 3.0)
|
75
175
|
toggl-jobcan!
|
76
176
|
|
77
177
|
BUNDLED WITH
|
78
|
-
|
178
|
+
2.2.28
|
data/README.md
CHANGED
@@ -1,5 +1,8 @@
|
|
1
1
|
# Toggl::Jobcan
|
2
2
|
|
3
|
+
![](https://img.shields.io/gem/v/toggl-jobcan.svg?style=popout)
|
4
|
+
[![Build Status](https://travis-ci.com/limitusus/toggl-jobcan.svg?branch=main)](https://travis-ci.com/limitusus/toggl-jobcan)
|
5
|
+
|
3
6
|
This gem provides `toggl-jobcan` command, which synchronises working time data in Toggl to JobCan.
|
4
7
|
|
5
8
|
This gem requires Ruby >= 2.5.
|
data/Rakefile
CHANGED
@@ -2,7 +2,15 @@
|
|
2
2
|
|
3
3
|
require 'bundler/gem_tasks'
|
4
4
|
require 'rspec/core/rake_task'
|
5
|
+
require 'github_changelog_generator/task'
|
5
6
|
|
6
7
|
RSpec::Core::RakeTask.new(:spec)
|
7
8
|
|
8
9
|
task default: :spec
|
10
|
+
|
11
|
+
GitHubChangelogGenerator::RakeTask.new :changelog do |config|
|
12
|
+
config.user = 'limitusus'
|
13
|
+
config.project = 'toggl-jobcan'
|
14
|
+
config.since_tag = 'v0.1.0'
|
15
|
+
config.future_release = '0.4.1'
|
16
|
+
end
|
data/exe/toggl-jobcan
CHANGED
@@ -4,61 +4,9 @@
|
|
4
4
|
lib = File.expand_path('../lib', __dir__)
|
5
5
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
6
6
|
|
7
|
-
require 'optparse'
|
8
|
-
|
9
|
-
require 'selenium-webdriver'
|
10
7
|
require 'toggl/jobcan'
|
11
8
|
|
12
|
-
|
13
|
-
|
14
|
-
Version = Toggl::Jobcan::VERSION
|
15
|
-
|
16
|
-
toggl_worktime_config = "#{ENV['HOME']}/.toggl_worktime"
|
17
|
-
dryrun = false
|
18
|
-
|
19
|
-
opt = OptionParser.new
|
20
|
-
opt.on('-c CONFIG', '--tw-config CONFIG') { |v| toggl_worktime_config = v }
|
21
|
-
opt.on('--dryrun') { |v| dryrun = v }
|
22
|
-
opt.parse!(ARGV)
|
23
|
-
|
24
|
-
raise RangeError, 'No dates given' if ARGV.empty?
|
25
|
-
|
26
|
-
target_days = ARGV.map do |s|
|
27
|
-
raise RangeError, 'Invalid format' unless s.match?(/\d#{8}/)
|
28
|
-
|
29
|
-
Date.parse(s)
|
30
|
-
end
|
31
|
-
|
32
|
-
puts '*** DRYRUN MODE ***' if dryrun
|
33
|
-
|
34
|
-
puts 'Target days:'
|
35
|
-
target_days.each do |date|
|
36
|
-
puts " - #{date.strftime('%F')}"
|
37
|
-
end
|
38
|
-
|
39
|
-
credentials = Toggl::Jobcan::Credentials.new(path: cred_file)
|
40
|
-
jobcan = Toggl::Jobcan::Client.new(
|
41
|
-
credentials: credentials,
|
42
|
-
toggl_worktime_config: toggl_worktime_config,
|
43
|
-
dryrun: dryrun
|
44
|
-
)
|
45
|
-
jobcan.login
|
46
|
-
|
47
|
-
puts 'Driver ready'
|
48
|
-
|
49
|
-
target_days.each do |date|
|
50
|
-
puts "Input date: #{date}"
|
51
|
-
working_times = jobcan.fetch_toggl_worktime(date).flatten
|
52
|
-
if working_times.any?(&:nil?)
|
53
|
-
puts 'Includes nil data: skip'
|
54
|
-
next
|
55
|
-
end
|
56
|
-
jobcan.navigate_to_attendance_modify_day(date)
|
57
|
-
jobcan.input_day_worktime(date, working_times)
|
58
|
-
sleep 1
|
59
|
-
puts " - Finish: #{date}; Total time: #{jobcan.toggl.total_time}"
|
60
|
-
end
|
61
|
-
|
62
|
-
jobcan.driver.quit
|
9
|
+
# Default action: main
|
10
|
+
%w[main version help].include?(ARGV[0]) || ARGV.unshift('main')
|
63
11
|
|
64
|
-
|
12
|
+
Toggl::Jobcan::Cli.start
|
@@ -0,0 +1,126 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'thor'
|
4
|
+
require 'optparse'
|
5
|
+
require 'selenium-webdriver'
|
6
|
+
|
7
|
+
module Toggl
|
8
|
+
module Jobcan
|
9
|
+
# CLI provider
|
10
|
+
class Cli < Thor
|
11
|
+
package_name 'toggl-jobcan'
|
12
|
+
default_command :main
|
13
|
+
|
14
|
+
DEFAULT_JOBCAN_CREDENTIAL_FILE_PATH = "#{ENV['HOME']}/.jobcan"
|
15
|
+
DEFAULT_TOGGL_WORKTIME_CONFIG_FILE_PATH = "#{ENV['HOME']}/.toggl_worktime"
|
16
|
+
|
17
|
+
desc(
|
18
|
+
'[options] DATE [DATE...]',
|
19
|
+
'Register worktime in Toggl into Jobcan for the given dates ' \
|
20
|
+
'("toggl-jobcan help main" for detailed usage)'
|
21
|
+
)
|
22
|
+
method_option(
|
23
|
+
:tw_config,
|
24
|
+
type: :string, aliases: '-c',
|
25
|
+
default: DEFAULT_TOGGL_WORKTIME_CONFIG_FILE_PATH,
|
26
|
+
banner: 'CONFIG', required: false,
|
27
|
+
desc: 'configuration file for toggl_worktime'
|
28
|
+
)
|
29
|
+
method_option(
|
30
|
+
:jc_credential,
|
31
|
+
type: :string, aliases: '-r',
|
32
|
+
default: DEFAULT_JOBCAN_CREDENTIAL_FILE_PATH,
|
33
|
+
banner: 'CREDENTIAL', required: false,
|
34
|
+
desc: 'credentials file for Jobcan'
|
35
|
+
)
|
36
|
+
method_option(
|
37
|
+
:days,
|
38
|
+
type: :boolean,
|
39
|
+
default: false,
|
40
|
+
desc: 'print days and exit'
|
41
|
+
)
|
42
|
+
method_option :dryrun, type: :boolean
|
43
|
+
def main(*args)
|
44
|
+
parse_args(args)
|
45
|
+
puts '*** DRYRUN MODE ***' if options[:dryrun]
|
46
|
+
|
47
|
+
show_target_days
|
48
|
+
return if options[:days]
|
49
|
+
|
50
|
+
prepare_jobcan
|
51
|
+
|
52
|
+
puts 'Driver ready'
|
53
|
+
register_days
|
54
|
+
|
55
|
+
jobcan.driver.quit
|
56
|
+
puts 'All Input finished'
|
57
|
+
end
|
58
|
+
|
59
|
+
map %w[--version -v] => :version
|
60
|
+
desc 'version', 'Show version.'
|
61
|
+
def version
|
62
|
+
puts "Version #{Toggl::Jobcan::VERSION}"
|
63
|
+
end
|
64
|
+
|
65
|
+
no_commands do # rubocop:disable Metrics/BlockLength
|
66
|
+
def initialize(*args)
|
67
|
+
super
|
68
|
+
@target_days = []
|
69
|
+
end
|
70
|
+
|
71
|
+
def parse_args(args)
|
72
|
+
@target_days = args.map do |s|
|
73
|
+
raise RangeError, "Invalid format #{s}" unless s.match?(/\d{8}/)
|
74
|
+
|
75
|
+
Date.parse(s)
|
76
|
+
end
|
77
|
+
raise NoDayGivenError if @target_days.size.zero?
|
78
|
+
end
|
79
|
+
|
80
|
+
def prepare_jobcan
|
81
|
+
@jc_credentials = Toggl::Jobcan::Credentials.new(
|
82
|
+
path: options[:jc_credential]
|
83
|
+
)
|
84
|
+
jobcan.login
|
85
|
+
end
|
86
|
+
|
87
|
+
def jobcan
|
88
|
+
@jobcan ||= Toggl::Jobcan::Client.new(
|
89
|
+
credentials: @jc_credentials,
|
90
|
+
toggl_worktime_config: options[:tw_config],
|
91
|
+
dryrun: options[:dryrun]
|
92
|
+
)
|
93
|
+
@jobcan
|
94
|
+
end
|
95
|
+
|
96
|
+
def show_target_days
|
97
|
+
puts 'Target days:'
|
98
|
+
@target_days.each do |date|
|
99
|
+
puts " - #{date.strftime('%F')}"
|
100
|
+
end
|
101
|
+
end
|
102
|
+
|
103
|
+
def register_days
|
104
|
+
@target_days.each do |date|
|
105
|
+
register_day(date)
|
106
|
+
end
|
107
|
+
end
|
108
|
+
|
109
|
+
def register_day(date)
|
110
|
+
puts "Input date: #{date}"
|
111
|
+
working_times = jobcan.fetch_toggl_worktime(date).flatten
|
112
|
+
if working_times.any?(&:nil?)
|
113
|
+
puts 'Includes nil data: skip'
|
114
|
+
return
|
115
|
+
end
|
116
|
+
jobcan.navigate_to_attendance_modify_day(date)
|
117
|
+
jobcan.input_day_worktime(date, working_times)
|
118
|
+
sleep 1
|
119
|
+
puts " - Finish: #{date}; Total time: #{jobcan.toggl.total_time}"
|
120
|
+
end
|
121
|
+
end
|
122
|
+
end
|
123
|
+
|
124
|
+
class NoDayGivenError < StandardError; end
|
125
|
+
end
|
126
|
+
end
|
data/lib/toggl/jobcan/version.rb
CHANGED
data/lib/toggl/jobcan.rb
CHANGED
data/toggl-jobcan.gemspec
CHANGED
@@ -22,12 +22,14 @@ Gem::Specification.new do |spec|
|
|
22
22
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
23
23
|
spec.require_paths = ['lib']
|
24
24
|
|
25
|
-
spec.add_dependency 'chromedriver-helper'
|
26
25
|
spec.add_dependency 'selenium-webdriver'
|
27
|
-
spec.add_dependency '
|
28
|
-
spec.
|
26
|
+
spec.add_dependency 'thor'
|
27
|
+
spec.add_dependency 'toggl-worktime', '~> 0.4.0', '>= 0.4.1'
|
28
|
+
spec.add_dependency 'webdrivers'
|
29
|
+
spec.add_development_dependency 'bundler', '~> 2.2.0'
|
30
|
+
spec.add_development_dependency 'github_changelog_generator'
|
29
31
|
spec.add_development_dependency 'pry'
|
30
32
|
spec.add_development_dependency 'pry-byebug'
|
31
|
-
spec.add_development_dependency 'rake', '~>
|
33
|
+
spec.add_development_dependency 'rake', '~> 13.0'
|
32
34
|
spec.add_development_dependency 'rspec', '~> 3.0'
|
33
35
|
end
|
metadata
CHANGED
@@ -1,17 +1,17 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: toggl-jobcan
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tomoya Kabe
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-09-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
name:
|
14
|
+
name: selenium-webdriver
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
@@ -25,7 +25,7 @@ dependencies:
|
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
|
-
name:
|
28
|
+
name: thor
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - ">="
|
@@ -44,34 +44,62 @@ dependencies:
|
|
44
44
|
requirements:
|
45
45
|
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: 0.
|
47
|
+
version: 0.4.0
|
48
48
|
- - ">="
|
49
49
|
- !ruby/object:Gem::Version
|
50
|
-
version: 0.
|
50
|
+
version: 0.4.1
|
51
51
|
type: :runtime
|
52
52
|
prerelease: false
|
53
53
|
version_requirements: !ruby/object:Gem::Requirement
|
54
54
|
requirements:
|
55
55
|
- - "~>"
|
56
56
|
- !ruby/object:Gem::Version
|
57
|
-
version: 0.
|
57
|
+
version: 0.4.0
|
58
|
+
- - ">="
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
version: 0.4.1
|
61
|
+
- !ruby/object:Gem::Dependency
|
62
|
+
name: webdrivers
|
63
|
+
requirement: !ruby/object:Gem::Requirement
|
64
|
+
requirements:
|
65
|
+
- - ">="
|
66
|
+
- !ruby/object:Gem::Version
|
67
|
+
version: '0'
|
68
|
+
type: :runtime
|
69
|
+
prerelease: false
|
70
|
+
version_requirements: !ruby/object:Gem::Requirement
|
71
|
+
requirements:
|
58
72
|
- - ">="
|
59
73
|
- !ruby/object:Gem::Version
|
60
|
-
version: 0
|
74
|
+
version: '0'
|
61
75
|
- !ruby/object:Gem::Dependency
|
62
76
|
name: bundler
|
63
77
|
requirement: !ruby/object:Gem::Requirement
|
64
78
|
requirements:
|
65
79
|
- - "~>"
|
66
80
|
- !ruby/object:Gem::Version
|
67
|
-
version:
|
81
|
+
version: 2.2.0
|
68
82
|
type: :development
|
69
83
|
prerelease: false
|
70
84
|
version_requirements: !ruby/object:Gem::Requirement
|
71
85
|
requirements:
|
72
86
|
- - "~>"
|
73
87
|
- !ruby/object:Gem::Version
|
74
|
-
version:
|
88
|
+
version: 2.2.0
|
89
|
+
- !ruby/object:Gem::Dependency
|
90
|
+
name: github_changelog_generator
|
91
|
+
requirement: !ruby/object:Gem::Requirement
|
92
|
+
requirements:
|
93
|
+
- - ">="
|
94
|
+
- !ruby/object:Gem::Version
|
95
|
+
version: '0'
|
96
|
+
type: :development
|
97
|
+
prerelease: false
|
98
|
+
version_requirements: !ruby/object:Gem::Requirement
|
99
|
+
requirements:
|
100
|
+
- - ">="
|
101
|
+
- !ruby/object:Gem::Version
|
102
|
+
version: '0'
|
75
103
|
- !ruby/object:Gem::Dependency
|
76
104
|
name: pry
|
77
105
|
requirement: !ruby/object:Gem::Requirement
|
@@ -106,14 +134,14 @@ dependencies:
|
|
106
134
|
requirements:
|
107
135
|
- - "~>"
|
108
136
|
- !ruby/object:Gem::Version
|
109
|
-
version: '
|
137
|
+
version: '13.0'
|
110
138
|
type: :development
|
111
139
|
prerelease: false
|
112
140
|
version_requirements: !ruby/object:Gem::Requirement
|
113
141
|
requirements:
|
114
142
|
- - "~>"
|
115
143
|
- !ruby/object:Gem::Version
|
116
|
-
version: '
|
144
|
+
version: '13.0'
|
117
145
|
- !ruby/object:Gem::Dependency
|
118
146
|
name: rspec
|
119
147
|
requirement: !ruby/object:Gem::Requirement
|
@@ -151,6 +179,7 @@ files:
|
|
151
179
|
- bin/setup
|
152
180
|
- exe/toggl-jobcan
|
153
181
|
- lib/toggl/jobcan.rb
|
182
|
+
- lib/toggl/jobcan/cli.rb
|
154
183
|
- lib/toggl/jobcan/client.rb
|
155
184
|
- lib/toggl/jobcan/credentials.rb
|
156
185
|
- lib/toggl/jobcan/toggl_support.rb
|
@@ -175,8 +204,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
175
204
|
- !ruby/object:Gem::Version
|
176
205
|
version: '0'
|
177
206
|
requirements: []
|
178
|
-
|
179
|
-
rubygems_version: 2.7.3
|
207
|
+
rubygems_version: 3.1.2
|
180
208
|
signing_key:
|
181
209
|
specification_version: 4
|
182
210
|
summary: Sync toggl worktime to JobCan.
|