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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: e669bba185d150189f3a3b3d39a5e2580fe504a8
4
- data.tar.gz: 040f0a671e8033280f98dd97e9835fa48e65c21c
2
+ SHA256:
3
+ metadata.gz: d3a8031e7707fb88197a85c2c3b9e1997c522333ab68542c34f25215a10a5ccb
4
+ data.tar.gz: 84bfea4dd827d62cd2c7f16b79878f7e0625d5262f257dc7ef6f942876ef3afb
5
5
  SHA512:
6
- metadata.gz: 2b60df8d43e896651ea4ad0eb24b2a1f087dc8688360d669e3d20999881fa5d8685c2a3de1129d5e1d967228daa6c0b84fb29e4dff4be08dd92a8c7a9f31d92b
7
- data.tar.gz: 67daa85fa3d19669f63b89386f30cf06dc48d09ae7677ba3b0a48b8cbcaa15ec73778ab0e1e1fca1c90f8051c9976a7261352f3c218ac04b257597ce3e46cf86
6
+ metadata.gz: 61b8dc9ef09fc1961bbdb7a48d595e6fa033d1594e6f239cf96c2f382961e4567064d1957c8cad6bf11ff12b7fc61b3d02d1e0b8a08cb8845f35734ec3e6a534
7
+ data.tar.gz: 92980ca74a0b13c6332909cf99c6f9e97baed391869fb704144afaba45370bb401275a54e3bf6e21564275b07c0eb4c2030253b1668ee4428823f879aa1d1408
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- 2.4.1
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.1.1)
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 (5.2.3)
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.5)
21
+ concurrent-ruby (1.1.6)
19
22
  diff-lcs (1.3)
20
- i18n (1.6.0)
23
+ i18n (1.8.2)
21
24
  concurrent-ruby (~> 1.0)
22
- minitest (5.11.3)
23
- rake (10.5.0)
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
- thor (0.20.3)
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.5)
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
- rake (~> 10.0)
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.1
62
+ 2.0.2
data/README.md CHANGED
@@ -1,55 +1,78 @@
1
1
  # TimeOverlap
2
2
 
3
- TODO: Add meeting time!!!!!!!!!!!!!!!!!!!
3
+ Command line tool which visualizes time overlap for distributed teams.
4
4
 
5
- Simple command line tool that allows to find overlap hours between two time zones, with visualization.
5
+ ## Features
6
6
 
