super_countdown 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 +7 -0
- data/LICENSE +21 -0
- data/bin/super_countdown +29 -0
- data/lib/super_countdown/version.rb +3 -0
- data/lib/super_countdown.rb +34 -0
- metadata +74 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: d0132c32d2b626a395d158a622df71a054e303cf32bc9943f624384e668252da
|
4
|
+
data.tar.gz: 336bb20c8aa8d1518e0e23226299391154a8aee4935d4450358b2cbffabedc7c
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: a8200d2611928becf3c2ad142b53d0d6504c129c412df6cce90b1905c7eb6476bb1e70caa152168b1c58c86e297e0b9acbac9b9ea11277b923f8c8d819f41e60
|
7
|
+
data.tar.gz: c15a76704da3380be87fd28bb4041d8bff2c83bde0d06084d6538eee99352dcbde33d8a732a47c446cabfddc7a82a70a55361b8f323c23c5149e9865794a78e9
|
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2024 Vinicius de Melo Rocha
|
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 all
|
13
|
+
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 THE
|
21
|
+
SOFTWARE.
|
data/bin/super_countdown
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'super_countdown'
|
4
|
+
require 'optparse'
|
5
|
+
|
6
|
+
def parse_date(date_str)
|
7
|
+
Time.parse(date_str)
|
8
|
+
rescue ArgumentError
|
9
|
+
puts "Invalid date format. Please use: YYYY-MM-DD HH:MM:SS"
|
10
|
+
exit 1
|
11
|
+
end
|
12
|
+
|
13
|
+
begin
|
14
|
+
target_date_str = if ARGV.empty?
|
15
|
+
print "Enter target date (YYYY-MM-DD HH:MM:SS): "
|
16
|
+
gets.chomp
|
17
|
+
else
|
18
|
+
ARGV.join(' ')
|
19
|
+
end
|
20
|
+
|
21
|
+
target_date = parse_date(target_date_str)
|
22
|
+
|
23
|
+
SuperCountdown.countdown_to(target_date) do |days, hours, minutes, seconds, ms|
|
24
|
+
print "\r%03d days %02d:%02d:%02d:%03d" % [days, hours, minutes, seconds, ms]
|
25
|
+
end
|
26
|
+
rescue Interrupt
|
27
|
+
puts "\nCountdown stopped."
|
28
|
+
exit 0
|
29
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
require 'date'
|
2
|
+
require 'time'
|
3
|
+
require 'super_countdown/version'
|
4
|
+
|
5
|
+
module SuperCountdown
|
6
|
+
def self.version
|
7
|
+
VERSION
|
8
|
+
end
|
9
|
+
|
10
|
+
def self.countdown_to(target_date)
|
11
|
+
loop do
|
12
|
+
now = Time.now
|
13
|
+
diff = target_date - now
|
14
|
+
|
15
|
+
break if diff <= 0
|
16
|
+
|
17
|
+
days = diff.to_i / 86400
|
18
|
+
hours = (diff.to_i % 86400) / 3600
|
19
|
+
minutes = (diff.to_i % 3600) / 60
|
20
|
+
seconds = diff.to_i % 60
|
21
|
+
milliseconds = ((diff - diff.to_i) * 1000).to_i
|
22
|
+
|
23
|
+
if block_given?
|
24
|
+
yield(days, hours, minutes, seconds, milliseconds)
|
25
|
+
else
|
26
|
+
print "\r#{days}d #{hours}h #{minutes}m #{seconds}s #{milliseconds}ms"
|
27
|
+
end
|
28
|
+
|
29
|
+
sleep 0.01
|
30
|
+
end
|
31
|
+
|
32
|
+
puts "\nTime's up!"
|
33
|
+
end
|
34
|
+
end
|
metadata
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: super_countdown
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
original_platform: ''
|
7
|
+
authors:
|
8
|
+
- Vinicius de Melo Rocha
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2024-12-19 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rspec
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '3.13'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '3.13'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: timecop
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 0.9.10
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 0.9.10
|
41
|
+
description: Displays a countdown timer to a specified future date with millisecond
|
42
|
+
precision
|
43
|
+
email: vmrocha@gmail.com
|
44
|
+
executables:
|
45
|
+
- super_countdown
|
46
|
+
extensions: []
|
47
|
+
extra_rdoc_files: []
|
48
|
+
files:
|
49
|
+
- LICENSE
|
50
|
+
- bin/super_countdown
|
51
|
+
- lib/super_countdown.rb
|
52
|
+
- lib/super_countdown/version.rb
|
53
|
+
homepage: https://github.com/vmrocha/super_countdown
|
54
|
+
licenses:
|
55
|
+
- MIT
|
56
|
+
metadata: {}
|
57
|
+
rdoc_options: []
|
58
|
+
require_paths:
|
59
|
+
- lib
|
60
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
61
|
+
requirements:
|
62
|
+
- - ">="
|
63
|
+
- !ruby/object:Gem::Version
|
64
|
+
version: 2.5.0
|
65
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
66
|
+
requirements:
|
67
|
+
- - ">="
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '0'
|
70
|
+
requirements: []
|
71
|
+
rubygems_version: 3.6.1
|
72
|
+
specification_version: 4
|
73
|
+
summary: A super simple countdown timer
|
74
|
+
test_files: []
|