basehangul 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +19 -0
- data/.rspec +2 -0
- data/.rubocop.yml +4 -0
- data/.rubocop_todo.yml +10 -0
- data/.travis.yml +12 -0
- data/CHANGELOG.md +5 -0
- data/Gemfile +9 -0
- data/LICENSE.txt +21 -0
- data/README.md +55 -0
- data/Rakefile +17 -0
- data/basehangul.gemspec +27 -0
- data/lib/basehangul.rb +47 -0
- data/lib/basehangul/utils.rb +51 -0
- data/lib/basehangul/version.rb +8 -0
- data/spec/basehangul/utils_spec.rb +94 -0
- data/spec/basehangul/version_spec.rb +9 -0
- data/spec/basehangul_spec.rb +89 -0
- data/spec/spec_helper.rb +74 -0
- data/spec/support/coverage.rb +15 -0
- metadata +138 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 48909fd8600e22b74fd809e6f9e6b35bd9005dd9
|
4
|
+
data.tar.gz: c65e09a4a53d1ff4f362c48d40c4c030e486a665
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 396ad4df9d2a499d143f2cea0f08f2960961f98a1e5a37e3c99302db8a8653bb8fd9ab0d350e33e6c4659f01e04db6b75a9ac5abffa5513e0f380b5e06aa28f8
|
7
|
+
data.tar.gz: 508cec650cae1100a6bae217b9c7270e856909d26f99e5857c7565a1388dea6b5b6ea32edd142584957bc78ad444e925e20c1943ffef447c2ece7840f1da76a7
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.rubocop.yml
ADDED
data/.rubocop_todo.yml
ADDED
@@ -0,0 +1,10 @@
|
|
1
|
+
# This configuration was generated by `rubocop --auto-gen-config`
|
2
|
+
# on 2014-11-05 06:26:54 +0900 using RuboCop version 0.27.0.
|
3
|
+
# The point is for the user to remove these configuration records
|
4
|
+
# one by one as the offenses are removed from the code base.
|
5
|
+
# Note that changes in the inspected code, or installation of new
|
6
|
+
# versions of RuboCop, may require this file to be generated again.
|
7
|
+
|
8
|
+
# Offense count: 2
|
9
|
+
Metrics/AbcSize:
|
10
|
+
Max: 19
|
data/.travis.yml
ADDED
data/CHANGELOG.md
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2014 ChaYoung You
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,55 @@
|
|
1
|
+
# BaseHangul
|
2
|
+
|
3
|
+
[![Build Status](https://travis-ci.org/yous/basehangul.svg?branch=master)](https://travis-ci.org/yous/basehangul)
|
4
|
+
[![Dependency Status](https://gemnasium.com/yous/basehangul.svg)](https://gemnasium.com/yous/basehangul)
|
5
|
+
[![Code Climate](https://codeclimate.com/github/yous/basehangul/badges/gpa.svg)](https://codeclimate.com/github/yous/basehangul)
|
6
|
+
[![Coverage Status](https://img.shields.io/coveralls/yous/basehangul.svg)](https://coveralls.io/r/yous/basehangul)
|
7
|
+
[![Inline docs](http://inch-ci.org/github/yous/basehangul.svg?branch=master)](http://inch-ci.org/github/yous/basehangul)
|
8
|
+
|
9
|
+
[BaseHangul](https://github.com/koreapyj/basehangul) for Ruby. BaseHangul is an binary encoder using hangul. You can see [the specification](http://api.dcmys.jp/basehangul/) of it.
|
10
|
+
|
11
|
+
## Installation
|
12
|
+
|
13
|
+
Add this line to your application's Gemfile:
|
14
|
+
|
15
|
+
``` ruby
|
16
|
+
gem 'basehangul'
|
17
|
+
```
|
18
|
+
|
19
|
+
And then execute:
|
20
|
+
|
21
|
+
``` sh
|
22
|
+
bundle
|
23
|
+
```
|
24
|
+
|
25
|
+
Or install it yourself as:
|
26
|
+
|
27
|
+
``` sh
|
28
|
+
gem install basehangul
|
29
|
+
```
|
30
|
+
|
31
|
+
## Usage
|
32
|
+
|
33
|
+
``` ruby
|
34
|
+
BaseHangul.encode('This is an encoded string')
|
35
|
+
# => "넥라똔먈늴멥갯놓궂뗐밸뮤뉴뗐뀄굡덜멂똑뚤"
|
36
|
+
|
37
|
+
BaseHangul.decode('넥라똔먈늴멥갯놓궂뗐밸뮤뉴뗐뀄굡덜멂똑뚤')
|
38
|
+
# => "This is an encoded string"
|
39
|
+
```
|
40
|
+
|
41
|
+
## Contributing
|
42
|
+
|
43
|
+
1. Fork it (https://github.com/yous/basehangul/fork)
|
44
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
45
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
46
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
47
|
+
5. Create a new Pull Request
|
48
|
+
|
49
|
+
## Changelog
|
50
|
+
|
51
|
+
See [CHANGELOG.md](CHANGELOG.md).
|
52
|
+
|
53
|
+
## License
|
54
|
+
|
55
|
+
Copyright (c) ChaYoung You. See [LICENSE.txt](LICENSE.txt) for further details.
|
data/Rakefile
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'bundler/gem_tasks'
|
4
|
+
|
5
|
+
require 'rspec/core/rake_task'
|
6
|
+
RSpec::Core::RakeTask.new(:spec)
|
7
|
+
|
8
|
+
require 'rubocop/rake_task'
|
9
|
+
RuboCop::RakeTask.new(:rubocop)
|
10
|
+
|
11
|
+
desc 'Run RSpec with code coverage'
|
12
|
+
task :coverage do
|
13
|
+
ENV['COVERAGE'] = 'true'
|
14
|
+
Rake::Task[:spec].execute
|
15
|
+
end
|
16
|
+
|
17
|
+
task default: [:spec, :rubocop]
|
data/basehangul.gemspec
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
lib = File.expand_path('../lib', __FILE__)
|
4
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
5
|
+
require 'basehangul/version'
|
6
|
+
|
7
|
+
Gem::Specification.new do |spec|
|
8
|
+
spec.name = 'basehangul'
|
9
|
+
spec.version = BaseHangul::Version::STRING
|
10
|
+
spec.authors = ['ChaYoung You']
|
11
|
+
spec.email = %w(yousbe@gmail.com)
|
12
|
+
spec.summary = 'BaseHangul for Ruby.'
|
13
|
+
spec.description = 'BaseHangul for Ruby.'
|
14
|
+
spec.homepage = ''
|
15
|
+
spec.license = 'MIT'
|
16
|
+
|
17
|
+
spec.files = `git ls-files -z`.split("\x0")
|
18
|
+
spec.executables = spec.files.grep(/^bin\//) { |f| File.basename(f) }
|
19
|
+
spec.test_files = spec.files.grep(/^(test|spec|features)\//)
|
20
|
+
spec.require_paths = %w(lib)
|
21
|
+
|
22
|
+
spec.add_development_dependency 'bundler', '~> 1.7'
|
23
|
+
spec.add_development_dependency 'rake', '~> 10.0'
|
24
|
+
spec.add_development_dependency 'rspec', '~> 3.0'
|
25
|
+
spec.add_development_dependency 'rubocop', '~> 0.27.0'
|
26
|
+
spec.add_development_dependency 'simplecov', '~> 0.9'
|
27
|
+
end
|
data/lib/basehangul.rb
ADDED
@@ -0,0 +1,47 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'basehangul/version'
|
4
|
+
require 'basehangul/utils'
|
5
|
+
|
6
|
+
# Binary encoder using hangul.
|
7
|
+
module BaseHangul
|
8
|
+
# Character for padding on encoding.
|
9
|
+
PADDING = '흐'.freeze
|
10
|
+
private_constant :PADDING
|
11
|
+
|
12
|
+
# Public: Encode binary with BaseHangul.
|
13
|
+
#
|
14
|
+
# bin - A String binary to encode.
|
15
|
+
#
|
16
|
+
# Returns the String encoded hangul.
|
17
|
+
def self.encode(bin)
|
18
|
+
chunks = Utils.chunks(bin.unpack('B*').first, 10)
|
19
|
+
padding = ''
|
20
|
+
last = chunks.last
|
21
|
+
if last
|
22
|
+
case last.size
|
23
|
+
when 2 then chunks[-1] = '1' + last.rjust(10, '0')
|
24
|
+
when 4, 6, 8 then padding = PADDING * (last.size / 2 - 1)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
chunks.map { |b| Utils.to_hangul(b.ljust(10, '0').to_i(2)) }.join + padding
|
28
|
+
end
|
29
|
+
|
30
|
+
# Public: Decode BaseHangul string.
|
31
|
+
#
|
32
|
+
# str - A String encoded with BaseHangul.
|
33
|
+
#
|
34
|
+
# Returns the String decoded binary.
|
35
|
+
def self.decode(str)
|
36
|
+
indices = str.each_char.map { |ch| Utils.to_index(ch) }
|
37
|
+
binary = indices.map do |index|
|
38
|
+
case index
|
39
|
+
when -1 then ''
|
40
|
+
when 0..1023 then index.to_s(2).rjust(10, '0')
|
41
|
+
when 1024..1027 then (index - 1024).to_s(2).rjust(2, '0')
|
42
|
+
end
|
43
|
+
end.join
|
44
|
+
binary = binary[0..-(binary.size % 8 + 1)]
|
45
|
+
[binary].pack('B*')
|
46
|
+
end
|
47
|
+
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
module BaseHangul
|
4
|
+
# Helper methods for BaseHangul.
|
5
|
+
module Utils
|
6
|
+
# Convert a hangul character to index.
|
7
|
+
#
|
8
|
+
# hangul - A hangul character encoded with BaseHangul.
|
9
|
+
#
|
10
|
+
# Returns the Integer index of the hangul between 0 to 1027.
|
11
|
+
# Raises ArgumentError if the character is not valid for BaseHangul.
|
12
|
+
def self.to_index(hangul)
|
13
|
+
return -1 if hangul == PADDING
|
14
|
+
offset = hangul.encode(Encoding::EUC_KR).ord - 0xB0A1
|
15
|
+
index = offset / 0x100 * 0x5E + offset % 0x100
|
16
|
+
if index < 0 || index > 1027
|
17
|
+
fail ArgumentError, 'Not a valid BaseHangul string'
|
18
|
+
end
|
19
|
+
index
|
20
|
+
end
|
21
|
+
|
22
|
+
# Convert a index to hangul character.
|
23
|
+
#
|
24
|
+
# index - An Integer to convert.
|
25
|
+
#
|
26
|
+
# Returns the String hangul for given index.
|
27
|
+
# Raises IndexError if the index is out of range 0..1027.
|
28
|
+
def self.to_hangul(index)
|
29
|
+
if index < 0 || index > 1027
|
30
|
+
fail IndexError, "Index #{index} outside of valid range: 0..1027"
|
31
|
+
end
|
32
|
+
(index / 0x5E * 0x100 + index % 0x5E + 0xB0A1).chr(Encoding::EUC_KR)
|
33
|
+
.encode(Encoding::UTF_8)
|
34
|
+
end
|
35
|
+
|
36
|
+
# Slice a string into chunks of a given size.
|
37
|
+
#
|
38
|
+
# str - The String to slice.
|
39
|
+
# size - The Integer max size of each chunk.
|
40
|
+
#
|
41
|
+
# Returns an Array of chunked Strings.
|
42
|
+
# Raises ArgumentError if the size is smaller then or equal to 0.
|
43
|
+
def self.chunks(str, size)
|
44
|
+
fail ArgumentError, 'Invalid slice size' if size <= 0
|
45
|
+
new_str = str.dup
|
46
|
+
array = []
|
47
|
+
array << new_str.slice!(0...size) until new_str.empty?
|
48
|
+
array
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
@@ -0,0 +1,94 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
RSpec.describe BaseHangul::Utils do
|
4
|
+
subject(:utils) { described_class }
|
5
|
+
let(:padding) { BaseHangul.const_get(:PADDING) }
|
6
|
+
|
7
|
+
describe '.to_index' do
|
8
|
+
it 'converts hangul to index' do
|
9
|
+
range = ('가'.encode(Encoding::EUC_KR)..'빗'.encode(Encoding::EUC_KR))
|
10
|
+
.map { |v| v.encode(Encoding::UTF_8) }
|
11
|
+
range.each_with_index do |hangul, expected|
|
12
|
+
index = utils.to_index(hangul)
|
13
|
+
expect(index).to eq(expected)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
it 'converts padding hangul to -1' do
|
18
|
+
index = utils.to_index(padding)
|
19
|
+
expect(index).to eq(-1)
|
20
|
+
end
|
21
|
+
|
22
|
+
it 'raises ArgumentError for invalid hangul' do
|
23
|
+
range = ('빙'.encode(Encoding::EUC_KR)..'힝'.encode(Encoding::EUC_KR))
|
24
|
+
.map { |v| v.encode(Encoding::UTF_8) }
|
25
|
+
range.reject { |v| v == padding }.each do |hangul|
|
26
|
+
expect { utils.to_index(hangul) }
|
27
|
+
.to raise_error(ArgumentError, 'Not a valid BaseHangul string')
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
describe '.to_hangul' do
|
33
|
+
it 'converts index to hangul' do
|
34
|
+
range = ('가'.encode(Encoding::EUC_KR)..'빗'.encode(Encoding::EUC_KR))
|
35
|
+
.map { |v| v.encode(Encoding::UTF_8) }
|
36
|
+
(0..1027).each do |index|
|
37
|
+
hangul = utils.to_hangul(index)
|
38
|
+
expect(range.index(hangul)).to eq(index)
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
it 'raises IndexError for index out of range' do
|
43
|
+
[-100, -1, 1028, 2000].each do |index|
|
44
|
+
expect { utils.to_hangul(index) }
|
45
|
+
.to raise_error(IndexError, "Index #{index} outside of valid " \
|
46
|
+
'range: 0..1027')
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
describe '.chunks' do
|
52
|
+
context 'with empty string' do
|
53
|
+
it 'returns an empty array' do
|
54
|
+
[1, 5, 100].each do |size|
|
55
|
+
chunks = utils.chunks('', size)
|
56
|
+
expect(chunks).to match_array([])
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
context 'with string of which length is multiple of size' do
|
62
|
+
it 'returns an array of chunks' do
|
63
|
+
# rubocop:disable Style/WordArray
|
64
|
+
chunks = utils.chunks('foo', 1)
|
65
|
+
expect(chunks).to match_array(['f', 'o', 'o'])
|
66
|
+
chunks = utils.chunks('foobarbaz', 3)
|
67
|
+
expect(chunks).to match_array(['foo', 'bar', 'baz'])
|
68
|
+
# rubocop:enable Style/WordArray
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
context 'with string of which length is not multiple of size' do
|
73
|
+
it 'returns an array of chunks' do
|
74
|
+
# rubocop:disable Style/WordArray
|
75
|
+
chunks = utils.chunks('abcd1234A', 4)
|
76
|
+
expect(chunks).to match_array(['abcd', '1234', 'A'])
|
77
|
+
chunks = utils.chunks('abcd1234AB', 4)
|
78
|
+
expect(chunks).to match_array(['abcd', '1234', 'AB'])
|
79
|
+
chunks = utils.chunks('abcd1234ABC', 4)
|
80
|
+
expect(chunks).to match_array(['abcd', '1234', 'ABC'])
|
81
|
+
# rubocop:enable Style/WordArray
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
context 'with invalid size' do
|
86
|
+
it 'raises ArgumentError' do
|
87
|
+
[0, -1, -5].each do |size|
|
88
|
+
expect { utils.chunks('foo', size) }
|
89
|
+
.to raise_error(ArgumentError, 'Invalid slice size')
|
90
|
+
end
|
91
|
+
end
|
92
|
+
end
|
93
|
+
end
|
94
|
+
end
|
@@ -0,0 +1,89 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
RSpec.describe BaseHangul do
|
4
|
+
subject(:basehangul) { described_class }
|
5
|
+
|
6
|
+
describe '.encode' do
|
7
|
+
it 'returns empty string with empty binary' do
|
8
|
+
encoded = basehangul.encode('')
|
9
|
+
expect(encoded).to eq('')
|
10
|
+
end
|
11
|
+
|
12
|
+
context 'when the length is multiple of 5' do
|
13
|
+
it 'encodes binary to hangul' do
|
14
|
+
encoded = basehangul.encode('This is an encoded string')
|
15
|
+
expect(encoded).to eq('넥라똔먈늴멥갯놓궂뗐밸뮤뉴뗐뀄굡덜멂똑뚤')
|
16
|
+
encoded = basehangul.encode('123ab')
|
17
|
+
expect(encoded).to eq('꺽먹꼍녜')
|
18
|
+
encoded = basehangul.encode("123d\x00")
|
19
|
+
expect(encoded).to eq('꺽먹꼐가')
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
context 'when the remainder is 1, 2, 3 when the length is divided by 5' do
|
24
|
+
it 'encodes binary to hangul with padding' do
|
25
|
+
encoded = basehangul.encode('1')
|
26
|
+
expect(encoded).to eq('꺽흐흐흐')
|
27
|
+
encoded = basehangul.encode('12')
|
28
|
+
expect(encoded).to eq('꺽먈흐흐')
|
29
|
+
encoded = basehangul.encode('123')
|
30
|
+
expect(encoded).to eq('꺽먹꺄흐')
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
context 'when the remainder is 4 when the length is divided by 5' do
|
35
|
+
it 'encodes binary to hangul' do
|
36
|
+
encoded = basehangul.encode('123d')
|
37
|
+
expect(encoded).to eq('꺽먹꼐빎')
|
38
|
+
encoded = basehangul.encode('123e')
|
39
|
+
expect(encoded).to eq('꺽먹꼐빔')
|
40
|
+
encoded = basehangul.encode('123f')
|
41
|
+
expect(encoded).to eq('꺽먹꼐빕')
|
42
|
+
encoded = basehangul.encode('123g')
|
43
|
+
expect(encoded).to eq('꺽먹꼐빗')
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
describe '.decode' do
|
49
|
+
it 'returns empty binary with empty string' do
|
50
|
+
decoded = basehangul.decode('')
|
51
|
+
expect(decoded).to eq('')
|
52
|
+
end
|
53
|
+
|
54
|
+
context 'when there is no padding characters' do
|
55
|
+
it 'decodes hangul to binary' do
|
56
|
+
decoded = basehangul.decode('넥라똔먈늴멥갯놓궂뗐밸뮤뉴뗐뀄굡덜멂똑뚤')
|
57
|
+
expect(decoded).to eq('This is an encoded string')
|
58
|
+
decoded = basehangul.decode('꺽먹꼍녜')
|
59
|
+
expect(decoded).to eq('123ab')
|
60
|
+
decoded = basehangul.decode('꺽먹꼐가')
|
61
|
+
expect(decoded).to eq("123d\x00")
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
context 'when there are padding characters' do
|
66
|
+
it 'decodes hangul to binary' do
|
67
|
+
decoded = basehangul.decode('꺽흐흐흐')
|
68
|
+
expect(decoded).to eq('1')
|
69
|
+
decoded = basehangul.decode('꺽먈흐흐')
|
70
|
+
expect(decoded).to eq('12')
|
71
|
+
decoded = basehangul.decode('꺽먹꺄흐')
|
72
|
+
expect(decoded).to eq('123')
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
context 'when there are special characters' do
|
77
|
+
it 'decodes hangul to binary 'do
|
78
|
+
decoded = basehangul.decode('꺽먹꼐빎')
|
79
|
+
expect(decoded).to eq('123d')
|
80
|
+
decoded = basehangul.decode('꺽먹꼐빔')
|
81
|
+
expect(decoded).to eq('123e')
|
82
|
+
decoded = basehangul.decode('꺽먹꼐빕')
|
83
|
+
expect(decoded).to eq('123f')
|
84
|
+
decoded = basehangul.decode('꺽먹꼐빗')
|
85
|
+
expect(decoded).to eq('123g')
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f }
|
4
|
+
require 'basehangul'
|
5
|
+
|
6
|
+
RSpec.configure do |config|
|
7
|
+
# rspec-expectations config goes here. You can use an alternate
|
8
|
+
# assertion/expectation library such as wrong or the stdlib/minitest
|
9
|
+
# assertions if you prefer.
|
10
|
+
config.expect_with :rspec do |expectations|
|
11
|
+
# This option will default to `true` in RSpec 4. It makes the `description`
|
12
|
+
# and `failure_message` of custom matchers include text for helper methods
|
13
|
+
# defined using `chain`, e.g.:
|
14
|
+
# be_bigger_than(2).and_smaller_than(4).description
|
15
|
+
# # => "be bigger than 2 and smaller than 4"
|
16
|
+
# ...rather than:
|
17
|
+
# # => "be bigger than 2"
|
18
|
+
expectations.include_chain_clauses_in_custom_matcher_descriptions = true
|
19
|
+
end
|
20
|
+
|
21
|
+
# rspec-mocks config goes here. You can use an alternate test double
|
22
|
+
# library (such as bogus or mocha) by changing the `mock_with` option here.
|
23
|
+
config.mock_with :rspec do |mocks|
|
24
|
+
# Prevents you from mocking or stubbing a method that does not exist on
|
25
|
+
# a real object. This is generally recommended, and will default to
|
26
|
+
# `true` in RSpec 4.
|
27
|
+
mocks.verify_partial_doubles = true
|
28
|
+
end
|
29
|
+
|
30
|
+
# These two settings work together to allow you to limit a spec run
|
31
|
+
# to individual examples or groups you care about by tagging them with
|
32
|
+
# `:focus` metadata. When nothing is tagged with `:focus`, all examples
|
33
|
+
# get run.
|
34
|
+
config.filter_run :focus
|
35
|
+
config.run_all_when_everything_filtered = true
|
36
|
+
|
37
|
+
# Limits the available syntax to the non-monkey patched syntax that is
|
38
|
+
# recommended. For more details, see:
|
39
|
+
# - http://myronmars.to/n/dev-blog/2012/06/rspecs-new-expectation-syntax
|
40
|
+
# - http://teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
|
41
|
+
# - http://myronmars.to/n/dev-blog/2014/05/notable-changes-in-rspec-3#new__config_option_to_disable_rspeccore_monkey_patching
|
42
|
+
config.disable_monkey_patching!
|
43
|
+
|
44
|
+
# This setting enables warnings. It's recommended, but in some cases may
|
45
|
+
# be too noisy due to issues in dependencies.
|
46
|
+
config.warnings = true
|
47
|
+
|
48
|
+
# Many RSpec users commonly either run the entire suite or an individual
|
49
|
+
# file, and it's useful to allow more verbose output when running an
|
50
|
+
# individual spec file.
|
51
|
+
if config.files_to_run.one?
|
52
|
+
# Use the documentation formatter for detailed output,
|
53
|
+
# unless a formatter has already been configured
|
54
|
+
# (e.g. via a command-line flag).
|
55
|
+
config.default_formatter = 'doc'
|
56
|
+
end
|
57
|
+
|
58
|
+
# Print the 10 slowest examples and example groups at the
|
59
|
+
# end of the spec run, to help surface which specs are running
|
60
|
+
# particularly slow.
|
61
|
+
config.profile_examples = 10
|
62
|
+
|
63
|
+
# Run specs in random order to surface order dependencies. If you find an
|
64
|
+
# order dependency and want to debug it, you can fix the order by providing
|
65
|
+
# the seed, which is printed after each run.
|
66
|
+
# --seed 1234
|
67
|
+
config.order = :random
|
68
|
+
|
69
|
+
# Seed global randomization in this process using the `--seed` CLI option.
|
70
|
+
# Setting this allows you to use `--seed` to deterministically reproduce
|
71
|
+
# test failures related to randomization by passing the same `--seed` value
|
72
|
+
# as the one that triggered the failure.
|
73
|
+
Kernel.srand config.seed
|
74
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
if ENV['TRAVIS'] || ENV['COVERAGE']
|
4
|
+
require 'simplecov'
|
5
|
+
|
6
|
+
if ENV['TRAVIS']
|
7
|
+
require 'coveralls'
|
8
|
+
SimpleCov.formatter = Coveralls::SimpleCov::Formatter
|
9
|
+
end
|
10
|
+
|
11
|
+
SimpleCov.start do
|
12
|
+
add_filter '/spec/'
|
13
|
+
add_filter '/vendor/bundle/'
|
14
|
+
end
|
15
|
+
end
|
metadata
ADDED
@@ -0,0 +1,138 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: basehangul
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- ChaYoung You
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-11-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.7'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.7'
|
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: '3.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '3.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rubocop
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 0.27.0
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: 0.27.0
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: simplecov
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0.9'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0.9'
|
83
|
+
description: BaseHangul for Ruby.
|
84
|
+
email:
|
85
|
+
- yousbe@gmail.com
|
86
|
+
executables: []
|
87
|
+
extensions: []
|
88
|
+
extra_rdoc_files: []
|
89
|
+
files:
|
90
|
+
- ".gitignore"
|
91
|
+
- ".rspec"
|
92
|
+
- ".rubocop.yml"
|
93
|
+
- ".rubocop_todo.yml"
|
94
|
+
- ".travis.yml"
|
95
|
+
- CHANGELOG.md
|
96
|
+
- Gemfile
|
97
|
+
- LICENSE.txt
|
98
|
+
- README.md
|
99
|
+
- Rakefile
|
100
|
+
- basehangul.gemspec
|
101
|
+
- lib/basehangul.rb
|
102
|
+
- lib/basehangul/utils.rb
|
103
|
+
- lib/basehangul/version.rb
|
104
|
+
- spec/basehangul/utils_spec.rb
|
105
|
+
- spec/basehangul/version_spec.rb
|
106
|
+
- spec/basehangul_spec.rb
|
107
|
+
- spec/spec_helper.rb
|
108
|
+
- spec/support/coverage.rb
|
109
|
+
homepage: ''
|
110
|
+
licenses:
|
111
|
+
- MIT
|
112
|
+
metadata: {}
|
113
|
+
post_install_message:
|
114
|
+
rdoc_options: []
|
115
|
+
require_paths:
|
116
|
+
- lib
|
117
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
118
|
+
requirements:
|
119
|
+
- - ">="
|
120
|
+
- !ruby/object:Gem::Version
|
121
|
+
version: '0'
|
122
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
123
|
+
requirements:
|
124
|
+
- - ">="
|
125
|
+
- !ruby/object:Gem::Version
|
126
|
+
version: '0'
|
127
|
+
requirements: []
|
128
|
+
rubyforge_project:
|
129
|
+
rubygems_version: 2.4.2
|
130
|
+
signing_key:
|
131
|
+
specification_version: 4
|
132
|
+
summary: BaseHangul for Ruby.
|
133
|
+
test_files:
|
134
|
+
- spec/basehangul/utils_spec.rb
|
135
|
+
- spec/basehangul/version_spec.rb
|
136
|
+
- spec/basehangul_spec.rb
|
137
|
+
- spec/spec_helper.rb
|
138
|
+
- spec/support/coverage.rb
|