jisx0208 0.1.0 → 0.1.1
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/README.md +16 -23
- data/lib/jisx0208/processor.rb +5 -5
- data/lib/jisx0208/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 117d24d1998f47e8226d3b1889463a20a3fef41015b52d4ecefb3a6d48c2bcc2
|
4
|
+
data.tar.gz: fb8399e275c127d3a5735b34971b7db5be73eadfe2e5fb266cb53560670b2a55
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 723b29e58350d0c88dab162d17afb7ac66361f297e26d6622b9139e9912439cfceca65e118a295c2a2958c8c0a20c75a3876f80854ebbafa517570d038d9284f
|
7
|
+
data.tar.gz: 4809fca7d0238ddd83d62088066c60cf73c687fbbfbb433249f82cf4b249231eb4a9dec5401071de9d873c7639cc0e5183d40661417bc1b79e1ebd2687974ff2
|
data/README.md
CHANGED
@@ -1,31 +1,24 @@
|
|
1
1
|
# Jisx0208
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/jisx0208`. To experiment with that code, run `bin/console` for an interactive prompt.
|
3
|
+
JIS X 0208 is a collection of common characters used in Japanese writing, place names, and people's names.
|
4
|
+
[jisx0208](https://rubygems.org/gems/jisx0208) is a Ruby gem that provides a simple way to check if a string contains [JIS X 0208 characters](https://www.unicode.org/Public/MAPPINGS/OBSOLETE/EASTASIA/JIS/JIS0208.TXT).
|
6
5
|
|
7
6
|
## Installation
|
8
7
|
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
$ bundle add UPDATE_WITH_YOUR_GEM_NAME_IMMEDIATELY_AFTER_RELEASE_TO_RUBYGEMS_ORG
|
14
|
-
|
15
|
-
If bundler is not being used to manage dependencies, install the gem by executing:
|
16
|
-
|
17
|
-
$ gem install UPDATE_WITH_YOUR_GEM_NAME_IMMEDIATELY_AFTER_RELEASE_TO_RUBYGEMS_ORG
|
8
|
+
```ruby
|
9
|
+
gem install jisx0208
|
10
|
+
```
|
18
11
|
|
19
12
|
## Usage
|
20
13
|
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
14
|
+
```ruby
|
15
|
+
require "jisx0208"
|
16
|
+
|
17
|
+
code = JISX0208::Code.new
|
18
|
+
code.contains_first_level_kanji?("亜") # => true
|
19
|
+
code.contains_first_level_kanji?("弌") # => false
|
20
|
+
code.contains_seconde_level_kanji?("弌") # => true
|
21
|
+
code.contains_seconde_level_kanji?("亜") # => false
|
22
|
+
# same as (contains_first_level_kanji || contains_seconde_level_kanji)
|
23
|
+
code.contains_jisx0208_kanji?("亜弌") # => true
|
24
|
+
```
|
data/lib/jisx0208/processor.rb
CHANGED
@@ -7,11 +7,11 @@ module JISX0208
|
|
7
7
|
file_path = File.join(File.dirname(__FILE__), "..", "..", "data", "JIS0208.TXT")
|
8
8
|
file = File.open(file_path)
|
9
9
|
|
10
|
-
mappings = file.each_line.with_object(
|
10
|
+
mappings = file.each_line.with_object({}) do |line, hash|
|
11
11
|
next if line.start_with?("#")
|
12
12
|
|
13
|
-
_sjis,
|
14
|
-
|
13
|
+
_sjis, jisx, unicode, _others = line.split(" ")
|
14
|
+
hash[jisx.to_i(16)] = unicode.to_i(16)
|
15
15
|
end
|
16
16
|
|
17
17
|
# see http://ash.jp/code/unitbl21.htm
|
@@ -34,8 +34,8 @@ module JISX0208
|
|
34
34
|
private
|
35
35
|
|
36
36
|
def collect_unicode_set(mappings, jisx_start, jisx_end)
|
37
|
-
mappings.map do |
|
38
|
-
|
37
|
+
mappings.map do |jisx, unicode|
|
38
|
+
unicode if jisx.between?(jisx_start, jisx_end)
|
39
39
|
end.compact.to_set
|
40
40
|
end
|
41
41
|
end
|
data/lib/jisx0208/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jisx0208
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- kaiba
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-11-
|
11
|
+
date: 2024-11-19 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Determines if a character is included in jisx0208 with JIS0208.TXT
|
14
14
|
email:
|