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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 525bc1aca1308de0f3d4318941237c89012f1b2a
4
- data.tar.gz: 49bb75b21ac026197465df8cf2969c24ea8a2a03
3
+ metadata.gz: 479751f7d898254d9eda04ff4119df805d76c945
4
+ data.tar.gz: 897d08b002a56a135e671ca3981669de9fd47308
5
5
  SHA512:
6
- metadata.gz: 1dbc4de67a6f37a8ea0df9c10238341325f43ae8fa55f252618c64c3b0b2b98646fb9a4a5c10d28f0ee88bc7f41288f116c21b596de7d55acc0a24c38a6d5f90
7
- data.tar.gz: 279fb23b1d36cbf5cc2dbfdfe5a26dea040f942ed27b4527f7937da45089e74fab56f001d8c794fa479f67583756e0653ebc0490581f6ed7fec5ea60de5a9121
6
+ metadata.gz: bc9076b43cb0dd4c5aed3f6feb08922c9750de3acebdd88ce837cc707c5fc5d701f442cee9cc10e5f309af896648f4378ef8e36105b47c59db3d7a520f21dca9
7
+ data.tar.gz: f99523d8ebc16b523735271361f8e1a6712fe2e22d0ddbb17c7f4603cab3a699b82f48ddcd924b8956d93a0e27d8c79e48fe9649066ab8424ccd768fb46c5dbc
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- nswparks (1.0.0)
4
+ nswparks (1.1.0)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
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 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.
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: NSWParks after installing the gem.
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/NSWParks`.
49
+ To run the development version of the CLI run `bundle exec bin/nswparks`.
48
50
 
49
51
  ## Contributing
50
52
 
@@ -1,11 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- module NSWParks
4
-
5
- end
6
-
3
+ require_relative "../lib/nswparks"
7
4
  require_relative '../lib/nswparks/nsw_parks'
8
5
  require_relative '../lib/nswparks/cli'
9
- require_relative "../lib/nswparks"
10
6
 
11
7
  NSWParks::CLI.new.call
@@ -7,8 +7,9 @@ require 'open-uri'
7
7
  require 'bundler'
8
8
  Bundler.require
9
9
 
10
+ require './lib/nswparks/version'
10
11
  require_relative '../lib/nswparks/nsw_parks'
11
12
  require_relative '../lib/nswparks/cli'
12
- require './lib/nswparks/version'
13
+
13
14
 
14
15
 
@@ -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
- puts ""
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
- puts ""
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
- puts ""
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 = 0
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 a interactive map of all National Parks in NSW enter 'map'"
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 ""
@@ -1,7 +1,7 @@
1
1
 
2
2
  class NSWParks::Nsw_parks
3
3
 
4
- attr_accessor :name, :park_url, :park_region
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
- puts ""
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
- puts ""
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
- puts "http://www.nationalparks.nsw.gov.au/nsw-state-map" # No url to scrape - hidden
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
- puts link.attribute("href").value # Puts out the website address forthe park guides
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
 
@@ -1,3 +1,3 @@
1
1
  module NSWParks
2
- VERSION = "1.0.1"
2
+ VERSION = "1.1.0"
3
3
  end
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.1
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-17 00:00:00.000000000 Z
11
+ date: 2017-03-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler