extraspace 1.0.3 → 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: 82b4f836ff0d65dcec12e541bfd6a4de027b8927f1ebf93af3e42c5f58536454
4
- data.tar.gz: faa23fe7722614c485e8c220c830df802dcf8f580cbe1624d15fe3ae51541bcc
3
+ metadata.gz: ca4e342bb9f821e482ae14ba01225c5e8f15a6214b902b4f3b5625c25a417a2b
4
+ data.tar.gz: ac6c2323e43a2bc73768e8baca46c9558781c1a208e7818aabcbd47b7233f652
5
5
  SHA512:
6
- metadata.gz: 2ea37cab3ac53c4cfd2afc417c3a593d10f37d395ed697872b94b20a6ec7e8823aacd1b3995b343982c4cf69652ddf99fd1ba781e8e33feb708ba17dd0b35c75
7
- data.tar.gz: 6f5dfa0086ba45d16e25f0bd8b1a2cc6a77f772c8845e7d8e0be2a9c6a3c557092fae941a73f22d9df0d919aa01f3cd9a15b4bd746ef632bf82d197db55101dd
6
+ metadata.gz: 60fb031eb92778affb4a5a5e31839d8e007822a10343f981c0791b652510b0d1497be4b707337b9304f35d50f7dd5b655546d55d371d6261c4c9f18e5eb6bcf2
7
+ data.tar.gz: bb646645850b03041c519fa1b15fb2b24b236c97ede2ec7a8844372f15c095f0d8108e07e735780db7b1c13e26fada06ce63022725258efe96f7b665e86350cb
@@ -63,17 +63,39 @@ module ExtraSpace
63
63
  data = parse_next_data(document: document)
64
64
  page_data = data.dig('props', 'pageProps', 'pageData', 'data')
65
65
  store_data = page_data.dig('facilityData', 'data', 'store')
66
- unit_classes = page_data.dig('unitClasses', 'data', 'unitClasses')
67
66
  id = store_data['number']
68
67
  name = store_data['name']
69
68
 
70
- address = Address.parse(data: store_data['address'])
71
- geocode = Geocode.parse(data: store_data['geocode'])
72
- prices = unit_classes.map { |price_data| Price.parse(data: price_data) }
69
+ address = parse_address(data: store_data)
70
+ geocode = parse_geocode(data: store_data)
71
+ prices = parse_prices(data: page_data)
73
72
 
74
73
  new(id:, url:, name:, address:, geocode:, prices:)
75
74
  end
76
75
 
76
+ # @param data [Hash]
77
+ # @return [Address]
78
+ def self.parse_address(data:)
79
+ Address.parse(data: data['address'])
80
+ end
81
+
82
+ # @param data [Hash]
83
+ # @return [Geocode]
84
+ def self.parse_geocode(data:)
85
+ Geocode.parse(data: data['geocode'])
86
+ end
87
+
88
+ # @param entries [Array<Hash>]
89
+ #
90
+ # @return [Array<Price>]
91
+ def self.parse_prices(data:)
92
+ unit_classes = data.dig('unitClasses', 'data', 'unitClasses')
93
+
94
+ unit_classes
95
+ .reject { |price_data| price_data.dig('availability', 'available')&.zero? }
96
+ .map { |price_data| Price.parse(data: price_data) }
97
+ end
98
+
77
99
  # @param document [Nokogiri::HTML::Document]
78
100
  #
79
101
  # @raise [ParseError]
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ExtraSpace
4
- VERSION = '1.0.3'
4
+ VERSION = '1.1.0'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: extraspace
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.3
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kevin Sylvestre
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2025-01-07 00:00:00.000000000 Z
11
+ date: 2025-01-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: http
@@ -115,8 +115,8 @@ licenses:
115
115
  metadata:
116
116
  rubygems_mfa_required: 'true'
117
117
  homepage_uri: https://github.com/ksylvest/extraspace
118
- source_code_uri: https://github.com/ksylvest/extraspace/tree/v1.0.3
119
- changelog_uri: https://github.com/ksylvest/extraspace/releases/tag/v1.0.3
118
+ source_code_uri: https://github.com/ksylvest/extraspace/tree/v1.1.0
119
+ changelog_uri: https://github.com/ksylvest/extraspace/releases/tag/v1.1.0
120
120
  documentation_uri: https://extraspace.ksylvest.com/
121
121
  post_install_message:
122
122
  rdoc_options: []