slotty 0.1.0 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/rspec.yml +15 -0
- data/.github/workflows/rubocop.yml +16 -0
- data/.tool-versions +1 -0
- data/Gemfile +4 -2
- data/Gemfile.lock +48 -18
- data/README.md +8 -5
- data/Rakefile +5 -3
- data/bin/console +4 -3
- data/lib/slotty/slot.rb +50 -0
- data/lib/slotty/timeframe.rb +33 -0
- data/lib/slotty/version.rb +3 -1
- data/lib/slotty.rb +65 -14
- data/slotty-0.1.0.gem +0 -0
- data/slotty.gemspec +20 -15
- metadata +35 -16
- data/.travis.yml +0 -7
- data/lib/slotty/validator.rb +0 -21
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2ee8874189a13b9afe1a96fdbf374869d042dbee081c7e93d882a37a70cfdecb
|
4
|
+
data.tar.gz: 78705a44de3d72b5f6ee03a757698956d765f04d21429a4821b6c91ae869322a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4130703e7deb8854d6c401f844957207a777484db2c34f349497c05fffb843bf5ea7517d5a3baf79b3a37ca7fcb672df3e0c781e0f97e810d54d3f9bb06ac7ec
|
7
|
+
data.tar.gz: be3e2c84168c5e89c9ecc79632548f191165f288799ac56ee26ca601daeca02826e3f8869899a0a8262c65a23c856bbdcfbd6624f74ff59b9300eebc71549845
|
@@ -0,0 +1,15 @@
|
|
1
|
+
name: Run RSpec tests
|
2
|
+
on: [push]
|
3
|
+
jobs:
|
4
|
+
run-rspec-tests:
|
5
|
+
runs-on: ubuntu-latest
|
6
|
+
steps:
|
7
|
+
- uses: actions/checkout@v2
|
8
|
+
- name: Set up Ruby
|
9
|
+
uses: ruby/setup-ruby@v1
|
10
|
+
with:
|
11
|
+
ruby-version: 3.3.0
|
12
|
+
bundler-cache: true
|
13
|
+
- name: Run tests
|
14
|
+
run: |
|
15
|
+
bundle exec rspec
|
@@ -0,0 +1,16 @@
|
|
1
|
+
name: Run Rubocop
|
2
|
+
on: [push]
|
3
|
+
jobs:
|
4
|
+
run-rubocop:
|
5
|
+
runs-on: ubuntu-latest
|
6
|
+
steps:
|
7
|
+
- uses: actions/checkout@v2
|
8
|
+
- name: Set up Ruby
|
9
|
+
uses: ruby/setup-ruby@v1
|
10
|
+
with:
|
11
|
+
ruby-version: 3.3.0
|
12
|
+
bundler-cache: true
|
13
|
+
- name: Run rubocop
|
14
|
+
run: |
|
15
|
+
bundle exec rubocop
|
16
|
+
|
data/.tool-versions
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
ruby 3.3.0
|
data/Gemfile
CHANGED
@@ -1,6 +1,8 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
3
|
+
source 'https://rubygems.org'
|
4
|
+
|
5
|
+
git_source(:github) { |repo_name| "https://github.com/#{repo_name}" }
|
4
6
|
|
5
7
|
# Specify your gem's dependencies in slotty.gemspec
|
6
8
|
gemspec
|
data/Gemfile.lock
CHANGED
@@ -1,35 +1,65 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
slotty (
|
4
|
+
slotty (1.1.0)
|
5
5
|
|
6
6
|
GEM
|
7
7
|
remote: https://rubygems.org/
|
8
8
|
specs:
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
9
|
+
ast (2.4.2)
|
10
|
+
diff-lcs (1.5.1)
|
11
|
+
json (2.7.2)
|
12
|
+
language_server-protocol (3.17.0.3)
|
13
|
+
parallel (1.24.0)
|
14
|
+
parser (3.3.1.0)
|
15
|
+
ast (~> 2.4.1)
|
16
|
+
racc
|
17
|
+
racc (1.7.3)
|
18
|
+
rainbow (3.1.1)
|
19
|
+
rake (13.2.1)
|
20
|
+
regexp_parser (2.9.2)
|
21
|
+
rexml (3.2.8)
|
22
|
+
strscan (>= 3.0.9)
|
23
|
+
rspec (3.13.0)
|
24
|
+
rspec-core (~> 3.13.0)
|
25
|
+
rspec-expectations (~> 3.13.0)
|
26
|
+
rspec-mocks (~> 3.13.0)
|
27
|
+
rspec-core (3.13.0)
|
28
|
+
rspec-support (~> 3.13.0)
|
29
|
+
rspec-expectations (3.13.0)
|
18
30
|
diff-lcs (>= 1.2.0, < 2.0)
|
19
|
-
rspec-support (~> 3.
|
20
|
-
rspec-mocks (3.
|
31
|
+
rspec-support (~> 3.13.0)
|
32
|
+
rspec-mocks (3.13.1)
|
21
33
|
diff-lcs (>= 1.2.0, < 2.0)
|
22
|
-
rspec-support (~> 3.
|
23
|
-
rspec-support (3.
|
34
|
+
rspec-support (~> 3.13.0)
|
35
|
+
rspec-support (3.13.1)
|
36
|
+
rubocop (1.63.5)
|
37
|
+
json (~> 2.3)
|
38
|
+
language_server-protocol (>= 3.17.0)
|
39
|
+
parallel (~> 1.10)
|
40
|
+
parser (>= 3.3.0.2)
|
41
|
+
rainbow (>= 2.2.2, < 4.0)
|
42
|
+
regexp_parser (>= 1.8, < 3.0)
|
43
|
+
rexml (>= 3.2.5, < 4.0)
|
44
|
+
rubocop-ast (>= 1.31.1, < 2.0)
|
45
|
+
ruby-progressbar (~> 1.7)
|
46
|
+
unicode-display_width (>= 2.4.0, < 3.0)
|
47
|
+
rubocop-ast (1.31.3)
|
48
|
+
parser (>= 3.3.1.0)
|
49
|
+
ruby-progressbar (1.13.0)
|
50
|
+
strscan (3.1.0)
|
51
|
+
unicode-display_width (2.5.0)
|
24
52
|
|
25
53
|
PLATFORMS
|
54
|
+
arm64-darwin-23
|
26
55
|
ruby
|
27
56
|
|
28
57
|
DEPENDENCIES
|
29
|
-
bundler (~>
|
30
|
-
rake (~>
|
31
|
-
rspec (~> 3.
|
58
|
+
bundler (~> 2.5.9)
|
59
|
+
rake (~> 13.2.1)
|
60
|
+
rspec (~> 3.13)
|
61
|
+
rubocop (~> 1.63)
|
32
62
|
slotty!
|
33
63
|
|
34
64
|
BUNDLED WITH
|
35
|
-
|
65
|
+
2.5.9
|
data/README.md
CHANGED
@@ -1,4 +1,6 @@
|
|
1
1
|
# Slotty
|
2
|
+
[![Rubocop](https://github.com/haydenrou/slotty/actions/workflows/rubocop.yml/badge.svg)](https://github.com/haydenrou/slotty/actions/workflows/rubocop.yml/badge.svg)
|
3
|
+
[![Rspec](https://github.com/haydenrou/slotty/actions/workflows/rspec.yml/badge.svg)](https://github.com/haydenrou/slotty/actions/workflows/rspec.yml/badge.svg)
|
2
4
|
|
3
5
|
Slotty provides a way of determining available slots within a time frame. An example would be where a service provider needs to take bookings.
|
4
6
|
|
@@ -22,12 +24,11 @@ Or install it yourself as:
|
|
22
24
|
|
23
25
|
```ruby
|
24
26
|
Slotty.get_slots(
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
timeframe: 15 * 60,
|
27
|
+
for_range: Time.new(2020, 05, 01, 8, 00)..Time.new(2020, 05, 01, 11, 00),
|
28
|
+
slot_length_mins: 60,
|
29
|
+
interval_mins: 15,
|
29
30
|
exclude_times: [
|
30
|
-
|
31
|
+
Time.new(2020, 05, 01, 9, 00)..Time.new(2020, 05, 01, 10, 00)
|
31
32
|
]
|
32
33
|
)
|
33
34
|
|
@@ -45,6 +46,8 @@ Slotty.get_slots(
|
|
45
46
|
# ]
|
46
47
|
```
|
47
48
|
|
49
|
+
If you want to just receive the human times back (i.e. "10:00 AM"), you can pass `for: :to_s` to `#get_slots`
|
50
|
+
|
48
51
|
## Development
|
49
52
|
|
50
53
|
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.
|
data/Rakefile
CHANGED
data/bin/console
CHANGED
@@ -1,7 +1,8 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
2
3
|
|
3
|
-
require
|
4
|
-
require
|
4
|
+
require 'bundler/setup'
|
5
|
+
require 'slotty'
|
5
6
|
|
6
7
|
# You can add fixtures and/or initialization code here to make experimenting
|
7
8
|
# with your gem easier. You can also use a different console, if you like.
|
@@ -10,5 +11,5 @@ require "slotty"
|
|
10
11
|
# require "pry"
|
11
12
|
# Pry.start
|
12
13
|
|
13
|
-
require
|
14
|
+
require 'irb'
|
14
15
|
IRB.start(__FILE__)
|
data/lib/slotty/slot.rb
ADDED
@@ -0,0 +1,50 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'slotty/timeframe'
|
4
|
+
|
5
|
+
module Slotty
|
6
|
+
# The Slot class represents a time slot and provides methods to check
|
7
|
+
# for overlaps with excluded slots and to format the time slot as a string.
|
8
|
+
class Slot
|
9
|
+
attr_reader :range, :begin, :end
|
10
|
+
|
11
|
+
# Initializes a Slot instance with a specified range.
|
12
|
+
#
|
13
|
+
# @param range [Range] The time range for the slot.
|
14
|
+
def initialize(range:)
|
15
|
+
@range = range
|
16
|
+
@begin = range.begin
|
17
|
+
@end = range.end
|
18
|
+
end
|
19
|
+
|
20
|
+
# Checks if the slot has overlaps with any of the excluded slots.
|
21
|
+
#
|
22
|
+
# @param excluded_slots [Array<Range>] An array of ranges representing excluded slots.
|
23
|
+
# @return [Boolean] true if there are overlaps with any excluded slots, otherwise false.
|
24
|
+
def overlaps?(excluded_slots = [])
|
25
|
+
return false if excluded_slots.empty?
|
26
|
+
|
27
|
+
excluded_slots.any? do |exc_slot|
|
28
|
+
Timeframe.contains?(exc_slot, range)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
# Returns the start time of the slot formatted as a string.
|
33
|
+
#
|
34
|
+
# @return [String] The formatted start time of the slot.
|
35
|
+
def to_s
|
36
|
+
range.begin.strftime('%I:%M %p')
|
37
|
+
end
|
38
|
+
|
39
|
+
# Returns a hash representation of the slot with detailed time information.
|
40
|
+
#
|
41
|
+
# @return [Hash] A hash containing the start time, end time, and formatted time.
|
42
|
+
def full
|
43
|
+
{
|
44
|
+
start_time: range.begin,
|
45
|
+
end_time: range.end,
|
46
|
+
time: to_s
|
47
|
+
}
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Slotty
|
4
|
+
# The Timeframe class provides methods to determine if one time range
|
5
|
+
# covers or contains another time range.
|
6
|
+
class Timeframe
|
7
|
+
class << self
|
8
|
+
# Determines if the surrounding_range completely covers the included_range.
|
9
|
+
#
|
10
|
+
# @param surrounding_range [Range] The range that is expected to cover the other.
|
11
|
+
# @param included_range [Range] The range that is expected to be covered.
|
12
|
+
# @return [Boolean] true if surrounding_range covers included_range, otherwise false.
|
13
|
+
def covers?(surrounding_range, included_range)
|
14
|
+
starts_before = surrounding_range.begin <= included_range.begin
|
15
|
+
ends_after = surrounding_range.end >= included_range.end
|
16
|
+
|
17
|
+
starts_before && ends_after
|
18
|
+
end
|
19
|
+
|
20
|
+
# Determines if the potential_slot is contained within the excluder range.
|
21
|
+
#
|
22
|
+
# @param excluder [Range] The range that potentially excludes another.
|
23
|
+
# @param potential_slot [Range] The range that is expected to be contained.
|
24
|
+
# @return [Boolean] true if potential_slot is within excluder, otherwise false.
|
25
|
+
def contains?(excluder, potential_slot)
|
26
|
+
start_within = potential_slot.begin >= excluder.begin && potential_slot.begin < excluder.end
|
27
|
+
end_within = potential_slot.end > excluder.begin && potential_slot.end <= excluder.end
|
28
|
+
|
29
|
+
start_within || end_within
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
data/lib/slotty/version.rb
CHANGED
data/lib/slotty.rb
CHANGED
@@ -1,32 +1,83 @@
|
|
1
|
-
|
2
|
-
require "slotty/validator"
|
1
|
+
# frozen_string_literal: true
|
3
2
|
|
3
|
+
require 'slotty/version'
|
4
|
+
require 'slotty/timeframe'
|
5
|
+
require 'slotty/slot'
|
6
|
+
|
7
|
+
# The Slotty module provides methods to generate time slots based on a specified
|
8
|
+
# range, slot length, and interval. It also allows for excluding specific time
|
9
|
+
# slots from the generated list.
|
4
10
|
module Slotty
|
5
|
-
|
11
|
+
InvalidFormatError = Class.new(StandardError)
|
12
|
+
InvalidDateError = Class.new(StandardError)
|
13
|
+
InvalidSlotLengthError = Class.new(StandardError)
|
14
|
+
InvalidIntervalError = Class.new(StandardError)
|
15
|
+
InvalidExclusionError = Class.new(StandardError)
|
6
16
|
|
7
17
|
class << self
|
8
|
-
|
18
|
+
# Retrieves available slots within a specified range, considering slot length,
|
19
|
+
# interval between slots, and any times to be excluded.
|
20
|
+
#
|
21
|
+
# @param for_range [Range] The range within which to generate slots.
|
22
|
+
# @param slot_length_mins [Integer] The length of each slot in minutes.
|
23
|
+
# @param interval_mins [Integer] The interval between the start of each slot in minutes.
|
24
|
+
# @param as [Symbol] The format in which to return the slots (:full by default).
|
25
|
+
# @param exclude_times [Array<Range>] An array of time ranges to be excluded.
|
26
|
+
# @raise [InvalidDateError] If for_range is not a Range.
|
27
|
+
# @raise [InvalidSlotLengthError] If slot_length_mins is not an integer.
|
28
|
+
# @raise [InvalidIntervalError] If interval_mins is not an integer.
|
29
|
+
# @raise [InvalidExclusionError] If exclude_times is not an array of ranges.
|
30
|
+
# @raise [InvalidFormatError] If the format specified in `as` is invalid.
|
31
|
+
# @return [Array<Object>] An array of slots in the specified format.
|
32
|
+
# rubocop:disable Metrics/MethodLength
|
33
|
+
# rubocop:disable Metrics/AbcSize
|
34
|
+
# rubocop:disable Metrics/CyclomaticComplexity
|
35
|
+
# rubocop:disable Metrics/PerceivedComplexity
|
36
|
+
def get_slots(for_range:,
|
37
|
+
slot_length_mins:,
|
38
|
+
interval_mins:,
|
39
|
+
as: :full,
|
40
|
+
exclude_times: [])
|
41
|
+
raise InvalidDateError, 'for_value must be type of Range' unless for_range.is_a?(Range)
|
42
|
+
raise InvalidSlotLengthError, 'slot_length_mins must be an integer' unless slot_length_mins.is_a?(Integer)
|
43
|
+
raise InvalidIntervalError, 'interval_mins must be an integer' unless interval_mins.is_a?(Integer)
|
44
|
+
|
45
|
+
unless exclude_times.is_a?(Array) && exclude_times.all? do |t|
|
46
|
+
t.is_a?(Range)
|
47
|
+
end
|
48
|
+
raise InvalidExclusionError,
|
49
|
+
'exclude_times must be an array of time ranges'
|
50
|
+
end
|
51
|
+
|
52
|
+
slot_length = slot_length_mins * 60
|
53
|
+
interval = interval_mins * 60
|
54
|
+
|
9
55
|
slots = Array.new(0)
|
10
56
|
|
11
|
-
potential_slot =
|
57
|
+
potential_slot = Slot.new(range: for_range.begin..(for_range.begin + slot_length))
|
12
58
|
|
13
|
-
while
|
14
|
-
if
|
15
|
-
|
59
|
+
while Timeframe.covers?(for_range, potential_slot)
|
60
|
+
if potential_slot.overlaps?(exclude_times)
|
61
|
+
range = (potential_slot.begin + interval)..(potential_slot.begin + interval + slot_length)
|
62
|
+
potential_slot = Slot.new(range:)
|
16
63
|
|
17
64
|
next
|
18
65
|
end
|
19
66
|
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
67
|
+
raise InvalidFormatError, 'cannot format slot in this way' unless potential_slot.respond_to?(as)
|
68
|
+
|
69
|
+
slots << potential_slot.send(as)
|
70
|
+
|
71
|
+
range = (potential_slot.begin + interval)..(potential_slot.begin + interval + slot_length)
|
25
72
|
|
26
|
-
potential_slot =
|
73
|
+
potential_slot = Slot.new(range:)
|
27
74
|
end
|
28
75
|
|
29
76
|
slots
|
30
77
|
end
|
78
|
+
# rubocop:enable Metrics/MethodLength
|
79
|
+
# rubocop:enable Metrics/AbcSize
|
80
|
+
# rubocop:enable Metrics/CyclomaticComplexity
|
81
|
+
# rubocop:enable Metrics/PerceivedComplexity
|
31
82
|
end
|
32
83
|
end
|
data/slotty-0.1.0.gem
ADDED
Binary file
|
data/slotty.gemspec
CHANGED
@@ -1,29 +1,34 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
|
2
|
-
lib = File.expand_path(
|
3
|
+
lib = File.expand_path('lib', __dir__)
|
3
4
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
-
require
|
5
|
+
require 'slotty/version'
|
5
6
|
|
6
7
|
Gem::Specification.new do |spec|
|
7
|
-
spec.name =
|
8
|
+
spec.name = 'slotty'
|
8
9
|
spec.version = Slotty::VERSION
|
9
|
-
spec.authors = [
|
10
|
-
spec.email = [
|
10
|
+
spec.authors = ['Hayden Rouille']
|
11
|
+
spec.email = ['hayden@rouille.dev']
|
11
12
|
|
12
|
-
spec.summary =
|
13
|
-
spec.description =
|
14
|
-
|
15
|
-
spec.
|
13
|
+
spec.summary = 'Generate available slots between time ranges'
|
14
|
+
spec.description = "Slotty will determine the available time slots for a given period, taking in a set of \
|
15
|
+
pre-existing busy periods and a timeframe of the appointment"
|
16
|
+
spec.homepage = 'https://github.com/haydenrou/slotty'
|
17
|
+
spec.license = 'MIT'
|
18
|
+
|
19
|
+
spec.required_ruby_version = '>= 3.3.0'
|
16
20
|
|
17
21
|
# Specify which files should be added to the gem when it is released.
|
18
22
|
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
19
|
-
spec.files
|
23
|
+
spec.files = Dir.chdir(File.expand_path(__dir__)) do
|
20
24
|
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
21
25
|
end
|
22
|
-
spec.bindir =
|
26
|
+
spec.bindir = 'exe'
|
23
27
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
24
|
-
spec.require_paths = [
|
28
|
+
spec.require_paths = ['lib']
|
25
29
|
|
26
|
-
spec.add_development_dependency
|
27
|
-
spec.add_development_dependency
|
28
|
-
spec.add_development_dependency
|
30
|
+
spec.add_development_dependency 'bundler', '~> 2.5.9'
|
31
|
+
spec.add_development_dependency 'rake', '~> 13.2.1'
|
32
|
+
spec.add_development_dependency 'rspec', '~> 3.13'
|
33
|
+
spec.add_development_dependency 'rubocop', '~> 1.63'
|
29
34
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: slotty
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Hayden Rouille
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-05-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -16,53 +16,70 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
19
|
+
version: 2.5.9
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version:
|
26
|
+
version: 2.5.9
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rake
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version:
|
33
|
+
version: 13.2.1
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version:
|
40
|
+
version: 13.2.1
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: rspec
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
45
|
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: '3.
|
47
|
+
version: '3.13'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: '3.
|
54
|
+
version: '3.13'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rubocop
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '1.63'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '1.63'
|
55
69
|
description: Slotty will determine the available time slots for a given period, taking
|
56
|
-
in a set of
|
70
|
+
in a set of pre-existing busy periods and a timeframe of
|
71
|
+
the appointment
|
57
72
|
email:
|
58
73
|
- hayden@rouille.dev
|
59
74
|
executables: []
|
60
75
|
extensions: []
|
61
76
|
extra_rdoc_files: []
|
62
77
|
files:
|
78
|
+
- ".github/workflows/rspec.yml"
|
79
|
+
- ".github/workflows/rubocop.yml"
|
63
80
|
- ".gitignore"
|
64
81
|
- ".rspec"
|
65
|
-
- ".
|
82
|
+
- ".tool-versions"
|
66
83
|
- CODE_OF_CONDUCT.md
|
67
84
|
- Gemfile
|
68
85
|
- Gemfile.lock
|
@@ -72,14 +89,16 @@ files:
|
|
72
89
|
- bin/console
|
73
90
|
- bin/setup
|
74
91
|
- lib/slotty.rb
|
75
|
-
- lib/slotty/
|
92
|
+
- lib/slotty/slot.rb
|
93
|
+
- lib/slotty/timeframe.rb
|
76
94
|
- lib/slotty/version.rb
|
95
|
+
- slotty-0.1.0.gem
|
77
96
|
- slotty.gemspec
|
78
97
|
homepage: https://github.com/haydenrou/slotty
|
79
98
|
licenses:
|
80
99
|
- MIT
|
81
100
|
metadata: {}
|
82
|
-
post_install_message:
|
101
|
+
post_install_message:
|
83
102
|
rdoc_options: []
|
84
103
|
require_paths:
|
85
104
|
- lib
|
@@ -87,15 +106,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
87
106
|
requirements:
|
88
107
|
- - ">="
|
89
108
|
- !ruby/object:Gem::Version
|
90
|
-
version:
|
109
|
+
version: 3.3.0
|
91
110
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
92
111
|
requirements:
|
93
112
|
- - ">="
|
94
113
|
- !ruby/object:Gem::Version
|
95
114
|
version: '0'
|
96
115
|
requirements: []
|
97
|
-
rubygems_version: 3.
|
98
|
-
signing_key:
|
116
|
+
rubygems_version: 3.5.3
|
117
|
+
signing_key:
|
99
118
|
specification_version: 4
|
100
119
|
summary: Generate available slots between time ranges
|
101
120
|
test_files: []
|
data/.travis.yml
DELETED
data/lib/slotty/validator.rb
DELETED
@@ -1,21 +0,0 @@
|
|
1
|
-
module Slotty
|
2
|
-
class Validator
|
3
|
-
class << self
|
4
|
-
def has_overlaps?(slot, excluded_slots = [])
|
5
|
-
return false if excluded_slots.empty?
|
6
|
-
|
7
|
-
excluded_slots.any? do |excluder|
|
8
|
-
excluder_overlaps_slot_start = (excluder[:start]..excluder[:end]).include? slot.begin
|
9
|
-
excluder_overlaps_slot_end = (excluder[:start]..excluder[:end]).include? slot.end
|
10
|
-
slot_overlaps_excluder_start = (slot.begin..slot.end).include? excluder[:start]
|
11
|
-
slot_overlaps_excluder_end = (slot.begin..slot.end).include? excluder[:end]
|
12
|
-
|
13
|
-
excluder_overlaps_slot_start |
|
14
|
-
excluder_overlaps_slot_end |
|
15
|
-
slot_overlaps_excluder_start |
|
16
|
-
slot_overlaps_excluder_end
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|