ruboty-kintai 1.0.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 +7 -0
- data/.gitignore +14 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +41 -0
- data/Rakefile +2 -0
- data/lib/ruboty/handlers/kintai.rb +102 -0
- data/lib/ruboty/kintai/reporters/csv.rb +27 -0
- data/lib/ruboty/kintai/version.rb +5 -0
- data/lib/ruboty/kintai.rb +12 -0
- data/ruboty-kintai.gemspec +25 -0
- data/screenshot.png +0 -0
- metadata +126 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA1:
|
|
3
|
+
metadata.gz: 0003cc29f66c82f3702c15de4660f68a35a58ab7
|
|
4
|
+
data.tar.gz: e8552ec583dc9dba107e8a423aa734ba9ec6032a
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: 176e3227e56d18a3cfce392f48708b796e789bb257f60598bb6c8ba4d7deae33624cf3b48a7516e646a81a19fcacd4d1d4210327c64ce94cb2c8a5f9ab0067ff
|
|
7
|
+
data.tar.gz: 1dbd7b394a0b35013c108cbdfed244b7a9329508c35292a8095fabacbf29ce552b855ec59bafbd6b955136b24dc0fc824dacb3a03237cdbb6e6ef8cac539a3ac
|
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,41 @@
|
|
|
1
|
+
# Ruboty::Kintai
|
|
2
|
+
|
|
3
|
+
ruboty plugin for 勤怠管理.
|
|
4
|
+
|
|
5
|
+

|
|
6
|
+
|
|
7
|
+
## Installation
|
|
8
|
+
|
|
9
|
+
Add this line to your application's Gemfile:
|
|
10
|
+
|
|
11
|
+
```ruby
|
|
12
|
+
gem 'ruboty-kintai'
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
If you want to use `勤怠3週間前から1週間前までcsvで`
|
|
16
|
+
|
|
17
|
+
```ruby
|
|
18
|
+
gem 'tokiyomi', github: 'moro/tokiyomi'
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
And then execute:
|
|
22
|
+
|
|
23
|
+
$ bundle
|
|
24
|
+
|
|
25
|
+
Or install it yourself as:
|
|
26
|
+
|
|
27
|
+
$ gem install ruboty-kintai
|
|
28
|
+
|
|
29
|
+
## Usage
|
|
30
|
+
|
|
31
|
+
@ruboty 出勤
|
|
32
|
+
@ruboty 退勤
|
|
33
|
+
@ruboty 勤怠1ヶ月前から今日までcsvで
|
|
34
|
+
|
|
35
|
+
## Contributing
|
|
36
|
+
|
|
37
|
+
1. Fork it ( https://github.com/blockgiven/ruboty-kintai/fork )
|
|
38
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
|
39
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
|
40
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
|
41
|
+
5. Create a new Pull Request
|
data/Rakefile
ADDED
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
module Ruboty
|
|
2
|
+
module Handlers
|
|
3
|
+
class Kintai < Base
|
|
4
|
+
NAMESPACE = 'kintai'
|
|
5
|
+
|
|
6
|
+
on /(?:シュッシャ|出社|出勤|帰りたい)(?:@(?<go_work_at>.*))?/, name: 'go_work', description: '出社時間を記録'
|
|
7
|
+
on /(?:タイシャ|退社|退勤|帰る)(?:@(?<go_home_at>.*))?/, name: 'go_home', description: '退社時間を記録'
|
|
8
|
+
on /(?:kintai|勤怠) ?(?<start>.*)から(?<end>.*)まで(?<reporter>csv)?/, name: 'list', description: '勤怠を見る'
|
|
9
|
+
|
|
10
|
+
def go_work(message)
|
|
11
|
+
go_work_at = Time.parse((message[:go_work_at] || Time.now).to_s)
|
|
12
|
+
|
|
13
|
+
kintai[message.from_name] ||= {}
|
|
14
|
+
kintai[message.from_name][:go_work_at] = go_work_at
|
|
15
|
+
|
|
16
|
+
greedings = %w(おはよー はよ はよはよ やっほー ふゎあぁ、おはよ ...)
|
|
17
|
+
|
|
18
|
+
message.reply("#{greedings.sample}, #{message.from_name}.")
|
|
19
|
+
rescue => e
|
|
20
|
+
if /no time information in/ =~ e.message
|
|
21
|
+
message.reply('時間がわからへん')
|
|
22
|
+
else
|
|
23
|
+
message.reply(e.message)
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
def go_home(message)
|
|
28
|
+
go_home_at = Time.parse((message[:go_home_at] || Time.now).to_s)
|
|
29
|
+
|
|
30
|
+
kintai[message.from_name] ||= {}
|
|
31
|
+
kintai[message.from_name][:go_home_at] = go_home_at
|
|
32
|
+
|
|
33
|
+
greedings = %w(おつかれさま おつかれさん 乙 はなきんだー バイバイ!)
|
|
34
|
+
|
|
35
|
+
if work_time = work_time(go_home_at, message.from_name)
|
|
36
|
+
stats = "今日は#{work_time}働いたみたいだよ。お疲れ様でした。"
|
|
37
|
+
else
|
|
38
|
+
stats = %w(あれ、いつきたのかな? 日付かわっちゃったかな? あ、帰る前に何時にきたか教えて!).sample
|
|
39
|
+
end
|
|
40
|
+
message.reply("#{greedings.sample}, #{message.from_name}. #{stats}.")
|
|
41
|
+
rescue => e
|
|
42
|
+
if /no time information in/ =~ e.message
|
|
43
|
+
message.reply('時間がわからへん')
|
|
44
|
+
else
|
|
45
|
+
message.reply(e.message)
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
def list(message)
|
|
50
|
+
start_at = Tokiyomi.parse(message[:start].tr('0-9', '0-9').gsub(/ヶ月|ケ月|か月|ヵ月|カ月/, '月'))
|
|
51
|
+
end_at = Tokiyomi.parse(message[:end].tr('0-9', '0-9').gsub(/ヶ月|ケ月|か月|ヵ月|カ月/, '月'))
|
|
52
|
+
|
|
53
|
+
reporter = reporter_for(message)
|
|
54
|
+
message.reply(reporter.new(kintai_range(start_at, end_at)).report)
|
|
55
|
+
rescue => e
|
|
56
|
+
message.reply("ごめんな、勤怠わからへん: #{e.message}@#{e.backtrace.take(5).join($/)}")
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
# こんな感じ
|
|
60
|
+
# {
|
|
61
|
+
# '2014-01-02': {
|
|
62
|
+
# 'blockgiven': {
|
|
63
|
+
# go_home_at: Time.now,
|
|
64
|
+
# go_work_at: Time.now
|
|
65
|
+
# }
|
|
66
|
+
# }
|
|
67
|
+
# }
|
|
68
|
+
def kintai(now = Time.now)
|
|
69
|
+
robot.brain.data[NAMESPACE] ||= {}
|
|
70
|
+
robot.brain.data[NAMESPACE][now.strftime("%Y-%m-%d")] ||= {}
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
def kintai_range(start_at, end_at)
|
|
74
|
+
Enumerator.new {|y|
|
|
75
|
+
time = start_at
|
|
76
|
+
while time < end_at.end_of_day do
|
|
77
|
+
y << [time.beginning_of_day, kintai(time)]
|
|
78
|
+
time = time.tomorrow
|
|
79
|
+
end
|
|
80
|
+
}
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
def work_time(time, name)
|
|
84
|
+
go_work_at = kintai(time).fetch(name, {})[:go_work_at]
|
|
85
|
+
go_home_at = kintai(time).fetch(name, {})[:go_home_at]
|
|
86
|
+
|
|
87
|
+
if go_work_at and go_home_at
|
|
88
|
+
Time.at(go_home_at - go_work_at - 9.hours).strftime("%H:%M") # FIXME
|
|
89
|
+
end
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
def reporter_for(message)
|
|
93
|
+
case message[:reporter]
|
|
94
|
+
when /csv/i
|
|
95
|
+
Ruboty::Kintai::Reporters::Csv
|
|
96
|
+
else
|
|
97
|
+
raise 'csv以外は出力できへん'
|
|
98
|
+
end
|
|
99
|
+
end
|
|
100
|
+
end
|
|
101
|
+
end
|
|
102
|
+
end
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
module Ruboty
|
|
2
|
+
module Kintai
|
|
3
|
+
module Reporters
|
|
4
|
+
class Csv
|
|
5
|
+
def initialize(kintai_range)
|
|
6
|
+
@kintai_range = kintai_range
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
def report
|
|
10
|
+
CSV.generate do |csv|
|
|
11
|
+
csv << %w(日付 名前 出勤 退勤)
|
|
12
|
+
@kintai_range.each do |time, kintais|
|
|
13
|
+
if kintais.empty?
|
|
14
|
+
csv << [time.strftime("%Y-%m-%d"), "", "", ""]
|
|
15
|
+
next
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
kintais.each do |name, kintai|
|
|
19
|
+
csv << [time.strftime("%Y-%m-%d"), name, kintai[:go_work_at], kintai[:go_home_at]]
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
end
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
require "ruboty/kintai/version"
|
|
2
|
+
require "ruboty/kintai/reporters/csv"
|
|
3
|
+
require "ruboty/handlers/kintai"
|
|
4
|
+
require "active_support"
|
|
5
|
+
require "active_support/core_ext"
|
|
6
|
+
require "tokiyomi"
|
|
7
|
+
|
|
8
|
+
module Ruboty
|
|
9
|
+
module Kintai
|
|
10
|
+
# Your code goes here...
|
|
11
|
+
end
|
|
12
|
+
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/kintai/version'
|
|
5
|
+
|
|
6
|
+
Gem::Specification.new do |spec|
|
|
7
|
+
spec.name = "ruboty-kintai"
|
|
8
|
+
spec.version = Ruboty::Kintai::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-kintai"
|
|
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_runtime_dependency "activesupport"
|
|
23
|
+
spec.add_development_dependency "bundler", "~> 1.7"
|
|
24
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
|
25
|
+
end
|
data/screenshot.png
ADDED
|
Binary file
|
metadata
ADDED
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: ruboty-kintai
|
|
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-20 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: activesupport
|
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
|
44
|
+
requirements:
|
|
45
|
+
- - ">="
|
|
46
|
+
- !ruby/object:Gem::Version
|
|
47
|
+
version: '0'
|
|
48
|
+
type: :runtime
|
|
49
|
+
prerelease: false
|
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
51
|
+
requirements:
|
|
52
|
+
- - ">="
|
|
53
|
+
- !ruby/object:Gem::Version
|
|
54
|
+
version: '0'
|
|
55
|
+
- !ruby/object:Gem::Dependency
|
|
56
|
+
name: bundler
|
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
|
58
|
+
requirements:
|
|
59
|
+
- - "~>"
|
|
60
|
+
- !ruby/object:Gem::Version
|
|
61
|
+
version: '1.7'
|
|
62
|
+
type: :development
|
|
63
|
+
prerelease: false
|
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
65
|
+
requirements:
|
|
66
|
+
- - "~>"
|
|
67
|
+
- !ruby/object:Gem::Version
|
|
68
|
+
version: '1.7'
|
|
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/handlers/kintai.rb
|
|
96
|
+
- lib/ruboty/kintai.rb
|
|
97
|
+
- lib/ruboty/kintai/reporters/csv.rb
|
|
98
|
+
- lib/ruboty/kintai/version.rb
|
|
99
|
+
- ruboty-kintai.gemspec
|
|
100
|
+
- screenshot.png
|
|
101
|
+
homepage: https://github.com/blockgiven/ruboty-kintai
|
|
102
|
+
licenses:
|
|
103
|
+
- MIT
|
|
104
|
+
metadata: {}
|
|
105
|
+
post_install_message:
|
|
106
|
+
rdoc_options: []
|
|
107
|
+
require_paths:
|
|
108
|
+
- lib
|
|
109
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
110
|
+
requirements:
|
|
111
|
+
- - ">="
|
|
112
|
+
- !ruby/object:Gem::Version
|
|
113
|
+
version: '0'
|
|
114
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
115
|
+
requirements:
|
|
116
|
+
- - ">="
|
|
117
|
+
- !ruby/object:Gem::Version
|
|
118
|
+
version: '0'
|
|
119
|
+
requirements: []
|
|
120
|
+
rubyforge_project:
|
|
121
|
+
rubygems_version: 2.2.2
|
|
122
|
+
signing_key:
|
|
123
|
+
specification_version: 4
|
|
124
|
+
summary: ruboty plugin for 勤怠管理.
|
|
125
|
+
test_files: []
|
|
126
|
+
has_rdoc:
|