witt 0.2.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/witt.rb +11 -4
- data/lib/witt/iata.rb +1 -2
- data/lib/witt/output.rb +8 -0
- data/lib/witt/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 86c29f07cd0cf564c0a9c81b017ec686e45107b4
|
4
|
+
data.tar.gz: f9fb86248a8ee48f0911ecaf836b56d9aaee104a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b4a44ff291ebe24f7573060fc49c65946bf8b2bdcef464d12111f748d85a232b6639181916122cd385c0a84c53bac6c317acd93819fc9e16e4f2b36a50ce4116
|
7
|
+
data.tar.gz: 740b1c157746e3ddebf6762a7fd7ecd8c4f63a725c910a51bdceb3ecfdd86a18ce8d356b2aab9399e02eb4f76c3d82d0cc6525c536d6432f5e4b46b062da7ce2
|
data/lib/witt.rb
CHANGED
@@ -12,12 +12,19 @@ module Witt
|
|
12
12
|
world_clock = WorldClock.new
|
13
13
|
output = Output.new
|
14
14
|
|
15
|
+
invalid_airports = []
|
16
|
+
|
15
17
|
airports.each do |airport|
|
16
18
|
airport = airport.upcase
|
17
|
-
timezone =
|
18
|
-
|
19
|
-
|
20
|
-
|
19
|
+
timezone = Witt::IATA[airport]
|
20
|
+
begin
|
21
|
+
time = world_clock.time_in(timezone)
|
22
|
+
output.print(time, airport, timezone)
|
23
|
+
rescue
|
24
|
+
invalid_airports << airport
|
25
|
+
end
|
21
26
|
end
|
27
|
+
|
28
|
+
output.print_error(invalid_airports) unless invalid_airports.empty?
|
22
29
|
end
|
23
30
|
end
|
data/lib/witt/iata.rb
CHANGED
data/lib/witt/output.rb
CHANGED
@@ -8,6 +8,11 @@ module Witt
|
|
8
8
|
puts "#{iata_code}: #{emoji} #{formatted_time} (#{timezone})"
|
9
9
|
end
|
10
10
|
|
11
|
+
def print_error(invalid_airports)
|
12
|
+
error_message = "\nNo time zone info found for: #{invalid_airports.join(", ")}"
|
13
|
+
puts message_in_red(error_message)
|
14
|
+
end
|
15
|
+
|
11
16
|
private
|
12
17
|
|
13
18
|
def to_emoji(time)
|
@@ -18,5 +23,8 @@ module Witt
|
|
18
23
|
time.hour >= 19 || time.hour <= 5
|
19
24
|
end
|
20
25
|
|
26
|
+
def message_in_red(message)
|
27
|
+
"\e[31m#{message}\e[0m"
|
28
|
+
end
|
21
29
|
end
|
22
30
|
end
|
data/lib/witt/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: witt
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Pedro Vereza
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-12-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: tzinfo
|
@@ -103,7 +103,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
103
103
|
version: '0'
|
104
104
|
requirements: []
|
105
105
|
rubyforge_project:
|
106
|
-
rubygems_version: 2.6.
|
106
|
+
rubygems_version: 2.6.14
|
107
107
|
signing_key:
|
108
108
|
specification_version: 4
|
109
109
|
summary: What Is The Time - Ruby world clock on your terminal
|