ruboty-wareki 1.0.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: d91dfb1de9e8f506c59359e0dc350b578caacf34
4
+ data.tar.gz: 020d2862c231b17edc2aed6d8d4f235ba47fc21c
5
+ SHA512:
6
+ metadata.gz: 7e827110024e53b6cc32a6d886fb264323991dcb69498d3def03553e620752666551ae485a12fb553dab568410759cf96277218f4f683e098eed8430d4e44219
7
+ data.tar.gz: a8321e59f75c41ce7fe0ac6f31197e2625df7a4455fa68603cb8ce6909d6ffde2f01fcef9081ad2be956bec7e970e980687ff07ec72742d446a60307bf7e8963
data/.gitignore ADDED
@@ -0,0 +1,14 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ *.bundle
11
+ *.so
12
+ *.o
13
+ *.a
14
+ mkmf.log
data/Gemfile ADDED
@@ -0,0 +1,5 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in ruboty-wareki.gemspec
4
+ gemspec
5
+ gem 'era_ja'
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 tbpgr
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,82 @@
1
+ # Ruboty::Wareki
2
+
3
+ An Ruboty Handler + Actions to 西暦年から和暦を出力する ruboty-wareki を作成しました.
4
+
5
+ [Ruboty](https://github.com/r7kamura/ruboty) is Chat bot framework. Ruby + Bot = Ruboty
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'ruboty-wareki'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install ruboty-wareki
22
+
23
+
24
+ ## Commands
25
+
26
+ |Command|Pattern|Description|
27
+ |:--|:--|:--|
28
+ |convert|/wareki convert (?<year>.\d\{4\})\z/|get wareki from AD. ※1月1日時点の元号|
29
+ |convert_after|/wareki convert_after (?<year>.\d\{4\})\z/|get wareki from AD. ※12月31日時点の元号|
30
+
31
+ ## Usage
32
+ ### convert
33
+ * get wareki from AD. ※1月1日時点の元号
34
+
35
+ ~~~bash
36
+ >ruboty wareki convert 1868
37
+ >明治01年
38
+ >ruboty wareki convert 1913
39
+ >大正02年
40
+ >ruboty wareki convert 1977
41
+ >昭和52年
42
+ >ruboty wareki convert 1989
43
+ >昭和64年
44
+ >ruboty wareki convert 1990
45
+ >平成02年
46
+ ~~~
47
+
48
+ ### convert_after
49
+ * get wareki from AD. ※12月31日時点の元号
50
+
51
+ ~~~bash
52
+ >ruboty wareki convert_after 1868
53
+ >明治01年
54
+ >ruboty wareki convert_after 1913
55
+ >大正02年
56
+ >ruboty wareki convert_after 1977
57
+ >昭和52年
58
+ >ruboty wareki convert_after 1989
59
+ >平成01年
60
+ >ruboty wareki convert_after 1990
61
+ >平成02年
62
+ ~~~
63
+
64
+ ## ENV
65
+
66
+ |Name|Description|
67
+ |:--|:--|
68
+ |--|--|
69
+
70
+ ## Dependency
71
+
72
+ |Name|Description|
73
+ |:--|:--|
74
+ |era_ja gem|<i class="fa fa-github-square" style="font-size:1em;"></i> [era_ja gem](https://github.com/tomiacannondale/era_ja)|
75
+
76
+ ## Contributing
77
+
78
+ 1. Fork it ( https://github.com/tbpgr/ruboty-wareki/fork )
79
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
80
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
81
+ 4. Push to the branch (`git push origin my-new-feature`)
82
+ 5. Create a new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+
@@ -0,0 +1,19 @@
1
+ require "ruboty/wareki/actions/convert"
2
+ require "ruboty/wareki/actions/convert_after"
3
+
4
+ module Ruboty
5
+ module Handlers
6
+ class Wareki < Base
7
+ on /wareki convert (?<year>\d{4})\z/, name: 'convert', description: 'get wareki from AD. ※1月1日時点の元号'
8
+ on /wareki convert_after (?<year>\d{4})\z/, name: 'convert_after', description: 'get wareki from AD. ※12月31日時点の元号'
9
+
10
+ def convert(message)
11
+ Ruboty::Wareki::Actions::Convert.new(message).call
12
+ end
13
+
14
+ def convert_after(message)
15
+ Ruboty::Wareki::Actions::ConvertAfter.new(message).call
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,8 @@
1
+ require "ruboty/wareki/version"
2
+ require "ruboty/handlers/wareki"
3
+
4
+ module Ruboty
5
+ module Wareki
6
+ # Your code goes here...
7
+ end
8
+ end
@@ -0,0 +1,20 @@
1
+ require 'ruboty/wareki/actions/era_ja_helper'
2
+
3
+ module Ruboty
4
+ module Wareki
5
+ module Actions
6
+ class Convert < Ruboty::Actions::Base
7
+ include EraJaHelper
8
+ def call
9
+ message.reply(convert)
10
+ end
11
+
12
+ private
13
+
14
+ def convert
15
+ to_era(year)
16
+ end
17
+ end
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,20 @@
1
+ require 'ruboty/wareki/actions/era_ja_helper'
2
+
3
+ module Ruboty
4
+ module Wareki
5
+ module Actions
6
+ class ConvertAfter < Ruboty::Actions::Base
7
+ include EraJaHelper
8
+ def call
9
+ message.reply(convert_after)
10
+ end
11
+
12
+ private
13
+
14
+ def convert_after
15
+ to_era(year, 12, 31)
16
+ end
17
+ end
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,13 @@
1
+ require 'era_ja/date'
2
+
3
+ module EraJaHelper
4
+ def to_era(year, month = 1, day = 1)
5
+ Date.new(year, month, day).to_era("%O%E年")
6
+ rescue => e
7
+ "1868/09/08 以降の日付のみ対応しています"
8
+ end
9
+
10
+ def year
11
+ message[:year].to_i
12
+ end
13
+ end
@@ -0,0 +1,5 @@
1
+ module Ruboty
2
+ module Wareki
3
+ VERSION = "1.0.0"
4
+ end
5
+ end
@@ -0,0 +1,26 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'ruboty/wareki/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "ruboty-wareki"
8
+ spec.version = Ruboty::Wareki::VERSION
9
+ spec.authors = ["tbpgr"]
10
+ spec.email = ["tbpgr@tbpgr.jp"]
11
+ spec.summary = %q{Get wareki from AD.}
12
+ spec.description = %q{Get wareki from AD.}
13
+ spec.homepage = "https://github.com/tbpgr/ruboty-wareki"
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_runtime_dependency "era_ja"
23
+
24
+ spec.add_development_dependency "bundler", "~> 1.7"
25
+ spec.add_development_dependency "rake", "~> 10.0"
26
+ end
metadata ADDED
@@ -0,0 +1,112 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: ruboty-wareki
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - tbpgr
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-11-30 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: era_ja
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: rake
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ~>
60
+ - !ruby/object:Gem::Version
61
+ version: '10.0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ~>
67
+ - !ruby/object:Gem::Version
68
+ version: '10.0'
69
+ description: Get wareki from AD.
70
+ email:
71
+ - tbpgr@tbpgr.jp
72
+ executables: []
73
+ extensions: []
74
+ extra_rdoc_files: []
75
+ files:
76
+ - .gitignore
77
+ - Gemfile
78
+ - LICENSE.txt
79
+ - README.md
80
+ - Rakefile
81
+ - lib/ruboty/handlers/wareki.rb
82
+ - lib/ruboty/wareki.rb
83
+ - lib/ruboty/wareki/actions/convert.rb
84
+ - lib/ruboty/wareki/actions/convert_after.rb
85
+ - lib/ruboty/wareki/actions/era_ja_helper.rb
86
+ - lib/ruboty/wareki/version.rb
87
+ - ruboty-wareki.gemspec
88
+ homepage: https://github.com/tbpgr/ruboty-wareki
89
+ licenses:
90
+ - MIT
91
+ metadata: {}
92
+ post_install_message:
93
+ rdoc_options: []
94
+ require_paths:
95
+ - lib
96
+ required_ruby_version: !ruby/object:Gem::Requirement
97
+ requirements:
98
+ - - '>='
99
+ - !ruby/object:Gem::Version
100
+ version: '0'
101
+ required_rubygems_version: !ruby/object:Gem::Requirement
102
+ requirements:
103
+ - - '>='
104
+ - !ruby/object:Gem::Version
105
+ version: '0'
106
+ requirements: []
107
+ rubyforge_project:
108
+ rubygems_version: 2.3.0
109
+ signing_key:
110
+ specification_version: 4
111
+ summary: Get wareki from AD.
112
+ test_files: []