ruboty-can_i_borrow 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 2c957ca2b31aae5115b1d07398f9304741d57578
4
+ data.tar.gz: 80a38b05d227f62734ad1364817f35df250456f0
5
+ SHA512:
6
+ metadata.gz: 5e9c891990713cae512cc38d65621dda682a77f9b55cdb2729e940f412002aee6bc35b8d0d6754e1af173803835b9e54e345ad477d359e8d76ffcb051235ddad
7
+ data.tar.gz: d1c1a3df1d6f846a7226c841f1c4cbc95f341ca7b91940cb8cc1fe6813f772b01cabe3383bcf1e085c6b123f0d1810739f67a8c87f969e2e7b39a421fe1c2118
data/.gitignore ADDED
@@ -0,0 +1,9 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
data/.travis.yml ADDED
@@ -0,0 +1,3 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.2.1
@@ -0,0 +1,13 @@
1
+ # Contributor Code of Conduct
2
+
3
+ As contributors and maintainers of this project, we pledge to respect all people who contribute through reporting issues, posting feature requests, updating documentation, submitting pull requests or patches, and other activities.
4
+
5
+ We are committed to making participation in this project a harassment-free experience for everyone, regardless of level of experience, gender, gender identity and expression, sexual orientation, disability, personal appearance, body size, race, age, or religion.
6
+
7
+ Examples of unacceptable behavior by participants include the use of sexual language or imagery, derogatory comments or personal attacks, trolling, public or private harassment, insults, or other unprofessional conduct.
8
+
9
+ Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct. Project maintainers who do not follow the Code of Conduct may be removed from the project team.
10
+
11
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by opening an issue or contacting one or more of the project maintainers.
12
+
13
+ This Code of Conduct is adapted from the [Contributor Covenant](http:contributor-covenant.org), version 1.0.0, available at [http://contributor-covenant.org/version/1/0/0/](http://contributor-covenant.org/version/1/0/0/)
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in ruboty-can_i_borrow.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2015 akira.takahashi
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,46 @@
1
+ # Ruboty::CanIBorrow
2
+
3
+ Logging lending record and check lending status
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'ruboty-can_i_borrow'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install ruboty-can_i_borrow
20
+
21
+ ## Usage
22
+
23
+ ```ruby
24
+
25
+ @ruboty borrow to "item"
26
+ => "itemを貸し出し状態にします。"
27
+ @ruboty borrow to "item"
28
+ => "itemは2015-10-07に{user}さんに貸し出されています。"
29
+ @ruboty return to "item"
30
+ => "itemを返却済みにします。ありがとうございました。"
31
+
32
+ ```
33
+
34
+ ## Development
35
+
36
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `bin/console` for an interactive prompt that will allow you to experiment.
37
+
38
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release` to create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
39
+
40
+ ## Contributing
41
+
42
+ 1. Fork it ( https://github.com/[my-github-username]/ruboty-can_i_borrow/fork )
43
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
44
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
45
+ 4. Push to the branch (`git push origin my-new-feature`)
46
+ 5. Create a new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "ruboty/can_i_borrow"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start
data/bin/setup ADDED
@@ -0,0 +1,7 @@
1
+ #!/bin/bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+
5
+ bundle install
6
+
7
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,29 @@
1
+ module Ruboty
2
+ module CanIBorrow
3
+ NAME_SPACE = 'CAN_I_BORROW'
4
+
5
+ module Actions
6
+ class Base < Ruboty::Actions::Base
7
+ def leager
8
+ message.robot.brain.data[Ruboty::CanIBorrow::NAME_SPACE] ||= {}
9
+ end
10
+
11
+ def borrowed?
12
+ !borrow_history.nil?
13
+ end
14
+
15
+ def borrower?
16
+ borrow_history[:user] == message.from_name
17
+ end
18
+
19
+ def borrow_history
20
+ leager[item]
21
+ end
22
+
23
+ def item
24
+ message[:item]
25
+ end
26
+ end
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,26 @@
1
+ module Ruboty
2
+ module CanIBorrow
3
+ module Actions
4
+ class Borrow < Base
5
+ def call
6
+ unless borrowed?
7
+ borrow
8
+ message.reply("#{item}を貸し出し状態にします。")
9
+ else
10
+ message.reply("#{item}は#{borrow_history[:borrowed_at]}に#{borrow_history[:user]}さんに貸し出されています。")
11
+ end
12
+ end
13
+
14
+ private
15
+
16
+ def borrow
17
+ leager[item] = {
18
+ item: item,
19
+ user: message.from_name,
20
+ borrowed_at: Date.today
21
+ }
22
+ end
23
+ end
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,24 @@
1
+ module Ruboty
2
+ module CanIBorrow
3
+ module Actions
4
+ class Return < Base
5
+ def call
6
+ return message.reply("#{message[:item]}は借しだされていません。") if borrow_history.nil?
7
+
8
+ if borrower?
9
+ return_item
10
+ message.reply("#{item}を返却済みにします。ありがとうございました。")
11
+ else
12
+ message.reply("#{item}は#{brower_history[:user]}さんによって借りられています。")
13
+ end
14
+ end
15
+
16
+ private
17
+
18
+ def return_item
19
+ leager[item] = nil
20
+ end
21
+ end
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,5 @@
1
+ module Ruboty
2
+ module CanIBorrow
3
+ VERSION = "0.1.0"
4
+ end
5
+ end
@@ -0,0 +1,7 @@
1
+ require "ruboty/can_i_borrow/version"
2
+
3
+ require "ruboty/can_i_borrow/actions/base"
4
+ require "ruboty/can_i_borrow/actions/borrow"
5
+ require "ruboty/can_i_borrow/actions/return"
6
+
7
+ require "ruboty/handlers/can_i_borrow"
@@ -0,0 +1,16 @@
1
+ module Ruboty
2
+ module Handlers
3
+ class CanIBorrow < Base
4
+ on /borrow to ?(?<item>.+)?/, name: 'borrow', description: 'TODO: write your description'
5
+ on /return to ?(?<item>.+)?/, name: 'return', description: 'TODO: write your description'
6
+
7
+ def borrow(message)
8
+ Ruboty::CanIBorrow::Actions::Borrow.new(message).call
9
+ end
10
+
11
+ def return(message)
12
+ Ruboty::CanIBorrow::Actions::Return.new(message).call
13
+ end
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,24 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'ruboty/can_i_borrow/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "ruboty-can_i_borrow"
8
+ spec.version = Ruboty::CanIBorrow::VERSION
9
+ spec.authors = ["akira.takahashi"]
10
+ spec.email = ["rike422@gmail.com"]
11
+ spec.summary = %q{Logging lending record and check lending status}
12
+ spec.description = %q{Logging lending record and check lending status}
13
+ spec.homepage = "https://github.com/rike422/ruboty-can_i_borrow"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_runtime_dependency "ruboty"
22
+ spec.add_development_dependency "bundler", "~> 1.8"
23
+ spec.add_development_dependency "rake", "~> 10.0"
24
+ end
@@ -0,0 +1,11 @@
1
+ require 'spec_helper'
2
+
3
+ describe Ruboty::CanIBorrow do
4
+ it 'has a version number' do
5
+ expect(Ruboty::CanIBorrow::VERSION).not_to be nil
6
+ end
7
+
8
+ it 'does something useful' do
9
+ expect(false).to eq(true)
10
+ end
11
+ end
@@ -0,0 +1,2 @@
1
+ $LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
2
+ require 'ruboty/can_i_borrow'
metadata ADDED
@@ -0,0 +1,109 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: ruboty-can_i_borrow
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - akira.takahashi
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-10-07 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: ruboty
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.8'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.8'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '10.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '10.0'
55
+ description: Logging lending record and check lending status
56
+ email:
57
+ - rike422@gmail.com
58
+ executables:
59
+ - console
60
+ - setup
61
+ extensions: []
62
+ extra_rdoc_files: []
63
+ files:
64
+ - ".gitignore"
65
+ - ".rspec"
66
+ - ".travis.yml"
67
+ - CODE_OF_CONDUCT.md
68
+ - Gemfile
69
+ - LICENSE.txt
70
+ - README.md
71
+ - Rakefile
72
+ - bin/console
73
+ - bin/setup
74
+ - lib/ruboty/can_i_borrow.rb
75
+ - lib/ruboty/can_i_borrow/actions/base.rb
76
+ - lib/ruboty/can_i_borrow/actions/borrow.rb
77
+ - lib/ruboty/can_i_borrow/actions/return.rb
78
+ - lib/ruboty/can_i_borrow/version.rb
79
+ - lib/ruboty/handlers/can_i_borrow.rb
80
+ - ruboty-can_i_borrow.gemspec
81
+ - spec/ruboty/can_i_borrow_spec.rb
82
+ - spec/spec_helper.rb
83
+ homepage: https://github.com/rike422/ruboty-can_i_borrow
84
+ licenses:
85
+ - MIT
86
+ metadata: {}
87
+ post_install_message:
88
+ rdoc_options: []
89
+ require_paths:
90
+ - lib
91
+ required_ruby_version: !ruby/object:Gem::Requirement
92
+ requirements:
93
+ - - ">="
94
+ - !ruby/object:Gem::Version
95
+ version: '0'
96
+ required_rubygems_version: !ruby/object:Gem::Requirement
97
+ requirements:
98
+ - - ">="
99
+ - !ruby/object:Gem::Version
100
+ version: '0'
101
+ requirements: []
102
+ rubyforge_project:
103
+ rubygems_version: 2.4.8
104
+ signing_key:
105
+ specification_version: 4
106
+ summary: Logging lending record and check lending status
107
+ test_files:
108
+ - spec/ruboty/can_i_borrow_spec.rb
109
+ - spec/spec_helper.rb