cangjie 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 2fdea6abc5d728f44caca9cf84d2496d54598f33
4
+ data.tar.gz: 2d516ecb57946b7529536325b24e70c132f12d9e
5
+ SHA512:
6
+ metadata.gz: 12fcea6dd9fd54d90339a14581ccf88cd73d833a5ac6a33a9b2315a53b437651cd94f31679f0d8128ccdb0213152a2cb2366c5b057d308a47fdf5b65a628a00d
7
+ data.tar.gz: 23f1ddadcd47fcd8bdc019d8de49757a9ed897a0f86bcd3bcf32787f69e70bfaac6cbfe853e5b66b328e873fb33ba6f82f7ee03213646977a47ebfcaa73020ff
@@ -0,0 +1,9 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
@@ -0,0 +1,12 @@
1
+ sudo: false
2
+ cache: bundler
3
+ language: ruby
4
+ bundler_args: --without debugging
5
+ rvm:
6
+ - 2.3.0
7
+ - 2.2.4
8
+ - ruby-head
9
+ matrix:
10
+ allow_failures:
11
+ - rvm: ruby-head
12
+ fast_finish: true
data/Gemfile ADDED
@@ -0,0 +1,10 @@
1
+ source "https://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in cangjie.gemspec
4
+ gemspec
5
+
6
+ group :development do
7
+ gem "bundler"
8
+ gem "rake"
9
+ gem "rspec", "~> 3.4"
10
+ end
@@ -0,0 +1,67 @@
1
+ # Cangjie
2
+
3
+ [![https://commons.wikimedia.org/wiki/File:Cangjie2.jpg#/media/File:Cangjie2.jpg](https://upload.wikimedia.org/wikipedia/commons/5/53/Cangjie2.jpg)](https://en.wikipedia.org/wiki/Cangjie)
4
+
5
+ Cangjie invented Chinese characters. I invite him to help us recognize Chinese to RubyGems world.
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem "cangjie"
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install cangjie
22
+
23
+ ## Usage
24
+
25
+ ```ruby
26
+ CHINESE = "讓我們再一次把紅寶石變得更美好"
27
+ ENGLISH = "Let's make Ruby great again"
28
+ CHI_ENG = "唐納·川普 Donald John Trump"
29
+
30
+ Cangjie.has_chinese? CHINESE # => true
31
+ Cangjie.all_chinese? CHINESE # => true
32
+
33
+ Cangjie.has_chinese? ENGLISH # => false
34
+ Cangjie.all_chinese? ENGLISH # => false
35
+
36
+ Cangjie.has_chinese? CHI_ENG # => true
37
+ Cangjie.all_chinese? CHI_ENG # => false
38
+ ```
39
+
40
+ If you love freedom, require this freedom patch:
41
+
42
+ ```
43
+ require "cangjie/core_ext"
44
+
45
+ "讓我們再一次把紅寶石變得更美好".has_chinese? # => true
46
+ "讓我們再一次把紅寶石變得更美好".all_chinese? # => true
47
+
48
+ "Let's make Ruby great again".has_chinese? # => false
49
+ "Let's make Ruby great again".all_chinese? # => false
50
+
51
+ "唐納·川普 Donald John Trump".has_chinese? # => true
52
+ "唐納·川普 Donald John Trump".all_chinese? # => false
53
+ ```
54
+
55
+ ## Development
56
+
57
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
58
+
59
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
60
+
61
+ ## Contributing
62
+
63
+ Bug reports and pull requests are welcome on GitHub at https://github.com/JuanitoFatas/cangjie.
64
+
65
+ ## LICENSE
66
+
67
+ [UNLICENSE](/UNLICENSE)
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task default: :spec
@@ -0,0 +1,24 @@
1
+ This is free and unencumbered software released into the public domain.
2
+
3
+ Anyone is free to copy, modify, publish, use, compile, sell, or
4
+ distribute this software, either in source code form or as a compiled
5
+ binary, for any purpose, commercial or non-commercial, and by any
6
+ means.
7
+
8
+ In jurisdictions that recognize copyright laws, the author or authors
9
+ of this software dedicate any and all copyright interest in the
10
+ software to the public domain. We make this dedication for the benefit
11
+ of the public at large and to the detriment of our heirs and
12
+ successors. We intend this dedication to be an overt act of
13
+ relinquishment in perpetuity of all present and future rights to this
14
+ software under copyright law.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
19
+ IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
20
+ OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
21
+ ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
22
+ OTHER DEALINGS IN THE SOFTWARE.
23
+
24
+ For more information, please refer to <http://unlicense.org>
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "cangjie"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$"\n\t"
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,21 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path("../lib", __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require "cangjie/version"
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "cangjie"
8
+ spec.version = Cangjie::VERSION
9
+ spec.authors = ["JuanitoFatas"]
10
+ spec.email = ["katehuang0320@gmail.com"]
11
+
12
+ spec.summary = "Cangjie invented Chinese characters. I invite him to help us recognize Chinese to RubyGems world."
13
+ spec.description = spec.summary
14
+ spec.homepage = "https://github.com/JuanitoFatas/cangjie"
15
+ spec.license = "UNLICENSE"
16
+
17
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
18
+ spec.bindir = "exe"
19
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
20
+ spec.require_paths = ["lib"]
21
+ end
@@ -0,0 +1,16 @@
1
+ require "cangjie/version"
2
+
3
+ module Cangjie
4
+ def self.has_chinese?(text)
5
+ text.split(EMPTY_STRING).any? { |char| char =~ /\p{Han}/ }
6
+ end
7
+
8
+ def self.all_chinese?(text)
9
+ text.split(EMPTY_STRING).all? { |char| char =~ /\p{Han}/ }
10
+ end
11
+
12
+ # private
13
+
14
+ EMPTY_STRING = "".freeze
15
+ private_constant :EMPTY_STRING
16
+ end
@@ -0,0 +1,17 @@
1
+ require "cangjie"
2
+
3
+ unless String.method_defined?(:has_chinese?)
4
+ class String
5
+ def has_chinese?
6
+ Cangjie.has_chinese?(self)
7
+ end
8
+ end
9
+ end
10
+
11
+ unless String.method_defined?(:all_chinese?)
12
+ class String
13
+ def all_chinese?
14
+ Cangjie.all_chinese?(self)
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,3 @@
1
+ module Cangjie
2
+ VERSION = "1.0.0".freeze
3
+ end
metadata ADDED
@@ -0,0 +1,59 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: cangjie
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - JuanitoFatas
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2016-03-07 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: Cangjie invented Chinese characters. I invite him to help us recognize
14
+ Chinese to RubyGems world.
15
+ email:
16
+ - katehuang0320@gmail.com
17
+ executables: []
18
+ extensions: []
19
+ extra_rdoc_files: []
20
+ files:
21
+ - ".gitignore"
22
+ - ".rspec"
23
+ - ".travis.yml"
24
+ - Gemfile
25
+ - README.md
26
+ - Rakefile
27
+ - UNLICENSE
28
+ - bin/console
29
+ - bin/setup
30
+ - cangjie.gemspec
31
+ - lib/cangjie.rb
32
+ - lib/cangjie/core_ext.rb
33
+ - lib/cangjie/version.rb
34
+ homepage: https://github.com/JuanitoFatas/cangjie
35
+ licenses:
36
+ - UNLICENSE
37
+ metadata: {}
38
+ post_install_message:
39
+ rdoc_options: []
40
+ require_paths:
41
+ - lib
42
+ required_ruby_version: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - ">="
45
+ - !ruby/object:Gem::Version
46
+ version: '0'
47
+ required_rubygems_version: !ruby/object:Gem::Requirement
48
+ requirements:
49
+ - - ">="
50
+ - !ruby/object:Gem::Version
51
+ version: '0'
52
+ requirements: []
53
+ rubyforge_project:
54
+ rubygems_version: 2.6.1
55
+ signing_key:
56
+ specification_version: 4
57
+ summary: Cangjie invented Chinese characters. I invite him to help us recognize Chinese
58
+ to RubyGems world.
59
+ test_files: []