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 +4 -4
- data/README.md +2 -0
- data/lib/classifieds/auto_scraper.rb +5 -4
- data/lib/classifieds/cli.rb +7 -9
- data/lib/classifieds/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 33e4a46de8e75a9e21d143a9a669af81e39ab4de
|
|
4
|
+
data.tar.gz: 440366a576f661b902cec53665f6dcac59db6bbb
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
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
|
-
|
|
19
|
-
|
|
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
|
|
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
|
|
97
|
+
doc[0].text.strip
|
|
97
98
|
end
|
|
98
99
|
|
|
99
100
|
PHONE_PATTERN = '\(\d\d\d\) \d\d\d-\d\d\d\d'
|
data/lib/classifieds/cli.rb
CHANGED
|
@@ -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
|
-
|
|
62
|
-
|
|
63
|
-
|
|
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
|
data/lib/classifieds/version.rb
CHANGED