jisx0208 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c48c2d17a1bfcc48ced6fa08d1f4a7c0e52c3d4a77035417c770eb8274f3c376
4
- data.tar.gz: d44c10021302f56565593f73b8b12940f38b06fa45589ce87421e7f49e61d5ff
3
+ metadata.gz: 117d24d1998f47e8226d3b1889463a20a3fef41015b52d4ecefb3a6d48c2bcc2
4
+ data.tar.gz: fb8399e275c127d3a5735b34971b7db5be73eadfe2e5fb266cb53560670b2a55
5
5
  SHA512:
6
- metadata.gz: f23a2a93ec9ff3f75e8f5dc9ad501acd3064f6782c97b88b282465709d15acfa196889ab1008e09fab3921c869c32d1dc8c99f6b5db47f95ca46607397d00700
7
- data.tar.gz: add62814b07b9a6e36bfd2a2621bfb09f8fe799a64e6bf3240826d5492eb4174ca51912b6f65a03fc2e6b56083b788b4e77714c318559f7485e48ff0f608b763
6
+ metadata.gz: 723b29e58350d0c88dab162d17afb7ac66361f297e26d6622b9139e9912439cfceca65e118a295c2a2958c8c0a20c75a3876f80854ebbafa517570d038d9284f
7
+ data.tar.gz: 4809fca7d0238ddd83d62088066c60cf73c687fbbfbb433249f82cf4b249231eb4a9dec5401071de9d873c7639cc0e5183d40661417bc1b79e1ebd2687974ff2
data/README.md CHANGED
@@ -1,31 +1,24 @@
1
1
  # Jisx0208
2
2
 
3
- TODO: Delete this and the text below, and describe your gem
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
- TODO: Replace `UPDATE_WITH_YOUR_GEM_NAME_IMMEDIATELY_AFTER_RELEASE_TO_RUBYGEMS_ORG` with your gem name right after releasing it to RubyGems.org. Please do not do it earlier due to security reasons. Alternatively, replace this section with instructions to install your gem from git if you don't plan to release to RubyGems.org.
10
-
11
- Install the gem and add to the application's Gemfile by executing:
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
- TODO: Write usage instructions here
22
-
23
- ## Development
24
-
25
- 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.
26
-
27
- 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 the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
28
-
29
- ## Contributing
30
-
31
- Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/jisx0208.
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
+ ```
@@ -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([]) do |line, arr|
10
+ mappings = file.each_line.with_object({}) do |line, hash|
11
11
  next if line.start_with?("#")
12
12
 
13
- _sjis, _, unicode, _others = line.split(" ")
14
- arr << { jisx: unicode.to_i(16) }
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 |unicode_value|
38
- unicode_value[:jisx] if unicode_value[:jisx].between?(jisx_start, jisx_end)
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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Jisx0208
4
- VERSION = "0.1.0"
4
+ VERSION = "0.1.1"
5
5
  end
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.0
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-16 00:00:00.000000000 Z
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: