kobot 1.2.1 → 1.2.2

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: dfc009d1da0376709ddb63ebec8176601a53cee00bc216c82554c403051d430f
4
- data.tar.gz: d7df58f052b9e2e945efd43c5cb11169c20d00b7d09a5d25ebfd3b688d1e16e8
3
+ metadata.gz: c5280569d35d3db17de90830bc1b6b2fa7fd4ec17c1b3efae0772a2329288fbe
4
+ data.tar.gz: 51a08ceb2e07e577a503e6c5bbd17352e664612a9b6ae6fd6e3ca9aedc56a71e
5
5
  SHA512:
6
- metadata.gz: 7728891bc95db5eb4dd2d9a4c4d20916930da12b32c82af6ee2458d4cb9e66a7c37cb4156a89f857b93141c22d06493b7f9bce4f5238786d0031bf8b0f64d0a6
7
- data.tar.gz: e4bc4ae0867ecfbe3bdd1018c9ffb9c578f34bf189f820e7344bbca7a7d5f209faee49e73d45f737161993cb2b3ea2f006695ee7f9870ea0dd1f7dea7417ad64
6
+ metadata.gz: 9ce2200116a9c36f384edbc2a0a2b47b37819ddb44fb8f590a1a1af1afd0859ea4d56c2022c4990f720f9bbd42eb4aaaf26986333298ed61580a4ad37b41bbed
7
+ data.tar.gz: 783cd8e9c729404108119fc2c26b49729852c68e40e415dad7d5ab92066021a4c2496fe3aaeab355911ad174b848af1cda99510496a53ff282f5d4fa42f8d244
@@ -14,3 +14,7 @@
14
14
  - Improved logging for better readability in logs
15
15
  - Switched to builtin Logger#deprecate from Logger#warn for deprecations
16
16
  - Renamed internal method to skip? from holiday? as it was meant for skipping any specified date
17
+
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
@@ -1,4 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
2
3
 
3
4
  require 'bundler/setup'
4
5
  require 'kobot'
@@ -14,8 +14,6 @@ require 'kobot/engine'
14
14
  # and with Google Gmail service email notification can also be sent to notify the results.
15
15
  module Kobot
16
16
  class << self
17
-
18
- # The entrance to run Kobot.
19
17
  def run
20
18
  configure
21
19
  Engine.new.start
@@ -1,7 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Kobot
4
-
5
4
  # Configuration definition includes static ones hardcoded and
6
5
  # dynamic ones that can be specified by command line options.
7
6
  class Config
@@ -4,7 +4,6 @@ module Kobot
4
4
  # Credentials include id and password to login to KOT and
5
5
  # Gmail SMTP id and password to send email notifications.
6
6
  class Credential
7
-
8
7
  class << self
9
8
  attr_accessor :kot_id,
10
9
  :kot_password,
@@ -6,7 +6,6 @@ module Kobot
6
6
  # The core class that launches browser, logins to KOT, reads today
7
7
  # record, and conducts clock in or clock out action based on config.
8
8
  class Engine
9
-
10
9
  def initialize
11
10
  @now = Time.now.getlocal(Config.kot_timezone_offset)
12
11
  @today = @now.strftime(Config.kot_date_format)
@@ -93,6 +92,8 @@ module Kobot
93
92
  def login
94
93
  Kobot.logger.info("Navigate to: #{@top_url}")
95
94
  @browser.get @top_url
95
+ @wait.until { @browser.find_element(id: 'modal_window') }
96
+ Kobot.logger.info "Page title: #{@browser.title}"
96
97
  Kobot.logger.debug do
97
98
  "Login with id=#{Credential.kot_id} and password=#{Credential.kot_password}"
98
99
  end
@@ -139,8 +140,12 @@ module Kobot
139
140
  @kot_today = date_cell.text
140
141
  @kot_today_css_class = date_cell.attribute('class')
141
142
  @kot_today_type = tr.find_element(css: 'td.work_day_type').text
142
- @kot_today_clock_in = tr.find_element(css: 'td.start_end_timerecord[data-ht-sort-index="START_TIMERECORD"]').text
143
- @kot_today_clock_out = tr.find_element(css: 'td.start_end_timerecord[data-ht-sort-index="END_TIMERECORD"]').text
143
+ @kot_today_clock_in = tr.find_element(
144
+ css: 'td.start_end_timerecord[data-ht-sort-index="START_TIMERECORD"]'
145
+ ).text
146
+ @kot_today_clock_out = tr.find_element(
147
+ css: 'td.start_end_timerecord[data-ht-sort-index="END_TIMERECORD"]'
148
+ ).text
144
149
  Kobot.logger.debug do
145
150
  {
146
151
  kot_toay: @kot_today,
@@ -158,26 +163,19 @@ module Kobot
158
163
  raise KotRecordError, "Today=#{@today} is not found on kot" if @kot_today.strip.empty?
159
164
 
160
165
  if kot_weekend?
161
- unless Config.force
162
- raise KotRecordError,
163
- "Today=#{@today} is marked as weekend on kot: #{@kot_today}"
164
- end
166
+ raise KotRecordError, "Today=#{@today} is marked as weekend on kot: #{@kot_today}" unless Config.force
165
167
 
166
168
  Kobot.logger.info(
167
169
  "[Force] should have exited: today=#{@today} is marked as weekend on kot: #{@kot_today}"
168
170
  )
169
171
  end
170
172
 
171
- if kot_public_holiday?
172
- unless Config.force
173
- raise KotRecordError,
174
- "Today=#{@today} is marked as public holiday on kot: #{@kot_today}"
175
- end
173
+ return unless kot_public_holiday?
174
+ raise KotRecordError, "Today=#{@today} is marked as public holiday on kot: #{@kot_today}" unless Config.force
176
175
 
177
- Kobot.logger.info(
178
- "[Force] should have exited: today=#{@today} is marked as public holiday on kot: #{@kot_today}"
179
- )
180
- end
176
+ Kobot.logger.info(
177
+ "[Force] should have exited: today=#{@today} is marked as public holiday on kot: #{@kot_today}"
178
+ )
181
179
  end
182
180
 
183
181
  def clock_in!
@@ -1,7 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Kobot
4
-
5
4
  class KotRecordError < StandardError
6
5
  end
7
6
 
@@ -10,5 +9,4 @@ module Kobot
10
9
 
11
10
  class KotClockOutError < StandardError
12
11
  end
13
-
14
12
  end
@@ -3,11 +3,9 @@
3
3
  require 'net/smtp'
4
4
 
5
5
  module Kobot
6
-
7
6
  # Responsible for sending email notifications in SMTP with Gmail
8
7
  class Mailer
9
8
  class << self
10
-
11
9
  # Sends email in preconfigured Gmail SMTP credential and to the recipient
12
10
  # configured by #{Config.gmail_notify_to} or self if not configured, with
13
11
  # email subject set by #{Config.gmail_notify_subject}.
@@ -3,11 +3,9 @@
3
3
  require 'optparse'
4
4
 
5
5
  module Kobot
6
-
7
6
  # Responsible for parsing the command line options for custom execution.
8
7
  class Option
9
8
  class << self
10
-
11
9
  # Parses command line options and returns a hash containing the options.
12
10
  def parse!
13
11
  options = {}
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Kobot
4
- VERSION = '1.2.1'
4
+ VERSION = '1.2.2'
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.1
4
+ version: 1.2.2
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-27 00:00:00.000000000 Z
11
+ date: 2020-09-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: webdrivers