ruboty-can_i_borrow 0.1.2 → 0.2.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6259c02b94759bf001e897701baaec4a8ebac114
4
- data.tar.gz: a91742de1f9ffe1e4883db1df5ccfb0490f9b9b1
3
+ metadata.gz: e788b3f9016bfde6d058065fe5562c0726be5aa1
4
+ data.tar.gz: da4e9fe793fb42f24a86092e1ad51b60ddb87637
5
5
  SHA512:
6
- metadata.gz: 3404c3f4e98e689692243a1d3dda08119528eeea66f60bb8ea0c2642cde60d196365f578e33983add11ac0f5058cfd6b5afe968e9cd3976212b32cacbaa744fa
7
- data.tar.gz: 739ecd76ef71cddf0f36e74be1c419008a55cb427e76f7b7c75fdc846ca36070a20978ac347c78cc848490805e6d19bca3c4a4a1f6722ac75dcdcc3cda645f0a
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
 
@@ -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
@@ -1,5 +1,5 @@
1
1
  module Ruboty
2
2
  module CanIBorrow
3
- VERSION = "0.1.2"
3
+ VERSION = "0.2.0"
4
4
  end
5
5
  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.1.2
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-08 00:00:00.000000000 Z
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