nsastorage 0.8.0 → 1.0.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: 25f9928da25644b2ac5762c8c400bc97d14f75421ea2f6b717931ef3b1de2ac8
4
- data.tar.gz: 9b561d664872d11ac2478840f8f55c8daeaeef67e1e48d2b509ca033f3cfd0b3
3
+ metadata.gz: e1449618a0f78eef6911c81caf0d8af5c1c3b3f372da510e7bbde4dd615f629f
4
+ data.tar.gz: 97d8d7a0814af12b1cebe8c844c5289aada32b1975a29e0fbd2fd6ae1d4ff924
5
5
  SHA512:
6
- metadata.gz: 45b801b891ec0be544495c8f766d28e605a933b934d7ff2e8c60fae09480097ab764eca457bc883744c15794b35003479ff1ba45c0fc88a8a2272031f1ed2ac8
7
- data.tar.gz: 32cd81b1a9a8a3a012e573e87cffadf79c164e4d67b4fe514ee79dd37da901b609e7ea22b6c8a05cd1b7a7526af218dad97fe5921389584fe562eb6b024d44d4
6
+ metadata.gz: 0add97c3b44b57b0f8611580e392a7c3cef55dd646c1dd67038bbb7b066ad22951fcbd2d4f425ce9438c8b811ae63b4f42c186f121ddb860dc076b0b0252067c
7
+ data.tar.gz: '0096c864db029f0dc90d9c35d5e32eed388e22c66f49085aec5173fbd079c0e06d7392afbcb19a2fe8e16e7f0198f2d091fe4c095bcab837a6efd7f5b7dd530d'
@@ -3,6 +3,8 @@
3
3
  module NSAStorage
4
4
  # The dimensions (width + depth + sqft) of a price.
5
5
  class Dimensions
6
+ DEFAULT_WIDTH = 5.0 # feet
7
+ DEFAULT_DEPTH = 5.0 # feet
6
8
  DEFAULT_HEIGHT = 8.0 # feet
7
9
 
8
10
  DIMENSIONS_REGEX = /(?<width>[\d\.]+) x (?<depth>[\d\.]+)/
@@ -65,8 +67,8 @@ module NSAStorage
65
67
  text = element.at_css('.unit-select-item-detail').text
66
68
  match = DIMENSIONS_REGEX.match(text)
67
69
 
68
- width = Float(match[:width])
69
- depth = Float(match[:depth])
70
+ width = match ? Float(match[:width]) : DEFAULT_WIDTH
71
+ depth = match ? Float(match[:depth]) : DEFAULT_DEPTH
70
72
  new(depth:, width:, height: DEFAULT_HEIGHT)
71
73
  end
72
74
  end
@@ -27,7 +27,10 @@ module NSAStorage
27
27
  # @return [Array<Price>]
28
28
  def self.fetch(facility_id:)
29
29
  url = "https://www.nsastorage.com/facility-units/#{facility_id}"
30
- html = Crawler.json(url:)['data']['html']['units']
30
+ data = Crawler.json(url:)['data']
31
+ return [] if data['error']
32
+
33
+ html = data['html']['units']
31
34
  Nokogiri::HTML(html).css(PRICE_SELECTOR).map { |element| parse(element:) }
32
35
  end
33
36
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module NSAStorage
4
- VERSION = '0.8.0'
4
+ VERSION = '1.0.0'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nsastorage
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.0
4
+ version: 1.0.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: 2024-12-11 00:00:00.000000000 Z
11
+ date: 2024-12-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: http