balboa_park_itinerary_ideas 0.1.12
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +8 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +4 -0
- data/Gemfile.lock +42 -0
- data/LICENSE.txt +21 -0
- data/README.md +77 -0
- data/Rakefile +2 -0
- data/balboa_park_itinerary_ideas.gemspec +46 -0
- data/bin/balboa_park_itinerary_ideas +7 -0
- data/bin/console +7 -0
- data/bin/setup +6 -0
- data/config/environment.rb +11 -0
- data/lib/balboa_park_itinerary_ideas.rb +5 -0
- data/lib/balboa_park_itinerary_ideas/cli.rb +90 -0
- data/lib/balboa_park_itinerary_ideas/itinerary.rb +18 -0
- data/lib/balboa_park_itinerary_ideas/scraper.rb +95 -0
- data/lib/balboa_park_itinerary_ideas/version.rb +3 -0
- metadata +152 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 58431cb70c936dbdb283c863bf32173bc4533d3e557827646b816f6084b81033
|
4
|
+
data.tar.gz: 6b52869726dc9ac18bad35a5bcd3a5507388bb8e3df07c79af215944e3e032b0
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: c374669f0740000e022b348e351665b2ac91273f5b29da3295f9b29e00e35f7372af1c473d7d7706267336d52fa66a3865ed72705cea009f124c7ff298cc5c0e
|
7
|
+
data.tar.gz: 6381c75f1d7b5896ee5dda1add446ecd92c4877c780e67ddf06c142bcb3c2a1afc39a9801eab9e05cda5cfb63cd51c7a70d4d0b1b78a63d942d037313c8dd7b7
|
data/.gitignore
ADDED
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
2
|
+
|
3
|
+
## Our Pledge
|
4
|
+
|
5
|
+
In the interest of fostering an open and welcoming environment, we as
|
6
|
+
contributors and maintainers pledge to making participation in our project and
|
7
|
+
our community a harassment-free experience for everyone, regardless of age, body
|
8
|
+
size, disability, ethnicity, gender identity and expression, level of experience,
|
9
|
+
nationality, personal appearance, race, religion, or sexual identity and
|
10
|
+
orientation.
|
11
|
+
|
12
|
+
## Our Standards
|
13
|
+
|
14
|
+
Examples of behavior that contributes to creating a positive environment
|
15
|
+
include:
|
16
|
+
|
17
|
+
* Using welcoming and inclusive language
|
18
|
+
* Being respectful of differing viewpoints and experiences
|
19
|
+
* Gracefully accepting constructive criticism
|
20
|
+
* Focusing on what is best for the community
|
21
|
+
* Showing empathy towards other community members
|
22
|
+
|
23
|
+
Examples of unacceptable behavior by participants include:
|
24
|
+
|
25
|
+
* The use of sexualized language or imagery and unwelcome sexual attention or
|
26
|
+
advances
|
27
|
+
* Trolling, insulting/derogatory comments, and personal or political attacks
|
28
|
+
* Public or private harassment
|
29
|
+
* Publishing others' private information, such as a physical or electronic
|
30
|
+
address, without explicit permission
|
31
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
32
|
+
professional setting
|
33
|
+
|
34
|
+
## Our Responsibilities
|
35
|
+
|
36
|
+
Project maintainers are responsible for clarifying the standards of acceptable
|
37
|
+
behavior and are expected to take appropriate and fair corrective action in
|
38
|
+
response to any instances of unacceptable behavior.
|
39
|
+
|
40
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
41
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
42
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
43
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
44
|
+
threatening, offensive, or harmful.
|
45
|
+
|
46
|
+
## Scope
|
47
|
+
|
48
|
+
This Code of Conduct applies both within project spaces and in public spaces
|
49
|
+
when an individual is representing the project or its community. Examples of
|
50
|
+
representing a project or community include using an official project e-mail
|
51
|
+
address, posting via an official social media account, or acting as an appointed
|
52
|
+
representative at an online or offline event. Representation of a project may be
|
53
|
+
further defined and clarified by project maintainers.
|
54
|
+
|
55
|
+
## Enforcement
|
56
|
+
|
57
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
58
|
+
reported by contacting the project team at 'berrier.jamie@gmail.com'. All
|
59
|
+
complaints will be reviewed and investigated and will result in a response that
|
60
|
+
is deemed necessary and appropriate to the circumstances. The project team is
|
61
|
+
obligated to maintain confidentiality with regard to the reporter of an incident.
|
62
|
+
Further details of specific enforcement policies may be posted separately.
|
63
|
+
|
64
|
+
Project maintainers who do not follow or enforce the Code of Conduct in good
|
65
|
+
faith may face temporary or permanent repercussions as determined by other
|
66
|
+
members of the project's leadership.
|
67
|
+
|
68
|
+
## Attribution
|
69
|
+
|
70
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
71
|
+
available at [http://contributor-covenant.org/version/1/4][version]
|
72
|
+
|
73
|
+
[homepage]: http://contributor-covenant.org
|
74
|
+
[version]: http://contributor-covenant.org/version/1/4/
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,42 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
balboa_park_itinerary_ideas (0.1.11)
|
5
|
+
colorize (~> 0.8.1)
|
6
|
+
nokogiri (~> 1.10)
|
7
|
+
strings (~> 0.1.4)
|
8
|
+
|
9
|
+
GEM
|
10
|
+
remote: https://rubygems.org/
|
11
|
+
specs:
|
12
|
+
coderay (1.1.2)
|
13
|
+
colorize (0.8.1)
|
14
|
+
method_source (0.8.2)
|
15
|
+
mini_portile2 (2.4.0)
|
16
|
+
nokogiri (1.10.3)
|
17
|
+
mini_portile2 (~> 2.4.0)
|
18
|
+
pry (0.10.4)
|
19
|
+
coderay (~> 1.1.0)
|
20
|
+
method_source (~> 0.8.1)
|
21
|
+
slop (~> 3.4)
|
22
|
+
rake (10.5.0)
|
23
|
+
slop (3.6.0)
|
24
|
+
strings (0.1.5)
|
25
|
+
strings-ansi (~> 0.1)
|
26
|
+
unicode-display_width (~> 1.5)
|
27
|
+
unicode_utils (~> 1.4)
|
28
|
+
strings-ansi (0.1.0)
|
29
|
+
unicode-display_width (1.6.0)
|
30
|
+
unicode_utils (1.4.0)
|
31
|
+
|
32
|
+
PLATFORMS
|
33
|
+
ruby
|
34
|
+
|
35
|
+
DEPENDENCIES
|
36
|
+
balboa_park_itinerary_ideas!
|
37
|
+
bundler (~> 2.0)
|
38
|
+
pry (~> 0.10.3)
|
39
|
+
rake (~> 10.0)
|
40
|
+
|
41
|
+
BUNDLED WITH
|
42
|
+
2.0.1
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2019 'jamieberrier'
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,77 @@
|
|
1
|
+
# BalboaParkItineraryIdeas
|
2
|
+
|
3
|
+
A Ruby Gem providing a CLI to view the itinerary ideas for San Diego's Balboa Park and the details about a selected itinerary as per the Balboa Park website.
|
4
|
+
|
5
|
+
## Installation - GitHub
|
6
|
+
|
7
|
+
Go To:
|
8
|
+
https://github.com/jamieberrier/balboa_park_itinerary_ideas
|
9
|
+
|
10
|
+
Click:
|
11
|
+
'Clone or download' button
|
12
|
+
|
13
|
+
Click:
|
14
|
+
clipboard icon ('Clone with SSH')
|
15
|
+
|
16
|
+
Type:
|
17
|
+
```ruby
|
18
|
+
$ git clone
|
19
|
+
```
|
20
|
+
|
21
|
+
And then paste, or type:
|
22
|
+
|
23
|
+
$ git clone git@github.com:jamieberrier/balboa_park_itinerary_ideas.git
|
24
|
+
|
25
|
+
Then type:
|
26
|
+
|
27
|
+
$ cd balboa_park_itinerary_ideas
|
28
|
+
|
29
|
+
Finally:
|
30
|
+
|
31
|
+
$ bundle install
|
32
|
+
|
33
|
+
## Usage - GitHub
|
34
|
+
|
35
|
+
$ bin/balboa_park_itinerary_ideas
|
36
|
+
|
37
|
+
And then follow the on screen prompts
|
38
|
+
|
39
|
+
## Installation - RubyGems
|
40
|
+
|
41
|
+
Add this line to your application's Gemfile:
|
42
|
+
|
43
|
+
```ruby
|
44
|
+
gem 'balboa_park_itinerary_ideas'
|
45
|
+
```
|
46
|
+
|
47
|
+
And then execute:
|
48
|
+
|
49
|
+
$ bundle
|
50
|
+
|
51
|
+
Or install it yourself as:
|
52
|
+
|
53
|
+
$ gem install balboa_park_itinerary_ideas
|
54
|
+
|
55
|
+
## Usage - RubyGems
|
56
|
+
|
57
|
+
$ balboa_park_itinerary_ideas
|
58
|
+
|
59
|
+
And then follow the on screen prompts
|
60
|
+
|
61
|
+
## Development
|
62
|
+
|
63
|
+
After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
64
|
+
|
65
|
+
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](https://rubygems.org).
|
66
|
+
|
67
|
+
## Contributing
|
68
|
+
|
69
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/'jamieberrier'/balboa_park_itinerary_ideas. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
70
|
+
|
71
|
+
## License
|
72
|
+
|
73
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
74
|
+
|
75
|
+
## Code of Conduct
|
76
|
+
|
77
|
+
Everyone interacting in the BalboaParkItineraryIdeas project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/'jamieberrier'/balboa_park_itinerary_ideas/blob/master/CODE_OF_CONDUCT.md).
|
data/Rakefile
ADDED
@@ -0,0 +1,46 @@
|
|
1
|
+
|
2
|
+
lib = File.expand_path("../lib", __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require './lib/balboa_park_itinerary_ideas/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "balboa_park_itinerary_ideas"
|
8
|
+
spec.version = BalboaParkItineraryIdeas::VERSION
|
9
|
+
spec.authors = ["jamieberrier"]
|
10
|
+
spec.email = ["berrier.jamie@gmail.com"]
|
11
|
+
|
12
|
+
spec.summary = "Balboa Park Itinerary Ideas"
|
13
|
+
spec.description = "A Ruby Gem providing a CLI to view itinerary ideas for San Diego's Balboa Park as per the Balboa Park website."
|
14
|
+
spec.homepage = "http://rubygems.org/gems/balboa_park_itinerary_ideas"
|
15
|
+
spec.license = "MIT"
|
16
|
+
|
17
|
+
# Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
|
18
|
+
# to allow pushing to a single host or delete this section to allow pushing to any host.
|
19
|
+
if spec.respond_to?(:metadata)
|
20
|
+
spec.metadata["allowed_push_host"] = "https://rubygems.org"
|
21
|
+
|
22
|
+
spec.metadata["homepage_uri"] = spec.homepage
|
23
|
+
spec.metadata["source_code_uri"] = "https://github.com/jamieberrier/balboa_park_itinerary_ideas"
|
24
|
+
spec.metadata["changelog_uri"] = "https://github.com/jamieberrier/balboa_park_itinerary_ideas"
|
25
|
+
else
|
26
|
+
raise "RubyGems 2.0 or newer is required to protect against " \
|
27
|
+
"public gem pushes."
|
28
|
+
end
|
29
|
+
|
30
|
+
# Specify which files should be added to the gem when it is released.
|
31
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
32
|
+
spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
|
33
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
34
|
+
end
|
35
|
+
spec.bindir = "bin"
|
36
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
37
|
+
spec.require_paths = ["lib"]
|
38
|
+
|
39
|
+
spec.add_development_dependency "bundler", "~> 2.0"
|
40
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
41
|
+
spec.add_development_dependency "pry", "~> 0.10.3"
|
42
|
+
|
43
|
+
spec.add_dependency "nokogiri", "~> 1.10"
|
44
|
+
spec.add_dependency "colorize", "~> 0.8.1"
|
45
|
+
spec.add_dependency "strings", "~> 0.1.4"
|
46
|
+
end
|
data/bin/console
ADDED
data/bin/setup
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
#require 'openssl'
|
2
|
+
require 'pry'
|
3
|
+
require 'nokogiri'
|
4
|
+
require 'open-uri'
|
5
|
+
require 'colorize'
|
6
|
+
require 'strings/extensions'
|
7
|
+
|
8
|
+
require_relative '../lib/balboa_park_itinerary_ideas/version'
|
9
|
+
require_relative '../lib/balboa_park_itinerary_ideas/cli'
|
10
|
+
require_relative '../lib/balboa_park_itinerary_ideas/scraper'
|
11
|
+
require_relative '../lib/balboa_park_itinerary_ideas/itinerary'
|
@@ -0,0 +1,90 @@
|
|
1
|
+
# The CLI Controller - responsible for business logic/user interactions
|
2
|
+
class BalboaParkItineraryIdeas::CLI
|
3
|
+
|
4
|
+
def call
|
5
|
+
@s = BalboaParkItineraryIdeas::Scraper.new
|
6
|
+
@s.scrape_itineraries
|
7
|
+
@welcome_header = @s.scrape_welcome_header
|
8
|
+
@welcome_message = @s.scrape_welcome_message
|
9
|
+
@header = @s.scrape_header
|
10
|
+
|
11
|
+
start
|
12
|
+
end
|
13
|
+
|
14
|
+
def start
|
15
|
+
welcome_message
|
16
|
+
list_itineraries
|
17
|
+
menu
|
18
|
+
end
|
19
|
+
|
20
|
+
# displays scraped welome header and message
|
21
|
+
def welcome_message
|
22
|
+
@border = "------------------------------------------------------------------------------"
|
23
|
+
|
24
|
+
puts @border
|
25
|
+
puts "#{@welcome_header}".blue.bold
|
26
|
+
puts Strings.wrap(@welcome_message, 80)
|
27
|
+
puts @border
|
28
|
+
end
|
29
|
+
|
30
|
+
# lists the itineraries for the user to choose from
|
31
|
+
def list_itineraries
|
32
|
+
puts "\n#{@header}".blue.bold
|
33
|
+
|
34
|
+
BalboaParkItineraryIdeas::Itinerary.all.each.with_index(1) do |itinerary, i|
|
35
|
+
puts "#{i}.".red.bold + " #{itinerary.title}".bold
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
# displays the user's choices, gets the user's input, and either displays details of an itinerary, the list of itineraries, or exits
|
40
|
+
def menu
|
41
|
+
input = nil
|
42
|
+
|
43
|
+
while input != "exit"
|
44
|
+
puts @border
|
45
|
+
puts "What would you like to do? Your choices are:".green.bold
|
46
|
+
puts "Type the itinerary number " + "('1', '2', '3'....'9')".red.bold + " to see the details"
|
47
|
+
puts "Type " + "list".red.bold + " to see the list again"
|
48
|
+
puts "Type " + "exit".red.bold
|
49
|
+
puts @border
|
50
|
+
|
51
|
+
input = gets.strip.downcase
|
52
|
+
|
53
|
+
if input.to_i.between?(1,9)
|
54
|
+
itinerary = BalboaParkItineraryIdeas::Itinerary.find(input.to_i)
|
55
|
+
# Prevent scraping for the selected itinerary's details if the details were already scraped
|
56
|
+
@s.scrape_itinerary_page(itinerary) unless !itinerary.summary.nil?
|
57
|
+
print_details(itinerary)
|
58
|
+
elsif input == "list"
|
59
|
+
list_itineraries
|
60
|
+
elsif input == "exit"
|
61
|
+
goodbye
|
62
|
+
else
|
63
|
+
puts "Didn't understand, please try again."
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
# displays the itinerary's details: title, summary, and each attraction's name, description, and URL (if has one)
|
69
|
+
def print_details(itinerary)
|
70
|
+
puts "\n#{itinerary.title}".blue.bold
|
71
|
+
puts Strings.wrap(itinerary.summary, 86).yellow
|
72
|
+
|
73
|
+
itinerary.attractions.each do |attraction|
|
74
|
+
puts "\n#{attraction[:name]}".bold.red
|
75
|
+
puts Strings.wrap(attraction[:description], 75)
|
76
|
+
|
77
|
+
unless attraction[:attraction_url].nil?
|
78
|
+
puts "Click for more info: ".green.bold + "#{attraction[:attraction_url]}".green.underline
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
puts "\nClick below for more information about the ".red + "#{itinerary.title} Itinerary:".red.bold
|
83
|
+
puts "#{itinerary.url}\n".green.underline
|
84
|
+
end
|
85
|
+
|
86
|
+
# displays exit message to the user
|
87
|
+
def goodbye
|
88
|
+
puts "\nGoodbye! Comeback soon!\n".green.bold
|
89
|
+
end
|
90
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
class BalboaParkItineraryIdeas::Itinerary
|
2
|
+
attr_accessor :title, :url, :summary, :attractions # an array of hashes with names, descriptions, and URLs of the attractions
|
3
|
+
|
4
|
+
@@all = []
|
5
|
+
|
6
|
+
def self.all
|
7
|
+
@@all
|
8
|
+
end
|
9
|
+
|
10
|
+
def save
|
11
|
+
@@all << self
|
12
|
+
end
|
13
|
+
|
14
|
+
# returns the itinerary that matches the user input
|
15
|
+
def self.find(id)
|
16
|
+
self.all[id-1]
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,95 @@
|
|
1
|
+
class BalboaParkItineraryIdeas::Scraper
|
2
|
+
URL = "https://www.balboapark.org"
|
3
|
+
|
4
|
+
# creates instances of Itinerary with title, url, and empty attractions array for each itinerary
|
5
|
+
def scrape_itineraries
|
6
|
+
@doc = Nokogiri::HTML(open(URL))
|
7
|
+
#@doc = Nokogiri::HTML(open(URL, ssl_verify_mode: OpenSSL::SSL::VERIFY_NONE)) # use if security certificate is expired
|
8
|
+
@doc.css('div.view-itineraries span.field-content').each do |it|
|
9
|
+
itinerary = BalboaParkItineraryIdeas::Itinerary.new
|
10
|
+
|
11
|
+
itinerary.title = it.css('a').text
|
12
|
+
itinerary.url = URL + it.css('a').attribute("href").value
|
13
|
+
itinerary.attractions = []
|
14
|
+
|
15
|
+
itinerary.save
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
def scrape_welcome_header # gets welcome header
|
20
|
+
@doc.css('section#block-welcome h2').text
|
21
|
+
end
|
22
|
+
|
23
|
+
def scrape_welcome_message # gets welome message
|
24
|
+
@doc.css('section#block-welcome p').text
|
25
|
+
end
|
26
|
+
|
27
|
+
def scrape_header # gets 'Itinerary Ideas' header
|
28
|
+
@doc.css('section#block-views-block-itineraries-block-1 h2').text
|
29
|
+
end
|
30
|
+
|
31
|
+
# gets itinerary summary and attractions (name, description & URL) from itinerary page and adds to itinerary
|
32
|
+
def scrape_itinerary_page(itinerary)
|
33
|
+
#itinerary_page = Nokogiri::HTML(open(itinerary_url, ssl_verify_mode: OpenSSL::SSL::VERIFY_NONE)) # use if security certificate is expired
|
34
|
+
@itinerary_page = Nokogiri::HTML(open(itinerary.url))
|
35
|
+
# Summary
|
36
|
+
if itinerary.title.include?("Explorer") # Explorer itinerary summary has a href with jpeg in the summary
|
37
|
+
itinerary.summary = get_explorer_summary
|
38
|
+
else
|
39
|
+
itinerary.summary = @itinerary_page.css('div.content div.field--type-text-with-summary p').text.strip
|
40
|
+
end
|
41
|
+
# Attractions
|
42
|
+
get_attractions(itinerary)
|
43
|
+
itinerary.attractions.reject! { |e| e[:name] == nil } # reject duplicates
|
44
|
+
end
|
45
|
+
|
46
|
+
def get_attractions(itinerary)
|
47
|
+
@itinerary_page.css('div.field--name-field-stops div.field--item').each do |attraction|
|
48
|
+
# attraction name
|
49
|
+
name = attraction.css('div.content').text.delete("\n").strip.split("Attraction").join.strip.split("Description").delete_at(0)
|
50
|
+
name.strip! unless name == nil
|
51
|
+
# attraction description
|
52
|
+
if itinerary.title.include?("Birds") # The Birds of Balboa Park itinerary has 3 paragraphs of text
|
53
|
+
description = get_birds_attraction_description(attraction)
|
54
|
+
else # all other itineraries
|
55
|
+
description = attraction.css('p').text
|
56
|
+
end
|
57
|
+
# URL
|
58
|
+
unless attraction.css('a').attr('href').nil? # not all attractions have a URL
|
59
|
+
attraction_url = URL + attraction.css('a').attr('href').value
|
60
|
+
end
|
61
|
+
# pushes hash of attraction details on to attractions array
|
62
|
+
itinerary.attractions.push(name: name, description: description, attraction_url: attraction_url)
|
63
|
+
end # end of each
|
64
|
+
end
|
65
|
+
|
66
|
+
# Handles that the Explorer itinerary summary has a href with jpeg in its summary
|
67
|
+
def get_explorer_summary
|
68
|
+
summary = @itinerary_page.css('div.content div.field--type-text-with-summary p')
|
69
|
+
node = summary.css('a')[0]
|
70
|
+
node.content = "Explorer Pass"
|
71
|
+
summary.text.strip
|
72
|
+
end
|
73
|
+
|
74
|
+
# Handles that the Birds of Balboa Park itinerary has 3 paragraphs of text
|
75
|
+
def get_birds_attraction_description(attraction)
|
76
|
+
description_array = []
|
77
|
+
# Handles that the California Thrasher has its latin name as <p> instead of <em> like the rest of the birds
|
78
|
+
if attraction.css('p').text.include?("Toxostoma")
|
79
|
+
d1 = attraction.css('p')[1].text.strip
|
80
|
+
d2 = attraction.css('p')[2].text.strip
|
81
|
+
d3 = attraction.css('p')[3].text.strip
|
82
|
+
else
|
83
|
+
d1 = attraction.css('p')[0].text.strip
|
84
|
+
d2 = attraction.css('p')[1].text.strip
|
85
|
+
# Handles the Red Shouldered Hawk's 'Nesting habits' leading whitespace that .strip doesn't remove
|
86
|
+
d3 = attraction.css('p')[2].text.gsub(/\A[[:space:]]+|[[:space:]]+\z/, '') # removes leading & trailing spaces
|
87
|
+
end
|
88
|
+
# formats the 3 paragraphs
|
89
|
+
descr = Strings.wrap(d1 + "\n", 86)
|
90
|
+
diet = Strings.wrap("\n" + d2 + "\n", 86)
|
91
|
+
nesting = Strings.wrap("\n" + d3, 86)
|
92
|
+
# pushes paragraphs on to array
|
93
|
+
description_array.push(descr, diet, nesting)
|
94
|
+
end
|
95
|
+
end
|
metadata
ADDED
@@ -0,0 +1,152 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: balboa_park_itinerary_ideas
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.12
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- jamieberrier
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2019-05-31 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '2.0'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '2.0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: pry
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 0.10.3
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 0.10.3
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: nokogiri
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '1.10'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '1.10'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: colorize
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: 0.8.1
|
76
|
+
type: :runtime
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: 0.8.1
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: strings
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: 0.1.4
|
90
|
+
type: :runtime
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: 0.1.4
|
97
|
+
description: A Ruby Gem providing a CLI to view itinerary ideas for San Diego's Balboa
|
98
|
+
Park as per the Balboa Park website.
|
99
|
+
email:
|
100
|
+
- berrier.jamie@gmail.com
|
101
|
+
executables:
|
102
|
+
- balboa_park_itinerary_ideas
|
103
|
+
- console
|
104
|
+
- setup
|
105
|
+
extensions: []
|
106
|
+
extra_rdoc_files: []
|
107
|
+
files:
|
108
|
+
- ".gitignore"
|
109
|
+
- CODE_OF_CONDUCT.md
|
110
|
+
- Gemfile
|
111
|
+
- Gemfile.lock
|
112
|
+
- LICENSE.txt
|
113
|
+
- README.md
|
114
|
+
- Rakefile
|
115
|
+
- balboa_park_itinerary_ideas.gemspec
|
116
|
+
- bin/balboa_park_itinerary_ideas
|
117
|
+
- bin/console
|
118
|
+
- bin/setup
|
119
|
+
- config/environment.rb
|
120
|
+
- lib/balboa_park_itinerary_ideas.rb
|
121
|
+
- lib/balboa_park_itinerary_ideas/cli.rb
|
122
|
+
- lib/balboa_park_itinerary_ideas/itinerary.rb
|
123
|
+
- lib/balboa_park_itinerary_ideas/scraper.rb
|
124
|
+
- lib/balboa_park_itinerary_ideas/version.rb
|
125
|
+
homepage: http://rubygems.org/gems/balboa_park_itinerary_ideas
|
126
|
+
licenses:
|
127
|
+
- MIT
|
128
|
+
metadata:
|
129
|
+
allowed_push_host: https://rubygems.org
|
130
|
+
homepage_uri: http://rubygems.org/gems/balboa_park_itinerary_ideas
|
131
|
+
source_code_uri: https://github.com/jamieberrier/balboa_park_itinerary_ideas
|
132
|
+
changelog_uri: https://github.com/jamieberrier/balboa_park_itinerary_ideas
|
133
|
+
post_install_message:
|
134
|
+
rdoc_options: []
|
135
|
+
require_paths:
|
136
|
+
- lib
|
137
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
138
|
+
requirements:
|
139
|
+
- - ">="
|
140
|
+
- !ruby/object:Gem::Version
|
141
|
+
version: '0'
|
142
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
143
|
+
requirements:
|
144
|
+
- - ">="
|
145
|
+
- !ruby/object:Gem::Version
|
146
|
+
version: '0'
|
147
|
+
requirements: []
|
148
|
+
rubygems_version: 3.0.3
|
149
|
+
signing_key:
|
150
|
+
specification_version: 4
|
151
|
+
summary: Balboa Park Itinerary Ideas
|
152
|
+
test_files: []
|