top_ten 0.1.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 +7 -0
- data/bin/top_ten +5 -0
- data/lib/top_ten/cli.rb +50 -0
- data/lib/top_ten/scraper.rb +14 -0
- data/lib/top_ten/top.rb +13 -0
- data/lib/top_ten/version.rb +3 -0
- data/lib/top_ten.rb +9 -0
- metadata +109 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: 8b62abee2012a0ffc2debfe8fec736c512f364175c51ebd6d621b85218f83b41
|
|
4
|
+
data.tar.gz: 4ec27b63e4b2cecf9c8fb58110cd16e9d1a1247844afd252a3004b87b3552ed7
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: a13eadf32b315cfae6fe2ad78202b077457c1b7a7463e778850d5f7b0524ba1d8600e4119a41c46bb2e2e083c38e89af7277a9c57bf7ed17a5b71b441517c03e
|
|
7
|
+
data.tar.gz: f2385f916b71e00cc26a4447d465d766160ae8066aaed319d6aa8356158ec36da8f9a3e427444b2223f06630a746ae4d49895f890a5219b076093555839a4f51
|
data/bin/top_ten
ADDED
data/lib/top_ten/cli.rb
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
class TopTen::CLI
|
|
2
|
+
|
|
3
|
+
def call
|
|
4
|
+
welcome
|
|
5
|
+
TopTen::Scraper.scrape_country
|
|
6
|
+
list_countries
|
|
7
|
+
menu
|
|
8
|
+
goodbye
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def welcome
|
|
12
|
+
puts "Welcome, traveler!"
|
|
13
|
+
puts "Not sure where you should go in 2018?"
|
|
14
|
+
puts "This should help!"
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def countries
|
|
18
|
+
@countries = TopTen::Top.all
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
def list_countries
|
|
22
|
+
puts "Here are Lonely Planet's Best in Travel Top 10 Countries to Visit in 2018:"
|
|
23
|
+
countries.each do |country|
|
|
24
|
+
puts "#{country.name}"
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
def menu
|
|
29
|
+
puts "Enter the number of the country you would like to learn more about."
|
|
30
|
+
puts "You can also enter 'list' to view the list again or 'exit' to exit the program."
|
|
31
|
+
input = gets.strip.downcase
|
|
32
|
+
|
|
33
|
+
if input != "exit"
|
|
34
|
+
if input.to_i.between?(1,10)
|
|
35
|
+
the_country = @countries[input.to_i - 1]
|
|
36
|
+
puts "#{the_country.name} - #{the_country.description}"
|
|
37
|
+
elsif input == "list"
|
|
38
|
+
list_countries
|
|
39
|
+
else
|
|
40
|
+
puts "Not sure what you mean."
|
|
41
|
+
end
|
|
42
|
+
menu
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
def goodbye
|
|
47
|
+
puts "Safe travels! See you next time!"
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
end
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
class TopTen::Scraper
|
|
2
|
+
|
|
3
|
+
def self.scrape_country
|
|
4
|
+
doc = Nokogiri::HTML(open("https://www.lonelyplanet.com/best-in-travel/countries"))
|
|
5
|
+
countries = doc.css(".marketing-article")
|
|
6
|
+
countries.collect do |country|
|
|
7
|
+
new_country = TopTen::Top.new
|
|
8
|
+
new_country.name = country.css("h1").text
|
|
9
|
+
new_country.description = country.css(".marketing-article__content").text.strip
|
|
10
|
+
|
|
11
|
+
new_country.save
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
end
|
data/lib/top_ten/top.rb
ADDED
data/lib/top_ten.rb
ADDED
metadata
ADDED
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: top_ten
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.1.0
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Alavia
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: bin
|
|
10
|
+
cert_chain: []
|
|
11
|
+
date: 2018-07-22 00:00:00.000000000 Z
|
|
12
|
+
dependencies:
|
|
13
|
+
- !ruby/object:Gem::Dependency
|
|
14
|
+
name: bundler
|
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
|
16
|
+
requirements:
|
|
17
|
+
- - "~>"
|
|
18
|
+
- !ruby/object:Gem::Version
|
|
19
|
+
version: '1.16'
|
|
20
|
+
type: :development
|
|
21
|
+
prerelease: false
|
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
23
|
+
requirements:
|
|
24
|
+
- - "~>"
|
|
25
|
+
- !ruby/object:Gem::Version
|
|
26
|
+
version: '1.16'
|
|
27
|
+
- !ruby/object:Gem::Dependency
|
|
28
|
+
name: rake
|
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
|
30
|
+
requirements:
|
|
31
|
+
- - "~>"
|
|
32
|
+
- !ruby/object:Gem::Version
|
|
33
|
+
version: '10.0'
|
|
34
|
+
type: :development
|
|
35
|
+
prerelease: false
|
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
37
|
+
requirements:
|
|
38
|
+
- - "~>"
|
|
39
|
+
- !ruby/object:Gem::Version
|
|
40
|
+
version: '10.0'
|
|
41
|
+
- !ruby/object:Gem::Dependency
|
|
42
|
+
name: pry
|
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
|
44
|
+
requirements:
|
|
45
|
+
- - ">="
|
|
46
|
+
- !ruby/object:Gem::Version
|
|
47
|
+
version: '0'
|
|
48
|
+
type: :development
|
|
49
|
+
prerelease: false
|
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
51
|
+
requirements:
|
|
52
|
+
- - ">="
|
|
53
|
+
- !ruby/object:Gem::Version
|
|
54
|
+
version: '0'
|
|
55
|
+
- !ruby/object:Gem::Dependency
|
|
56
|
+
name: nokogiri
|
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
|
58
|
+
requirements:
|
|
59
|
+
- - ">="
|
|
60
|
+
- !ruby/object:Gem::Version
|
|
61
|
+
version: '0'
|
|
62
|
+
type: :runtime
|
|
63
|
+
prerelease: false
|
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
65
|
+
requirements:
|
|
66
|
+
- - ">="
|
|
67
|
+
- !ruby/object:Gem::Version
|
|
68
|
+
version: '0'
|
|
69
|
+
description: This gem will teach you about Lonely Planet's Best in Travel Top 10 Countries
|
|
70
|
+
to Visit in 2018.
|
|
71
|
+
email:
|
|
72
|
+
- alavia.yahya@gmail.com
|
|
73
|
+
executables:
|
|
74
|
+
- top_ten
|
|
75
|
+
extensions: []
|
|
76
|
+
extra_rdoc_files: []
|
|
77
|
+
files:
|
|
78
|
+
- bin/top_ten
|
|
79
|
+
- lib/top_ten.rb
|
|
80
|
+
- lib/top_ten/cli.rb
|
|
81
|
+
- lib/top_ten/scraper.rb
|
|
82
|
+
- lib/top_ten/top.rb
|
|
83
|
+
- lib/top_ten/version.rb
|
|
84
|
+
homepage: https://github.com/alavia/top_ten
|
|
85
|
+
licenses:
|
|
86
|
+
- MIT
|
|
87
|
+
metadata: {}
|
|
88
|
+
post_install_message:
|
|
89
|
+
rdoc_options: []
|
|
90
|
+
require_paths:
|
|
91
|
+
- lib
|
|
92
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
93
|
+
requirements:
|
|
94
|
+
- - ">="
|
|
95
|
+
- !ruby/object:Gem::Version
|
|
96
|
+
version: '0'
|
|
97
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
98
|
+
requirements:
|
|
99
|
+
- - ">="
|
|
100
|
+
- !ruby/object:Gem::Version
|
|
101
|
+
version: '0'
|
|
102
|
+
requirements: []
|
|
103
|
+
rubyforge_project:
|
|
104
|
+
rubygems_version: 2.7.6
|
|
105
|
+
signing_key:
|
|
106
|
+
specification_version: 4
|
|
107
|
+
summary: Scrapes Lonely Planet website to display top 10 countries to visit in 2018
|
|
108
|
+
with details about countries.
|
|
109
|
+
test_files: []
|