sharks_ahead 0.1.6

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 799ed924ab9bdaf5017dd61b0d2e8269b6d97f51
4
+ data.tar.gz: 580e4bc937f664fc6f6f475bdc24e215eb33f9bc
5
+ SHA512:
6
+ metadata.gz: 6666011882fc3d10d8d6662c6f0c764918fb0a8065a2dc18919191a175d667fd51633fb8edd46da55d8095950a6b57238b68e05f32b3349c19f7c46898a0c3a3
7
+ data.tar.gz: fd1ec5eeba9af90bc558d8a6348d19dd12ab2f55cb4e76d86f45043878c8170e213468778d1e194112976f9d3d5f88f4df3da6511fab5885b311fb026d8bece3
data/.gitignore ADDED
@@ -0,0 +1,10 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ /sharks_ahead-0.1.3.gem/
@@ -0,0 +1,49 @@
1
+ # Contributor Code of Conduct
2
+
3
+ As contributors and maintainers of this project, and in the interest of
4
+ fostering an open and welcoming community, we pledge to respect all people who
5
+ contribute through reporting issues, posting feature requests, updating
6
+ documentation, submitting pull requests or patches, and other activities.
7
+
8
+ We are committed to making participation in this project a harassment-free
9
+ experience for everyone, regardless of level of experience, gender, gender
10
+ identity and expression, sexual orientation, disability, personal appearance,
11
+ body size, race, ethnicity, age, religion, or nationality.
12
+
13
+ Examples of unacceptable behavior by participants include:
14
+
15
+ * The use of sexualized language or imagery
16
+ * Personal attacks
17
+ * Trolling or insulting/derogatory comments
18
+ * Public or private harassment
19
+ * Publishing other's private information, such as physical or electronic
20
+ addresses, without explicit permission
21
+ * Other unethical or unprofessional conduct
22
+
23
+ Project maintainers have the right and responsibility to remove, edit, or
24
+ reject comments, commits, code, wiki edits, issues, and other contributions
25
+ that are not aligned to this Code of Conduct, or to ban temporarily or
26
+ permanently any contributor for other behaviors that they deem inappropriate,
27
+ threatening, offensive, or harmful.
28
+
29
+ By adopting this Code of Conduct, project maintainers commit themselves to
30
+ fairly and consistently applying these principles to every aspect of managing
31
+ this project. Project maintainers who do not follow or enforce the Code of
32
+ Conduct may be permanently removed from the project team.
33
+
34
+ This code of conduct applies both within project spaces and in public spaces
35
+ when an individual is representing the project or its community.
36
+
37
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
38
+ reported by contacting a project maintainer at beckysherman000@gmail.com. All
39
+ complaints will be reviewed and investigated and will result in a response that
40
+ is deemed necessary and appropriate to the circumstances. Maintainers are
41
+ obligated to maintain confidentiality with regard to the reporter of an
42
+ incident.
43
+
44
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage],
45
+ version 1.3.0, available at
46
+ [http://contributor-covenant.org/version/1/3/0/][version]
47
+
48
+ [homepage]: http://contributor-covenant.org
49
+ [version]: http://contributor-covenant.org/version/1/3/0/
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in sharks_ahead.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2016 Rebecca Sherman (becky000)
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,43 @@
1
+ # SharksAhead
2
+
3
+
4
+ [![Gem Version](https://badge.fury.io/rb/sharks_ahead.svg)](https://badge.fury.io/rb/sharks_ahead)
5
+
6
+ SharksAhead cli gem was built to scrape and display information about living and extinct shark species.
7
+
8
+ ## Installation
9
+
10
+ Add this line to your application's Gemfile:
11
+
12
+ ```ruby
13
+ gem 'sharks_ahead'
14
+ ```
15
+
16
+ And then execute:
17
+
18
+ $ bundle
19
+
20
+ Or install it yourself as:
21
+
22
+ $ gem install sharks_ahead
23
+
24
+ ## Usage
25
+
26
+ ![Thar be sharks ahead! screenshot](https://cloud.githubusercontent.com/assets/18357112/16693613/f4115a9c-4503-11e6-81a9-6b41a4ccb3be.jpg)
27
+
28
+ With a pirate theme, this gem is intended to be educational and amusing for all ages. After installing gem, execute with command "sharks-ahead".
29
+
30
+ ## Development
31
+
32
+ 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.
33
+
34
+ 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).
35
+
36
+ ## Contributing
37
+
38
+ Bug reports and pull requests are welcome on GitHub at https://github.com/becky000/sharks_ahead. 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.
39
+
40
+
41
+ ## License
42
+
43
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+ task :default => :spec
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "sharks_ahead"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
data/bin/sharks-ahead ADDED
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require_relative '../lib/sharks_ahead'
4
+
5
+ SharksAhead::CLI.new.call
@@ -0,0 +1,7 @@
1
+ require 'nokogiri'
2
+ require 'open-uri'
3
+
4
+ require_relative './sharks_ahead/version'
5
+ require_relative './sharks_ahead/shark-living'
6
+ require_relative './sharks_ahead/shark-extinct'
7
+ require_relative './sharks_ahead/cli'
@@ -0,0 +1,168 @@
1
+ class SharksAhead::CLI
2
+
3
+ def call
4
+ welcome
5
+ end
6
+
7
+ def welcome
8
+ puts "\e[H\e[2J"
9
+ # text art generator at http://fsymbols.com/generators/carty/
10
+ puts <<-DOC
11
+ ╔═══╗ ╔╗ ╔╗ ╔═══╗ ╔═══╗ ╔╗╔═╗ ╔╗
12
+ ║╔═╗║ ║║ ║║ ║╔═╗║ ║╔═╗║ ║║║╔╝ ║║
13
+ ║╚══╗ ║╚═╝║ ║║ ║║ ║╚═╝║ ║╚╝╝ ║║
14
+ ╚══╗║ ║╔═╗║ ║╚═╝║ ║╔╗╔╝ ║╔╗║ ╚╝
15
+ ║╚═╝║ ║║ ║║ ║╔═╗║ ║║║╚╗ ║║║╚╗ ╔╗
16
+ ╚═══╝ ╚╝ ╚╝ ╚╝ ╚╝ ╚╝╚═╝ ╚╝╚═╝ ╚╝
17
+ DOC
18
+
19
+ # ascii ship art from http://chris.com/ascii/index.php?art=transportation/nautical
20
+ puts " _~"
21
+ puts " _~ )_)_~ "
22
+ puts " )_))_))_) Thar be sharks ahead! "
23
+ puts " _!__!__!_"
24
+ puts " ~ ~ \\______t/"
25
+ puts "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|\\~~~~~~~|\\~~~~~~~~~~~~~~~~"
26
+ print "\nAre ye prepared to look fer 'em? Tell me! Yes or no? "
27
+
28
+ answer_look = nil
29
+ while answer_look != "exit"
30
+ answer_look = gets.chomp
31
+ case answer_look
32
+ when /^(y|yes)$/i then answer_yes
33
+ when /^(n|no)$/i then goodbye1
34
+ else belay_that
35
+ end
36
+ end
37
+ end
38
+
39
+ def answer_yes
40
+ puts "\e[H\e[2J"
41
+ # ascii shark art from http://www.ascii-art.de/ascii/s/sharks.txt
42
+ puts " , "
43
+ puts " .'; "
44
+ puts " .-'` .' "
45
+ puts " ,`.-'-.`\ "
46
+ puts " ; / '-'"
47
+ puts " | \ ,-,"
48
+ puts " \ '-.__ )_`'._ "
49
+ puts " '. ``` ``'--._ "
50
+ puts " .-' , `'-. Are ye lookin' fer dead sharks"
51
+ puts " '-'`-._ (( o ) or livin'? Tell me!"
52
+ puts " `'--....(`- ,__..--' "
53
+ print " '-'` Dead or alive? "
54
+
55
+ answer_dead_or_alive = nil
56
+ while answer_dead_or_alive != "exit"
57
+ answer_dead_or_alive = gets.chomp
58
+ case answer_dead_or_alive
59
+ when /^(d|dead)$/i then list_extinct
60
+ when /^(a|alive)$/i then list_living
61
+ when /^(e|exit)$/i then goodbye2
62
+ else belay_that
63
+ end
64
+ end
65
+ end
66
+
67
+ def list_extinct
68
+ puts "\nWe'll be lookin' fer extinct ones. Here y'arr:\n\n"
69
+
70
+ @shark_extinct = SharksAhead::SharkExtinct.get_extinct_sharks
71
+ @shark_extinct.each.with_index(1) do |shark, i|
72
+ printf "%3s - %-50s\n", i, shark[:name]
73
+ end
74
+ description_extinct
75
+ end
76
+
77
+ def description_extinct
78
+ extinct_input = nil
79
+ while extinct_input != "exit"
80
+ give_choices
81
+
82
+ extinct_input = gets.chomp
83
+ the_shark = @shark_extinct[extinct_input.to_i-1]
84
+
85
+ case extinct_input
86
+ when /([1-7])/ then puts "\n#{the_shark[:description]}\n\n"
87
+ when /^(l|list)$/i then list_extinct
88
+ when /^(e|exit)$/i then goodbye2
89
+ when /^(s|start)$/i then welcome
90
+ else belay_that
91
+ end
92
+ end
93
+ end
94
+
95
+ def list_living
96
+ puts "\nLet's find thee a livin' one!\n\n"
97
+
98
+ @shark_living = SharksAhead::SharkLiving.get_living_sharks
99
+ @shark_living.each.with_index(1) do |shark, i|
100
+ printf "%3s - %-50s\n", i, shark[:name]
101
+ end
102
+ description_living
103
+ end
104
+
105
+ def description_living
106
+ living_input = nil
107
+ while living_input != "exit"
108
+ give_choices
109
+
110
+ living_input = gets.chomp
111
+ the_shark = @shark_living[living_input.to_i-1]
112
+
113
+ case living_input
114
+ when /([1-7])/ then puts "\n#{the_shark[:description]}\n\n"
115
+ when /^(l|list)$/i then list_living
116
+ when /^(e|exit)$/i then goodbye2
117
+ when /^(s|start)$/i then welcome
118
+ else belay_that
119
+ end
120
+ end
121
+ end
122
+
123
+ def give_choices
124
+ puts "\nWhat's yer lucky number? Else ye may abandon ship by typin' exit."
125
+ puts "If ye cannot recall the list, type list."
126
+ print "If ye wish to start again, ye may type start. "
127
+ end
128
+
129
+ def goodbye1
130
+ puts "\nWell then, ye must be a wee babe. I'll sing ye a lullaby instead.\n\n"
131
+
132
+ # Seal Lullaby from The Jungle Book by Rudyard Kipling
133
+ # http://www.poetryloverspage.com/poets/kipling/seal_lullaby.html
134
+ puts <<-DOC
135
+ Oh! hush thee, my baby, the night is behind us,
136
+ And black are the waters that sparkled so green.
137
+ The moon, o'er the combers, looks downward to find us
138
+ At rest in the hollows that rustle between.
139
+ Where billow meets billow, there soft be thy pillow;
140
+ Ah, weary wee flipperling, curl at thy ease!
141
+ The storm shall not wake thee, nor shark overtake thee,
142
+ Asleep in the arms of the slow-swinging seas.
143
+ DOC
144
+
145
+ puts "\nCome back to see me when ye get yer mettle up."
146
+ ship_end
147
+ exit
148
+ end
149
+
150
+ def goodbye2
151
+ puts "\nFare thee well me matey. Ye may join me crew again anytime!\n\n"
152
+ ship_end
153
+ exit
154
+ end
155
+
156
+ def belay_that
157
+ print "\nBelay that! Ye must make a proper choice. "
158
+ end
159
+
160
+ def ship_end
161
+ puts " . _~ *"
162
+ puts " . * _~ )_)_~"
163
+ puts " * )_))_))_)"
164
+ puts " * . * . _!__!__!_ ."
165
+ puts " \\______t/"
166
+ puts "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\n"
167
+ end
168
+ end
@@ -0,0 +1,22 @@
1
+ class SharksAhead::SharkExtinct
2
+
3
+ def self.get_extinct_sharks
4
+ extinct_sharks = []
5
+ url = [
6
+ 'http://dinosaurs.about.com/od/tetrapodsandamphibians/p/cladoselache.htm',
7
+ 'http://dinosaurs.about.com/od/tetrapodsandamphibians/p/Diablodontus.htm',
8
+ 'http://dinosaurs.about.com/od/tetrapodsandamphibians/p/falcatus.htm',
9
+ 'http://dinosaurs.about.com/od/tetrapodsandamphibians/p/helicoprion.htm',
10
+ 'http://dinosaurs.about.com/od/tetrapodsandamphibians/p/otodus.htm',
11
+ 'http://dinosaurs.about.com/od/tetrapodsandamphibians/p/squalicorax.htm',
12
+ 'http://dinosaurs.about.com/od/tetrapodsandamphibians/p/stethacanthus.htm',
13
+ ]
14
+ url.each do |u|
15
+ doc = Nokogiri::HTML(open(u))
16
+ name = doc.search('h1').text
17
+ description = doc.search('div.col-push-2.col-push-tablet-1.content-responsive p').text.tr("\n", " ")
18
+ extinct_sharks << {name: name, description: description}
19
+ end
20
+ extinct_sharks
21
+ end
22
+ end
@@ -0,0 +1,22 @@
1
+ class SharksAhead::SharkLiving
2
+
3
+ def self.get_living_sharks
4
+ living_sharks = []
5
+ url = [
6
+ 'http://marinelife.about.com/od/vertebrates/p/baskingshark.htm',
7
+ 'http://marinelife.about.com/od/Sharks/p/Blue-Shark.htm',
8
+ 'http://marinelife.about.com/od/fish/p/Greatwhiteshark.htm',
9
+ 'http://marinelife.about.com/od/Sharks/p/Hammerhead-Sharks.htm',
10
+ 'http://marinelife.about.com/od/vertebrates/p/shortfinmako.htm',
11
+ 'http://marinelife.about.com/od/Sharks/p/Tiger-Shark-Galeocerdo-Cuvier.htm',
12
+ 'http://marinelife.about.com/od/fish/p/whaleshark.htm',
13
+ ]
14
+ url.each do |u|
15
+ doc = Nokogiri::HTML(open(u))
16
+ name = doc.search('h1').text
17
+ description = doc.search('article.content.widget.widget-alt.expert-content.expert-content-text p').text
18
+ living_sharks << {name: name, description: description}
19
+ end
20
+ living_sharks
21
+ end
22
+ end
@@ -0,0 +1,3 @@
1
+ module SharksAhead
2
+ VERSION = "0.1.6"
3
+ end
@@ -0,0 +1,24 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'sharks_ahead/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "sharks_ahead"
8
+ spec.version = SharksAhead::VERSION
9
+ spec.authors = ["Rebecca Sherman"]
10
+ spec.email = ["beckysherman000@gmail.com"]
11
+
12
+ spec.summary = %q{Scrapes and displays information via CLI about living and extinct shark species.}
13
+ spec.description = %q{With a pirate theme, this gem is intended to be educational and amusing for all ages.}
14
+ spec.homepage = "https://github.com/becky000/sharks_ahead"
15
+ spec.license = "MIT"
16
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
17
+ spec.bindir = "bin"
18
+ spec.executables = ["sharks-ahead"]
19
+ spec.require_paths = "lib"
20
+
21
+ spec.add_development_dependency "bundler", "~> 1.12"
22
+ spec.add_development_dependency "rake", "~> 10.0"
23
+ spec.add_dependency "nokogiri"
24
+ end
data/spec.md ADDED
@@ -0,0 +1,20 @@
1
+ # Specifications for the CLI Assessment
2
+
3
+ ## Specs:
4
+ - [x] Have a CLI for interfacing with the application
5
+
6
+ After installation, the CLI is called from the command line with `sharks-ahead`.
7
+ The user makes choices by entering from menus of commands.
8
+
9
+
10
+ - [x] Pull data from an external source
11
+
12
+ The gem pulls data from two main external sources:
13
+
14
+ http://marinelife.about.com/od/fish/tp/Types-Of-Sharks.htm
15
+ http://dinosaurs.about.com/od/otherprehistoriclife/a/prehistoric-sharks.htm
16
+
17
+ - [x] Implement both list and detail views
18
+
19
+ The user is presented with a list of choices after choosing from two options.
20
+ When choosing from the list, a detail view is given specific to that choice.
metadata ADDED
@@ -0,0 +1,105 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: sharks_ahead
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.6
5
+ platform: ruby
6
+ authors:
7
+ - Rebecca Sherman
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2016-07-24 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: '1.12'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.12'
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: nokogiri
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ description: With a pirate theme, this gem is intended to be educational and amusing
56
+ for all ages.
57
+ email:
58
+ - beckysherman000@gmail.com
59
+ executables:
60
+ - sharks-ahead
61
+ extensions: []
62
+ extra_rdoc_files: []
63
+ files:
64
+ - ".gitignore"
65
+ - CODE_OF_CONDUCT.md
66
+ - Gemfile
67
+ - LICENSE.txt
68
+ - README.md
69
+ - Rakefile
70
+ - bin/console
71
+ - bin/setup
72
+ - bin/sharks-ahead
73
+ - lib/sharks_ahead.rb
74
+ - lib/sharks_ahead/cli.rb
75
+ - lib/sharks_ahead/shark-extinct.rb
76
+ - lib/sharks_ahead/shark-living.rb
77
+ - lib/sharks_ahead/version.rb
78
+ - sharks_ahead.gemspec
79
+ - spec.md
80
+ homepage: https://github.com/becky000/sharks_ahead
81
+ licenses:
82
+ - MIT
83
+ metadata: {}
84
+ post_install_message:
85
+ rdoc_options: []
86
+ require_paths:
87
+ - lib
88
+ required_ruby_version: !ruby/object:Gem::Requirement
89
+ requirements:
90
+ - - ">="
91
+ - !ruby/object:Gem::Version
92
+ version: '0'
93
+ required_rubygems_version: !ruby/object:Gem::Requirement
94
+ requirements:
95
+ - - ">="
96
+ - !ruby/object:Gem::Version
97
+ version: '0'
98
+ requirements: []
99
+ rubyforge_project:
100
+ rubygems_version: 2.6.6
101
+ signing_key:
102
+ specification_version: 4
103
+ summary: Scrapes and displays information via CLI about living and extinct shark species.
104
+ test_files: []
105
+ has_rdoc: