ruboty-ragoon 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +10 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +21 -0
- data/README.md +27 -0
- data/Rakefile +1 -0
- data/lib/ruboty/handlers/ragoon.rb +30 -0
- data/lib/ruboty/ragoon/config.rb +15 -0
- data/lib/ruboty/ragoon/event.rb +61 -0
- data/lib/ruboty/ragoon/template.rb +20 -0
- data/lib/ruboty/ragoon/version.rb +5 -0
- data/lib/ruboty/ragoon.rb +9 -0
- data/ruboty-ragoon.gemspec +27 -0
- data/templates/events.erb +9 -0
- metadata +127 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 0bc229ed3aeded0cb577e7dc2274e637f7898ede
|
4
|
+
data.tar.gz: 6eea99c21023d7e56ef0417efd06e7ec3f8b8924
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: b3738011691f8156f67d04a96050e8a20f3b5e9fac8246836e733ee8d92b07bca2979618ab13438e84782af855635b7c2340c61746125b766caebccbf8b27579
|
7
|
+
data.tar.gz: 83cb7af608c7af8a62424b7c46e2b29c9bafd11bfa6220a60309a1c2648cc2f61bf5f0c50b73941b3cc79f0141d92d803de90f6d441b6b8bcf7904deccd52bac
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2015 SHIOYA, Hiromu
|
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,27 @@
|
|
1
|
+
# Ruboty::Ragoon
|
2
|
+
|
3
|
+
[Ragoon](https://github.com/kwappa/ragoon) handler for [Ruboty](https://github.com/r7kamura/ruboty)
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your Ruboty's Gemfile:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem 'ruboty-ragoon'
|
11
|
+
```
|
12
|
+
|
13
|
+
## Variables
|
14
|
+
|
15
|
+
Set these variables to connect your Garoon (required by Ragoon)
|
16
|
+
|
17
|
+
- `GAROON_ENDPOINT` : your garoon URL (ends with `?WSDL`)
|
18
|
+
- `GAROON_USERNAME` : your garoon username
|
19
|
+
- `GAROON_PASSWORD` : your garoon password
|
20
|
+
|
21
|
+
## Usage
|
22
|
+
|
23
|
+
TODO: Write usage instructions here
|
24
|
+
|
25
|
+
## License
|
26
|
+
|
27
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
@@ -0,0 +1,30 @@
|
|
1
|
+
module Ruboty
|
2
|
+
module Handlers
|
3
|
+
class Ragoon < Base
|
4
|
+
on(/ragoon( me)? (?<date>.+)/, name: 'schedule', description: 'retrieve schedule from garoon')
|
5
|
+
|
6
|
+
def schedule(message)
|
7
|
+
target_date = parse_date(message[:date])
|
8
|
+
events = ::Ruboty::Ragoon::Event.new(target_date)
|
9
|
+
message.reply(events.render)
|
10
|
+
end
|
11
|
+
|
12
|
+
private
|
13
|
+
|
14
|
+
def parse_date(date)
|
15
|
+
case date.downcase
|
16
|
+
when 'today'
|
17
|
+
Date.today
|
18
|
+
when 'tomorrow'
|
19
|
+
Date.today + 1
|
20
|
+
when 'yesterday'
|
21
|
+
Date.today - 1
|
22
|
+
else
|
23
|
+
Date.parse(date)
|
24
|
+
end
|
25
|
+
rescue
|
26
|
+
Date.today
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module Ruboty
|
2
|
+
module Ragoon
|
3
|
+
module Config
|
4
|
+
TEMPLATE_DIRS = [
|
5
|
+
File.join(Dir.pwd, 'templates'),
|
6
|
+
File.join(File.dirname(File.expand_path(__FILE__)), '..', '..', '..', 'templates'),
|
7
|
+
]
|
8
|
+
|
9
|
+
def ragoon_config(key)
|
10
|
+
::Ruboty::Ragoon::Config.const_get(key.to_s.upcase)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
@@ -0,0 +1,61 @@
|
|
1
|
+
module Ruboty
|
2
|
+
module Ragoon
|
3
|
+
class Event
|
4
|
+
include ::Ruboty::Ragoon::Template
|
5
|
+
|
6
|
+
attr_accessor :date
|
7
|
+
attr_reader :events
|
8
|
+
|
9
|
+
def initialize(date = Date.today)
|
10
|
+
@date = date
|
11
|
+
self.retrieve
|
12
|
+
end
|
13
|
+
|
14
|
+
def retrieve
|
15
|
+
@events ||= ::Ragoon::Services::Schedule.new.schedule_get_events(::Ragoon::Services.start_and_end(date))
|
16
|
+
end
|
17
|
+
|
18
|
+
def render(private: false)
|
19
|
+
render_template('events', events: format(private), date: self.date)
|
20
|
+
end
|
21
|
+
|
22
|
+
private
|
23
|
+
|
24
|
+
def format(private)
|
25
|
+
@events.map { |event| format_event(event, private) }
|
26
|
+
end
|
27
|
+
|
28
|
+
def format_event(event, private)
|
29
|
+
plan = event[:plan].to_s != '' ? "【#{event[:plan].strip}】" : ''
|
30
|
+
period = if event[:allday]
|
31
|
+
'終日'
|
32
|
+
else
|
33
|
+
"#{format_time(event[:start_at])}〜#{format_time(event[:end_at])}"
|
34
|
+
end
|
35
|
+
if !private && event[:private]
|
36
|
+
title = '予定あり'
|
37
|
+
facilities = ''
|
38
|
+
else
|
39
|
+
title = event[:title]
|
40
|
+
facilities = event[:facilities].join(', ')
|
41
|
+
end
|
42
|
+
|
43
|
+
{
|
44
|
+
plan: plan,
|
45
|
+
period: period,
|
46
|
+
title: title,
|
47
|
+
facilities: facilities,
|
48
|
+
private: event[:private],
|
49
|
+
}
|
50
|
+
end
|
51
|
+
|
52
|
+
def format_time(time)
|
53
|
+
if time.to_s == ''
|
54
|
+
''
|
55
|
+
else
|
56
|
+
Time.parse(time).localtime.strftime('%R')
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module Ruboty
|
2
|
+
module Ragoon
|
3
|
+
module Template
|
4
|
+
include ::Ruboty::Ragoon::Config
|
5
|
+
|
6
|
+
def render_template(template_name, variables = {})
|
7
|
+
template = ::Tilt.new(find_template(template_name))
|
8
|
+
template.render(nil, variables)
|
9
|
+
end
|
10
|
+
|
11
|
+
def find_template(template_name)
|
12
|
+
ragoon_config(:template_dirs).each do |dirname|
|
13
|
+
template_file = Dir.glob(File.join(dirname, "#{template_name}*")).first
|
14
|
+
return template_file unless template_file.nil?
|
15
|
+
end
|
16
|
+
raise "Template Missing : #{template_name} is not found"
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
lib = File.expand_path('../lib', __FILE__)
|
2
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
3
|
+
require 'ruboty/ragoon/version'
|
4
|
+
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = 'ruboty-ragoon'
|
7
|
+
spec.version = Ruboty::Ragoon::VERSION
|
8
|
+
spec.authors = ['SHIOYA, Hiromu']
|
9
|
+
spec.email = ['kwappa.856@gmail.com']
|
10
|
+
|
11
|
+
spec.summary = 'ruboty handlers to use ragoon'
|
12
|
+
spec.description = spec.summary
|
13
|
+
spec.homepage = 'http://github.com/kwappa/ruboty-ragoon'
|
14
|
+
spec.license = 'MIT'
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
17
|
+
spec.bindir = 'exe'
|
18
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
19
|
+
spec.require_paths = ['lib']
|
20
|
+
|
21
|
+
spec.add_dependency 'ruboty'
|
22
|
+
spec.add_dependency 'ragoon'
|
23
|
+
spec.add_dependency 'tilt'
|
24
|
+
|
25
|
+
spec.add_development_dependency 'bundler', '~> 1.10'
|
26
|
+
spec.add_development_dependency 'rake', '~> 10.0'
|
27
|
+
end
|
@@ -0,0 +1,9 @@
|
|
1
|
+
<%= "*#{date.strftime('%m').gsub(/\A0/, '')}月#{date.strftime('%d').gsub(/\A0/, '')}日(#{%w[日 月 火 水 木 金 土][date.strftime('%w').to_i]})*" %>
|
2
|
+
|
3
|
+
<% if events.count > 0 %>
|
4
|
+
<% events.each do |event| %>
|
5
|
+
* <%= event[:period] %> <%= event[:plan] %> <%= event[:private] ? ':lock: ' : '' %><%= event[:title] %> <%= event[:facilities] %>
|
6
|
+
<% end %>
|
7
|
+
<% else %>
|
8
|
+
予定はありません。
|
9
|
+
<% end %>
|
metadata
ADDED
@@ -0,0 +1,127 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: ruboty-ragoon
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- SHIOYA, Hiromu
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-12-02 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: ragoon
|
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: tilt
|
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.10'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '1.10'
|
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: ruboty handlers to use ragoon
|
84
|
+
email:
|
85
|
+
- kwappa.856@gmail.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/ragoon.rb
|
96
|
+
- lib/ruboty/ragoon.rb
|
97
|
+
- lib/ruboty/ragoon/config.rb
|
98
|
+
- lib/ruboty/ragoon/event.rb
|
99
|
+
- lib/ruboty/ragoon/template.rb
|
100
|
+
- lib/ruboty/ragoon/version.rb
|
101
|
+
- ruboty-ragoon.gemspec
|
102
|
+
- templates/events.erb
|
103
|
+
homepage: http://github.com/kwappa/ruboty-ragoon
|
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.4.5.1
|
124
|
+
signing_key:
|
125
|
+
specification_version: 4
|
126
|
+
summary: ruboty handlers to use ragoon
|
127
|
+
test_files: []
|