pets_seeking_people 0.2.0 → 0.3.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/Gemfile +1 -1
- data/Gemfile.lock +2 -2
- data/bin/pets_seeking_people +1 -1
- data/lib/pets_seeking_people/cli.rb +16 -23
- data/lib/pets_seeking_people/pets.rb +5 -1
- data/lib/pets_seeking_people/scraper.rb +8 -1
- data/lib/pets_seeking_people/version.rb +1 -1
- data/spec.md +2 -4
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 66b99d7db1a44914d2ea092f42af2b249adb064523d39a71fc74fa7a563cba9e
|
|
4
|
+
data.tar.gz: 44cbbf3185528432de8618c1c50c5d6ee156c9b2e8a9388e99a940202d948002
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: be5417bf4d1fc7c84df5402bac5ab730525c455fae5261f342d29a154870636205cfa4c97855de53bb12568dc2a2fad585bcfa8990d5f97e500dec7873be0f88
|
|
7
|
+
data.tar.gz: 7a3c57403c803b7f38fa632058da8b421a099fc98d123f20993e5b16a73e670ab4a320bc8edb948fe953450b26bd60520937daa468cb90a01db7683ca73018e5
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: .
|
|
3
3
|
specs:
|
|
4
|
-
pets_seeking_people (0.
|
|
4
|
+
pets_seeking_people (0.3.0)
|
|
5
5
|
nokogiri
|
|
6
6
|
|
|
7
7
|
GEM
|
|
@@ -11,7 +11,7 @@ GEM
|
|
|
11
11
|
diff-lcs (1.3)
|
|
12
12
|
method_source (0.9.0)
|
|
13
13
|
mini_portile2 (2.3.0)
|
|
14
|
-
nokogiri (1.8.
|
|
14
|
+
nokogiri (1.8.2)
|
|
15
15
|
mini_portile2 (~> 2.3.0)
|
|
16
16
|
pry (0.11.3)
|
|
17
17
|
coderay (~> 1.1.0)
|
data/bin/pets_seeking_people
CHANGED
|
@@ -1,10 +1,6 @@
|
|
|
1
|
-
# This is the toolkit key for cats as of 1/30/18. It may change. toolkitKey=6REv6Spa
|
|
2
|
-
# This is the toolkit key for dogs as of 1/30/18. It may change. toolkitKey=zu8atrEs
|
|
3
|
-
# Adjust toolkit keys on line 50 as needed.
|
|
4
|
-
|
|
5
1
|
class PetsSeekingPeople::CLI
|
|
6
2
|
|
|
7
|
-
|
|
3
|
+
attr_accessor :pet_input, :zip_input
|
|
8
4
|
|
|
9
5
|
def call
|
|
10
6
|
puts "Welcome to pets seeking people!"
|
|
@@ -51,16 +47,14 @@ class PetsSeekingPeople::CLI
|
|
|
51
47
|
end
|
|
52
48
|
|
|
53
49
|
def find_available_pets
|
|
54
|
-
|
|
55
|
-
animals_array = PetsSeekingPeople::Scraper.scrape_index_page("https://toolkit.rescuegroups.org/j/3/grid1_layout.php?&location_0=#{zip_input}&toolkitIndex=0&toolkitKey=#{pet_type_input}", pet_type_input)
|
|
50
|
+
animals_array = PetsSeekingPeople::Scraper.scrape_index_page(zip_input, pet_input)
|
|
56
51
|
PetsSeekingPeople::Pets.create_from_collection(animals_array)
|
|
57
52
|
end
|
|
58
53
|
|
|
59
|
-
def add_info_about_pet(
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
search_pet.add_animal_attributes(info)
|
|
54
|
+
def add_info_about_pet(list_pet)
|
|
55
|
+
if !list_pet.info
|
|
56
|
+
info = PetsSeekingPeople::Scraper.scrape_animal_page(list_pet.animal_url)
|
|
57
|
+
list_pet.add_animal_attributes(info)
|
|
64
58
|
end
|
|
65
59
|
end
|
|
66
60
|
|
|
@@ -73,23 +67,22 @@ class PetsSeekingPeople::CLI
|
|
|
73
67
|
end
|
|
74
68
|
end
|
|
75
69
|
|
|
76
|
-
def list_details(
|
|
77
|
-
add_info_about_pet(
|
|
78
|
-
pet = PetsSeekingPeople::Pets.all[pet_number]
|
|
70
|
+
def list_details(list_pet)
|
|
71
|
+
add_info_about_pet(list_pet)
|
|
79
72
|
puts ""
|
|
80
|
-
puts "------------------- Here's info on #{
|
|
73
|
+
puts "------------------- Here's info on #{list_pet.name}: ---------------------"
|
|
81
74
|
puts ""
|
|
82
75
|
puts "Some deets you should know:"
|
|
83
|
-
|
|
76
|
+
list_pet.info.each {|pet_fact| puts "#{pet_fact}"}
|
|
84
77
|
puts ""
|
|
85
78
|
puts "--------------------------------------------------------------------------"
|
|
86
79
|
puts ""
|
|
87
|
-
puts "If you want to adopt #{
|
|
88
|
-
|
|
80
|
+
puts "If you want to adopt #{list_pet.name}, contact:"
|
|
81
|
+
list_pet.adoption_contact.each {|contact| puts "#{contact}"}
|
|
89
82
|
puts ""
|
|
90
83
|
puts "--------------------------------------------------------------------------"
|
|
91
84
|
puts ""
|
|
92
|
-
puts "For more details on #{
|
|
85
|
+
puts "For more details on #{list_pet.name}, go to: #{list_pet.adoption_website}"
|
|
93
86
|
end
|
|
94
87
|
|
|
95
88
|
def menu
|
|
@@ -107,9 +100,9 @@ class PetsSeekingPeople::CLI
|
|
|
107
100
|
puts ""
|
|
108
101
|
input = gets.strip.downcase
|
|
109
102
|
|
|
110
|
-
if input.to_i > 0 && input.to_i <=
|
|
111
|
-
|
|
112
|
-
list_details(
|
|
103
|
+
if input.to_i > 0 && input.to_i <= PetsSeekingPeople::Pets.all.size
|
|
104
|
+
list_pet = PetsSeekingPeople::Pets.find(input)
|
|
105
|
+
list_details(list_pet)
|
|
113
106
|
elsif input == "list"
|
|
114
107
|
list_pets
|
|
115
108
|
end
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
class PetsSeekingPeople::Pets
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
attr_accessor :name, :breed, :age, :gender, :animal_url, :info, :detailed_info, :adoption_contact, :adoption_website
|
|
4
4
|
|
|
5
5
|
@@all = []
|
|
6
6
|
|
|
@@ -24,5 +24,9 @@ class PetsSeekingPeople::Pets
|
|
|
24
24
|
@@all
|
|
25
25
|
end
|
|
26
26
|
|
|
27
|
+
def self.find(input)
|
|
28
|
+
self.all[input.to_i-1]
|
|
29
|
+
end
|
|
30
|
+
|
|
27
31
|
end
|
|
28
32
|
|
|
@@ -1,6 +1,12 @@
|
|
|
1
|
+
# This is the toolkit key for cats as of 1/30/18. It may change. toolkitKey=6REv6Spa
|
|
2
|
+
# This is the toolkit key for dogs as of 1/30/18. It may change. toolkitKey=zu8atrEs
|
|
3
|
+
# Adjust toolkit keys on line 8 as needed.
|
|
4
|
+
|
|
1
5
|
class PetsSeekingPeople::Scraper
|
|
2
6
|
|
|
3
|
-
def self.scrape_index_page(
|
|
7
|
+
def self.scrape_index_page(zip_input, pet_input)
|
|
8
|
+
pet_input == "cat" ? pet_type_input = "6REv6Spa" : pet_type_input = "zu8atrEs"
|
|
9
|
+
index_url = "https://toolkit.rescuegroups.org/j/3/grid1_layout.php?&location_0=#{zip_input}&toolkitIndex=0&toolkitKey=#{pet_type_input}"
|
|
4
10
|
doc = Nokogiri::HTML(open(index_url))
|
|
5
11
|
animals = []
|
|
6
12
|
|
|
@@ -56,5 +62,6 @@ class PetsSeekingPeople::Scraper
|
|
|
56
62
|
animal[:adoption_website] = profile_doc.xpath("//*[@id='rgtkPetFieldOrgUrl_0']/a").text #org website
|
|
57
63
|
animal
|
|
58
64
|
end
|
|
65
|
+
|
|
59
66
|
end
|
|
60
67
|
|
data/spec.md
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
Specifications for the CLI Assessment
|
|
2
|
-
|
|
3
1
|
Specs:
|
|
4
2
|
|
|
5
3
|
[X] Have a CLI for interfacing with the application
|
|
@@ -10,8 +8,8 @@ Specs:
|
|
|
10
8
|
4) Inputting a number from the list to access more details about that animal,
|
|
11
9
|
5) Using the menu options to view the list again, view detailed info on another animal, or exit
|
|
12
10
|
[X] Pull data from an external source
|
|
13
|
-
|
|
11
|
+
Pull data from ASPCA site based on dog v. cat input & zip code input. Pull from index/search page and from detailed page specific to each animal.
|
|
14
12
|
[X] Implement both list and detail views
|
|
15
13
|
List view displays basic info about animals available for adoption (name, breed, age, gender).
|
|
16
14
|
Detail view displays list of additional facts, and contact info (name, address, phone, email) for organization people can connect with to adopt that pet.
|
|
17
|
-
Additional option to pull in detailed paragraphs about animal. Commented out in scraper
|
|
15
|
+
Additional option to pull in detailed paragraphs about animal. Commented out in scraper as it's likely too much info for terminal view. Can comment back in to view.
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: pets_seeking_people
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.3.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Autumn J
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2018-
|
|
11
|
+
date: 2018-02-07 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: bundler
|