jisx0208 0.1.1 → 0.3.0
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 +5 -0
- data/bump_new_version.sh +38 -0
- data/lib/jisx0208/processor.rb +25 -0
- data/lib/jisx0208/version.rb +1 -1
- data/lib/jisx0208.rb +20 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: df31e4cd2133bcd6d29df8dc276a6d91416830a584562e481ec7bf467317a3da
|
4
|
+
data.tar.gz: 403efbc30320410819b124682aa52cf74af5c39c5e8c9558514d9666b5ef0160
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
```
|
data/bump_new_version.sh
ADDED
@@ -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
|
data/lib/jisx0208/processor.rb
CHANGED
@@ -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)
|
data/lib/jisx0208/version.rb
CHANGED
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.
|
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-
|
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
|