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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 87691a9de20b669f0f555aa296d7b3bdca7a60ed8388760b2842a603d431eb9d
4
- data.tar.gz: d531edfa52945ea463d3ebb4beaee295a1f8e2e8122ebd3c83671dbde52bdc58
3
+ metadata.gz: 2ee8874189a13b9afe1a96fdbf374869d042dbee081c7e93d882a37a70cfdecb
4
+ data.tar.gz: 78705a44de3d72b5f6ee03a757698956d765f04d21429a4821b6c91ae869322a
5
5
  SHA512:
6
- metadata.gz: dae671c77e03776d70cb76e2b6811bcdbb0dd0570e502ecec0c633043aa9fb86268bb61430c12b0f9e562106661caa4300ba879d64a80f8603187e8a41eb3d6a
7
- data.tar.gz: d95d422495cf2deb9eb8879d5ae9f3dfe8e23ef3619723c1809e5e98df507c3967bf5dc34503a1ade345df020bc97aff35c48cbed131d706d90c3bb91d87631e
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
- source "https://rubygems.org"
1
+ # frozen_string_literal: true
2
2
 
3
- git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
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 (0.1.0)
4
+ slotty (1.1.0)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
8
8
  specs:
9
- diff-lcs (1.3)
10
- rake (10.5.0)
11
- rspec (3.9.0)
12
- rspec-core (~> 3.9.0)
13
- rspec-expectations (~> 3.9.0)
14
- rspec-mocks (~> 3.9.0)
15
- rspec-core (3.9.2)
16
- rspec-support (~> 3.9.3)
17
- rspec-expectations (3.9.1)
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.9.0)
20
- rspec-mocks (3.9.1)
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.9.0)
23
- rspec-support (3.9.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 (~> 1.17)
30
- rake (~> 10.0)
31
- rspec (~> 3.0)
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
- 1.17.2
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
- from: Time.new(2020, 05, 01, 8, 00),
26
- to: Time.new(2020, 05, 01, 11, 00),
27
- slot_length: 60 * 60,
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
- { start: Time.new(2020, 05, 01, 9, 01), end: Time.new(2020, 05, 01, 9, 59) },
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
@@ -1,6 +1,8 @@
1
- require "bundler/gem_tasks"
2
- require "rspec/core/rake_task"
1
+ # frozen_string_literal: true
2
+
3
+ require 'bundler/gem_tasks'
4
+ require 'rspec/core/rake_task'
3
5
 
4
6
  RSpec::Core::RakeTask.new(:spec)
5
7
 
6
- task :default => :spec
8
+ task default: :spec
data/bin/console CHANGED
@@ -1,7 +1,8 @@
1
1
  #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
2
3
 
3
- require "bundler/setup"
4
- require "slotty"
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 "irb"
14
+ require 'irb'
14
15
  IRB.start(__FILE__)
@@ -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
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Slotty
2
- VERSION = "0.1.0"
4
+ VERSION = '1.1.0'
3
5
  end
data/lib/slotty.rb CHANGED
@@ -1,32 +1,83 @@
1
- require "slotty/version"
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
- class Error < StandardError; end
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
- def get_slots(from:, to:, slot_length:, timeframe:, exclude_times: [])
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 = from..(from + slot_length)
57
+ potential_slot = Slot.new(range: for_range.begin..(for_range.begin + slot_length))
12
58
 
13
- while (from..to).cover?(potential_slot)
14
- if Validator.has_overlaps?(potential_slot, exclude_times)
15
- potential_slot = (potential_slot.begin + timeframe)..(potential_slot.begin + timeframe + slot_length)
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
- slots << {
21
- start_time: potential_slot.begin,
22
- end_time: potential_slot.end,
23
- time: potential_slot.begin.strftime('%H:%M %p')
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 = (potential_slot.begin + timeframe)..(potential_slot.begin + timeframe + slot_length)
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("../lib", __FILE__)
3
+ lib = File.expand_path('lib', __dir__)
3
4
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
- require "slotty/version"
5
+ require 'slotty/version'
5
6
 
6
7
  Gem::Specification.new do |spec|
7
- spec.name = "slotty"
8
+ spec.name = 'slotty'
8
9
  spec.version = Slotty::VERSION
9
- spec.authors = ["Hayden Rouille"]
10
- spec.email = ["hayden@rouille.dev"]
10
+ spec.authors = ['Hayden Rouille']
11
+ spec.email = ['hayden@rouille.dev']
11
12
 
12
- spec.summary = %q{Generate available slots between time ranges}
13
- spec.description = %q{Slotty will determine the available time slots for a given period, taking in a set of pre-existing busy periods and a timeframe of the appointment}
14
- spec.homepage = "https://github.com/haydenrou/slotty"
15
- spec.license = "MIT"
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 = Dir.chdir(File.expand_path('..', __FILE__)) do
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 = "exe"
26
+ spec.bindir = 'exe'
23
27
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
24
- spec.require_paths = ["lib"]
28
+ spec.require_paths = ['lib']
25
29
 
26
- spec.add_development_dependency "bundler", "~> 1.17"
27
- spec.add_development_dependency "rake", "~> 10.0"
28
- spec.add_development_dependency "rspec", "~> 3.0"
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: 0.1.0
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: 2020-05-06 00:00:00.000000000 Z
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: '1.17'
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: '1.17'
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: '10.0'
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: '10.0'
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.0'
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.0'
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 pre-existing busy periods and a timeframe of the appointment
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
- - ".travis.yml"
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/validator.rb
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: '0'
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.0.1
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
@@ -1,7 +0,0 @@
1
- ---
2
- sudo: false
3
- language: ruby
4
- cache: bundler
5
- rvm:
6
- - 2.6.1
7
- before_install: gem install bundler -v 1.17.2
@@ -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