touringplans 0.1.0 → 0.2.3

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: ac65da412a524dde7cc16db943d0f55ab38984bd5b9736fa9c209a7e6da8a5f3
4
- data.tar.gz: e46b800c1ccd95df6e26842610a3976b1bc1bff6859de260819718cf3f4b11c0
3
+ metadata.gz: 3f511ffe6654c86a85702f5b4a984b8569e9783db8d4f3bd31a98408f02ca336
4
+ data.tar.gz: 2b76432691eeab05abd3eb23caf1406445605aa4814709d45fbfc615491febc8
5
5
  SHA512:
6
- metadata.gz: '08b04c00ddbbc5fc1032e6f715c0e31d65476918080ecf423c8891967cf8654709ed19cf33c18f1a4a2355921e129a3b58938e457e9883b91a1327fe14f4f6c1'
7
- data.tar.gz: bae9ce0a3abeef04449087c28af3ec86040985d52713fa17d31fcb76c6f0e36282c46bba1a6e672d50dcf08c5bb35e2f74ffbfa8b9be273ec5ad3f32a73b5cd1
6
+ metadata.gz: 1efa8beb0d74fc6ff5eb967c4fa189359db1437e5a25b26b9e4ecc24af786c1ffe3220dba75c0ae3f4ef03feddc134da4dd0571ce31d3e686fbd9a5bc5e2094e
7
+ data.tar.gz: 471f50c2dbe6791ec51ac8fee428efa18827caa2aee84e46ee50c33da0f2b49815399f189bb5a63e9d7a1063b458087de150c34b75082b8f64ed8b1d02dd727d
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
data/.rubocop.yml CHANGED
@@ -1,5 +1,13 @@
1
1
  AllCops:
2
- TargetRubyVersion: 2.4
2
+ TargetRubyVersion: 2.6
3
+ SuggestExtensions: false
4
+ NewCops: enable
5
+
6
+ Style/FrozenStringLiteralComment:
7
+ Enabled: false
8
+
9
+ Style/RaiseArgs:
10
+ Enabled: false
3
11
 
4
12
  Style/StringLiterals:
5
13
  Enabled: true
@@ -10,4 +18,11 @@ Style/StringLiteralsInInterpolation:
10
18
  EnforcedStyle: double_quotes
11
19
 
12
20
  Layout/LineLength:
13
- Max: 120
21
+ Max: 200
22
+
23
+ Metrics/BlockLength:
24
+ Exclude:
25
+ - "spec/*"
26
+
27
+ Metrics/MethodLength:
28
+ Max: 20
data/.version CHANGED
@@ -1 +1 @@
1
- 0.1.2
1
+ 0.2.3
@@ -0,0 +1,84 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ We as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone, regardless of age, body size, visible or invisible disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, religion, or sexual identity and orientation.
6
+
7
+ We pledge to act and interact in ways that contribute to an open, welcoming, diverse, inclusive, and healthy community.
8
+
9
+ ## Our Standards
10
+
11
+ Examples of behavior that contributes to a positive environment for our community include:
12
+
13
+ * Demonstrating empathy and kindness toward other people
14
+ * Being respectful of differing opinions, viewpoints, and experiences
15
+ * Giving and gracefully accepting constructive feedback
16
+ * Accepting responsibility and apologizing to those affected by our mistakes, and learning from the experience
17
+ * Focusing on what is best not just for us as individuals, but for the overall community
18
+
19
+ Examples of unacceptable behavior include:
20
+
21
+ * The use of sexualized language or imagery, and sexual attention or
22
+ advances of any kind
23
+ * Trolling, insulting or derogatory comments, and personal or political attacks
24
+ * Public or private harassment
25
+ * Publishing others' private information, such as a physical or email
26
+ address, without their explicit permission
27
+ * Other conduct which could reasonably be considered inappropriate in a
28
+ professional setting
29
+
30
+ ## Enforcement Responsibilities
31
+
32
+ Community leaders are responsible for clarifying and enforcing our standards of acceptable behavior and will take appropriate and fair corrective action in response to any behavior that they deem inappropriate, threatening, offensive, or harmful.
33
+
34
+ Community leaders have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, and will communicate reasons for moderation decisions when appropriate.
35
+
36
+ ## Scope
37
+
38
+ This Code of Conduct applies within all community spaces, and also applies when an individual is officially representing the community in public spaces. Examples of representing our community include using an official e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event.
39
+
40
+ ## Enforcement
41
+
42
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the community leaders responsible for enforcement at brett@bigcartel.com. All complaints will be reviewed and investigated promptly and fairly.
43
+
44
+ All community leaders are obligated to respect the privacy and security of the reporter of any incident.
45
+
46
+ ## Enforcement Guidelines
47
+
48
+ Community leaders will follow these Community Impact Guidelines in determining the consequences for any action they deem in violation of this Code of Conduct:
49
+
50
+ ### 1. Correction
51
+
52
+ **Community Impact**: Use of inappropriate language or other behavior deemed unprofessional or unwelcome in the community.
53
+
54
+ **Consequence**: A private, written warning from community leaders, providing clarity around the nature of the violation and an explanation of why the behavior was inappropriate. A public apology may be requested.
55
+
56
+ ### 2. Warning
57
+
58
+ **Community Impact**: A violation through a single incident or series of actions.
59
+
60
+ **Consequence**: A warning with consequences for continued behavior. No interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, for a specified period of time. This includes avoiding interactions in community spaces as well as external channels like social media. Violating these terms may lead to a temporary or permanent ban.
61
+
62
+ ### 3. Temporary Ban
63
+
64
+ **Community Impact**: A serious violation of community standards, including sustained inappropriate behavior.
65
+
66
+ **Consequence**: A temporary ban from any sort of interaction or public communication with the community for a specified period of time. No public or private interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, is allowed during this period. Violating these terms may lead to a permanent ban.
67
+
68
+ ### 4. Permanent Ban
69
+
70
+ **Community Impact**: Demonstrating a pattern of violation of community standards, including sustained inappropriate behavior, harassment of an individual, or aggression toward or disparagement of classes of individuals.
71
+
72
+ **Consequence**: A permanent ban from any sort of public interaction within the community.
73
+
74
+ ## Attribution
75
+
76
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 2.0,
77
+ available at https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
78
+
79
+ Community Impact Guidelines were inspired by [Mozilla's code of conduct enforcement ladder](https://github.com/mozilla/diversity).
80
+
81
+ [homepage]: https://www.contributor-covenant.org
82
+
83
+ For answers to common questions about this code of conduct, see the FAQ at
84
+ https://www.contributor-covenant.org/faq. Translations are available at https://www.contributor-covenant.org/translations.
data/Gemfile CHANGED
@@ -4,11 +4,17 @@ source "https://rubygems.org"
4
4
 
5
5
  # Specify your gem's dependencies in touringplans.gemspec
6
6
  gemspec
7
-
7
+ # development
8
+ gem "awesome_print", "~> 1.9", ">= 1.9.2"
9
+ gem "pry", "~> 0.14.1"
8
10
  gem "rake", "~> 13.0"
11
+ gem "rubocop", "~> 1.7", require: false
9
12
 
10
- gem "minitest", "~> 5.0"
11
-
12
- gem "rubocop", "~> 1.7"
13
+ # testing
14
+ gem "rspec", "~> 3.0"
13
15
 
14
- gem 'httparty', '~> 0.19.0'
16
+ ## custom for gem
17
+ # connect to the API
18
+ gem "httparty", "~> 0.19.0"
19
+ # convert httparty hash to objects
20
+ gem 'dry-struct', '~> 1.4'
data/Rakefile CHANGED
@@ -1,16 +1,12 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require "bundler/gem_tasks"
4
- require "rake/testtask"
4
+ require "rspec/core/rake_task"
5
5
 
6
- Rake::TestTask.new(:test) do |t|
7
- t.libs << "test"
8
- t.libs << "lib"
9
- t.test_files = FileList["test/**/*_test.rb"]
10
- end
6
+ RSpec::Core::RakeTask.new(:spec)
11
7
 
12
8
  require "rubocop/rake_task"
13
9
 
14
10
  RuboCop::RakeTask.new
15
11
 
16
- task default: %i[test rubocop]
12
+ task default: %i[spec rubocop]
data/bin/console CHANGED
@@ -8,8 +8,8 @@ require "touringplans"
8
8
  # with your gem easier. You can also use a different console, if you like.
9
9
 
10
10
  # (If you use this, don't forget to add pry to your Gemfile!)
11
- # require "pry"
12
- # Pry.start
11
+ require "pry"
12
+ Pry.start
13
13
 
14
- require "irb"
15
- IRB.start(__FILE__)
14
+ # require "irb"
15
+ # IRB.start(__FILE__)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Touringplans
4
- VERSION = "0.1.0"
4
+ VERSION = "0.2.3"
5
5
  end
data/lib/touringplans.rb CHANGED
@@ -2,32 +2,472 @@
2
2
 
3
3
  require_relative "touringplans/version"
4
4
  require "httparty"
5
+ require "dry-struct"
6
+
7
+ # list and show attractions and eateries at Walt Disney World
5
8
  module Touringplans
6
9
  class Error < StandardError; end
7
- # Your code goes here...\
10
+
11
+ module Types
12
+ include Dry.Types()
13
+ end
14
+
8
15
  include HTTParty
9
- base_uri "touringplans.com"
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
+ ROUTES = {
24
+ magic_kingdom_dining: {
25
+ method: "get",
26
+ path: "/magic-kingdom/dining.json"
27
+ },
28
+ magic_kingdom_attractions: {
29
+ method: "get",
30
+ path: "/magic-kingdom/attractions.json"
31
+ },
32
+ animal_kingdom_dining: {
33
+ method: "get",
34
+ path: "/animal-kingdom/dining.json"
35
+ },
36
+ animal_kingdom_attractions: {
37
+ method: "get",
38
+ path: "/animal-kingdom/attractions.json"
39
+ },
40
+ epcot_dining: {
41
+ method: "get",
42
+ path: "/epcot/dining.json"
43
+ },
44
+ epcot_attractions: {
45
+ method: "get",
46
+ path: "/epcot/attractions.json"
47
+ },
48
+ hollywood_studios_dining: {
49
+ method: "get",
50
+ path: "/hollywood-studios/dining.json"
51
+ },
52
+ hollywood_studios_attractions: {
53
+ method: "get",
54
+ path: "/hollywood-studios/attractions.json"
55
+ },
56
+ walt_disney_world_hotels: {
57
+ method: "get",
58
+ path: "/walt-disney-world/hotels.json"
59
+ },
60
+ walt_disney_world_campground: {
61
+ method: "get",
62
+ path: "/walt-disney-world/hotels.json"
63
+ },
64
+ walt_disney_world_deluxe_hotels: {
65
+ method: "get",
66
+ path: "/walt-disney-world/hotels.json"
67
+ },
68
+ walt_disney_world_deluxe_villas: {
69
+ method: "get",
70
+ path: "/walt-disney-world/hotels.json"
71
+ },
72
+ walt_disney_world_moderate_hotels: {
73
+ method: "get",
74
+ path: "/walt-disney-world/hotels.json"
75
+ },
76
+ walt_disney_world_value_hotels: {
77
+ method: "get",
78
+ path: "/walt-disney-world/hotels.json"
79
+ },
80
+ walt_disney_world_disney_springs_resorts: {
81
+ method: "get",
82
+ path: "/walt-disney-world/hotels.json"
83
+ },
84
+ }
85
+ # deals solely with how to create access to the resource, the lock of "lock & key"
86
+ class Connection
87
+ # concerned only on where it gets the info it needs
88
+ # and maybe a version number
89
+
90
+ include HTTParty
91
+ # currently Touring Plans has no verision in its API
92
+ DEFAULT_API_VERSION = "1"
93
+ DEFAULT_BASE_URI = "https://touringplans.com/"
94
+ DEFAULT_QUERY = {}
95
+
96
+ base_uri DEFAULT_BASE_URI
97
+
98
+ def initialize(options = {})
99
+ @api_version = options.fetch(:api_version, DEFAULT_API_VERSION)
100
+ @query = options.fetch(:query, DEFAULT_QUERY)
101
+ @connection = self.class
102
+ end
103
+
104
+ def query(params = {})
105
+ @query.update(params)
106
+ end
107
+
108
+ def get(relative_path, query = {})
109
+ # relative_path = add_api_version(relative_path)
110
+ connection.get relative_path, query: @query.merge(query)
111
+ end
112
+
113
+ private
114
+
115
+ attr_reader :connection
116
+ # currently Touring Plans has no verision in its API
117
+
118
+ # def add_api_version(relative_path)
119
+ # "/#{api_version_path}#{relative_path}"
120
+ # end
121
+
122
+ # def api_version_path
123
+ # "v" + @api_version.to_s
124
+ # end
125
+ end
126
+
127
+ # deals solely with how to manage the connection, the key of "lock & key"
128
+ class Client
129
+ def initialize(connection:, routes:)
130
+ @connection = connection
131
+ @routes = routes
132
+ end
133
+
134
+ def method_missing(method, *request_arguments)
135
+ # retrieve the route map
136
+ route_map = routes.fetch(method)
137
+
138
+ # make request via the connection
139
+ response_from_route(route_map, request_arguments)
140
+ end
141
+
142
+ private
143
+
144
+ attr_reader :connection, :routes
145
+
146
+ def response_from_route(route_map, request_arguments)
147
+ # gather the routes required parameters
148
+ http_method = route_map.fetch(:method)
149
+ relative_path = route_map.fetch(:path)
150
+
151
+ # call the connection for records
152
+ connection.send(http_method, relative_path, *request_arguments)
153
+ end
154
+ end
155
+
156
+ # model with the attributes
157
+ class CounterServiceLocation < Dry::Struct
158
+ transform_keys(&:to_sym)
159
+
160
+ attribute :id, Types::Integer
161
+ attribute :land_id, Types::Integer
162
+ attribute :name, Types::String
163
+ attribute :permalink, Types::String
164
+ attribute :category_code, Types::String
165
+ attribute :portion_size, Types::String.optional
166
+ attribute :cost_code, Types::String.optional
167
+ attribute :cuisine, Types::String
168
+ attribute :phone_number, Types::String.optional
169
+ attribute :entree_range, Types::String.optional
170
+ attribute :when_to_go, Types::String.optional
171
+ attribute :parking, Types::String.optional
172
+ attribute :bar, Types::String.optional
173
+ attribute :wine_list, Types::String.optional
174
+ attribute :dress, Types::String.optional
175
+ attribute :awards, Types::String.optional
176
+ attribute :breakfast_hours, Types::String.optional
177
+ attribute :lunch_hours, Types::String.optional
178
+ attribute :dinner_hours, Types::String.optional
179
+ attribute :selection, Types::String.optional
180
+ attribute :setting_atmosphere, Types::String.optional
181
+ attribute :other_recommendations, Types::String.optional
182
+ attribute :summary, Types::String.optional
183
+ attribute :house_specialties, Types::String.optional
184
+ attribute :counter_quality_rating, Types::String.optional
185
+ attribute :counter_value_rating, Types::String.optional
186
+ attribute :table_quality_rating, Types::String.optional
187
+ attribute :table_value_rating, Types::String.optional
188
+ attribute :overall_rating, Types::Float.optional
189
+ attribute :service_rating, Types::String.optional
190
+ attribute :friendliness_rating, Types::String.optional
191
+ attribute :adult_breakfast_menu_url, Types::String.optional
192
+ attribute :adult_lunch_menu_url, Types::String.optional
193
+ attribute :adult_dinner_menu_url, Types::String.optional
194
+ attribute :child_breakfast_menu_url, Types::String.optional
195
+ attribute :child_lunch_menu_url, Types::String.optional
196
+ attribute :child_dinner_menu_url, Types::String.optional
197
+ attribute :requires_credit_card, Types::Params::Bool
198
+ attribute :requires_pre_payment, Types::Params::Bool
199
+ attribute :created_at, Types::Params::DateTime
200
+ attribute :updated_at, Types::Params::DateTime
201
+ attribute :plan_x_coord, Types::Coercible::Integer.optional
202
+ attribute :plan_y_coord, Types::Coercible::Integer.optional
203
+ attribute :old_park_id, Types::Params::Integer.optional
204
+ attribute :old_attraction_id, Types::Params::Integer.optional
205
+ attribute :plan_name, Types::String.optional
206
+ attribute :extinct_on, Types::Params::DateTime.optional
207
+ attribute :opened_on, Types::Params::DateTime.optional
208
+ attribute :disney_permalink, Types::String.optional
209
+ attribute :code, Types::String.optional
210
+ attribute :short_name, Types::String.optional
211
+ attribute :accepts_reservations, Types::Params::Bool
212
+ attribute :kosher_available, Types::Params::Bool
213
+ attribute :dinable_id, Types::Params::Integer
214
+ attribute :dinable_type, Types::String.optional
215
+ end
216
+
217
+ # model with the attributes
218
+ class TableServiceLocation < Dry::Struct
219
+ transform_keys(&:to_sym)
220
+
221
+ attribute :id, Types::Integer
222
+ attribute :land_id, Types::Integer
223
+ attribute :name, Types::String
224
+ attribute :permalink, Types::String
225
+ attribute :category_code, Types::String
226
+ attribute :portion_size, Types::String.optional
227
+ attribute :cost_code, Types::String.optional
228
+ attribute :cuisine, Types::String
229
+ attribute :phone_number, Types::String.optional
230
+ attribute :entree_range, Types::String.optional
231
+ attribute :when_to_go, Types::String.optional
232
+ attribute :parking, Types::String.optional
233
+ attribute :bar, Types::String.optional
234
+ attribute :wine_list, Types::String.optional
235
+ attribute :dress, Types::String.optional
236
+ attribute :awards, Types::String.optional
237
+ attribute :breakfast_hours, Types::String.optional
238
+ attribute :lunch_hours, Types::String.optional
239
+ attribute :dinner_hours, Types::String.optional
240
+ attribute :selection, Types::String.optional
241
+ attribute :setting_atmosphere, Types::String.optional
242
+ attribute :other_recommendations, Types::String.optional
243
+ attribute :summary, Types::String.optional
244
+ attribute :house_specialties, Types::String.optional
245
+ attribute :counter_quality_rating, Types::String.optional
246
+ attribute :counter_value_rating, Types::String.optional
247
+ attribute :table_quality_rating, Types::Params::Decimal.optional
248
+ attribute :table_value_rating, Types::Params::Decimal.optional
249
+ attribute :overall_rating, Types::Params::Decimal.optional
250
+ attribute :service_rating, Types::Params::Decimal.optional
251
+ attribute :friendliness_rating, Types::Params::Decimal.optional
252
+ attribute :adult_breakfast_menu_url, Types::String.optional
253
+ attribute :adult_lunch_menu_url, Types::String.optional
254
+ attribute :adult_dinner_menu_url, Types::String.optional
255
+ attribute :child_breakfast_menu_url, Types::String.optional
256
+ attribute :child_lunch_menu_url, Types::String.optional
257
+ attribute :child_dinner_menu_url, Types::String.optional
258
+ attribute :requires_credit_card, Types::Params::Bool
259
+ attribute :requires_pre_payment, Types::Params::Bool
260
+ attribute :created_at, Types::Params::DateTime
261
+ attribute :updated_at, Types::Params::DateTime
262
+ attribute :plan_x_coord, Types::Params::Integer.optional
263
+ attribute :plan_y_coord, Types::Params::Integer.optional
264
+ attribute :old_park_id, Types::Params::Integer.optional
265
+ attribute :old_attraction_id, Types::Params::Integer.optional
266
+ attribute :plan_name, Types::String.optional
267
+ attribute :extinct_on, Types::Params::DateTime.optional
268
+ attribute :opened_on, Types::Params::DateTime.optional
269
+ attribute :disney_permalink, Types::String.optional
270
+ attribute :code, Types::String.optional
271
+ attribute :short_name, Types::String.optional
272
+ attribute :accepts_reservations, Types::Params::Bool
273
+ attribute :kosher_available, Types::Params::Bool
274
+ attribute :dinable_id, Types::Params::Integer
275
+ attribute :dinable_type, Types::String.optional
276
+ end
277
+
278
+ # model with the attributes
279
+ class ParkAttraction < Dry::Struct
280
+ transform_keys(&:to_sym)
281
+
282
+ attribute :name, Types::String
283
+ attribute :short_name, Types::String
284
+ attribute :permalink, Types::String
285
+ end
286
+
287
+ # model with the attributes
288
+ class Hotel < Dry::Struct
289
+ transform_keys(&:to_sym)
290
+
291
+ attribute :name, Types::String
292
+ attribute :sort_name, Types::String
293
+ attribute :permalink, Types::String
294
+ attribute :category_code, Types::String.optional
295
+ end
296
+
297
+ PLACE_KEYS = %i[magic_kingdom
298
+ animal_kingdom
299
+ epcot
300
+ hollywood_studios
301
+ walt_disney_world
302
+ ].freeze
303
+ # {interest:"interest_type"}
304
+ INTERESTS = %i[counter_services
305
+ table_services
306
+ attractions
307
+ hotels
308
+ campground
309
+ deluxe_hotels
310
+ deluxe_villas
311
+ moderate_hotels
312
+ value_hotels
313
+ disney_springs_resorts
314
+ ].freeze
315
+ HOTEL_CATEGORIES = %i[campground
316
+ deluxe_hotels
317
+ deluxe_villas
318
+ moderate_hotels
319
+ value_hotels
320
+ disney_springs_resorts]
321
+
322
+ # list interest at location
323
+ # current interest are "counter service" "table service", and "attractions"
324
+ # current locations are the four parks
325
+ def self.list(interest, location)
326
+ return "The location is not on Disney property" unless PLACE_KEYS.include? _symbolize(location)
327
+ return "The interest is not valid" unless INTERESTS.include? _symbolize(interest)
328
+
329
+ client = _setup_client
330
+ listings = []
331
+ interest_type = _determine_interest_type(interest)
332
+ route = _assemble_route(location, interest_type)
333
+ response = client.send(route).parsed_response
334
+ listing_hashes = _collect_listing_hashes_from_response(interest, response)
335
+
336
+ listing_hashes
337
+ listing_hashes.each do |hash|
338
+ listing = _set_model_from_hash(interest, hash)
339
+ listings << listing
340
+ end
341
+
342
+ listings = list_hotels_of_a_category(listings, interest) if HOTEL_CATEGORIES.include? _symbolize(interest)
343
+
344
+ listings
345
+ end
346
+
347
+ def self.list_all(interest_type)
348
+ return "The interest_type is not valid" unless %i[dining attractions hotels].include? _symbolize(interest_type)
10
349
 
11
- # park dining
12
- def self.find_all_dining_at_park(park_name)
13
- formatted_park_name = park_name.to_s.downcase.gsub(" ", "-")
14
- response = get("/#{formatted_park_name}/dining.json").parsed_response
350
+ parks = ["Magic Kingdom", "Animal Kingdom", "Epcot", "Hollywood Studios"]
351
+ places = []
352
+
353
+ if interest_type == "attractions"
354
+ parks.each do |park|
355
+ list = Touringplans.list("attractions", park)
356
+ places << list
357
+ end
358
+ end
359
+
360
+ if interest_type == "dining"
361
+ parks.each do |park|
362
+ list = Touringplans.list("counter services", park)
363
+ places << list
364
+ list = Touringplans.list("table services", park)
365
+ places << list
366
+ end
367
+ end
368
+
369
+ places.flatten
15
370
  end
16
371
 
17
- def self.find_all_counter_service_dining_at_park(park_name)
18
- eateries = self.find_all_dining_at_park(park_name)
19
- eateries[0]
372
+ def self.show(interest_type, short_name)
373
+ return "The interest_type is not valid" unless %i[dining attractions hotels].include? _symbolize(interest_type)
374
+
375
+ # get a list of every model of one kind of interest_type (dining, attractions, hotels)
376
+ places = list_all(interest_type)
377
+
378
+ # filter by short_name
379
+ places.find { |place| place.short_name == short_name }
20
380
  end
21
381
 
22
- def self.find_all_table_service_dining_at_park(park_name)
23
- eateries = self.find_all_dining_at_park(park_name)
24
- eateries[1]
382
+ def self._setup_client
383
+ connection = Connection.new
384
+ connection.query(key: "HowdyLen")
385
+ Client.new(connection: connection, routes: ROUTES)
25
386
  end
26
387
 
27
- # park attractions
28
- def self.find_all_attractions_at_park(park_name)
29
- formatted_park_name = park_name.to_s.downcase.gsub(" ", "-")
30
- response = get("/#{formatted_park_name}/attractions.json").parsed_response
388
+ def self._format_location_name(location_name)
389
+ location_name.to_s.downcase.gsub(" ", "-")
390
+ end
391
+
392
+ def self._determine_interest_type(interest)
393
+ interest_type = interest
394
+
395
+ interest_type = "dining" if interest == "counter services"
396
+ interest_type = "dining" if interest == "table services"
397
+ interest_type = "hotels" if %i[campground deluxe_hotels deluxe_villas moderate_hotels value_hotels disney_springs_resorts
398
+ ].include? _symbolize(interest)
399
+
400
+ interest_type
31
401
  end
32
402
 
403
+ def self._symbolize(item)
404
+ # turn a Stringinto a symbol, like comparing to PLACE_KEYS
405
+ item.to_s.downcase.gsub(" ", "_").to_sym
406
+ end
407
+
408
+ def self._assemble_route(location, interest_type)
409
+ formatted_location = location.to_s.downcase.gsub(" ", "_")
410
+ formatted_interest_type = interest_type.to_s.downcase.gsub(" ", "_")
411
+ "#{formatted_location}_#{formatted_interest_type}"
412
+ end
413
+
414
+ def self._collect_listing_hashes_from_response(interest, response)
415
+ hotel_categories = %i[campground deluxe_hotels deluxe_villas moderate_hotels value_hotels disney_springs_resorts]
416
+
417
+ listing_hashes = response if interest == "attractions"
418
+ listing_hashes = response if interest == "dining"
419
+ listing_hashes = response[0] if interest == "counter services"
420
+ listing_hashes = response[1] if interest == "table services"
421
+
422
+ listing_hashes = list_all_hotels(response) if interest == "hotels"
423
+ listing_hashes = list_all_hotels(response) if hotel_categories.include? _symbolize(interest)
424
+
425
+ listing_hashes
426
+ end
427
+
428
+ def self.list_all_hotels(response_from_touringplans_hotels_url)
429
+ listing_hashes = []
430
+
431
+ response_from_touringplans_hotels_url.each do |child|
432
+ child.each do |grandchild|
433
+ if "#{grandchild.class}" == "Array"
434
+ listing_hashes << grandchild
435
+ end
436
+ end
437
+ end
438
+
439
+ listing_hashes.flatten
440
+ end
441
+
442
+ # search for hotels of a category_code
443
+ def self.list_hotels_of_a_category(hotels, interest)
444
+ hotel_categories = {campground:"campground", deluxe_hotels:"deluxe",
445
+ deluxe_villas:"deluxe_villa", moderate_hotels:"moderate",
446
+ value_hotels:"value", disney_springs_resorts: NilClass}
447
+ # get a list of every hotel model
448
+
449
+ # filter by category_code
450
+ # disney springs category code is null. We need to find a rule for finding those that don't have any of the values of
451
+ # hotel categories
452
+ if interest == "disney springs resorts"
453
+ target_hotels = hotels.find_all { |hotel| hotel.category_code.class == NilClass }
454
+
455
+ else
456
+ target_hotels = hotels.find_all { |hotel| hotel.category_code == hotel_categories[_symbolize(interest)] }
457
+
458
+ end
459
+
460
+ target_hotels
461
+ end
462
+
463
+
464
+ def self._set_model_from_hash(interest, hash)
465
+ hotel_categories = %i[campground deluxe_hotels deluxe_villas moderate_hotels value_hotels disney_springs_resorts hotels]
466
+
467
+ listing = CounterServiceLocation.new(hash) if interest == "counter services"
468
+ listing = TableServiceLocation.new(hash) if interest == "table services"
469
+ listing = ParkAttraction.new(hash) if interest == "attractions"
470
+ listing = Hotel.new(hash) if hotel_categories.include? _symbolize(interest)
471
+ listing
472
+ end
33
473
  end
data/touringplans.gemspec CHANGED
@@ -8,16 +8,19 @@ Gem::Specification.new do |spec|
8
8
  spec.authors = ["captproton"]
9
9
  spec.email = ["carl@wdwhub.net"]
10
10
 
11
- spec.summary = "TouringPlans.com is a great fan website to plan a trip to Walt Disney World in Florida. This ruby gem makes its API easier to work with."
11
+ spec.summary = "Easily access the API of touringplans.com as ruby objects."
12
+ spec.description = "Because ruby objects are better than json."
12
13
  spec.homepage = "https://github.com/wdwhub/touringplans"
13
14
  spec.license = "MIT"
14
- spec.required_ruby_version = ">= 2.4.0"
15
+ spec.required_ruby_version = ">= 2.6.0"
15
16
 
16
- spec.metadata["homepage_uri"] = "https://github.com/wdwhub/touringplans"
17
- spec.metadata["source_code_uri"] = "https://github.com/wdwhub/touringplans"
18
- spec.metadata["changelog_uri"] = "https://github.com/wdwhub/touringplans/blob/main/Changelog.md"
17
+ spec.metadata["allowed_push_host"] = "https://rubygems.org"
19
18
 
20
- spec.add_dependency 'httparty', '~> 0.19.0'
19
+ spec.metadata["homepage_uri"] = spec.homepage
20
+ spec.metadata["source_code_uri"] = spec.homepage
21
+ spec.metadata["changelog_uri"] = "#{spec.homepage}/CHANGELOG.md"
22
+
23
+ spec.add_dependency "httparty", "~> 0.19.0"
21
24
 
22
25
  # Specify which files should be added to the gem when it is released.
23
26
  # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
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.1.0
4
+ version: 0.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - captproton
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-09-25 00:00:00.000000000 Z
11
+ date: 2021-10-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httparty
@@ -24,18 +24,19 @@ dependencies:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: 0.19.0
27
- description:
27
+ description: Because ruby objects are better than json.
28
28
  email:
29
29
  - carl@wdwhub.net
30
30
  executables: []
31
31
  extensions: []
32
32
  extra_rdoc_files: []
33
33
  files:
34
+ - ".rspec"
34
35
  - ".rubocop.yml"
35
36
  - ".version"
36
37
  - CHANGELOG.md
38
+ - CODE_OF_CONDUCT.md
37
39
  - Gemfile
38
- - Gemfile.lock
39
40
  - LICENSE.txt
40
41
  - README.md
41
42
  - Rakefile
@@ -48,9 +49,10 @@ homepage: https://github.com/wdwhub/touringplans
48
49
  licenses:
49
50
  - MIT
50
51
  metadata:
52
+ allowed_push_host: https://rubygems.org
51
53
  homepage_uri: https://github.com/wdwhub/touringplans
52
54
  source_code_uri: https://github.com/wdwhub/touringplans
53
- changelog_uri: https://github.com/wdwhub/touringplans/blob/main/Changelog.md
55
+ changelog_uri: https://github.com/wdwhub/touringplans/CHANGELOG.md
54
56
  post_install_message:
55
57
  rdoc_options: []
56
58
  require_paths:
@@ -59,7 +61,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
59
61
  requirements:
60
62
  - - ">="
61
63
  - !ruby/object:Gem::Version
62
- version: 2.4.0
64
+ version: 2.6.0
63
65
  required_rubygems_version: !ruby/object:Gem::Requirement
64
66
  requirements:
65
67
  - - ">="
@@ -69,6 +71,5 @@ requirements: []
69
71
  rubygems_version: 3.2.15
70
72
  signing_key:
71
73
  specification_version: 4
72
- summary: TouringPlans.com is a great fan website to plan a trip to Walt Disney World
73
- in Florida. This ruby gem makes its API easier to work with.
74
+ summary: Easily access the API of touringplans.com as ruby objects.
74
75
  test_files: []
data/Gemfile.lock DELETED
@@ -1,51 +0,0 @@
1
- PATH
2
- remote: .
3
- specs:
4
- touringplans (0.1.0)
5
- httparty (~> 0.19.0)
6
-
7
- GEM
8
- remote: https://rubygems.org/
9
- specs:
10
- ast (2.4.2)
11
- httparty (0.19.0)
12
- mime-types (~> 3.0)
13
- multi_xml (>= 0.5.2)
14
- mime-types (3.3.1)
15
- mime-types-data (~> 3.2015)
16
- mime-types-data (3.2021.0901)
17
- minitest (5.14.4)
18
- multi_xml (0.6.0)
19
- parallel (1.21.0)
20
- parser (3.0.2.0)
21
- ast (~> 2.4.1)
22
- rainbow (3.0.0)
23
- rake (13.0.6)
24
- regexp_parser (2.1.1)
25
- rexml (3.2.5)
26
- rubocop (1.21.0)
27
- parallel (~> 1.10)
28
- parser (>= 3.0.0.0)
29
- rainbow (>= 2.2.2, < 4.0)
30
- regexp_parser (>= 1.8, < 3.0)
31
- rexml
32
- rubocop-ast (>= 1.9.1, < 2.0)
33
- ruby-progressbar (~> 1.7)
34
- unicode-display_width (>= 1.4.0, < 3.0)
35
- rubocop-ast (1.11.0)
36
- parser (>= 3.0.1.1)
37
- ruby-progressbar (1.11.0)
38
- unicode-display_width (2.1.0)
39
-
40
- PLATFORMS
41
- x86_64-darwin-20
42
-
43
- DEPENDENCIES
44
- httparty (~> 0.19.0)
45
- minitest (~> 5.0)
46
- rake (~> 13.0)
47
- rubocop (~> 1.7)
48
- touringplans!
49
-
50
- BUNDLED WITH
51
- 2.2.27