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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 647f7ade4a1c9e592cf714b64c52e039ecc32a32a3d32b360dfcd1dabd5cb7e3
4
- data.tar.gz: 06ca761b7f436bf29d82622e7d7ed5a0bbdd22f598754f3c3f5aef0d82912760
3
+ metadata.gz: 66b99d7db1a44914d2ea092f42af2b249adb064523d39a71fc74fa7a563cba9e
4
+ data.tar.gz: 44cbbf3185528432de8618c1c50c5d6ee156c9b2e8a9388e99a940202d948002
5
5
  SHA512:
6
- metadata.gz: 2ee65b82ade99ebe5a33413606c663c345d31da41ea740c78c2c91e7a520fc346d0762290cce1dabb3737624c172c51ad930f79229b79c39b58b456be2f9097f
7
- data.tar.gz: 680cdf9b31b0b695b11fa9152ead5d670d8ab2dd962730e731f90ca516bc690e8e533e2fe3f20c10140ec4de53fe87c2605b9cc89d413ea161708cb678c8299e
6
+ metadata.gz: be5417bf4d1fc7c84df5402bac5ab730525c455fae5261f342d29a154870636205cfa4c97855de53bb12568dc2a2fad585bcfa8990d5f97e500dec7873be0f88
7
+ data.tar.gz: 7a3c57403c803b7f38fa632058da8b421a099fc98d123f20993e5b16a73e670ab4a320bc8edb948fe953450b26bd60520937daa468cb90a01db7683ca73018e5
data/Gemfile CHANGED
@@ -3,4 +3,4 @@ source "https://rubygems.org"
3
3
  git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
4
4
 
5
5
  # Specify your gem's dependencies in pets_seeking_people.gemspec
6
- gemspec
6
+ gemspec
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- pets_seeking_people (0.2.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.1)
14
+ nokogiri (1.8.2)
15
15
  mini_portile2 (~> 2.3.0)
16
16
  pry (0.11.3)
17
17
  coderay (~> 1.1.0)
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
3
  require "bundler/setup"
4
- require "pets_seeking_people"
4
+ require_relative "../lib/pets_seeking_people.rb"
5
5
 
6
6
 
7
7
  PetsSeekingPeople::CLI.new.call
@@ -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
- attr_accessor :pet_input, :zip_input
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
- pet_input == "cat" ? pet_type_input = "6REv6Spa" : pet_type_input = "zu8atrEs"
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(pet_number)
60
- search_pet = PetsSeekingPeople::Pets.all[pet_number]
61
- if !PetsSeekingPeople::Pets.all[pet_number].info
62
- info = PetsSeekingPeople::Scraper.scrape_animal_page(search_pet.animal_url)
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(pet_number)
77
- add_info_about_pet(pet_number)
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 #{pet.name}: ---------------------"
73
+ puts "------------------- Here's info on #{list_pet.name}: ---------------------"
81
74
  puts ""
82
75
  puts "Some deets you should know:"
83
- pet.info.each {|pet_fact| puts "#{pet_fact}"}
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 #{pet.name}, contact:"
88
- pet.adoption_contact.each {|contact| puts "#{contact}"}
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 #{pet.name}, go to: #{pet.adoption_website}"
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 <= 24
111
- pet_number = input.to_i-1
112
- list_details(pet_number)
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
- attr_accessor :name, :breed, :age, :gender, :animal_url, :info, :detailed_info, :adoption_contact, :adoption_website
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(index_url, pet_type_input)
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
 
@@ -1,3 +1,3 @@
1
1
  module PetsSeekingPeople
2
- VERSION = "0.2.0"
2
+ VERSION = "0.3.0"
3
3
  end
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
- 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.
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 & CLI as it's likely too much info for terminal view. Can comment back in to view.
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.2.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-01-30 00:00:00.000000000 Z
11
+ date: 2018-02-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler