ruboty-jobcan 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d024fdf806849cce74402a4f3ff17cfc85c1102b
4
- data.tar.gz: f91996db70b6e397e3458b3d9598d66c6c28b596
3
+ metadata.gz: 56f732325b542a73278f169be504638eec2e63b3
4
+ data.tar.gz: 560c033f3d6a14bd87988b4acc23dc1cd51c5ba9
5
5
  SHA512:
6
- metadata.gz: 14a0a391c1b2fec21b64c20602a65aee20738811b5ff08a5353d39348e499ab0e4ebfd6417457306007140682ff9cde659b670b4aa56c1b1f6a3042a29f34009
7
- data.tar.gz: 175d4e6ed45dfcb90b60a151e1d8b7fe8aff6b8109a5a9596413de1540afc68ebbcb7b64c2470ce92890f12b45f050191317e8b5bca0145aafd15709e95db55a
6
+ metadata.gz: 42bdd99cf2618c0a17e426bddee6a9b6ee6875a5c8722fec208ef0d577ed32dc2b2b79ba0e35df55f74791e3d0541bcd18bcb0b35448f0b5dd60fa422c68d09e
7
+ data.tar.gz: 97a11cb46f5ce519e0b1ed6961d939667a32d4f15458d12861e8fe9c6da001fab56a6edc943566f5d7a1c0eda2142d996e09ef2005401f16dbd24f56d57574ec
@@ -22,7 +22,7 @@ module Ruboty
22
22
  message.reply("I remember.")
23
23
  end
24
24
 
25
- def punch_clock
25
+ def punch_clock(in_out = :auto)
26
26
  unless (code = user_data["code"])
27
27
  message.reply("I don't know your JOBCAN code.")
28
28
  return
@@ -31,7 +31,7 @@ module Ruboty
31
31
  message.reply("I don't know your JOBCAN group ID.")
32
32
  return
33
33
  end
34
- client = JobcanClient.new(code, group_id)
34
+ client = JobcanClient.new(code, group_id, in_out)
35
35
  client.authenticate!
36
36
  status = client.punch_clock!
37
37
  message.reply("OK, your current status is #{status}.")
@@ -39,6 +39,14 @@ module Ruboty
39
39
  message.reply("Error: #{$!}")
40
40
  end
41
41
 
42
+ def clock_in
43
+ punch_clock(:in)
44
+ end
45
+
46
+ def clock_out
47
+ punch_clock(:out)
48
+ end
49
+
42
50
  private
43
51
 
44
52
  def user_data
@@ -47,9 +55,10 @@ module Ruboty
47
55
  end
48
56
 
49
57
  class JobcanClient
50
- def initialize(code, group_id)
58
+ def initialize(code, group_id, in_out)
51
59
  @code = code
52
60
  @group_id = group_id
61
+ @in_out = in_out
53
62
  end
54
63
 
55
64
  def authenticate!
@@ -96,7 +105,15 @@ module Ruboty
96
105
  end
97
106
 
98
107
  def punch_clock_request_body
99
- { is_yakin: "0", adit_item: "DEF", adit_group_id: @group_id, notice: "" }
108
+ { is_yakin: "0", adit_item: adit_item, adit_group_id: @group_id, notice: "" }
109
+ end
110
+
111
+ def adit_item
112
+ case @in_out
113
+ when :auto then "DEF"
114
+ when :in then "work_start"
115
+ when :out then "work_end"
116
+ end
100
117
  end
101
118
  end
102
119
  end
@@ -19,6 +19,18 @@ module Ruboty
19
19
  name: "punch_clock",
20
20
  )
21
21
 
22
+ on(
23
+ /clock in\z/,
24
+ description: "Clock in on JOBCAN",
25
+ name: "clock_in",
26
+ )
27
+
28
+ on(
29
+ /clock out\z/,
30
+ description: "Clock out on JOBCAN",
31
+ name: "clock_out",
32
+ )
33
+
22
34
  def remember_code(message)
23
35
  Ruboty::Actions::Jobcan.new(message).remember_code
24
36
  end
@@ -30,6 +42,14 @@ module Ruboty
30
42
  def punch_clock(message)
31
43
  Ruboty::Actions::Jobcan.new(message).punch_clock
32
44
  end
45
+
46
+ def clock_in(message)
47
+ Ruboty::Actions::Jobcan.new(message).clock_in
48
+ end
49
+
50
+ def clock_out(message)
51
+ Ruboty::Actions::Jobcan.new(message).clock_out
52
+ end
33
53
  end
34
54
  end
35
55
  end
@@ -1,5 +1,5 @@
1
1
  module Ruboty
2
2
  module Jobcan
3
- VERSION = "0.1.0"
3
+ VERSION = "0.1.1"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruboty-jobcan
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tomoki Aonuma