sharks_ahead 0.1.6 → 0.2.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/CHANGELOG.md +1 -0
- data/README.md +43 -43
- data/bin/sharks-ahead +5 -5
- data/lib/sharks_ahead/cli.rb +183 -168
- data/lib/sharks_ahead/shark-extinct.rb +26 -22
- data/lib/sharks_ahead/shark-living.rb +22 -22
- data/lib/sharks_ahead/version.rb +1 -1
- data/sharks_ahead.gemspec +1 -1
- data/spec.md +20 -20
- metadata +8 -8
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 677949237ec9525dcba486700690d2e37e9d06d2
|
|
4
|
+
data.tar.gz: 50964e5576720b0f7c19cb722c822e348f244c43
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: a84d6b2756f34aa30f96b7e81b7d33a072546530a3b81b35c90206ddc7b90585357f573264491da7d70a037bfb455216b21415919b8e2e701614a55bb3346986
|
|
7
|
+
data.tar.gz: 47638a493767ea28fb9fd399856d76769b49a6ecc68aa72d070e02d9601876f28e56c356e85503ce9b3c5f7595958c2423160d5cde30dca60458ca94ac601184
|
data/CHANGELOG.md
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Version 0.2.0 - fixed broken links in shark-extinct, added word wrap, changed version
|
data/README.md
CHANGED
|
@@ -1,43 +1,43 @@
|
|
|
1
|
-
# SharksAhead
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
[](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
|
-
.
|
|
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).
|
|
1
|
+
# SharksAhead
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
[](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
|
+

|
|
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/bin/sharks-ahead
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
#!/usr/bin/env ruby
|
|
2
|
-
|
|
3
|
-
require_relative '../lib/sharks_ahead'
|
|
4
|
-
|
|
5
|
-
SharksAhead::CLI.new.call
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
|
|
3
|
+
require_relative '../lib/sharks_ahead'
|
|
4
|
+
|
|
5
|
+
SharksAhead::CLI.new.call
|
data/lib/sharks_ahead/cli.rb
CHANGED
|
@@ -1,168 +1,183 @@
|
|
|
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
|
-
|
|
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
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
puts
|
|
45
|
-
|
|
46
|
-
puts "
|
|
47
|
-
puts "
|
|
48
|
-
puts "
|
|
49
|
-
puts " '
|
|
50
|
-
puts "
|
|
51
|
-
puts "
|
|
52
|
-
puts "
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
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
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
puts
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
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
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
def answer_look
|
|
32
|
+
answer = nil
|
|
33
|
+
while answer != "exit"
|
|
34
|
+
answer = gets.chomp
|
|
35
|
+
case answer
|
|
36
|
+
when /^(y|yes)$/i then answer_yes
|
|
37
|
+
when /^(n|no)$/i then goodbye1
|
|
38
|
+
else belay_that
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
def answer_yes
|
|
44
|
+
puts "\e[H\e[2J"
|
|
45
|
+
# ascii shark art from http://www.ascii-art.de/ascii/s/sharks.txt
|
|
46
|
+
puts " , "
|
|
47
|
+
puts " .'; "
|
|
48
|
+
puts " .-'` .' "
|
|
49
|
+
puts " ,`.-'-.`\ "
|
|
50
|
+
puts " ; / '-'"
|
|
51
|
+
puts " | \ ,-,"
|
|
52
|
+
puts " \ '-.__ )_`'._ "
|
|
53
|
+
puts " '. ``` ``'--._ "
|
|
54
|
+
puts " .-' , `'-. Are ye lookin' fer dead sharks"
|
|
55
|
+
puts " '-'`-._ (( o ) or livin'? Tell me!"
|
|
56
|
+
puts " `'--....(`- ,__..--' "
|
|
57
|
+
print " '-'` Dead or alive? "
|
|
58
|
+
|
|
59
|
+
answer_dead_or_alive
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
def answer_dead_or_alive
|
|
63
|
+
answer = nil
|
|
64
|
+
while answer != "exit"
|
|
65
|
+
answer = gets.chomp
|
|
66
|
+
case answer
|
|
67
|
+
when /^(d|dead)$/i then list_extinct
|
|
68
|
+
when /^(a|alive)$/i then list_living
|
|
69
|
+
when /^(e|exit)$/i then goodbye2
|
|
70
|
+
else belay_that
|
|
71
|
+
end
|
|
72
|
+
end
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
def list_extinct
|
|
76
|
+
puts "\nWe'll be lookin' fer extinct ones. Here y'arr:\n\n"
|
|
77
|
+
|
|
78
|
+
@shark_extinct = SharksAhead::SharkExtinct.get_extinct_sharks
|
|
79
|
+
@shark_extinct.each.with_index(1) do |shark, i|
|
|
80
|
+
printf "%3s - %-50s\n", i, shark[:name]
|
|
81
|
+
end
|
|
82
|
+
description_extinct
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
def description_extinct
|
|
86
|
+
extinct_input = nil
|
|
87
|
+
while extinct_input != "exit"
|
|
88
|
+
give_choices
|
|
89
|
+
|
|
90
|
+
extinct_input = gets.chomp
|
|
91
|
+
the_shark = @shark_extinct[extinct_input.to_i-1]
|
|
92
|
+
|
|
93
|
+
case extinct_input
|
|
94
|
+
when /([1-7])/ then puts word_wrap("\n#{the_shark[:description]}\n\n", 75)
|
|
95
|
+
when /^(l|list)$/i then list_extinct
|
|
96
|
+
when /^(e|exit)$/i then goodbye2
|
|
97
|
+
when /^(s|start)$/i then welcome
|
|
98
|
+
else belay_that
|
|
99
|
+
end
|
|
100
|
+
end
|
|
101
|
+
end
|
|
102
|
+
|
|
103
|
+
def list_living
|
|
104
|
+
puts "\nLet's find thee a livin' one!\n\n"
|
|
105
|
+
|
|
106
|
+
@shark_living = SharksAhead::SharkLiving.get_living_sharks
|
|
107
|
+
@shark_living.each.with_index(1) do |shark, i|
|
|
108
|
+
printf "%3s - %-50s\n", i, shark[:name]
|
|
109
|
+
end
|
|
110
|
+
description_living
|
|
111
|
+
end
|
|
112
|
+
|
|
113
|
+
def description_living
|
|
114
|
+
living_input = nil
|
|
115
|
+
while living_input != "exit"
|
|
116
|
+
give_choices
|
|
117
|
+
|
|
118
|
+
living_input = gets.chomp
|
|
119
|
+
the_shark = @shark_living[living_input.to_i-1]
|
|
120
|
+
|
|
121
|
+
case living_input
|
|
122
|
+
when /([1-7])/ then puts word_wrap("\n#{the_shark[:description]}\n\n", 75)
|
|
123
|
+
when /^(l|list)$/i then list_living
|
|
124
|
+
when /^(e|exit)$/i then goodbye2
|
|
125
|
+
when /^(s|start)$/i then welcome
|
|
126
|
+
else belay_that
|
|
127
|
+
end
|
|
128
|
+
end
|
|
129
|
+
end
|
|
130
|
+
|
|
131
|
+
def give_choices
|
|
132
|
+
puts "\nWhat's yer lucky number? Else ye may abandon ship by typin' exit."
|
|
133
|
+
puts "If ye cannot recall the list, type list."
|
|
134
|
+
print "If ye wish to start again, ye may type start. "
|
|
135
|
+
end
|
|
136
|
+
|
|
137
|
+
# Word wrap from Ruby Cookbook
|
|
138
|
+
def word_wrap(text, width = 70)
|
|
139
|
+
text.gsub(/(.{1,#{width}})(\s+|\Z)/, "\\1\n")
|
|
140
|
+
end
|
|
141
|
+
|
|
142
|
+
def goodbye1
|
|
143
|
+
puts "\nWell then, ye must be a wee babe. I'll sing ye a lullaby instead.\n\n"
|
|
144
|
+
lullaby
|
|
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 lullaby
|
|
161
|
+
# Seal Lullaby from The Jungle Book by Rudyard Kipling
|
|
162
|
+
# http://www.poetryloverspage.com/poets/kipling/seal_lullaby.html
|
|
163
|
+
puts <<-DOC
|
|
164
|
+
Oh! hush thee, my baby, the night is behind us,
|
|
165
|
+
And black are the waters that sparkled so green.
|
|
166
|
+
The moon, o'er the combers, looks downward to find us
|
|
167
|
+
At rest in the hollows that rustle between.
|
|
168
|
+
Where billow meets billow, there soft be thy pillow;
|
|
169
|
+
Ah, weary wee flipperling, curl at thy ease!
|
|
170
|
+
The storm shall not wake thee, nor shark overtake thee,
|
|
171
|
+
Asleep in the arms of the slow-swinging seas.
|
|
172
|
+
DOC
|
|
173
|
+
end
|
|
174
|
+
|
|
175
|
+
def ship_end
|
|
176
|
+
puts " . _~ *"
|
|
177
|
+
puts " . * _~ )_)_~"
|
|
178
|
+
puts " * )_))_))_)"
|
|
179
|
+
puts " * . * . _!__!__!_ ."
|
|
180
|
+
puts " \\______t/"
|
|
181
|
+
puts "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\n"
|
|
182
|
+
end
|
|
183
|
+
end
|
|
@@ -1,22 +1,26 @@
|
|
|
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/
|
|
8
|
-
'http://dinosaurs.about.com/od/tetrapodsandamphibians/p/
|
|
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
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
end
|
|
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/cretoxyrhina.htm',
|
|
8
|
+
'http://dinosaurs.about.com/od/tetrapodsandamphibians/p/Edestus.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
|
+
]
|
|
15
|
+
url.each do |u|
|
|
16
|
+
doc = Nokogiri::HTML(open(u))
|
|
17
|
+
name = doc.search('h1').text
|
|
18
|
+
description = doc.search('div.col-push-2.col-push-tablet-1.content-responsive p').text.tr("\n", " ")
|
|
19
|
+
extinct_sharks << {name: name, description: description}
|
|
20
|
+
end
|
|
21
|
+
extinct_sharks
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
# [19] pry(main)> link = doc.search('a[href]').text
|
|
26
|
+
# => "\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t \n\t\t\t\t\t\t\t\nAbout.comAutosCareersDating & RelationshipsEducationen EspañolEntertainmentFoodHealthHomeMoneyNews & IssuesParentingReligion & SpiritualitySportsStyleTechTravel\t\t\t\t1\n\t\t\t\t 400 Million Years of Shark Evolution\n\n\t\t\t\t\t2\n\t\t\t\t\t 500 Million Years of Fish Evolution\n\n\t\t\t\t\t3\n\t\t\t\t\t The Devonian Period (416-360 Million Years Ago)\n\n\t\t\t\t\t4\n\t\t\t\t\t Ichthyosaurs - The \"Fish Lizards\"\n\n\t\t\t\t\t5\n\t\t\t\t\t Helicoprion\n\n\t\t\t\tAbout.com\n\t\t\t\t\tAbout Education\n\t\t\t\t\tDinosaurs\n\t\t\t\t\t\tPrehistoric Animals\nBy Bob Strauss\t\t \tDinosaurs Expert\n \n\n\n\n\n\n\n\n\n\n\nShare\n\n\n\n\n\n\n\n\n\n\n\n\n\n \n\n\n\n\n\n\n\n\n\n\nPin\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n \n\n\n\n\n\n\n\n\n\n\nTweet\n\n\n\n\n\n\n\n\n\n\n\n\n\n \n\n\n\n\n\n\n\n\n\n\nSubmit\n\n\n\n\n\n\n\n\n\n\n\n\n\n \n\n\n\n\n\n\n\n\n\n\nStumble\n\n\n\n\n\n\n\n\n\n\n\n\n\n \n\n\n\n\n\n\n\n\n\n\nPost\n\n\n\n\n\n\n\n\n\n\n\n\n\n \n\n\n\n\n\n\n\n\n\n\nShare\n\n\n\n\n\n\n\n\n\n\n\n\n\nBob StraussOrdovicianpliosaursmosasaursGreat White Sharkgallery of prehistoric shark pictureswhy there are no giant sharks alive todayfossilized teethtetrapodsCladoselacheStethacanthusOrthacanthusXenacanthusMesozoic EraichthyosaursHybodusCretaceousCretoxyrhinaSqualicoraxPtychodusMioceneOtodusMegalodonclimate changeCladoselacheCretoxyrhinaDiablodontusEdestusFalcatusHelicoprionHybodusIschyrhizaMegalodonOrthacanthusOtodusPtychodusSqualicoraxStethacanthusXenacanthus\t\t\n\t\t\tShow Full Article\n\t\t\t\n\t\t\nHybodus FactsThese Sharks Were the Terror of the Mesozoic and Cenozoic ErasStethacanthus FactsSqualicorax FactsDinosaurs Dinosaur Basics\n Types of Dinosaurs - Carnivorous and Herbivorous Dinosaurs and Other Prehistoric Reptiles\n Dinosaur Evolution\n The Daily Life of a Dinosaur\n Dinosaurs and Birds\n Prehistoric Animals\n Dinosaur Extinction\n Dinosaur Controversies\n Dinosaur Discovery\n Dinosaur Fun!\nAbout Education\n\n\n\nOur StoryAdvertise With UsSite MapHelpWrite for AboutCareers at AboutTerms of Use & PoliciesVerywellThe Balance"
|
|
@@ -1,22 +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
|
|
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
|
data/lib/sharks_ahead/version.rb
CHANGED
data/sharks_ahead.gemspec
CHANGED
data/spec.md
CHANGED
|
@@ -1,20 +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.
|
|
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
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: sharks_ahead
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.2.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Rebecca Sherman
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2016-
|
|
11
|
+
date: 2016-10-05 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: bundler
|
|
@@ -42,16 +42,16 @@ dependencies:
|
|
|
42
42
|
name: nokogiri
|
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
|
44
44
|
requirements:
|
|
45
|
-
- - "
|
|
45
|
+
- - "~>"
|
|
46
46
|
- !ruby/object:Gem::Version
|
|
47
|
-
version:
|
|
47
|
+
version: 1.6.8
|
|
48
48
|
type: :runtime
|
|
49
49
|
prerelease: false
|
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
|
51
51
|
requirements:
|
|
52
|
-
- - "
|
|
52
|
+
- - "~>"
|
|
53
53
|
- !ruby/object:Gem::Version
|
|
54
|
-
version:
|
|
54
|
+
version: 1.6.8
|
|
55
55
|
description: With a pirate theme, this gem is intended to be educational and amusing
|
|
56
56
|
for all ages.
|
|
57
57
|
email:
|
|
@@ -62,6 +62,7 @@ extensions: []
|
|
|
62
62
|
extra_rdoc_files: []
|
|
63
63
|
files:
|
|
64
64
|
- ".gitignore"
|
|
65
|
+
- CHANGELOG.md
|
|
65
66
|
- CODE_OF_CONDUCT.md
|
|
66
67
|
- Gemfile
|
|
67
68
|
- LICENSE.txt
|
|
@@ -97,9 +98,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
97
98
|
version: '0'
|
|
98
99
|
requirements: []
|
|
99
100
|
rubyforge_project:
|
|
100
|
-
rubygems_version: 2.
|
|
101
|
+
rubygems_version: 2.4.8
|
|
101
102
|
signing_key:
|
|
102
103
|
specification_version: 4
|
|
103
104
|
summary: Scrapes and displays information via CLI about living and extinct shark species.
|
|
104
105
|
test_files: []
|
|
105
|
-
has_rdoc:
|