sawarineko 1.0.0 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 75980ca94a35d77ff9069f6eeb2491e7522167dd
4
- data.tar.gz: 3c56c3c707b69d61a026ce95d3770d5d19e6a5db
3
+ metadata.gz: a3f2a14c9be7b8aa29c25f511c70cb89cdb5b3a5
4
+ data.tar.gz: 68a1c98dca7f5c6b75b82e07358428df92b6c405
5
5
  SHA512:
6
- metadata.gz: 9bd502c4127d2a492c343b8b4fd3e9798330a0121cb130e1bb2f4647f0b49997c7585e9067b2d6ec144f7fc6784d4e23b60e5c23f67c9b4db04ed089cccac5e1
7
- data.tar.gz: 0a5f6a6ec900623a52c5eacb7511fd9a543c8cda2729c6d7bedee03468024fe2e5774fd168e2376bc3b4d43dc484cae24bb6106b4e7c992333c4f050909d768c
6
+ metadata.gz: 69a20a207b87bf97cb7f86c0ce65173e673b00839b90f625acf5812dd89c2e66e90b5a8f7ed3f3f81f04d4ab6ac628c385edec15ddf04880ab504ea78ec9b593
7
+ data.tar.gz: d432ce8bbe7830a7f475f7ef627ca6390ccd2fa2518f7718b7f510a6893ebfbc6a29f4d3c695cd826c359c35d187b9620cae1fda6c0e2ee9f4e263961600363c
@@ -1,5 +1,10 @@
1
1
  # Changelog
2
2
 
3
+ ## 1.1.0 (2014-10-28)
4
+
5
+ - Add `Sawarineko#nya`
6
+ - Make `Converter#convert` to get the source as argument
7
+
3
8
  ## 1.0.0 (2014-10-27)
4
9
 
5
10
  - Fix crash in `Converter#convert`
data/README.md CHANGED
@@ -3,6 +3,8 @@
3
3
  [![Gem Version](https://badge.fury.io/rb/sawarineko.svg)](http://badge.fury.io/rb/sawarineko)
4
4
  [![Build Status](https://travis-ci.org/yous/sawarineko.svg?branch=master)](https://travis-ci.org/yous/sawarineko)
5
5
  [![Dependency Status](https://gemnasium.com/yous/sawarineko.svg)](https://gemnasium.com/yous/sawarineko)
6
+ [![Code Climate](https://codeclimate.com/github/yous/sawarineko/badges/gpa.svg)](https://codeclimate.com/github/yous/sawarineko)
7
+ [![Coverage Status](https://img.shields.io/coveralls/yous/sawarineko.svg)](https://coveralls.io/r/yous/sawarineko?branch=master)
6
8
  [![Inline docs](http://inch-ci.org/github/yous/sawarineko.svg?branch=master)](http://inch-ci.org/github/yous/sawarineko)
7
9
  [![sawarineko API Documentation](https://www.omniref.com/ruby/gems/sawarineko.png)](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
@@ -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
@@ -21,8 +21,8 @@ module Sawarineko
21
21
  else
22
22
  IO.read(paths[0])
23
23
  end
24
- runner = Converter.new(source)
25
- puts runner.convert
24
+ converter = Converter.new
25
+ puts converter.convert(source)
26
26
  0
27
27
  end
28
28
  end
@@ -3,18 +3,13 @@
3
3
  module Sawarineko
4
4
  # Convert plain text to Sawarineko text.
5
5
  class Converter
6
- # Initialize a Converter. Get a String source.
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
- @source
11
+ def convert(source)
12
+ source
18
13
  .gsub(/な/, 'にゃ')
19
14
  .gsub(/ナ/, 'ニャ')
20
15
  .gsub(/[나-낳]/) { |ch| (ch.ord + 56).chr(Encoding::UTF_8) }
@@ -3,6 +3,6 @@
3
3
  module Sawarineko
4
4
  # Hold Sawarineko's version information.
5
5
  module Version
6
- STRING = '1.0.0'
6
+ STRING = '1.1.0'
7
7
  end
8
8
  end
@@ -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.new('な').convert).to eq('にゃ')
10
- expect(converter.new('ななめななじゅうななどのならびで' \
11
- 'なくなくいななくななはんななだい' \
12
- 'なんなくならべてながながめ').convert)
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.new('ナ').convert).to eq('ニャ')
20
- expect(converter.new('ナナメナナジュウナナドノナラビデ' \
21
- 'ナクナクイナナクナナハンナナダイ' \
22
- 'ナンナクナラベテナガナガメ').convert)
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.new(na).convert).to eq(nya)
30
+ expect(converter.convert(na)).to eq(nya)
31
31
  end
32
- expect(converter.new('나랑 너랑 봄나들이 배낭 매고 봄나들이 ' \
33
- '버드나무 낭창낭창 남실바람 남실남실 ' \
34
- '개나리 꽃에 나비가 하나 ' \
35
- '배낭 속에 바나나가 하나').convert)
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.0.0
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-27 00:00:00.000000000 Z
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