cubesmart 0.3.0 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/cubesmart/facility.rb +13 -5
- data/lib/cubesmart/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: '04490c967861512d4d25fd09f917727d68f6d49f67b8c8c3c6c6cb35e49c0eec'
|
4
|
+
data.tar.gz: 35323ecbb630e3124f67aa1b424a7bf9c87e9d27a48a3790238c314548b1eadc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a217dd096b6923431d7282a06fb581b87dc660d2b3c94ee778a6531c855390d314dd04846e649887b312e2da18a7f60418461bc7d74b7c91d0c2550102dff6e8
|
7
|
+
data.tar.gz: e50bda05ca0c0944682c1c759ffff34dd32042a9739d527f55de1d7d8826893d3dcfa5fd4ecd066893052bd7f1512617b3b6a02e99e404fdf81b2cc06e1dcc4e
|
data/lib/cubesmart/facility.rb
CHANGED
@@ -22,6 +22,10 @@ module CubeSmart
|
|
22
22
|
# @return [String]
|
23
23
|
attr_accessor :id
|
24
24
|
|
25
|
+
# @attribute [rw] url
|
26
|
+
# @return [String]
|
27
|
+
attr_accessor :url
|
28
|
+
|
25
29
|
# @attribute [rw] name
|
26
30
|
# @return [String]
|
27
31
|
attr_accessor :name
|
@@ -56,22 +60,23 @@ module CubeSmart
|
|
56
60
|
# @return [Facility]
|
57
61
|
def self.fetch(url:)
|
58
62
|
document = Crawler.html(url:)
|
59
|
-
parse(document:)
|
63
|
+
parse(url:, document:)
|
60
64
|
end
|
61
65
|
|
66
|
+
# @param url [String]
|
62
67
|
# @param document [Nokogiri::HTML::Document]
|
63
68
|
#
|
64
69
|
# @return [Facility]
|
65
|
-
def self.parse(document:)
|
70
|
+
def self.parse(url:, document:)
|
66
71
|
data = parse_json_ld(document:)
|
67
72
|
|
68
|
-
id =
|
73
|
+
id = ID_REGEX.match(url)[:id]
|
69
74
|
name = data['name']
|
70
75
|
address = Address.parse(data: data['address'])
|
71
76
|
geocode = Geocode.parse(data: data['geo'])
|
72
77
|
prices = document.css(PRICE_SELECTOR).map { |element| Price.parse(element: element) }
|
73
78
|
|
74
|
-
new(id:, name:, address:, geocode:, prices:)
|
79
|
+
new(id:, url:, name:, address:, geocode:, prices:)
|
75
80
|
end
|
76
81
|
|
77
82
|
# @param document [Nokogiri::HTML::Document]
|
@@ -85,14 +90,16 @@ module CubeSmart
|
|
85
90
|
end
|
86
91
|
|
87
92
|
# @param id [String]
|
93
|
+
# @param url [String]
|
88
94
|
# @param name [String]
|
89
95
|
# @param address [Address]
|
90
96
|
# @param geocode [Geocode]
|
91
97
|
# @param phone [String]
|
92
98
|
# @param email [String]
|
93
99
|
# @param prices [Array<Price>]
|
94
|
-
def initialize(id:, name:, address:, geocode:, phone: DEFAULT_PHONE, email: DEFAULT_EMAIL, prices: [])
|
100
|
+
def initialize(id:, url:, name:, address:, geocode:, phone: DEFAULT_PHONE, email: DEFAULT_EMAIL, prices: [])
|
95
101
|
@id = id
|
102
|
+
@url = url
|
96
103
|
@name = name
|
97
104
|
@address = address
|
98
105
|
@geocode = geocode
|
@@ -105,6 +112,7 @@ module CubeSmart
|
|
105
112
|
def inspect
|
106
113
|
props = [
|
107
114
|
"id=#{@id.inspect}",
|
115
|
+
"url=#{@url.inspect}",
|
108
116
|
"address=#{@address.inspect}",
|
109
117
|
"geocode=#{@geocode.inspect}",
|
110
118
|
"phone=#{@phone.inspect}",
|
data/lib/cubesmart/version.rb
CHANGED