miteras_batch_application 0.0.0 → 0.0.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: 995e77630ccf56c2ee8d87d3040bc374c5fdb68c38a631ebc43de1707b7c7294
4
- data.tar.gz: d407aeb24d78dc799fca7bc68f75c5eadaa995e5d9a12a06f6d38ffae6ef800c
3
+ metadata.gz: 158ccc3c7c9de10ec07ff45dfea97d0606f00328e9f7611bcae8a0ce2fcfcc65
4
+ data.tar.gz: df2b6dd70b066e19955811dd19f3e437df64b3816ddc3cc6fe9394bebf552908
5
5
  SHA512:
6
- metadata.gz: f54997162757b8e383cff7eddc20fe572075358bb564c2fd30aff955b1e91ab10fcd48bde29728c1484a953a342d91219db840e313b498d02022981ed72e0da2
7
- data.tar.gz: 9eb8dda05930caa9a535e2c8628616c1dc570b3e04f3865271373f8027542fe070fb5891e4cd81472ee3ed051e0535a9f8a72868c3a6db2a708bca4f10fa8bba
6
+ metadata.gz: 39a9a45eb4e70cad91893327ec6d9928d8ca7355f5c8a6d8bfc4c3e699200852824fa873a96f57622f0bf923a2bca9b69185119f626fb494776b3a3ea3aeba79
7
+ data.tar.gz: c5a3e7bb58e17bece6b605ea9a305a38391e84c0df51e59ddc106e4be25ba9ed77e568c8dea7b96658cc681baadfb814ce6fb599d769db782af537c5e7c59cb8
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- require 'miteras_batch_application'
3
+ require 'attendance'
4
4
  require 'optparse'
5
5
 
6
6
  opt = OptionParser.new
@@ -0,0 +1,24 @@
1
+ class AcknowledgementOfApplication
2
+ def initialize(table_row)
3
+ @table_row = table_row
4
+ end
5
+
6
+ def check_on_holidays
7
+ puts
8
+ @table_row.find_element(:class, 'monthly-checkbox').click if past_day? && unapplied?
9
+ end
10
+
11
+ private
12
+
13
+ def past_day?
14
+ require_table_row_day <= Date.today.day
15
+ end
16
+
17
+ def require_table_row_day
18
+ @table_row.text.match(/^[0-9]*/)[0].to_i
19
+ end
20
+
21
+ def unapplied?
22
+ !@table_row.text.include?('申請済')
23
+ end
24
+ end
data/lib/attendance.rb ADDED
@@ -0,0 +1,60 @@
1
+ require 'selenium-webdriver'
2
+ require_relative './user'
3
+ require_relative './acknowledgement_of_application'
4
+
5
+ class Attendance
6
+ def initialize(argv, params)
7
+ @session = Selenium::WebDriver.for :chrome
8
+ @session.manage.timeouts.implicit_wait = 10
9
+ @user = User.new(argv[0], argv[1], @session)
10
+ @reason = argv[2] || 'slack確認のため'
11
+ @is_c = params[:c]
12
+ @is_e = params[:e]
13
+ end
14
+
15
+ def input
16
+ @user.login
17
+ move_work_condition_page
18
+ enter_discrepancy_reasons if @is_e
19
+ check_on_holidays if @is_c
20
+ end
21
+
22
+ private
23
+
24
+ def move_work_condition_page
25
+ @session.find_element(:id, 'work-condition-page').click
26
+ sleep(1)
27
+ end
28
+
29
+ def enter_discrepancy_reasons
30
+ find_table_row.length.times { |index| enter_discrepancy_reason(index) }
31
+ end
32
+
33
+ def find_table_row
34
+ @session.find_elements(:class, "table01__row")
35
+ end
36
+
37
+ def enter_discrepancy_reason(index)
38
+ if find_alert_tooltip(index)
39
+ find_table_row[index].find_element(:class, 'divergence').click
40
+ sleep(1)
41
+ @session.find_element(:id, 'reason').send_keys(@reason)
42
+ @session.find_element(:id, 'regist').click
43
+ @session.find_element(:class, 'modalConfirm__btnBox').find_element(:class, 'divergence-close').click
44
+ sleep(1)
45
+ end
46
+ end
47
+
48
+ def find_alert_tooltip(index)
49
+ find_table_row[index].find_elements(:class, 'alert-tooltip').first
50
+ end
51
+
52
+ def check_on_holidays
53
+ find_table_row.map do |table_row|
54
+ AcknowledgementOfApplication.new(table_row).check_on_holidays
55
+ end
56
+ @session.find_element(:id, 'batch-request').click
57
+ @session.find_element(:id, 'save-batch-request').click
58
+ sleep(4)
59
+ end
60
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: miteras_batch_application
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.0
4
+ version: 0.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - pontan
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-07-24 00:00:00.000000000 Z
11
+ date: 2022-08-21 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: miteras batch application
14
14
  email: xuyangfujia@gmail.com
@@ -18,11 +18,12 @@ extensions: []
18
18
  extra_rdoc_files: []
19
19
  files:
20
20
  - bin/miteras_batch_application
21
- - lib/miteras_batch_application.rb
21
+ - lib/acknowledgement_of_application.rb
22
+ - lib/attendance.rb
22
23
  - lib/user.rb
23
24
  homepage: https://rubygems.org/gems/miteras_batch_application
24
25
  licenses:
25
- - asahi
26
+ - MIT
26
27
  metadata: {}
27
28
  post_install_message:
28
29
  rdoc_options: []
@@ -1,58 +0,0 @@
1
- require 'selenium-webdriver'
2
- require_relative './user'
3
-
4
- class Attendance
5
- def initialize(argv, params)
6
- @username = argv[0]
7
- @password = argv[1]
8
- @reason = argv[2] || 'slack確認のため'
9
- @params = params
10
- end
11
-
12
- def input
13
- @index = 0
14
- @session = Selenium::WebDriver.for :chrome
15
- @session.manage.timeouts.implicit_wait = 10
16
- User.new(@username, @password, @session).login
17
- move_work_condition_page
18
- make_batch_application
19
- @session.quit
20
- end
21
-
22
- private
23
-
24
- def move_work_condition_page
25
- @session.find_element(:id, 'work-condition-page').click
26
- sleep(1)
27
- end
28
-
29
- def make_batch_application
30
- @table01_row = @session.find_elements(:class, "table01__row")
31
- while @index < @table01_row.length
32
- @row = @table01_row[@index]
33
- check_on_holidays if @params[:c]
34
- enter_reason_discrepancy if @params[:e]
35
- @index += 1
36
- end
37
- @session.find_element(:id, 'batch-request').click
38
- @session.find_element(:id, 'save-batch-request').click
39
- end
40
-
41
- def enter_reason_discrepancy
42
- if @row.find_elements(:class, 'alert-tooltip').first
43
- @row.find_element(:class, 'divergence').click
44
- sleep(1)
45
- @session.find_element(:id, 'reason').send_keys(@reason)
46
- @session.find_element(:id, 'regist').click
47
- divergence_close = @session.find_element(:class, 'modalConfirm__btnBox').find_element(:class, 'divergence-close')
48
- divergence_close.click
49
- sleep(1)
50
- @table01_row = @session.find_elements(:class, "table01__row")
51
- end
52
- end
53
-
54
- def check_on_holidays
55
- wday = @row.text.match(/\(.\)/)[0]
56
- @row.find_element(:class, 'monthly-checkbox').click if wday == '(土)' || wday == '(日)'
57
- end
58
- end