publicstorage 1.0.0 → 1.2.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 +4 -4
- data/lib/publicstorage/dimensions.rb +22 -11
- data/lib/publicstorage/facility.rb +27 -4
- data/lib/publicstorage/version.rb +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 24f5bb4366cb716cf259fb43e0df167617389a71bbcffa20c2e3534c588b06c1
|
4
|
+
data.tar.gz: 5b3be4bad58043fdfe30dee4067935bfc2346b778c967231155b670490a08d70
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e117b9fa84c46cbae5a14756cb4f5926a6a1405a91be4963c112fbe2c22d71f8090a33df5ad4b7c9a9126c64c09b524caaa01a1e10c58975d98b5ee593f22a4e
|
7
|
+
data.tar.gz: 15e95167c0d18276093a62594d95c13b9d2be48276541045c3b683b14748fbe65f38d43e58aeb609e75c3dc98cd82dc688d54d8a22aeb7ebbc514d4dd5e90dbd
|
@@ -1,8 +1,10 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module PublicStorage
|
4
|
-
# The dimensions (width + depth +
|
4
|
+
# The dimensions (width + depth + height) of a price.
|
5
5
|
class Dimensions
|
6
|
+
DEFAULT_HEIGHT = 8.0 # feet
|
7
|
+
|
6
8
|
SELECTOR = '.unit-size'
|
7
9
|
|
8
10
|
# @attribute [rw] depth
|
@@ -13,17 +15,17 @@ module PublicStorage
|
|
13
15
|
# @return [Integer]
|
14
16
|
attr_accessor :width
|
15
17
|
|
16
|
-
# @attribute [rw]
|
17
|
-
#
|
18
|
-
attr_accessor :
|
18
|
+
# @attribute [rw] height
|
19
|
+
# @return [Integer]
|
20
|
+
attr_accessor :height
|
19
21
|
|
20
22
|
# @param depth [Float]
|
21
23
|
# @param width [Float]
|
22
|
-
# @param
|
23
|
-
def initialize(depth:, width:,
|
24
|
+
# @param height [Float]
|
25
|
+
def initialize(depth:, width:, height: DEFAULT_HEIGHT)
|
24
26
|
@depth = depth
|
25
27
|
@width = width
|
26
|
-
@
|
28
|
+
@height = height
|
27
29
|
end
|
28
30
|
|
29
31
|
# @return [String]
|
@@ -31,14 +33,24 @@ module PublicStorage
|
|
31
33
|
props = [
|
32
34
|
"depth=#{@depth.inspect}",
|
33
35
|
"width=#{@width.inspect}",
|
34
|
-
"
|
36
|
+
"height=#{@height.inspect}"
|
35
37
|
]
|
36
38
|
"#<#{self.class.name} #{props.join(' ')}>"
|
37
39
|
end
|
38
40
|
|
39
41
|
# @return [String] e.g. "10' × 10' (100 sqft)"
|
40
42
|
def text
|
41
|
-
"#{format('%g', @width)}' × #{format('%g', @depth)}' (#{
|
43
|
+
"#{format('%g', @width)}' × #{format('%g', @depth)}' (#{sqft} sqft)"
|
44
|
+
end
|
45
|
+
|
46
|
+
# @return [Integer]
|
47
|
+
def sqft
|
48
|
+
Integer(@width * @depth)
|
49
|
+
end
|
50
|
+
|
51
|
+
# @return [Integer]
|
52
|
+
def cuft
|
53
|
+
Integer(@width * @depth * @height)
|
42
54
|
end
|
43
55
|
|
44
56
|
# @param data [Hash]
|
@@ -48,9 +60,8 @@ module PublicStorage
|
|
48
60
|
match = data['dimension'].match(/(?<depth>[\d\.]+)'x(?<width>[\d\.]+)'/)
|
49
61
|
depth = Float(match[:depth])
|
50
62
|
width = Float(match[:width])
|
51
|
-
sqft = Integer(depth * width)
|
52
63
|
|
53
|
-
new(depth:, width:,
|
64
|
+
new(depth:, width:, height: DEFAULT_HEIGHT)
|
54
65
|
end
|
55
66
|
end
|
56
67
|
end
|
@@ -5,6 +5,9 @@ module PublicStorage
|
|
5
5
|
class Facility
|
6
6
|
SITEMAP_URL = 'https://www.publicstorage.com/sitemap_0-product.xml'
|
7
7
|
|
8
|
+
DEFAULT_PHONE = '1-800-742-8048'
|
9
|
+
DEFAULT_EMAIL = 'customerservice@publicstorage.com'
|
10
|
+
|
8
11
|
PRICE_SELECTOR = '.units-results-section .unit-list-group .unit-list-item'
|
9
12
|
LD_SELECTOR = 'script[type="application/ld+json"]'
|
10
13
|
|
@@ -14,10 +17,22 @@ module PublicStorage
|
|
14
17
|
# @return [Integer]
|
15
18
|
attr_accessor :id
|
16
19
|
|
20
|
+
# @attribute [rw] url
|
21
|
+
# @return [String]
|
22
|
+
attr_accessor :url
|
23
|
+
|
17
24
|
# @attribute [rw] name
|
18
25
|
# @return [String]
|
19
26
|
attr_accessor :name
|
20
27
|
|
28
|
+
# @attribute [rw] phone
|
29
|
+
# @return [String]
|
30
|
+
attr_accessor :phone
|
31
|
+
|
32
|
+
# @attribute [rw] email
|
33
|
+
# @return [String]
|
34
|
+
attr_accessor :email
|
35
|
+
|
21
36
|
# @attribute [rw] address
|
22
37
|
# @return [Address]
|
23
38
|
attr_accessor :address
|
@@ -40,13 +55,13 @@ module PublicStorage
|
|
40
55
|
# @return [Facility]
|
41
56
|
def self.fetch(url:)
|
42
57
|
document = Crawler.html(url:)
|
43
|
-
parse(document:)
|
58
|
+
parse(url:, document:)
|
44
59
|
end
|
45
60
|
|
46
61
|
# @param document [NokoGiri::XML::Document]
|
47
62
|
#
|
48
63
|
# @return [Facility]
|
49
|
-
def self.parse(document:)
|
64
|
+
def self.parse(url:, document:)
|
50
65
|
data = parse_ld(document:)
|
51
66
|
id = Integer(data['url'].match(ID_REGEX)[:id])
|
52
67
|
name = data['name']
|
@@ -55,7 +70,7 @@ module PublicStorage
|
|
55
70
|
|
56
71
|
prices = document.css(PRICE_SELECTOR).map { |element| Price.parse(element:) }
|
57
72
|
|
58
|
-
new(id:, name:, address:, geocode:, prices:)
|
73
|
+
new(id:, url:, name:, address:, geocode:, prices:)
|
59
74
|
end
|
60
75
|
|
61
76
|
# @param document [NokoGiri::XML::Document]
|
@@ -81,23 +96,31 @@ module PublicStorage
|
|
81
96
|
end
|
82
97
|
|
83
98
|
# @param id [String]
|
99
|
+
# @param url [String]
|
84
100
|
# @param name [String]
|
85
101
|
# @param address [Address]
|
86
102
|
# @param geocode [Geocode]
|
87
103
|
# @param prices [Array<Price>]
|
88
|
-
def initialize(id:, name:, address:, geocode:, prices:)
|
104
|
+
def initialize(id:, url:, name:, address:, geocode:, phone: DEFAULT_PHONE, email: DEFAULT_EMAIL, prices: [])
|
89
105
|
@id = id
|
106
|
+
@url = url
|
90
107
|
@name = name
|
91
108
|
@address = address
|
92
109
|
@geocode = geocode
|
110
|
+
@phone = phone
|
111
|
+
@email = email
|
93
112
|
@prices = prices
|
94
113
|
end
|
95
114
|
|
96
115
|
# @return [String]
|
97
116
|
def inspect
|
98
117
|
props = [
|
118
|
+
"id=#{@id.inspect}",
|
119
|
+
"url=#{@url.inspect}",
|
99
120
|
"address=#{@address.inspect}",
|
100
121
|
"geocode=#{@geocode.inspect}",
|
122
|
+
"phone=#{@phone.inspect}",
|
123
|
+
"email=#{@email.inspect}",
|
101
124
|
"prices=#{@prices.inspect}"
|
102
125
|
]
|
103
126
|
"#<#{self.class.name} #{props.join(' ')}>"
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: publicstorage
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.2.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:
|
11
|
+
date: 2025-01-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: http
|
@@ -100,8 +100,8 @@ licenses:
|
|
100
100
|
metadata:
|
101
101
|
rubygems_mfa_required: 'true'
|
102
102
|
homepage_uri: https://github.com/ksylvest/publicstorage
|
103
|
-
source_code_uri: https://github.com/ksylvest/publicstorage/tree/v1.
|
104
|
-
changelog_uri: https://github.com/ksylvest/publicstorage/releases/tag/v1.
|
103
|
+
source_code_uri: https://github.com/ksylvest/publicstorage/tree/v1.2.0
|
104
|
+
changelog_uri: https://github.com/ksylvest/publicstorage/releases/tag/v1.2.0
|
105
105
|
documentation_uri: https://publicstorage.ksylvest.com/
|
106
106
|
post_install_message:
|
107
107
|
rdoc_options: []
|