waaah 0.1.1 → 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.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/lib/waaah/cli.rb +40 -31
  3. data/lib/waaah/version.rb +1 -1
  4. metadata +3 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e9cecb7466ed50c96de2fb46c551c54afa8d7c878e2bc40c58e0a3810840779a
4
- data.tar.gz: e61af3f2f9210986745862551848cce7187347520a5912c333a5a9229d40ba1a
3
+ metadata.gz: 00d4ee490e420882000aeb95d4f69fd2d0f1e7556edd424be259021fd1c1c1e4
4
+ data.tar.gz: ddf385283fadafb0f2177d62a0de646eb96406a1c90f892a900afa34ffe0b670
5
5
  SHA512:
6
- metadata.gz: 412eb192f7721af3446195bde3ac11c235acfe544dbf78061f8b785fbf8fff358752b5de2876cda02fe71be46a67c0a5697eb76c5a97a2269eb67efcd7c66b11
7
- data.tar.gz: c08400ac2492bc7d629dd39522a38d2c92c8befb576bf68f5872772545d68072608b2b2ad457072bcc33026314009b8863970667bdad3e6b4ba960faf6de13f5
6
+ metadata.gz: fd508211d174d9715f19a02ed70bf694b8e94ca1bf6c252f2b2ed7ae750090e81a513087aee4a04b51b9fe2be19ea650f6ec409ba6481c3c85f72e0414915a19
7
+ data.tar.gz: 636095d17616e9f9d43375498a9c53ed06a06c9aeb86cb7b0da19861b69230053328a39187c32d43d19600c6223f7e454f5f464721fd0b78ad3318e7561d96c0
data/lib/waaah/cli.rb CHANGED
@@ -3,45 +3,54 @@ require 'date'
3
3
 
4
4
  module Waaah
5
5
  class CLI
6
- def self.run(argv)
7
- options = {}
6
+ class << self
7
+ def run(argv)
8
+ options = {}
8
9
 
9
- OptionParser.new do |opts|
10
- opts.on('-h' '--help', 'Command execution example: waaah -d YYYY-MM-DD') do |boolean|
11
- puts ops
12
- exit
13
- end
10
+ OptionParser.new do |opts|
11
+ opts.on('-h' '--help', 'Command execution example: waaah -d YYYY-MM-DD') do |boolean|
12
+ puts ops
13
+ exit
14
+ end
14
15
 
15
- opts.on("-d", "--date DATE", "Specify the due date(ex: 2025-01-01)") do |date|
16
- begin
17
- options[:due_date] = Date.parse(date)
18
- rescue ArgumentError
19
- puts 'Error: The date format is not correct.(ex: 2025-01-01)'
20
- exit 1
16
+ opts.on("-d", "--date DATE", "Specify the due date(ex: 2025-01-01)") do |date|
17
+ begin
18
+ options[:due_date] = Date.parse(date)
19
+ rescue ArgumentError
20
+ puts 'Error: The date format is not correct.(ex: 2025-01-01)'
21
+ exit 1
22
+ end
21
23
  end
24
+ end.parse!
25
+
26
+ unless options[:due_date]
27
+ warn "Error: The specification of the due date is required."
28
+ exit 1
22
29
  end
23
- end.parse!
24
30
 
25
- unless options[:due_date]
26
- warn "Error: The specification of the due date is required."
27
- exit 1
28
- end
31
+ today = Date.today
32
+ due_date = options[:due_date]
33
+ start_date = due_date - 280
29
34
 
30
- due_date = options[:due_date]
31
- today = Date.today
32
- start_date = due_date - 280
35
+ puts '----------------------'
36
+ puts "Due date: #{due_date}"
37
+ puts '----------------------'
38
+ puts "Pregnancy start date: #{start_date}"
33
39
 
34
- puts '----------------------'
35
- puts "Due date: #{due_date}"
36
- puts '----------------------'
37
- puts "Pregnancy start date: #{start_date}"
40
+ (1..10).each do |month|
41
+ month_start_date = start_date + (month * 28)
42
+ now = ' *' if months_of_pregnancy?(today, month_start_date)
43
+ puts "#{month} month of pregnancy: #{month_start_date}#{now}"
44
+ end
45
+ end
38
46
 
39
- (1..10).each do |month|
40
- month_start_date = start_date + (month * 4 * 7)
41
- month_end_date = month_start_date + 28
42
- now = ' *' if (month_start_date..month_end_date).cover?(today)
43
- puts "#{month} month of pregnancy: #{month_start_date}#{now}"
47
+ def months_of_pregnancy?(today, month_start_date)
48
+ month_end_date = month_start_date + 27
49
+ (month_start_date..month_end_date).cover?(today)
50
+ end
51
+ def due_date?(due_date, today)
52
+ due_date == today
44
53
  end
45
54
  end
46
55
  end
47
- end
56
+ end
data/lib/waaah/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Waaah
4
- VERSION = "0.1.1"
4
+ VERSION = "0.1.2"
5
5
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: waaah
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - tadaaki
8
8
  bindir: bin
9
9
  cert_chain: []
10
- date: 2025-05-25 00:00:00.000000000 Z
10
+ date: 2025-05-26 00:00:00.000000000 Z
11
11
  dependencies: []
12
12
  executables:
13
13
  - waaah
@@ -24,6 +24,7 @@ licenses:
24
24
  metadata:
25
25
  homepage_uri: https://github.com/torinoko/waaah
26
26
  source_code_uri: https://github.com/torinoko/waaah
27
+ changelog_uri: https://github.com/torinoko/waaah/CHANGELOG.md
27
28
  rdoc_options: []
28
29
  require_paths:
29
30
  - lib