7
- ```
8
- $ time_overlap count 8 16 +00:00 Bangkok 4
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
- ![screenshot](http://i68.tinypic.com/mi1npd.png)
13
+ ## Installation
12
14
 
13
- Assuming that you are in Bangkok and the target time zone is UTC +0
14
- and you want to cover 4 hours - from 8:00 to 16:00.
15
+ Install it yourself as:
15
16
 
16
- In most cases it suggests 2 options (cover first 4 hours: 8-12 or last: 12-16).
17
+ $ gem install time_overlap
17
18
 
18
- More info: https://www.daxx.com/blog/offshore-team/time-difference-offshore-development
19
+ ## Contents
19
20
 
20
- ## Installation
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
- Add this line to your application's Gemfile:
27
+ ## 1. Usage
23
28
 
24
- ```ruby
25
- gem 'time_overlap'
26
- ```
29
+ $ time_overlap help
27
30
 
28
- And then execute:
31
+ ## 2. Commands
29
32
 
30
- $ bundle
33
+ ### 2.1 light
31
34
 
32
- Or install it yourself as:
35
+ $ time_overlap light 9 17 London Hanoi Sydney
33
36
 
34
- $ gem install time_overlap
37
+ ![screenshot](img/light.png)
35
38
 
36
- ## Usage
39
+ ### 2.2 expert
37
40
 
41
+ $ time_overlap expert 9 17 4 London Hanoi Sydney
38
42
 
39
- ## Development
43
+ ![screenshot](img/expert.png)
40
44
 
41
- After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
45
+ ### 2.2 list
42
46
 
43
- To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
47
+ $ time_overlap list
44
48
 
45
- ## Contributing
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
- Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/time_overlap. 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.
66
+ ## Contributing
48
67
 
49
- ## License
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
- The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
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
- ## Code of Conduct
76
+ ## Copyright
54
77
 
55
- Everyone interacting in the TimeOverlap project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/time_overlap/blob/master/CODE_OF_CONDUCT.md).
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.count(*args)
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
- x_start_time = (start_time - offset * 60 * 60).in_time_zone(my_time_zone)
31
- x_end_time = (end_time - offset * 60 * 60).in_time_zone(my_time_zone)
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
- y_start_time = (end_time - min_overlap * 60 * 60).in_time_zone(my_time_zone)
34
- y_end_time = (y_start_time + duration * 60 * 60).in_time_zone(my_time_zone)
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: x_start_time,
47
- end: x_end_time
50
+ start: overlap_1_start_time,
51
+ end: overlap_1_end_time,
48
52
  },
49
53
  overlap_2: {
50
- start: y_start_time,
51
- end: y_end_time
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
- puts @data.inspect
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
- if x_start_time == y_start_time && x_end_time == y_end_time
71
+ unless @expert
72
+ @data.delete(:overlap_1)
58
73
  @data.delete(:overlap_2)
59
74
  end
60
75
 
61
- throw_errors!
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[time_zone]
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 'Wrong time_zone' if offset.nil?
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
@@ -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 'count',
7
- "Example: `time_overlap count 8 16 +00:00 Bangkok 4`'
8
- 8 -> from (hour, integer) \n
9
- 16 -> to (hour, integer)
10
- +00:00 -> target time zone
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 count(from, to, time_zone, my_time_zone, min_overlap)
15
- TimeOverlap::Calculator.count(
16
- from: from.to_i,
17
- to: to.to_i,
18
- time_zone: time_zone,
19
- my_time_zone: my_time_zone,
20
- min_overlap: min_overlap.to_i
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 ".freeze
7
- PM = " PM".freeze
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
- puts "Original:"
26
- puts "#{formated_time(@data[:original][:start], false)} - #{formated_time(@data[:original][:end])}".green
27
- timeline(@data[:original][:start], @data[:original][:end])
28
- puts "Full overlap:"
29
- puts "#{formated_time(@data[:full_overlap][:start], false)} - #{formated_time(@data[:full_overlap][:end])}".green
30
- timeline(@data[:full_overlap][:start], @data[:full_overlap][:end])
31
- puts "Overlap 1:"
32
- puts "#{formated_time(@data[:overlap_1][:start], false)} - #{formated_time(@data[:overlap_1][:end])}".green
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 separator
47
- puts (" " * 102)
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 formated_time(time, zone=true)
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.concat(" (%:z)") if zone
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
- print " "
78
- (0..23).each do |hour|
79
- printf("%-4s", hour)
80
- end
136
+ timeline = ""
137
+
138
+ timeline << " "
81
139
 
82
- puts ""
140
+ (0..23).map do |hour|
141
+ timeline << "%-4s" % hour
142
+ end
83
143
 
84
- print AM
144
+ timeline << "\n"
85
145
 
86
- (0..23).each do |hour|
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
- print with_color(AVAILABLE_SLOT, hour)
152
+ timeline << with_color(AVAILABLE_SLOT, hour)
95
153
  else
96
- print with_color(EMPTY_SLOT, hour)
154
+ timeline << with_color(EMPTY_SLOT, hour)
97
155
  end
98
156
  else
99
- print with_color(EMPTY_SLOT, hour)
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
- print with_color(AVAILABLE_SLOT, hour)
163
+ timeline << with_color(AVAILABLE_SLOT, hour)
106
164
  else
107
- print with_color(EMPTY_SLOT, hour)
165
+ timeline << with_color(EMPTY_SLOT, hour)
108
166
  end
109
167
  else
110
- print with_color(EMPTY_SLOT, hour)
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
- print with_color(AVAILABLE_SLOT, hour)
173
+ timeline << with_color(AVAILABLE_SLOT, hour)
116
174
  else
117
- print with_color(EMPTY_SLOT, hour)
175
+ timeline << with_color(EMPTY_SLOT, hour)
118
176
  end
119
177
  else
120
178
  if end_time.hour != hour
121
- print with_color(AVAILABLE_SLOT, hour)
179
+ timeline << with_color(AVAILABLE_SLOT, hour)
122
180
  else
123
- print with_color(EMPTY_SLOT, hour)
181
+ timeline << with_color(EMPTY_SLOT, hour)
124
182
  end
125
183
  end
126
184
  end
127
185
  end
128
186
  end
129
- print PM
130
- puts ""
131
- separator
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
@@ -1,3 +1,3 @@
1
1
  module TimeOverlap
2
- VERSION = "0.1.2"
2
+ VERSION = "0.2.0"
3
3
  end
data/lib/time_overlap.rb CHANGED
@@ -6,6 +6,8 @@ require "time_overlap/presenter"
6
6
  require "time_overlap/cli"
7
7
  require "time_overlap/calculator"
8
8
 
9
+ require "byebug"
10
+
9
11
  module TimeOverlap
10
12
 
11
13
  end
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", "~> 10.0"
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.1.2
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: 2019-07-19 00:00:00.000000000 Z
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: '10.0'
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: '10.0'
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
- rubyforge_project:
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.