kobot 2.0.0 → 2.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0e2452d15afce1b0ec273b240ab062cc526adedcf7f11ecaf98e7cbe3590d393
4
- data.tar.gz: 16f3f7fefbf4f30c621148841ba93aa57b8859cc5adb092edad02b3e6970e95c
3
+ metadata.gz: e51c45d51bed6c3e614f58f41e557a9da9ab4dd6d457419bf1f2d654bc0e8e6d
4
+ data.tar.gz: 6cf858d531f3ef1b990751a8c821fd13965f04b234191a324598c9eefc68ac6c
5
5
  SHA512:
6
- metadata.gz: 4ec4604ff3d7486b48bc574f3130f2856787d6cb46644ba11cf1832569590dfe5a6159518a8474390a28500f77cd506da58531981df855db8e0d220627bb6486
7
- data.tar.gz: 6f57f5fdf3e1f5186ca8ae60b6a482d555ca5a6e23004fec8f5bef324942001f7008fddfc96e93151c8ad88a9d17a99440bfef912540c2715a622433ea67b1a1
6
+ metadata.gz: 4f00479950ad49f878f85fc515e5cb337a0fe3b047fa49a8b94dd5bcf2b776008f24d168c122c6f651445a1a883084c56296d9a4b034e9693f66b6336422351a
7
+ data.tar.gz: c6dc7304b15f26a6ae39dcfd9e644c82081b22519d2b28469f6671e570c73c70baf91be0e30eb4950833330b1a39cf200d3c9722d819c57377ab678f9efa2e6c
data/CHANGELOG.md CHANGED
@@ -1,39 +1,42 @@
1
- ### v1.0.0
2
- - Initial release
1
+ ### v2.1.0
2
+ - Changed i18n identification strategy due to that KOT displays in Japanese even though the login screen is in English
3
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
4
+ ### v2.0.0
5
+ - Added -a, --auto-skip flag to support the enabling and disabling of auto-skipping feature
6
+ - Renamed the schedule config option from -a, --auto-skip-without to -w, --auto-skip-without
8
7
 
9
- ### v1.2.0
10
- - Added an option to allow forcibly running regardless of weekends or public holidays
11
- - Added an ENV flag to allow requiring lib in local workspace for development purpose
8
+ ### v1.3.0
9
+ - Added config option (-a, --auto-skip-without) to enable automatic skipping based on schedule
10
+ - Replaced deprecated options with capabilities option in Selenium driver initialization
11
+ - Refactored scattered attr_accessors and reduced instance variables count reported by Rubocop
12
12
 
13
- ### v1.2.1
14
- - Improved logging for better readability in logs
15
- - Switched to builtin Logger#deprecate from Logger#warn for deprecations
16
- - Renamed internal method to skip? from holiday? as it was meant for skipping any specified date
13
+ ### v1.2.5
14
+ - Added I18n support for both English and Japanese KOT UI
17
15
 
18
- ### v1.2.2
19
- - Improved login screen wait and logging
20
- - Applied fix for offenses about empty lines and long lines reported by Rubocop
16
+ ### v1.2.4
17
+ - Changed to use boolean values for validation instead of raising exceptions
21
18
 
22
19
  ### v1.2.3
23
20
  - Improved validation logic to skip running due to weekend or intentional skips
24
21
  - Refactored engine by reducing methods length based on reports by Rubocop
25
22
 
26
- ### v1.2.4
27
- - Changed to use boolean values for validation instead of raising exceptions
23
+ ### v1.2.2
24
+ - Improved login screen wait and logging
25
+ - Applied fix for offenses about empty lines and long lines reported by Rubocop
28
26
 
29
- ### v1.2.5
30
- - Added I18n support for both English and Japanese KOT UI
27
+ ### v1.2.1
28
+ - Improved logging for better readability in logs
29
+ - Switched to builtin Logger#deprecate from Logger#warn for deprecations
30
+ - Renamed internal method to skip? from holiday? as it was meant for skipping any specified date
31
31
 
32
- ### v1.3.0
33
- - Added config option (-a, --auto-skip-without) to enable automatic skipping based on schedule
34
- - Replaced deprecated options with capabilities option in Selenium driver initialization
35
- - Refactored scattered attr_accessors and reduced instance variables count reported by Rubocop
32
+ ### v1.2.0
33
+ - Added an option to allow forcibly running regardless of weekends or public holidays
34
+ - Added an ENV flag to allow requiring lib in local workspace for development purpose
36
35
 
