unified_hyphen 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: c007506100662dc25a2bc1ab13107dab873ae1de
4
- data.tar.gz: 0c295ad2a0ca34c31560a6787a8b3049fe04a0c1
3
+ metadata.gz: 97bab0130a131792abb21be1f263d70e57d457b8
4
+ data.tar.gz: 7505ded29185b7dfd282f8a23a66c6918a0b970c
5
5
  SHA512:
6
- metadata.gz: 8064f83f5e9b04dcb16619cf25b38f1e2b313c8272913d07335c95c69034ae9d3924cf5a4d6d4627eb3c063776724856065e96dd6daf51c017b6ff950fb78696
7
- data.tar.gz: eb9005739a816f8258b4eba998e329fd2dc1f4b601a76ac209debd84a35764cd04bea1604994e129e68b6908d365a482c18ff1fe3fcb7f4b4082d4af8a626062
6
+ metadata.gz: 55bbefb76c24c4ebdfa084041137fa546db854343e2e74436c5b14d73403199ea91189e23055da89a5b7559fb4ddc6eb320026a55d23591ba87fd43e5161c234
7
+ data.tar.gz: 56e9850b68491273bad9786c21703b0ed3c3914408ce9ae8dd64933c812463a1e529b9555db6390a4cbd2e66f85d515a9ffabb75ed21fb31ceea24cb3fbdc936
data/bin/rspec ADDED
@@ -0,0 +1,16 @@
1
+ #!/usr/bin/env ruby
2
+ #
3
+ # This file was generated by Bundler.
4
+ #
5
+ # The application 'rspec' is installed as part of a gem, and
6
+ # this file is here to facilitate running it.
7
+ #
8
+
9
+ require "pathname"
10
+ ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
11
+ Pathname.new(__FILE__).realpath)
12
+
13
+ require "rubygems"
14
+ require "bundler/setup"
15
+
16
+ load Gem.bin_path("rspec-core", "rspec")
@@ -2,13 +2,12 @@ require "unified_hyphen/version"
2
2
  module UnifiedHyphen
3
3
  end
4
4
  class String
5
- def unify_ja(to_hyphen="-")
6
- hyphen = "ー|−|―|-|‐|‑|–|—|ー"
7
- self.gsub(/#{hyphen}/, to_hyphen)
5
+ JA_HYPEN_PATTERN = /ー|−|―|-|‐|‑|–|—|ー/
6
+ def unify_ja_hyphen(dst_string="-")
7
+ self.gsub(JA_HYPEN_PATTERN, dst_string)
8
8
  end
9
9
 
10
- def unify_ja!(to_hyphen="-")
11
- hyphen = "ー|−|―|-|‐|‑|–|—|ー"
12
- self.gsub!(/#{hyphen}/, to_hyphen)
10
+ def unify_ja_hyphen!(dst_string="-")
11
+ self.gsub!(JA_HYPEN_PATTERN, dst_string)
13
12
  end
14
13
  end
@@ -1,3 +1,3 @@
1
1
  module UnifiedHyphen
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
@@ -1,12 +1,29 @@
1
1
  require 'spec_helper'
2
2
 
3
+ RSpec.shared_examples "correct unified hyphen" do |parameter|
4
+ it {
5
+ expect(str_fixed).to eq str_org.send(parameter)
6
+ }
7
+ end
8
+
3
9
  describe UnifiedHyphen do
4
10
  it 'has a version number' do
5
11
  expect(UnifiedHyphen::VERSION).not_to be nil
6
12
  end
7
13
 
8
- it 'correct unified hyphen' do
9
- unified_hyphen = "ー:−:―:-:‐:‑:–:—:ー".unify_ja
10
- expect("-:-:-:-:-:-:-:-:-").to eq unified_hyphen
14
+ let(:str_org) { "ー:−:―:-:‐:‑:–:—:ー" }
15
+ let(:str_fixed) { "-:-:-:-:-:-:-:-:-" }
16
+
17
+ include_examples "correct unified hyphen", :unify_ja_hyphen
18
+ include_examples "correct unified hyphen", :unify_ja_hyphen!
19
+
20
+ it 'unify_ja_hyphen is not bang method' do
21
+ str_org.unify_ja_hyphen
22
+ expect(str_org).to eq str_org
23
+ end
24
+
25
+ it 'unify_ja_hyphen! is bang method' do
26
+ str_org.unify_ja_hyphen!
27
+ expect(str_fixed).to eq str_org
11
28
  end
12
29
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: unified_hyphen
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
  - Yoshiki Kobayashi
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-02-10 00:00:00.000000000 Z
11
+ date: 2017-02-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -55,7 +55,8 @@ dependencies:
55
55
  description: unified hyphen
56
56
  email:
57
57
  - attack_no22001@yahoo.co.jp
58
- executables: []
58
+ executables:
59
+ - rspec
59
60
  extensions: []
60
61
  extra_rdoc_files: []
61
62
  files:
@@ -66,6 +67,7 @@ files:
66
67
  - LICENSE.txt
67
68
  - README.md
68
69
  - Rakefile
70
+ - bin/rspec
69
71
  - lib/unified_hyphen.rb
70
72
  - lib/unified_hyphen/version.rb
71
73
  - spec/spec_helper.rb