spacifier 1.0.0.pre.alpha2

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 9d9f70f6f9b9efdb04de2cc4c4838c6a36e8d68b
4
+ data.tar.gz: 747190451b7c1f70f7e74562d8f28caa295e7f12
5
+ SHA512:
6
+ metadata.gz: 18a00994e46eeefcf821d48b436f5c5c9983eefc5e4ebf81539b2c3e829a6f897e045debc161518c495c343d162829535aa6f31df299b629c3d99b05ea1e78a2
7
+ data.tar.gz: a2f41e63fd3b5ef7aab0fa8bbc305abe7c8b5a2533042bacd1d956a38edb625e1996cea2f7dd9e600b5f6bf9f0d6b883d70d86b86dd251500b75ed44da536ff2
data/.gitignore ADDED
@@ -0,0 +1,50 @@
1
+ *.gem
2
+ *.rbc
3
+ /.config
4
+ /coverage/
5
+ /InstalledFiles
6
+ /pkg/
7
+ /spec/reports/
8
+ /spec/examples.txt
9
+ /test/tmp/
10
+ /test/version_tmp/
11
+ /tmp/
12
+
13
+ # Used by dotenv library to load environment variables.
14
+ # .env
15
+
16
+ ## Specific to RubyMotion:
17
+ .dat*
18
+ .repl_history
19
+ build/
20
+ *.bridgesupport
21
+ build-iPhoneOS/
22
+ build-iPhoneSimulator/
23
+
24
+ ## Specific to RubyMotion (use of CocoaPods):
25
+ #
26
+ # We recommend against adding the Pods directory to your .gitignore. However
27
+ # you should judge for yourself, the pros and cons are mentioned at:
28
+ # https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control
29
+ #
30
+ # vendor/Pods/
31
+
32
+ ## Documentation cache and generated files:
33
+ /.yardoc/
34
+ /_yardoc/
35
+ /doc/
36
+ /rdoc/
37
+
38
+ ## Environment normalization:
39
+ /.bundle/
40
+ /vendor/bundle
41
+ /lib/bundler/man/
42
+
43
+ # for a library or gem, you might want to ignore these files since the code is
44
+ # intended to run in multiple environments; otherwise, check them in:
45
+ # Gemfile.lock
46
+ # .ruby-version
47
+ # .ruby-gemset
48
+
49
+ # unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
50
+ .rvmrc
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2016 David Zhang
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 all
13
+ 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 THE
21
+ SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,32 @@
1
+ # Spacifier
2
+
3
+ [![Gem Version](https://badge.fury.io/rb/spacifier.svg)](https://badge.fury.io/rb/spacifier)
4
+ [![](https://api.travis-ci.org/crispgm/spacifier.svg)](https://travis-ci.org/crispgm/spacifier)
5
+ [![Code Climate](https://codeclimate.com/github/crispgm/spacifier/badges/gpa.svg)](https://codeclimate.com/github/crispgm/spacifier)
6
+ [![Test Coverage](https://codeclimate.com/github/crispgm/spacifier/badges/coverage.svg)](https://codeclimate.com/github/crispgm/spacifier/coverage)
7
+
8
+ Insert a space between a Chinese character and a western character.
9
+
10
+ ## Installation
11
+
12
+ ```
13
+ $ gem install spacifier
14
+ ```
15
+
16
+ ## Usage
17
+
18
+ Put inputs with pipe to `spacifier`:
19
+
20
+ ```
21
+ $ echo "何为跨域?何为JSONP?JSONP技术能实现什么?是否有必要使用JSONP技术?" | spacifier
22
+ ```
23
+
24
+ Output:
25
+
26
+ ```
27
+ $ 何为跨域?何为 JSONP?JSONP 技术能实现什么?是否有必要使用 JSONP 技术?
28
+ ```
29
+
30
+ ## Jekyll-spacify
31
+
32
+ * WIP
data/exe/spacifier ADDED
@@ -0,0 +1,9 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), *%w(.. lib)))
4
+
5
+ require "spacifier"
6
+
7
+ input = ARGF.read
8
+
9
+ puts Spacifier.spacify(input)
@@ -0,0 +1,11 @@
1
+ # encoding: utf-8
2
+
3
+ module Spacifier
4
+ CHINESE_PUNCTUATIONS = ",。/、()【】「」·~《》?".freeze
5
+
6
+ class << self
7
+ def is_chinese_punctuation(c)
8
+ CHINESE_PUNCTUATIONS.include? c
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,3 @@
1
+ module Spacifier
2
+ VERSION = "1.0.0-alpha2".freeze
3
+ end
data/lib/spacifier.rb ADDED
@@ -0,0 +1,33 @@
1
+ # encoding: utf-8
2
+
3
+ module Spacifier
4
+
5
+ require "spacifier/punctuation"
6
+ require "spacifier/version"
7
+
8
+ class << self
9
+ def spacify(words)
10
+ # strip words
11
+ words.strip!
12
+ # init vars
13
+ new_words = ""
14
+ last_word_type = nil # 0 for cn, 1 for en
15
+ # iterate chars
16
+ words.each_char do |c|
17
+ if is_chinese_punctuation(c)
18
+ new_words << c
19
+ elsif /\p{Han}/.match(c) == nil
20
+ new_words << " " if last_word_type == 0
21
+ new_words << c
22
+ last_word_type = 1
23
+ else
24
+ new_words << " " if last_word_type == 1
25
+ new_words << c
26
+ last_word_type = 0
27
+ end
28
+ end
29
+
30
+ new_words
31
+ end
32
+ end
33
+ end
data/spacifier.gemspec ADDED
@@ -0,0 +1,28 @@
1
+ # coding: utf-8
2
+
3
+ lib = File.expand_path('../lib', __FILE__)
4
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
5
+ require 'spacifier/version'
6
+
7
+ Gem::Specification.new do |spec|
8
+ spec.name = "spacifier"
9
+ spec.version = Spacifier::VERSION
10
+ spec.authors = ["David Zhang"]
11
+ spec.email = ["crispgm@gmail.com"]
12
+ spec.summary = "Insert a space between a Chinese character and a western character"
13
+ spec.description = "Insert a space between a Chinese character and a western character"
14
+ spec.homepage = "https://github.com/crispgm/spacifier"
15
+ spec.license = "MIT"
16
+
17
+ spec.required_ruby_version = '>= 2.2.5'
18
+
19
+ spec.files = `git ls-files -z`.split("\x0")
20
+ spec.bindir = "exe"
21
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
22
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
23
+ spec.require_paths = ["lib"]
24
+
25
+ # spec.add_development_dependency "minitest"
26
+ # spec.add_development_dependency "shoulda-context"
27
+ # spec.add_development_dependency "codeclimate-test-reporter", "0.6.0"
28
+ end
metadata ADDED
@@ -0,0 +1,53 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: spacifier
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0.pre.alpha2
5
+ platform: ruby
6
+ authors:
7
+ - David Zhang
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2016-11-27 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: Insert a space between a Chinese character and a western character
14
+ email:
15
+ - crispgm@gmail.com
16
+ executables:
17
+ - spacifier
18
+ extensions: []
19
+ extra_rdoc_files: []
20
+ files:
21
+ - ".gitignore"
22
+ - LICENSE
23
+ - README.md
24
+ - exe/spacifier
25
+ - lib/spacifier.rb
26
+ - lib/spacifier/punctuation.rb
27
+ - lib/spacifier/version.rb
28
+ - spacifier.gemspec
29
+ homepage: https://github.com/crispgm/spacifier
30
+ licenses:
31
+ - MIT
32
+ metadata: {}
33
+ post_install_message:
34
+ rdoc_options: []
35
+ require_paths:
36
+ - lib
37
+ required_ruby_version: !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - ">="
40
+ - !ruby/object:Gem::Version
41
+ version: 2.2.5
42
+ required_rubygems_version: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - ">"
45
+ - !ruby/object:Gem::Version
46
+ version: 1.3.1
47
+ requirements: []
48
+ rubyforge_project:
49
+ rubygems_version: 2.6.7
50
+ signing_key:
51
+ specification_version: 4
52
+ summary: Insert a space between a Chinese character and a western character
53
+ test_files: []