kobot 1.2.2 → 1.2.3
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 +4 -0
- data/lib/kobot/engine.rb +22 -20
- data/lib/kobot/exception.rb +3 -0
- data/lib/kobot/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3eba14b1e3b076a368dd700c2ac46a9db4fd13bf57a58e29797de7db7eb16fc3
|
4
|
+
data.tar.gz: 1926333cefbaf4272ae117cc7afb12284ed85d6ff41aa96a02094904599b5312
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '08ad9cb2d55c2931a34ed4243884a7e16c189d1d914e5aa935cfd4d32fc3d3d7567cdaecdb53de54e980e84ec4c6e696761b7f9b15fb65e3a0eef11f829370e5'
|
7
|
+
data.tar.gz: f8662e41fe53d35df04b1b530f946621330124684d6bd955e6b18e53830efaef74c22db66818a8a3958aa8a4745b4d37090419f538962c3a4876e8dbb9b6c1d7
|
data/CHANGELOG.md
CHANGED
@@ -18,3 +18,7 @@
|
|
18
18
|
### v1.2.2
|
19
19
|
- Improved login screen wait and logging
|
20
20
|
- Applied fix for offenses about empty lines and long lines reported by Rubocop
|
21
|
+
|
22
|
+
### v1.2.3
|
23
|
+
- Improved validation logic to skip running due to weekend or intentional skips
|
24
|
+
- Refactored engine by reducing methods length based on reports by Rubocop
|
data/lib/kobot/engine.rb
CHANGED
@@ -24,32 +24,19 @@ module Kobot
|
|
24
24
|
# System errors or any unknown exceptions occurred if any are
|
25
25
|
# to be popped up and should be handled by the outside caller.
|
26
26
|
def start
|
27
|
-
|
28
|
-
if Config.force
|
29
|
-
Kobot.logger.info("[Force] should have exited: today=#{@today} is weekend")
|
30
|
-
else
|
31
|
-
Kobot.logger.info("Today=#{@today} is weekend")
|
32
|
-
return
|
33
|
-
end
|
34
|
-
end
|
35
|
-
if skip?
|
36
|
-
Kobot.logger.info("Today=#{@today} is skipped as per: --skip=#{Config.skip}")
|
37
|
-
return
|
38
|
-
end
|
39
|
-
unless %i[in out].include? Config.clock
|
40
|
-
Kobot.logger.warn("Invalid clock operation: #{Config.clock}")
|
41
|
-
return
|
42
|
-
end
|
27
|
+
validate_today!
|
43
28
|
launch_browser
|
44
29
|
login
|
45
30
|
read_today_record
|
46
|
-
|
31
|
+
validate_today_record!
|
47
32
|
if Config.clock == :in
|
48
33
|
clock_in!
|
49
34
|
else
|
50
35
|
clock_out!
|
51
36
|
end
|
52
37
|
logout
|
38
|
+
rescue KotSkip => e
|
39
|
+
Kobot.logger.warn(e.message)
|
53
40
|
rescue KotRecordError => e
|
54
41
|
Kobot.logger.warn(e.message)
|
55
42
|
Mailer.send(clock_notify_message(status: e.message))
|
@@ -68,12 +55,20 @@ module Kobot
|
|
68
55
|
Mailer.send(clock_notify_message(status: e.message))
|
69
56
|
logout
|
70
57
|
ensure
|
71
|
-
|
72
|
-
@browser&.quit
|
58
|
+
close_browser
|
73
59
|
end
|
74
60
|
|
75
61
|
private
|
76
62
|
|
63
|
+
def validate_today!
|
64
|
+
raise KotSkip, "Today=#{@today} is skipped as per: --skip=#{Config.skip}" if skip?
|
65
|
+
|
66
|
+
return unless weekend?
|
67
|
+
raise KotSkip, "Today=#{@today} is weekend" unless Config.force
|
68
|
+
|
69
|
+
Kobot.logger.info("[Force] should have exited: today=#{@today} is weekend")
|
70
|
+
end
|
71
|
+
|
77
72
|
def launch_browser
|
78
73
|
prefs = {
|
79
74
|
profile: {
|
@@ -89,6 +84,13 @@ module Kobot
|
|
89
84
|
Kobot.logger.info('Launch browser successful')
|
90
85
|
end
|
91
86
|
|
87
|
+
def close_browser
|
88
|
+
return unless @browser
|
89
|
+
|
90
|
+
Kobot.logger.info('Close browser')
|
91
|
+
@browser.quit
|
92
|
+
end
|
93
|
+
|
92
94
|
def login
|
93
95
|
Kobot.logger.info("Navigate to: #{@top_url}")
|
94
96
|
@browser.get @top_url
|
@@ -159,7 +161,7 @@ module Kobot
|
|
159
161
|
end
|
160
162
|
end
|
161
163
|
|
162
|
-
def
|
164
|
+
def validate_today_record!
|
163
165
|
raise KotRecordError, "Today=#{@today} is not found on kot" if @kot_today.strip.empty?
|
164
166
|
|
165
167
|
if kot_weekend?
|
data/lib/kobot/exception.rb
CHANGED
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.2.
|
4
|
+
version: 1.2.3
|
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-09-
|
11
|
+
date: 2020-09-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: webdrivers
|