fullwidth 0.0.1 → 0.0.2
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/.rspec +2 -0
- data/README.md +6 -2
- data/bin/fullwidth +13 -0
- data/fullwidth.gemspec +1 -0
- data/lib/fullwidth/string_ext.rb +3 -1
- data/lib/fullwidth/version.rb +1 -1
- data/spec/fullwidth_spec.rb +40 -0
- data/spec/spec_helper.rb +19 -0
- metadata +25 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0c7487d75ddd961756696937519defb041781b78
|
4
|
+
data.tar.gz: c20b251d13e3f4bf371231d65498bb02e998eab0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 36bdfb5b6719440a65a1aef9c1537d541d8940c160a187ead8adea2036ebcd6ace6bd1171093a44430ccc52cfcef6b79797102fe2250d0d4ede80050acc789d1
|
7
|
+
data.tar.gz: f51352efdfa1e8f3c94f78c26ff17c68db2b8678056e69f6b0221d8bd640116e85b2e3339e0722fbb7ccf7219bbcd136c50a5a2472a4c6640f108b4aa5dcc2c2
|
data/.rspec
ADDED
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# Fullwidth
|
2
2
|
|
3
|
-
|
3
|
+
Convert ASCII to equivalent fullwidth characters.
|
4
4
|
|
5
5
|
## Installation
|
6
6
|
|
@@ -18,7 +18,11 @@ Or install it yourself as:
|
|
18
18
|
|
19
19
|
## Usage
|
20
20
|
|
21
|
-
|
21
|
+
``` ruby
|
22
|
+
"foobar".to_fullwidth # => "foobar"
|
23
|
+
"hello, world.".to_fullwidth # => "hello, world."
|
24
|
+
"鋸".to_fullwidth # => "鋸"
|
25
|
+
```
|
22
26
|
|
23
27
|
## Contributing
|
24
28
|
|
data/bin/fullwidth
ADDED
data/fullwidth.gemspec
CHANGED
data/lib/fullwidth/string_ext.rb
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
class String
|
2
|
+
HALFWIDTH_KANA = '。「」、・ヲァィゥェォャュョッーアイウエオカキクケコサシスセソタチツテトナニヌネノハヒフヘホマミムメモヤユヨラリルレロワン゙゚'
|
3
|
+
FULLWIDTH_KANA = '。「」、・ヲァィゥェォャュョッーアイウエオカキクケコサシスセソタチツテトナニヌネノハヒフヘホマミムメモヤユヨラリルレロワン゛゜'
|
2
4
|
def to_fullwidth
|
3
|
-
tr(' !-~', "\u3000" + (0xFF01...0xFF5f).to_a.pack('U*'))
|
5
|
+
tr(' !-~' + HALFWIDTH_KANA, "\u3000" + (0xFF01...0xFF5f).to_a.pack('U*') + FULLWIDTH_KANA)
|
4
6
|
end
|
5
7
|
end
|
data/lib/fullwidth/version.rb
CHANGED
@@ -0,0 +1,40 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe ".to_fullwidth" do
|
4
|
+
subject{ original.to_fullwidth }
|
5
|
+
|
6
|
+
context "simple latin characters" do
|
7
|
+
let(:original){ 'Hello, world.' }
|
8
|
+
it{ should eq("Hello, world.") }
|
9
|
+
end
|
10
|
+
|
11
|
+
context "whole alphabet" do
|
12
|
+
let(:original){ 'The quick brown fox jumps over the lazy dog' }
|
13
|
+
it{ should eq("The quick brown fox jumps over the lazy dog") }
|
14
|
+
end
|
15
|
+
|
16
|
+
context "kanji" do
|
17
|
+
let(:original){ '鋸' }
|
18
|
+
it{ should eq('鋸') }
|
19
|
+
end
|
20
|
+
|
21
|
+
context "half-width kana" do
|
22
|
+
let(:original) do
|
23
|
+
<<-EOS
|
24
|
+
。 「 」 、 ・ ヲ ァ ィ ゥ ェ ォ ャ ュ ョ ッ
|
25
|
+
ー ア イ ウ エ オ カ キ ク ケ コ サ シ ス セ ソ
|
26
|
+
タ チ ツ テ ト ナ ニ ヌ ネ ノ ハ ヒ フ ヘ ホ マ
|
27
|
+
ミ ム メ モ ヤ ユ ヨ ラ リ ル レ ロ ワ ン ゙ ゚
|
28
|
+
EOS
|
29
|
+
end
|
30
|
+
|
31
|
+
it do
|
32
|
+
should eq(<<-EOS)
|
33
|
+
。 「 」 、 ・ ヲ ァ ィ ゥ ェ ォ ャ ュ ョ ッ
|
34
|
+
ー ア イ ウ エ オ カ キ ク ケ コ サ シ ス セ ソ
|
35
|
+
タ チ ツ テ ト ナ ニ ヌ ネ ノ ハ ヒ フ ヘ ホ マ
|
36
|
+
ミ ム メ モ ヤ ユ ヨ ラ リ ル レ ロ ワ ン ゛ ゜
|
37
|
+
EOS
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'fullwidth'
|
2
|
+
|
3
|
+
# This file was generated by the `rspec --init` command. Conventionally, all
|
4
|
+
# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
|
5
|
+
# Require this file using `require "spec_helper"` to ensure that it is only
|
6
|
+
# loaded once.
|
7
|
+
#
|
8
|
+
# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
|
9
|
+
RSpec.configure do |config|
|
10
|
+
config.treat_symbols_as_metadata_keys_with_true_values = true
|
11
|
+
config.run_all_when_everything_filtered = true
|
12
|
+
config.filter_run :focus
|
13
|
+
|
14
|
+
# Run specs in random order to surface order dependencies. If you find an
|
15
|
+
# order dependency and want to debug it, you can fix the order by providing
|
16
|
+
# the seed, which is printed after each run.
|
17
|
+
# --seed 1234
|
18
|
+
config.order = 'random'
|
19
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fullwidth
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- John Hawthorn
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-01-
|
11
|
+
date: 2014-01-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -38,22 +38,41 @@ dependencies:
|
|
38
38
|
- - '>='
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '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'
|
41
55
|
description: Convert ASCII to equivalent fullwidth characters.
|
42
56
|
email:
|
43
57
|
- john.hawthorn@gmail.com
|
44
|
-
executables:
|
58
|
+
executables:
|
59
|
+
- fullwidth
|
45
60
|
extensions: []
|
46
61
|
extra_rdoc_files: []
|
47
62
|
files:
|
48
63
|
- .gitignore
|
64
|
+
- .rspec
|
49
65
|
- Gemfile
|
50
66
|
- LICENSE.txt
|
51
67
|
- README.md
|
52
68
|
- Rakefile
|
69
|
+
- bin/fullwidth
|
53
70
|
- fullwidth.gemspec
|
54
71
|
- lib/fullwidth.rb
|
55
72
|
- lib/fullwidth/string_ext.rb
|
56
73
|
- lib/fullwidth/version.rb
|
74
|
+
- spec/fullwidth_spec.rb
|
75
|
+
- spec/spec_helper.rb
|
57
76
|
homepage: ''
|
58
77
|
licenses:
|
59
78
|
- MIT
|
@@ -78,4 +97,6 @@ rubygems_version: 2.1.11
|
|
78
97
|
signing_key:
|
79
98
|
specification_version: 4
|
80
99
|
summary: Convert ASCII to equivalent fullwidth characters.
|
81
|
-
test_files:
|
100
|
+
test_files:
|
101
|
+
- spec/fullwidth_spec.rb
|
102
|
+
- spec/spec_helper.rb
|