hiking_guide 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +3 -3
- data/README.md +1 -1
- data/hiking_guide.gemspec +2 -2
- data/lib/hiking_guide/command_line_interface.rb +19 -11
- data/lib/hiking_guide/scraper.rb +11 -1
- data/lib/hiking_guide/version.rb +1 -1
- metadata +10 -10
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1f3515780fd32ea59324071cf336b51cf2cdd832
|
4
|
+
data.tar.gz: 6bb5112a0b6784c25604bfc0d0605e0c06948c7c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3c720710a23f840b5592009df01bfb57e30106da535fc0eab0ed17a458a72aec4cec2038f6b999b903bedef2fc025f622e03a81133d1fb243db22101eaeae058
|
7
|
+
data.tar.gz: 5411bfedff673739d7a5212daf94f3b840724969534290a1c72a89ed9019c1b148919a597f336f950b6695c0bdde9715b548f2ea22c1c29250ae4daa17507cfb
|
data/Gemfile.lock
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
hiking_guide (0.1.
|
4
|
+
hiking_guide (0.1.1)
|
5
5
|
colorize (~> 0.8, >= 0.8.1)
|
6
|
-
nokogiri
|
6
|
+
nokogiri
|
7
7
|
|
8
8
|
GEM
|
9
9
|
remote: https://rubygems.org/
|
@@ -43,7 +43,7 @@ PLATFORMS
|
|
43
43
|
DEPENDENCIES
|
44
44
|
bundler (~> 1.12)
|
45
45
|
hiking_guide!
|
46
|
-
pry
|
46
|
+
pry
|
47
47
|
rake (~> 10.0)
|
48
48
|
rspec (~> 3.0)
|
49
49
|
|
data/README.md
CHANGED
@@ -22,7 +22,7 @@ Or install it yourself as:
|
|
22
22
|
|
23
23
|
## Usage
|
24
24
|
|
25
|
-
Run: ```
|
25
|
+
Run: ```hiking-guide``` after installing the gem.
|
26
26
|
|
27
27
|
Follow the prompts to browse through lists of hiking trails by state, all from the comfort of your command line.
|
28
28
|
|
data/hiking_guide.gemspec
CHANGED
@@ -20,11 +20,11 @@ Gem::Specification.new do |spec|
|
|
20
20
|
|
21
21
|
spec.post_install_message = "Thanks for installing! Hit the trails!"
|
22
22
|
|
23
|
-
spec.add_runtime_dependency 'nokogiri'
|
23
|
+
spec.add_runtime_dependency 'nokogiri'
|
24
24
|
spec.add_runtime_dependency 'colorize', '~> 0.8', '>= 0.8.1'
|
25
25
|
|
26
26
|
spec.add_development_dependency 'bundler', '~> 1.12'
|
27
27
|
spec.add_development_dependency 'rake', '~> 10.0'
|
28
28
|
spec.add_development_dependency 'rspec', '~> 3.0'
|
29
|
-
spec.add_development_dependency 'pry'
|
29
|
+
spec.add_development_dependency 'pry'
|
30
30
|
end
|
@@ -12,8 +12,8 @@ class HikingGuide::CommandLineInteface
|
|
12
12
|
HikingGuide::Trail.create_from_collection(trails_array)
|
13
13
|
end
|
14
14
|
|
15
|
-
def self.add_trail_attributes
|
16
|
-
|
15
|
+
def self.add_trail_attributes(state)
|
16
|
+
state.each do |trail|
|
17
17
|
attributes = HikingGuide::Scraper.scrape_trail_profile(trail.profile_url)
|
18
18
|
trail.add_trail_attributes(attributes)
|
19
19
|
end
|
@@ -36,14 +36,14 @@ class HikingGuide::CommandLineInteface
|
|
36
36
|
puts " / \\/\\ \\ ".light_yellow.on_yellow
|
37
37
|
puts " / / \\ \\ ".light_yellow.on_yellow
|
38
38
|
puts " / / \\ \\".light_yellow.on_yellow
|
39
|
-
|
39
|
+
sleep(1)
|
40
40
|
puts "All set!"
|
41
41
|
sleep(1)
|
42
42
|
hit_the_trails
|
43
43
|
puts ""
|
44
44
|
puts "Welcome to Hiking Guide!".black.on_green
|
45
45
|
puts ""
|
46
|
-
puts "
|
46
|
+
puts "Access trail details from HikingUpward without leaving the comfort of the command line!"
|
47
47
|
puts ""
|
48
48
|
end
|
49
49
|
|
@@ -63,13 +63,14 @@ class HikingGuide::CommandLineInteface
|
|
63
63
|
end
|
64
64
|
|
65
65
|
def self.main_menu
|
66
|
+
puts "* At any time you can exit by typing 'exit' *".black.on_green
|
66
67
|
puts "Where would you like to explore?".black.on_green
|
67
68
|
puts "(1) Maryland hikes"
|
68
69
|
puts "(2) Pennsylvania hikes"
|
69
70
|
puts "(3) North Carolina hikes"
|
70
71
|
puts "(4) Virginia hikes"
|
71
72
|
puts "(5) West Virginia hikes"
|
72
|
-
puts "please enter 1-5:"
|
73
|
+
puts "please enter 1-5:".black.on_green
|
73
74
|
input = gets.strip
|
74
75
|
if input == "1"
|
75
76
|
puts "Here is a list of trails in Maryland:".black.on_green
|
@@ -81,7 +82,7 @@ class HikingGuide::CommandLineInteface
|
|
81
82
|
puts "Here is a list of trails in North Carolina:".black.on_green
|
82
83
|
state_menu(HikingGuide::Trail.nc)
|
83
84
|
elsif input == "4"
|
84
|
-
puts "Here is a list of trails in
|
85
|
+
puts "Here is a list of trails in Virginia:".black.on_green
|
85
86
|
state_menu(HikingGuide::Trail.va)
|
86
87
|
elsif input == "5"
|
87
88
|
puts "Here is a list of trails in West Virginia:".black.on_green
|
@@ -107,12 +108,16 @@ class HikingGuide::CommandLineInteface
|
|
107
108
|
|
108
109
|
def self.state_menu(state_trails_list)
|
109
110
|
state_list(state_trails_list)
|
110
|
-
puts "Please type the number of any trail you'd like to learn more about"
|
111
|
-
puts "
|
111
|
+
puts "Please type the number of any trail you'd like to learn more about".black.on_green
|
112
|
+
puts "To return to the main menu, type 'menu'"
|
113
|
+
puts "To exit completely, type 'exit'"
|
112
114
|
input = gets.strip
|
113
115
|
if input.to_i > 0 && input.to_i <= state_trails_list.size
|
114
|
-
|
115
|
-
|
116
|
+
trail = state_trails_list[input.to_i-1]
|
117
|
+
attributes = HikingGuide::Scraper.scrape_trail_profile(trail.profile_url)
|
118
|
+
trail.add_trail_attributes(attributes)
|
119
|
+
display_trail_details(trail)
|
120
|
+
puts "Would you like to read about another trail in #{trail.state}? (y/n)"
|
116
121
|
response = gets.strip
|
117
122
|
if response.upcase == "Y"
|
118
123
|
state_menu(state_trails_list)
|
@@ -133,7 +138,8 @@ class HikingGuide::CommandLineInteface
|
|
133
138
|
end
|
134
139
|
|
135
140
|
def self.exit
|
136
|
-
puts "Thanks for visiting -- Happy Trails!"
|
141
|
+
puts "Thanks for visiting -- Happy Trails!".black.on_green
|
142
|
+
puts "The information in Hiking Guide comes from a volunteer organization called HikingUpward (http://www.hikingupward.com/). If you find the information useful, please consider volunteering as a Trail Contributer, or donating to the organization."
|
137
143
|
hit_the_trails
|
138
144
|
end
|
139
145
|
|
@@ -153,6 +159,8 @@ class HikingGuide::CommandLineInteface
|
|
153
159
|
|
154
160
|
def self.display_all_trails
|
155
161
|
HikingGuide::Trail.all.each do |trail|
|
162
|
+
attributes = HikingGuide::Scraper.scrape_trail_profile(trail.profile_url)
|
163
|
+
trail.add_trail_attributes(attributes)
|
156
164
|
display_trail_details(trail)
|
157
165
|
end
|
158
166
|
main_menu
|
data/lib/hiking_guide/scraper.rb
CHANGED
@@ -39,11 +39,21 @@ class HikingGuide::Scraper
|
|
39
39
|
trail[:elevation_gain] = page.css("td")[reference+8].children[2].text.split.join(" ") : "unknown"
|
40
40
|
|
41
41
|
page.css("p") != nil ?
|
42
|
-
trail[:description] = page
|
42
|
+
trail[:description] = clean_description(page).join(" ")[0..750].gsub(/\s\w+\s*$/, '...') : "unknown"
|
43
43
|
|
44
44
|
trail[:map_pdf_link] = profile_url+("images/Map.pdf")
|
45
45
|
|
46
46
|
trail
|
47
47
|
end
|
48
48
|
|
49
|
+
def self.clean_description(page)
|
50
|
+
paragraphs = []
|
51
|
+
page.css("p").each do |paragraph|
|
52
|
+
paragraphs << paragraph.text
|
53
|
+
end
|
54
|
+
paragraphs.delete_if {|p| p.include? ("Printable Topo Hike Map")}
|
55
|
+
paragraphs.delete_if {|p| p.include? ("(<!--")}
|
56
|
+
paragraphs
|
57
|
+
end
|
58
|
+
|
49
59
|
end
|
data/lib/hiking_guide/version.rb
CHANGED
metadata
CHANGED
@@ -1,29 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hiking_guide
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Eleanor Graham
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-10-
|
11
|
+
date: 2016-10-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: nokogiri
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
19
|
+
version: '0'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - "
|
24
|
+
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '
|
26
|
+
version: '0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: colorize
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -90,16 +90,16 @@ dependencies:
|
|
90
90
|
name: pry
|
91
91
|
requirement: !ruby/object:Gem::Requirement
|
92
92
|
requirements:
|
93
|
-
- - "
|
93
|
+
- - ">="
|
94
94
|
- !ruby/object:Gem::Version
|
95
|
-
version: '0
|
95
|
+
version: '0'
|
96
96
|
type: :development
|
97
97
|
prerelease: false
|
98
98
|
version_requirements: !ruby/object:Gem::Requirement
|
99
99
|
requirements:
|
100
|
-
- - "
|
100
|
+
- - ">="
|
101
101
|
- !ruby/object:Gem::Version
|
102
|
-
version: '0
|
102
|
+
version: '0'
|
103
103
|
description: Hiking Guide is a CLI Gem that allows users to browse trails in the US
|
104
104
|
mid Atlantic region, taking descriptions from Hiking Upward.
|
105
105
|
email:
|