landmarks-of-st-petersburg 0.1.3 → 0.1.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/landmarks/cli.rb +56 -40
- data/lib/landmarks/scraper.rb +9 -11
- data/lib/landmarks/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7c6d24768794e3a8fdada5e76abc853ae5a5300c
|
4
|
+
data.tar.gz: 40daaac7fa4d53dd2960817841b2c4cacfc8f39f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1f24987789579919f0644be16979886e1d2c4012c7f765e09bb9f5ac2d08e4328255e0cdaed1f8610da65035b73c27d94899db87275a7aa1ed5bd8d133f8f25a
|
7
|
+
data.tar.gz: 37ab460ceb55e8e04270bd42e2c9bcb99c7915000d9e294d0f5f311a36d2fc25455c8d4ba100daffb2199b1d6245bebf9fce3e6b8ff456add2ca9ae44ac6914b
|
data/lib/landmarks/cli.rb
CHANGED
@@ -1,13 +1,15 @@
|
|
1
|
+
require 'pry'
|
2
|
+
|
1
3
|
class Landmarks::CLI
|
2
4
|
|
3
5
|
def call
|
4
6
|
puts ""
|
5
7
|
puts "WELCOME TO TOP 20 ST. PETERSBURG ARCHITECTURAL LANDMARKS!"
|
6
|
-
scraper = Landmarks::
|
7
|
-
scraper.print_the_title
|
8
|
-
scraper.scrape_landmarks_index
|
8
|
+
@scraper = Landmarks::Scraper.new
|
9
|
+
@scraper.print_the_title
|
10
|
+
@scraper.scrape_landmarks_index
|
9
11
|
puts ""
|
10
|
-
|
12
|
+
print_landmarks_index
|
11
13
|
puts ""
|
12
14
|
start
|
13
15
|
end
|
@@ -15,57 +17,71 @@ class Landmarks::CLI
|
|
15
17
|
def start
|
16
18
|
puts "Please enter the number of the landmark you would like more information on:"
|
17
19
|
input = gets.chomp.to_i
|
18
|
-
if
|
19
|
-
puts "Please enter a number from 1 to 20!"
|
20
|
-
start
|
21
|
-
end
|
22
|
-
landmark = Landmarks::Landmark.find(input)
|
23
|
-
puts "\t\n"
|
24
|
-
puts landmark.name.strip.upcase
|
25
|
-
puts "\t\n"
|
26
|
-
puts "\t\t\t\t\t\t================== Description of the Landmark =================="
|
27
|
-
puts "\t\n"
|
28
|
-
puts landmark.description
|
29
|
-
puts "\t\n"
|
30
|
-
puts "\t\t\t\t\t\t================================================================="
|
31
|
-
puts "\t\n"
|
32
|
-
puts "Would you like to check the availability of directions, contact information and business hours? y/n"
|
33
|
-
answer = gets.chomp.downcase
|
20
|
+
if input.between?(1, 20)
|
34
21
|
|
35
|
-
|
22
|
+
landmark = Landmarks::Landmark.find(input)
|
23
|
+
# @scraper.scrape_additional_details(landmark)
|
24
|
+
puts "\t\n"
|
25
|
+
puts landmark.name.strip.upcase
|
36
26
|
puts "\t\n"
|
37
|
-
puts "\t\t\t\t\t\t
|
27
|
+
puts "\t\t\t\t\t\t================== Description of the Landmark =================="
|
38
28
|
puts "\t\n"
|
39
|
-
puts landmark.
|
29
|
+
puts landmark.description
|
40
30
|
puts "\t\n"
|
41
31
|
puts "\t\t\t\t\t\t================================================================="
|
42
32
|
puts "\t\n"
|
43
|
-
puts "Would you like to
|
44
|
-
|
33
|
+
puts "Would you like to check the availability of directions, contact information and business hours? y/n"
|
34
|
+
answer = gets.chomp.downcase
|
45
35
|
|
46
|
-
if
|
47
|
-
start
|
48
|
-
else
|
36
|
+
if answer == "y"
|
49
37
|
puts "\t\n"
|
50
|
-
puts "
|
38
|
+
puts "\t\t\t\t\t\t====== Directions, contact information and business hours ======"
|
51
39
|
puts "\t\n"
|
52
|
-
puts
|
40
|
+
puts landmark.directions
|
53
41
|
puts "\t\n"
|
54
|
-
|
42
|
+
puts "\t\t\t\t\t\t================================================================="
|
43
|
+
puts "\t\n"
|
44
|
+
puts "Would you like to find out more about another landmark? y/n"
|
45
|
+
response = gets.chomp.downcase
|
46
|
+
|
47
|
+
if response == "y"
|
48
|
+
start
|
49
|
+
else
|
50
|
+
puts "\t\n"
|
51
|
+
puts "Thank you for your interest! Have a great day, and welcome again in the future!"
|
52
|
+
puts "\t\n"
|
53
|
+
puts "\t\t\t**************************"
|
54
|
+
puts "\t\n"
|
55
|
+
end
|
55
56
|
|
56
|
-
else
|
57
|
-
puts "\t\n"
|
58
|
-
puts "Would you like to find out more about another landmark? y/n"
|
59
|
-
response = gets.chomp.downcase
|
60
|
-
if response == "y"
|
61
|
-
start
|
62
57
|
else
|
63
|
-
puts "Thank you for your interest! Have a great day, and welcome again in the future!"
|
64
|
-
puts "\t\n"
|
65
|
-
puts "\t\t\t**************************"
|
66
58
|
puts "\t\n"
|
59
|
+
puts "Would you like to find out more about another landmark? y/n"
|
60
|
+
response = gets.chomp.downcase
|
61
|
+
if response == "y"
|
62
|
+
start
|
63
|
+
else
|
64
|
+
puts "Thank you for your interest! Have a great day, and welcome again in the future!"
|
65
|
+
puts "\t\n"
|
66
|
+
puts "\t\t\t**************************"
|
67
|
+
puts "\t\n"
|
68
|
+
end
|
69
|
+
end
|
70
|
+
else
|
71
|
+
puts "Please enter a number from 1 to 20!"
|
72
|
+
start
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
def print_landmarks_index
|
77
|
+
Landmarks::Landmark.all.each.with_index do |el, index|
|
78
|
+
if el.name.include?("\r\n")
|
79
|
+
puts "#{index+1}.#{el.name}".gsub("\r\n", "")
|
80
|
+
else
|
81
|
+
puts "#{index+1}.\t#{el.name}"
|
67
82
|
end
|
68
83
|
end
|
84
|
+
nil
|
69
85
|
end
|
70
86
|
|
71
87
|
end
|
data/lib/landmarks/scraper.rb
CHANGED
@@ -9,7 +9,9 @@ class Landmarks::Scraper
|
|
9
9
|
end
|
10
10
|
|
11
11
|
def scrape_landmarks_index
|
12
|
-
self.get_page.css("h2").each
|
12
|
+
self.get_page.css("h2").each do |el|
|
13
|
+
Landmarks::Landmark.new(el.text, "http://www.saint-petersburg.com"+el.css("a").attr("href").text)
|
14
|
+
end
|
13
15
|
end
|
14
16
|
|
15
17
|
|
@@ -17,16 +19,12 @@ class Landmarks::Scraper
|
|
17
19
|
puts self.get_page.css("h1").text
|
18
20
|
end
|
19
21
|
|
20
|
-
def print_landmarks_index
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
end
|
27
|
-
end
|
28
|
-
nil
|
29
|
-
end
|
22
|
+
# def print_landmarks_index
|
23
|
+
# Landmarks::Landmark.all.each.with_index do |el, index|
|
24
|
+
# puts "#{index+1}.\t#{el.name}"
|
25
|
+
# end
|
26
|
+
# nil
|
27
|
+
# end
|
30
28
|
|
31
29
|
def print_landmarks_urls
|
32
30
|
Landmarks::Landmark.all.each.with_index { |el, index| puts "#{index+1}.\t#{el.url}" }
|
data/lib/landmarks/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: landmarks-of-st-petersburg
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- "'Igor Eskin'"
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-08-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|