kobot 1.2.0 → 1.2.1

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: c867dcb791e15db7a407fc9dc0898ad49e9dccba53514f98ad32b253f1fc8adc
4
- data.tar.gz: 6887ebe669b7628a7972a89d2b508b498f5ce856fe80d98e85a52c3bcedfd377
3
+ metadata.gz: dfc009d1da0376709ddb63ebec8176601a53cee00bc216c82554c403051d430f
4
+ data.tar.gz: d7df58f052b9e2e945efd43c5cb11169c20d00b7d09a5d25ebfd3b688d1e16e8
5
5
  SHA512:
6
- metadata.gz: 8ed4028a1a25f75cfa21370c41b72a7fbe66916c442279f7985b3dc6f1be6e540395b81292931549b53496b7db026ec0ca33f9c743623176207d31bf1b740aa4
7
- data.tar.gz: b53a002259ad6312ae6437d11320b9b12f8d62e3ac26a01ed4e3dc48399cfb9d2f572384aebc2c3930014bf77e83c6351c7e7cf051b5eab02a87db33e31f7f51
6
+ metadata.gz: 7728891bc95db5eb4dd2d9a4c4d20916930da12b32c82af6ee2458d4cb9e66a7c37cb4156a89f857b93141c22d06493b7f9bce4f5238786d0031bf8b0f64d0a6
7
+ data.tar.gz: e4bc4ae0867ecfbe3bdd1018c9ffb9c578f34bf189f820e7344bbca7a7d5f209faee49e73d45f737161993cb2b3ea2f006695ee7f9870ea0dd1f7dea7417ad64
@@ -9,3 +9,8 @@
9
9
  ### v1.2.0
10
10
  - Added an option to allow forcibly running regardless of weekends or public holidays
11
11
  - Added an ENV flag to allow requiring lib in local workspace for development purpose
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
@@ -30,7 +30,7 @@ module Kobot
30
30
  @credentials.each do |attr, value|
31
31
  send("#{attr}=".to_sym, value)
32
32
  end
33
- Kobot.logger.info('Credentials load successful')
33
+ Kobot.logger.info('Load credentials successful')
34
34
  Kobot.logger.debug(@credentials)
35
35
  end
36
36
 
@@ -49,11 +49,7 @@ module Kobot
49
49
  required_credentials = %w[kot_id kot_password]
50
50
  required_credentials.concat %w[gmail_id gmail_password] if Config.gmail_notify_enabled
51
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
52
+ Kobot.logger.deprecate(attr, attr.upcase) if ENV[attr]
57
53
  env_attr_value = ENV[attr.upcase] || ENV[attr]
58
54
  @credentials[attr] = env_attr_value if env_attr_value
59
55
  end
@@ -33,8 +33,8 @@ module Kobot
33
33
  return
34
34
  end
35
35
  end
36
- if holiday?
37
- Kobot.logger.info("Today=#{@today} is holiday")
36
+ if skip?
37
+ Kobot.logger.info("Today=#{@today} is skipped as per: --skip=#{Config.skip}")
38
38
  return
39
39
  end
40
40
  unless %i[in out].include? Config.clock
@@ -69,6 +69,7 @@ module Kobot
69
69
  Mailer.send(clock_notify_message(status: e.message))
70
70
  logout
71
71
  ensure
72
+ Kobot.logger.info('Close browser')
72
73
  @browser&.quit
73
74
  end
74
75
 
@@ -90,8 +91,8 @@ module Kobot
90
91
  end
91
92
 
92
93
  def login
93
- @browser.get @top_url
94
94
  Kobot.logger.info("Navigate to: #{@top_url}")
95
+ @browser.get @top_url
95
96
  Kobot.logger.debug do
96
97
  "Login with id=#{Credential.kot_id} and password=#{Credential.kot_password}"
97
98
  end
@@ -108,13 +109,15 @@ module Kobot
108
109
  Kobot.logger.warn "Get geolocation failed: #{e.message}"
109
110
  end
110
111
  end
111
- Kobot.logger.info @browser.title
112
+ Kobot.logger.info "Page title: #{@browser.title}"
112
113
  end
113
114
 
114
115
  def logout
115
116
  if @browser.current_url.include? 'admin'
117
+ Kobot.logger.info('Logout from タイムカード page')
116
118
  @browser.find_element(css: 'div.htBlock-header_logoutButton').click
117
119
  else
120
+ Kobot.logger.info('Logout from Myレコーダー page')
118
121
  @wait.until { @browser.find_element(id: 'menu_icon') }.click
119
122
  @wait.until { @browser.find_element(link: 'ログアウト') }.click
120
123
  @browser.switch_to.alert.accept
@@ -123,6 +126,7 @@ module Kobot
123
126
  end
124
127
 
125
128
  def read_today_record
129
+ Kobot.logger.info('Navigate to タイムカード page')
126
130
  @wait.until { @browser.find_element(id: 'menu_icon') }.click
127
131
  @wait.until { @browser.find_element(link: 'タイムカード') }.click
128
132
 
@@ -216,21 +220,25 @@ module Kobot
216
220
  end
217
221
 
218
222
  def click_clock_in_button
223
+ Kobot.logger.info("Navigate to: #{@top_url}")
219
224
  @browser.get @top_url
220
225
  clock_in_button = @wait.until { @browser.find_element(css: 'div.record-clock-in') }
221
226
  if Config.dryrun
222
227
  Kobot.logger.info('[Dryrun] clock in button (出勤) would have been clicked')
223
228
  else
229
+ Kobot.logger.info('Clicking the clock in button (出勤)')
224
230
  clock_in_button.click
225
231
  end
226
232
  end
227
233
 
228
234
  def click_clock_out_button
235
+ Kobot.logger.info("Navigate to: #{@top_url}")
229
236
  @browser.get @top_url
230
237
  clock_out_button = @wait.until { @browser.find_element(css: 'div.record-clock-out') }
231
238
  if Config.dryrun
232
239
  Kobot.logger.info('[Dryrun] clock out button (退勤) would have been clicked')
233
240
  else
241
+ Kobot.logger.info('Clicking the clock in button (退勤)')
234
242
  clock_out_button.click
235
243
  end
236
244
  end
@@ -239,7 +247,7 @@ module Kobot
239
247
  @now.saturday? || @now.sunday?
240
248
  end
241
249
 
242
- def holiday?
250
+ def skip?
243
251
  return false unless Config.skip
244
252
  return false unless Config.skip.respond_to? :include?
245
253
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Kobot
4
- VERSION = '1.2.0'
4
+ VERSION = '1.2.1'
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: 1.2.0
4
+ version: 1.2.1
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-22 00:00:00.000000000 Z
11
+ date: 2020-08-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: webdrivers