ruboty-can_i_borrow 0.1.2 → 0.2.0
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e788b3f9016bfde6d058065fe5562c0726be5aa1
|
4
|
+
data.tar.gz: da4e9fe793fb42f24a86092e1ad51b60ddb87637
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8d619a120a149ebf336cda49dd7608e4fbfc309efa6a7e724caf3ca89cecef6157b59e1399da0d8be6b4a16b762d64d720504a66c760a264c58e09f126716101
|
7
|
+
data.tar.gz: 417f2af93d13437fa376d7d42d82e8451afa5678323bb6c3184a8607ba1fbf3ff651d44ee65556fcacff7b19318ac6580a8b92edb67fec5ed2b9314a013380e5
|
data/README.md
CHANGED
@@ -26,8 +26,12 @@ Or install it yourself as:
|
|
26
26
|
=> "itemを貸し出し状態にします。"
|
27
27
|
@ruboty borrow to "item"
|
28
28
|
=> "itemは2015-10-07に{user}さんに貸し出されています。"
|
29
|
+
@ruboty list borrowed
|
30
|
+
=> "{user}さんが、2015-10-07にitemを借りています。"
|
29
31
|
@ruboty return to "item"
|
30
32
|
=> "itemを返却済みにします。ありがとうございました。"
|
33
|
+
@ruboty list borrowed
|
34
|
+
=> "現在、誰も借りていません。"
|
31
35
|
|
32
36
|
```
|
33
37
|
|
data/lib/ruboty/can_i_borrow.rb
CHANGED
@@ -3,5 +3,6 @@ require "ruboty/can_i_borrow/version"
|
|
3
3
|
require "ruboty/can_i_borrow/actions/base"
|
4
4
|
require "ruboty/can_i_borrow/actions/borrow"
|
5
5
|
require "ruboty/can_i_borrow/actions/return"
|
6
|
+
require "ruboty/can_i_borrow/actions/borrowed_histories"
|
6
7
|
|
7
8
|
require "ruboty/handlers/can_i_borrow"
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module Ruboty
|
2
|
+
module CanIBorrow
|
3
|
+
module Actions
|
4
|
+
class BorrowedHistories < Base
|
5
|
+
def call
|
6
|
+
if borrow_histories.empty?
|
7
|
+
message.reply("現在、誰も借りていません。")
|
8
|
+
else
|
9
|
+
message.reply(build_message_borrow_histries)
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
def build_message_borrow_histries
|
14
|
+
borrow_histories.map do |item, borrow_history|
|
15
|
+
"#{borrow_history[:user]}さんが、#{borrow_history[:borrowed_at]}に#{item}を借りています。"
|
16
|
+
end.join("\n")
|
17
|
+
end
|
18
|
+
|
19
|
+
def borrow_histories
|
20
|
+
leager.select{|k, v| v != nil }
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -3,6 +3,7 @@ module Ruboty
|
|
3
3
|
class CanIBorrow < Base
|
4
4
|
on /borrow to ?(?<item>.+)?/, name: 'borrow', description: 'TODO: write your description'
|
5
5
|
on /return to ?(?<item>.+)?/, name: 'return', description: 'TODO: write your description'
|
6
|
+
on 'list borrowed', name: 'borrowed_histories', description: 'show borrowed histories'
|
6
7
|
|
7
8
|
def borrow(message)
|
8
9
|
Ruboty::CanIBorrow::Actions::Borrow.new(message).call
|
@@ -11,6 +12,10 @@ module Ruboty
|
|
11
12
|
def return(message)
|
12
13
|
Ruboty::CanIBorrow::Actions::Return.new(message).call
|
13
14
|
end
|
15
|
+
|
16
|
+
def borrowed_histories(message)
|
17
|
+
Ruboty::CanIBorrow::Actions::BorrowedHistories.new(message).call
|
18
|
+
end
|
14
19
|
end
|
15
20
|
end
|
16
21
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruboty-can_i_borrow
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- akira.takahashi
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-10-
|
11
|
+
date: 2015-10-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: ruboty
|
@@ -74,6 +74,7 @@ files:
|
|
74
74
|
- lib/ruboty/can_i_borrow.rb
|
75
75
|
- lib/ruboty/can_i_borrow/actions/base.rb
|
76
76
|
- lib/ruboty/can_i_borrow/actions/borrow.rb
|
77
|
+
- lib/ruboty/can_i_borrow/actions/borrowed_histories.rb
|
77
78
|
- lib/ruboty/can_i_borrow/actions/return.rb
|
78
79
|
- lib/ruboty/can_i_borrow/version.rb
|
79
80
|
- lib/ruboty/handlers/can_i_borrow.rb
|