pup_finder 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.DS_Store +0 -0
- data/.gitignore +8 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +8 -0
- data/Gemfile.lock +34 -0
- data/LICENSE.txt +21 -0
- data/README.md +45 -0
- data/Rakefile +2 -0
- data/bin/console +14 -0
- data/bin/pup_finder +5 -0
- data/bin/run +3 -0
- data/bin/setup +8 -0
- data/config/environment.rb +11 -0
- data/lib/pup_finder.rb +2 -0
- data/lib/pup_finder/breed.rb +23 -0
- data/lib/pup_finder/cli.rb +173 -0
- data/lib/pup_finder/scraper.rb +68 -0
- data/lib/pup_finder/urlgenerator.rb +21 -0
- data/lib/pup_finder/version.rb +3 -0
- data/pup_finder.gemspec +29 -0
- metadata +92 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: ec0c7c0f46bde2811e00c02face34f61dac9867d00f08a5e180ba4bd4564e058
|
4
|
+
data.tar.gz: dfdf4f7da9d724c48fe39dece5d9153ce052a8865deef22e54eda2f5d55dff01
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: f89080ee6d5cef79478a1ed746441bcfa38d54e06e77325c5263c3b7d3e35468d07571643dedf827267ee025c7a223cf9313a797730b5a904f34241728514bc4
|
7
|
+
data.tar.gz: c25c11361f354720a5f6b1f9f25e86d33754d5da67d06cff4e6f6505274d5c6f8e7c3c7f525741820a6fc447f45cc0a70822c9f31b657d14d54d5950af3b5d9d
|
data/.DS_Store
ADDED
Binary file
|
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 <github email address>. 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,34 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
pup_finder (0.1.0)
|
5
|
+
|
6
|
+
GEM
|
7
|
+
remote: https://rubygems.org/
|
8
|
+
specs:
|
9
|
+
coderay (1.1.2)
|
10
|
+
method_source (0.9.2)
|
11
|
+
mini_portile2 (2.4.0)
|
12
|
+
nokogiri (1.10.3)
|
13
|
+
mini_portile2 (~> 2.4.0)
|
14
|
+
pry (0.12.2)
|
15
|
+
coderay (~> 1.1.0)
|
16
|
+
method_source (~> 0.9.0)
|
17
|
+
rainbow (3.0.0)
|
18
|
+
rake (10.5.0)
|
19
|
+
require_all (2.0.0)
|
20
|
+
|
21
|
+
PLATFORMS
|
22
|
+
ruby
|
23
|
+
|
24
|
+
DEPENDENCIES
|
25
|
+
bundler (~> 2.0)
|
26
|
+
nokogiri
|
27
|
+
pry
|
28
|
+
pup_finder!
|
29
|
+
rainbow
|
30
|
+
rake (~> 10.0)
|
31
|
+
require_all
|
32
|
+
|
33
|
+
BUNDLED WITH
|
34
|
+
2.0.1
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2019 <github username>
|
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,45 @@
|
|
1
|
+
# PupFinder
|
2
|
+
|
3
|
+
Welcome to PupFinder! This Ruby gem provides a CLI to browse the American Kennel Club's offical list of dog breeds. The gem also allows you to view more information about a selected breed.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem 'pup_finder'
|
11
|
+
```
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
$ bundle
|
16
|
+
|
17
|
+
Or install it yourself as:
|
18
|
+
|
19
|
+
$ gem install pup_finder
|
20
|
+
|
21
|
+
## Usage
|
22
|
+
|
23
|
+
Type the below and follow the on screen prompts.
|
24
|
+
|
25
|
+
``` ruby
|
26
|
+
$ pup_finder
|
27
|
+
```
|
28
|
+
|
29
|
+
## Development
|
30
|
+
|
31
|
+
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.
|
32
|
+
|
33
|
+
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).
|
34
|
+
|
35
|
+
## Contributing
|
36
|
+
|
37
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/eponsonby/pup_finder. 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.
|
38
|
+
|
39
|
+
## License
|
40
|
+
|
41
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
42
|
+
|
43
|
+
## Code of Conduct
|
44
|
+
|
45
|
+
Everyone interacting in the PupFinder project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/eponsonby/pup_finder/blob/master/CODE_OF_CONDUCT.md).
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "pup_finder"
|
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(__FILE__)
|
data/bin/pup_finder
ADDED
data/bin/run
ADDED
data/bin/setup
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
require 'open-uri'
|
2
|
+
require_relative '../lib/pup_finder/breed.rb'
|
3
|
+
require_relative '../lib/pup_finder/cli.rb'
|
4
|
+
require_relative '../lib/pup_finder/scraper.rb'
|
5
|
+
require_relative '../lib/pup_finder/urlgenerator.rb'
|
6
|
+
require_relative '../lib/pup_finder/version.rb'
|
7
|
+
|
8
|
+
require 'pry'
|
9
|
+
require 'require_all'
|
10
|
+
require 'nokogiri'
|
11
|
+
require 'rainbow'
|
data/lib/pup_finder.rb
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
class Breed
|
2
|
+
attr_accessor :temperament, :weight, :life_expectancy, :description
|
3
|
+
attr_reader :breed_name, :breed_link, :breed_size
|
4
|
+
|
5
|
+
@@all = []
|
6
|
+
|
7
|
+
def initialize(breed_name, breed_link, breed_size)
|
8
|
+
@breed_name = breed_name
|
9
|
+
@breed_link = breed_link
|
10
|
+
@breed_size = breed_size
|
11
|
+
@temperament = nil
|
12
|
+
@weight = nil
|
13
|
+
@life_expectancy = nil
|
14
|
+
@description = nil
|
15
|
+
@@all << self
|
16
|
+
end
|
17
|
+
|
18
|
+
def self.all
|
19
|
+
@@all
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
|
@@ -0,0 +1,173 @@
|
|
1
|
+
class CLI
|
2
|
+
|
3
|
+
attr_reader :generated_url, :selected_size, :list
|
4
|
+
|
5
|
+
def welcome
|
6
|
+
puts Rainbow(" _____ ______ _ _").cyan
|
7
|
+
puts Rainbow("| __ \\\ | ____(_) | |").cyan
|
8
|
+
puts Rainbow("| |__) | _ _ __ | |__ _ _ __ __| | ___ _ __").cyan
|
9
|
+
puts Rainbow("| ___/ | | | '_ \\\ | __| | | '_ \\\ / _` |/ _ \\\ '__|").cyan
|
10
|
+
puts Rainbow("| | | |_| | |_) | | | | | | | | (_| | __/ |").cyan
|
11
|
+
puts Rainbow("|_| \\\__,_| .__/ |_| |_|_| |_|\\\__,_|\\\___|_|").cyan
|
12
|
+
puts Rainbow(" | | ").cyan
|
13
|
+
puts Rainbow(" |_| ").cyan
|
14
|
+
puts Rainbow("\nWelcome to PupFinder!").bright
|
15
|
+
|
16
|
+
call
|
17
|
+
end
|
18
|
+
|
19
|
+
def call
|
20
|
+
what_size
|
21
|
+
if get_size != "exit"
|
22
|
+
please_wait
|
23
|
+
scrape_pages
|
24
|
+
get_info
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
def get_info
|
29
|
+
@list = list_breeds
|
30
|
+
enter_a_number
|
31
|
+
number_to_see = get_number(list)
|
32
|
+
|
33
|
+
if number_to_see == "exit"
|
34
|
+
puts Rainbow("\n\nGoodbye!").cyan
|
35
|
+
else
|
36
|
+
breed_to_scrape = list[number_to_see - 1]
|
37
|
+
exists = Breed.all.select {|breed_object| breed_object.breed_name == breed_to_scrape}
|
38
|
+
|
39
|
+
if !exists[0].weight
|
40
|
+
AKCScraper.make_breed(number_to_see, list)
|
41
|
+
end
|
42
|
+
|
43
|
+
more_info(number_to_see)
|
44
|
+
continue_message
|
45
|
+
options
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
def what_size
|
50
|
+
puts "What size pupper are you interested in?"
|
51
|
+
puts "You can say tiny, small, medium, large, or huge\n\n"
|
52
|
+
end
|
53
|
+
|
54
|
+
def get_size
|
55
|
+
sizes_to_select_from = ["tiny", "small", "medium", "large", "huge"]
|
56
|
+
input = gets.strip.downcase
|
57
|
+
|
58
|
+
if input == "tiny"
|
59
|
+
input = "xsmall"
|
60
|
+
elsif input == "huge"
|
61
|
+
input = "xlarge"
|
62
|
+
elsif input == "exit"
|
63
|
+
puts Rainbow("Goodbye!").cyan
|
64
|
+
return "exit"
|
65
|
+
elsif !sizes_to_select_from.include?(input)
|
66
|
+
puts "Please try again"
|
67
|
+
input = get_size
|
68
|
+
end
|
69
|
+
|
70
|
+
@selected_size = input
|
71
|
+
return input
|
72
|
+
end
|
73
|
+
|
74
|
+
def please_wait
|
75
|
+
puts "\nPlease wait while we load the pups!\n\n"
|
76
|
+
end
|
77
|
+
|
78
|
+
def generate_url(input)
|
79
|
+
url_to_scrape = URLGenerator.new_url(input)
|
80
|
+
end
|
81
|
+
|
82
|
+
def scrape_pages
|
83
|
+
#this prevents the program from instantiating new breeds if they already exist
|
84
|
+
if @generated_url == generate_url(selected_size)
|
85
|
+
|
86
|
+
else
|
87
|
+
@generated_url = generate_url(selected_size)
|
88
|
+
AKCScraper.get_all_pages_of_breeds(generated_url)
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
# Returns an array of all breed objects (with just name, size and link attributes) that match size
|
93
|
+
def find_all_breeds_by_size(size)
|
94
|
+
Breed.all.select {|breed_object| breed_object.breed_size == size}
|
95
|
+
end
|
96
|
+
|
97
|
+
|
98
|
+
# Returns a numbered list of all breeds by the selected size
|
99
|
+
def list_breeds
|
100
|
+
find_all_breeds_by_size(selected_size).map.with_index do |breed, index|
|
101
|
+
puts Rainbow("#{index + 1}. #{breed.breed_name}").cyan
|
102
|
+
breed.breed_name
|
103
|
+
end
|
104
|
+
end
|
105
|
+
|
106
|
+
def enter_a_number
|
107
|
+
puts "\n\nEnter a number to see more information about that pup \n\n"
|
108
|
+
end
|
109
|
+
|
110
|
+
def get_number(list)
|
111
|
+
range_to_select_from = (1..list.length).to_a
|
112
|
+
number_entered = gets.strip
|
113
|
+
if number_entered != "exit"
|
114
|
+
number_entered = number_entered.to_i
|
115
|
+
loop do
|
116
|
+
if !range_to_select_from.include?(number_entered)
|
117
|
+
puts "Please enter a number between #{range_to_select_from[0]} and #{range_to_select_from[-1]}"
|
118
|
+
return get_number(list)
|
119
|
+
else
|
120
|
+
return number_entered
|
121
|
+
end
|
122
|
+
end
|
123
|
+
else
|
124
|
+
return "exit"
|
125
|
+
end
|
126
|
+
end
|
127
|
+
|
128
|
+
def more_info(number_entered)
|
129
|
+
breed_to_see = @list[number_entered - 1]
|
130
|
+
Breed.all.each do |breed|
|
131
|
+
if breed.breed_name == breed_to_see
|
132
|
+
puts Rainbow("\nThe #{breed.breed_name}\n").bold
|
133
|
+
puts Rainbow(" __\n(___()'`;\n/, /`\n\\\\'--\\\\\n\n").cyan.bright
|
134
|
+
puts Rainbow("Temperament: ").bold + Rainbow("#{breed.temperament}\n").cyan
|
135
|
+
puts Rainbow("Weight: ").bold + Rainbow("#{breed.weight}\n").cyan
|
136
|
+
puts Rainbow("Life Expectancy: ").bold + Rainbow("#{breed.life_expectancy}\n").cyan
|
137
|
+
puts Rainbow("Description: ").bold + Rainbow("#{breed.description}\n").cyan
|
138
|
+
end
|
139
|
+
end
|
140
|
+
end
|
141
|
+
|
142
|
+
|
143
|
+
def continue_message
|
144
|
+
puts "\nWould you like to see another pup?"
|
145
|
+
puts "You can enter yes, no, or menu to go back to the main menu"
|
146
|
+
puts "Enter exit to end this program\n\n"
|
147
|
+
end
|
148
|
+
|
149
|
+
def continue_gets
|
150
|
+
gets.strip.downcase
|
151
|
+
end
|
152
|
+
|
153
|
+
def options
|
154
|
+
case continue_gets
|
155
|
+
when "yes"
|
156
|
+
puts "\n"
|
157
|
+
get_info
|
158
|
+
when "menu"
|
159
|
+
puts "\n"
|
160
|
+
call
|
161
|
+
when "no"
|
162
|
+
puts Rainbow("\nGoodbye!").cyan
|
163
|
+
when "exit"
|
164
|
+
puts Rainbow("\nGoodbye!").cyan
|
165
|
+
else
|
166
|
+
puts "Please try again"
|
167
|
+
options
|
168
|
+
end
|
169
|
+
end
|
170
|
+
|
171
|
+
|
172
|
+
end
|
173
|
+
|
@@ -0,0 +1,68 @@
|
|
1
|
+
class AKCScraper
|
2
|
+
|
3
|
+
@@load_more_link = nil
|
4
|
+
|
5
|
+
def self.get_first_page_breeds(size_url)
|
6
|
+
#open first url based on user input
|
7
|
+
doc = Nokogiri::HTML(open(size_url))
|
8
|
+
|
9
|
+
# get all breeds on page 1
|
10
|
+
first_page_breeds = doc.css('.breed-card-type-grid .grid-col')
|
11
|
+
initial_breed_instantiation(first_page_breeds, size_url)
|
12
|
+
|
13
|
+
# get load more link on page 1
|
14
|
+
@@load_more_link = doc.css(".mt2 a").attribute("href").value
|
15
|
+
end
|
16
|
+
|
17
|
+
def self.get_all_pages_of_breeds(size_url)
|
18
|
+
self.get_first_page_breeds(size_url)
|
19
|
+
|
20
|
+
while @@load_more_link do
|
21
|
+
# get all breeds on page #
|
22
|
+
next_page_doc = Nokogiri::HTML(open(@@load_more_link))
|
23
|
+
next_page_breeds = next_page_doc.css('.breed-card-type-grid .grid-col')
|
24
|
+
initial_breed_instantiation(next_page_breeds, size_url)
|
25
|
+
|
26
|
+
# get load more link on page #
|
27
|
+
@@load_more_link = next_page_doc.css(".mt2 a").attribute("href")
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
def self.initial_breed_instantiation(page_of_breeds, size_url)
|
32
|
+
page_of_breeds.each do |breed|
|
33
|
+
breed_name = breed.css(".breed-type-card a h3").text
|
34
|
+
breed_link = breed.css(".breed-type-card a").attribute('href').value
|
35
|
+
breed_size = size_url.split("=")[1]
|
36
|
+
Breed.new(breed_name, breed_link, breed_size)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
def self.make_breed(number, list)
|
41
|
+
breed_to_scrape = list[number - 1]
|
42
|
+
|
43
|
+
# Creates an array with just the object we want to add more data too
|
44
|
+
breed_object_array = Breed.all.select {|breed| breed.breed_name == breed_to_scrape}
|
45
|
+
|
46
|
+
doc = Nokogiri::HTML(open(breed_object_array[0].breed_link))
|
47
|
+
# Get each li and set each attribute
|
48
|
+
all_lis = doc.css(".panel-flex__aside ul li.attribute-list__row")
|
49
|
+
all_lis.each do |li|
|
50
|
+
if li.css(".attribute-list__term").text == "Temperament:"
|
51
|
+
breed_object_array[0].temperament = li.css(".attribute-list__description").text
|
52
|
+
elsif li.css(".attribute-list__term").text == "Weight:"
|
53
|
+
breed_object_array[0].weight = li.css(".attribute-list__description").text
|
54
|
+
elsif li.css(".attribute-list__term").text == "Life Expectancy:"
|
55
|
+
breed_object_array[0].life_expectancy = li.css(".attribute-list__description").text.strip
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
# Sets the breed description
|
60
|
+
if doc.css(".breed-hero__footer")
|
61
|
+
breed_object_array[0].description = doc.css(".breed-hero__footer").text.strip
|
62
|
+
else
|
63
|
+
breed_object_array[0].description = "none available"
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
end
|
68
|
+
|
@@ -0,0 +1,21 @@
|
|
1
|
+
class URLGenerator
|
2
|
+
|
3
|
+
def self.new_url(selected_size)
|
4
|
+
base_url = "https://www.akc.org/dog-breeds/"
|
5
|
+
input = selected_size
|
6
|
+
case input
|
7
|
+
when "xsmall"
|
8
|
+
new_url = base_url << "?size=#{input}"
|
9
|
+
when "small"
|
10
|
+
new_url = base_url << "?size=#{input}"
|
11
|
+
when "medium"
|
12
|
+
new_url = base_url << "?size=#{input}"
|
13
|
+
when "large"
|
14
|
+
new_url = base_url << "?size=#{input}"
|
15
|
+
when "xlarge"
|
16
|
+
new_url = base_url << "?size=#{input}"
|
17
|
+
end
|
18
|
+
return new_url
|
19
|
+
end
|
20
|
+
|
21
|
+
end
|
data/pup_finder.gemspec
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
|
2
|
+
lib = File.expand_path("./lib", __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require_relative "./lib/pup_finder/version"
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "pup_finder"
|
8
|
+
spec.version = PupFinder::VERSION
|
9
|
+
spec.authors = ["Erin Ponsonby"]
|
10
|
+
spec.email = ["erinponsonby@gmail.com"]
|
11
|
+
|
12
|
+
spec.summary = %q{A gem for browsing the American Kennel Clubs offical list of dogs.}
|
13
|
+
spec.homepage = "https://github.com/eponsonby/pup_finder"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
|
17
|
+
spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
|
18
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
19
|
+
end
|
20
|
+
|
21
|
+
spec.bindir = "bin"
|
22
|
+
spec.executables = ["pup_finder"]
|
23
|
+
spec.require_paths = ["lib"]
|
24
|
+
|
25
|
+
spec.add_development_dependency "bundler", "~> 2.0"
|
26
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
27
|
+
|
28
|
+
|
29
|
+
end
|
metadata
ADDED
@@ -0,0 +1,92 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: pup_finder
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.5.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Erin Ponsonby
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2019-06-26 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
|
+
description:
|
42
|
+
email:
|
43
|
+
- erinponsonby@gmail.com
|
44
|
+
executables:
|
45
|
+
- pup_finder
|
46
|
+
extensions: []
|
47
|
+
extra_rdoc_files: []
|
48
|
+
files:
|
49
|
+
- ".DS_Store"
|
50
|
+
- ".gitignore"
|
51
|
+
- CODE_OF_CONDUCT.md
|
52
|
+
- Gemfile
|
53
|
+
- Gemfile.lock
|
54
|
+
- LICENSE.txt
|
55
|
+
- README.md
|
56
|
+
- Rakefile
|
57
|
+
- bin/console
|
58
|
+
- bin/pup_finder
|
59
|
+
- bin/run
|
60
|
+
- bin/setup
|
61
|
+
- config/environment.rb
|
62
|
+
- lib/pup_finder.rb
|
63
|
+
- lib/pup_finder/breed.rb
|
64
|
+
- lib/pup_finder/cli.rb
|
65
|
+
- lib/pup_finder/scraper.rb
|
66
|
+
- lib/pup_finder/urlgenerator.rb
|
67
|
+
- lib/pup_finder/version.rb
|
68
|
+
- pup_finder.gemspec
|
69
|
+
homepage: https://github.com/eponsonby/pup_finder
|
70
|
+
licenses:
|
71
|
+
- MIT
|
72
|
+
metadata: {}
|
73
|
+
post_install_message:
|
74
|
+
rdoc_options: []
|
75
|
+
require_paths:
|
76
|
+
- lib
|
77
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
78
|
+
requirements:
|
79
|
+
- - ">="
|
80
|
+
- !ruby/object:Gem::Version
|
81
|
+
version: '0'
|
82
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
83
|
+
requirements:
|
84
|
+
- - ">="
|
85
|
+
- !ruby/object:Gem::Version
|
86
|
+
version: '0'
|
87
|
+
requirements: []
|
88
|
+
rubygems_version: 3.0.4
|
89
|
+
signing_key:
|
90
|
+
specification_version: 4
|
91
|
+
summary: A gem for browsing the American Kennel Clubs offical list of dogs.
|
92
|
+
test_files: []
|