miteras_batch_application 0.0.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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 995e77630ccf56c2ee8d87d3040bc374c5fdb68c38a631ebc43de1707b7c7294
4
+ data.tar.gz: d407aeb24d78dc799fca7bc68f75c5eadaa995e5d9a12a06f6d38ffae6ef800c
5
+ SHA512:
6
+ metadata.gz: f54997162757b8e383cff7eddc20fe572075358bb564c2fd30aff955b1e91ab10fcd48bde29728c1484a953a342d91219db840e313b498d02022981ed72e0da2
7
+ data.tar.gz: 9eb8dda05930caa9a535e2c8628616c1dc570b3e04f3865271373f8027542fe070fb5891e4cd81472ee3ed051e0535a9f8a72868c3a6db2a708bca4f10fa8bba
@@ -0,0 +1,12 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'miteras_batch_application'
4
+ require 'optparse'
5
+
6
+ opt = OptionParser.new
7
+ params = {}
8
+ opt.on('-c') {|v| params[:c] = v }
9
+ opt.on('-e') {|v| params[:e] = v }
10
+ opt.parse!(ARGV)
11
+ attendance = Attendance.new(ARGV, params)
12
+ attendance.input
@@ -0,0 +1,58 @@
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
data/lib/user.rb ADDED
@@ -0,0 +1,14 @@
1
+ class User
2
+ def initialize(username, password, session)
3
+ @session = session
4
+ @username = username
5
+ @password = password
6
+ end
7
+
8
+ def login
9
+ @session.navigate.to "https://kintai.miteras.jp/A319971/login"
10
+ @session.find_element(:id, 'username').send_keys(@username)
11
+ @session.find_element(:id, 'password').send_keys(@password, :enter)
12
+ sleep(1)
13
+ end
14
+ end
metadata ADDED
@@ -0,0 +1,46 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: miteras_batch_application
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.0
5
+ platform: ruby
6
+ authors:
7
+ - pontan
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2022-07-24 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: miteras batch application
14
+ email: xuyangfujia@gmail.com
15
+ executables:
16
+ - miteras_batch_application
17
+ extensions: []
18
+ extra_rdoc_files: []
19
+ files:
20
+ - bin/miteras_batch_application
21
+ - lib/miteras_batch_application.rb
22
+ - lib/user.rb
23
+ homepage: https://rubygems.org/gems/miteras_batch_application
24
+ licenses:
25
+ - asahi
26
+ metadata: {}
27
+ post_install_message:
28
+ rdoc_options: []
29
+ require_paths:
30
+ - lib
31
+ required_ruby_version: !ruby/object:Gem::Requirement
32
+ requirements:
33
+ - - ">="
34
+ - !ruby/object:Gem::Version
35
+ version: '0'
36
+ required_rubygems_version: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ requirements: []
42
+ rubygems_version: 3.3.14
43
+ signing_key:
44
+ specification_version: 4
45
+ summary: miteras batch application!
46
+ test_files: []