420-time 0.0.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 +7 -0
- data/bin/420 +4 -0
- data/lib/420.rb +68 -0
- data/lib/local/en.yml +10 -0
- metadata +47 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: b2bba51a5f16ab2d924268156af02ee6d7509747
|
4
|
+
data.tar.gz: ca8a7ec30857622514eccef4ae3168f27b9fad20
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 7c93f5fcbd1579c8149d2e616a9f989451cd4f56eaef7d372dfe1b199241d4683d3cb7552c64638f60e5323dc324cc64474d5600d7d9e0418fcdc94ff4ef8fd0
|
7
|
+
data.tar.gz: fccc81a6fa8f8e0121ba3901ff4ee1d56d01942bad301a3824f32b8937074020b4df697c1a96f81ad9d65f9b893056bb9b72a606fc5f28b166148379a2873a1a
|
data/bin/420
ADDED
data/lib/420.rb
ADDED
@@ -0,0 +1,68 @@
|
|
1
|
+
require "thor"
|
2
|
+
require "time_diff"
|
3
|
+
require 'i18n'
|
4
|
+
|
5
|
+
|
6
|
+
class App < Thor
|
7
|
+
desc "time", "Gets the time left until the next 4:20"
|
8
|
+
def time(time=Time.new)
|
9
|
+
if time.is_a? String
|
10
|
+
time = Time.parse(time)
|
11
|
+
end
|
12
|
+
return timeUntil(time)
|
13
|
+
end
|
14
|
+
default_task :time
|
15
|
+
end
|
16
|
+
|
17
|
+
def timeUntil(time=Time.new)
|
18
|
+
|
19
|
+
# This truncates the seconds off the time, to prevent rounding
|
20
|
+
time = Time.parse(time.strftime("%H:%M:00"), time)
|
21
|
+
time = Time.local(time.year, time.month, time.day, time.strftime("%I"), time.strftime("%M"))
|
22
|
+
|
23
|
+
bowl_times = [Time.local(time.year, time.month, time.day, 4, 20),
|
24
|
+
Time.local(time.year, time.month, time.day, 16, 20)]
|
25
|
+
|
26
|
+
# This means it's exactly 420!
|
27
|
+
if time.strftime("%I:%M") == "04:20"
|
28
|
+
local = I18n.t :happy, :scope => 'returns'
|
29
|
+
return local
|
30
|
+
|
31
|
+
# This means it's before 4:20am.
|
32
|
+
elsif time < bowl_times[0]
|
33
|
+
time_until = Time.diff(time, bowl_times[0])
|
34
|
+
if time_until[:hour] == 0
|
35
|
+
local = I18n.t :time_minutes, :scope => 'returns'
|
36
|
+
return local % [time_until[:minute]]
|
37
|
+
else
|
38
|
+
local = I18n.t :time, :scope => 'returns'
|
39
|
+
return local % [time_until[:hour], time_until[:minute]]
|
40
|
+
end
|
41
|
+
|
42
|
+
# This means it's passed 4:20am.
|
43
|
+
elsif time > bowl_times[0] and time < bowl_times[1]
|
44
|
+
time_until = Time.diff(time, bowl_times[1])
|
45
|
+
if time_until[:hour] == 0
|
46
|
+
local = I18n.t :time_minutes, :scope => 'returns'
|
47
|
+
return local % [time_until[:minute]]
|
48
|
+
else
|
49
|
+
local = I18n.t :time, :scope => 'returns'
|
50
|
+
return local % [time_until[:hour], time_until[:minute]]
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
end
|
55
|
+
|
56
|
+
# FourTwenty is the includable ruby module to run the thor app and test
|
57
|
+
module FourTwenty
|
58
|
+
def self.run
|
59
|
+
dir = File.dirname(__FILE__)
|
60
|
+
I18n.load_path = Dir[dir + '/local/*.yml', dir + '/local/*.rb']
|
61
|
+
puts App.start
|
62
|
+
end
|
63
|
+
def self.run_from_time(args)
|
64
|
+
dir = File.dirname(__FILE__)
|
65
|
+
I18n.load_path = Dir[dir + '/local/*.yml', dir + '/local/*.rb']
|
66
|
+
App.start(args)
|
67
|
+
end
|
68
|
+
end
|
data/lib/local/en.yml
ADDED
metadata
ADDED
@@ -0,0 +1,47 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: 420-time
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.2
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- mediachicken
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-11-03 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description: A simple command to display the amount of time left until 420
|
14
|
+
email: self@mediachicken.com
|
15
|
+
executables:
|
16
|
+
- '420'
|
17
|
+
extensions: []
|
18
|
+
extra_rdoc_files: []
|
19
|
+
files:
|
20
|
+
- bin/420
|
21
|
+
- lib/420.rb
|
22
|
+
- lib/local/en.yml
|
23
|
+
homepage: http://github.com/mediachicken/420
|
24
|
+
licenses:
|
25
|
+
- BSD
|
26
|
+
metadata: {}
|
27
|
+
post_install_message:
|
28
|
+
rdoc_options: []
|
29
|
+
require_paths:
|
30
|
+
- lib
|
31
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
32
|
+
requirements:
|
33
|
+
- - ">="
|
34
|
+
- !ruby/object:Gem::Version
|
35
|
+
version: '0'
|
36
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
requirements: []
|
42
|
+
rubyforge_project:
|
43
|
+
rubygems_version: 2.4.2
|
44
|
+
signing_key:
|
45
|
+
specification_version: 4
|
46
|
+
summary: Countdown to 420
|
47
|
+
test_files: []
|