aun 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +14 -0
- data/.rspec +2 -0
- data/.rubocop.yml +1 -0
- data/.travis.yml +7 -0
- data/Gemfile +9 -0
- data/LICENSE.txt +22 -0
- data/README.md +172 -0
- data/Rakefile +8 -0
- data/aun.gemspec +24 -0
- data/bin/aun +68 -0
- data/images/aun.gif +0 -0
- data/lib/aun/default_messages.rb +10 -0
- data/lib/aun/definition_manager.rb +33 -0
- data/lib/aun/finder.rb +30 -0
- data/lib/aun/message.rb +49 -0
- data/lib/aun/message_formatter.rb +28 -0
- data/lib/aun/version.rb +3 -0
- data/lib/aun_core.rb +9 -0
- data/rubocop-todo.yml +49 -0
- data/spec/aun/finder_spec.rb +315 -0
- data/spec/aun/message_formatter_spec.rb +183 -0
- data/spec/aun/message_spec.rb +273 -0
- data/spec/spec_helper.rb +16 -0
- metadata +114 -0
@@ -0,0 +1,273 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require 'spec_helper'
|
3
|
+
require 'aun/message'
|
4
|
+
|
5
|
+
describe Aun::Message do
|
6
|
+
context :talk do
|
7
|
+
cases = [
|
8
|
+
{
|
9
|
+
case_no: 1,
|
10
|
+
case_title: 'valid case',
|
11
|
+
a: 'んーばばんばんば',
|
12
|
+
un: 'めらっさめらっさ',
|
13
|
+
owner: 'パプワくん',
|
14
|
+
origin: '南国少年パプワくん',
|
15
|
+
user_defined: true,
|
16
|
+
expected: 'めらっさめらっさ',
|
17
|
+
}
|
18
|
+
]
|
19
|
+
|
20
|
+
cases.each do |c|
|
21
|
+
it "|case_no=#{c[:case_no]}|case_title=#{c[:case_title]}" do
|
22
|
+
begin
|
23
|
+
case_before c
|
24
|
+
|
25
|
+
# -- given --
|
26
|
+
aun_message = Aun::Message.new(
|
27
|
+
c[:a],
|
28
|
+
c[:un],
|
29
|
+
owner: c[:owner],
|
30
|
+
origin: c[:origin],
|
31
|
+
user_defined: c[:user_defined]
|
32
|
+
)
|
33
|
+
|
34
|
+
# -- when --
|
35
|
+
actual = aun_message.talk
|
36
|
+
|
37
|
+
# -- then --
|
38
|
+
expect(actual).to eq(c[:expected])
|
39
|
+
ensure
|
40
|
+
case_after c
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
def case_before(c)
|
45
|
+
# implement each case before
|
46
|
+
end
|
47
|
+
|
48
|
+
def case_after(c)
|
49
|
+
# implement each case after
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
context :owner_talk do
|
55
|
+
cases = [
|
56
|
+
{
|
57
|
+
case_no: 1,
|
58
|
+
case_title: 'valid case',
|
59
|
+
a: 'んーばばんばんば',
|
60
|
+
un: 'めらっさめらっさ',
|
61
|
+
owner: 'パプワくん',
|
62
|
+
origin: '南国少年パプワくん',
|
63
|
+
user_defined: true,
|
64
|
+
expected: 'パプワくん「めらっさめらっさ」',
|
65
|
+
},
|
66
|
+
{
|
67
|
+
case_no: 2,
|
68
|
+
case_title: 'no owner case',
|
69
|
+
a: 'んーばばんばんば',
|
70
|
+
un: 'めらっさめらっさ',
|
71
|
+
owner: :unknown,
|
72
|
+
origin: '南国少年パプワくん',
|
73
|
+
user_defined: true,
|
74
|
+
expected: 'めらっさめらっさ',
|
75
|
+
}
|
76
|
+
]
|
77
|
+
|
78
|
+
cases.each do |c|
|
79
|
+
it "|case_no=#{c[:case_no]}|case_title=#{c[:case_title]}" do
|
80
|
+
begin
|
81
|
+
case_before c
|
82
|
+
|
83
|
+
# -- given --
|
84
|
+
aun_message = Aun::Message.new(
|
85
|
+
c[:a],
|
86
|
+
c[:un],
|
87
|
+
owner: c[:owner],
|
88
|
+
origin: c[:origin],
|
89
|
+
user_defined: c[:user_defined]
|
90
|
+
)
|
91
|
+
# -- when --
|
92
|
+
actual = aun_message.owner_talk
|
93
|
+
|
94
|
+
# -- then --
|
95
|
+
expect(actual).to eq(c[:expected])
|
96
|
+
ensure
|
97
|
+
case_after c
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
101
|
+
def case_before(c)
|
102
|
+
# implement each case before
|
103
|
+
end
|
104
|
+
|
105
|
+
def case_after(c)
|
106
|
+
# implement each case after
|
107
|
+
end
|
108
|
+
end
|
109
|
+
end
|
110
|
+
|
111
|
+
context :talk_with_origin do
|
112
|
+
cases = [
|
113
|
+
{
|
114
|
+
case_no: 1,
|
115
|
+
case_title: 'valid case',
|
116
|
+
a: 'んーばばんばんば',
|
117
|
+
un: 'めらっさめらっさ',
|
118
|
+
owner: 'パプワくん',
|
119
|
+
origin: '南国少年パプワくん',
|
120
|
+
user_defined: true,
|
121
|
+
expected: 'パプワくん「めらっさめらっさ」 from [南国少年パプワくん]',
|
122
|
+
},
|
123
|
+
{
|
124
|
+
case_no: 2,
|
125
|
+
case_title: 'no owner case',
|
126
|
+
a: 'んーばばんばんば',
|
127
|
+
un: 'めらっさめらっさ',
|
128
|
+
owner: :unknown,
|
129
|
+
origin: '南国少年パプワくん',
|
130
|
+
user_defined: true,
|
131
|
+
expected: 'めらっさめらっさ from [南国少年パプワくん]',
|
132
|
+
},
|
133
|
+
{
|
134
|
+
case_no: 3,
|
135
|
+
case_title: 'no origin case',
|
136
|
+
a: 'んーばばんばんば',
|
137
|
+
un: 'めらっさめらっさ',
|
138
|
+
owner: 'パプワくん',
|
139
|
+
origin: :unknown,
|
140
|
+
user_defined: true,
|
141
|
+
expected: 'パプワくん「めらっさめらっさ」',
|
142
|
+
}
|
143
|
+
]
|
144
|
+
|
145
|
+
cases.each do |c|
|
146
|
+
it "|case_no=#{c[:case_no]}|case_title=#{c[:case_title]}" do
|
147
|
+
begin
|
148
|
+
case_before c
|
149
|
+
|
150
|
+
# -- given --
|
151
|
+
aun_message = Aun::Message.new(
|
152
|
+
c[:a],
|
153
|
+
c[:un],
|
154
|
+
owner: c[:owner],
|
155
|
+
origin: c[:origin],
|
156
|
+
user_defined: c[:user_defined]
|
157
|
+
)
|
158
|
+
# -- when --
|
159
|
+
actual = aun_message.talk_with_origin
|
160
|
+
|
161
|
+
# -- then --
|
162
|
+
expect(actual).to eq(c[:expected])
|
163
|
+
ensure
|
164
|
+
case_after c
|
165
|
+
end
|
166
|
+
end
|
167
|
+
|
168
|
+
def case_before(c)
|
169
|
+
# implement each case before
|
170
|
+
end
|
171
|
+
|
172
|
+
def case_after(c)
|
173
|
+
# implement each case after
|
174
|
+
end
|
175
|
+
end
|
176
|
+
end
|
177
|
+
|
178
|
+
context :inspect do
|
179
|
+
cases = [
|
180
|
+
{
|
181
|
+
case_no: 1,
|
182
|
+
case_title: 'valid case',
|
183
|
+
a: 'んーばばんばんば',
|
184
|
+
un: 'めらっさめらっさ',
|
185
|
+
owner: 'パプワくん',
|
186
|
+
origin: '南国少年パプワくん',
|
187
|
+
user_defined: true,
|
188
|
+
expected: "阿:んーばばんばんば\t吽:めらっさめらっさ\t発言者:パプワくん\t原典:南国少年パプワくん,\tユーザー定義:true"
|
189
|
+
}
|
190
|
+
]
|
191
|
+
|
192
|
+
cases.each do |c|
|
193
|
+
it "|case_no=#{c[:case_no]}|case_title=#{c[:case_title]}" do
|
194
|
+
begin
|
195
|
+
case_before c
|
196
|
+
|
197
|
+
# -- given --
|
198
|
+
aun_message = Aun::Message.new(
|
199
|
+
c[:a],
|
200
|
+
c[:un],
|
201
|
+
owner: c[:owner],
|
202
|
+
origin: c[:origin],
|
203
|
+
user_defined: c[:user_defined]
|
204
|
+
)
|
205
|
+
|
206
|
+
# -- when --
|
207
|
+
actual = aun_message.inspect
|
208
|
+
|
209
|
+
# -- then --
|
210
|
+
expect(actual).to eq(c[:expected])
|
211
|
+
ensure
|
212
|
+
case_after c
|
213
|
+
end
|
214
|
+
end
|
215
|
+
|
216
|
+
def case_before(c)
|
217
|
+
# implement each case before
|
218
|
+
end
|
219
|
+
|
220
|
+
def case_after(c)
|
221
|
+
# implement each case after
|
222
|
+
end
|
223
|
+
end
|
224
|
+
end
|
225
|
+
|
226
|
+
context :columns do
|
227
|
+
cases = [
|
228
|
+
{
|
229
|
+
case_no: 1,
|
230
|
+
case_title: 'valid case',
|
231
|
+
a: 'んーばばんばんば',
|
232
|
+
un: 'めらっさめらっさ',
|
233
|
+
owner: 'パプワくん',
|
234
|
+
origin: '南国少年パプワくん',
|
235
|
+
user_defined: true,
|
236
|
+
expected: ['んーばばんばんば', 'めらっさめらっさ', 'パプワくん', '南国少年パプワくん', true]
|
237
|
+
}
|
238
|
+
]
|
239
|
+
|
240
|
+
cases.each do |c|
|
241
|
+
it "|case_no=#{c[:case_no]}|case_title=#{c[:case_title]}" do
|
242
|
+
begin
|
243
|
+
case_before c
|
244
|
+
|
245
|
+
# -- given --
|
246
|
+
aun_message = Aun::Message.new(
|
247
|
+
c[:a],
|
248
|
+
c[:un],
|
249
|
+
owner: c[:owner],
|
250
|
+
origin: c[:origin],
|
251
|
+
user_defined: c[:user_defined]
|
252
|
+
)
|
253
|
+
|
254
|
+
# -- when --
|
255
|
+
actual = aun_message.columns
|
256
|
+
|
257
|
+
# -- then --
|
258
|
+
expect(actual).to eq(c[:expected])
|
259
|
+
ensure
|
260
|
+
case_after c
|
261
|
+
end
|
262
|
+
end
|
263
|
+
|
264
|
+
def case_before(c)
|
265
|
+
# implement each case before
|
266
|
+
end
|
267
|
+
|
268
|
+
def case_after(c)
|
269
|
+
# implement each case after
|
270
|
+
end
|
271
|
+
end
|
272
|
+
end
|
273
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require 'simplecov'
|
3
|
+
require 'coveralls'
|
4
|
+
Coveralls.wear!
|
5
|
+
SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter[
|
6
|
+
SimpleCov::Formatter::HTMLFormatter,
|
7
|
+
Coveralls::SimpleCov::Formatter
|
8
|
+
]
|
9
|
+
SimpleCov.start do
|
10
|
+
add_filter '/spec/'
|
11
|
+
end
|
12
|
+
RSpec.configure do |config|
|
13
|
+
config.treat_symbols_as_metadata_keys_with_true_values = true
|
14
|
+
config.run_all_when_everything_filtered = true
|
15
|
+
config.filter_run :focus
|
16
|
+
end
|
metadata
ADDED
@@ -0,0 +1,114 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: aun
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- tbpgr
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-10-04 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ~>
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.6'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.6'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ~>
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ~>
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - '>='
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
description: A-Un
|
56
|
+
email:
|
57
|
+
- tbpgr@tbpgr.jp
|
58
|
+
executables:
|
59
|
+
- aun
|
60
|
+
extensions: []
|
61
|
+
extra_rdoc_files: []
|
62
|
+
files:
|
63
|
+
- .gitignore
|
64
|
+
- .rspec
|
65
|
+
- .rubocop.yml
|
66
|
+
- .travis.yml
|
67
|
+
- Gemfile
|
68
|
+
- LICENSE.txt
|
69
|
+
- README.md
|
70
|
+
- Rakefile
|
71
|
+
- aun.gemspec
|
72
|
+
- bin/aun
|
73
|
+
- images/aun.gif
|
74
|
+
- lib/aun/default_messages.rb
|
75
|
+
- lib/aun/definition_manager.rb
|
76
|
+
- lib/aun/finder.rb
|
77
|
+
- lib/aun/message.rb
|
78
|
+
- lib/aun/message_formatter.rb
|
79
|
+
- lib/aun/version.rb
|
80
|
+
- lib/aun_core.rb
|
81
|
+
- rubocop-todo.yml
|
82
|
+
- spec/aun/finder_spec.rb
|
83
|
+
- spec/aun/message_formatter_spec.rb
|
84
|
+
- spec/aun/message_spec.rb
|
85
|
+
- spec/spec_helper.rb
|
86
|
+
homepage: https://github.com/tbpgr/aun
|
87
|
+
licenses:
|
88
|
+
- MIT
|
89
|
+
metadata: {}
|
90
|
+
post_install_message:
|
91
|
+
rdoc_options: []
|
92
|
+
require_paths:
|
93
|
+
- lib
|
94
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
95
|
+
requirements:
|
96
|
+
- - '>='
|
97
|
+
- !ruby/object:Gem::Version
|
98
|
+
version: '0'
|
99
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - '>='
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
requirements: []
|
105
|
+
rubyforge_project:
|
106
|
+
rubygems_version: 2.3.0
|
107
|
+
signing_key:
|
108
|
+
specification_version: 4
|
109
|
+
summary: A-Un
|
110
|
+
test_files:
|
111
|
+
- spec/aun/finder_spec.rb
|
112
|
+
- spec/aun/message_formatter_spec.rb
|
113
|
+
- spec/aun/message_spec.rb
|
114
|
+
- spec/spec_helper.rb
|