isBooked 0.0.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 +7 -0
- data/lib/IsBooked.rb +60 -0
- data/lib/app.rb +72 -0
- data/lib/mockDb.rb +66 -0
- metadata +44 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: 89350c67b6d463204e0d23678d0e1f3cd5da61f4554ef976de5895333e76f8d7
|
|
4
|
+
data.tar.gz: dd3ea9f86fe1fc502b8b7adba2eba7de966881ca71ef9c0fdec9757aecd2a7e1
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: '0044948f78288c8ac761d649cbff73c36743341f306eabaafa0d3fdcc0cae721e587f4ea971a6ab000fbbb76643088da80ab65f2904a99dd33ff3a172943e16f'
|
|
7
|
+
data.tar.gz: 7e6aea3ce8bb6d1486cd24a228f79cd376368621e3f00de99b50abc1e4c1af19471e76d0be454dba3b5cff08049b36333914379625c79090b6a55bd8844849ff
|
data/lib/IsBooked.rb
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
require_relative 'mockDb'
|
|
2
|
+
require 'time'
|
|
3
|
+
|
|
4
|
+
ENV['TZ'] = 'UTC'
|
|
5
|
+
|
|
6
|
+
class IsBooked
|
|
7
|
+
def initialize(student, tutor, booking )
|
|
8
|
+
@student = student
|
|
9
|
+
@booking = booking
|
|
10
|
+
@tutor = tutor
|
|
11
|
+
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def get_student
|
|
15
|
+
return @student
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def get_booking
|
|
19
|
+
return @booking
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def get_tutor
|
|
23
|
+
return @tutor
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def get_dates_booked
|
|
27
|
+
return @tutor["dates_booked"]
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
#check if tutor is booked
|
|
31
|
+
#check if time booked falls in range of start time and stop time
|
|
32
|
+
#stop_time is calculated by adding 4 hours to start_time booked to represent a lesson block
|
|
33
|
+
#lesson blocks cannot exceed 4 hours
|
|
34
|
+
#if time falls within the slot, push date to bookings_array
|
|
35
|
+
#in addition, if end of session booked falls within a time tutor is booked, return false
|
|
36
|
+
#return true if length of bookings_array >= 1 else return false
|
|
37
|
+
def checkIfBooked
|
|
38
|
+
booking_start_time = Time.parse(get_booking["date"])
|
|
39
|
+
hours_booked = get_booking["hours_booked"].to_i
|
|
40
|
+
booking_stop_time = booking_start_time + (3600 * hours_booked)
|
|
41
|
+
dates_booked = get_tutor["dates_booked"]
|
|
42
|
+
lesson_block = 14400
|
|
43
|
+
bookings_array = []
|
|
44
|
+
dates_booked.each do |date|
|
|
45
|
+
start_time = Time.parse(date["date"])
|
|
46
|
+
stop_time = start_time + lesson_block
|
|
47
|
+
if(booking_start_time >= start_time && booking_start_time <= stop_time)
|
|
48
|
+
bookings_array.push(date)
|
|
49
|
+
elsif(start_time >= booking_start_time && start_time <= booking_stop_time)
|
|
50
|
+
bookings_array.push(date)
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
end
|
|
54
|
+
if(bookings_array.length >= 1)
|
|
55
|
+
return true
|
|
56
|
+
else
|
|
57
|
+
return false
|
|
58
|
+
end
|
|
59
|
+
end
|
|
60
|
+
end
|
data/lib/app.rb
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
require_relative "mockDb"
|
|
2
|
+
require_relative "IsBooked"
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
module TestCases
|
|
6
|
+
def self.check_has_student
|
|
7
|
+
self.init_isbooked
|
|
8
|
+
return @isBooked.get_student
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def self.check_is_student_hash
|
|
12
|
+
self.init_isbooked
|
|
13
|
+
return @isBooked.get_student.class
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def self.check_has_booking
|
|
17
|
+
self.init_isbooked
|
|
18
|
+
return @isBooked.get_booking
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
def self.check_is_booking_hash
|
|
22
|
+
self.init_isbooked
|
|
23
|
+
return @isBooked.get_booking.class
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def self.check_has_tutor
|
|
27
|
+
self.init_isbooked
|
|
28
|
+
return @isBooked.get_tutor
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
def self.check_is_tutor_hash
|
|
32
|
+
self.init_isbooked
|
|
33
|
+
return @isBooked.get_tutor.class
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
def self.check_if_tutor_has_dates_booked
|
|
37
|
+
self.init_isbooked
|
|
38
|
+
dates_booked = @isBooked.get_tutor["dates_booked"]
|
|
39
|
+
return dates_booked
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
def self.check_if_dates_booked_is_array
|
|
43
|
+
self.init_isbooked
|
|
44
|
+
dates_booked = @isBooked.get_tutor["dates_booked"]
|
|
45
|
+
return dates_booked.class
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
def self.check_if_dates_booked_is_set
|
|
49
|
+
self.init_isbooked
|
|
50
|
+
return @isBooked.get_dates_booked
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
def self.check_if_dates_booked_has_date_value
|
|
54
|
+
self.init_isbooked
|
|
55
|
+
return @isBooked.get_dates_booked[0].keys[0]
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
def self.check_if_booked
|
|
59
|
+
self.init_isbooked
|
|
60
|
+
return @isBooked.checkIfBooked
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
def self.init_isbooked
|
|
65
|
+
@isBooked = IsBooked.new(MockDb.student, MockDb.tutor, MockDb.booking)
|
|
66
|
+
end
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
#puts TestCases.check_if_dates_booked_is_set
|
|
70
|
+
@isBooked = IsBooked.new(MockDb.student, MockDb.tutor, MockDb.booking)
|
|
71
|
+
booking = @isBooked.checkIfBooked
|
|
72
|
+
puts booking
|
data/lib/mockDb.rb
ADDED
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
module MockDb
|
|
2
|
+
def self.student
|
|
3
|
+
return {
|
|
4
|
+
"education_level" => "University",
|
|
5
|
+
"description" => "A student ready to learn",
|
|
6
|
+
"subjects_of_interest" => [
|
|
7
|
+
{"subject" => "Mathematics", "competency" => "1"},
|
|
8
|
+
{"subject" => "Chemistry", "competency" => "2"},
|
|
9
|
+
{"subject" => "Finance" , "competency" => "3"}
|
|
10
|
+
],
|
|
11
|
+
"student_id" => "3"
|
|
12
|
+
}
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def self.booking
|
|
16
|
+
return {
|
|
17
|
+
"id" => "29",
|
|
18
|
+
"date" => "2019-12-09 14:30:00",
|
|
19
|
+
"location" => "{\"longitude\"=>\"-6.24315339120024\", \"latitude\"=>\"53...\"}",
|
|
20
|
+
"user_id" => "9",
|
|
21
|
+
"user_booked" => "13",
|
|
22
|
+
"hours_booked" => "2"
|
|
23
|
+
}
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def self.tutor
|
|
27
|
+
return {
|
|
28
|
+
"headline" => "I am a tutor",
|
|
29
|
+
"description" => "i am a professional Javascript instructor",
|
|
30
|
+
"years_teaching" => "3",
|
|
31
|
+
"teaching_style" => "Fast",
|
|
32
|
+
"work_experience" => [
|
|
33
|
+
{
|
|
34
|
+
"company" => "Apple",
|
|
35
|
+
"location" => "California",
|
|
36
|
+
"title" => "Product Designer",
|
|
37
|
+
"from" => "Tue, 05 Nov 2015",
|
|
38
|
+
"to" => "Wed, 10 Sept 2017"
|
|
39
|
+
}
|
|
40
|
+
],
|
|
41
|
+
"education" => [
|
|
42
|
+
{
|
|
43
|
+
"school" => "National College of Ireland",
|
|
44
|
+
"degree" => "MSc Cloud Computing",
|
|
45
|
+
"graduated" => "Fri, 12 Nov 2014"
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
],
|
|
49
|
+
"subjects" => [
|
|
50
|
+
"Javascript",
|
|
51
|
+
"Computing",
|
|
52
|
+
"Cloud Computing"
|
|
53
|
+
],
|
|
54
|
+
"user_id" => "13",
|
|
55
|
+
"dates_booked" => [
|
|
56
|
+
{"date"=>"Tue, 03 Dec 2019 19:00:00 +0000", "booked_by"=>9},
|
|
57
|
+
{"date"=>"Wed, 04 Dec 2019 19:00:00 +0000", "booked_by"=>9},
|
|
58
|
+
{"date"=>"Fri, 06 Dec 2019 12:15:00 +0000", "booked_by"=>9},
|
|
59
|
+
{"date"=>"Sat, 07 Dec 2019 09:30:00 +0000", "booked_by"=>9},
|
|
60
|
+
{"date"=>"Sun, 08 Dec 2019 13:30:00 +0000", "booked_by"=>9},
|
|
61
|
+
{"date"=>"Mon, 09 Dec 2019 16:30:00 +0000", "booked_by"=>9}
|
|
62
|
+
]
|
|
63
|
+
}
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: isBooked
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.0.0
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Femi Abdul
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: bin
|
|
10
|
+
cert_chain: []
|
|
11
|
+
date: 2019-12-04 00:00:00.000000000 Z
|
|
12
|
+
dependencies: []
|
|
13
|
+
description: A library to check of a tutor is booked on the bookatutor application
|
|
14
|
+
email: femi.abdul67@gmail.com
|
|
15
|
+
executables: []
|
|
16
|
+
extensions: []
|
|
17
|
+
extra_rdoc_files: []
|
|
18
|
+
files:
|
|
19
|
+
- lib/IsBooked.rb
|
|
20
|
+
- lib/app.rb
|
|
21
|
+
- lib/mockDb.rb
|
|
22
|
+
homepage: http://rubygems.org/gems/isBooked
|
|
23
|
+
licenses: []
|
|
24
|
+
metadata: {}
|
|
25
|
+
post_install_message:
|
|
26
|
+
rdoc_options: []
|
|
27
|
+
require_paths:
|
|
28
|
+
- lib
|
|
29
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
30
|
+
requirements:
|
|
31
|
+
- - ">="
|
|
32
|
+
- !ruby/object:Gem::Version
|
|
33
|
+
version: '0'
|
|
34
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
35
|
+
requirements:
|
|
36
|
+
- - ">="
|
|
37
|
+
- !ruby/object:Gem::Version
|
|
38
|
+
version: '0'
|
|
39
|
+
requirements: []
|
|
40
|
+
rubygems_version: 3.0.6
|
|
41
|
+
signing_key:
|
|
42
|
+
specification_version: 4
|
|
43
|
+
summary: Check of tutor is booked on the bookatutor app
|
|
44
|
+
test_files: []
|