sawarineko 1.0.0 → 1.1.0
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 +5 -0
- data/README.md +15 -0
- data/lib/sawarineko.rb +12 -0
- data/lib/sawarineko/cli.rb +2 -2
- data/lib/sawarineko/converter.rb +3 -8
- data/lib/sawarineko/version.rb +1 -1
- data/spec/sawarineko/converter_spec.rb +19 -14
- data/spec/sawarineko_spec.rb +22 -0
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a3f2a14c9be7b8aa29c25f511c70cb89cdb5b3a5
|
4
|
+
data.tar.gz: 68a1c98dca7f5c6b75b82e07358428df92b6c405
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 69a20a207b87bf97cb7f86c0ce65173e673b00839b90f625acf5812dd89c2e66e90b5a8f7ed3f3f81f04d4ab6ac628c385edec15ddf04880ab504ea78ec9b593
|
7
|
+
data.tar.gz: d432ce8bbe7830a7f475f7ef627ca6390ccd2fa2518f7718b7f510a6893ebfbc6a29f4d3c695cd826c359c35d187b9620cae1fda6c0e2ee9f4e263961600363c
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -3,6 +3,8 @@
|
|
3
3
|
[](http://badge.fury.io/rb/sawarineko)
|
4
4
|
[](https://travis-ci.org/yous/sawarineko)
|
5
5
|
[](https://gemnasium.com/yous/sawarineko)
|
6
|
+
[](https://codeclimate.com/github/yous/sawarineko)
|
7
|
+
[](https://coveralls.io/r/yous/sawarineko?branch=master)
|
6
8
|
[](http://inch-ci.org/github/yous/sawarineko)
|
7
9
|
[](https://www.omniref.com/ruby/gems/sawarineko)
|
8
10
|
|
@@ -24,6 +26,19 @@ gem 'sawarineko'
|
|
24
26
|
|
25
27
|
## Usage
|
26
28
|
|
29
|
+
Just get your Nya with Sawarineko:
|
30
|
+
|
31
|
+
``` ruby
|
32
|
+
Sawarineko.nya('ばなな')
|
33
|
+
# => "ばにゃにゃ"
|
34
|
+
|
35
|
+
Sawarineko.nya('バナナ')
|
36
|
+
# => "バニャニャ"
|
37
|
+
|
38
|
+
Sawarineko.nya('바나나')
|
39
|
+
# => "바냐냐"
|
40
|
+
```
|
41
|
+
|
27
42
|
Run `sawarineko` with no arguments to pass texts through terminal input.
|
28
43
|
|
29
44
|
``` sh
|
data/lib/sawarineko.rb
CHANGED
@@ -4,3 +4,15 @@ require 'sawarineko/version'
|
|
4
4
|
require 'sawarineko/converter'
|
5
5
|
require 'sawarineko/option'
|
6
6
|
require 'sawarineko/cli'
|
7
|
+
|
8
|
+
# Get your Nya!
|
9
|
+
module Sawarineko
|
10
|
+
# Make the source to Sawarineko. See Converter.
|
11
|
+
#
|
12
|
+
# source - The String source to convert.
|
13
|
+
#
|
14
|
+
# Returns the String converted to Sawarineko.
|
15
|
+
def self.nya(source)
|
16
|
+
Converter.new.convert(source)
|
17
|
+
end
|
18
|
+
end
|
data/lib/sawarineko/cli.rb
CHANGED
data/lib/sawarineko/converter.rb
CHANGED
@@ -3,18 +3,13 @@
|
|
3
3
|
module Sawarineko
|
4
4
|
# Convert plain text to Sawarineko text.
|
5
5
|
class Converter
|
6
|
-
#
|
6
|
+
# Convert the source.
|
7
7
|
#
|
8
8
|
# source - The String source to convert.
|
9
|
-
def initialize(source)
|
10
|
-
@source = source
|
11
|
-
end
|
12
|
-
|
13
|
-
# Convert the source.
|
14
9
|
#
|
15
10
|
# Returns the String converted to Sawarineko.
|
16
|
-
def convert
|
17
|
-
|
11
|
+
def convert(source)
|
12
|
+
source
|
18
13
|
.gsub(/な/, 'にゃ')
|
19
14
|
.gsub(/ナ/, 'ニャ')
|
20
15
|
.gsub(/[나-낳]/) { |ch| (ch.ord + 56).chr(Encoding::UTF_8) }
|
data/lib/sawarineko/version.rb
CHANGED
@@ -3,23 +3,23 @@
|
|
3
3
|
require 'spec_helper'
|
4
4
|
|
5
5
|
RSpec.describe Sawarineko::Converter do
|
6
|
-
subject(:converter) { described_class }
|
6
|
+
subject(:converter) { described_class.new }
|
7
7
|
|
8
8
|
it 'converts hiragana な to にゃ' do
|
9
|
-
expect(converter.
|
10
|
-
expect(converter.
|
11
|
-
|
12
|
-
|
9
|
+
expect(converter.convert('な')).to eq('にゃ')
|
10
|
+
expect(converter.convert('ななめななじゅうななどのならびで' \
|
11
|
+
'なくなくいななくななはんななだい' \
|
12
|
+
'なんなくならべてながながめ'))
|
13
13
|
.to eq('にゃにゃめにゃにゃじゅうにゃにゃどのにゃらびで' \
|
14
14
|
'にゃくにゃくいにゃにゃくにゃにゃはんにゃにゃだい' \
|
15
15
|
'にゃんにゃくにゃらべてにゃがにゃがめ')
|
16
16
|
end
|
17
17
|
|
18
18
|
it 'converts katakana ナ to ニャ' do
|
19
|
-
expect(converter.
|
20
|
-
expect(converter.
|
21
|
-
|
22
|
-
|
19
|
+
expect(converter.convert('ナ')).to eq('ニャ')
|
20
|
+
expect(converter.convert('ナナメナナジュウナナドノナラビデ' \
|
21
|
+
'ナクナクイナナクナナハンナナダイ' \
|
22
|
+
'ナンナクナラベテナガナガメ'))
|
23
23
|
.to eq('ニャニャメニャニャジュウニャニャドノニャラビデ' \
|
24
24
|
'ニャクニャクイニャニャクニャニャハンニャニャダイ' \
|
25
25
|
'ニャンニャクニャラベテニャガニャガメ')
|
@@ -27,15 +27,20 @@ RSpec.describe Sawarineko::Converter do
|
|
27
27
|
|
28
28
|
it 'converts hangul 나-낳 to 냐-냫' do
|
29
29
|
('나'..'낳').zip('냐'..'냫').each do |na, nya|
|
30
|
-
expect(converter.
|
30
|
+
expect(converter.convert(na)).to eq(nya)
|
31
31
|
end
|
32
|
-
expect(converter.
|
33
|
-
|
34
|
-
|
35
|
-
|
32
|
+
expect(converter.convert('나랑 너랑 봄나들이 배낭 매고 봄나들이 ' \
|
33
|
+
'버드나무 낭창낭창 남실바람 남실남실 ' \
|
34
|
+
'개나리 꽃에 나비가 하나 ' \
|
35
|
+
'배낭 속에 바나나가 하나'))
|
36
36
|
.to eq('냐랑 너랑 봄냐들이 배냥 매고 봄냐들이 ' \
|
37
37
|
'버드냐무 냥창냥창 냠실바람 냠실냠실 ' \
|
38
38
|
'개냐리 꽃에 냐비가 하냐 ' \
|
39
39
|
'배냥 속에 바냐냐가 하냐')
|
40
40
|
end
|
41
|
+
|
42
|
+
it 'converts all languages at once' do
|
43
|
+
expect(converter.convert(%w(な ナ 나).join("\n")))
|
44
|
+
.to eq(%w(にゃ ニャ 냐).join("\n"))
|
45
|
+
end
|
41
46
|
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
RSpec.describe Sawarineko do
|
6
|
+
subject(:sawarineko) { described_class }
|
7
|
+
|
8
|
+
describe '#nya' do
|
9
|
+
it { is_expected.to respond_to(:nya) }
|
10
|
+
|
11
|
+
it 'converts string passed as an argument' do
|
12
|
+
expect(sawarineko.nya('ななめななじゅうななどの' \
|
13
|
+
'ならびでなくなくいななく' \
|
14
|
+
'ななはんななだいなんなく' \
|
15
|
+
'ならべてながながめ'))
|
16
|
+
.to eq('にゃにゃめにゃにゃじゅうにゃにゃどの' \
|
17
|
+
'にゃらびでにゃくにゃくいにゃにゃく' \
|
18
|
+
'にゃにゃはんにゃにゃだいにゃんにゃく' \
|
19
|
+
'にゃらべてにゃがにゃがめ')
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sawarineko
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- ChaYoung You
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-10-
|
11
|
+
date: 2014-10-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -109,6 +109,7 @@ files:
|
|
109
109
|
- spec/sawarineko/converter_spec.rb
|
110
110
|
- spec/sawarineko/option_spec.rb
|
111
111
|
- spec/sawarineko/version_spec.rb
|
112
|
+
- spec/sawarineko_spec.rb
|
112
113
|
- spec/spec_helper.rb
|
113
114
|
- spec/support/exit_code_matchers.rb
|
114
115
|
- spec/support/file_helper.rb
|
@@ -142,6 +143,7 @@ test_files:
|
|
142
143
|
- spec/sawarineko/converter_spec.rb
|
143
144
|
- spec/sawarineko/option_spec.rb
|
144
145
|
- spec/sawarineko/version_spec.rb
|
146
|
+
- spec/sawarineko_spec.rb
|
145
147
|
- spec/spec_helper.rb
|
146
148
|
- spec/support/exit_code_matchers.rb
|
147
149
|
- spec/support/file_helper.rb
|