miyabi 0.3.1 → 0.4.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1103a78e1af969ad03b878f820fb9a7f0d9363dbe29aff68b7540dc1e7ff3949
4
- data.tar.gz: 16371b54fef10e351692081b844b5d03c527526acd876f6a9d80afa36d20ba25
3
+ metadata.gz: bb04c2510122b519fffedbe7da7a7bbc231fe2691dc25b72b6892ecbb3cccdd4
4
+ data.tar.gz: 7c7ccea8e988db4b4e8e634b559d3143ced7b3722bc4c912c5ea98234fdb0839
5
5
  SHA512:
6
- metadata.gz: b9141239952ac1a220b140a480c4a600a6ced23568128468384ca6a1be12fbcf02987243ca7b96268925b44588220504a056e4261b1a573dd78a47ee675d2810
7
- data.tar.gz: db3caac3764db0c5bc5811d667a893f2a529a31c40f1aeef71c996c489f636ea0767d473e20b84df31ffae875df3f0b802e5813e12b4a9f43c5ff241c63a5cae
6
+ metadata.gz: d75a4b99bba5e2e6a0dd267a94dc3a36dd0e0fac3ec16afcd43cb35f61341c9628e35448acba8bc099d96bce32a6ef7355cc623a57cce80c30c9ef8da5c19240
7
+ data.tar.gz: c521af659f19b5a73b84308f65f9ce15b38b29093c986d8f395dc59157bad7ed8926752850c7f67b279038fdb83962ac6aa8a1e36e7e2691eab79acbf2aee6d0
@@ -0,0 +1,31 @@
1
+ # https://guides.rubygems.org/trusted-publishing/releasing-gems/
2
+ name: Release
3
+ on:
4
+ push:
5
+ tags:
6
+ - '*'
7
+ workflow_dispatch:
8
+ jobs:
9
+ push:
10
+ name: Push gem to RubyGems.org
11
+ runs-on: ubuntu-latest
12
+
13
+ permissions:
14
+ id-token: write # IMPORTANT: this permission is mandatory for trusted publishing
15
+ contents: write # IMPORTANT: this permission is required for `rake release` to push the release tag
16
+
17
+ environment: release
18
+
19
+ steps:
20
+ # Set up
21
+ - uses: actions/checkout@v6
22
+ with:
23
+ persist-credentials: false
24
+ - name: Set up Ruby
25
+ uses: ruby/setup-ruby@v1
26
+ with:
27
+ bundler-cache: true
28
+ ruby-version: ruby
29
+
30
+ # Release
31
+ - uses: rubygems/release-gem@v1
data/.rubocop.yml CHANGED
@@ -3,6 +3,7 @@ inherit_from: .rubocop_todo.yml
3
3
  AllCops:
4
4
  NewCops: enable
5
5
  TargetRubyVersion: 3.0
6
+ DisabledByDefault: true
6
7
 
7
8
  Style/FrozenStringLiteralComment:
8
9
  Enabled: true
data/.rubocop_todo.yml CHANGED
@@ -1,28 +1,7 @@
1
1
  # This configuration was generated by
2
2
  # `rubocop --auto-gen-config`
3
- # on 2024-11-13 10:06:34 UTC using RuboCop version 1.48.1.
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,19 @@ 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.1
13
+
14
+ Maintenance release. Mainly for enabling trusted publishing.
15
+
16
+ ## 0.4.0
17
+
18
+ Make `to_kanhira` method optional. If you still need this, install Nokogiri gem and:
19
+
20
+ ```ruby
21
+ require "miyabi/format_string_online"
22
+ String.include(Miyabi::FormatStringOnline)
23
+ ```
24
+
12
25
  ## 0.3.1
13
26
 
14
27
  This is a maintenance release.
data/LICENSE.txt CHANGED
@@ -1,6 +1,7 @@
1
1
  The MIT License (MIT)
2
2
 
3
3
  Copyright (c) 2017 Hironori Akaishi
4
+ Copyright (c) 2023, 2024, 2025 gemmaro
4
5
 
5
6
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
7
  of this software and associated documentation files (the "Software"), to deal
data/README.md CHANGED
@@ -45,7 +45,7 @@ require 'miyabi'
45
45
 
46
46
  ## Development
47
47
 
