nth_weekday 0.1.0 → 0.1.2
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 +77 -4
- data/Rakefile +4 -2
- data/VERSION +1 -1
- data/examples/basic_usage.rb +2 -0
- data/examples/simple_demo.rb +3 -2
- data/lib/nth_weekday.rb +18 -16
- metadata +4 -49
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 69519a49798e6edd6879ae4f8ce20ebec5f09ed7761380d592b6770ed40d13a9
|
|
4
|
+
data.tar.gz: eb41eb2c8e89dd6689b04b607a000e8e0c8ef93886372a721f8e47987b7e5ade
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 40caf4872dc1ef615b8667a6c415aedcc46eec7975b80784d73d09ebbcabd1609dc6c9690b763e80cbbc8c74400d010fec2b2c7277791b50f9ad9f0bb1a1aad9
|
|
7
|
+
data.tar.gz: 95680caaea53204cb06df51c79b7484d3b3aa539355e01dcdf568754a4409ff0aa92f20f4c61552dfec97b68fb9eabb63ef86e5729fd4d1e5afc3d2caeee87d5
|
data/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# nth_weekday
|
|
2
2
|
|
|
3
|
-
[](https://rubygems.org/gems/nth_weekday)
|
|
4
4
|
[](https://github.com/yusukehigasa/nth_weekday/actions)
|
|
5
5
|
|
|
6
6
|
---
|
|
@@ -19,7 +19,6 @@
|
|
|
19
19
|
- ✅ Rails / Sinatra / CLI / バッチ対応
|
|
20
20
|
- 🧪 テスト済み、CI/CD導入しやすい構成
|
|
21
21
|
|
|
22
|
-
|
|
23
22
|
## 💎 Installation / インストール
|
|
24
23
|
|
|
25
24
|
```bash
|
|
@@ -30,6 +29,11 @@ gem 'nth_weekday'
|
|
|
30
29
|
gem install nth_weekday
|
|
31
30
|
```
|
|
32
31
|
|
|
32
|
+
## 💻 Requirements / 動作環境
|
|
33
|
+
|
|
34
|
+
- Ruby 3.3.0以上
|
|
35
|
+
- CI verified on Ruby 3.3.0 and Ruby 4.0.1
|
|
36
|
+
|
|
33
37
|
## 🚀 Usage / 使い方
|
|
34
38
|
|
|
35
39
|
```ruby
|
|
@@ -50,9 +54,18 @@ NthWeekday.get(year: 2025, month: 12, weekday: :fr, nth: -1)
|
|
|
50
54
|
|--------------|--------|-------------------------------------------------------|
|
|
51
55
|
| `year` | Integer| 対象年(例: 2025) |
|
|
52
56
|
| `month` | Integer| 対象月(1〜12) |
|
|
53
|
-
| `weekday` | Symbol |
|
|
57
|
+
| `weekday` | Symbol | 対象曜日(`:su`, `:mo`, `:tu`, `:we`, `:th`, `:fr`, `:sa`) |
|
|
54
58
|
| `nth` | Integer| 第n◯曜日。1〜5、または `-1` で「最後の◯曜日」を指定 |
|
|
55
59
|
|
|
60
|
+
### 曜日シンボル一覧
|
|
61
|
+
- `:su` - 日曜日 (Sunday)
|
|
62
|
+
- `:mo` - 月曜日 (Monday)
|
|
63
|
+
- `:tu` - 火曜日 (Tuesday)
|
|
64
|
+
- `:we` - 水曜日 (Wednesday)
|
|
65
|
+
- `:th` - 木曜日 (Thursday)
|
|
66
|
+
- `:fr` - 金曜日 (Friday)
|
|
67
|
+
- `:sa` - 土曜日 (Saturday)
|
|
68
|
+
|
|
56
69
|
## 🧪 Example: 2025年の各月の第3水曜日を取得
|
|
57
70
|
|
|
58
71
|
```ruby
|
|
@@ -68,9 +81,68 @@ end
|
|
|
68
81
|
git clone https://github.com/yusukehigasa/nth_weekday.git
|
|
69
82
|
cd nth_weekday
|
|
70
83
|
bundle install
|
|
71
|
-
rspec
|
|
84
|
+
bundle exec rspec # テスト実行
|
|
85
|
+
bundle exec rubocop # コードスタイルチェック
|
|
72
86
|
```
|
|
73
87
|
|
|
88
|
+
このプロジェクトでは [RuboCop](https://rubocop.org/) を使用してコードスタイルを一貫して維持しています。コード変更時は `bundle exec rubocop` でスタイルチェックを実行してください。
|
|
89
|
+
|
|
90
|
+
エージェント運用時のルールは以下を参照してください。
|
|
91
|
+
|
|
92
|
+
## 🤖 AI / Agent Development Modes
|
|
93
|
+
|
|
94
|
+
このリポジトリは AI エージェントによる開発を前提に、2つのモードをサポートしています。
|
|
95
|
+
|
|
96
|
+
### 🧩 通常モード(Single Agent)
|
|
97
|
+
|
|
98
|
+
単一エージェントによる高速な実装。
|
|
99
|
+
|
|
100
|
+
**用途**
|
|
101
|
+
- 小規模修正
|
|
102
|
+
- 明確なタスク
|
|
103
|
+
|
|
104
|
+
---
|
|
105
|
+
|
|
106
|
+
### 🧠 オーケストレーターモード(Multi-Agent)
|
|
107
|
+
|
|
108
|
+
複数の役割エージェントによる段階的開発。
|
|
109
|
+
|
|
110
|
+
**フロー**
|
|
111
|
+
1. Issue
|
|
112
|
+
2. Plan
|
|
113
|
+
3. Implementation
|
|
114
|
+
4. Review
|
|
115
|
+
5. PR
|
|
116
|
+
|
|
117
|
+
**用途**
|
|
118
|
+
- 複雑な変更
|
|
119
|
+
- 設計が必要なタスク
|
|
120
|
+
|
|
121
|
+
## 🧭 Mode Selection
|
|
122
|
+
|
|
123
|
+
| ケース | モード |
|
|
124
|
+
| :-- |:-- |
|
|
125
|
+
| 小規模な変更・新規機能 | 通常 |
|
|
126
|
+
| 複雑な変更・大規模な新規機能 | オーケストレーター |
|
|
127
|
+
|
|
128
|
+
---
|
|
129
|
+
|
|
130
|
+
## 📚 Docs
|
|
131
|
+
|
|
132
|
+
- [AGENTS.md](./AGENTS.md)
|
|
133
|
+
- [CODING_RULES.md](./CODING_RULES.md)
|
|
134
|
+
- [HUMAN_IN_THE_LOOP.md](./HUMAN_IN_THE_LOOP.md)
|
|
135
|
+
|
|
136
|
+
## 👥 Contributing / 貢献
|
|
137
|
+
|
|
138
|
+
1. Fork the repository
|
|
139
|
+
2. Create your feature branch (`git checkout -b feature/amazing-feature`)
|
|
140
|
+
3. Commit your changes (`git commit -am 'Add some amazing feature'`)
|
|
141
|
+
4. Push to the branch (`git push origin feature/amazing-feature`)
|
|
142
|
+
5. Create a new Pull Request
|
|
143
|
+
|
|
144
|
+
バグ報告や機能要望は[GitHub Issues](https://github.com/yusukehigasa/nth_weekday/issues)にお願いします。
|
|
145
|
+
|
|
74
146
|
## 📄 License
|
|
75
147
|
|
|
76
148
|
- MIT License
|
|
@@ -83,3 +155,4 @@ rspec
|
|
|
83
155
|
|
|
84
156
|
- [RubyGems - nth_weekday](https://rubygems.org/gems/nth_weekday)
|
|
85
157
|
- [GitHub Repository](https://github.com/yusukehigasa/nth_weekday)
|
|
158
|
+
- [Changelog](https://github.com/yusukehigasa/nth_weekday/blob/main/CHANGELOG.md)
|
data/Rakefile
CHANGED
data/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
0.1.
|
|
1
|
+
0.1.2
|
data/examples/basic_usage.rb
CHANGED
data/examples/simple_demo.rb
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
#!/usr/bin/env ruby
|
|
2
|
+
# frozen_string_literal: true
|
|
2
3
|
|
|
3
4
|
require 'nth_weekday'
|
|
4
5
|
|
|
5
|
-
puts
|
|
6
|
-
puts
|
|
6
|
+
puts 'NthWeekday gem example'
|
|
7
|
+
puts '======================='
|
|
7
8
|
|
|
8
9
|
# 2025年5月の第2月曜日を取得
|
|
9
10
|
monday = NthWeekday.get(year: 2025, month: 5, weekday: :mo, nth: 2)
|
data/lib/nth_weekday.rb
CHANGED
|
@@ -1,16 +1,18 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
require 'date'
|
|
2
4
|
|
|
3
5
|
# NthWeekday module - Get specific weekdays (like 3rd Wednesday) from any year/month
|
|
4
6
|
module NthWeekday
|
|
5
7
|
# Mapping of weekday symbols to Date's wday values (0-6, Sunday is 0)
|
|
6
8
|
WEEKDAY_MAP = {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
9
|
+
su: 0, # Sunday
|
|
10
|
+
mo: 1, # Monday
|
|
11
|
+
tu: 2, # Tuesday
|
|
12
|
+
we: 3, # Wednesday
|
|
13
|
+
th: 4, # Thursday
|
|
14
|
+
fr: 5, # Friday
|
|
15
|
+
sa: 6 # Saturday
|
|
14
16
|
}.freeze
|
|
15
17
|
|
|
16
18
|
class << self
|
|
@@ -23,26 +25,26 @@ module NthWeekday
|
|
|
23
25
|
# @raise [ArgumentError] If parameters are invalid
|
|
24
26
|
def get(year:, month:, weekday:, nth:)
|
|
25
27
|
validate_params(year, month, weekday, nth)
|
|
26
|
-
|
|
28
|
+
|
|
27
29
|
wday = WEEKDAY_MAP[weekday.to_sym]
|
|
28
|
-
raise ArgumentError,
|
|
29
|
-
|
|
30
|
+
raise ArgumentError, 'Invalid weekday symbol' unless wday
|
|
31
|
+
|
|
30
32
|
first_day = Date.new(year, month, 1)
|
|
31
33
|
last_day = first_day.next_month.prev_day
|
|
32
|
-
|
|
34
|
+
|
|
33
35
|
days = (first_day..last_day).select { |date| date.wday == wday }
|
|
34
|
-
|
|
36
|
+
|
|
35
37
|
if nth == -1
|
|
36
38
|
days.last
|
|
37
39
|
else
|
|
38
40
|
days[nth - 1]
|
|
39
41
|
end
|
|
40
42
|
end
|
|
41
|
-
|
|
43
|
+
|
|
42
44
|
private
|
|
43
|
-
|
|
44
|
-
def validate_params(year, month,
|
|
45
|
-
raise ArgumentError, "Invalid year: #{year}" unless year.is_a?(Integer) && year
|
|
45
|
+
|
|
46
|
+
def validate_params(year, month, _weekday, nth)
|
|
47
|
+
raise ArgumentError, "Invalid year: #{year}" unless year.is_a?(Integer) && year.positive?
|
|
46
48
|
raise ArgumentError, "Invalid month: #{month}" unless month.is_a?(Integer) && month.between?(1, 12)
|
|
47
49
|
raise ArgumentError, "Invalid nth: #{nth}" unless nth.is_a?(Integer) && (nth.between?(1, 5) || nth == -1)
|
|
48
50
|
end
|
metadata
CHANGED
|
@@ -1,57 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: nth_weekday
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.1.
|
|
4
|
+
version: 0.1.2
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Yusuke Higasa
|
|
8
|
-
autorequire:
|
|
9
8
|
bindir: exe
|
|
10
9
|
cert_chain: []
|
|
11
|
-
date:
|
|
12
|
-
dependencies:
|
|
13
|
-
- !ruby/object:Gem::Dependency
|
|
14
|
-
name: bundler
|
|
15
|
-
requirement: !ruby/object:Gem::Requirement
|
|
16
|
-
requirements:
|
|
17
|
-
- - "~>"
|
|
18
|
-
- !ruby/object:Gem::Version
|
|
19
|
-
version: '2.0'
|
|
20
|
-
type: :development
|
|
21
|
-
prerelease: false
|
|
22
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
23
|
-
requirements:
|
|
24
|
-
- - "~>"
|
|
25
|
-
- !ruby/object:Gem::Version
|
|
26
|
-
version: '2.0'
|
|
27
|
-
- !ruby/object:Gem::Dependency
|
|
28
|
-
name: rake
|
|
29
|
-
requirement: !ruby/object:Gem::Requirement
|
|
30
|
-
requirements:
|
|
31
|
-
- - "~>"
|
|
32
|
-
- !ruby/object:Gem::Version
|
|
33
|
-
version: '13.0'
|
|
34
|
-
type: :development
|
|
35
|
-
prerelease: false
|
|
36
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
37
|
-
requirements:
|
|
38
|
-
- - "~>"
|
|
39
|
-
- !ruby/object:Gem::Version
|
|
40
|
-
version: '13.0'
|
|
41
|
-
- !ruby/object:Gem::Dependency
|
|
42
|
-
name: rspec
|
|
43
|
-
requirement: !ruby/object:Gem::Requirement
|
|
44
|
-
requirements:
|
|
45
|
-
- - "~>"
|
|
46
|
-
- !ruby/object:Gem::Version
|
|
47
|
-
version: '3.0'
|
|
48
|
-
type: :development
|
|
49
|
-
prerelease: false
|
|
50
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
51
|
-
requirements:
|
|
52
|
-
- - "~>"
|
|
53
|
-
- !ruby/object:Gem::Version
|
|
54
|
-
version: '3.0'
|
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
11
|
+
dependencies: []
|
|
55
12
|
description: A lightweight Ruby library to get dates like "3rd Wednesday" or "last
|
|
56
13
|
Friday" from any given year and month. Rails-compatible and dependency-free.
|
|
57
14
|
email:
|
|
@@ -76,7 +33,6 @@ metadata:
|
|
|
76
33
|
changelog_uri: https://github.com/yusukehigasa/nth_weekday/blob/main/CHANGELOG.md
|
|
77
34
|
bug_tracker_uri: https://github.com/yusukehigasa/nth_weekday/issues
|
|
78
35
|
rubygems_mfa_required: 'true'
|
|
79
|
-
post_install_message:
|
|
80
36
|
rdoc_options: []
|
|
81
37
|
require_paths:
|
|
82
38
|
- lib
|
|
@@ -91,8 +47,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
91
47
|
- !ruby/object:Gem::Version
|
|
92
48
|
version: '0'
|
|
93
49
|
requirements: []
|
|
94
|
-
rubygems_version:
|
|
95
|
-
signing_key:
|
|
50
|
+
rubygems_version: 4.0.3
|
|
96
51
|
specification_version: 4
|
|
97
52
|
summary: Get dates like "3rd Wednesday" or "last Friday" from any given year and month
|
|
98
53
|
test_files: []
|