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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8051c968238e3b1c43c720ab361048ea6c4425bb
4
- data.tar.gz: 7abea26a46025b0ccebefddf1283a49f02a216bd
3
+ metadata.gz: 0c7487d75ddd961756696937519defb041781b78
4
+ data.tar.gz: c20b251d13e3f4bf371231d65498bb02e998eab0
5
5
  SHA512:
6
- metadata.gz: 1917b40881a3c0c5365d358f94d9d79dfb720e864544c5efb92f9b68de35ac8587fffc60fa3c30bf60902aa8abc5a0a7cdce3a89454ccf0754d909e58009bb2f
7
- data.tar.gz: 4bad761f33b502f47a40c47e4c3b6bb5a9d41b23bedd8b8f7acdfd7fafb3be737abd6489f11b88a3100e53c13578114686a6b60b6c122d14b23c836bf2d99d13
6
+ metadata.gz: 36bdfb5b6719440a65a1aef9c1537d541d8940c160a187ead8adea2036ebcd6ace6bd1171093a44430ccc52cfcef6b79797102fe2250d0d4ede80050acc789d1
7
+ data.tar.gz: f51352efdfa1e8f3c94f78c26ff17c68db2b8678056e69f6b0221d8bd640116e85b2e3339e0722fbb7ccf7219bbcd136c50a5a2472a4c6640f108b4aa5dcc2c2
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --format progress
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Fullwidth
2
2
 
3
- TODO: Write a gem description
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
- TODO: Write usage instructions here
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
 
@@ -0,0 +1,13 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'fullwidth'
4
+
5
+ def input_string
6
+ if ARGV.length > 0
7
+ ARGV.join(' ')
8
+ else
9
+ STDIN.read
10
+ end
11
+ end
12
+
13
+ puts input_string.to_fullwidth
@@ -20,4 +20,5 @@ Gem::Specification.new do |spec|
20
20
 
21
21
  spec.add_development_dependency "bundler", "~> 1.2"
22
22
  spec.add_development_dependency "rake"
23
+ spec.add_development_dependency "rspec"
23
24
  end
@@ -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
@@ -1,3 +1,3 @@
1
1
  module Fullwidth
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
@@ -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
@@ -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.1
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-07 00:00:00.000000000 Z
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