pets_seeking_people 0.1.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 +7 -0
- data/.gitignore +11 -0
- data/.rspec +3 -0
- data/.travis.yml +5 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +6 -0
- data/Gemfile.lock +45 -0
- data/LICENSE.txt +21 -0
- data/README.md +45 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/pets_seeking_people +7 -0
- data/bin/setup +8 -0
- data/lib/pets_seeking_people.rb +9 -0
- data/lib/pets_seeking_people/cli.rb +126 -0
- data/lib/pets_seeking_people/pets.rb +28 -0
- data/lib/pets_seeking_people/scraper.rb +60 -0
- data/lib/pets_seeking_people/version.rb +3 -0
- data/pets_seeking_people.gemspec +37 -0
- data/spec.md +7 -0
- metadata +134 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: dab67e9dcaed53675bcb3cc18190dfacbfe2b90098b15fbadd07796c01dfc17c
|
|
4
|
+
data.tar.gz: c3cc73b0a24bd8540e4f0742d2cd014b5d80f40df8c2a0b5b76cb255c9a068bf
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: bccdf64e4cd5780505c2245745522ccc22f2391034376e147a9c01f79d2d4bf7a866b44931c1572c20153ede0e1ce0176ea38396671c28facb61de06f3bbb47d
|
|
7
|
+
data.tar.gz: 91569bbf53f7e8bafcad3495601a21e7fd22d0ef5da6f8d48c2de294d5f8008c72bb10bac6541f88156e20c9191d42d6a7eb9ceca237138fd7d39a5f832d37e4
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
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 autumnkangas@gmail.com. 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,45 @@
|
|
|
1
|
+
PATH
|
|
2
|
+
remote: .
|
|
3
|
+
specs:
|
|
4
|
+
pets_seeking_people (0.1.0)
|
|
5
|
+
nokogiri
|
|
6
|
+
|
|
7
|
+
GEM
|
|
8
|
+
remote: https://rubygems.org/
|
|
9
|
+
specs:
|
|
10
|
+
coderay (1.1.2)
|
|
11
|
+
diff-lcs (1.3)
|
|
12
|
+
method_source (0.9.0)
|
|
13
|
+
mini_portile2 (2.3.0)
|
|
14
|
+
nokogiri (1.8.1)
|
|
15
|
+
mini_portile2 (~> 2.3.0)
|
|
16
|
+
pry (0.11.3)
|
|
17
|
+
coderay (~> 1.1.0)
|
|
18
|
+
method_source (~> 0.9.0)
|
|
19
|
+
rake (10.5.0)
|
|
20
|
+
rspec (3.7.0)
|
|
21
|
+
rspec-core (~> 3.7.0)
|
|
22
|
+
rspec-expectations (~> 3.7.0)
|
|
23
|
+
rspec-mocks (~> 3.7.0)
|
|
24
|
+
rspec-core (3.7.1)
|
|
25
|
+
rspec-support (~> 3.7.0)
|
|
26
|
+
rspec-expectations (3.7.0)
|
|
27
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
|
28
|
+
rspec-support (~> 3.7.0)
|
|
29
|
+
rspec-mocks (3.7.0)
|
|
30
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
|
31
|
+
rspec-support (~> 3.7.0)
|
|
32
|
+
rspec-support (3.7.0)
|
|
33
|
+
|
|
34
|
+
PLATFORMS
|
|
35
|
+
ruby
|
|
36
|
+
|
|
37
|
+
DEPENDENCIES
|
|
38
|
+
bundler (~> 1.16)
|
|
39
|
+
pets_seeking_people!
|
|
40
|
+
pry
|
|
41
|
+
rake (~> 10.0)
|
|
42
|
+
rspec (~> 3.0)
|
|
43
|
+
|
|
44
|
+
BUNDLED WITH
|
|
45
|
+
1.16.1
|
data/LICENSE.txt
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2018 Autumn J
|
|
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
|
+
# PetsSeekingPeople
|
|
2
|
+
|
|
3
|
+
## A CLI Gem to Locate Adoptable Dogs & Cats in Your Area!
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
Add this line to your application's Gemfile:
|
|
8
|
+
|
|
9
|
+
```ruby
|
|
10
|
+
gem 'pets_seeking_people'
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
And then execute:
|
|
14
|
+
|
|
15
|
+
$ bundle
|
|
16
|
+
|
|
17
|
+
Or install it yourself as:
|
|
18
|
+
|
|
19
|
+
$ gem install pets_seeking_people
|
|
20
|
+
|
|
21
|
+
## Usage
|
|
22
|
+
|
|
23
|
+
Once installed, execute:
|
|
24
|
+
|
|
25
|
+
$ pets_seeking_people
|
|
26
|
+
|
|
27
|
+
When prompted, enter:
|
|
28
|
+
1) The type of pet you're searching for (dog or cat -- the adoption of other pets is always supported, just not by this gem)
|
|
29
|
+
2) Your zip code
|
|
30
|
+
|
|
31
|
+
After some computer magic occurs, view 24 pets available for adoption in the given zip code! Follow the menu prompts to learn more about each pet, and obtain contact info for the organization you can connect with to adopt them.
|
|
32
|
+
|
|
33
|
+
Adopt away!
|
|
34
|
+
|
|
35
|
+
## Contributing
|
|
36
|
+
|
|
37
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/AutumnJ/pets_seeking_people. 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 PetsSeekingPeople project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/AutumnJ/pets_seeking_people/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 "pets_seeking_people"
|
|
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/setup
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
# environment dependencies
|
|
2
|
+
require "open-uri"
|
|
3
|
+
require "nokogiri"
|
|
4
|
+
require "pry"
|
|
5
|
+
|
|
6
|
+
require_relative "./pets_seeking_people/version"
|
|
7
|
+
require_relative "./pets_seeking_people/cli"
|
|
8
|
+
require_relative "./pets_seeking_people/scraper"
|
|
9
|
+
require_relative "./pets_seeking_people/pets"
|
|
@@ -0,0 +1,126 @@
|
|
|
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
|
+
class PetsSeekingPeople::CLI
|
|
6
|
+
|
|
7
|
+
attr_accessor :pet_input, :zip_input
|
|
8
|
+
|
|
9
|
+
def call
|
|
10
|
+
puts "Welcome to pets seeking people!"
|
|
11
|
+
pet_type
|
|
12
|
+
zip
|
|
13
|
+
find_available_pets
|
|
14
|
+
if PetsSeekingPeople::Pets.all == []
|
|
15
|
+
puts ""
|
|
16
|
+
puts "Sad day for you - there are no pets in your area up for adoption. You adopted them all!"
|
|
17
|
+
farewell
|
|
18
|
+
else
|
|
19
|
+
list_pets
|
|
20
|
+
menu
|
|
21
|
+
farewell
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def pet_type
|
|
26
|
+
puts "If you're looking for a dog, type 'dog'. If you're looking for a cat, type 'cat'."
|
|
27
|
+
@pet_input = gets.strip.downcase
|
|
28
|
+
if !valid_pet_input?(pet_input)
|
|
29
|
+
puts ""
|
|
30
|
+
puts "While that's a lovely animal (or a typo), it's not an option."
|
|
31
|
+
self.pet_type
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
def zip
|
|
36
|
+
puts "What is your zip code?"
|
|
37
|
+
@zip_input = gets.strip
|
|
38
|
+
if !valid_zip_code?(zip_input)
|
|
39
|
+
puts ""
|
|
40
|
+
puts "Oops, not a valid zip!"
|
|
41
|
+
self.zip
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
def valid_pet_input?(pet_input)
|
|
46
|
+
pet_input == "cat" || pet_input == "dog"
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
def valid_zip_code?(zip_input)
|
|
50
|
+
/\A\d+\z/.match(zip_input) && zip_input.size == 5
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
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)
|
|
56
|
+
PetsSeekingPeople::Pets.create_from_collection(animals_array)
|
|
57
|
+
end
|
|
58
|
+
|
|
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)
|
|
64
|
+
end
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
def list_pets
|
|
68
|
+
puts ""
|
|
69
|
+
puts "---------- These pets are available for adoption in your area: ----------"
|
|
70
|
+
puts ""
|
|
71
|
+
PetsSeekingPeople::Pets.all.each.with_index(1) do |pet, i|
|
|
72
|
+
puts "#{i}. #{pet.name} - #{pet.breed} - #{pet.age} - #{pet.gender}"
|
|
73
|
+
end
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
def list_details(pet_number)
|
|
77
|
+
add_info_about_pet(pet_number)
|
|
78
|
+
pet = PetsSeekingPeople::Pets.all[pet_number]
|
|
79
|
+
puts ""
|
|
80
|
+
puts "------------------- Here's info on #{pet.name}: ---------------------"
|
|
81
|
+
puts ""
|
|
82
|
+
puts "Some deets you should know:"
|
|
83
|
+
pet.info.each {|pet_fact| puts "#{pet_fact}"}
|
|
84
|
+
puts ""
|
|
85
|
+
puts "--------------------------------------------------------------------------"
|
|
86
|
+
puts ""
|
|
87
|
+
puts "If you want to adopt #{pet.name}, contact: #{pet.adoption_contact}"
|
|
88
|
+
puts ""
|
|
89
|
+
puts "--------------------------------------------------------------------------"
|
|
90
|
+
puts ""
|
|
91
|
+
puts "For more details on #{pet.name}, go to: #{pet.adoption_website}"
|
|
92
|
+
end
|
|
93
|
+
|
|
94
|
+
def menu
|
|
95
|
+
input = nil
|
|
96
|
+
if input == "exit"
|
|
97
|
+
farewell
|
|
98
|
+
else
|
|
99
|
+
while input != 'exit'
|
|
100
|
+
puts ""
|
|
101
|
+
puts "---------------------------------- Menu ----------------------------------"
|
|
102
|
+
puts "Enter the number of the pet you'd like more info."
|
|
103
|
+
puts "Or type 'list' to see the list of available pets again."
|
|
104
|
+
puts "Or type 'exit' to exit."
|
|
105
|
+
puts "--------------------------------------------------------------------------"
|
|
106
|
+
puts ""
|
|
107
|
+
input = gets.strip.downcase
|
|
108
|
+
|
|
109
|
+
if input.to_i > 0 && input.to_i <= 24
|
|
110
|
+
pet_number = input.to_i-1
|
|
111
|
+
list_details(pet_number)
|
|
112
|
+
elsif input == "list"
|
|
113
|
+
list_pets
|
|
114
|
+
end
|
|
115
|
+
end
|
|
116
|
+
end
|
|
117
|
+
end
|
|
118
|
+
|
|
119
|
+
def farewell
|
|
120
|
+
puts ""
|
|
121
|
+
puts "Thanks for considering giving a lovely pet a home! Visit again soon."
|
|
122
|
+
puts " ▼・ᴥ・▼ "
|
|
123
|
+
puts ""
|
|
124
|
+
end
|
|
125
|
+
|
|
126
|
+
end
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
class PetsSeekingPeople::Pets
|
|
2
|
+
|
|
3
|
+
attr_accessor :name, :breed, :age, :gender, :animal_url, :info, :detailed_info, :adoption_contact, :adoption_website
|
|
4
|
+
|
|
5
|
+
@@all = []
|
|
6
|
+
|
|
7
|
+
def initialize(animal_hash)
|
|
8
|
+
animal_hash.each {|key, value| self.send(("#{key}="), value)}
|
|
9
|
+
@@all << self
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def self.create_from_collection(animals_array)
|
|
13
|
+
animals_array.each do |animal|
|
|
14
|
+
PetsSeekingPeople::Pets.new(animal)
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def add_animal_attributes(attributes_hash)
|
|
19
|
+
attributes_hash.each {|key, value| self.send(("#{key}="), value)}
|
|
20
|
+
self
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def self.all
|
|
24
|
+
@@all
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
end
|
|
28
|
+
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
class PetsSeekingPeople::Scraper
|
|
2
|
+
|
|
3
|
+
def self.scrape_index_page(index_url, pet_type_input)
|
|
4
|
+
doc = Nokogiri::HTML(open(index_url))
|
|
5
|
+
animals = []
|
|
6
|
+
|
|
7
|
+
doc.xpath("//td[@class='rgtkSearchResultsCell']").each do |animal|
|
|
8
|
+
animal_ID = animal.xpath(".//div[@class='rgtkSearchPetName']/a/@onclick").text.split(",")[1]
|
|
9
|
+
animals << {
|
|
10
|
+
:name => animal.xpath(".//div[@class='rgtkSearchPetName']/a").text,
|
|
11
|
+
:breed => animal.xpath(".//div[@class='rgtkSearchPetBreed']").text,
|
|
12
|
+
:age => animal.xpath(".//div[@class='rgtkSearchPetBasicInfo']").text.split(" ")[0],
|
|
13
|
+
:gender => animal.xpath(".//div[@class='rgtkSearchPetBasicInfo']").text.split(" ")[1],
|
|
14
|
+
:animal_url => "https://toolkit.rescuegroups.org/j/3/pet1_layout.php?toolkitIndex=0&toolkitKey=#{pet_type_input}&animalID=#{animal_ID.strip}"
|
|
15
|
+
}
|
|
16
|
+
end
|
|
17
|
+
animals
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def self.scrape_animal_page(animal_url)
|
|
21
|
+
profile_doc = Nokogiri::HTML(open(animal_url))
|
|
22
|
+
animal = {}
|
|
23
|
+
|
|
24
|
+
about_animal_array = []
|
|
25
|
+
profile_doc.xpath("//*[@id='rgtkPetInfoIndented_0']/li").each do |li|
|
|
26
|
+
about_animal_array << li.text
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
# ------Aesthetically, this is a lot of info to display in the terminal-----
|
|
30
|
+
# detailed_info = []
|
|
31
|
+
# profile_doc.xpath("//*[@id='rgtkPetFieldDescription_0']/div[1]/p"). each do |paragraph|
|
|
32
|
+
# detailed_info << paragraph.text
|
|
33
|
+
# end
|
|
34
|
+
# detailed_info.delete_if {|paragraph| paragraph == " "}
|
|
35
|
+
|
|
36
|
+
adoption_contact =[]
|
|
37
|
+
adoption_contact << "Organization name: #{profile_doc.xpath("//*[@id='rgtkPetFieldOrgName_0']").text}" #org name
|
|
38
|
+
|
|
39
|
+
adoption_address = []
|
|
40
|
+
if profile_doc.xpath("//*[@id='rgtkPetFieldOrgAddress_0']").text.size > 3
|
|
41
|
+
adoption_address << "Address: #{profile_doc.xpath("//*[@id='rgtkPetFieldOrgAddress_0']").text}"
|
|
42
|
+
end
|
|
43
|
+
if profile_doc.xpath("//*[@id='rgtkPetFieldOrgCitystatezip_0']").text.size > 3
|
|
44
|
+
adoption_address << "#{profile_doc.xpath("//*[@id='rgtkPetFieldOrgCitystatezip_0']").text}" #org address
|
|
45
|
+
end
|
|
46
|
+
adoption_contact << adoption_address.join(", ")
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
if profile_doc.xpath("//*[@id='rgtkPetFieldOrgPhone_0']").text.size > 3
|
|
50
|
+
adoption_contact << "Phone: #{profile_doc.xpath("//*[@id='rgtkPetFieldOrgPhone_0']").text}" #org phone
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
animal[:info] = about_animal_array
|
|
54
|
+
#animal[:detailed_info] = detailed_info
|
|
55
|
+
animal[:adoption_contact] = adoption_contact.join("; ")
|
|
56
|
+
animal[:adoption_website] = profile_doc.xpath("//*[@id='rgtkPetFieldOrgUrl_0']/a").text #org website
|
|
57
|
+
animal
|
|
58
|
+
end
|
|
59
|
+
end
|
|
60
|
+
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
|
|
2
|
+
lib = File.expand_path("../lib", __FILE__)
|
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
|
+
require "pets_seeking_people/version"
|
|
5
|
+
|
|
6
|
+
Gem::Specification.new do |spec|
|
|
7
|
+
spec.name = "pets_seeking_people"
|
|
8
|
+
spec.version = PetsSeekingPeople::VERSION
|
|
9
|
+
spec.authors = ["Autumn J"]
|
|
10
|
+
spec.email = ["autumnkangas@gmail.com"]
|
|
11
|
+
|
|
12
|
+
spec.summary = %q{An awesome scraper gem that helps users locate cats and dogs available for adoption in their area.}
|
|
13
|
+
spec.homepage = "https://github.com/AutumnJ/AutumnJ-cli-app"
|
|
14
|
+
spec.license = "MIT"
|
|
15
|
+
|
|
16
|
+
# # Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
|
|
17
|
+
# # to allow pushing to a single host or delete this section to allow pushing to any host.
|
|
18
|
+
# if spec.respond_to?(:metadata)
|
|
19
|
+
# spec.metadata["allowed_push_host"] = "TODO: Set to 'http://mygemserver.com'"
|
|
20
|
+
# else
|
|
21
|
+
# raise "RubyGems 2.0 or newer is required to protect against " \
|
|
22
|
+
# "public gem pushes."
|
|
23
|
+
# end
|
|
24
|
+
|
|
25
|
+
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
|
26
|
+
f.match(%r{^(test|spec|features)/})
|
|
27
|
+
end
|
|
28
|
+
spec.bindir = "exe"
|
|
29
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
|
30
|
+
spec.require_paths = ["lib"]
|
|
31
|
+
|
|
32
|
+
spec.add_development_dependency "bundler", "~> 1.16"
|
|
33
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
|
34
|
+
spec.add_development_dependency "rspec", "~> 3.0"
|
|
35
|
+
spec.add_development_dependency "pry"
|
|
36
|
+
spec.add_dependency "nokogiri"
|
|
37
|
+
end
|
data/spec.md
ADDED
metadata
ADDED
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: pets_seeking_people
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.1.0
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Autumn J
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: exe
|
|
10
|
+
cert_chain: []
|
|
11
|
+
date: 2018-01-30 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.16'
|
|
20
|
+
type: :development
|
|
21
|
+
prerelease: false
|
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
23
|
+
requirements:
|
|
24
|
+
- - "~>"
|
|
25
|
+
- !ruby/object:Gem::Version
|
|
26
|
+
version: '1.16'
|
|
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: rspec
|
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
|
44
|
+
requirements:
|
|
45
|
+
- - "~>"
|
|
46
|
+
- !ruby/object:Gem::Version
|
|
47
|
+
version: '3.0'
|
|
48
|
+
type: :development
|
|
49
|
+
prerelease: false
|
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
51
|
+
requirements:
|
|
52
|
+
- - "~>"
|
|
53
|
+
- !ruby/object:Gem::Version
|
|
54
|
+
version: '3.0'
|
|
55
|
+
- !ruby/object:Gem::Dependency
|
|
56
|
+
name: pry
|
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
|
58
|
+
requirements:
|
|
59
|
+
- - ">="
|
|
60
|
+
- !ruby/object:Gem::Version
|
|
61
|
+
version: '0'
|
|
62
|
+
type: :development
|
|
63
|
+
prerelease: false
|
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
65
|
+
requirements:
|
|
66
|
+
- - ">="
|
|
67
|
+
- !ruby/object:Gem::Version
|
|
68
|
+
version: '0'
|
|
69
|
+
- !ruby/object:Gem::Dependency
|
|
70
|
+
name: nokogiri
|
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
|
72
|
+
requirements:
|
|
73
|
+
- - ">="
|
|
74
|
+
- !ruby/object:Gem::Version
|
|
75
|
+
version: '0'
|
|
76
|
+
type: :runtime
|
|
77
|
+
prerelease: false
|
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
79
|
+
requirements:
|
|
80
|
+
- - ">="
|
|
81
|
+
- !ruby/object:Gem::Version
|
|
82
|
+
version: '0'
|
|
83
|
+
description:
|
|
84
|
+
email:
|
|
85
|
+
- autumnkangas@gmail.com
|
|
86
|
+
executables: []
|
|
87
|
+
extensions: []
|
|
88
|
+
extra_rdoc_files: []
|
|
89
|
+
files:
|
|
90
|
+
- ".gitignore"
|
|
91
|
+
- ".rspec"
|
|
92
|
+
- ".travis.yml"
|
|
93
|
+
- CODE_OF_CONDUCT.md
|
|
94
|
+
- Gemfile
|
|
95
|
+
- Gemfile.lock
|
|
96
|
+
- LICENSE.txt
|
|
97
|
+
- README.md
|
|
98
|
+
- Rakefile
|
|
99
|
+
- bin/console
|
|
100
|
+
- bin/pets_seeking_people
|
|
101
|
+
- bin/setup
|
|
102
|
+
- lib/pets_seeking_people.rb
|
|
103
|
+
- lib/pets_seeking_people/cli.rb
|
|
104
|
+
- lib/pets_seeking_people/pets.rb
|
|
105
|
+
- lib/pets_seeking_people/scraper.rb
|
|
106
|
+
- lib/pets_seeking_people/version.rb
|
|
107
|
+
- pets_seeking_people.gemspec
|
|
108
|
+
- spec.md
|
|
109
|
+
homepage: https://github.com/AutumnJ/AutumnJ-cli-app
|
|
110
|
+
licenses:
|
|
111
|
+
- MIT
|
|
112
|
+
metadata: {}
|
|
113
|
+
post_install_message:
|
|
114
|
+
rdoc_options: []
|
|
115
|
+
require_paths:
|
|
116
|
+
- lib
|
|
117
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
118
|
+
requirements:
|
|
119
|
+
- - ">="
|
|
120
|
+
- !ruby/object:Gem::Version
|
|
121
|
+
version: '0'
|
|
122
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
123
|
+
requirements:
|
|
124
|
+
- - ">="
|
|
125
|
+
- !ruby/object:Gem::Version
|
|
126
|
+
version: '0'
|
|
127
|
+
requirements: []
|
|
128
|
+
rubyforge_project:
|
|
129
|
+
rubygems_version: 2.7.4
|
|
130
|
+
signing_key:
|
|
131
|
+
specification_version: 4
|
|
132
|
+
summary: An awesome scraper gem that helps users locate cats and dogs available for
|
|
133
|
+
adoption in their area.
|
|
134
|
+
test_files: []
|