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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6949725dce17ce498d68c619e13aee0b99fe18a0
4
- data.tar.gz: 4dd4df2650aa0da116ae1835213045d4b000b9cd
3
+ metadata.gz: 1f3515780fd32ea59324071cf336b51cf2cdd832
4
+ data.tar.gz: 6bb5112a0b6784c25604bfc0d0605e0c06948c7c
5
5
  SHA512:
6
- metadata.gz: 0713b4756e6e1b7cb35a7fb88053f805168cdb306d92d7d34d59032e0d24981d991084f866a3e2d4545359f5f6cd2d01cb712555b41981ef858c23253d89bfed
7
- data.tar.gz: 684a6346be81d48d55ca1934ccea278c6c27d6f338c6b0c71213d9ac36b6985da97c1085f79044310cde61c18b60ff34b1d02459f7a417e17ac6ee261bf9dbbd
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.0)
4
+ hiking_guide (0.1.1)
5
5
  colorize (~> 0.8, >= 0.8.1)
6
- nokogiri (~> 1.6)
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 (~> 0.10)
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: ```hiking_guide``` after installing the gem.
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', '~> 1.6'
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', '~> 0.10'
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
- HikingGuide::Trail.all.each do |trail|
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
- add_trail_attributes
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 "The information in Hiking Guide comes from a volunteer organization called Hiking Upward (http://www.hikingupward.com/). If you find the information useful, please consider volunteering as a Trail Contributer, or donating to the organization."
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 Virgini:".black.on_green
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 "Or if you wish to return to the main menu, type 'menu'"
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
- display_trail_details(state_trails_list[input.to_i-1])
115
- puts "Would you like to read about another of these trails? (y/n)"
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
@@ -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.css("p").text.split.join(" ")[0..750].gsub(/\s\w+\s*$/, '...') : "unknown"
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
@@ -1,3 +1,3 @@
1
1
  module HikingGuide
2
- VERSION = "0.1.1"
2
+ VERSION = "0.1.2"
3
3
  end
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.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-03 00:00:00.000000000 Z
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: '1.6'
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: '1.6'
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.10'
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.10'
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: