toggl-jobcan 0.3.1 → 0.4.0
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/CHANGELOG.md +7 -0
- data/Gemfile.lock +19 -20
- data/exe/toggl-jobcan +3 -55
- data/lib/toggl/jobcan.rb +1 -0
- 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/toggl-jobcan.gemspec +2 -1
- metadata +19 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 949c32514cbce938b26e91fe48eceb4033fb992f951fd5e3acc04dd2fe55a8fb
|
4
|
+
data.tar.gz: e84549b66520109801009354cdc5d95d02be579f85d8e8fdd8b7826df8f9ea42
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 36b60237831926d3d95d7d8dbef01b3effc2da31f1376177591cc470f09c594d14aa8635578fac895c979e4632da09e84ee6167b8fe2134536ebda700632e1ad
|
7
|
+
data.tar.gz: f187d5b17bc6658f274824c4713f7e59be6540a8cc960a4b75344daf4fb661220eafdecfb17d5a20d4618e4d0340c25a337bfb897f1b9dd61d1c2d89138df05a
|
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/CHANGELOG.md
CHANGED
@@ -1,5 +1,12 @@
|
|
1
1
|
# Change Log
|
2
2
|
|
3
|
+
## [v0.3.1](https://github.com/limitusus/toggl-jobcan/tree/v0.3.1) (2019-02-01)
|
4
|
+
[Full Changelog](https://github.com/limitusus/toggl-jobcan/compare/v0.3.0...v0.3.1)
|
5
|
+
|
6
|
+
**Merged pull requests:**
|
7
|
+
|
8
|
+
- Fix bug from 2019 [\#4](https://github.com/limitusus/toggl-jobcan/pull/4) ([limitusus](https://github.com/limitusus))
|
9
|
+
|
3
10
|
## [v0.3.0](https://github.com/limitusus/toggl-jobcan/tree/v0.3.0) (2018-09-26)
|
4
11
|
[Full Changelog](https://github.com/limitusus/toggl-jobcan/compare/v0.2.0...v0.3.0)
|
5
12
|
|
data/Gemfile.lock
CHANGED
@@ -1,41 +1,35 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
toggl-jobcan (0.
|
5
|
-
chromedriver-helper
|
4
|
+
toggl-jobcan (0.4.0)
|
6
5
|
selenium-webdriver
|
6
|
+
thor
|
7
7
|
toggl-worktime (~> 0.3.0, >= 0.3.2)
|
8
|
+
webdrivers
|
8
9
|
|
9
10
|
GEM
|
10
11
|
remote: https://rubygems.org/
|
11
12
|
specs:
|
12
|
-
archive-zip (0.11.0)
|
13
|
-
io-like (~> 0.3.0)
|
14
13
|
awesome_print (1.8.0)
|
15
|
-
byebug (
|
16
|
-
childprocess (0.
|
17
|
-
|
18
|
-
chromedriver-helper (2.1.0)
|
19
|
-
archive-zip (~> 0.10)
|
20
|
-
nokogiri (~> 1.8)
|
14
|
+
byebug (11.0.1)
|
15
|
+
childprocess (1.0.1)
|
16
|
+
rake (< 13.0)
|
21
17
|
coderay (1.1.2)
|
22
18
|
diff-lcs (1.3)
|
23
19
|
faraday (0.15.4)
|
24
20
|
multipart-post (>= 1.2, < 3)
|
25
|
-
ffi (1.10.0)
|
26
|
-
io-like (0.3.0)
|
27
21
|
logger (1.3.0)
|
28
22
|
method_source (0.9.2)
|
29
23
|
mini_portile2 (2.4.0)
|
30
|
-
multipart-post (2.
|
31
|
-
nokogiri (1.10.
|
24
|
+
multipart-post (2.1.1)
|
25
|
+
nokogiri (1.10.3)
|
32
26
|
mini_portile2 (~> 2.4.0)
|
33
|
-
oj (3.7.
|
27
|
+
oj (3.7.12)
|
34
28
|
pry (0.12.2)
|
35
29
|
coderay (~> 1.1.0)
|
36
30
|
method_source (~> 0.9.0)
|
37
|
-
pry-byebug (3.
|
38
|
-
byebug (~>
|
31
|
+
pry-byebug (3.7.0)
|
32
|
+
byebug (~> 11.0)
|
39
33
|
pry (~> 0.10)
|
40
34
|
rake (10.5.0)
|
41
35
|
rspec (3.8.0)
|
@@ -44,7 +38,7 @@ GEM
|
|
44
38
|
rspec-mocks (~> 3.8.0)
|
45
39
|
rspec-core (3.8.0)
|
46
40
|
rspec-support (~> 3.8.0)
|
47
|
-
rspec-expectations (3.8.
|
41
|
+
rspec-expectations (3.8.3)
|
48
42
|
diff-lcs (>= 1.2.0, < 2.0)
|
49
43
|
rspec-support (~> 3.8.0)
|
50
44
|
rspec-mocks (3.8.0)
|
@@ -52,9 +46,10 @@ GEM
|
|
52
46
|
rspec-support (~> 3.8.0)
|
53
47
|
rspec-support (3.8.0)
|
54
48
|
rubyzip (1.2.2)
|
55
|
-
selenium-webdriver (3.
|
56
|
-
childprocess (
|
49
|
+
selenium-webdriver (3.142.3)
|
50
|
+
childprocess (>= 0.5, < 2.0)
|
57
51
|
rubyzip (~> 1.2, >= 1.2.2)
|
52
|
+
thor (0.20.3)
|
58
53
|
toggl-worktime (0.3.2)
|
59
54
|
awesome_print
|
60
55
|
togglv8
|
@@ -62,6 +57,10 @@ GEM
|
|
62
57
|
faraday
|
63
58
|
logger
|
64
59
|
oj
|
60
|
+
webdrivers (3.9.4)
|
61
|
+
nokogiri (~> 1.6)
|
62
|
+
rubyzip (~> 1.0)
|
63
|
+
selenium-webdriver (~> 3.0)
|
65
64
|
|
66
65
|
PLATFORMS
|
67
66
|
ruby
|
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 #{s}" 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
|
data/lib/toggl/jobcan.rb
CHANGED
@@ -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/toggl-jobcan.gemspec
CHANGED
@@ -22,9 +22,10 @@ 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'
|
26
|
+
spec.add_dependency 'thor'
|
27
27
|
spec.add_dependency 'toggl-worktime', '~> 0.3.0', '>= 0.3.2'
|
28
|
+
spec.add_dependency 'webdrivers'
|
28
29
|
spec.add_development_dependency 'bundler', '~> 1.16'
|
29
30
|
spec.add_development_dependency 'pry'
|
30
31
|
spec.add_development_dependency 'pry-byebug'
|
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.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tomoya Kabe
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-05-22 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
|
- - ">="
|
@@ -58,6 +58,20 @@ dependencies:
|
|
58
58
|
- - ">="
|
59
59
|
- !ruby/object:Gem::Version
|
60
60
|
version: 0.3.2
|
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:
|
72
|
+
- - ">="
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
version: '0'
|
61
75
|
- !ruby/object:Gem::Dependency
|
62
76
|
name: bundler
|
63
77
|
requirement: !ruby/object:Gem::Requirement
|
@@ -151,6 +165,7 @@ files:
|
|
151
165
|
- bin/setup
|
152
166
|
- exe/toggl-jobcan
|
153
167
|
- lib/toggl/jobcan.rb
|
168
|
+
- lib/toggl/jobcan/cli.rb
|
154
169
|
- lib/toggl/jobcan/client.rb
|
155
170
|
- lib/toggl/jobcan/credentials.rb
|
156
171
|
- lib/toggl/jobcan/toggl_support.rb
|