time_overlap 0.1.2 → 0.2.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 +5 -5
- data/.ruby-version +1 -1
- data/Gemfile.lock +18 -10
- data/README.md +52 -29
- data/img/expert.png +0 -0
- data/img/light.png +0 -0
- data/lib/time_overlap/calculator.rb +41 -22
- data/lib/time_overlap/cli.rb +62 -15
- data/lib/time_overlap/presenter.rb +119 -49
- data/lib/time_overlap/version.rb +1 -1
- data/lib/time_overlap.rb +2 -0
- data/time_overlap.gemspec +6 -4
- metadata +35 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: d3a8031e7707fb88197a85c2c3b9e1997c522333ab68542c34f25215a10a5ccb
|
4
|
+
data.tar.gz: 84bfea4dd827d62cd2c7f16b79878f7e0625d5262f257dc7ef6f942876ef3afb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 61b8dc9ef09fc1961bbdb7a48d595e6fa033d1594e6f239cf96c2f382961e4567064d1957c8cad6bf11ff12b7fc61b3d02d1e0b8a08cb8845f35734ec3e6a534
|
7
|
+
data.tar.gz: 92980ca74a0b13c6332909cf99c6f9e97baed391869fb704144afaba45370bb401275a54e3bf6e21564275b07c0eb4c2030253b1668ee4428823f879aa1d1408
|
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.
|
1
|
+
2.6.3
|
data/Gemfile.lock
CHANGED
@@ -1,26 +1,29 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
time_overlap (0.
|
4
|
+
time_overlap (0.2.0)
|
5
5
|
activesupport
|
6
6
|
colorize
|
7
|
+
terminal-table
|
7
8
|
thor
|
8
9
|
|
9
10
|
GEM
|
10
11
|
remote: https://rubygems.org/
|
11
12
|
specs:
|
12
|
-
activesupport (
|
13
|
+
activesupport (6.0.2.2)
|
13
14
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
14
15
|
i18n (>= 0.7, < 2)
|
15
16
|
minitest (~> 5.1)
|
16
17
|
tzinfo (~> 1.1)
|
18
|
+
zeitwerk (~> 2.2)
|
19
|
+
byebug (11.1.1)
|
17
20
|
colorize (0.8.1)
|
18
|
-
concurrent-ruby (1.1.
|
21
|
+
concurrent-ruby (1.1.6)
|
19
22
|
diff-lcs (1.3)
|
20
|
-
i18n (1.
|
23
|
+
i18n (1.8.2)
|
21
24
|
concurrent-ruby (~> 1.0)
|
22
|
-
minitest (5.
|
23
|
-
rake (
|
25
|
+
minitest (5.14.0)
|
26
|
+
rake (13.0.1)
|
24
27
|
rspec (3.8.0)
|
25
28
|
rspec-core (~> 3.8.0)
|
26
29
|
rspec-expectations (~> 3.8.0)
|
@@ -34,21 +37,26 @@ GEM
|
|
34
37
|
diff-lcs (>= 1.2.0, < 2.0)
|
35
38
|
rspec-support (~> 3.8.0)
|
36
39
|
rspec-support (3.8.0)
|
37
|
-
|
40
|
+
terminal-table (1.8.0)
|
41
|
+
unicode-display_width (~> 1.1, >= 1.1.1)
|
42
|
+
thor (1.0.1)
|
38
43
|
thread_safe (0.3.6)
|
39
44
|
timecop (0.9.1)
|
40
|
-
tzinfo (1.2.
|
45
|
+
tzinfo (1.2.7)
|
41
46
|
thread_safe (~> 0.1)
|
47
|
+
unicode-display_width (1.7.0)
|
48
|
+
zeitwerk (2.3.0)
|
42
49
|
|
43
50
|
PLATFORMS
|
44
51
|
ruby
|
45
52
|
|
46
53
|
DEPENDENCIES
|
47
54
|
bundler (~> 2.0)
|
48
|
-
|
55
|
+
byebug
|
56
|
+
rake (~> 13.0)
|
49
57
|
rspec (~> 3.0)
|
50
58
|
time_overlap!
|
51
59
|
timecop
|
52
60
|
|
53
61
|
BUNDLED WITH
|
54
|
-
2.0.
|
62
|
+
2.0.2
|
data/README.md
CHANGED
@@ -1,55 +1,78 @@
|
|
1
1
|
# TimeOverlap
|
2
2
|
|
3
|
-
|
3
|
+
Command line tool which visualizes time overlap for distributed teams.
|
4
4
|
|
5
|
-
|
5
|
+
## Features
|
6
6
|
|
7
|
-
|
8
|
-
|
9
|
-
|
7
|
+
* Handles as many time zones as you want
|
8
|
+
* Allows to specify start and end time
|
9
|
+
* Supports two modes: Light and Expert
|
10
|
+
* Lists all possible time zones
|
11
|
+
* Works well during Daylight Saving Time
|
10
12
|
|
11
|
-
|
13
|
+
## Installation
|
12
14
|
|
13
|
-
|
14
|
-
and you want to cover 4 hours - from 8:00 to 16:00.
|
15
|
+
Install it yourself as:
|
15
16
|
|
16
|
-
|
17
|
+
$ gem install time_overlap
|
17
18
|
|
18
|
-
|
19
|
+
## Contents
|
19
20
|
|
20
|
-
|
21
|
+
* [1. Usage](#1-usage)
|
22
|
+
* [2. Commands](#2-commands)
|
23
|
+
* [2.1 light](#21-light)
|
24
|
+
* [2.2 expert](#22-expert)
|
25
|
+
* [2.3 list](#23-list)
|
21
26
|
|
22
|
-
|
27
|
+
## 1. Usage
|
23
28
|
|
24
|
-
|
25
|
-
gem 'time_overlap'
|
26
|
-
```
|
29
|
+
$ time_overlap help
|
27
30
|
|
28
|
-
|
31
|
+
## 2. Commands
|
29
32
|
|
30
|
-
|
33
|
+
### 2.1 light
|
31
34
|
|
32
|
-
|
35
|
+
$ time_overlap light 9 17 London Hanoi Sydney
|
33
36
|
|
34
|
-
|
37
|
+

|
35
38
|
|
36
|
-
|
39
|
+
### 2.2 expert
|
37
40
|
|
41
|
+
$ time_overlap expert 9 17 4 London Hanoi Sydney
|
38
42
|
|
39
|
-
|
43
|
+

|
40
44
|
|
41
|
-
|
45
|
+
### 2.2 list
|
42
46
|
|
43
|
-
|
47
|
+
$ time_overlap list
|
44
48
|
|
45
|
-
|
49
|
+
```
|
50
|
+
List of available time zones:
|
51
|
+
-----------------------------
|
52
|
+
-12:00: International Date Line West
|
53
|
+
-11:00: American Samoa
|
54
|
+
-11:00: Midway Island
|
55
|
+
-10:00: Hawaii
|
56
|
+
-09:00: Alaska
|
57
|
+
-08:00: Pacific Time (US & Canada)
|
58
|
+
-08:00: Tijuana
|
59
|
+
-07:00: Arizona
|
60
|
+
-07:00: Chihuahua
|
61
|
+
-07:00: Mazatlan
|
62
|
+
-07:00: Mountain Time (US & Canada)
|
63
|
+
(...)
|
64
|
+
```
|
46
65
|
|
47
|
-
|
66
|
+
## Contributing
|
48
67
|
|
49
|
-
|
68
|
+
1. Fork it ( https://github.com/rafaltrojanowski/time_overlap/fork )
|
69
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
70
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
71
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
72
|
+
5. Create a new Pull Request
|
50
73
|
|
51
|
-
|
74
|
+
This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
52
75
|
|
53
|
-
##
|
76
|
+
## Copyright
|
54
77
|
|
55
|
-
|
78
|
+
Copyright (c) 2020 Rafał Trojanowski. See LICENSE for further details.
|
data/img/expert.png
ADDED
Binary file
|
data/img/light.png
ADDED
Binary file
|
@@ -1,10 +1,11 @@
|
|
1
1
|
module TimeOverlap
|
2
2
|
class Calculator
|
3
3
|
|
4
|
-
def initialize(from:, to:, time_zone:, my_time_zone:, min_overlap:)
|
4
|
+
def initialize(from:, to:, time_zone:, my_time_zone:, min_overlap:, expert: true, show_base: true)
|
5
5
|
@current_year = Time.current.year
|
6
6
|
@current_month = Time.current.month
|
7
7
|
@current_day = Time.current.day
|
8
|
+
|
8
9
|
@from = from
|
9
10
|
@to = to
|
10
11
|
@time_zone = time_zone
|
@@ -14,10 +15,13 @@ module TimeOverlap
|
|
14
15
|
@end_time = set_time(to)
|
15
16
|
@duration = (end_time - start_time).to_i / 60 / 60
|
16
17
|
|
18
|
+
@expert = expert
|
19
|
+
@show_base = show_base
|
20
|
+
|
17
21
|
@data = {}
|
18
22
|
end
|
19
23
|
|
20
|
-
def self.
|
24
|
+
def self.show(*args)
|
21
25
|
self.new(*args).execute
|
22
26
|
end
|
23
27
|
|
@@ -27,11 +31,11 @@ module TimeOverlap
|
|
27
31
|
start_time_in_my_time_zone = start_time.in_time_zone(my_time_zone)
|
28
32
|
end_time_in_my_time_zone = end_time.in_time_zone(my_time_zone)
|
29
33
|
|
30
|
-
|
31
|
-
|
34
|
+
overlap_1_start_time = (start_time - offset * 60 * 60).in_time_zone(my_time_zone)
|
35
|
+
overlap_1_end_time = (end_time - offset * 60 * 60).in_time_zone(my_time_zone)
|
32
36
|
|
33
|
-
|
34
|
-
|
37
|
+
overlap_2_start_time = (end_time - min_overlap * 60 * 60).in_time_zone(my_time_zone)
|
38
|
+
overlap_2_end_time = (overlap_2_start_time + duration * 60 * 60).in_time_zone(my_time_zone)
|
35
39
|
|
36
40
|
@data = {
|
37
41
|
original: {
|
@@ -43,23 +47,33 @@ module TimeOverlap
|
|
43
47
|
end: end_time_in_my_time_zone
|
44
48
|
},
|
45
49
|
overlap_1: {
|
46
|
-
start:
|
47
|
-
end:
|
50
|
+
start: overlap_1_start_time,
|
51
|
+
end: overlap_1_end_time,
|
48
52
|
},
|
49
53
|
overlap_2: {
|
50
|
-
start:
|
51
|
-
end:
|
52
|
-
}
|
54
|
+
start: overlap_2_start_time,
|
55
|
+
end: overlap_2_end_time
|
56
|
+
},
|
57
|
+
duration: duration,
|
58
|
+
min_overlap: min_overlap,
|
59
|
+
time_zone: time_zone,
|
60
|
+
my_time_zone: my_time_zone
|
53
61
|
}
|
54
62
|
|
55
|
-
|
63
|
+
if overlap_1_start_time == overlap_2_start_time &&
|
64
|
+
overlap_1_end_time == overlap_2_end_time
|
65
|
+
@data.delete(:overlap_2)
|
66
|
+
end
|
67
|
+
|
68
|
+
|
69
|
+
throw_errors!
|
56
70
|
|
57
|
-
|
71
|
+
unless @expert
|
72
|
+
@data.delete(:overlap_1)
|
58
73
|
@data.delete(:overlap_2)
|
59
74
|
end
|
60
75
|
|
61
|
-
|
62
|
-
Presenter.new(@data).generate_output
|
76
|
+
present_result
|
63
77
|
end
|
64
78
|
|
65
79
|
private
|
@@ -76,15 +90,23 @@ module TimeOverlap
|
|
76
90
|
:duration
|
77
91
|
)
|
78
92
|
|
93
|
+
def present_result
|
94
|
+
presenter_instance.generate_output
|
95
|
+
end
|
96
|
+
|
97
|
+
def presenter_instance
|
98
|
+
@presenter_instance ||= Presenter.new(@data)
|
99
|
+
end
|
100
|
+
|
79
101
|
def set_time(hour)
|
80
102
|
offset = Time.zone_offset(time_zone)
|
81
103
|
|
82
104
|
if offset.nil?
|
83
|
-
zone = ActiveSupport::TimeZone
|
84
|
-
offset = zone.utc_offset
|
105
|
+
zone = ActiveSupport::TimeZone.new(time_zone)
|
106
|
+
offset = zone.now.utc_offset
|
85
107
|
end
|
86
108
|
|
87
|
-
raise
|
109
|
+
raise "Problem has occured during offset calculation for #{time_zone}" if offset.nil?
|
88
110
|
|
89
111
|
Time.new(
|
90
112
|
@current_year,
|
@@ -98,10 +120,7 @@ module TimeOverlap
|
|
98
120
|
end
|
99
121
|
|
100
122
|
def throw_errors!
|
101
|
-
if @min_overlap > @duration
|
102
|
-
raise "Min overlap must be lower that duration"
|
103
|
-
end
|
104
|
-
|
123
|
+
raise "Min overlap must be lower that duration" if @min_overlap > @duration
|
105
124
|
raise "Wrong Overlap 1" unless (data[:overlap_1][:end] - data[:overlap_1][:start]).to_i / 60 / 60 == duration
|
106
125
|
|
107
126
|
if data[:overlap_2] && (data[:overlap_2][:end] - data[:overlap_2][:start]).to_i / 60 / 60 != duration
|
data/lib/time_overlap/cli.rb
CHANGED
@@ -1,24 +1,71 @@
|
|
1
1
|
require "thor"
|
2
|
+
require 'terminal-table'
|
2
3
|
|
3
4
|
module TimeOverlap
|
4
5
|
class CLI < Thor
|
5
6
|
|
6
|
-
desc '
|
7
|
-
"
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
Bangkok -> my time zone
|
12
|
-
4 -> min_overlap (hours, integer)
|
7
|
+
desc 'expert',
|
8
|
+
"Usage:
|
9
|
+
`time_overlap expert start_hour end_hour min_overlap base_zone other_zone(s)`
|
10
|
+
Example:
|
11
|
+
`time_overlap expert 8 16 4 Warsaw Bangkok`
|
13
12
|
"
|
14
|
-
def
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
)
|
13
|
+
def expert(from, to, min_overlap, base_time_zone, *time_zones)
|
14
|
+
rows = []
|
15
|
+
header = ""
|
16
|
+
header << "*** Your overlap hours in #{time_zones.join(", ")} to #{base_time_zone} (Expert view) ***\n".center(Presenter::WIDTH)
|
17
|
+
rows << [header]
|
18
|
+
puts Terminal::Table.new rows: rows, :style => { :width => Presenter::WIDTH + 4 }
|
19
|
+
|
20
|
+
raise "Min overlap (#{min_overlap}) need to be Integer from range (1..24)" if min_overlap.to_i.zero?
|
21
|
+
|
22
|
+
time_zones.each_with_index do |zone_name, index|
|
23
|
+
TimeOverlap::Calculator.show(
|
24
|
+
from: from.to_i,
|
25
|
+
to: to.to_i,
|
26
|
+
min_overlap: min_overlap.to_i,
|
27
|
+
time_zone: base_time_zone,
|
28
|
+
my_time_zone: zone_name,
|
29
|
+
expert: true,
|
30
|
+
)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
desc 'light',
|
35
|
+
"Usage:
|
36
|
+
`time_overlap light start_hour end_hour base_zone team_zone(s)`
|
37
|
+
Example:
|
38
|
+
`time_overlap light 7 15 Warsaw Bangkok Chongqing Osaka Hobart Auckland Samoa`
|
39
|
+
"
|
40
|
+
def light(from, to, base_time_zone, *time_zones)
|
41
|
+
rows = []
|
42
|
+
header = ""
|
43
|
+
header << "*** Your overlap hours in #{time_zones.join(", ")} to #{base_time_zone} (Light view) ***".center(Presenter::WIDTH)
|
44
|
+
rows << [header]
|
45
|
+
puts Terminal::Table.new rows: rows, :style => { :width => Presenter::WIDTH + 4 }
|
46
|
+
|
47
|
+
time_zones.each_with_index do |zone_name, index|
|
48
|
+
TimeOverlap::Calculator.show(
|
49
|
+
from: from.to_i,
|
50
|
+
to: to.to_i,
|
51
|
+
min_overlap: 0,
|
52
|
+
time_zone: base_time_zone,
|
53
|
+
my_time_zone: zone_name,
|
54
|
+
expert: false,
|
55
|
+
)
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
desc 'list',
|
60
|
+
"Example: `time_overlap list`"
|
61
|
+
def list
|
62
|
+
puts "List of available time zones:"
|
63
|
+
puts "-----------------------------"
|
64
|
+
ActiveSupport::TimeZone.all.map do |zone|
|
65
|
+
puts "#{ActiveSupport::TimeZone[zone.name].formatted_offset}: #{zone.name}"
|
66
|
+
end
|
67
|
+
puts "-----------------------------"
|
68
|
+
self.help
|
22
69
|
end
|
23
70
|
end
|
24
71
|
end
|
@@ -1,14 +1,20 @@
|
|
1
1
|
require 'colorize'
|
2
|
+
require 'terminal-table'
|
2
3
|
|
3
4
|
module TimeOverlap
|
4
5
|
class Presenter
|
5
6
|
|
6
|
-
AM = "AM "
|
7
|
-
PM = " PM"
|
7
|
+
AM = "AM "
|
8
|
+
PM = " PM"
|
8
9
|
NOON = " 12:00 "
|
9
10
|
SIX_AM = " 6:00 "
|
10
11
|
SIX_PM = " 6:00 "
|
11
12
|
|
13
|
+
EARLY_BIRD = 'Early Bird'
|
14
|
+
NIGHT_OWL = 'Night Owl'
|
15
|
+
|
16
|
+
WIDTH = 102
|
17
|
+
|
12
18
|
AVAILABLE_SLOT = "|█| "
|
13
19
|
EMPTY_SLOT = "[ ] "
|
14
20
|
|
@@ -22,34 +28,92 @@ module TimeOverlap
|
|
22
28
|
end
|
23
29
|
|
24
30
|
def generate_output
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
puts
|
33
|
-
timeline(@data[:overlap_1][:start], @data[:overlap_1][:end])
|
34
|
-
|
35
|
-
if @data[:overlap_2]
|
36
|
-
puts "Overlap 2:"
|
37
|
-
puts "#{formated_time(@data[:overlap_2][:start], false)} - #{formated_time(@data[:overlap_2][:end])}".green
|
38
|
-
timeline(@data[:overlap_2][:start], @data[:overlap_2][:end])
|
39
|
-
end
|
31
|
+
rows = []
|
32
|
+
|
33
|
+
rows << [base_content]
|
34
|
+
rows << [min_overlap_content]
|
35
|
+
rows << [full_overlap_content]
|
36
|
+
|
37
|
+
table = Terminal::Table.new :rows => rows
|
38
|
+
puts table
|
40
39
|
|
41
40
|
@data
|
42
41
|
end
|
43
42
|
|
44
43
|
private
|
45
44
|
|
46
|
-
def
|
47
|
-
|
45
|
+
def duration
|
46
|
+
@data[:duration]
|
47
|
+
end
|
48
|
+
|
49
|
+
def min_overlap
|
50
|
+
@data[:min_overlap]
|
51
|
+
end
|
52
|
+
|
53
|
+
def my_time_zone
|
54
|
+
@data[:my_time_zone]
|
55
|
+
end
|
56
|
+
|
57
|
+
def time_zone
|
58
|
+
@data[:time_zone]
|
59
|
+
end
|
60
|
+
|
61
|
+
def original
|
62
|
+
@data[:original]
|
63
|
+
end
|
64
|
+
|
65
|
+
def overlap_1
|
66
|
+
@data[:overlap_1]
|
67
|
+
end
|
68
|
+
|
69
|
+
def overlap_2
|
70
|
+
@data[:overlap_2]
|
71
|
+
end
|
72
|
+
|
73
|
+
def full_overlap
|
74
|
+
@data[:full_overlap]
|
75
|
+
end
|
76
|
+
|
77
|
+
def base_content
|
78
|
+
return unless original
|
79
|
+
|
80
|
+
output = ""
|
81
|
+
|
82
|
+
output << "* #{time_zone} (Base)\n"
|
83
|
+
output << "#{formated_time(original[:start], true)} - #{formated_time(original[:end])}\n".green
|
84
|
+
|
85
|
+
output << timeline(original[:start], original[:end])
|
86
|
+
end
|
87
|
+
|
88
|
+
def min_overlap_content
|
89
|
+
return unless overlap_1
|
90
|
+
|
91
|
+
output = ""
|
92
|
+
|
93
|
+
output << "* #{my_time_zone} #{EARLY_BIRD} (#{min_overlap} hour(s) of overlap)\n"
|
94
|
+
output << "#{formated_time(overlap_1[:start], true)} - #{formated_time(overlap_1[:end])}\n".green
|
95
|
+
output << timeline(overlap_1[:start], overlap_1[:end])
|
96
|
+
|
97
|
+
if overlap_2
|
98
|
+
output << "\n"
|
99
|
+
output << "* #{my_time_zone} #{NIGHT_OWL} (#{min_overlap} hour(s) of overlap)\n"
|
100
|
+
output << "#{formated_time(overlap_2[:start], true)} - #{formated_time(overlap_2[:end])}\n".green
|
101
|
+
output << timeline(overlap_2[:start], overlap_2[:end])
|
102
|
+
end
|
103
|
+
|
104
|
+
output
|
48
105
|
end
|
49
106
|
|
50
|
-
def
|
107
|
+
def full_overlap_content
|
108
|
+
output = ""
|
109
|
+
output << "* #{my_time_zone} (#{duration} hours of overlap)\n"
|
110
|
+
output << "#{formated_time(full_overlap[:start], true)} - #{formated_time(full_overlap[:end])}\n".green
|
111
|
+
output << timeline(full_overlap[:start], full_overlap[:end])
|
112
|
+
end
|
113
|
+
|
114
|
+
def formated_time(time, with_zone=false)
|
51
115
|
format = "%T"
|
52
|
-
format.
|
116
|
+
format.prepend("TZ: %:z | ") if with_zone
|
53
117
|
time.strftime(format)
|
54
118
|
end
|
55
119
|
|
@@ -66,69 +130,75 @@ module TimeOverlap
|
|
66
130
|
when 22..23
|
67
131
|
then :blue
|
68
132
|
end
|
69
|
-
|
70
|
-
end
|
71
|
-
|
72
|
-
def with_color(string, hour)
|
73
|
-
string.colorize(get_color(hour))
|
74
133
|
end
|
75
134
|
|
76
135
|
def timeline(start_time, end_time)
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
end
|
136
|
+
timeline = ""
|
137
|
+
|
138
|
+
timeline << " "
|
81
139
|
|
82
|
-
|
140
|
+
(0..23).map do |hour|
|
141
|
+
timeline << "%-4s" % hour
|
142
|
+
end
|
83
143
|
|
84
|
-
|
144
|
+
timeline << "\n"
|
85
145
|
|
86
|
-
|
87
|
-
# print NOON if hour == 12
|
88
|
-
# print SIX_AM if hour == 6
|
89
|
-
# print SIX_PM if hour == 18
|
146
|
+
timeline << AM
|
90
147
|
|
148
|
+
(0..23).map do |hour|
|
91
149
|
if start_time.hour < end_time.hour
|
92
150
|
if (start_time.hour..end_time.hour).cover?(hour)
|
93
151
|
if end_time.hour != hour
|
94
|
-
|
152
|
+
timeline << with_color(AVAILABLE_SLOT, hour)
|
95
153
|
else
|
96
|
-
|
154
|
+
timeline << with_color(EMPTY_SLOT, hour)
|
97
155
|
end
|
98
156
|
else
|
99
|
-
|
157
|
+
timeline << with_color(EMPTY_SLOT, hour)
|
100
158
|
end
|
101
159
|
else
|
102
160
|
if start_time.hour <= 12
|
103
161
|
if (end_time.hour..start_time.hour).cover?(hour)
|
104
162
|
if end_time.hour != hour
|
105
|
-
|
163
|
+
timeline << with_color(AVAILABLE_SLOT, hour)
|
106
164
|
else
|
107
|
-
|
165
|
+
timeline << with_color(EMPTY_SLOT, hour)
|
108
166
|
end
|
109
167
|
else
|
110
|
-
|
168
|
+
timeline << with_color(EMPTY_SLOT, hour)
|
111
169
|
end
|
112
170
|
else
|
113
171
|
if (end_time.hour..start_time.hour).cover?(hour)
|
114
172
|
if (start_time.hour == hour)
|
115
|
-
|
173
|
+
timeline << with_color(AVAILABLE_SLOT, hour)
|
116
174
|
else
|
117
|
-
|
175
|
+
timeline << with_color(EMPTY_SLOT, hour)
|
118
176
|
end
|
119
177
|
else
|
120
178
|
if end_time.hour != hour
|
121
|
-
|
179
|
+
timeline << with_color(AVAILABLE_SLOT, hour)
|
122
180
|
else
|
123
|
-
|
181
|
+
timeline << with_color(EMPTY_SLOT, hour)
|
124
182
|
end
|
125
183
|
end
|
126
184
|
end
|
127
185
|
end
|
128
186
|
end
|
129
|
-
|
130
|
-
|
131
|
-
|
187
|
+
|
188
|
+
timeline << PM
|
189
|
+
timeline << "\n"
|
190
|
+
timeline << separator
|
191
|
+
|
192
|
+
|
193
|
+
timeline
|
194
|
+
end
|
195
|
+
|
196
|
+
def with_color(string, hour)
|
197
|
+
string.colorize(get_color(hour))
|
198
|
+
end
|
199
|
+
|
200
|
+
def separator
|
201
|
+
" " * WIDTH
|
132
202
|
end
|
133
203
|
end
|
134
204
|
end
|
data/lib/time_overlap/version.rb
CHANGED
data/lib/time_overlap.rb
CHANGED
data/time_overlap.gemspec
CHANGED
@@ -30,12 +30,14 @@ Gem::Specification.new do |spec|
|
|
30
30
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
31
31
|
spec.require_paths = ["lib"]
|
32
32
|
|
33
|
-
spec.add_dependency 'activesupport'
|
34
|
-
spec.add_dependency 'thor'
|
35
|
-
spec.add_dependency 'colorize'
|
33
|
+
spec.add_dependency 'activesupport' # Time zone support
|
34
|
+
spec.add_dependency 'thor' # Cli support
|
35
|
+
spec.add_dependency 'colorize' # Output
|
36
|
+
spec.add_dependency 'terminal-table' # Output
|
36
37
|
|
37
38
|
spec.add_development_dependency "bundler", "~> 2.0"
|
38
|
-
spec.add_development_dependency "rake", "~>
|
39
|
+
spec.add_development_dependency "rake", "~> 13.0"
|
39
40
|
spec.add_development_dependency "rspec", "~> 3.0"
|
40
41
|
spec.add_development_dependency "timecop"
|
42
|
+
spec.add_development_dependency "byebug"
|
41
43
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: time_overlap
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Rafał Trojanowski
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-04-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -52,6 +52,20 @@ dependencies:
|
|
52
52
|
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: terminal-table
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
55
69
|
- !ruby/object:Gem::Dependency
|
56
70
|
name: bundler
|
57
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -72,14 +86,14 @@ dependencies:
|
|
72
86
|
requirements:
|
73
87
|
- - "~>"
|
74
88
|
- !ruby/object:Gem::Version
|
75
|
-
version: '
|
89
|
+
version: '13.0'
|
76
90
|
type: :development
|
77
91
|
prerelease: false
|
78
92
|
version_requirements: !ruby/object:Gem::Requirement
|
79
93
|
requirements:
|
80
94
|
- - "~>"
|
81
95
|
- !ruby/object:Gem::Version
|
82
|
-
version: '
|
96
|
+
version: '13.0'
|
83
97
|
- !ruby/object:Gem::Dependency
|
84
98
|
name: rspec
|
85
99
|
requirement: !ruby/object:Gem::Requirement
|
@@ -108,6 +122,20 @@ dependencies:
|
|
108
122
|
- - ">="
|
109
123
|
- !ruby/object:Gem::Version
|
110
124
|
version: '0'
|
125
|
+
- !ruby/object:Gem::Dependency
|
126
|
+
name: byebug
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - ">="
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: '0'
|
132
|
+
type: :development
|
133
|
+
prerelease: false
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - ">="
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: '0'
|
111
139
|
description: Write a longer description or delete this line.
|
112
140
|
email:
|
113
141
|
- rt.trojanowski@gmail.com
|
@@ -129,6 +157,8 @@ files:
|
|
129
157
|
- bin/console
|
130
158
|
- bin/setup
|
131
159
|
- exe/time_overlap
|
160
|
+
- img/expert.png
|
161
|
+
- img/light.png
|
132
162
|
- lib/time_overlap.rb
|
133
163
|
- lib/time_overlap/calculator.rb
|
134
164
|
- lib/time_overlap/cli.rb
|
@@ -155,8 +185,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
155
185
|
- !ruby/object:Gem::Version
|
156
186
|
version: '0'
|
157
187
|
requirements: []
|
158
|
-
|
159
|
-
rubygems_version: 2.6.11
|
188
|
+
rubygems_version: 3.0.3
|
160
189
|
signing_key:
|
161
190
|
specification_version: 4
|
162
191
|
summary: Write a short summary, because RubyGems requires one.
|