nswparks 1.0.1 → 1.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 +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +7 -5
- data/bin/nswparks +1 -5
- data/lib/nswparks.rb +2 -1
- data/lib/nswparks/cli.rb +7 -19
- data/lib/nswparks/nsw_parks.rb +14 -28
- data/lib/nswparks/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: 479751f7d898254d9eda04ff4119df805d76c945
|
4
|
+
data.tar.gz: 897d08b002a56a135e671ca3981669de9fd47308
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bc9076b43cb0dd4c5aed3f6feb08922c9750de3acebdd88ce837cc707c5fc5d701f442cee9cc10e5f309af896648f4378ef8e36105b47c59db3d7a520f21dca9
|
7
|
+
data.tar.gz: f99523d8ebc16b523735271361f8e1a6712fe2e22d0ddbb17c7f4603cab3a699b82f48ddcd924b8956d93a0e27d8c79e48fe9649066ab8424ccd768fb46c5dbc
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -28,15 +28,17 @@ State Government.
|
|
28
28
|
* It allows you to request information on each national park from the main list
|
29
29
|
and from the region list
|
30
30
|
|
31
|
-
|
32
|
-
|
33
31
|
## Installation
|
34
32
|
|
35
|
-
You can install this gem via gem install
|
33
|
+
You can install this gem via `gem install nswparks`. The nswparks CLI will be installed and you can run `nswparks` to get a list and information on NSW National Parks right in your command line.
|
36
34
|
|
37
35
|
## Usage
|
38
36
|
|
39
|
-
Run:
|
37
|
+
Run: `nswparks` after installing the gem.
|
38
|
+
|
39
|
+
## Contributors
|
40
|
+
|
41
|
+
Malki Davis for the hint to use system open
|
40
42
|
|
41
43
|
## Development
|
42
44
|
|
@@ -44,7 +46,7 @@ After checking out the repo, run `bundle exec bin/setup` to install dependencies
|
|
44
46
|
|
45
47
|
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to rubygems.org.
|
46
48
|
|
47
|
-
To run the development version of the CLI run `bundle exec bin/
|
49
|
+
To run the development version of the CLI run `bundle exec bin/nswparks`.
|
48
50
|
|
49
51
|
## Contributing
|
50
52
|
|
data/bin/nswparks
CHANGED
data/lib/nswparks.rb
CHANGED
data/lib/nswparks/cli.rb
CHANGED
@@ -27,11 +27,7 @@ class NSWParks::CLI
|
|
27
27
|
# Validate user input - input must be an integer and exist in the list
|
28
28
|
while !(park_no.is_a? Integer) || park_no < 1 || park_no > NSWParks::Nsw_parks.all.length
|
29
29
|
park_list
|
30
|
-
|
31
|
-
puts "-----------------------------------------------"
|
32
|
-
puts "Please enter a park number from the list above:" # Prompt user to enter again
|
33
|
-
puts "-----------------------------------------------"
|
34
|
-
park_no = gets.strip.to_i
|
30
|
+
park_no = NSWParks::Nsw_parks.valid_input
|
35
31
|
end
|
36
32
|
puts ""
|
37
33
|
puts NSWParks::Nsw_parks.all[park_no - 1].name # Gives returned park info a heading of the park name
|
@@ -50,17 +46,13 @@ class NSWParks::CLI
|
|
50
46
|
def park_region
|
51
47
|
region_no = 0
|
52
48
|
input = 0
|
53
|
-
areas = park_area # Use #park_area to output list of NSW Regions
|
49
|
+
areas = park_area # Use #park_area to output list of NSW Regions and select a region
|
54
50
|
puts "Enter the number for the region you are interested in:"
|
55
51
|
region_no = gets.strip.to_i
|
56
52
|
# Validate user input - input must be numerical and exist in the list
|
57
53
|
while !(region_no.is_a? Integer) || region_no < 1 || region_no > areas.length
|
58
54
|
park_area
|
59
|
-
|
60
|
-
puts "--------------------------------------------------"
|
61
|
-
puts "Please enter one of the regions in the list above:" # Prompt user to enter again
|
62
|
-
puts "--------------------------------------------------"
|
63
|
-
region_no = gets.strip.to_i
|
55
|
+
region_no = NSWParks::Nsw_parks.valid_input
|
64
56
|
end
|
65
57
|
puts ""
|
66
58
|
puts "The parks in the #{areas[region_no.to_i - 1]} region are:"
|
@@ -73,11 +65,7 @@ class NSWParks::CLI
|
|
73
65
|
while !(input.is_a? Integer) || input < 1 || input > array.length
|
74
66
|
array = NSWParks::Nsw_parks.park_region(region_no.to_s)
|
75
67
|
array.each.with_index(1) {|a,i| puts "#{i}. #{a}"}
|
76
|
-
|
77
|
-
puts "---------------------------------------------------------"
|
78
|
-
puts "Please enter one of the park numbers from the list above:" # Prompt user to enter again
|
79
|
-
puts "---------------------------------------------------------"
|
80
|
-
input = gets.strip.to_i
|
68
|
+
input = NSWParks::Nsw_parks.valid_input
|
81
69
|
end
|
82
70
|
puts ""
|
83
71
|
puts "Information for #{array[input - 1]}:" # Puts out heading of park name
|
@@ -106,13 +94,13 @@ class NSWParks::CLI
|
|
106
94
|
|
107
95
|
# Starts the app and gives users the available options for the app
|
108
96
|
def start
|
109
|
-
answer =
|
97
|
+
answer = nil
|
110
98
|
while answer != "exit"
|
111
99
|
puts ""
|
112
|
-
puts "For a list of NSW National Parks and information on a park enter 'info"
|
100
|
+
puts "For a list of NSW National Parks and information on a park enter 'info'"
|
113
101
|
puts "To exit the program enter 'exit'"
|
114
102
|
puts "To see the National Park regions in NSW and choose a park by its region enter 'region'"
|
115
|
-
puts "To access
|
103
|
+
puts "To access an interactive map of all National Parks in NSW enter 'map'"
|
116
104
|
puts "To download a free pocket guide for NSW National Park Regions enter 'guide'"
|
117
105
|
puts "To visit the website for a National Park enter 'url'"
|
118
106
|
puts ""
|
data/lib/nswparks/nsw_parks.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
|
2
2
|
class NSWParks::Nsw_parks
|
3
3
|
|
4
|
-
attr_accessor :name, :park_url
|
4
|
+
attr_accessor :name, :park_url
|
5
5
|
|
6
6
|
@@all = [] # Collects all NSW National Parks
|
7
7
|
|
@@ -23,14 +23,6 @@ class NSWParks::Nsw_parks
|
|
23
23
|
park.collect {|a| new(a.text.strip, a.attribute("href").value)}
|
24
24
|
end
|
25
25
|
|
26
|
-
# Instructions to the user on how to use the provided website links
|
27
|
-
def self.url_use
|
28
|
-
puts "<------------------------------------------------------------------------------->"
|
29
|
-
puts " Right-click or Control-click on the website address above and select 'open url'"
|
30
|
-
puts " from the dropdown menu!! This will open the website in your default browser "
|
31
|
-
puts "<------------------------------------------------------------------------------->"
|
32
|
-
end
|
33
|
-
|
34
26
|
# Allow users to access information on any NSW National Park
|
35
27
|
def self.park_overview(park_no)
|
36
28
|
check = ""
|
@@ -124,12 +116,19 @@ class NSWParks::Nsw_parks
|
|
124
116
|
park_overview(i + 1)
|
125
117
|
end
|
126
118
|
end
|
127
|
-
end
|
119
|
+
end
|
120
|
+
|
121
|
+
def self.valid_input
|
122
|
+
puts ""
|
123
|
+
puts "---------------------------------------------------------"
|
124
|
+
puts "Please enter one of the numbers from the list above:" # Prompt user to enter again
|
125
|
+
puts "---------------------------------------------------------"
|
126
|
+
gets.strip.to_i
|
127
|
+
end
|
128
128
|
|
129
129
|
# Accesses the website information for a selected NSW National Park
|
130
130
|
def self.park_url
|
131
131
|
input = 0
|
132
|
-
array = 0
|
133
132
|
@@all.each.with_index(1) {|a,i| puts "#{i}. #{a.name}"} # Puts outs list of National Parks
|
134
133
|
puts ""
|
135
134
|
puts "Select the park number from above and enter the number to access the website address"
|
@@ -137,34 +136,21 @@ class NSWParks::Nsw_parks
|
|
137
136
|
# Validate user input - input must be numerical and exist in the list
|
138
137
|
while !(input.is_a? Integer) || input < 1 || input > @@all.length
|
139
138
|
@@all.each.with_index(1) {|a,i| puts "#{i}. #{a.name}"} # Puts outs list of National Parks
|
140
|
-
|
141
|
-
puts "----------------------------------------------"
|
142
|
-
puts "Please enter a park number from the list above:" # Prompt user to enter again
|
143
|
-
puts "----------------------------------------------"
|
144
|
-
input = gets.strip.to_i
|
139
|
+
input = valid_input
|
145
140
|
end
|
146
|
-
|
147
|
-
puts "The website address for #{@@all[input - 1].name} is:" # Puts a heading of the park name
|
148
|
-
puts ""
|
149
|
-
puts @@all[input - 1].park_url # Puts out the park website address
|
150
|
-
puts ""
|
151
|
-
url_use # Instructions to the user on how to use the provided website links
|
141
|
+
system("open #{@@all[input - 1].park_url}") # Puts out the park website address
|
152
142
|
end
|
153
143
|
|
154
144
|
# Provides user with a link to the map and instructions to open the link in their browser
|
155
145
|
def self.park_map
|
156
|
-
|
157
|
-
puts ""
|
158
|
-
url_use # Instructions to the user on how to use the provided website links
|
146
|
+
system("open http://www.nationalparks.nsw.gov.au/nsw-state-map") # No url to scrape - hidden
|
159
147
|
end
|
160
148
|
|
161
149
|
# Provides user with a link to guides and instructions to open the link in their browser
|
162
150
|
def self.park_guide
|
163
151
|
page = Nokogiri::HTML(open("http://www.nationalparks.nsw.gov.au"))
|
164
152
|
link = page.css("#headerNavBottom nav ul li#mainNav__about .box ul li[5] a")
|
165
|
-
|
166
|
-
puts ""
|
167
|
-
url_use # Instructions to the user on how to use the provided website links
|
153
|
+
system("open #{link.attribute("href").value}") # Puts out the website address forthe park guides
|
168
154
|
end
|
169
155
|
end
|
170
156
|
|
data/lib/nswparks/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: nswparks
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Annette Drapalski
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-03-
|
11
|
+
date: 2017-03-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|