itsuka 0.1.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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: bb73113a7767f456cca77a0ce32e39a426789879b40dc6ceecf4d1600a78e86d
4
+ data.tar.gz: d975bdf4d2f78bd3686bdf3f74e5d8aaa9e31e2067a2ceaa6e1ecf353e821319
5
+ SHA512:
6
+ metadata.gz: 7a215e0e3c1c82f08763c8a43fab0e84161ca225c7f4bbabd81b742d022eaf82d69116e75e74634787f2927e97d3c2488cd955989639ad20a082603837f6e4bf
7
+ data.tar.gz: 0f863daa24a02fa2b314cf7bf7aa0972766c6e82ba4082dcdbdca706921ad1783ae830e062ec5f8bad3a0223dbe97d1a27e2ed3f428a9177672d3c0b3190ada5
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
data/.rubocop.yml ADDED
@@ -0,0 +1,4 @@
1
+ inherit_from: .rubocop_todo.yml
2
+
3
+ AllCops:
4
+ TargetRubyVersion: 3.1
data/.rubocop_todo.yml ADDED
@@ -0,0 +1,18 @@
1
+ # This configuration was generated by
2
+ # `rubocop --auto-gen-config`
3
+ # on 2025-03-29 08:40:37 UTC using RuboCop version 1.75.1.
4
+ # The point is for the user to remove these configuration records
5
+ # one by one as the offenses are removed from the code base.
6
+ # Note that changes in the inspected code, or installation of new
7
+ # versions of RuboCop, may require this file to be generated again.
8
+
9
+ # Offense count: 1
10
+ # Configuration parameters: CountComments, CountAsOne, AllowedMethods, AllowedPatterns.
11
+ Metrics/MethodLength:
12
+ Max: 16
13
+
14
+ # Offense count: 1
15
+ # Configuration parameters: AllowedConstants.
16
+ Style/Documentation:
17
+ Exclude:
18
+ - 'lib/itsuka.rb'
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2025 junohm410
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,39 @@
1
+ # Itsuka
2
+
3
+ 日本語の自然言語で書かれた日付を`Date`オブジェクトに変換する Ruby gem です。
4
+
5
+ ## インストール方法
6
+
7
+ Gemfile に以下を追記して、`bundle install`してください。
8
+
9
+ ```ruby
10
+ gem 'itsuka'
11
+ ```
12
+
13
+ もしくは、`gem`コマンドで直接インストールしてください。
14
+
15
+ ```bash
16
+ gem install itsuka
17
+ ```
18
+
19
+ ## 使い方
20
+
21
+ ```ruby
22
+ require 'itsuka'
23
+
24
+ Date.today #=> #<Date: 2025-03-29 ...>
25
+
26
+ Itsuka.parse('今日') #=> #<Date: 2024-03-29 ...>
27
+ Itsuka.parse('明日') #=> #<Date: 2024-03-30 ...>
28
+ Itsuka.parse('3日後') #=> #<Date: 2024-04-01 ...>
29
+ Itsuka.parse('2日前') #=> #<Date: 2024-03-27 ...>
30
+ ```
31
+
32
+ ## 対応済みの表現
33
+
34
+ - 今日・明日・昨日
35
+ - n 日後・n 日前
36
+
37
+ ## ライセンス
38
+
39
+ MIT License
data/Rakefile ADDED
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'bundler/gem_tasks'
4
+ require 'rspec/core/rake_task'
5
+
6
+ RSpec::Core::RakeTask.new(:spec)
7
+
8
+ require 'rubocop/rake_task'
9
+
10
+ RuboCop::RakeTask.new
11
+
12
+ task default: %i[spec rubocop]
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Itsuka
4
+ VERSION = '0.1.0'
5
+ end
data/lib/itsuka.rb ADDED
@@ -0,0 +1,21 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'itsuka/version'
4
+ require 'date'
5
+
6
+ module Itsuka
7
+ def self.parse(date_str)
8
+ case date_str
9
+ when '今日'
10
+ Date.today
11
+ when '明日'
12
+ Date.today + 1
13
+ when '昨日'
14
+ Date.today - 1
15
+ when /\A(\d+)日後\z/
16
+ Date.today + Regexp.last_match(1).to_i
17
+ when /\A(?<day>\d+)日前\z/
18
+ Date.today - Regexp.last_match(1).to_i
19
+ end
20
+ end
21
+ end
metadata ADDED
@@ -0,0 +1,96 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: itsuka
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - junohm410
8
+ bindir: exe
9
+ cert_chain: []
10
+ date: 2025-03-29 00:00:00.000000000 Z
11
+ dependencies:
12
+ - !ruby/object:Gem::Dependency
13
+ name: rake
14
+ requirement: !ruby/object:Gem::Requirement
15
+ requirements:
16
+ - - "~>"
17
+ - !ruby/object:Gem::Version
18
+ version: '13.0'
19
+ type: :development
20
+ prerelease: false
21
+ version_requirements: !ruby/object:Gem::Requirement
22
+ requirements:
23
+ - - "~>"
24
+ - !ruby/object:Gem::Version
25
+ version: '13.0'
26
+ - !ruby/object:Gem::Dependency
27
+ name: rspec
28
+ requirement: !ruby/object:Gem::Requirement
29
+ requirements:
30
+ - - "~>"
31
+ - !ruby/object:Gem::Version
32
+ version: '3.0'
33
+ type: :development
34
+ prerelease: false
35
+ version_requirements: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - "~>"
38
+ - !ruby/object:Gem::Version
39
+ version: '3.0'
40
+ - !ruby/object:Gem::Dependency
41
+ name: rubocop
42
+ requirement: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - "~>"
45
+ - !ruby/object:Gem::Version
46
+ version: '1.21'
47
+ type: :development
48
+ prerelease: false
49
+ version_requirements: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - "~>"
52
+ - !ruby/object:Gem::Version
53
+ version: '1.21'
54
+ description: |2
55
+ 'Itsuka converts natural Japanese date expressions,
56
+ such as "今日" (today), "明日" (tomorrow), or "3日後" (in 3 days),
57
+ into Ruby Date objects.'
58
+ email:
59
+ - junohm410@gmail.com
60
+ executables: []
61
+ extensions: []
62
+ extra_rdoc_files: []
63
+ files:
64
+ - ".rspec"
65
+ - ".rubocop.yml"
66
+ - ".rubocop_todo.yml"
67
+ - LICENSE.txt
68
+ - README.md
69
+ - Rakefile
70
+ - lib/itsuka.rb
71
+ - lib/itsuka/version.rb
72
+ homepage: https://github.com/junohm410/itsuka
73
+ licenses:
74
+ - MIT
75
+ metadata:
76
+ allowed_push_host: https://rubygems.org
77
+ homepage_uri: https://github.com/junohm410/itsuka
78
+ source_code_uri: https://github.com/junohm410/itsuka
79
+ rdoc_options: []
80
+ require_paths:
81
+ - lib
82
+ required_ruby_version: !ruby/object:Gem::Requirement
83
+ requirements:
84
+ - - ">="
85
+ - !ruby/object:Gem::Version
86
+ version: 3.1.0
87
+ required_rubygems_version: !ruby/object:Gem::Requirement
88
+ requirements:
89
+ - - ">="
90
+ - !ruby/object:Gem::Version
91
+ version: '0'
92
+ requirements: []
93
+ rubygems_version: 3.6.2
94
+ specification_version: 4
95
+ summary: A Ruby gem to parse natural Japanese date expressions into Date objects.
96
+ test_files: []