lita-kintai 0.3.0 → 0.3.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/lita/handlers/kintai.rb +4 -2
- data/lita-kintai.gemspec +1 -1
- data/spec/lita/handlers/kintai_spec.rb +49 -8
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 205202f5b71741586c8f4de24f18a58913862cff
|
4
|
+
data.tar.gz: 1755673df81ca30e27776dff2038a5e6dc3a1ba1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3ad7981cdc07276f90754aa61fd0b37fde40f3b049f9a5b10a4bcd570beaaf1ee5a26d568a9aa8985043df8c8a26ab8aa99b019ef1b741353893c329d3a64b59
|
7
|
+
data.tar.gz: c3ccca9c84e6678efd31a21cb31d6d9bff76d86d0225932e531566c410a7c89729c6ee5192d880fe14667c3e6d1eba5473d94d537cd5e897b5fe1f333f11be32
|
data/lib/lita/handlers/kintai.rb
CHANGED
@@ -38,7 +38,9 @@ module Lita
|
|
38
38
|
def register_draft(response, info)
|
39
39
|
mail = create_kintai_mail(info)
|
40
40
|
reply = response.reply(mail_to_message(mail))
|
41
|
-
|
41
|
+
if (reply.kind_of?(Hash) && reply.has_key?("channel") && reply.has_key?("ts"))
|
42
|
+
@@draft = { channel: reply["channel"], ts: reply["ts"], mail: mail }
|
43
|
+
end
|
42
44
|
reply
|
43
45
|
end
|
44
46
|
|
@@ -140,7 +142,7 @@ Subject: #{mail.subject}
|
|
140
142
|
name = m[:from].split("\"")[1]
|
141
143
|
|
142
144
|
text = m[:subject] + m[:body]
|
143
|
-
info = kintai_from_text(text)
|
145
|
+
info = Kintai.kintai_from_text(text)
|
144
146
|
|
145
147
|
texts << "#{name}さん: #{info}\n"
|
146
148
|
end
|
data/lita-kintai.gemspec
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
Gem::Specification.new do |spec|
|
2
2
|
spec.name = "lita-kintai"
|
3
|
-
spec.version = "0.3.
|
3
|
+
spec.version = "0.3.1"
|
4
4
|
spec.authors = ["Shoma SATO"]
|
5
5
|
spec.email = ["noir.neo.04@gmail.com"]
|
6
6
|
spec.description = "A lita handler for summarize attendance emails. Fuckin' legacy attendance management method by email!"
|
@@ -13,23 +13,64 @@ describe Lita::Handlers::Kintai, lita_handler: true do
|
|
13
13
|
allow(Gmail).to receive(:find_mail).and_return(
|
14
14
|
[
|
15
15
|
{
|
16
|
-
subject: '',
|
17
|
-
from: '',
|
18
|
-
date:
|
19
|
-
body: '',
|
16
|
+
subject: '佐藤 5分遅刻',
|
17
|
+
from: '\"佐藤',
|
18
|
+
date: Time.now,
|
19
|
+
body: '電車遅延のため、5分ほど遅れます。',
|
20
20
|
}
|
21
21
|
]
|
22
22
|
)
|
23
|
+
registry.config.handlers.kintai.mail_to = "mail@to"
|
24
|
+
registry.config.handlers.kintai.mail_cc = "mail@cc"
|
25
|
+
registry.config.handlers.kintai.template_subject = "Subject"
|
26
|
+
registry.config.handlers.kintai.template_header = "header"
|
27
|
+
registry.config.handlers.kintai.template_footer = "footer"
|
28
|
+
registry.config.handlers.kintai.template_info = "info template"
|
23
29
|
end
|
24
30
|
|
25
|
-
|
31
|
+
it 'returns kintai list' do
|
26
32
|
send_command('kintai')
|
27
|
-
expect(replies.last).
|
33
|
+
expect(replies.last).to eq <<-EOS
|
34
|
+
To: ["mail@to"]
|
35
|
+
Cc: ["mail@cc"]
|
36
|
+
Subject: #{Date.today.strftime("%m/%d")} (#{%w(日 月 火 水 木 金 土)[Date.today.wday]})Subject
|
37
|
+
header
|
38
|
+
|
39
|
+
佐藤さん: 電車遅延のため、10:05頃出社予定です。
|
40
|
+
info template
|
41
|
+
|
42
|
+
footer
|
43
|
+
|
44
|
+
EOS
|
28
45
|
end
|
29
46
|
end
|
30
47
|
end
|
31
48
|
|
32
|
-
describe '
|
49
|
+
describe '.kintai_from_text' do
|
50
|
+
subject { Lita::Handlers::Kintai.kintai_from_text(text) }
|
51
|
+
|
52
|
+
context '理由と時間がマッチする時' do
|
53
|
+
let(:text) { "電車が遅れていて5分ほど遅れます" }
|
54
|
+
it { is_expected.to eq "電車遅延のため、10:05頃出社予定です。" }
|
55
|
+
end
|
56
|
+
|
57
|
+
context '理由がマッチする時' do
|
58
|
+
let(:text) { "電車が遅れていて出社時刻わかりません" }
|
59
|
+
it { is_expected.to eq "電車遅延のため、出社時刻未定です。" }
|
60
|
+
end
|
61
|
+
|
62
|
+
context '時間がマッチする時' do
|
63
|
+
let(:text) { "5分ほど遅れます" }
|
64
|
+
it { is_expected.to eq "私用のため、10:05頃出社予定です。" }
|
65
|
+
end
|
66
|
+
|
67
|
+
context '理由と時間どちらもマッチしない時' do
|
68
|
+
let(:text) { "大変なことになったのでめっちゃ遅れます" }
|
69
|
+
it { is_expected.to eq "私用のため、出社時刻未定です。" }
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
describe '.kintai_reason(text)' do
|
33
74
|
subject { Lita::Handlers::Kintai.kintai_reason(text) }
|
34
75
|
|
35
76
|
context '「電車」が含まれる時' do
|
@@ -53,7 +94,7 @@ describe Lita::Handlers::Kintai, lita_handler: true do
|
|
53
94
|
end
|
54
95
|
end
|
55
96
|
|
56
|
-
describe '
|
97
|
+
describe '.kintai_time(text)' do
|
57
98
|
subject { Lita::Handlers::Kintai.kintai_time(text) }
|
58
99
|
|
59
100
|
context '「HH:mm」が含まれる時' do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lita-kintai
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Shoma SATO
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-04-
|
11
|
+
date: 2017-04-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: lita
|