cubesmart 0.2.0 → 0.4.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e1781d8409650e418c66768205aaa73dd3b95d10c22cfdb58996c4b7d0f813c5
4
- data.tar.gz: 4c9cc3f1d3f3ff55cac8fa8442faea727f3ac885f3224f33e225de9b802ec246
3
+ metadata.gz: '04490c967861512d4d25fd09f917727d68f6d49f67b8c8c3c6c6cb35e49c0eec'
4
+ data.tar.gz: 35323ecbb630e3124f67aa1b424a7bf9c87e9d27a48a3790238c314548b1eadc
5
5
  SHA512:
6
- metadata.gz: b5d64f586345d591466b8b50dacf95baf86c71bbbf2d02f967b88e5768c48e528b5602f2617e10b9f62006d62c4bdcd8ea7f8c485d30b5b0cac85390406f77d4
7
- data.tar.gz: 04356e1ca5ae5fb07435d39e7eb44837146f0b3f2f2b13d373aaf3caeb327f15104b99a6467098c29f622da3e891c54764c67fa05616b271dcd2ecbce433e592
6
+ metadata.gz: a217dd096b6923431d7282a06fb581b87dc660d2b3c94ee778a6531c855390d314dd04846e649887b312e2da18a7f60418461bc7d74b7c91d0c2550102dff6e8
7
+ data.tar.gz: e50bda05ca0c0944682c1c759ffff34dd32042a9739d527f55de1d7d8826893d3dcfa5fd4ecd066893052bd7f1512617b3b6a02e99e404fdf81b2cc06e1dcc4e
@@ -7,6 +7,9 @@ module CubeSmart
7
7
  class Facility
8
8
  class ParseError < StandardError; end
9
9
 
10
+ DEFAULT_EMAIL = 'webleads@cubesmart.com'
11
+ DEFAULT_PHONE = '1-877-279-7585'
12
+
10
13
  SITEMAP_URL = 'https://www.cubesmart.com/sitemap-facility.xml'
11
14
 
12
15
  PRICE_SELECTOR = %w[small medium large].map do |group|
@@ -19,10 +22,22 @@ module CubeSmart
19
22
  # @return [String]
20
23
  attr_accessor :id
21
24
 
25
+ # @attribute [rw] url
26
+ # @return [String]
27
+ attr_accessor :url
28
+
22
29
  # @attribute [rw] name
23
30
  # @return [String]
24
31
  attr_accessor :name
25
32
 
33
+ # @attribute [rw] phone
34
+ # @return [String]
35
+ attr_accessor :phone
36
+
37
+ # @attribute [rw] email
38
+ # @return [String]
39
+ attr_accessor :email
40
+
26
41
  # @attribute [rw] address
27
42
  # @return [Address]
28
43
  attr_accessor :address
@@ -45,22 +60,23 @@ module CubeSmart
45
60
  # @return [Facility]
46
61
  def self.fetch(url:)
47
62
  document = Crawler.html(url:)
48
- parse(document:)
63
+ parse(url:, document:)
49
64
  end
50
65
 
66
+ # @param url [String]
51
67
  # @param document [Nokogiri::HTML::Document]
52
68
  #
53
69
  # @return [Facility]
54
- def self.parse(document:)
70
+ def self.parse(url:, document:)
55
71
  data = parse_json_ld(document:)
56
72
 
57
- id = data['url'].match(ID_REGEX)[:id]
73
+ id = ID_REGEX.match(url)[:id]
58
74
  name = data['name']
59
75
  address = Address.parse(data: data['address'])
60
76
  geocode = Geocode.parse(data: data['geo'])
61
77
  prices = document.css(PRICE_SELECTOR).map { |element| Price.parse(element: element) }
62
78
 
63
- new(id:, name:, address:, geocode:, prices:)
79
+ new(id:, url:, name:, address:, geocode:, prices:)
64
80
  end
65
81
 
66
82
  # @param document [Nokogiri::HTML::Document]
@@ -74,15 +90,21 @@ module CubeSmart
74
90
  end
75
91
 
76
92
  # @param id [String]
93
+ # @param url [String]
77
94
  # @param name [String]
78
95
  # @param address [Address]
79
96
  # @param geocode [Geocode]
97
+ # @param phone [String]
98
+ # @param email [String]
80
99
  # @param prices [Array<Price>]
81
- def initialize(id:, name:, address:, geocode:, prices:)
100
+ def initialize(id:, url:, name:, address:, geocode:, phone: DEFAULT_PHONE, email: DEFAULT_EMAIL, prices: [])
82
101
  @id = id
102
+ @url = url
83
103
  @name = name
84
104
  @address = address
85
105
  @geocode = geocode
106
+ @phone = phone
107
+ @email = email
86
108
  @prices = prices
87
109
  end
88
110
 
@@ -90,8 +112,11 @@ module CubeSmart
90
112
  def inspect
91
113
  props = [
92
114
  "id=#{@id.inspect}",
115
+ "url=#{@url.inspect}",
93
116
  "address=#{@address.inspect}",
94
117
  "geocode=#{@geocode.inspect}",
118
+ "phone=#{@phone.inspect}",
119
+ "email=#{@email.inspect}",
95
120
  "prices=#{@prices.inspect}"
96
121
  ]
97
122
  "#<#{self.class.name} #{props.join(' ')}>"
@@ -99,7 +124,7 @@ module CubeSmart
99
124
 
100
125
  # @return [String]
101
126
  def text
102
- "#{@id} | #{@name} | #{@address.text} | #{@geocode.text}"
127
+ "#{@id} | #{@name} | #{@phone} | #{@email} | #{@address.text} | #{@geocode.text}"
103
128
  end
104
129
  end
105
130
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module CubeSmart
4
- VERSION = '0.2.0'
4
+ VERSION = '0.4.0'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cubesmart
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.4.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-03 00:00:00.000000000 Z
11
+ date: 2024-12-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: http