attendance_bot 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/exe/attendance_bot +1 -0
- data/lib/attendance_bot.rb +23 -9
- data/lib/attendance_bot/cli.rb +11 -1
- data/lib/attendance_bot/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e1cc076ced50abb91e311dcf1b4d4fdc0dd840f4b7f2b5f443aaeea8bd519284
|
4
|
+
data.tar.gz: 27cc8a9999e54fdf7c16356d4fe839e17117890d386debd3b224ffdf2e517c0d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c97844ae3d3ba71ec0f2ba772be0e959bcef38f0dd9e8ff70ef932147ebf7046e9b255916125028b44ebd13733042403a72de9983d4537edbd68e74ed44005df
|
7
|
+
data.tar.gz: fad6cb3bc850b41670e441f4969b5dae07edfc0e7176906ea97ae6312f7dd8097463410dae6075015a7ed2ee2f4f5902d710c4b7ab74a4bb91740ad443a4ffdc
|
data/Gemfile.lock
CHANGED
data/exe/attendance_bot
CHANGED
data/lib/attendance_bot.rb
CHANGED
@@ -8,10 +8,16 @@ require 'config'
|
|
8
8
|
|
9
9
|
module AttendanceBot
|
10
10
|
class Error < StandardError; end
|
11
|
-
|
11
|
+
|
12
12
|
class Bot
|
13
|
-
|
14
|
-
|
13
|
+
attr_accessor :agent
|
14
|
+
|
15
|
+
def initialize
|
16
|
+
@agent = Mechanize.new
|
17
|
+
Config.load_and_set_settings('./config/config.yml')
|
18
|
+
end
|
19
|
+
|
20
|
+
def login
|
15
21
|
page = agent.get('https://attendance.moneyforward.com/employee_session/new')
|
16
22
|
login_form = page.form(action: '/employee_session')
|
17
23
|
|
@@ -19,21 +25,29 @@ module AttendanceBot
|
|
19
25
|
email_field = login_form.fields.find { |f| f.name == 'employee_session_form[account_name_or_email]' }
|
20
26
|
password_field = login_form.fields.find { |f| f.name == 'employee_session_form[password]' }
|
21
27
|
|
22
|
-
Config.load_and_set_settings('./config/config.yml')
|
23
|
-
|
24
28
|
office_field.value = Settings.office
|
25
29
|
email_field.value = Settings.email
|
26
30
|
password_field.value = Settings.password
|
27
31
|
|
32
|
+
login_form.submit
|
33
|
+
end
|
28
34
|
|
29
|
-
|
30
|
-
|
31
|
-
|
35
|
+
def checkin
|
36
|
+
page = login
|
32
37
|
clock_in_form = page.forms.first
|
33
|
-
user_time = clock_in_form.fields.find{ |f| f.name == 'web_time_recorder_form[user_time]' }
|
38
|
+
user_time = clock_in_form.fields.find { |f| f.name == 'web_time_recorder_form[user_time]' }
|
34
39
|
user_time.value = Time.now.to_s
|
35
40
|
|
36
41
|
clock_in_form.submit
|
37
42
|
end
|
43
|
+
|
44
|
+
def checkout
|
45
|
+
page = login
|
46
|
+
clock_out_form = page.forms[1]
|
47
|
+
user_time = clock_out_form.fields.find { |f| f.name == 'web_time_recorder_form[user_time]' }
|
48
|
+
user_time.value = Time.now.to_s
|
49
|
+
|
50
|
+
clock_out_form.submit
|
51
|
+
end
|
38
52
|
end
|
39
53
|
end
|
data/lib/attendance_bot/cli.rb
CHANGED
@@ -4,9 +4,19 @@ require 'attendance_bot'
|
|
4
4
|
|
5
5
|
module AttendanceBot
|
6
6
|
class CLI < Thor
|
7
|
+
def initialize(args = nil, options = nil, config = nil)
|
8
|
+
@bot = AttendanceBot::Bot.new
|
9
|
+
super
|
10
|
+
end
|
11
|
+
|
7
12
|
desc 'checkin', 'checkin with current time'
|
8
13
|
def checkin
|
9
|
-
|
14
|
+
@bot.checkin
|
15
|
+
end
|
16
|
+
|
17
|
+
desc 'checkout', 'checkout with current time'
|
18
|
+
def checkout
|
19
|
+
@bot.checkout
|
10
20
|
end
|
11
21
|
end
|
12
22
|
end
|