ruboty-deadline 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +15 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +35 -0
- data/Rakefile +2 -0
- data/lib/ruboty/deadline/actions/create.rb +26 -0
- data/lib/ruboty/deadline/actions/destroy.rb +20 -0
- data/lib/ruboty/deadline/actions/list.rb +11 -0
- data/lib/ruboty/deadline/version.rb +5 -0
- data/lib/ruboty/deadline.rb +33 -0
- data/lib/ruboty/handlers/deadline.rb +25 -0
- data/ruboty-deadline.gemspec +25 -0
- data/screenshot.png +0 -0
- metadata +128 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 78a1a69304fc6f8db32f387ec6e933bce5dded11
|
4
|
+
data.tar.gz: 58bae7313f5d6712339d74f441f855ec24e81a8c
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: d3dba87cd055727eee3ba4769184f6c07c19ab25a33cda99bdce00fa5b30d60fa0d59baeb627d2838d92db9d9ce112f7bf02adb144afca2c4a71fa86dea92834
|
7
|
+
data.tar.gz: 1570e5f8e8f3d544fc19d8e26835b354e591b59dedd7e5c64ba663e2cdece11c307b5408cf81c351235775f5230052e5cc431e04f0db8b38e5af5c0d3209c224
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 block_given?
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
# Ruboty::Deadline
|
2
|
+
|
3
|
+
ruboty plugin for 〆
|
4
|
+
|
5
|
+
![screenshot](screenshot.png)
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add this line to your application's Gemfile:
|
10
|
+
|
11
|
+
```ruby
|
12
|
+
gem 'ruboty-deadline'
|
13
|
+
```
|
14
|
+
|
15
|
+
And then execute:
|
16
|
+
|
17
|
+
$ bundle
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
|
21
|
+
$ gem install ruboty-deadline
|
22
|
+
|
23
|
+
## Usage
|
24
|
+
|
25
|
+
@ruboty 〆 地球滅亡 3日後 # add 〆
|
26
|
+
@ruboty 〆 # list 〆
|
27
|
+
@ruboty rm 〆 地球滅亡 # remove 〆
|
28
|
+
|
29
|
+
## Contributing
|
30
|
+
|
31
|
+
1. Fork it ( https://github.com/blockgiven/ruboty-deadline/fork )
|
32
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
33
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
34
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
35
|
+
5. Create a new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
require 'tokiyomi'
|
2
|
+
|
3
|
+
module Ruboty
|
4
|
+
module Deadline
|
5
|
+
module Actions
|
6
|
+
class Create < Ruboty::Actions::Base
|
7
|
+
def call
|
8
|
+
::Ruboty::Deadline.deadlines(message.robot)[task] = deadline.beginning_of_day
|
9
|
+
message.reply(::Ruboty::Deadline.deadline_message(task, deadline))
|
10
|
+
end
|
11
|
+
|
12
|
+
private
|
13
|
+
|
14
|
+
def task
|
15
|
+
message[:task]
|
16
|
+
end
|
17
|
+
|
18
|
+
def deadline
|
19
|
+
Tokiyomi.parse(message[:deadline])
|
20
|
+
rescue
|
21
|
+
Time.parse(message[:deadline])
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module Ruboty
|
2
|
+
module Deadline
|
3
|
+
module Actions
|
4
|
+
class Destroy < Ruboty::Actions::Base
|
5
|
+
def call
|
6
|
+
if deadline = ::Ruboty::Deadline.deadlines(message.robot)[task]
|
7
|
+
::Ruboty::Deadline.deadlines(message.robot).delete(task)
|
8
|
+
message.reply(::Ruboty::Deadline.deadline_message(task, deadline))
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
private
|
13
|
+
|
14
|
+
def task
|
15
|
+
message[:task]
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
require "ruboty/deadline/version"
|
2
|
+
require "ruboty/handlers/deadline"
|
3
|
+
|
4
|
+
module Ruboty
|
5
|
+
module Deadline
|
6
|
+
NAMESPACE = 'deadline'
|
7
|
+
|
8
|
+
module_function
|
9
|
+
|
10
|
+
def deadlines(robot)
|
11
|
+
robot.brain.data[NAMESPACE] ||= {}
|
12
|
+
end
|
13
|
+
|
14
|
+
def deadline_messages(robot)
|
15
|
+
now = Time.now
|
16
|
+
deadlines(robot).map {|task, deadline|
|
17
|
+
deadline_message(task, deadline, now)
|
18
|
+
}
|
19
|
+
end
|
20
|
+
|
21
|
+
def deadline_message(task, deadline, now = Time.now)
|
22
|
+
remains = ((deadline.beginning_of_day - now.beginning_of_day) / 1.day).to_i
|
23
|
+
case remains <=> 0
|
24
|
+
when 0
|
25
|
+
"―――今日は#{task}の日―――"
|
26
|
+
when 1
|
27
|
+
"―――#{task}まで残り#{remains}日―――"
|
28
|
+
when -1
|
29
|
+
"―――#{task}から#{-remains}日―――"
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require "ruboty/deadline/actions/list"
|
2
|
+
require "ruboty/deadline/actions/create"
|
3
|
+
require "ruboty/deadline/actions/destroy"
|
4
|
+
|
5
|
+
module Ruboty
|
6
|
+
module Handlers
|
7
|
+
class Deadline < Base
|
8
|
+
on /〆$/, name: 'list', description: 'list 〆'
|
9
|
+
on /rm 〆 (?<task>.*)/, name: 'destroy', description: 'rm 〆'
|
10
|
+
on /〆 (?<task>.*) (?<deadline>.*)/, name: 'create', description: 'add 〆'
|
11
|
+
|
12
|
+
def list(message)
|
13
|
+
Ruboty::Deadline::Actions::List.new(message).call
|
14
|
+
end
|
15
|
+
|
16
|
+
def create(message)
|
17
|
+
Ruboty::Deadline::Actions::Create.new(message).call
|
18
|
+
end
|
19
|
+
|
20
|
+
def destroy(message)
|
21
|
+
Ruboty::Deadline::Actions::Destroy.new(message).call
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'ruboty/deadline/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "ruboty-deadline"
|
8
|
+
spec.version = Ruboty::Deadline::VERSION
|
9
|
+
spec.authors = ["block_given?"]
|
10
|
+
spec.email = ["block_given@outlook.com"]
|
11
|
+
spec.summary = %q{ruboty plugin for 〆.}
|
12
|
+
spec.homepage = "https://github.com/blockgiven/ruboty-deadline"
|
13
|
+
spec.license = "MIT"
|
14
|
+
|
15
|
+
spec.files = `git ls-files -z`.split("\x0")
|
16
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
17
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
18
|
+
spec.require_paths = ["lib"]
|
19
|
+
|
20
|
+
spec.add_runtime_dependency "ruboty"
|
21
|
+
spec.add_runtime_dependency "tokiyomi"
|
22
|
+
spec.add_development_dependency "bundler", "~> 1.7"
|
23
|
+
spec.add_development_dependency "pry"
|
24
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
25
|
+
end
|
data/screenshot.png
ADDED
Binary file
|
metadata
ADDED
@@ -0,0 +1,128 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: ruboty-deadline
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- block_given?
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-10-29 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: tokiyomi
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: bundler
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '1.7'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '1.7'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: pry
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rake
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '10.0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '10.0'
|
83
|
+
description:
|
84
|
+
email:
|
85
|
+
- block_given@outlook.com
|
86
|
+
executables: []
|
87
|
+
extensions: []
|
88
|
+
extra_rdoc_files: []
|
89
|
+
files:
|
90
|
+
- ".gitignore"
|
91
|
+
- Gemfile
|
92
|
+
- LICENSE.txt
|
93
|
+
- README.md
|
94
|
+
- Rakefile
|
95
|
+
- lib/ruboty/deadline.rb
|
96
|
+
- lib/ruboty/deadline/actions/create.rb
|
97
|
+
- lib/ruboty/deadline/actions/destroy.rb
|
98
|
+
- lib/ruboty/deadline/actions/list.rb
|
99
|
+
- lib/ruboty/deadline/version.rb
|
100
|
+
- lib/ruboty/handlers/deadline.rb
|
101
|
+
- ruboty-deadline.gemspec
|
102
|
+
- screenshot.png
|
103
|
+
homepage: https://github.com/blockgiven/ruboty-deadline
|
104
|
+
licenses:
|
105
|
+
- MIT
|
106
|
+
metadata: {}
|
107
|
+
post_install_message:
|
108
|
+
rdoc_options: []
|
109
|
+
require_paths:
|
110
|
+
- lib
|
111
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
112
|
+
requirements:
|
113
|
+
- - ">="
|
114
|
+
- !ruby/object:Gem::Version
|
115
|
+
version: '0'
|
116
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
117
|
+
requirements:
|
118
|
+
- - ">="
|
119
|
+
- !ruby/object:Gem::Version
|
120
|
+
version: '0'
|
121
|
+
requirements: []
|
122
|
+
rubyforge_project:
|
123
|
+
rubygems_version: 2.2.2
|
124
|
+
signing_key:
|
125
|
+
specification_version: 4
|
126
|
+
summary: ruboty plugin for 〆.
|
127
|
+
test_files: []
|
128
|
+
has_rdoc:
|