uhaul 1.0.3 → 1.0.5

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: 4acc4dc138e904232902f124d9ee0c78923dc74c609c42515b97e83cdeea3fb2
4
- data.tar.gz: 9e98885feb0367400d6a444f191b859d2e54abf646c9dda26938545f0d2bf8c6
3
+ metadata.gz: b388432681a65491cb00ec0e857de4c53d52694cac0c1aadbc0525c5b867f84b
4
+ data.tar.gz: 728069489c8363a38ca497177e2ea79a460ec508e20bd925fa56b7cecd8290dd
5
5
  SHA512:
6
- metadata.gz: 3ecf98d2ab243fe983f6ef926c6fd425d988676173892a92990845b489561de61525ea30653d66c1b9d5956842006901064847c46aba4c5b9894c8f1a2846940
7
- data.tar.gz: dde69a5ed918065d156872112b37b6d67b6f04a462f18f492da53ca7ecd56224ad38d1659f9e0b2bfa86f7e2f79684a0f7cdf391e1dbbece994e80dfec480e40
6
+ metadata.gz: 6dab025e1b62ef31777c9b953b819e3024c9e58740fa0178b8de517c6cbec40981b360da876d773fcc9808a460c9be3f87a615521dc749691be784ce157978b7
7
+ data.tar.gz: 4566c08f42643043adee459e644199f3e7003390713c64cbf3e99470ba171bc6618494a872dd4110fbf4a7b9e3d871679ce22bd568acf0f459687ce6a318490a
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # UHaul
1
+ # U-Haul
2
2
 
3
3
  [![LICENSE](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/ksylvest/uhaul/blob/main/LICENSE)
4
4
  [![RubyGems](https://img.shields.io/gem/v/uhaul)](https://rubygems.org/gems/uhaul)
@@ -6,6 +6,8 @@
6
6
  [![Yard](https://img.shields.io/badge/docs-site-blue.svg)](https://uhaul.ksylvest.com)
7
7
  [![CircleCI](https://img.shields.io/circleci/build/github/ksylvest/uhaul)](https://circleci.com/gh/ksylvest/uhaul)
8
8
 
9
+ A Ruby library offering both a CLI and API for scraping [U-Haul](https://www.publicstorage.com/) self-storage facilities and prices.
10
+
9
11
  ## Installation
10
12
 
11
13
  ```bash
@@ -49,3 +51,7 @@ end
49
51
  ```bash
50
52
  uhaul crawl
51
53
  ```
54
+
55
+ ```bash
56
+ uhaul crawl "https://www.uhaul.com/Locations/Self-Storage-near-Manchester-Township-NJ-08759/925037/"
57
+ ```
data/lib/uhaul/cli.rb CHANGED
@@ -21,7 +21,7 @@ module UHaul
21
21
  command = argv.shift
22
22
 
23
23
  case command
24
- when 'crawl' then crawl
24
+ when 'crawl' then crawl(*argv)
25
25
  else
26
26
  warn("unsupported command=#{command.inspect}")
27
27
  exit(Code::ERROR)
@@ -30,8 +30,9 @@ module UHaul
30
30
 
31
31
  private
32
32
 
33
- def crawl
34
- Crawl.run
33
+ # @param url [String] optional
34
+ def crawl(url = nil)
35
+ Crawl.run(url: url)
35
36
  exit(Code::OK)
36
37
  end
37
38
 
@@ -52,6 +53,11 @@ module UHaul
52
53
 
53
54
  options.on('-h', '--help', 'help') { help(options) }
54
55
  options.on('-v', '--version', 'version') { version }
56
+
57
+ options.separator <<~COMMANDS
58
+ commands:
59
+ crawl [url]
60
+ COMMANDS
55
61
  end
56
62
  end
57
63
  end
data/lib/uhaul/crawl.rb CHANGED
@@ -9,19 +9,22 @@ module UHaul
9
9
 
10
10
  # @param stdout [IO] optional
11
11
  # @param stderr [IO] optional
12
- # @param options [Hash] optional
13
- def initialize(stdout: $stdout, stderr: $stderr, options: {})
12
+ # @param url [String] optional
13
+ def initialize(stdout: $stdout, stderr: $stderr, url: nil)
14
14
  @stdout = stdout
15
15
  @stderr = stderr
16
- @options = options
16
+ @url = url
17
17
  end
18
18
 
19
19
  def run
20
- sitemap = Facility.sitemap
21
- @stdout.puts("count=#{sitemap.links.count}")
22
- @stdout.puts
23
-
24
- sitemap.links.each { |link| process(url: link.loc) }
20
+ if @url
21
+ process(url: @url)
22
+ else
23
+ sitemap = Facility.sitemap
24
+ @stdout.puts("count=#{sitemap.links.count}")
25
+ @stdout.puts
26
+ sitemap.links.each { |link| process(url: link.loc) }
27
+ end
25
28
  end
26
29
 
27
30
  def process(url:)
data/lib/uhaul/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module UHaul
4
- VERSION = '1.0.3'
4
+ VERSION = '1.0.5'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: uhaul
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.3
4
+ version: 1.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kevin Sylvestre
@@ -115,8 +115,9 @@ licenses:
115
115
  metadata:
116
116
  rubygems_mfa_required: 'true'
117
117
  homepage_uri: https://github.com/ksylvest/uhaul
118
- source_code_uri: https://github.com/ksylvest/uhaul
119
- changelog_uri: https://github.com/ksylvest/uhaul
118
+ source_code_uri: https://github.com/ksylvest/uhaul/tree/v1.0.5
119
+ changelog_uri: https://github.com/ksylvest/uhaul/releases/tag/v1.0.5
120
+ documentation_uri: https://uhaul.ksylvest.com/
120
121
  post_install_message:
121
122
  rdoc_options: []
122
123
  require_paths: