jisx0208 0.1.1 → 0.3.0

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: 117d24d1998f47e8226d3b1889463a20a3fef41015b52d4ecefb3a6d48c2bcc2
4
- data.tar.gz: fb8399e275c127d3a5735b34971b7db5be73eadfe2e5fb266cb53560670b2a55
3
+ metadata.gz: df31e4cd2133bcd6d29df8dc276a6d91416830a584562e481ec7bf467317a3da
4
+ data.tar.gz: 403efbc30320410819b124682aa52cf74af5c39c5e8c9558514d9666b5ef0160
5
5
  SHA512:
6
- metadata.gz: 723b29e58350d0c88dab162d17afb7ac66361f297e26d6622b9139e9912439cfceca65e118a295c2a2958c8c0a20c75a3876f80854ebbafa517570d038d9284f
7
- data.tar.gz: 4809fca7d0238ddd83d62088066c60cf73c687fbbfbb433249f82cf4b249231eb4a9dec5401071de9d873c7639cc0e5183d40661417bc1b79e1ebd2687974ff2
6
+ metadata.gz: 34088717a5e2e284b703d50d3846e9fd0c3e4e9e94067c508a9b713eddd560bee6105c9346682174f6c8e27a6360b6a027ffbb9ca0d7e212b9b7a5d582a19cb5
7
+ data.tar.gz: 567da61871adffd160b74310a96da30ea3536f61beddeea494ec1370fda8d2cd5d6aba44cb02ccb04cfd0a2d67139e4a56dc9d7036c4caa0a5aec3136f81d719
data/README.md CHANGED
@@ -21,4 +21,9 @@ code.contains_seconde_level_kanji?("弌") # => true
21
21
  code.contains_seconde_level_kanji?("亜") # => false
22
22
  # same as (contains_first_level_kanji || contains_seconde_level_kanji)
23
23
  code.contains_jisx0208_kanji?("亜弌") # => true
24
+
25
+ code.only_first_level_kanji?("回転寿司") # => true
26
+ code.only_second_level_kanji?("偃龠偕") # => true
27
+ # same as (only_first_level_kanji || only_second_level_kanji)
28
+ code.only_jisx0208_kanji?("回転寿司偃龠偕") # => true
24
29
  ```
@@ -0,0 +1,38 @@
1
+ #!/bin/bash
2
+
3
+ if [ -z "$1" ]; then
4
+ echo "Usage: $0 <version>"
5
+ exit 1
6
+ fi
7
+
8
+ # ~/.gem/credentials
9
+ if [ ! -f ~/.gem/credentials ]; then
10
+ echo "Error: ~/.gem/credentials not found. Please set up your RubyGems credentials."
11
+ exit 1
12
+ fi
13
+
14
+ PROJECT_NAME="jisx0208"
15
+ GITHUB_REPO="kaibadash/jisx0208-ruby"
16
+ VERSION=$1
17
+ echo "Start bumping version: $VERSION"
18
+
19
+ # Publish
20
+ # Add release branch
21
+ git checkout master
22
+ git checkout -b release/$VERSION
23
+ sed -i '' "s/VERSION = \".*\"/VERSION = \"$VERSION\"/" lib/$PROJECT_NAME/version.rb
24
+
25
+ # Publish to rubygems
26
+ gem build $PROJECT_NAME.gemspec
27
+ bundle install
28
+ git commit -am "Bump version $VERSION"
29
+ gem push $PROJECT_NAME-$VERSION.gem
30
+
31
+ # GitHub release
32
+ git tag $VERSION
33
+ git push --tags
34
+ open https://github.com/$GITHUB_REPO/releases/new
35
+
36
+ # merge to master
37
+ git checkout master
38
+ git merge release/$VERSION
@@ -17,6 +17,7 @@ module JISX0208
17
17
  # see http://ash.jp/code/unitbl21.htm
18
18
  @first_level_ranges = collect_unicode_set(mappings, 0x3021, 0x4F53)
19
19
  @second_level_ranges = collect_unicode_set(mappings, 0x5021, 0x7426)
20
+ @others_ranges = collect_unicode_set(mappings, 0x2120, 0x2840)
20
21
  end
21
22
 
22
23
  def contains_first_level_kanji?(string)
@@ -31,6 +32,30 @@ module JISX0208
31
32
  contains_first_level_kanji?(string) || contains_seconde_level_kanji?(string)
32
33
  end
33
34
 
35
+ def contains_jisx0208?(string)
36
+ contains_jisx0208_kanji?(string) || string.each_char.any? do |char|
37
+ @others_ranges.include?(char.ord)
38
+ end
39
+ end
40
+
41
+ def only_first_level_kanji?(string)
42
+ string.each_char.all? { |char| @first_level_ranges.include?(char.ord) }
43
+ end
44
+
45
+ def only_second_level_kanji?(string)
46
+ string.each_char.all? { |char| @second_level_ranges.include?(char.ord) }
47
+ end
48
+
49
+ def only_jisx0208_kanji?(string)
50
+ jisx0208 = @first_level_ranges + @second_level_ranges
51
+ string.each_char.all? { |char| jisx0208.include?(char.ord) }
52
+ end
53
+
54
+ def only_jisx0208?(string)
55
+ jisx0208 = @first_level_ranges + @second_level_ranges + @others_ranges
56
+ string.each_char.all? { |char| jisx0208.include?(char.ord) }
57
+ end
58
+
34
59
  private
35
60
 
36
61
  def collect_unicode_set(mappings, jisx_start, jisx_end)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Jisx0208
4
- VERSION = "0.1.1"
4
+ VERSION = "0.3.0"
5
5
  end
data/lib/jisx0208.rb CHANGED
@@ -20,5 +20,25 @@ module JISX0208
20
20
  def contains_jisx0208_kanji?(string)
21
21
  @processor.contains_jisx0208_kanji?(string)
22
22
  end
23
+
24
+ def only_first_level_kanji?(string)
25
+ @processor.only_first_level_kanji?(string)
26
+ end
27
+
28
+ def only_second_level_kanji?(string)
29
+ @processor.only_second_level_kanji?(string)
30
+ end
31
+
32
+ def only_jisx0208_kanji?(string)
33
+ @processor.only_jisx0208_kanji?(string)
34
+ end
35
+
36
+ def contains_jisx0208?(string)
37
+ @processor.contains_jisx0208?(string)
38
+ end
39
+
40
+ def only_jisx0208?(string)
41
+ @processor.only_jisx0208?(string)
42
+ end
23
43
  end
24
44
  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.1
4
+ version: 0.3.0
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-19 00:00:00.000000000 Z
11
+ date: 2024-11-20 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:
@@ -21,6 +21,7 @@ files:
21
21
  - LICENSE
22
22
  - README.md
23
23
  - Rakefile
24
+ - bump_new_version.sh
24
25
  - data/JIS0208.TXT
25
26
  - lib/jisx0208.rb
26
27
  - lib/jisx0208/processor.rb