touringplans 0.2.5 → 0.3.1
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 +4 -4
- data/.version +1 -1
- data/lib/routes.yml +919 -0
- data/lib/touringplans/version.rb +1 -1
- data/lib/touringplans.rb +407 -81
- metadata +3 -2
data/lib/touringplans/version.rb
CHANGED
data/lib/touringplans.rb
CHANGED
@@ -12,14 +12,6 @@ module Touringplans
|
|
12
12
|
include Dry.Types()
|
13
13
|
end
|
14
14
|
|
15
|
-
include HTTParty
|
16
|
-
# currently Touring Plans has no verision in its API
|
17
|
-
DEFAULT_API_VERSION = "1"
|
18
|
-
DEFAULT_BASE_URI = "https://touringplans.com/"
|
19
|
-
DEFAULT_QUERY = {}
|
20
|
-
|
21
|
-
base_uri DEFAULT_BASE_URI
|
22
|
-
|
23
15
|
ROUTES = {
|
24
16
|
magic_kingdom_dining: {
|
25
17
|
method: "get",
|
@@ -80,8 +72,13 @@ module Touringplans
|
|
80
72
|
walt_disney_world_disney_springs_resorts: {
|
81
73
|
method: "get",
|
82
74
|
path: "/walt-disney-world/hotels.json"
|
83
|
-
}
|
84
|
-
}
|
75
|
+
}
|
76
|
+
}.freeze
|
77
|
+
|
78
|
+
def self.routes
|
79
|
+
ROUTES
|
80
|
+
end
|
81
|
+
|
85
82
|
# deals solely with how to create access to the resource, the lock of "lock & key"
|
86
83
|
class Connection
|
87
84
|
# concerned only on where it gets the info it needs
|
@@ -91,6 +88,7 @@ module Touringplans
|
|
91
88
|
# currently Touring Plans has no verision in its API
|
92
89
|
DEFAULT_API_VERSION = "1"
|
93
90
|
DEFAULT_BASE_URI = "https://touringplans.com/"
|
91
|
+
# do not freeze DEFAULT_QUERY
|
94
92
|
DEFAULT_QUERY = {}
|
95
93
|
|
96
94
|
base_uri DEFAULT_BASE_URI
|
@@ -153,6 +151,132 @@ module Touringplans
|
|
153
151
|
end
|
154
152
|
end
|
155
153
|
|
154
|
+
# Generates and updates routes for all types of venues in a YAML document.
|
155
|
+
class RoutesTable
|
156
|
+
require "fileutils"
|
157
|
+
def initialize(filename: "routes_table.yml")
|
158
|
+
@filename = filename
|
159
|
+
end
|
160
|
+
|
161
|
+
def self.original_routes
|
162
|
+
# this method exists so that we can create a yaml file of routes
|
163
|
+
tpr = Touringplans.routes
|
164
|
+
# convert symbols back to strings
|
165
|
+
stringify_keys(tpr)
|
166
|
+
# rt_keys = tpr.keys
|
167
|
+
# rt_values = tpr.values
|
168
|
+
# string_keys = []
|
169
|
+
|
170
|
+
# rt_keys.each {|k| string_keys << k.to_s}
|
171
|
+
# # create new hash with string keys
|
172
|
+
# string_keys.zip(rt_values).to_h
|
173
|
+
end
|
174
|
+
|
175
|
+
def self.symbolize_keys(hash)
|
176
|
+
hash.each_with_object({}) do |(key, value), result|
|
177
|
+
new_key = case key
|
178
|
+
when String then key.to_sym
|
179
|
+
else key
|
180
|
+
end
|
181
|
+
new_value = case value
|
182
|
+
when Hash then symbolize_keys(value)
|
183
|
+
else value
|
184
|
+
end
|
185
|
+
result[new_key] = new_value
|
186
|
+
end
|
187
|
+
end
|
188
|
+
|
189
|
+
def self.stringify_keys(hash)
|
190
|
+
# inspired by https://avdi.codes/recursively-symbolize-keys/
|
191
|
+
hash.each_with_object({}) do |(key, value), result|
|
192
|
+
new_key = case key
|
193
|
+
when Symbol then key.to_s
|
194
|
+
else key
|
195
|
+
end
|
196
|
+
new_value = case value
|
197
|
+
when Hash then stringify_keys(value)
|
198
|
+
else value
|
199
|
+
end
|
200
|
+
result[new_key] = new_value
|
201
|
+
end
|
202
|
+
end
|
203
|
+
|
204
|
+
def self.load_routes_file(routes_relative_file_path: "/routes.yml")
|
205
|
+
tp_path = $LOAD_PATH.grep(/touringplans/).last
|
206
|
+
routes_file = "#{tp_path}#{routes_relative_file_path}"
|
207
|
+
YAML.safe_load(File.read(routes_file))
|
208
|
+
end
|
209
|
+
|
210
|
+
def self.update_file
|
211
|
+
# gather info into hashes
|
212
|
+
attractions_routes = _generate_interest_routes_hash("attractions")
|
213
|
+
dining_routes = _generate_interest_routes_hash("dining")
|
214
|
+
hotels_routes = _generate_interest_routes_hash("hotels")
|
215
|
+
updated_routes = original_routes.merge(attractions_routes, dining_routes, hotels_routes)
|
216
|
+
|
217
|
+
updated_routes_yaml = _convert_hash_to_yaml(updated_routes)
|
218
|
+
|
219
|
+
file = _initialize_file
|
220
|
+
_save_content_to_file(file, updated_routes_yaml)
|
221
|
+
end
|
222
|
+
|
223
|
+
def self._initialize_file
|
224
|
+
# delete old file if it exits
|
225
|
+
lib_dir = FileUtils.getwd + "/lib"
|
226
|
+
routes_file = "#{lib_dir}/routes.yml"
|
227
|
+
|
228
|
+
# ensure the file exists
|
229
|
+
touched_routes_file_array = FileUtils.touch(routes_file)
|
230
|
+
# we want the first string value
|
231
|
+
touched_routes_file_array.first
|
232
|
+
end
|
233
|
+
|
234
|
+
def self._generate_interest_routes_hash(interest)
|
235
|
+
interest_venues = Touringplans.list_all(interest)
|
236
|
+
interest_routes = {}
|
237
|
+
|
238
|
+
interest_venues.each do |iv|
|
239
|
+
new_route = _generate_interest_route(iv.venue_permalink, interest, iv.permalink)
|
240
|
+
key = new_route.keys.first
|
241
|
+
values = new_route[key]
|
242
|
+
interest_routes[key] = values
|
243
|
+
end
|
244
|
+
|
245
|
+
interest_routes
|
246
|
+
end
|
247
|
+
|
248
|
+
def self._generate_interest_route(venue_permalink, interest_permalink, place_permalink)
|
249
|
+
# {magic_kingdom_attractions_haunted_mansion: {
|
250
|
+
# method: "get",
|
251
|
+
# path: "/magic-kingdom/attractions/haunted-mansion.json"
|
252
|
+
# }
|
253
|
+
# }
|
254
|
+
path = "/#{venue_permalink}/#{interest_permalink}/#{place_permalink}"
|
255
|
+
key = path.to_s.downcase.gsub("/", " ").gsub("-", " ").strip
|
256
|
+
key = key.gsub(" ", "_")
|
257
|
+
method = "get"
|
258
|
+
format = "json"
|
259
|
+
|
260
|
+
{ key => { "method".to_s => method,
|
261
|
+
"path".to_s => "#{path}.#{format}" } }
|
262
|
+
end
|
263
|
+
|
264
|
+
def self._convert_hash_to_yaml(hash)
|
265
|
+
hash.to_yaml
|
266
|
+
end
|
267
|
+
|
268
|
+
def self._save_content_to_file(file, content)
|
269
|
+
new_file = File.open(file, "w")
|
270
|
+
new_file.write(content)
|
271
|
+
new_file.close
|
272
|
+
end
|
273
|
+
|
274
|
+
def self._read_file_to_terminal(file)
|
275
|
+
new_file = File.open(file, "r")
|
276
|
+
new_file.close
|
277
|
+
end
|
278
|
+
end
|
279
|
+
|
156
280
|
# model with the attributes
|
157
281
|
class CounterServiceLocation < Dry::Struct
|
158
282
|
transform_keys(&:to_sym)
|
@@ -212,7 +336,7 @@ module Touringplans
|
|
212
336
|
attribute :kosher_available, Types::Params::Bool
|
213
337
|
attribute :dinable_id, Types::Params::Integer
|
214
338
|
attribute :dinable_type, Types::String.optional
|
215
|
-
attribute :venue_permalink, Types::String.optional
|
339
|
+
attribute :venue_permalink, Types::String.optional
|
216
340
|
end
|
217
341
|
|
218
342
|
# model with the attributes
|
@@ -245,11 +369,11 @@ module Touringplans
|
|
245
369
|
attribute :house_specialties, Types::String.optional
|
246
370
|
attribute :counter_quality_rating, Types::String.optional
|
247
371
|
attribute :counter_value_rating, Types::String.optional
|
248
|
-
attribute :table_quality_rating, Types::Params::
|
249
|
-
attribute :table_value_rating, Types::Params::
|
250
|
-
attribute :overall_rating, Types::Params::
|
251
|
-
attribute :service_rating, Types::Params::
|
252
|
-
attribute :friendliness_rating, Types::Params::
|
372
|
+
attribute :table_quality_rating, Types::Params::Float.optional
|
373
|
+
attribute :table_value_rating, Types::Params::Float.optional
|
374
|
+
attribute :overall_rating, Types::Params::Float.optional
|
375
|
+
attribute :service_rating, Types::Params::Float.optional
|
376
|
+
attribute :friendliness_rating, Types::Params::Float.optional
|
253
377
|
attribute :adult_breakfast_menu_url, Types::String.optional
|
254
378
|
attribute :adult_lunch_menu_url, Types::String.optional
|
255
379
|
attribute :adult_dinner_menu_url, Types::String.optional
|
@@ -277,6 +401,70 @@ module Touringplans
|
|
277
401
|
attribute :venue_permalink, Types::String.optional
|
278
402
|
end
|
279
403
|
|
404
|
+
# model with the attributes
|
405
|
+
class DiningVenueFull < Dry::Struct
|
406
|
+
transform_keys(&:to_sym)
|
407
|
+
|
408
|
+
attribute :name, Types::String
|
409
|
+
attribute :permalink, Types::String
|
410
|
+
attribute :category_code, Types::String
|
411
|
+
attribute :portion_size, Types::String.optional
|
412
|
+
attribute :cost_code, Types::String.optional
|
413
|
+
attribute :cuisine, Types::String
|
414
|
+
attribute :phone_number, Types::String.optional
|
415
|
+
attribute :entree_range, Types::String.optional
|
416
|
+
attribute :when_to_go, Types::String.optional
|
417
|
+
attribute :parking, Types::String.optional
|
418
|
+
attribute :bar, Types::String.optional
|
419
|
+
attribute :wine_list, Types::String.optional
|
420
|
+
attribute :dress, Types::String.optional
|
421
|
+
attribute :awards, Types::String.optional
|
422
|
+
attribute :breakfast_hours, Types::String.optional
|
423
|
+
attribute :lunch_hours, Types::String.optional
|
424
|
+
attribute :dinner_hours, Types::String.optional
|
425
|
+
attribute :house_specialties, Types::String.optional
|
426
|
+
attribute :counter_quality_rating, Types::String.optional
|
427
|
+
attribute :counter_value_rating, Types::String.optional
|
428
|
+
attribute :table_quality_rating, Types::Float.optional
|
429
|
+
attribute :table_value_rating, Types::Float.optional
|
430
|
+
attribute :overall_rating, Types::Float.optional
|
431
|
+
attribute :service_rating, Types::Float.optional
|
432
|
+
attribute :friendliness_rating, Types::Float.optional
|
433
|
+
attribute :adult_breakfast_menu_url, Types::String.optional
|
434
|
+
attribute :adult_lunch_menu_url, Types::String.optional
|
435
|
+
attribute :adult_dinner_menu_url, Types::String.optional
|
436
|
+
attribute :child_breakfast_menu_url, Types::String.optional
|
437
|
+
attribute :child_lunch_menu_url, Types::String.optional
|
438
|
+
attribute :child_dinner_menu_url, Types::String.optional
|
439
|
+
attribute :requires_credit_card, Types::Params::Bool
|
440
|
+
attribute :requires_pre_payment, Types::Params::Bool
|
441
|
+
attribute :created_at, Types::Params::DateTime
|
442
|
+
attribute :updated_at, Types::Params::DateTime
|
443
|
+
attribute :extinct_on, Types::Params::DateTime.optional
|
444
|
+
attribute :opened_on, Types::Params::DateTime.optional
|
445
|
+
attribute :disney_permalink, Types::String.optional
|
446
|
+
attribute :code, Types::String.optional
|
447
|
+
attribute :short_name, Types::String.optional
|
448
|
+
attribute :accepts_reservations, Types::Params::Bool
|
449
|
+
attribute :kosher_available, Types::Params::Bool
|
450
|
+
|
451
|
+
attribute :operator_id, Types::Integer
|
452
|
+
attribute :operator_url, Types::String.optional
|
453
|
+
attribute :operator_type, Types::String.optional
|
454
|
+
attribute :walking_time_proxy_id, Types::String.optional
|
455
|
+
attribute :sort_name, Types::String.optional
|
456
|
+
attribute :mobile_ordering, Types::Bool.optional
|
457
|
+
attribute :extinct_on_uncertain, Types::String.optional
|
458
|
+
attribute :opened_on_uncertain, Types::String.optional
|
459
|
+
attribute :opened_on_known, Types::String.optional
|
460
|
+
attribute :operational_notes, Types::String.optional
|
461
|
+
attribute :latitude, Types::String.optional
|
462
|
+
attribute :longitude, Types::String.optional
|
463
|
+
attribute :summary_at_top, Types::Bool.optional
|
464
|
+
|
465
|
+
end
|
466
|
+
|
467
|
+
|
280
468
|
# model with the attributes
|
281
469
|
class ParkAttraction < Dry::Struct
|
282
470
|
transform_keys(&:to_sym)
|
@@ -285,7 +473,91 @@ module Touringplans
|
|
285
473
|
attribute :short_name, Types::String
|
286
474
|
attribute :permalink, Types::String
|
287
475
|
attribute :venue_permalink, Types::String
|
288
|
-
|
476
|
+
end
|
477
|
+
|
478
|
+
# model with the attributes
|
479
|
+
class ParkAttractionFull < Dry::Struct
|
480
|
+
transform_keys(&:to_sym)
|
481
|
+
|
482
|
+
attribute :name, Types::String
|
483
|
+
attribute :fastpass_booth, Types::Bool
|
484
|
+
attribute :short_name, Types::String
|
485
|
+
attribute :created_at, Types::Params::DateTime
|
486
|
+
attribute :updated_at, Types::Params::DateTime
|
487
|
+
attribute :open_emh_morning, Types::Bool
|
488
|
+
attribute :open_emh_evening, Types::Bool
|
489
|
+
attribute :single_rider, Types::Bool
|
490
|
+
attribute :time_zone, Types::String
|
491
|
+
attribute :seasonal, Types::Bool
|
492
|
+
attribute :open_very_merry, Types::Bool
|
493
|
+
attribute :open_not_so_scary, Types::Bool
|
494
|
+
attribute :category_code, Types::String
|
495
|
+
attribute :duration, Types::Float
|
496
|
+
attribute :scheduled_code, Types::String.optional
|
497
|
+
attribute :what_it_is, Types::String
|
498
|
+
attribute :scope_and_scale_code, Types::String
|
499
|
+
attribute :when_to_go, Types::String
|
500
|
+
attribute :average_wait_per_hundred, Types::Float
|
501
|
+
attribute :average_wait_assumes, Types::String.optional
|
502
|
+
attribute :loading_speed, Types::String
|
503
|
+
attribute :probable_wait_time, Types::Float.optional
|
504
|
+
attribute :special_needs, Types::String.optional
|
505
|
+
attribute :height_restriction, Types::Float.optional
|
506
|
+
attribute :intense, Types::Bool
|
507
|
+
attribute :extinct_on, Types::Params::DateTime.optional
|
508
|
+
attribute :opened_on, Types::Params::DateTime.optional
|
509
|
+
attribute :frightening, Types::Bool
|
510
|
+
attribute :physical_considerations, Types::Bool
|
511
|
+
attribute :handheld_captioning, Types::Bool
|
512
|
+
attribute :video_captioning, Types::Bool
|
513
|
+
attribute :reflective_captioning, Types::Bool
|
514
|
+
attribute :assistive_listening, Types::Bool
|
515
|
+
attribute :audio_description, Types::Bool
|
516
|
+
attribute :wheelchair_transfer_code, Types::String
|
517
|
+
attribute :no_service_animals, Types::Bool
|
518
|
+
attribute :sign_language, Types::Bool
|
519
|
+
attribute :service_animal_check, Types::Bool
|
520
|
+
attribute :not_to_be_missed, Types::Bool
|
521
|
+
attribute :rider_swap, Types::Bool
|
522
|
+
attribute :ultimate_code, Types::String
|
523
|
+
attribute :ultimate_task, Types::String
|
524
|
+
attribute :park_entrance, Types::Bool
|
525
|
+
attribute :relative_open, Types::Bool.optional
|
526
|
+
attribute :relative_close, Types::Bool.optional
|
527
|
+
attribute :close_at_dusk, Types::Bool.optional
|
528
|
+
attribute :crowd_calendar_version, Types::Integer
|
529
|
+
attribute :match_name, Types::String
|
530
|
+
attribute :crazy_threshold, Types::Integer.optional
|
531
|
+
attribute :fastpass_only, Types::Bool
|
532
|
+
attribute :allow_showtimes_after_close, Types::Bool
|
533
|
+
attribute :disconnected_fastpass_booth, Types::Bool
|
534
|
+
attribute :arrive_before, Types::Bool.optional
|
535
|
+
attribute :arrive_before_fp, Types::Bool.optional
|
536
|
+
attribute :allow_time_restriction, Types::Bool
|
537
|
+
attribute :relative_open_to_sunset, Types::Bool.optional
|
538
|
+
attribute :relative_close_to_sunset, Types::Bool.optional
|
539
|
+
attribute :closing_round_code, Types::Bool.optional
|
540
|
+
attribute :walking_time_proxy_id, Types::Integer.optional
|
541
|
+
attribute :flexible_duration, Types::Bool
|
542
|
+
attribute :operator_id, Types::Integer
|
543
|
+
attribute :operator_type, Types::String
|
544
|
+
attribute :hide_app, Types::Bool
|
545
|
+
attribute :showtime_proxy_id, Types::Integer.optional
|
546
|
+
attribute :sort_name, Types::String
|
547
|
+
attribute :extinct_on_uncertain, Types::Bool.optional
|
548
|
+
attribute :opened_on_uncertain, Types::Bool.optional
|
549
|
+
attribute :ignore_scrapes, Types::Bool.optional
|
550
|
+
attribute :extra_cost, Types::Bool
|
551
|
+
attribute :climate_controlled, Types::Bool
|
552
|
+
attribute :wet, Types::Bool.optional
|
553
|
+
attribute :operational_notes, Types::String.optional
|
554
|
+
attribute :masthead_circle_x, Types::Integer
|
555
|
+
attribute :masthead_circle_y, Types::Integer
|
556
|
+
attribute :latitude, Types::String
|
557
|
+
attribute :longitude, Types::String
|
558
|
+
attribute :open_early, Types::Bool
|
559
|
+
attribute :themeparks_entity_id, Types::String
|
560
|
+
attribute :has_virtual_queue, Types::Bool
|
289
561
|
end
|
290
562
|
|
291
563
|
# model with the attributes
|
@@ -299,49 +571,78 @@ module Touringplans
|
|
299
571
|
attribute :venue_permalink, Types::String.optional
|
300
572
|
end
|
301
573
|
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
|
318
|
-
|
319
|
-
|
320
|
-
|
321
|
-
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
|
574
|
+
# model with the attributes
|
575
|
+
class HotelFull < Dry::Struct
|
576
|
+
transform_keys(&:to_sym)
|
577
|
+
|
578
|
+
attribute :name, Types::String
|
579
|
+
attribute :address, Types::String
|
580
|
+
attribute :city, Types::String
|
581
|
+
attribute :state_code, Types::String
|
582
|
+
attribute :zip_code, Types::String
|
583
|
+
attribute :phone_number, Types::String
|
584
|
+
attribute :url, Types::String
|
585
|
+
attribute :off_site, Types::Bool
|
586
|
+
attribute :water_sports, Types::Bool
|
587
|
+
attribute :marina, Types::Bool
|
588
|
+
attribute :beach, Types::Bool
|
589
|
+
attribute :tennis, Types::Bool
|
590
|
+
attribute :biking, Types::Bool
|
591
|
+
attribute :suites, Types::Bool
|
592
|
+
attribute :concierge_floor, Types::Bool
|
593
|
+
attribute :room_service, Types::Bool
|
594
|
+
attribute :wired_internet, Types::Bool
|
595
|
+
attribute :wireless_internet, Types::Bool
|
596
|
+
attribute :num_rooms, Types::Integer
|
597
|
+
attribute :theme, Types::String
|
598
|
+
attribute :cost_range, Types::String
|
599
|
+
attribute :shuttle_to_parks, Types::Bool
|
600
|
+
attribute :cost_estimate, Types::String.optional
|
601
|
+
attribute :lodging_area_code, Types::String
|
602
|
+
attribute :category_code, Types::String
|
603
|
+
end
|
604
|
+
|
605
|
+
PLACE_KEYS = %i[magic_kingdom
|
606
|
+
animal_kingdom
|
607
|
+
epcot
|
608
|
+
hollywood_studios
|
609
|
+
walt_disney_world].freeze
|
610
|
+
# {interest:"interest_type"}
|
611
|
+
INTERESTS = %i[counter_services
|
612
|
+
table_services
|
613
|
+
dining
|
614
|
+
attractions
|
615
|
+
hotels
|
616
|
+
campground
|
617
|
+
deluxe_hotels
|
618
|
+
deluxe_villas
|
619
|
+
moderate_hotels
|
620
|
+
value_hotels
|
621
|
+
disney_springs_resorts].freeze
|
622
|
+
HOTEL_CATEGORIES = %i[campground
|
623
|
+
deluxe_hotels
|
624
|
+
deluxe_villas
|
625
|
+
moderate_hotels
|
626
|
+
value_hotels
|
627
|
+
disney_springs_resorts].freeze
|
326
628
|
|
327
629
|
# list interest at location
|
328
630
|
# current interest are "counter service" "table service", and "attractions"
|
329
631
|
# current locations are the four parks
|
330
632
|
def self.list(interest, location)
|
331
633
|
return "The location is not on Disney property" unless PLACE_KEYS.include? _symbolize(location)
|
332
|
-
return "The interest is not valid"
|
634
|
+
return "The interest is not valid" unless INTERESTS.include? _symbolize(interest)
|
333
635
|
|
334
636
|
client = _setup_client
|
335
637
|
listings = []
|
336
638
|
interest_type = _determine_interest_type(interest)
|
337
|
-
route = _assemble_route(location, interest_type)
|
639
|
+
route = _assemble_route(location, interest_type, "list")
|
338
640
|
response = client.send(route).parsed_response
|
339
641
|
listing_hashes = _collect_listing_hashes_from_response(interest, response)
|
340
642
|
listing_hashes.each do |item|
|
341
|
-
item["venue_permalink"] =
|
643
|
+
item["venue_permalink"] = location.to_s.downcase.gsub(" ", "-").gsub("_", "-")
|
342
644
|
end
|
343
645
|
|
344
|
-
listing_hashes
|
345
646
|
listing_hashes.each do |hash|
|
346
647
|
listing = _set_model_from_hash(interest, hash)
|
347
648
|
listings << listing
|
@@ -374,23 +675,32 @@ module Touringplans
|
|
374
675
|
end
|
375
676
|
end
|
376
677
|
|
678
|
+
if interest_type == "hotels"
|
679
|
+
HOTEL_CATEGORIES.each do |category|
|
680
|
+
list = Touringplans.list(category.to_s, "walt_disney_world")
|
681
|
+
places << list
|
682
|
+
end
|
683
|
+
end
|
684
|
+
|
377
685
|
places.flatten
|
378
686
|
end
|
379
687
|
|
380
|
-
def self.show(interest_type,
|
381
|
-
|
382
|
-
|
383
|
-
|
384
|
-
places = list_all(interest_type)
|
688
|
+
def self.show(place, interest_type, permalink)
|
689
|
+
# see specs for examples
|
690
|
+
return "The location is not on Disney property" unless PLACE_KEYS.include? _symbolize(place)
|
691
|
+
return "The interest_type is not valid" unless INTERESTS.include? _symbolize(interest_type)
|
385
692
|
|
386
|
-
|
387
|
-
|
693
|
+
client = _setup_client
|
694
|
+
route = _assemble_route(place, interest_type, permalink)
|
695
|
+
response = client.send(route).parsed_response
|
696
|
+
_set_model_from_hash(interest_type, response)
|
388
697
|
end
|
389
698
|
|
390
699
|
def self._setup_client
|
391
700
|
connection = Connection.new
|
392
701
|
connection.query(key: "HowdyLen")
|
393
|
-
|
702
|
+
routes = Touringplans::RoutesTable.symbolize_keys(Touringplans::RoutesTable.load_routes_file)
|
703
|
+
Client.new(connection: connection, routes: routes)
|
394
704
|
end
|
395
705
|
|
396
706
|
def self._format_location_name(location_name)
|
@@ -402,21 +712,30 @@ module Touringplans
|
|
402
712
|
|
403
713
|
interest_type = "dining" if interest == "counter services"
|
404
714
|
interest_type = "dining" if interest == "table services"
|
405
|
-
interest_type = "hotels" if %i[campground deluxe_hotels deluxe_villas moderate_hotels value_hotels disney_springs_resorts
|
406
|
-
].include? _symbolize(interest)
|
715
|
+
interest_type = "hotels" if %i[campground deluxe_hotels deluxe_villas moderate_hotels value_hotels disney_springs_resorts].include? _symbolize(interest)
|
407
716
|
|
408
717
|
interest_type
|
409
718
|
end
|
410
719
|
|
411
720
|
def self._symbolize(item)
|
412
|
-
|
413
|
-
item
|
721
|
+
## turn a Stringinto a symbol, like comparing to PLACE_KEYS
|
722
|
+
# if item is a path or name we need to turn it into a phrase of words
|
723
|
+
str = item.to_s.downcase.gsub("/", " ").gsub("-", " ").strip
|
724
|
+
# turn item into a symbol
|
725
|
+
str = str.gsub(" ", "_")
|
726
|
+
str.to_sym
|
414
727
|
end
|
415
728
|
|
416
|
-
def self._assemble_route(
|
417
|
-
|
418
|
-
|
419
|
-
"
|
729
|
+
def self._assemble_route(collection, interest_type, venue)
|
730
|
+
# format route
|
731
|
+
collection = collection.to_s.downcase.gsub(" ", "_").gsub("-", "_")
|
732
|
+
interest_type = interest_type.to_s.downcase.gsub(" ", "_").gsub("-", "_")
|
733
|
+
venue = venue.to_s.downcase.gsub(" ", "_").gsub("-", "_")
|
734
|
+
|
735
|
+
route = [collection, interest_type, venue].join("_")
|
736
|
+
route = [collection, interest_type].join("_") if venue == "list"
|
737
|
+
|
738
|
+
route
|
420
739
|
end
|
421
740
|
|
422
741
|
def self._collect_listing_hashes_from_response(interest, response)
|
@@ -432,15 +751,13 @@ module Touringplans
|
|
432
751
|
|
433
752
|
listing_hashes
|
434
753
|
end
|
435
|
-
|
754
|
+
|
436
755
|
def self.list_all_hotels(response_from_touringplans_hotels_url)
|
437
756
|
listing_hashes = []
|
438
757
|
|
439
758
|
response_from_touringplans_hotels_url.each do |child|
|
440
759
|
child.each do |grandchild|
|
441
|
-
if
|
442
|
-
listing_hashes << grandchild
|
443
|
-
end
|
760
|
+
listing_hashes << grandchild if grandchild.class.to_s == "Array"
|
444
761
|
end
|
445
762
|
end
|
446
763
|
|
@@ -448,34 +765,43 @@ module Touringplans
|
|
448
765
|
end
|
449
766
|
|
450
767
|
# search for hotels of a category_code
|
451
|
-
def self.list_hotels_of_a_category(hotels, interest)
|
452
|
-
hotel_categories = {campground:"campground", deluxe_hotels:"deluxe",
|
453
|
-
|
454
|
-
|
768
|
+
def self.list_hotels_of_a_category(hotels, interest)
|
769
|
+
hotel_categories = { campground: "campground", deluxe_hotels: "deluxe",
|
770
|
+
deluxe_villas: "deluxe_villa", moderate_hotels: "moderate",
|
771
|
+
value_hotels: "value", disney_springs_resorts: NilClass }
|
455
772
|
# get a list of every hotel model
|
456
773
|
|
457
774
|
# filter by category_code
|
458
|
-
# disney springs category code is null. We need to find a rule for finding those that don't have any of the values of
|
775
|
+
# disney springs category code is null. We need to find a rule for finding those that don't have any of the values of
|
459
776
|
# hotel categories
|
460
777
|
if interest == "disney springs resorts"
|
461
|
-
|
462
|
-
|
778
|
+
hotels.find_all { |hotel| hotel.category_code.instance_of?(NilClass) }
|
779
|
+
|
463
780
|
else
|
464
|
-
|
465
|
-
|
781
|
+
hotels.find_all { |hotel| hotel.category_code == hotel_categories[_symbolize(interest)] }
|
782
|
+
|
466
783
|
end
|
784
|
+
end
|
467
785
|
|
468
|
-
|
786
|
+
def generate_route_table
|
787
|
+
# initial_routes = ROUTES
|
469
788
|
end
|
470
|
-
|
471
|
-
|
789
|
+
|
472
790
|
def self._set_model_from_hash(interest, hash)
|
473
791
|
hotel_categories = %i[campground deluxe_hotels deluxe_villas moderate_hotels value_hotels disney_springs_resorts hotels]
|
474
792
|
|
475
|
-
|
476
|
-
|
477
|
-
|
478
|
-
|
793
|
+
if hash["permalink"].to_s.length > 1
|
794
|
+
listing = CounterServiceLocation.new(hash) if interest == "counter services"
|
795
|
+
listing = TableServiceLocation.new(hash) if interest == "table services"
|
796
|
+
listing = ParkAttraction.new(hash) if interest == "attractions"
|
797
|
+
listing = DiningVenueFull.new(hash) if interest == "dining"
|
798
|
+
listing = Hotel.new(hash) if hotel_categories.include? _symbolize(interest)
|
799
|
+
else
|
800
|
+
listing = DiningVenueFull.new(hash) if interest == "dining"
|
801
|
+
listing = ParkAttractionFull.new(hash) if interest == "attractions"
|
802
|
+
listing = HotelFull.new(hash) if hotel_categories.include? _symbolize(interest)
|
803
|
+
end
|
804
|
+
|
479
805
|
listing
|
480
806
|
end
|
481
807
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: touringplans
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- captproton
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-10-
|
11
|
+
date: 2021-10-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: awesome_print
|
@@ -132,6 +132,7 @@ files:
|
|
132
132
|
- Rakefile
|
133
133
|
- bin/console
|
134
134
|
- bin/setup
|
135
|
+
- lib/routes.yml
|
135
136
|
- lib/touringplans.rb
|
136
137
|
- lib/touringplans/version.rb
|
137
138
|
homepage: https://github.com/wdwhub/touringplans
|