48
- 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.
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,12 +53,15 @@ 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 GitHub at https://github.com/h-akaishi/miyabi. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
56
+ Bug reports and pull requests are welcome on
57
+ [GitHub](https://github.com/gemmaro/miyabi).
57
58
 
58
59
  ## License
59
60
 
60
61
  The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
61
62
 
62
- ## Code of Conduct
63
+ ## Links and Related Works
63
64
 
64
- Everyone interacting in the Miyabi project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/h-akaishi/miyabi/blob/master/CODE_OF_CONDUCT.md).
65
+ This work has been initially created by isy at [isy/miyabi](https://github.com/isy/miyabi).
66
+
67
+ There are other similar libraries such as [jaconv](https://github.com/ikegami-yukino/jaconv) (Python library).
data/TODO.org ADDED
@@ -0,0 +1,2 @@
1
+ * TODO jaconvを参考にする
2
+ https://github.com/ikegami-yukino/jaconv/blob/b82abca9d8e29c3cad33825926900bea6c7e170f/test_jaconv.py#L44
@@ -1,30 +1,38 @@
1
- require 'net/http'
2
- require 'nokogiri'
1
+ require "set"
3
2
 
4
3
  module Miyabi
5
4
  module FormatString
6
- def to_kanhira
7
- http = Net::HTTP.new('yomikatawa.com', 443)
8
- http.use_ssl = true
9
- path = File.join('/kanji', self)
10
- html = http.get(path).body
11
- Nokogiri::HTML(html).search('#yomikata tbody tr td').first.inner_text
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
- def to_kana
15
- tr('ぁ-ん', 'ァ-ン')
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 to_katakana to_kana
25
+ alias to_hira katakana_to_hiragana
26
+ alias to_hiragana katakana_to_hiragana
19
27
 
20
- def to_hira
21
- tr('ァ-ン', 'ぁ-ん')
22
- end
28
+ TR_HIRAGANA = 'ぁ-んゔゕゖゝゞ'
29
+ private_constant :TR_HIRAGANA
23
30
 
24
- alias to_hiragana to_hira
31
+ TR_KATAKANA = 'ァ-ンヴヵヶヽヾ'
32
+ private_constant :TR_KATAKANA
25
33
 
26
34
  def to_roman
27
- s = to_kana
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
@@ -1,3 +1,3 @@
1
1
  module Miyabi
2
- VERSION = '0.3.1'
2
+ VERSION = '0.4.1'
3
3
  end
data/manifest.scm CHANGED
@@ -1,11 +1,5 @@
1
- (use-modules (guix packages)
2
- (gnu packages ruby))
3
-
4
- (define-public ruby-nokogiri'
5
- (package
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.3 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/isy/miyabi'
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,7 @@ Gem::Specification.new do |spec|
20
20
  spec.require_paths = ['lib']
21
21
 
22
22
  spec.required_ruby_version = '>= 3.0'
23
- spec.add_dependency 'nokogiri', '~> 1.14'
23
+
24
24
  spec.add_development_dependency 'rspec', '~> 3.12'
25
+ spec.add_development_dependency 'rake'
25
26
  end
metadata CHANGED
@@ -1,79 +1,78 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: miyabi
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Hironori Akaishi
8
- autorequire:
8
+ - gemmaro
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-11-13 00:00:00.000000000 Z
11
+ date: 1980-01-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: nokogiri
14
+ name: rspec
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '1.14'
20
- type: :runtime
19
+ version: '3.12'
20
+ type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '1.14'
26
+ version: '3.12'
27
27
  - !ruby/object:Gem::Dependency
28
- name: rspec
28
+ name: rake
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - "~>"
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
- version: '3.12'
33
+ version: '0'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - "~>"
38
+ - - ">="
39
39
  - !ruby/object:Gem::Version
40
- version: '3.12'
40
+ version: '0'
41
41
  description: Format Japanese characters
42
42
  email:
43
43
  - ah.gm3622@gmail.com
44
+ - gemmaro.dev@gmail.com
44
45
  executables: []
45
46
  extensions: []
46
47
  extra_rdoc_files: []
47
48
  files:
48
49
  - ".envrc"
50
+ - ".github/workflows/release.yaml"
49
51
  - ".gitignore"
50
52
  - ".rspec"
51
53
  - ".rubocop.yml"
52
54
  - ".rubocop_todo.yml"
53
- - ".travis.yml"
54
55
  - CHANGELOG.md
55
- - CODE_OF_CONDUCT.md
56
56
  - Gemfile
57
57
  - LICENSE.txt
58
58
  - README.md
59
59
  - Rakefile
60
- - bin/console
61
- - bin/setup
60
+ - TODO.org
62
61
  - lib/check.rb
63
62
  - lib/format.rb
64
63
  - lib/miyabi.rb
65
64
  - lib/miyabi/check_string.rb
66
65
  - lib/miyabi/format_string.rb
66
+ - lib/miyabi/format_string_online.rb
67
67
  - lib/miyabi/version.rb
68
68
  - manifest.scm
69
69
  - miyabi.gemspec
70
70
  - sig/miyabi.rbs
71
- homepage: https://github.com/isy/miyabi
71
+ homepage: https://github.com/gemmaro/miyabi
72
72
  licenses:
73
73
  - MIT
74
74
  metadata:
75
75
  rubygems_mfa_required: 'true'
76
- post_install_message:
77
76
  rdoc_options: []
78
77
  require_paths:
79
78
  - lib
@@ -88,8 +87,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
88
87
  - !ruby/object:Gem::Version
89
88
  version: '0'
90
89
  requirements: []
91
- rubygems_version: 3.4.19
92
- signing_key:
90
+ rubygems_version: 4.0.6
93
91
  specification_version: 4
94
92
  summary: kana,hira,kanji formatter
95
93
  test_files: []
data/.travis.yml DELETED
@@ -1,5 +0,0 @@
1
- sudo: false
2
- language: ruby
3
- rvm:
4
- - 2.3.4
5
- before_install: gem install bundler -v 1.15.4
data/CODE_OF_CONDUCT.md DELETED
@@ -1,74 +0,0 @@
1
- # Contributor Covenant Code of Conduct
2
-
3
- ## Our Pledge
4
-
5
- In the interest of fostering an open and welcoming environment, we as
6
- contributors and maintainers pledge to making participation in our project and
7
- our community a harassment-free experience for everyone, regardless of age, body
8
- size, disability, ethnicity, gender identity and expression, level of experience,
9
- nationality, personal appearance, race, religion, or sexual identity and
10
- orientation.
11
-
12
- ## Our Standards
13
-
14
- Examples of behavior that contributes to creating a positive environment
15
- include:
16
-
17
- * Using welcoming and inclusive language
18
- * Being respectful of differing viewpoints and experiences
19
- * Gracefully accepting constructive criticism
20
- * Focusing on what is best for the community
21
- * Showing empathy towards other community members
22
-
23
- Examples of unacceptable behavior by participants include:
24
-
25
- * The use of sexualized language or imagery and unwelcome sexual attention or
26
- advances
27
- * Trolling, insulting/derogatory comments, and personal or political attacks
28
- * Public or private harassment
29
- * Publishing others' private information, such as a physical or electronic
30
- address, without explicit permission
31
- * Other conduct which could reasonably be considered inappropriate in a
32
- professional setting
33
-
34
- ## Our Responsibilities
35
-
36
- Project maintainers are responsible for clarifying the standards of acceptable
37
- behavior and are expected to take appropriate and fair corrective action in
38
- response to any instances of unacceptable behavior.
39
-
40
- Project maintainers have the right and responsibility to remove, edit, or
41
- reject comments, commits, code, wiki edits, issues, and other contributions
42
- that are not aligned to this Code of Conduct, or to ban temporarily or
43
- permanently any contributor for other behaviors that they deem inappropriate,
44
- threatening, offensive, or harmful.
45
-
46
- ## Scope
47
-
48
- This Code of Conduct applies both within project spaces and in public spaces
49
- when an individual is representing the project or its community. Examples of
50
- representing a project or community include using an official project e-mail
51
- address, posting via an official social media account, or acting as an appointed
52
- representative at an online or offline event. Representation of a project may be
53
- further defined and clarified by project maintainers.
54
-
55
- ## Enforcement
56
-
57
- Instances of abusive, harassing, or otherwise unacceptable behavior may be
58
- reported by contacting the project team at ah.gm3622@gmail.com. All
59
- complaints will be reviewed and investigated and will result in a response that
60
- is deemed necessary and appropriate to the circumstances. The project team is
61
- obligated to maintain confidentiality with regard to the reporter of an incident.
62
- Further details of specific enforcement policies may be posted separately.
63
-
64
- Project maintainers who do not follow or enforce the Code of Conduct in good
65
- faith may face temporary or permanent repercussions as determined by other
66
- members of the project's leadership.
67
-
68
- ## Attribution
69
-
70
- This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71
- available at [http://contributor-covenant.org/version/1/4][version]
72
-
73
- [homepage]: http://contributor-covenant.org
74
- [version]: http://contributor-covenant.org/version/1/4/
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__)
data/bin/setup DELETED
@@ -1,8 +0,0 @@
1
- #!/usr/bin/env bash
2
- set -euo pipefail
3
- IFS=$'\n\t'
4
- set -vx
5
-
6
- bundle install
7
-
8
- # Do any other automated setup that you need to do here