kobot 1.0.0 → 1.1.0
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/CHANGELOG.md +5 -0
- data/README.md +24 -15
- data/kobot.gemspec +1 -1
- data/lib/kobot/credential.rb +10 -6
- data/lib/kobot/option.rb +2 -1
- data/lib/kobot/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 00f2c1151ffcb202b20d4b3f9881c9570b1075ea3684f7ab3ea2cfc65baf4b33
|
4
|
+
data.tar.gz: a6f3da0260abbbfce192557ea580526698b828ed19ec7175dd64080fa437ba35
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4fb7e982db990bdbf659009501f3eb028d02fdddf7e8d6ea48762495867196f5dfc748c6d14926d5239b57c4433dad3d2568c8d6ca9bf42d6de401b91391e7a3
|
7
|
+
data.tar.gz: '06482f411bfbf8f0083d0750e7d8ea4074f6740de3e9b1d6ba27c3e850356cd28c39d83d3a27f5d99bf7e21589cce65d64396793ffd018180ec621f926db7327'
|
data/CHANGELOG.md
CHANGED
@@ -1,2 +1,7 @@
|
|
1
1
|
### v1.0.0
|
2
2
|
- Initial release
|
3
|
+
|
4
|
+
### v1.1.0
|
5
|
+
- Deprecated lower-case environment variables for credentials configuration
|
6
|
+
- Updated option help doc to indicate weekends and public holidays are skipped by default
|
7
|
+
- Updated required_ruby_version to be >= 2.4.0 to align with the webdrivers dependency
|
data/README.md
CHANGED
@@ -1,8 +1,9 @@
|
|
1
|
-
# Kobot
|
1
|
+
# Kobot [](https://badge.fury.io/rb/kobot)
|
2
2
|
|
3
3
|
Kobot is a simple tool to automate the clock in or clock out operation on the web service
|
4
|
-
provided by [KING OF TIME](kingtime.jp) by leveraging [Selenium WebDriver](
|
5
|
-
and with Google Gmail service email
|
4
|
+
provided by [KING OF TIME](https://www.kingtime.jp/) by leveraging [Selenium WebDriver](
|
5
|
+
https://www.selenium.dev/), and with Google Gmail service email notifications can also be
|
6
|
+
sent to notify the results.
|
6
7
|
|
7
8
|
It is meant for use only by one working under the discretionary labor system or flexible
|
8
9
|
hours where the daily record is still required regardless of the actual start or end time
|
@@ -21,10 +22,11 @@ Tested on macOS Catelina and runs on Heroku platform so it works on unix-like sy
|
|
21
22
|
#### Configuration
|
22
23
|
|
23
24
|
By default it uses `~/.kobot` file locally to persist credentials for reuse, but all credentials
|
24
|
-
can be overridden by
|
25
|
-
|
26
|
-
|
27
|
-
so there is no need to manually prepare the file beforehand
|
25
|
+
can also be supplied or overridden by runtime environment variables, which is the recommended way
|
26
|
+
of running as scheduled jobs on platforms like Heroku. When running for the first time, if neither
|
27
|
+
the configuration file nor ENV satisfies all required credentials, `an interactive prompt will be
|
28
|
+
displayed for initial setting, so there is no need to manually prepare the file beforehand`. The
|
29
|
+
content looks something like:
|
28
30
|
```property
|
29
31
|
kot_id=xxx
|
30
32
|
kot_password=xxx
|
@@ -34,6 +36,7 @@ Gmail account and password (or `app` password if MFA is on) are asked when notif
|
|
34
36
|
gmail_id=xxx
|
35
37
|
gmail_password=xxx
|
36
38
|
```
|
39
|
+
Note: use all upper-case letters for the above variables if using environment variables, e.g. `KOT_ID`.
|
37
40
|
|
38
41
|
#### Google Chrome browser
|
39
42
|
|
@@ -51,13 +54,14 @@ $ gem install kobot
|
|
51
54
|
## Usage
|
52
55
|
|
53
56
|
Get help doc:
|
54
|
-
```
|
57
|
+
```
|
55
58
|
$ kobot -h
|
56
59
|
Usage: kobot [options]
|
57
60
|
-c, --clock CLOCK The clock action: in, out
|
58
61
|
-l, --loglevel [LEVEL] Specify log level: debug, info, warn, error. Default is info
|
59
62
|
-s, --skip [D1,D2,D3] Specify dates to skip clock in/out with date format YYYY-MM-DD and
|
60
63
|
multiple values separated by comma, such as: 2020-05-01,2020-12-31
|
64
|
+
Weekends and public holidays in Japan are skipped by default.
|
61
65
|
-t, --to [TO] Email address to send notification to. By default it is sent to
|
62
66
|
the same self email account used in SMTP config as the sender
|
63
67
|
-n, --notify Enable email notification
|
@@ -69,20 +73,25 @@ Usage: kobot [options]
|
|
69
73
|
```
|
70
74
|
|
71
75
|
Dryrun to try out:
|
72
|
-
```
|
73
|
-
$ kobot --clock in --dryrun
|
76
|
+
```
|
77
|
+
$ kobot --clock in --notify --dryrun
|
74
78
|
```
|
75
79
|
|
76
80
|
Clock in/out with email notification
|
77
|
-
```
|
78
|
-
$ kobot --clock in --notify
|
79
|
-
$ kobot --clock out --notify
|
81
|
+
```
|
82
|
+
$ kobot --clock in --notify --headless
|
83
|
+
$ kobot --clock out --notify --headless
|
80
84
|
```
|
81
85
|
|
82
86
|
Run the task with crontab
|
83
87
|
```cron
|
84
|
-
|
85
|
-
30
|
88
|
+
# Weekend and public holidays will be skipped by default
|
89
|
+
30 09 * * * user kobot --cin -n -x
|
90
|
+
30 18 * * * user kobot --cout -n -x
|
91
|
+
|
92
|
+
# Skip for weekdays planned to take leave for example
|
93
|
+
30 09 * * * user kobot --cin -n -x -s 2020-09-01,2020-11-11
|
94
|
+
30 18 * * * user kobot --cout -n -x -s 2020-09-01,2020-11-11
|
86
95
|
```
|
87
96
|
On platforms like Heroku, an add-on called [Heroku Scheduler](https://elements.heroku.com/addons/scheduler) makes
|
88
97
|
running scheduled tasks much easier. Tips: either clock in or clock out task can be scheduled multiple times in
|
data/kobot.gemspec
CHANGED
@@ -17,7 +17,7 @@ Gem::Specification.new do |spec|
|
|
17
17
|
|
18
18
|
spec.homepage = 'https://github.com/yuan-jiang/kobot'
|
19
19
|
spec.license = 'MIT'
|
20
|
-
spec.required_ruby_version = Gem::Requirement.new('>= 2.
|
20
|
+
spec.required_ruby_version = Gem::Requirement.new('>= 2.4.0')
|
21
21
|
|
22
22
|
spec.metadata['allowed_push_host'] = 'https://rubygems.org/'
|
23
23
|
spec.metadata['homepage_uri'] = spec.homepage
|
data/lib/kobot/credential.rb
CHANGED
@@ -41,18 +41,22 @@ module Kobot
|
|
41
41
|
if File.exist? Config.credentials_file
|
42
42
|
File.open(Config.credentials_file) do |file|
|
43
43
|
file.each do |line|
|
44
|
-
attr, value = line.
|
44
|
+
attr, value = line.strip.split('=')
|
45
45
|
@credentials[attr] = value
|
46
46
|
end
|
47
47
|
end
|
48
48
|
end
|
49
|
-
@credentials['kot_id'] = ENV['kot_id'] if ENV['kot_id']
|
50
|
-
@credentials['kot_password'] = ENV['kot_password'] if ENV['kot_password']
|
51
|
-
@credentials['gmail_id'] = ENV['gmail_id'] if ENV['gmail_id']
|
52
|
-
@credentials['gmail_password'] = ENV['gmail_password'] if ENV['gmail_password']
|
53
|
-
|
54
49
|
required_credentials = %w[kot_id kot_password]
|
55
50
|
required_credentials.concat %w[gmail_id gmail_password] if Config.gmail_notify_enabled
|
51
|
+
required_credentials.each do |attr|
|
52
|
+
if ENV[attr]
|
53
|
+
Kobot.logger.warn(
|
54
|
+
"[DEPRECATION] lower-case ENV variable is deprecated, please use #{attr.upcase} instead."
|
55
|
+
)
|
56
|
+
end
|
57
|
+
env_attr_value = ENV[attr.upcase] || ENV[attr]
|
58
|
+
@credentials[attr] = env_attr_value if env_attr_value
|
59
|
+
end
|
56
60
|
required_credentials.none? do |attr|
|
57
61
|
credential = @credentials[attr]
|
58
62
|
!credential || credential.strip.empty?
|
data/lib/kobot/option.rb
CHANGED
@@ -24,7 +24,8 @@ module Kobot
|
|
24
24
|
|
25
25
|
opt.on('-s', '--skip [D1,D2,D3]', Array,
|
26
26
|
'Specify dates to skip clock in/out with date format YYYY-MM-DD and',
|
27
|
-
'multiple values separated by comma, such as: 2020-05-01,2020-12-31'
|
27
|
+
'multiple values separated by comma, such as: 2020-05-01,2020-12-31',
|
28
|
+
'Weekends and public holidays in Japan are skipped by default.') do |skip|
|
28
29
|
options[:skip] = skip
|
29
30
|
end
|
30
31
|
|
data/lib/kobot/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: kobot
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andy Jiang
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-08-
|
11
|
+
date: 2020-08-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: webdrivers
|
@@ -100,7 +100,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
100
100
|
requirements:
|
101
101
|
- - ">="
|
102
102
|
- !ruby/object:Gem::Version
|
103
|
-
version: 2.
|
103
|
+
version: 2.4.0
|
104
104
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
105
105
|
requirements:
|
106
106
|
- - ">="
|