pokeberu 0.1.3 → 0.1.4
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 +4 -4
- data/CHANGELOG.md +4 -0
- data/Gemfile.lock +2 -2
- data/README.md +12 -9
- data/lib/pokeberu/converter.rb +56 -4
- data/lib/pokeberu/decorator.rb +5 -5
- data/lib/pokeberu/runner.rb +7 -3
- data/lib/pokeberu/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a5008bc20349e495bbbc583130a96fd500422b582fbd2a2ea0abe586d3e6e8bf
|
4
|
+
data.tar.gz: '09121533a1dc7c0a6c73534a6786276dea6e706b1c8c4a1ffa6bda06a4d7bf25'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e93a8ee4630b4b06ec80d42ab423b6007722efef21fc55bc309a93109d799740f2794348f4144bdd814e140c3ac6ed599eab1e6bdb1493ea935809e18a9ef28f
|
7
|
+
data.tar.gz: 571a54c4d83b152d3345f8fb0cb3149988524014ff8543bbe09ff9c05210a5b8a94196d559ad85cf26d85ba95448c3aa3c9e19feeb0d6d22abe57ac56963bf38
|
data/CHANGELOG.md
ADDED
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -21,7 +21,7 @@ Or install it yourself as:
|
|
21
21
|
|
22
22
|
## Usage
|
23
23
|
|
24
|
-
```
|
24
|
+
```ruby
|
25
25
|
require 'pokeberu'
|
26
26
|
|
27
27
|
converter = Pokeberu::Converter.new
|
@@ -29,17 +29,20 @@ converter.to_chars('1112324493')
|
|
29
29
|
#=> アイシテル
|
30
30
|
```
|
31
31
|
|
32
|
-
|
32
|
+
Or
|
33
33
|
|
34
34
|
```
|
35
35
|
$ pokeberu
|
36
|
-
メッセージを入力してください (
|
37
|
-
|
38
|
-
|
|
39
|
-
|
36
|
+
メッセージを入力してください (h=help, q=quit): 1112324493
|
37
|
+
--------------------
|
38
|
+
| アイシテル |
|
39
|
+
--------------------
|
40
|
+
|
41
|
+
メッセージを入力してください (h=help, q=quit): q
|
42
|
+
--------------------
|
43
|
+
| BYE! |
|
44
|
+
--------------------
|
40
45
|
|
41
|
-
メッセージを入力してください (exitで終了): exit
|
42
|
-
Bye!
|
43
46
|
```
|
44
47
|
|
45
48
|
## Development
|
@@ -50,7 +53,7 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
|
|
50
53
|
|
51
54
|
## Contributing
|
52
55
|
|
53
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/
|
56
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/JunichiIto/pokeberu. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
54
57
|
|
55
58
|
## License
|
56
59
|
|
data/lib/pokeberu/converter.rb
CHANGED
@@ -12,12 +12,64 @@ module Pokeberu
|
|
12
12
|
%w(ら り る れ ろ 1 2 3 4 5),
|
13
13
|
%w(わ を ん ゛ ゜ 6 7 8 9 0),
|
14
14
|
]
|
15
|
+
HELP_COL_WIDTH = 4
|
16
|
+
H_BORDER = '-'
|
17
|
+
V_BORDER = '|'
|
15
18
|
|
16
19
|
def to_chars(input)
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
20
|
+
to_c = -> ((row, col)) { TABLE[row][col] }
|
21
|
+
|
22
|
+
input
|
23
|
+
.each_char
|
24
|
+
.map(&:to_i)
|
25
|
+
.map(&:pred)
|
26
|
+
.each_slice(2)
|
27
|
+
.map(&to_c)
|
28
|
+
.join
|
29
|
+
.katakana
|
30
|
+
.zen_to_han
|
31
|
+
end
|
32
|
+
|
33
|
+
def help
|
34
|
+
tr = []
|
35
|
+
TABLE.each.with_index(1) do |row, i|
|
36
|
+
tr << draw_full_border
|
37
|
+
tr << draw_char_cols(row)
|
38
|
+
tr << draw_num_cols(i)
|
39
|
+
end
|
40
|
+
tr << draw_full_border
|
41
|
+
tr.map(&method(:format_row)).join("\n")
|
42
|
+
end
|
43
|
+
|
44
|
+
private
|
45
|
+
|
46
|
+
def draw_char_cols(row)
|
47
|
+
row.map(&method(:format_char)).join(V_BORDER)
|
48
|
+
end
|
49
|
+
|
50
|
+
def format_char(c)
|
51
|
+
c.katakana.center(HELP_COL_WIDTH - 1)
|
52
|
+
end
|
53
|
+
|
54
|
+
def draw_num_cols(i)
|
55
|
+
i = 0 if i > 9
|
56
|
+
from = i * 10
|
57
|
+
to = from + 9
|
58
|
+
nums = (from..to).map(&method(:format_num))
|
59
|
+
nums.rotate(1).join(V_BORDER)
|
60
|
+
end
|
61
|
+
|
62
|
+
def format_num(n)
|
63
|
+
n.to_s.rjust(2, '0').center(HELP_COL_WIDTH)
|
64
|
+
end
|
65
|
+
|
66
|
+
def draw_full_border
|
67
|
+
col_count = TABLE[0].size
|
68
|
+
H_BORDER * (HELP_COL_WIDTH * col_count + col_count - 1)
|
69
|
+
end
|
70
|
+
|
71
|
+
def format_row(text)
|
72
|
+
[V_BORDER, text, V_BORDER].join
|
21
73
|
end
|
22
74
|
end
|
23
75
|
end
|
data/lib/pokeberu/decorator.rb
CHANGED
data/lib/pokeberu/runner.rb
CHANGED
@@ -13,15 +13,19 @@ module Pokeberu
|
|
13
13
|
|
14
14
|
def run
|
15
15
|
loop do
|
16
|
-
print 'メッセージを入力してください (
|
16
|
+
print 'メッセージを入力してください (h=help, q=quit): '
|
17
17
|
input = gets.chomp
|
18
|
-
|
18
|
+
case input
|
19
|
+
when ?q
|
20
|
+
show_pokberu(BYE)
|
19
21
|
break
|
22
|
+
when ?h
|
23
|
+
puts @converter.help
|
24
|
+
puts
|
20
25
|
else
|
21
26
|
show_pokberu(input)
|
22
27
|
end
|
23
28
|
end
|
24
|
-
show_pokberu(BYE)
|
25
29
|
end
|
26
30
|
|
27
31
|
private
|
data/lib/pokeberu/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pokeberu
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Junichi Ito
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-10-
|
11
|
+
date: 2019-10-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: mojinizer
|
@@ -77,6 +77,7 @@ extra_rdoc_files: []
|
|
77
77
|
files:
|
78
78
|
- ".gitignore"
|
79
79
|
- ".travis.yml"
|
80
|
+
- CHANGELOG.md
|
80
81
|
- CODE_OF_CONDUCT.md
|
81
82
|
- Gemfile
|
82
83
|
- Gemfile.lock
|