aun 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +3 -3
- data/README.md +21 -0
- data/aun.gemspec +24 -24
- data/bin/aun +68 -68
- data/lib/aun/default_messages.rb +7 -0
- data/lib/aun/definition_manager.rb +17 -3
- data/lib/aun/finder.rb +18 -6
- data/lib/aun/version.rb +3 -3
- data/spec/aun/finder_spec.rb +394 -315
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 12979ef90ff5c7d165203cb0860ceb7c2b7e0db7
|
4
|
+
data.tar.gz: 8d287341379dee434fe3af5caa8bb74c2198b476
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f55e0b4aaba6f93a2e28f0e39e9d66487546b99e3f2748062382310a8290ba7bb26e23559b2339ad1665cb5dbbcda040b03a57d7234efe0e4458e97d9fb31176
|
7
|
+
data.tar.gz: 7d7e9f462ea9fc93279655785cb2ba846d72d3968256cbe7635cbe6f3e2911835d38bf2c9638a16a571a74745bb60b2fc785a78dd9b83ee39fed6b9278ec5cc3
|
data/Gemfile
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
source 'https://rubygems.org'
|
2
2
|
|
3
3
|
gemspec
|
4
|
-
gem
|
5
|
-
gem
|
6
|
-
gem
|
4
|
+
gem 'rspec', '~> 2.14.1'
|
5
|
+
gem 'thor', '~> 0.18.1'
|
6
|
+
gem 'simplecov', '~> 0.8.2'
|
7
7
|
group :test do
|
8
8
|
gem 'coveralls', require: false
|
9
9
|
end
|
data/README.md
CHANGED
@@ -2,6 +2,7 @@
|
|
2
2
|
|
3
3
|
[![Gem Version](https://badge.fury.io/rb/aun.svg)](http://badge.fury.io/rb/aun)
|
4
4
|
[![Build Status](https://travis-ci.org/tbpgr/aun.png?branch=master)](https://travis-ci.org/tbpgr/aun)
|
5
|
+
[![Coverage Status](https://coveralls.io/repos/tbpgr/aun/badge.png)](https://coveralls.io/r/tbpgr/aun)
|
5
6
|
|
6
7
|
Aun [阿吽] は「阿吽の呼吸」、「ツー」といえば「カー」など
|
7
8
|
A に呼応して B のメッセージを返却するためのツールです。
|
@@ -132,6 +133,15 @@ print finder.talk_with_origin('ぬるぽ'), "\n"
|
|
132
133
|
print finder.talk('やらないか?'), "\n"
|
133
134
|
print finder.owner_talk('やらないか?'), "\n"
|
134
135
|
print finder.talk_with_origin('やらないか?'), "\n"
|
136
|
+
print finder.talk_with_origin('ゆ・・・ゆるさん・・・'), "\n"
|
137
|
+
print finder.talk_with_origin('ゆ・・・ゆるさん・・・'), "\n"
|
138
|
+
print finder.talk_with_origin('ゆ・・・ゆるさん・・・'), "\n"
|
139
|
+
|
140
|
+
puts "!!! ver 0.0.2. 原典フィルタ !!!"
|
141
|
+
print finder.inspect_all('ドラゴンボール'), "\n"
|
142
|
+
print finder.talk_with_origin('ゆ・・・ゆるさん・・・', 'ドラゴンボール'), "\n"
|
143
|
+
print finder.talk_with_origin('ゆ・・・ゆるさん・・・', 'ドラゴンボール'), "\n"
|
144
|
+
print finder.talk_with_origin('ゆ・・・ゆるさん・・・', 'ドラゴンボール'), "\n"
|
135
145
|
~~~
|
136
146
|
|
137
147
|
### 出力
|
@@ -151,6 +161,16 @@ print finder.talk_with_origin('やらないか?'), "\n"
|
|
151
161
|
アーッ!
|
152
162
|
阿部さん「アーッ!」
|
153
163
|
阿部さん「アーッ!」 from [くそみそテクニック]
|
164
|
+
フリーザ「ぜったいにゆるさんぞ虫ケラども!!!」 from [ドラゴンボール]
|
165
|
+
山田 太郎「ぜったいにゆるさんぞ虫ケラども!!!」 from [珍遊記]
|
166
|
+
フリーザ「ぜったいにゆるさんぞ虫ケラども!!!」 from [ドラゴンボール]
|
167
|
+
!!! ver 0.0.2. 原典フィルタ !!!
|
168
|
+
阿:オス 吽:オラ悟空 発言者:孫悟空 原典:ドラゴンボール, ユーザー定義:false
|
169
|
+
阿:今度は木っ端微塵にしてやる。あの地球人のように 吽:クリリンのことか───────っ!!!!! 発言者:孫悟空 原典:ドラゴンボール, ユーザー定義:false
|
170
|
+
阿:ゆ・・・ゆるさん・・・ 吽:ぜったいにゆるさんぞ虫ケラども!!! 発言者:フリーザ 原典:ドラゴンボール, ユーザー定義:false
|
171
|
+
フリーザ「ぜったいにゆるさんぞ虫ケラども!!!」 from [ドラゴンボール]
|
172
|
+
フリーザ「ぜったいにゆるさんぞ虫ケラども!!!」 from [ドラゴンボール]
|
173
|
+
フリーザ「ぜったいにゆるさんぞ虫ケラども!!!」 from [ドラゴンボール]
|
154
174
|
~~~
|
155
175
|
|
156
176
|
## デフォルト阿吽メッセージへのプルリク
|
@@ -161,6 +181,7 @@ merge か reject かは独断と偏見で行います。
|
|
161
181
|
また元ネタの説明は出来る限り日本語でお願いします。
|
162
182
|
|
163
183
|
## History
|
184
|
+
* version 0.0.2 : 原典絞込オプション追加(CLIは未対応)
|
164
185
|
* version 0.0.1 : First release.
|
165
186
|
|
166
187
|
## Contributing
|
data/aun.gemspec
CHANGED
@@ -1,24 +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 'aun/version'
|
5
|
-
|
6
|
-
Gem::Specification.new do |spec|
|
7
|
-
spec.name = 'aun'
|
8
|
-
spec.version = Aun::VERSION
|
9
|
-
spec.authors = ['tbpgr']
|
10
|
-
spec.email = ['tbpgr@tbpgr.jp']
|
11
|
-
spec.summary =
|
12
|
-
spec.description =
|
13
|
-
spec.homepage = 'https://github.com/tbpgr/aun'
|
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_development_dependency 'bundler', '~> 1.6'
|
22
|
-
spec.add_development_dependency 'rake', '~> 10.0'
|
23
|
-
spec.add_development_dependency 'rspec'
|
24
|
-
end
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'aun/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = 'aun'
|
8
|
+
spec.version = Aun::VERSION
|
9
|
+
spec.authors = ['tbpgr']
|
10
|
+
spec.email = ['tbpgr@tbpgr.jp']
|
11
|
+
spec.summary = 'A-Un'
|
12
|
+
spec.description = 'A-Un'
|
13
|
+
spec.homepage = 'https://github.com/tbpgr/aun'
|
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_development_dependency 'bundler', '~> 1.6'
|
22
|
+
spec.add_development_dependency 'rake', '~> 10.0'
|
23
|
+
spec.add_development_dependency 'rspec'
|
24
|
+
end
|
data/bin/aun
CHANGED
@@ -1,68 +1,68 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
# encoding: utf-8
|
3
|
-
|
4
|
-
require 'aun_core'
|
5
|
-
require 'aun/version'
|
6
|
-
require 'thor'
|
7
|
-
|
8
|
-
module Aun
|
9
|
-
# = Aun CLI
|
10
|
-
class CLI < Thor
|
11
|
-
class_option :help, type: :boolean, aliases: '-h', desc: 'help message.'
|
12
|
-
class_option :version, type: :boolean, desc: 'version'
|
13
|
-
|
14
|
-
desc 'init', 'Generate Aundefinition.csv template'
|
15
|
-
def init
|
16
|
-
Aun::DefinitionManager.new.init
|
17
|
-
exit(true)
|
18
|
-
rescue
|
19
|
-
exit(false)
|
20
|
-
end
|
21
|
-
|
22
|
-
desc 'inspect_all', 'inspect_all'
|
23
|
-
def inspect_all
|
24
|
-
call_finder_no_arity(:inspect_all)
|
25
|
-
end
|
26
|
-
|
27
|
-
%i(talk owner_talk talk_with_origin inspect).each do |m|
|
28
|
-
desc m.to_s, m.to_s
|
29
|
-
define_method m do |key|
|
30
|
-
call_finder_1_arity(m, key)
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
|
-
desc 'version', 'version'
|
35
|
-
def version
|
36
|
-
p Aun::VERSION
|
37
|
-
end
|
38
|
-
|
39
|
-
private
|
40
|
-
|
41
|
-
def call_finder_no_arity(m)
|
42
|
-
af = get_finder_instance
|
43
|
-
puts af.send(m)
|
44
|
-
exit(true)
|
45
|
-
rescue => e
|
46
|
-
STDERR.puts(e.backtrace)
|
47
|
-
exit(false)
|
48
|
-
end
|
49
|
-
|
50
|
-
def call_finder_1_arity(m, key)
|
51
|
-
af = get_finder_instance
|
52
|
-
puts af.send(m, key.encode('utf-8'))
|
53
|
-
exit(true)
|
54
|
-
rescue => e
|
55
|
-
STDERR.puts(e.backtrace)
|
56
|
-
exit(false)
|
57
|
-
end
|
58
|
-
|
59
|
-
def get_finder_instance
|
60
|
-
user_definition = Aun::DefinitionManager.new.load_user_definition
|
61
|
-
af = Aun::Finder.new
|
62
|
-
af.add_messages(user_definition)
|
63
|
-
af
|
64
|
-
end
|
65
|
-
end
|
66
|
-
end
|
67
|
-
|
68
|
-
Aun::CLI.start(ARGV)
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# encoding: utf-8
|
3
|
+
|
4
|
+
require 'aun_core'
|
5
|
+
require 'aun/version'
|
6
|
+
require 'thor'
|
7
|
+
|
8
|
+
module Aun
|
9
|
+
# = Aun CLI
|
10
|
+
class CLI < Thor
|
11
|
+
class_option :help, type: :boolean, aliases: '-h', desc: 'help message.'
|
12
|
+
class_option :version, type: :boolean, desc: 'version'
|
13
|
+
|
14
|
+
desc 'init', 'Generate Aundefinition.csv template'
|
15
|
+
def init
|
16
|
+
Aun::DefinitionManager.new.init
|
17
|
+
exit(true)
|
18
|
+
rescue
|
19
|
+
exit(false)
|
20
|
+
end
|
21
|
+
|
22
|
+
desc 'inspect_all', 'inspect_all'
|
23
|
+
def inspect_all
|
24
|
+
call_finder_no_arity(:inspect_all)
|
25
|
+
end
|
26
|
+
|
27
|
+
%i(talk owner_talk talk_with_origin inspect).each do |m|
|
28
|
+
desc m.to_s, m.to_s
|
29
|
+
define_method m do |key|
|
30
|
+
call_finder_1_arity(m, key)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
desc 'version', 'version'
|
35
|
+
def version
|
36
|
+
p Aun::VERSION
|
37
|
+
end
|
38
|
+
|
39
|
+
private
|
40
|
+
|
41
|
+
def call_finder_no_arity(m)
|
42
|
+
af = get_finder_instance
|
43
|
+
puts af.send(m)
|
44
|
+
exit(true)
|
45
|
+
rescue => e
|
46
|
+
STDERR.puts(e.backtrace)
|
47
|
+
exit(false)
|
48
|
+
end
|
49
|
+
|
50
|
+
def call_finder_1_arity(m, key)
|
51
|
+
af = get_finder_instance
|
52
|
+
puts af.send(m, key.encode('utf-8'))
|
53
|
+
exit(true)
|
54
|
+
rescue => e
|
55
|
+
STDERR.puts(e.backtrace)
|
56
|
+
exit(false)
|
57
|
+
end
|
58
|
+
|
59
|
+
def get_finder_instance
|
60
|
+
user_definition = Aun::DefinitionManager.new.load_user_definition
|
61
|
+
af = Aun::Finder.new
|
62
|
+
af.add_messages(user_definition)
|
63
|
+
af
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
Aun::CLI.start(ARGV)
|
data/lib/aun/default_messages.rb
CHANGED
@@ -1,10 +1,17 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
module Aun
|
3
|
+
# rubocop:disable LineLength
|
3
4
|
module DefaultMessages
|
4
5
|
MESSAGES = [
|
5
6
|
Message.new('君名前は?', '田原年彦', owner: '田原年彦', origin: '行け!稲中卓球部'),
|
6
7
|
Message.new('山', '川'),
|
7
8
|
Message.new('ぬるぽ', 'ガッ'),
|
9
|
+
Message.new('もうおわりだ', '戸棚のウラはネズミの卵でいっぱいだー!', owner: '二階堂昭夫', origin: '動物のお医者さん'),
|
10
|
+
Message.new('オス', 'オラ悟空', owner: '孫悟空', origin: 'ドラゴンボール'),
|
11
|
+
Message.new('今度は木っ端微塵にしてやる。あの地球人のように', 'クリリンのことか───────っ!!!!!', owner: '孫悟空', origin: 'ドラゴンボール'),
|
12
|
+
Message.new('ゆ・・・ゆるさん・・・', 'ぜったいにゆるさんぞ虫ケラども!!!', owner: 'フリーザ', origin: 'ドラゴンボール'),
|
13
|
+
Message.new('ゆ・・・ゆるさん・・・', 'ぜったいにゆるさんぞ虫ケラども!!!', owner: '山田 太郎', origin: '珍遊記')
|
8
14
|
]
|
9
15
|
end
|
10
16
|
end
|
17
|
+
# rubocop:enable LineLength
|
@@ -8,22 +8,36 @@ module Aun
|
|
8
8
|
阿(例:海賊王に),吽(例:俺はなる),発言者(モンキー・D・ルフィ※不明の場合は空欄に),原典(One Piece※不明の場合は空欄に)
|
9
9
|
EOS
|
10
10
|
|
11
|
+
module AunDefinitionColumns
|
12
|
+
A = 0
|
13
|
+
UN = 1
|
14
|
+
OWNER = 2
|
15
|
+
ORIGIN = 3
|
16
|
+
end
|
17
|
+
|
11
18
|
def init
|
12
19
|
File.open(AUNDEFINITION_FILE, 'w:UTF-8') do |f|
|
13
20
|
f.puts AUNDEFINITION_TEMPLATE
|
14
21
|
end
|
15
22
|
end
|
16
23
|
|
24
|
+
# rubocop:disable MethodLength
|
25
|
+
|
26
|
+
# load_user_definition
|
17
27
|
def load_user_definition
|
18
28
|
return [] unless File.exist?(AUNDEFINITION_FILE)
|
19
29
|
memo = []
|
20
30
|
CSV.foreach(AUNDEFINITION_FILE, encoding: 'utf-8') do |row|
|
21
|
-
owner = row[
|
22
|
-
origin = row[
|
23
|
-
memo << Aun::Message.new(
|
31
|
+
owner = row[AunDefinitionColumns::OWNER]
|
32
|
+
origin = row[AunDefinitionColumns::ORIGIN]
|
33
|
+
memo << Aun::Message.new(
|
34
|
+
row[AunDefinitionColumns::A],
|
35
|
+
row[AunDefinitionColumns::UN],
|
36
|
+
owner: owner, origin: origin, user_defined: true)
|
24
37
|
end
|
25
38
|
memo
|
26
39
|
end
|
40
|
+
# rubocop:enable MethodLength
|
27
41
|
|
28
42
|
private
|
29
43
|
def empty_to_unknown(target)
|
data/lib/aun/finder.rb
CHANGED
@@ -9,18 +9,30 @@ module Aun
|
|
9
9
|
end
|
10
10
|
|
11
11
|
%i(talk owner_talk talk_with_origin inspect).each do |m|
|
12
|
-
define_method m do |key|
|
13
|
-
message =
|
12
|
+
define_method m do |key, origin_filter = ''|
|
13
|
+
message =
|
14
|
+
if origin_filter && origin_filter.empty?
|
15
|
+
@messages.select { |e|e.a == key }
|
16
|
+
else
|
17
|
+
@messages.select { |e|e.origin == origin_filter }
|
18
|
+
.select { |e|e.a == key }
|
19
|
+
end
|
14
20
|
message.empty? ? '' : message.sample.send(m)
|
15
21
|
end
|
16
22
|
end
|
17
23
|
|
18
|
-
def inspect_all
|
19
|
-
|
24
|
+
def inspect_all(origin_filter = '')
|
25
|
+
if origin_filter && origin_filter.empty?
|
26
|
+
@messages.map(&:inspect).join("\n")
|
27
|
+
else
|
28
|
+
@messages.select { |e|e.origin == origin_filter }
|
29
|
+
.map(&:inspect).join("\n")
|
30
|
+
end
|
20
31
|
end
|
21
32
|
|
22
|
-
def aun_definitions
|
23
|
-
@messages
|
33
|
+
def aun_definitions(origin_filter = '')
|
34
|
+
return @messages if origin_filter.empty?
|
35
|
+
@messages.select { |e|e.origin == origin_filter }
|
24
36
|
end
|
25
37
|
|
26
38
|
def add_messages(messages = [])
|
data/lib/aun/version.rb
CHANGED
@@ -1,3 +1,3 @@
|
|
1
|
-
module Aun
|
2
|
-
VERSION = '0.0.
|
3
|
-
end
|
1
|
+
module Aun
|
2
|
+
VERSION = '0.0.2'
|
3
|
+
end
|
data/spec/aun/finder_spec.rb
CHANGED
@@ -1,315 +1,394 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
require 'spec_helper'
|
3
|
-
require 'aun/finder'
|
4
|
-
require 'aun/default_messages'
|
5
|
-
|
6
|
-
describe Aun::Finder do
|
7
|
-
context :talk do
|
8
|
-
cases = [
|
9
|
-
{
|
10
|
-
case_no: 1,
|
11
|
-
case_title: 'valid key',
|
12
|
-
key: '君名前は?',
|
13
|
-
expected: '田原年彦'
|
14
|
-
},
|
15
|
-
{
|
16
|
-
case_no: 2,
|
17
|
-
case_title: 'not exist key',
|
18
|
-
key: '山んば',
|
19
|
-
expected: ''
|
20
|
-
}
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
end
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
|
314
|
-
|
315
|
-
|
1
|
+
# encoding: utf-8
|
2
|
+
require 'spec_helper'
|
3
|
+
require 'aun/finder'
|
4
|
+
require 'aun/default_messages'
|
5
|
+
|
6
|
+
describe Aun::Finder do
|
7
|
+
context :talk do
|
8
|
+
cases = [
|
9
|
+
{
|
10
|
+
case_no: 1,
|
11
|
+
case_title: 'valid key',
|
12
|
+
key: '君名前は?',
|
13
|
+
expected: '田原年彦'
|
14
|
+
},
|
15
|
+
{
|
16
|
+
case_no: 2,
|
17
|
+
case_title: 'not exist key',
|
18
|
+
key: '山んば',
|
19
|
+
expected: ''
|
20
|
+
},
|
21
|
+
{
|
22
|
+
case_no: 3,
|
23
|
+
case_title: 'valid key with origin filter',
|
24
|
+
key: 'ゆ・・・ゆるさん・・・',
|
25
|
+
origin_filter: 'ドラゴンボール',
|
26
|
+
expected: 'ぜったいにゆるさんぞ虫ケラども!!!'
|
27
|
+
}
|
28
|
+
]
|
29
|
+
|
30
|
+
cases.each do |c|
|
31
|
+
it "|case_no=#{c[:case_no]}|case_title=#{c[:case_title]}" do
|
32
|
+
begin
|
33
|
+
case_before c
|
34
|
+
|
35
|
+
# -- given --
|
36
|
+
aun_message = Aun::Finder.new
|
37
|
+
|
38
|
+
# -- when --
|
39
|
+
actual =
|
40
|
+
if c[:origin_filter]
|
41
|
+
aun_message.talk(c[:key], c[:origin_filter])
|
42
|
+
else
|
43
|
+
aun_message.talk(c[:key])
|
44
|
+
end
|
45
|
+
|
46
|
+
# -- then --
|
47
|
+
expect(actual).to eq(c[:expected])
|
48
|
+
ensure
|
49
|
+
case_after c
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
def case_before(c)
|
54
|
+
# implement each case before
|
55
|
+
end
|
56
|
+
|
57
|
+
def case_after(c)
|
58
|
+
# implement each case after
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
context :owner_talk do
|
64
|
+
cases = [
|
65
|
+
{
|
66
|
+
case_no: 1,
|
67
|
+
case_title: 'valid key',
|
68
|
+
key: '君名前は?',
|
69
|
+
expected: '田原年彦「田原年彦」'
|
70
|
+
},
|
71
|
+
{
|
72
|
+
case_no: 2,
|
73
|
+
case_title: 'not exist key',
|
74
|
+
key: '山んば',
|
75
|
+
expected: ''
|
76
|
+
},
|
77
|
+
{
|
78
|
+
case_no: 3,
|
79
|
+
case_title: 'valid key with origin filter',
|
80
|
+
key: 'ゆ・・・ゆるさん・・・',
|
81
|
+
origin_filter: 'ドラゴンボール',
|
82
|
+
expected: 'フリーザ「ぜったいにゆるさんぞ虫ケラども!!!」'
|
83
|
+
}
|
84
|
+
]
|
85
|
+
|
86
|
+
cases.each do |c|
|
87
|
+
it "|case_no=#{c[:case_no]}|case_title=#{c[:case_title]}" do
|
88
|
+
begin
|
89
|
+
case_before c
|
90
|
+
|
91
|
+
# -- given --
|
92
|
+
aun_message = Aun::Finder.new
|
93
|
+
|
94
|
+
# -- when --
|
95
|
+
actual =
|
96
|
+
if c[:origin_filter]
|
97
|
+
aun_message.owner_talk(c[:key], c[:origin_filter])
|
98
|
+
else
|
99
|
+
aun_message.owner_talk(c[:key])
|
100
|
+
end
|
101
|
+
|
102
|
+
# -- then --
|
103
|
+
expect(actual).to eq(c[:expected])
|
104
|
+
ensure
|
105
|
+
case_after c
|
106
|
+
end
|
107
|
+
end
|
108
|
+
|
109
|
+
def case_before(c)
|
110
|
+
# implement each case before
|
111
|
+
end
|
112
|
+
|
113
|
+
def case_after(c)
|
114
|
+
# implement each case after
|
115
|
+
end
|
116
|
+
end
|
117
|
+
end
|
118
|
+
|
119
|
+
context :talk_with_origin do
|
120
|
+
cases = [
|
121
|
+
{
|
122
|
+
case_no: 1,
|
123
|
+
case_title: 'valid key',
|
124
|
+
key: '君名前は?',
|
125
|
+
expected: '田原年彦「田原年彦」 from [行け!稲中卓球部]'
|
126
|
+
},
|
127
|
+
{
|
128
|
+
case_no: 2,
|
129
|
+
case_title: 'not exist key',
|
130
|
+
key: '山んば',
|
131
|
+
expected: ''
|
132
|
+
},
|
133
|
+
{
|
134
|
+
case_no: 3,
|
135
|
+
case_title: 'valid key with origin filter',
|
136
|
+
key: 'ゆ・・・ゆるさん・・・',
|
137
|
+
origin_filter: 'ドラゴンボール',
|
138
|
+
expected: 'フリーザ「ぜったいにゆるさんぞ虫ケラども!!!」 from [ドラゴンボール]'
|
139
|
+
}
|
140
|
+
]
|
141
|
+
|
142
|
+
cases.each do |c|
|
143
|
+
it "|case_no=#{c[:case_no]}|case_title=#{c[:case_title]}" do
|
144
|
+
begin
|
145
|
+
case_before c
|
146
|
+
|
147
|
+
# -- given --
|
148
|
+
aun_message = Aun::Finder.new
|
149
|
+
|
150
|
+
# -- when --
|
151
|
+
actual =
|
152
|
+
if c[:origin_filter]
|
153
|
+
aun_message.talk_with_origin(c[:key], c[:origin_filter])
|
154
|
+
else
|
155
|
+
aun_message.talk_with_origin(c[:key])
|
156
|
+
end
|
157
|
+
|
158
|
+
# -- then --
|
159
|
+
expect(actual).to eq(c[:expected])
|
160
|
+
ensure
|
161
|
+
case_after c
|
162
|
+
end
|
163
|
+
end
|
164
|
+
|
165
|
+
def case_before(c)
|
166
|
+
# implement each case before
|
167
|
+
end
|
168
|
+
|
169
|
+
def case_after(c)
|
170
|
+
# implement each case after
|
171
|
+
end
|
172
|
+
end
|
173
|
+
end
|
174
|
+
|
175
|
+
context :inspect do
|
176
|
+
cases = [
|
177
|
+
{
|
178
|
+
case_no: 1,
|
179
|
+
case_title: 'valid key',
|
180
|
+
key: '君名前は?',
|
181
|
+
expected: "阿:君名前は?\t吽:田原年彦\t発言者:田原年彦\t原典:行け!稲中卓球部,\tユーザー定義:false"
|
182
|
+
},
|
183
|
+
{
|
184
|
+
case_no: 2,
|
185
|
+
case_title: 'not exist key',
|
186
|
+
key: '山んば',
|
187
|
+
expected: ''
|
188
|
+
},
|
189
|
+
{
|
190
|
+
case_no: 3,
|
191
|
+
case_title: 'valid key with origin filter',
|
192
|
+
key: 'ゆ・・・ゆるさん・・・',
|
193
|
+
origin_filter: 'ドラゴンボール',
|
194
|
+
expected: "阿:ゆ・・・ゆるさん・・・\t吽:ぜったいにゆるさんぞ虫ケラども!!!\t発言者:フリーザ\t原典:ドラゴンボール,\tユーザー定義:false"
|
195
|
+
}
|
196
|
+
]
|
197
|
+
|
198
|
+
cases.each do |c|
|
199
|
+
it "|case_no=#{c[:case_no]}|case_title=#{c[:case_title]}" do
|
200
|
+
begin
|
201
|
+
case_before c
|
202
|
+
|
203
|
+
# -- given --
|
204
|
+
aun_message = Aun::Finder.new
|
205
|
+
|
206
|
+
# -- when --
|
207
|
+
actual =
|
208
|
+
if c[:origin_filter]
|
209
|
+
aun_message.inspect(c[:key], c[:origin_filter])
|
210
|
+
else
|
211
|
+
aun_message.inspect(c[:key])
|
212
|
+
end
|
213
|
+
|
214
|
+
# -- then --
|
215
|
+
expect(actual).to eq(c[:expected])
|
216
|
+
ensure
|
217
|
+
case_after c
|
218
|
+
end
|
219
|
+
end
|
220
|
+
|
221
|
+
def case_before(c)
|
222
|
+
# implement each case before
|
223
|
+
end
|
224
|
+
|
225
|
+
def case_after(c)
|
226
|
+
# implement each case after
|
227
|
+
end
|
228
|
+
end
|
229
|
+
end
|
230
|
+
|
231
|
+
context :inspect_all do
|
232
|
+
cases = [
|
233
|
+
{
|
234
|
+
case_no: 1,
|
235
|
+
case_title: 'valid key',
|
236
|
+
expected: <<-EOS
|
237
|
+
阿:君名前は?\t吽:田原年彦\t発言者:田原年彦\t原典:行け!稲中卓球部,\tユーザー定義:false
|
238
|
+
阿:山\t吽:川\t発言者:unknown\t原典:unknown,\tユーザー定義:false
|
239
|
+
阿:ぬるぽ\t吽:ガッ\t発言者:unknown\t原典:unknown,\tユーザー定義:false
|
240
|
+
阿:もうおわりだ\t吽:戸棚のウラはネズミの卵でいっぱいだー!\t発言者:二階堂昭夫\t原典:動物のお医者さん,\tユーザー定義:false
|
241
|
+
阿:オス\t吽:オラ悟空\t発言者:孫悟空\t原典:ドラゴンボール,\tユーザー定義:false
|
242
|
+
阿:今度は木っ端微塵にしてやる。あの地球人のように\t吽:クリリンのことか───────っ!!!!!\t発言者:孫悟空\t原典:ドラゴンボール,\tユーザー定義:false
|
243
|
+
阿:ゆ・・・ゆるさん・・・\t吽:ぜったいにゆるさんぞ虫ケラども!!!\t発言者:フリーザ\t原典:ドラゴンボール,\tユーザー定義:false
|
244
|
+
阿:ゆ・・・ゆるさん・・・\t吽:ぜったいにゆるさんぞ虫ケラども!!!\t発言者:山田 太郎\t原典:珍遊記,\tユーザー定義:false
|
245
|
+
EOS
|
246
|
+
},
|
247
|
+
{
|
248
|
+
case_no: 2,
|
249
|
+
case_title: 'valid key with origin filter',
|
250
|
+
origin_filter: 'ドラゴンボール',
|
251
|
+
expected: <<-EOS
|
252
|
+
阿:オス\t吽:オラ悟空\t発言者:孫悟空\t原典:ドラゴンボール,\tユーザー定義:false
|
253
|
+
阿:今度は木っ端微塵にしてやる。あの地球人のように\t吽:クリリンのことか───────っ!!!!!\t発言者:孫悟空\t原典:ドラゴンボール,\tユーザー定義:false
|
254
|
+
阿:ゆ・・・ゆるさん・・・\t吽:ぜったいにゆるさんぞ虫ケラども!!!\t発言者:フリーザ\t原典:ドラゴンボール,\tユーザー定義:false
|
255
|
+
EOS
|
256
|
+
}
|
257
|
+
]
|
258
|
+
|
259
|
+
cases.each do |c|
|
260
|
+
it "|case_no=#{c[:case_no]}|case_title=#{c[:case_title]}" do
|
261
|
+
begin
|
262
|
+
case_before c
|
263
|
+
|
264
|
+
# -- given --
|
265
|
+
aun_message = Aun::Finder.new
|
266
|
+
|
267
|
+
# -- when --
|
268
|
+
actual = aun_message.inspect_all
|
269
|
+
actual =
|
270
|
+
if c[:origin_filter]
|
271
|
+
aun_message.inspect_all(c[:origin_filter])
|
272
|
+
else
|
273
|
+
aun_message.inspect_all
|
274
|
+
end
|
275
|
+
|
276
|
+
# -- then --
|
277
|
+
expect(actual).to eq(c[:expected].chomp)
|
278
|
+
ensure
|
279
|
+
case_after c
|
280
|
+
end
|
281
|
+
end
|
282
|
+
|
283
|
+
def case_before(c)
|
284
|
+
# implement each case before
|
285
|
+
end
|
286
|
+
|
287
|
+
def case_after(c)
|
288
|
+
# implement each case after
|
289
|
+
end
|
290
|
+
end
|
291
|
+
end
|
292
|
+
|
293
|
+
context :aun_definitions do
|
294
|
+
cases = [
|
295
|
+
{
|
296
|
+
case_no: 1,
|
297
|
+
case_title: 'valid case',
|
298
|
+
expected: Aun::DefaultMessages::MESSAGES
|
299
|
+
},
|
300
|
+
{
|
301
|
+
case_no: 1,
|
302
|
+
case_title: 'valid case',
|
303
|
+
origin_filter: 'ドラゴンボール',
|
304
|
+
expected: Aun::DefaultMessages::MESSAGES.select { |e|e.origin == 'ドラゴンボール' }
|
305
|
+
},
|
306
|
+
]
|
307
|
+
|
308
|
+
cases.each do |c|
|
309
|
+
it "|case_no=#{c[:case_no]}|case_title=#{c[:case_title]}" do
|
310
|
+
begin
|
311
|
+
case_before c
|
312
|
+
|
313
|
+
# -- given --
|
314
|
+
aun_message = Aun::Finder.new
|
315
|
+
|
316
|
+
# -- when --
|
317
|
+
actual =
|
318
|
+
if c[:origin_filter]
|
319
|
+
aun_message.aun_definitions(c[:origin_filter])
|
320
|
+
else
|
321
|
+
aun_message.aun_definitions
|
322
|
+
end
|
323
|
+
|
324
|
+
# -- then --
|
325
|
+
expect(actual).to eq(c[:expected])
|
326
|
+
ensure
|
327
|
+
case_after c
|
328
|
+
end
|
329
|
+
end
|
330
|
+
|
331
|
+
def case_before(c)
|
332
|
+
# implement each case before
|
333
|
+
end
|
334
|
+
|
335
|
+
def case_after(c)
|
336
|
+
# implement each case after
|
337
|
+
end
|
338
|
+
end
|
339
|
+
end
|
340
|
+
|
341
|
+
context :add_messages do
|
342
|
+
ADDITIONAL_MESSAGES = [
|
343
|
+
Aun::Message.new(
|
344
|
+
'んーばばんばんば',
|
345
|
+
'めらっさめらっさ',
|
346
|
+
owner: 'パプワくん',
|
347
|
+
origin: '南国少年パプワくん',
|
348
|
+
user_defined: true
|
349
|
+
),
|
350
|
+
Aun::Message.new(
|
351
|
+
'ツー',
|
352
|
+
'カー',
|
353
|
+
user_defined: true
|
354
|
+
)
|
355
|
+
]
|
356
|
+
|
357
|
+
cases = [
|
358
|
+
{
|
359
|
+
case_no: 1,
|
360
|
+
case_title: 'case_title',
|
361
|
+
messages: ADDITIONAL_MESSAGES,
|
362
|
+
expected: Aun::DefaultMessages::MESSAGES + ADDITIONAL_MESSAGES
|
363
|
+
},
|
364
|
+
]
|
365
|
+
|
366
|
+
cases.each do |c|
|
367
|
+
it "|case_no=#{c[:case_no]}|case_title=#{c[:case_title]}" do
|
368
|
+
begin
|
369
|
+
case_before c
|
370
|
+
|
371
|
+
# -- given --
|
372
|
+
aun_message = Aun::Finder.new
|
373
|
+
|
374
|
+
# -- when --
|
375
|
+
aun_message.add_messages(c[:messages])
|
376
|
+
actual = aun_message.messages
|
377
|
+
|
378
|
+
# -- then --
|
379
|
+
expect(actual).to eq(c[:expected])
|
380
|
+
ensure
|
381
|
+
case_after c
|
382
|
+
end
|
383
|
+
end
|
384
|
+
|
385
|
+
def case_before(c)
|
386
|
+
# implement each case before
|
387
|
+
end
|
388
|
+
|
389
|
+
def case_after(c)
|
390
|
+
# implement each case after
|
391
|
+
end
|
392
|
+
end
|
393
|
+
end
|
394
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: aun
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- tbpgr
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-10-
|
11
|
+
date: 2014-10-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|