37
- ### v2.0.0
38
- - Added -a, --auto-skip flag to support the enabling and disabling of auto-skipping feature
39
- - Renamed the schedule config option from -a, --auto-skip-without to -w, --auto-skip-without
36
+ ### v1.1.0
37
+ - Deprecated lower-case environment variables for credentials configuration
38
+ - Updated option help doc to indicate weekends and public holidays are skipped by default
39
+ - Updated required_ruby_version to be >= 2.4.0 to align with the webdrivers dependency
40
+
41
+ ### v1.0.0
42
+ - Initial release
data/lib/kobot/engine.rb CHANGED
@@ -100,13 +100,7 @@ module Kobot
100
100
  Kobot.logger.info("Navigate to: #{@top_url}")
101
101
  @browser.get @top_url
102
102
  @wait.until { @browser.find_element(id: 'modal_window') }
103
- modal_title_element = @wait.until { @browser.find_element(css: '.modal-title') }
104
- @selector = if modal_title_element.text.downcase.include? 'password'
105
- Selector.en
106
- else
107
- Selector.ja
108
- end
109
- Kobot.logger.info "Page title: #{@browser.title}"
103
+ Kobot.logger.info "Page title (before login): #{@browser.title}"
110
104
  Kobot.logger.debug do
111
105
  "Login with id=#{Credential.kot_id} and password=#{Credential.kot_password}"
112
106
  end
@@ -115,8 +109,20 @@ module Kobot
115
109
  @browser.find_element(css: 'div.btn-control-message').click
116
110
 
117
111
  Kobot.logger.info 'Login successful'
118
- @wait.until do
119
- @browser.find_element(id: 'notification_content').text.include?(@selector.login_success_notification_text)
112
+ clock_in_button = @wait.until { @browser.find_element(css: '.record-clock-in') }
113
+ @selector = if clock_in_button.text.include? '出勤'
114
+ Kobot.logger.info('Identify UI in Japanese')
115
+ Selector.ja
116
+ else
117
+ Kobot.logger.info('Identify UI in English')
118
+ Selector.en
119
+ end
120
+ begin
121
+ @wait.until do
122
+ @browser.find_element(id: 'notification_content').text.include?(@selector.login_success_notification_text)
123
+ end
124
+ rescue StandardError => e
125
+ Kobot.logger.warn "Failed to validate login success notification text: #{e.message}"
120
126
  end
121
127
  if Config.browser_geolocation
122
128
  begin
@@ -127,7 +133,7 @@ module Kobot
127
133
  Kobot.logger.warn "Get geolocation failed: #{e.message}"
128
134
  end
129
135
  end
130
- Kobot.logger.info "Page title: #{@browser.title}"
136
+ Kobot.logger.info "Page title (after login): #{@browser.title}"
131
137
  end
132
138
 
133
139
  def logout
@@ -153,7 +159,7 @@ module Kobot
153
159
  date_cell = tr.find_element(css: 'td.htBlock-scrollTable_day')
154
160
  next unless date_cell.text.include? @today
155
161
 
156
- Kobot.logger.info('Reading today record')
162
+ Kobot.logger.info('Read today record')
157
163
  @kot_data = {}
158
164
  @kot_data[:today] = date_cell.text
159
165
  @kot_data[:today_css_class] = date_cell.attribute('class')
data/lib/kobot/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Kobot
4
- VERSION = '2.0.0'
4
+ VERSION = '2.1.0'
5
5
  end
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: 2.0.0
4
+ version: 2.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andy Jiang
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-12-09 00:00:00.000000000 Z
11
+ date: 2022-01-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: webdrivers
@@ -93,7 +93,7 @@ metadata:
93
93
  homepage_uri: https://github.com/yuan-jiang/kobot
94
94
  source_code_uri: https://github.com/yuan-jiang/kobot
95
95
  changelog_uri: https://github.com/yuan-jiang/kobot/blob/master/CHANGELOG.md
96
- post_install_message:
96
+ post_install_message:
97
97
  rdoc_options: []
98
98
  require_paths:
99
99
  - lib
@@ -108,8 +108,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
108
108
  - !ruby/object:Gem::Version
109
109
  version: '0'
110
110
  requirements: []
111
- rubygems_version: 3.1.2
112
- signing_key:
111
+ rubygems_version: 3.2.32
112
+ signing_key:
113
113
  specification_version: 4
114
114
  summary: Kobot automates the clock in/out of KING OF TIME.
115
115
  test_files: []