classifieds_cli_app 0.1.3 → 0.1.4

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
  SHA1:
3
- metadata.gz: c16f45478a5a574ffad8f21da75ab3c5d82be2ac
4
- data.tar.gz: 33cb3156c226ffec9ccee433077c0f80a61758bc
3
+ metadata.gz: 33e4a46de8e75a9e21d143a9a669af81e39ab4de
4
+ data.tar.gz: 440366a576f661b902cec53665f6dcac59db6bbb
5
5
  SHA512:
6
- metadata.gz: 7295e6ab313b0d86a611a3e0c43c140df3526bfd48b6411b2fb9ce1b40a0090b9cb0924c515cf17338dc51a20a541e3d85e8426efbff6df2a86e938162528efa
7
- data.tar.gz: b653a96f8ae4be2341ac1979e08ec111d1798397e6a1b1909193f83904331bb9feefb0da345cf44b1d56d2e814b59dc7bd72ad05c4cdcaea5b2a17b65a8f30ad
6
+ metadata.gz: 4ee2c22f518fb5796cd6e59053d59c48edd5575c51e4d3dea205a1bc7f6b60d2752c52db2d0443ca345bccd7d1d46dc91c99733ad7ed2429104a14ec4f15ca8a
7
+ data.tar.gz: 20270afafe8f29ee3957915ec2753f594e67355642069e72c3d8aaa88d18770b2af54c7b8599fd815214922d085422a83d8be5e24af6e5bd72d7076dd0af096b
data/README.md CHANGED
@@ -6,6 +6,8 @@ This gem was created to meet the requirements of the learn.co CLI Data Gem Proje
6
6
  0.1.1 Initial release.
7
7
  0.1.2 Improved column display formatting.
8
8
  0.1.3 Improved use of Nokogiri methods.
9
+ 0.1.4 Fix scrape bug introduced in 0.1.3.
10
+ Display invalid input message if user enters item number 0.
9
11
 
10
12
  ## Installation
11
13
 
@@ -15,8 +15,9 @@ class Classifieds::AutoScraper # converts automobile classified listings into o
15
15
  sale_price = sale_price(description_pod_div)
16
16
 
17
17
  contact_div = result.at_css('.contactLinks')
18
- seller_name = seller_name(contact_div)
19
- seller_location = seller_location(contact_div)
18
+ contact_strong = contact_div.css('strong')
19
+ seller_name = seller_name(contact_strong)
20
+ seller_location = seller_location(contact_strong)
20
21
  seller_phone = seller_phone(contact_div, id, results_url_file)
21
22
 
22
23
  detail_url = detail_url(results_url, result)
@@ -88,12 +89,12 @@ private
88
89
 
89
90
  # Returns the seller's address
90
91
  def self.seller_location(doc)
91
- doc.at_css('strong')[1].text.strip
92
+ doc[1].text.strip
92
93
  end
93
94
 
94
95
  # Returns the seller's name
95
96
  def self.seller_name(doc)
96
- doc.at_css('strong')[0].text.strip
97
+ doc[0].text.strip
97
98
  end
98
99
 
99
100
  PHONE_PATTERN = '\(\d\d\d\) \d\d\d-\d\d\d\d'
@@ -56,17 +56,15 @@ class Classifieds::CLI # is the command line interface for the classified app
56
56
  continue_program = false
57
57
  # when 's'
58
58
  # # list sellers instead of items
59
+ when ''
60
+ # display next summary rows
59
61
  else
60
- item_number = user_input.to_i
61
- if 0 < item_number
62
- index = item_number - 1
63
- if index < Classifieds::Listing.all.size
64
- Classifieds::Listing.all[index].print_detail(item_number)
65
- else
66
- STDERR.puts Classifieds::CLI.red('Invalid selection')
67
- end
68
- Classifieds::CLI.prompt 'Press Enter to continue...'
62
+ if (item_number = user_input.to_i).between?(1, Classifieds::Listing.all.size)
63
+ Classifieds::Listing.all[item_number-1].print_detail(item_number)
64
+ else
65
+ STDERR.puts Classifieds::CLI.red('Invalid selection')
69
66
  end
67
+ Classifieds::CLI.prompt 'Press Enter to continue...'
70
68
  end
71
69
  continue_program
72
70
  end
@@ -1,3 +1,3 @@
1
1
  module Classifieds
2
- VERSION = "0.1.3"
2
+ VERSION = "0.1.4"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: classifieds_cli_app
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - John Pfingst