top-travel-destinations-cli-gem 1.1.0 → 1.2.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 +4 -4
- data/Gemfile.lock +47 -0
- data/lib/top_travel_destinations/cli.rb +2 -11
- data/lib/top_travel_destinations/region.rb +16 -0
- data/lib/top_travel_destinations/scraper.rb +2 -14
- data/lib/top_travel_destinations/version.rb +1 -1
- data/pkg/top-travel-destinations-cli-gem-1.2.0.gem +0 -0
- data/top-travel-destinations-cli-gem-1.1.0.gem +0 -0
- data/top_travel_destinations.gemspec +1 -1
- metadata +7 -4
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 0e8a820e99855dde9db204f393c40bbedd3d730c
|
|
4
|
+
data.tar.gz: 255dfa7e4d16aabe03daddb76f40cb81aa53027d
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 974d7ee2b07c7e9a2e7e9b89f09bc6edfc8824766cfe038fd887a4df0ed463ff9eb04c51d9bc5dd31fe47095c26102c32f41af2434b695673d9953b50a68c0ee
|
|
7
|
+
data.tar.gz: d1ca9ac4d7384d9fa29373480eadfff7c209454fe229abde580cd8b27e447fe714886c4a27b60e18835dc8118be7cae898722ab04c98e76012ee5c8849e7145b
|
data/Gemfile.lock
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
PATH
|
|
2
|
+
remote: .
|
|
3
|
+
specs:
|
|
4
|
+
top-travel-destinations-cli-gem (1.2.0)
|
|
5
|
+
|
|
6
|
+
GEM
|
|
7
|
+
remote: https://rubygems.org/
|
|
8
|
+
specs:
|
|
9
|
+
coderay (1.1.1)
|
|
10
|
+
diff-lcs (1.2.5)
|
|
11
|
+
method_source (0.8.2)
|
|
12
|
+
mini_portile2 (2.0.0)
|
|
13
|
+
nokogiri (1.6.7.2)
|
|
14
|
+
mini_portile2 (~> 2.0.0.rc2)
|
|
15
|
+
pry (0.10.3)
|
|
16
|
+
coderay (~> 1.1.0)
|
|
17
|
+
method_source (~> 0.8.1)
|
|
18
|
+
slop (~> 3.4)
|
|
19
|
+
rake (10.5.0)
|
|
20
|
+
rspec (3.4.0)
|
|
21
|
+
rspec-core (~> 3.4.0)
|
|
22
|
+
rspec-expectations (~> 3.4.0)
|
|
23
|
+
rspec-mocks (~> 3.4.0)
|
|
24
|
+
rspec-core (3.4.4)
|
|
25
|
+
rspec-support (~> 3.4.0)
|
|
26
|
+
rspec-expectations (3.4.0)
|
|
27
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
|
28
|
+
rspec-support (~> 3.4.0)
|
|
29
|
+
rspec-mocks (3.4.1)
|
|
30
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
|
31
|
+
rspec-support (~> 3.4.0)
|
|
32
|
+
rspec-support (3.4.1)
|
|
33
|
+
slop (3.6.0)
|
|
34
|
+
|
|
35
|
+
PLATFORMS
|
|
36
|
+
ruby
|
|
37
|
+
|
|
38
|
+
DEPENDENCIES
|
|
39
|
+
bundler (~> 1.11)
|
|
40
|
+
nokogiri (~> 1.0)
|
|
41
|
+
pry (~> 0)
|
|
42
|
+
rake (~> 10.0)
|
|
43
|
+
rspec (~> 3.0)
|
|
44
|
+
top-travel-destinations-cli-gem!
|
|
45
|
+
|
|
46
|
+
BUNDLED WITH
|
|
47
|
+
1.11.2
|
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
class TopTravelDestinations::CLI
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
|
|
4
3
|
def call
|
|
5
4
|
welcome_screen
|
|
6
5
|
make_regions
|
|
7
|
-
add_destinations_to_regions
|
|
8
6
|
list_regions
|
|
9
7
|
select_region
|
|
10
8
|
end
|
|
@@ -24,17 +22,10 @@ class TopTravelDestinations::CLI
|
|
|
24
22
|
end
|
|
25
23
|
|
|
26
24
|
def make_regions
|
|
27
|
-
region_array = TopTravelDestinations::
|
|
25
|
+
region_array = TopTravelDestinations::Region.get_regions
|
|
28
26
|
TopTravelDestinations::Region.create_from_array(region_array)
|
|
29
27
|
end
|
|
30
28
|
|
|
31
|
-
def add_destinations_to_regions
|
|
32
|
-
TopTravelDestinations::Region.all.each do |region|
|
|
33
|
-
destinations_array = TopTravelDestinations::Scraper.scrape_destinations_array(region.region_url)
|
|
34
|
-
region.create_attribute_from_array(destinations_array)
|
|
35
|
-
end
|
|
36
|
-
end
|
|
37
|
-
|
|
38
29
|
def list_regions
|
|
39
30
|
puts "\n"
|
|
40
31
|
puts "Here are the Regions of the World:"
|
|
@@ -6,6 +6,8 @@ class TopTravelDestinations::Region
|
|
|
6
6
|
|
|
7
7
|
def initialize(region_hash)
|
|
8
8
|
self.create_attributes_from_hash(region_hash)
|
|
9
|
+
self.destinations = []
|
|
10
|
+
self.get_destinations
|
|
9
11
|
self.class.all << self
|
|
10
12
|
end
|
|
11
13
|
|
|
@@ -29,4 +31,18 @@ class TopTravelDestinations::Region
|
|
|
29
31
|
@@all
|
|
30
32
|
end
|
|
31
33
|
|
|
34
|
+
def get_destinations
|
|
35
|
+
html = open(self.region_url)
|
|
36
|
+
doc = Nokogiri::HTML(html)
|
|
37
|
+
|
|
38
|
+
doc.search("div.winnerName div.mainName a").collect do |destination|
|
|
39
|
+
name = destination.text
|
|
40
|
+
self.destinations << name
|
|
41
|
+
end#end iterator
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
def self.get_regions
|
|
45
|
+
TopTravelDestinations::Scraper.scrape_regions_array
|
|
46
|
+
end
|
|
47
|
+
|
|
32
48
|
end
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
class TopTravelDestinations::Scraper
|
|
2
2
|
|
|
3
|
-
def self.scrape_regions_array
|
|
3
|
+
def self.scrape_regions_array
|
|
4
|
+
index_url = "https://www.tripadvisor.com/TravelersChoice-Destinations"
|
|
4
5
|
html = open(index_url)
|
|
5
6
|
doc = Nokogiri::HTML(html)
|
|
6
7
|
|
|
@@ -17,17 +18,4 @@ class TopTravelDestinations::Scraper
|
|
|
17
18
|
region_array
|
|
18
19
|
end #end method
|
|
19
20
|
|
|
20
|
-
def self.scrape_destinations_array(profile_url)
|
|
21
|
-
html = open(profile_url)
|
|
22
|
-
doc = Nokogiri::HTML(html)
|
|
23
|
-
|
|
24
|
-
destinations_array = []
|
|
25
|
-
|
|
26
|
-
doc.search("div.winnerName div.mainName a").collect do |destination|
|
|
27
|
-
name = destination.text
|
|
28
|
-
destinations_array << name
|
|
29
|
-
end#end iterator
|
|
30
|
-
destinations_array
|
|
31
|
-
end#end method
|
|
32
|
-
|
|
33
21
|
end #end Class
|
|
Binary file
|
|
Binary file
|
|
@@ -32,6 +32,6 @@ Gem::Specification.new do |spec|
|
|
|
32
32
|
spec.add_development_dependency "bundler", "~> 1.11"
|
|
33
33
|
spec.add_development_dependency "rake", "~> 10.0"
|
|
34
34
|
spec.add_development_dependency "rspec", "~> 3.0"
|
|
35
|
-
spec.add_development_dependency "nokogiri", "~> 0"
|
|
35
|
+
spec.add_development_dependency "nokogiri", "~> 1.0"
|
|
36
36
|
spec.add_development_dependency "pry", "~> 0"
|
|
37
37
|
end
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: top-travel-destinations-cli-gem
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.
|
|
4
|
+
version: 1.2.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Antonio David
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2016-03-
|
|
11
|
+
date: 2016-03-18 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: bundler
|
|
@@ -58,14 +58,14 @@ dependencies:
|
|
|
58
58
|
requirements:
|
|
59
59
|
- - "~>"
|
|
60
60
|
- !ruby/object:Gem::Version
|
|
61
|
-
version: '0'
|
|
61
|
+
version: '1.0'
|
|
62
62
|
type: :development
|
|
63
63
|
prerelease: false
|
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
|
65
65
|
requirements:
|
|
66
66
|
- - "~>"
|
|
67
67
|
- !ruby/object:Gem::Version
|
|
68
|
-
version: '0'
|
|
68
|
+
version: '1.0'
|
|
69
69
|
- !ruby/object:Gem::Dependency
|
|
70
70
|
name: pry
|
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -90,6 +90,7 @@ extra_rdoc_files: []
|
|
|
90
90
|
files:
|
|
91
91
|
- CODE_OF_CONDUCT.md
|
|
92
92
|
- Gemfile
|
|
93
|
+
- Gemfile.lock
|
|
93
94
|
- LICENSE.txt
|
|
94
95
|
- README.md
|
|
95
96
|
- Rakefile
|
|
@@ -101,7 +102,9 @@ files:
|
|
|
101
102
|
- lib/top_travel_destinations/region.rb
|
|
102
103
|
- lib/top_travel_destinations/scraper.rb
|
|
103
104
|
- lib/top_travel_destinations/version.rb
|
|
105
|
+
- pkg/top-travel-destinations-cli-gem-1.2.0.gem
|
|
104
106
|
- top-travel-destinations-cli-gem-1.0.0.gem
|
|
107
|
+
- top-travel-destinations-cli-gem-1.1.0.gem
|
|
105
108
|
- top_travel_destinations.gemspec
|
|
106
109
|
homepage: https://github.com/agdavid/top-travel-destinations-cli-gem
|
|
107
110
|
licenses:
|