miyabi 0.3.1 → 0.4.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/.rubocop.yml +1 -0
- data/.rubocop_todo.yml +1 -22
- data/CHANGELOG.md +9 -0
- data/LICENSE.txt +1 -0
- data/README.md +13 -3
- data/TODO.org +2 -0
- data/lib/miyabi/format_string.rb +36 -16
- data/lib/miyabi/format_string_online.rb +16 -0
- data/lib/miyabi/version.rb +1 -1
- data/manifest.scm +5 -11
- data/miyabi.gemspec +4 -4
- metadata +8 -21
- data/.travis.yml +0 -5
- data/bin/console +0 -14
- data/bin/setup +0 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: acad0974c78fe7cac1841d823ea439e671a69eb3dad915ef8adcfcfdd0f4fdda
|
4
|
+
data.tar.gz: 4bfc100695a36d2d22fc68295fa8cf0441d2e7bba02e2b300b06949e079ce87a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a19ce621920fa07fb6905f96891aeb26cb05987c8e5e6467042258ee94463fb9e6254b68fe7245d629a1ab7f929c1a711e446fbbf875574302e081fae0339e5f
|
7
|
+
data.tar.gz: b82e68c6a79e5fb0360abf73b1989bd95e012a6e6adac69411fa1672cac9709227b2e0a268e3c7319dc5406bb14da7bcafc7c47a7ded18658fa9a6df33c78e71
|
data/.rubocop.yml
CHANGED
data/.rubocop_todo.yml
CHANGED
@@ -1,28 +1,7 @@
|
|
1
1
|
# This configuration was generated by
|
2
2
|
# `rubocop --auto-gen-config`
|
3
|
-
# on
|
3
|
+
# on 2025-04-08 11:38:33 UTC using RuboCop version 1.48.1.
|
4
4
|
# The point is for the user to remove these configuration records
|
5
5
|
# one by one as the offenses are removed from the code base.
|
6
6
|
# Note that changes in the inspected code, or installation of new
|
7
7
|
# versions of RuboCop, may require this file to be generated again.
|
8
|
-
|
9
|
-
# Offense count: 5
|
10
|
-
# This cop supports safe autocorrection (--autocorrect).
|
11
|
-
Layout/EmptyLineAfterGuardClause:
|
12
|
-
Exclude:
|
13
|
-
- 'lib/miyabi/check_string.rb'
|
14
|
-
|
15
|
-
# Offense count: 1
|
16
|
-
# Configuration parameters: CountComments, CountAsOne.
|
17
|
-
Metrics/ModuleLength:
|
18
|
-
Max: 145
|
19
|
-
|
20
|
-
# Offense count: 3
|
21
|
-
# Configuration parameters: AllowedConstants.
|
22
|
-
Style/Documentation:
|
23
|
-
Exclude:
|
24
|
-
- 'spec/**/*'
|
25
|
-
- 'test/**/*'
|
26
|
-
- 'lib/miyabi.rb'
|
27
|
-
- 'lib/miyabi/check_string.rb'
|
28
|
-
- 'lib/miyabi/format_string.rb'
|
data/CHANGELOG.md
CHANGED
@@ -9,6 +9,15 @@ The format is based on [Keep a Changelog][cl], and this project adheres to [Sema
|
|
9
9
|
|
10
10
|
## [Unreleased]
|
11
11
|
|
12
|
+
## 0.4.0
|
13
|
+
|
14
|
+
Make `to_kanhira` method optional. If you still need this, install Nokogiri gem and:
|
15
|
+
|
16
|
+
```ruby
|
17
|
+
require "miyabi/format_string_online"
|
18
|
+
String.include(Miyabi::FormatStringOnline)
|
19
|
+
```
|
20
|
+
|
12
21
|
## 0.3.1
|
13
22
|
|
14
23
|
This is a maintenance release.
|
data/LICENSE.txt
CHANGED
data/README.md
CHANGED
@@ -45,7 +45,7 @@ require 'miyabi'
|
|
45
45
|
|
46
46
|
## Development
|
47
47
|
|
48
|
-
|
48
|
+
Run `rake spec` to run the tests.
|
49
49
|
|
50
50
|
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).
|
51
51
|
|
@@ -53,7 +53,11 @@ If you use the GNU Guix, `guix shell` to enter the development environment, then
|
|
53
53
|
|
54
54
|
## Contributing
|
55
55
|
|
56
|
-
Bug reports and pull requests are welcome on
|
56
|
+
Bug reports and pull requests are welcome on
|
57
|
+
[GitHub](https://github.com/gemmaro/miyabi). This project is intended to be a
|
58
|
+
safe, welcoming space for collaboration, and contributors are expected to
|
59
|
+
adhere to the [Contributor Covenant](http://contributor-covenant.org) code of
|
60
|
+
conduct.
|
57
61
|
|
58
62
|
## License
|
59
63
|
|
@@ -61,4 +65,10 @@ The gem is available as open source under the terms of the [MIT License](http://
|
|
61
65
|
|
62
66
|
## Code of Conduct
|
63
67
|
|
64
|
-
Everyone interacting in the Miyabi project’s codebases, issue trackers, chat
|
68
|
+
Everyone interacting in the Miyabi project’s codebases, issue trackers, chat
|
69
|
+
rooms and mailing lists is expected to follow the [code of
|
70
|
+
conduct](https://github.com/gemmaro/miyabi/blob/master/CODE_OF_CONDUCT.md).
|
71
|
+
|
72
|
+
## Related Works
|
73
|
+
|
74
|
+
[jaconv](https://github.com/ikegami-yukino/jaconv) (Python library)
|
data/TODO.org
ADDED
data/lib/miyabi/format_string.rb
CHANGED
@@ -1,30 +1,38 @@
|
|
1
|
-
require
|
2
|
-
require 'nokogiri'
|
1
|
+
require "set"
|
3
2
|
|
4
3
|
module Miyabi
|
5
4
|
module FormatString
|
6
|
-
def
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
5
|
+
def hiragana_to_katakana(ignore: nil)
|
6
|
+
ignored = ignore ? ignore.chars.to_set : Set[]
|
7
|
+
result = +""
|
8
|
+
chars.each do |char|
|
9
|
+
if ignored.member?(char)
|
10
|
+
result << char
|
11
|
+
else
|
12
|
+
result << char.tr(TR_HIRAGANA, TR_KATAKANA)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
result
|
12
16
|
end
|
13
17
|
|
14
|
-
|
15
|
-
|
18
|
+
alias to_kana hiragana_to_katakana
|
19
|
+
alias to_katakana hiragana_to_katakana
|
20
|
+
|
21
|
+
def katakana_to_hiragana
|
22
|
+
tr(TR_KATAKANA, TR_HIRAGANA)
|
16
23
|
end
|
17
24
|
|
18
|
-
alias
|
25
|
+
alias to_hira katakana_to_hiragana
|
26
|
+
alias to_hiragana katakana_to_hiragana
|
19
27
|
|
20
|
-
|
21
|
-
|
22
|
-
end
|
28
|
+
TR_HIRAGANA = 'ぁ-んゔゕゖゝゞ'
|
29
|
+
private_constant :TR_HIRAGANA
|
23
30
|
|
24
|
-
|
31
|
+
TR_KATAKANA = 'ァ-ンヴヵヶヽヾ'
|
32
|
+
private_constant :TR_KATAKANA
|
25
33
|
|
26
34
|
def to_roman
|
27
|
-
s =
|
35
|
+
s = hiragana_to_katakana
|
28
36
|
KATAKANA_TO_ROMAN_MAPPING.each do |kana, roman|
|
29
37
|
s.gsub!(kana, roman)
|
30
38
|
end
|
@@ -155,5 +163,17 @@ module Miyabi
|
|
155
163
|
}
|
156
164
|
|
157
165
|
private_constant :KATAKANA_TO_ROMAN_MAPPING
|
166
|
+
|
167
|
+
def roman_to_katakana
|
168
|
+
str = dup
|
169
|
+
ROMAN_TO_KATAKANA_MAPPING.each do |roman, kana|
|
170
|
+
str.gsub!(kana, roman)
|
171
|
+
end
|
172
|
+
str
|
173
|
+
end
|
174
|
+
|
175
|
+
ROMAN_TO_KATAKANA_MAPPING = KATAKANA_TO_ROMAN_MAPPING.invert
|
176
|
+
|
177
|
+
private_constant :ROMAN_TO_KATAKANA_MAPPING
|
158
178
|
end
|
159
179
|
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
require 'net/http'
|
2
|
+
require 'nokogiri'
|
3
|
+
|
4
|
+
module Miyabi::FormatStringOnline
|
5
|
+
def to_kanhira
|
6
|
+
http = Net::HTTP.new('yomikatawa.com', 443)
|
7
|
+
http.use_ssl = true
|
8
|
+
path = File.join('/kanji', self)
|
9
|
+
html = http.get(path).body
|
10
|
+
Nokogiri::HTML(html).search('#yomikata tbody tr td').first.inner_text
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
module Miyabi
|
15
|
+
deprecate_constant :FormatStringOnline
|
16
|
+
end
|
data/lib/miyabi/version.rb
CHANGED
data/manifest.scm
CHANGED
@@ -1,11 +1,5 @@
|
|
1
|
-
(use-modules (
|
2
|
-
(gnu packages ruby)
|
3
|
-
|
4
|
-
(
|
5
|
-
|
6
|
-
(inherit ruby-nokogiri)
|
7
|
-
(arguments
|
8
|
-
(cons* #:ruby ruby-3.2
|
9
|
-
(package-arguments ruby-nokogiri)))))
|
10
|
-
|
11
|
-
(packages->manifest (list ruby-nokogiri' ruby-rspec ruby-3.2 ruby-rubocop))
|
1
|
+
(use-modules (gnu packages ruby)
|
2
|
+
(gnu packages ruby-xyz)
|
3
|
+
(gnu packages ruby-check)
|
4
|
+
(guix profiles))
|
5
|
+
(packages->manifest (list ruby-nokogiri ruby-rspec ruby-3.1 ruby-rubocop))
|
data/miyabi.gemspec
CHANGED
@@ -5,12 +5,12 @@ require 'miyabi/version'
|
|
5
5
|
Gem::Specification.new do |spec|
|
6
6
|
spec.name = 'miyabi'
|
7
7
|
spec.version = Miyabi::VERSION
|
8
|
-
spec.authors = ['Hironori Akaishi']
|
9
|
-
spec.email = ['ah.gm3622@gmail.com']
|
8
|
+
spec.authors = ['Hironori Akaishi', 'gemmaro']
|
9
|
+
spec.email = ['ah.gm3622@gmail.com', 'gemmaro.dev@gmail.com']
|
10
10
|
|
11
11
|
spec.summary = 'kana,hira,kanji formatter'
|
12
12
|
spec.description = 'Format Japanese characters'
|
13
|
-
spec.homepage = 'https://github.com/
|
13
|
+
spec.homepage = 'https://github.com/gemmaro/miyabi'
|
14
14
|
spec.license = 'MIT'
|
15
15
|
spec.metadata['rubygems_mfa_required'] = 'true'
|
16
16
|
|
@@ -20,6 +20,6 @@ Gem::Specification.new do |spec|
|
|
20
20
|
spec.require_paths = ['lib']
|
21
21
|
|
22
22
|
spec.required_ruby_version = '>= 3.0'
|
23
|
-
|
23
|
+
|
24
24
|
spec.add_development_dependency 'rspec', '~> 3.12'
|
25
25
|
end
|
metadata
CHANGED
@@ -1,29 +1,16 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: miyabi
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Hironori Akaishi
|
8
|
+
- gemmaro
|
8
9
|
autorequire:
|
9
10
|
bindir: bin
|
10
11
|
cert_chain: []
|
11
|
-
date:
|
12
|
+
date: 2025-07-21 00:00:00.000000000 Z
|
12
13
|
dependencies:
|
13
|
-
- !ruby/object:Gem::Dependency
|
14
|
-
name: nokogiri
|
15
|
-
requirement: !ruby/object:Gem::Requirement
|
16
|
-
requirements:
|
17
|
-
- - "~>"
|
18
|
-
- !ruby/object:Gem::Version
|
19
|
-
version: '1.14'
|
20
|
-
type: :runtime
|
21
|
-
prerelease: false
|
22
|
-
version_requirements: !ruby/object:Gem::Requirement
|
23
|
-
requirements:
|
24
|
-
- - "~>"
|
25
|
-
- !ruby/object:Gem::Version
|
26
|
-
version: '1.14'
|
27
14
|
- !ruby/object:Gem::Dependency
|
28
15
|
name: rspec
|
29
16
|
requirement: !ruby/object:Gem::Requirement
|
@@ -41,6 +28,7 @@ dependencies:
|
|
41
28
|
description: Format Japanese characters
|
42
29
|
email:
|
43
30
|
- ah.gm3622@gmail.com
|
31
|
+
- gemmaro.dev@gmail.com
|
44
32
|
executables: []
|
45
33
|
extensions: []
|
46
34
|
extra_rdoc_files: []
|
@@ -50,25 +38,24 @@ files:
|
|
50
38
|
- ".rspec"
|
51
39
|
- ".rubocop.yml"
|
52
40
|
- ".rubocop_todo.yml"
|
53
|
-
- ".travis.yml"
|
54
41
|
- CHANGELOG.md
|
55
42
|
- CODE_OF_CONDUCT.md
|
56
43
|
- Gemfile
|
57
44
|
- LICENSE.txt
|
58
45
|
- README.md
|
59
46
|
- Rakefile
|
60
|
-
-
|
61
|
-
- bin/setup
|
47
|
+
- TODO.org
|
62
48
|
- lib/check.rb
|
63
49
|
- lib/format.rb
|
64
50
|
- lib/miyabi.rb
|
65
51
|
- lib/miyabi/check_string.rb
|
66
52
|
- lib/miyabi/format_string.rb
|
53
|
+
- lib/miyabi/format_string_online.rb
|
67
54
|
- lib/miyabi/version.rb
|
68
55
|
- manifest.scm
|
69
56
|
- miyabi.gemspec
|
70
57
|
- sig/miyabi.rbs
|
71
|
-
homepage: https://github.com/
|
58
|
+
homepage: https://github.com/gemmaro/miyabi
|
72
59
|
licenses:
|
73
60
|
- MIT
|
74
61
|
metadata:
|
@@ -88,7 +75,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
88
75
|
- !ruby/object:Gem::Version
|
89
76
|
version: '0'
|
90
77
|
requirements: []
|
91
|
-
rubygems_version: 3.
|
78
|
+
rubygems_version: 3.3.27
|
92
79
|
signing_key:
|
93
80
|
specification_version: 4
|
94
81
|
summary: kana,hira,kanji formatter
|
data/.travis.yml
DELETED
data/bin/console
DELETED
@@ -1,14 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
require 'bundler/setup'
|
4
|
-
require 'miyabi'
|
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(__FILE__)
|