closest_weightlifting_gem 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +9 -0
- data/.rspec +2 -0
- data/.travis.yml +4 -0
- data/Gemfile +5 -0
- data/LICENSE.txt +21 -0
- data/README.md +46 -0
- data/Rakefile +6 -0
- data/bin/closest-weightlifting-gem +5 -0
- data/bin/console +25 -0
- data/bin/setup +8 -0
- data/closest_weightlifting_gem-0.1.0.gem +0 -0
- data/closest_weightlifting_gem-0.1.1.gem +0 -0
- data/closest_weightlifting_gem.gemspec +38 -0
- data/lib/closest_weightlifting_gem.rb +11 -0
- data/lib/closest_weightlifting_gem/cli.rb +203 -0
- data/lib/closest_weightlifting_gem/geocoder.rb +3 -0
- data/lib/closest_weightlifting_gem/gym.rb +70 -0
- data/lib/closest_weightlifting_gem/scraper.rb +73 -0
- data/lib/closest_weightlifting_gem/version.rb +3 -0
- data/notes.md +37 -0
- metadata +163 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 786b4111c162920f2b4dabd1b55b3e67ba6a211c
|
4
|
+
data.tar.gz: 4501d815a84546ec4463c58184c63d26d17e6c74
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 67b2d1669bc805e84370a9ce7f9d381afb73dbfdfe83c589c2b312aab0c08ed3cf2e7ba4e9fba92f4b2e7aaf5c837bf0dd2dae0daa1903f8c6521e641198053b
|
7
|
+
data.tar.gz: 0b517cd6bdbcb91225f35f89ac523ee31834e2795d53422f3ca5115f7886560fcbe5cd6ceabd0d06c22522815d73cf23d0aed5860a16840dde8981814c86843d
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2016 zacscodingclub
|
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,46 @@
|
|
1
|
+
# ClosestWeightliftingGem
|
2
|
+
|
3
|
+
This application scrapes the [USA Weightlifting's Find a Club ](http://www.teamusa.org/usa-weightlifting/clubs-lwc/find-a-club) feature and builds a Gym object for each club, which includes some basic biographical information.
|
4
|
+
|
5
|
+
TODO:
|
6
|
+
---
|
7
|
+
* Implement proper options from CLI#show_gym
|
8
|
+
* show_gym page from #find_by_names menu should take it back to those search results instead of the state results
|
9
|
+
* Geocode gym addresses
|
10
|
+
* Implement user location input to find nearest gyms
|
11
|
+
|
12
|
+
## Installation
|
13
|
+
|
14
|
+
Add this line to your application's Gemfile:
|
15
|
+
|
16
|
+
```ruby
|
17
|
+
gem 'closest_weightlifting_gem'
|
18
|
+
```
|
19
|
+
|
20
|
+
And then execute:
|
21
|
+
|
22
|
+
$ bundle
|
23
|
+
|
24
|
+
Or install it yourself as:
|
25
|
+
|
26
|
+
$ gem install closest_weightlifting_gem
|
27
|
+
|
28
|
+
## Usage
|
29
|
+
|
30
|
+
|
31
|
+
|
32
|
+
## Development
|
33
|
+
|
34
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
35
|
+
|
36
|
+
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).
|
37
|
+
|
38
|
+
## Contributing
|
39
|
+
|
40
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/zacscodingclub/closest_weightlifting_gem.
|
41
|
+
|
42
|
+
|
43
|
+
## License
|
44
|
+
|
45
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
46
|
+
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "closest_weightlifting_gem"
|
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 'pry'
|
14
|
+
|
15
|
+
def reload!
|
16
|
+
load './lib/closest_weightlifting_gem.rb'
|
17
|
+
end
|
18
|
+
|
19
|
+
def basic_setup
|
20
|
+
["FL","IL","NY"].each do |state|
|
21
|
+
ClosestWeightliftingGem::Scraper.scrape_state_page(state)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
Pry.start
|
data/bin/setup
ADDED
Binary file
|
Binary file
|
@@ -0,0 +1,38 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'closest_weightlifting_gem/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "closest_weightlifting_gem"
|
8
|
+
spec.version = ClosestWeightliftingGem::VERSION
|
9
|
+
spec.authors = ["zacscodingclub"]
|
10
|
+
spec.email = ["zbaston@gmail.com"]
|
11
|
+
|
12
|
+
spec.summary = "USA Weighlifting Club Gyms"
|
13
|
+
spec.description = "This gem uses the data available on the USA Weightlifting website (http://www.teamusa.org/usa-weightlifting/clubs-lwc/find-a-club) to create a simple CLI interface with all the gyms."
|
14
|
+
spec.homepage = "http://rubygems.org/gems/closest_weightlifting_gem"
|
15
|
+
spec.license = "MIT"
|
16
|
+
|
17
|
+
# Prevent pushing this gem to RubyGems.org by setting 'allowed_push_host', or
|
18
|
+
# delete this section to allow pushing this gem to any host.
|
19
|
+
# if spec.respond_to?(:metadata)
|
20
|
+
# spec.metadata['allowed_push_host'] = "TODO: Set to 'http://mygemserver.com'"
|
21
|
+
# else
|
22
|
+
# raise "RubyGems 2.0 or newer is required to protect against public gem pushes."
|
23
|
+
# end
|
24
|
+
|
25
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
26
|
+
spec.bindir = "exe"
|
27
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
28
|
+
spec.require_paths = ["lib"]
|
29
|
+
|
30
|
+
spec.add_development_dependency "bundler", "~> 1.11"
|
31
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
32
|
+
spec.add_development_dependency "rspec", "~> 3.0"
|
33
|
+
spec.add_development_dependency "pry", "~> 0.10.3"
|
34
|
+
|
35
|
+
spec.add_dependency "nokogiri", "~> 1.6.7.2"
|
36
|
+
spec.add_dependency "require_all", "~> 1.3.3"
|
37
|
+
spec.add_dependency "titleize", "~> 1.4.0"
|
38
|
+
end
|
@@ -0,0 +1,203 @@
|
|
1
|
+
class ClosestWeightliftingGem::CLI
|
2
|
+
def call
|
3
|
+
load_gyms
|
4
|
+
|
5
|
+
main_menu
|
6
|
+
end
|
7
|
+
|
8
|
+
def load_gyms
|
9
|
+
puts <<-DOC.gsub /^\s*/, ''
|
10
|
+
Welcome to the Closest Weightlifting Gem!
|
11
|
+
Give me a few minutes to fetch a fresh data widget doohicky from the cloud nebula...
|
12
|
+
DOC
|
13
|
+
|
14
|
+
ClosestWeightliftingGem::Scraper.scrape_main
|
15
|
+
end
|
16
|
+
|
17
|
+
# Not implemented currently, but plan to introduce when I figure out geocoder
|
18
|
+
#
|
19
|
+
# def address_input
|
20
|
+
# puts <<-DOC.gsub /^\s*/, ''
|
21
|
+
# Please enter your address below and I'll find
|
22
|
+
# the closest weightlifting gym. (ex. 123 Main St. New York, NY)
|
23
|
+
# DOC
|
24
|
+
|
25
|
+
# address = gets.chomp
|
26
|
+
# end
|
27
|
+
|
28
|
+
def main_menu
|
29
|
+
puts "What do you want to do now?"
|
30
|
+
|
31
|
+
options(__method__)
|
32
|
+
end
|
33
|
+
|
34
|
+
def show_gyms(gyms)
|
35
|
+
width = 80
|
36
|
+
puts line
|
37
|
+
puts "OK, your search yielded #{gyms.size} gyms!\n"
|
38
|
+
puts "Here's the list: "
|
39
|
+
puts line
|
40
|
+
puts " Gym Name".ljust(width/2)+" City"
|
41
|
+
|
42
|
+
gyms.each_with_index do |gym, i|
|
43
|
+
puts "#{(i+1).to_s.rjust(3)}. #{gym.name.ljust(width/2)} #{gym.city}, #{gym.state}"
|
44
|
+
end
|
45
|
+
|
46
|
+
options(__method__, gyms)
|
47
|
+
end
|
48
|
+
|
49
|
+
def show_gym(gym)
|
50
|
+
ClosestWeightliftingGem::Scraper.scrape_attributes(gym) if !gym.coach
|
51
|
+
|
52
|
+
puts "Name: #{gym.name}"
|
53
|
+
puts "Address: #{gym.full_address}"
|
54
|
+
puts "Director: #{gym.director}"
|
55
|
+
puts "Coach: #{gym.coach}"
|
56
|
+
puts "Website: #{gym.website}"
|
57
|
+
|
58
|
+
options(__method__, gym)
|
59
|
+
end
|
60
|
+
|
61
|
+
def options(menu, data=nil)
|
62
|
+
menu = menu.to_s
|
63
|
+
|
64
|
+
case menu
|
65
|
+
when "main_menu"
|
66
|
+
puts line
|
67
|
+
puts <<-DOC.gsub(/^\s*/,'')
|
68
|
+
1. List By State Abbreviation (ex. AL, AK, CA, FL, IL, NY, etc.)
|
69
|
+
2. Search Club Names
|
70
|
+
3. Exit
|
71
|
+
DOC
|
72
|
+
|
73
|
+
process_main
|
74
|
+
when "show_gyms"
|
75
|
+
puts line
|
76
|
+
puts <<-DOC.gsub(/^\s*/,'')
|
77
|
+
1. Select Gym By Number
|
78
|
+
2. Replay List
|
79
|
+
3. Main menu
|
80
|
+
4. Exit
|
81
|
+
DOC
|
82
|
+
|
83
|
+
process_gyms(data)
|
84
|
+
when "show_gym"
|
85
|
+
puts line
|
86
|
+
puts <<-DOC.gsub(/^\s*/,'')
|
87
|
+
1. Open Website
|
88
|
+
2. Back to State Results
|
89
|
+
3. Main menu
|
90
|
+
4. Exit
|
91
|
+
DOC
|
92
|
+
|
93
|
+
process_gym(data)
|
94
|
+
else
|
95
|
+
puts "WTF"
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
99
|
+
def open_in_browser(gym)
|
100
|
+
if gym.website == "none"
|
101
|
+
puts "Sorry, that gym doesn't have a website. :("
|
102
|
+
elsif !gym.website.include?("http")
|
103
|
+
system("open", "http://#{gym.website}")
|
104
|
+
else
|
105
|
+
system("open", "#{gym.website}")
|
106
|
+
end
|
107
|
+
end
|
108
|
+
|
109
|
+
def process_main
|
110
|
+
input = nil
|
111
|
+
|
112
|
+
while input != "exit"
|
113
|
+
input = gets.strip.downcase
|
114
|
+
|
115
|
+
case input
|
116
|
+
when "1"
|
117
|
+
puts "Which state?"
|
118
|
+
state = gets.chomp.upcase
|
119
|
+
show_gyms(ClosestWeightliftingGem::Gym.find_by_state(state))
|
120
|
+
when "2"
|
121
|
+
puts "What do you want to search for?"
|
122
|
+
search_term = gets.chomp.upcase
|
123
|
+
show_gyms(ClosestWeightliftingGem::Gym.find_by_name(search_term))
|
124
|
+
when "3"
|
125
|
+
good_bye
|
126
|
+
|
127
|
+
exit
|
128
|
+
when "exit"
|
129
|
+
good_bye
|
130
|
+
|
131
|
+
exit
|
132
|
+
else
|
133
|
+
puts "I didn't understand that, please try again."
|
134
|
+
end
|
135
|
+
end
|
136
|
+
end
|
137
|
+
|
138
|
+
def process_gyms(gyms)
|
139
|
+
input = nil
|
140
|
+
|
141
|
+
until input == "exit"
|
142
|
+
input = gets.strip.downcase
|
143
|
+
case input
|
144
|
+
when "1"
|
145
|
+
puts "Select a gym by the number:"
|
146
|
+
gym_num = gets.chomp.to_i - 1
|
147
|
+
|
148
|
+
show_gym(gyms[gym_num])
|
149
|
+
when "2"
|
150
|
+
show_gyms(gyms)
|
151
|
+
when "3"
|
152
|
+
main_menu
|
153
|
+
when "4"
|
154
|
+
good_bye
|
155
|
+
|
156
|
+
exit
|
157
|
+
when "exit"
|
158
|
+
good_bye
|
159
|
+
|
160
|
+
exit
|
161
|
+
else
|
162
|
+
puts "I didn't understand that, please try again."
|
163
|
+
end
|
164
|
+
end
|
165
|
+
end
|
166
|
+
|
167
|
+
def process_gym(gym)
|
168
|
+
input = nil
|
169
|
+
|
170
|
+
until input == "exit"
|
171
|
+
input = gets.strip.downcase
|
172
|
+
case input
|
173
|
+
when "1"
|
174
|
+
open_in_browser(gym)
|
175
|
+
|
176
|
+
options("show_gym", gym)
|
177
|
+
when "2"
|
178
|
+
show_gyms(ClosestWeightliftingGem::Gym.find_by_state(gym.state))
|
179
|
+
when "3"
|
180
|
+
main_menu
|
181
|
+
when "4"
|
182
|
+
good_bye
|
183
|
+
|
184
|
+
exit
|
185
|
+
when "exit"
|
186
|
+
good_bye
|
187
|
+
|
188
|
+
exit
|
189
|
+
else
|
190
|
+
puts "I didn't understand that, please try again."
|
191
|
+
end
|
192
|
+
end
|
193
|
+
|
194
|
+
end
|
195
|
+
|
196
|
+
def line
|
197
|
+
"="*80
|
198
|
+
end
|
199
|
+
|
200
|
+
def good_bye
|
201
|
+
puts "Adios friend. Hope you come back to lift weights again!"
|
202
|
+
end
|
203
|
+
end
|
@@ -0,0 +1,70 @@
|
|
1
|
+
class ClosestWeightliftingGem::Gym
|
2
|
+
attr_accessor :name,
|
3
|
+
:full_address,
|
4
|
+
:street,
|
5
|
+
:city,
|
6
|
+
:state,
|
7
|
+
:zipcode,
|
8
|
+
:phone,
|
9
|
+
:director,
|
10
|
+
:coach,
|
11
|
+
:usaw_url,
|
12
|
+
:website
|
13
|
+
|
14
|
+
@@all = []
|
15
|
+
@@searches = []
|
16
|
+
|
17
|
+
def initialize(gym_attributes)
|
18
|
+
gym_attributes.each { |k,v| self.send(("#{k}="), v)}
|
19
|
+
|
20
|
+
@@all << self
|
21
|
+
end
|
22
|
+
|
23
|
+
def add_attributes(gym_attributes)
|
24
|
+
gym_attributes.each { |k,v| self.send(("#{k}="), v)}
|
25
|
+
end
|
26
|
+
|
27
|
+
def full_address
|
28
|
+
"#{street} #{city}, #{state} #{zipcode}"
|
29
|
+
end
|
30
|
+
|
31
|
+
def self.all
|
32
|
+
@@all
|
33
|
+
end
|
34
|
+
|
35
|
+
def self.last_search
|
36
|
+
@@searches.last
|
37
|
+
end
|
38
|
+
|
39
|
+
def self.searches
|
40
|
+
@@searches
|
41
|
+
end
|
42
|
+
|
43
|
+
def self.reset!
|
44
|
+
self.all.clear
|
45
|
+
end
|
46
|
+
|
47
|
+
def self.weird_gyms
|
48
|
+
self.all.find_all do |g|
|
49
|
+
g.phone == nil || g.street == nil || g.name == nil
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
def self.find_by_name(input)
|
54
|
+
self.searches << { method: __method__, value: input }
|
55
|
+
|
56
|
+
select_few = self.all.select do |gym|
|
57
|
+
gym.name.upcase.include?(input.upcase)
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
def self.find_by_state(state)
|
62
|
+
self.searches << { method: __method__, value: state }
|
63
|
+
|
64
|
+
self.all.find_all { |gym| gym.state == state.upcase }
|
65
|
+
end
|
66
|
+
|
67
|
+
def self.count_by_state
|
68
|
+
self.all.inject(Hash.new(0)) { |total, gym| total[gym.state] += 1 ; total }
|
69
|
+
end
|
70
|
+
end
|
@@ -0,0 +1,73 @@
|
|
1
|
+
class ClosestWeightliftingGem::Scraper
|
2
|
+
|
3
|
+
BASE_URL = "https://webpoint.usaweightlifting.org/wp15/Companies/"
|
4
|
+
|
5
|
+
def self.scrape_main
|
6
|
+
puts "Fetching index..."
|
7
|
+
index = Nokogiri::HTML(open("#{BASE_URL}/Clubs.wp?frm=t"))
|
8
|
+
|
9
|
+
get_state_abbreviations(index).each { |state| scrape_state_page(state) }
|
10
|
+
|
11
|
+
puts "\n\nSorry that took so long."
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.scrape_state_page(state)
|
15
|
+
puts "Fetching gym data in #{state}..."
|
16
|
+
state_doc = Nokogiri::HTML(open("#{BASE_URL}/Clubs.wp?frm=t&CompanyState=#{state}"))
|
17
|
+
|
18
|
+
# I want it to scrape each state page
|
19
|
+
# I want it to insantiate and save gym objects for each gym on the page
|
20
|
+
# This will just be basic info and I can set other data in the gym class
|
21
|
+
|
22
|
+
state_doc.search(".datarow").each do |gym_row|
|
23
|
+
|
24
|
+
if gym_row.search(".right+ .left").text.split(" ").size < 5
|
25
|
+
scrape_gym_page(gym_row)
|
26
|
+
else
|
27
|
+
ClosestWeightliftingGem::Gym.new({
|
28
|
+
:name => gym_row.search("a").first.children.text.titleize,
|
29
|
+
:street => gym_row.children[5].children[0].text,
|
30
|
+
:city => gym_row.children[5].children[2].text.split(",").first,
|
31
|
+
:state => state,
|
32
|
+
:zipcode => gym_row.children[5].children[2].text.split(/\W+/).last,
|
33
|
+
:phone => gym_row.children[5].children[4].text,
|
34
|
+
:usaw_url => gym_row.search("a").first.attr("onclick").match(/\/V.+true/)[0]
|
35
|
+
})
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
def self.scrape_gym_page(gym_row)
|
41
|
+
gym_doc = Nokogiri::HTML(open("#{BASE_URL + gym_row.search("a").first.attr("onclick").match(/\/V.+true/)[0]}"))
|
42
|
+
|
43
|
+
ClosestWeightliftingGem::Gym.new({
|
44
|
+
:name => gym_doc.search(".fe_vbig_row td").text.titleize,
|
45
|
+
:street => gym_doc.search(".fe_vbig_row+ .fe_big_row td").children.to_s.split("<br>")[0],
|
46
|
+
:city => gym_doc.search(".fe_vbig_row+ .fe_big_row td").children.to_s.split("<br>")[1].split(",")[0],
|
47
|
+
:state => gym_doc.search(".fe_vbig_row+ .fe_big_row td").children.to_s.split(",").last.split(/\W+/)[1],
|
48
|
+
:zipcode => gym_doc.search(".fe_vbig_row+ .fe_big_row td").children.to_s.split(/\W/).last,
|
49
|
+
:phone => gym_doc.search(".fe_big_row:nth-child(4) td").children.last.to_s[1..-1],
|
50
|
+
:director => gym_doc.search(".fe_big_row:nth-child(2) td+ td").text,
|
51
|
+
:coach => gym_doc.search(".fe_big_row+ .fe_big_row td+ td").text,
|
52
|
+
:website => gym_doc.text.split("site:")[1].split("\r").first[1..-1],
|
53
|
+
:usaw_url => gym_row.search("a").first.attr("onclick").match(/\/V.+true/)[0]
|
54
|
+
})
|
55
|
+
|
56
|
+
end
|
57
|
+
|
58
|
+
def self.scrape_attributes(gym)
|
59
|
+
gym_doc = Nokogiri::HTML(open("#{BASE_URL + gym.usaw_url}"))
|
60
|
+
|
61
|
+
gym.add_attributes({
|
62
|
+
:phone => gym_doc.search(".fe_big_row:nth-child(4) td").children.last.to_s[1..-1],
|
63
|
+
:director => gym_doc.search(".fe_big_row:nth-child(2) td+ td").text,
|
64
|
+
:coach => gym_doc.search(".fe_big_row+ .fe_big_row td+ td").text,
|
65
|
+
:website => gym_doc.text.split("site:")[1].split("\r").first[1..-1]
|
66
|
+
})
|
67
|
+
end
|
68
|
+
|
69
|
+
def self.get_state_abbreviations(index)
|
70
|
+
index.search("select").children.collect { |child| child.attr("value") }[2..-1]
|
71
|
+
end
|
72
|
+
|
73
|
+
end
|
data/notes.md
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
ToDo:
|
2
|
+
|
3
|
+
Update Gemspec ToDos
|
4
|
+
2. Start with project structure
|
5
|
+
3. Start with entry point - file run (bin/closest-weightlifting-gem)
|
6
|
+
4. Build to CLI interface
|
7
|
+
5. Stub out interface
|
8
|
+
6. Start makinig things real
|
9
|
+
7. Discover objects
|
10
|
+
8. Program
|
11
|
+
|
12
|
+
|
13
|
+
|
14
|
+
1. Plan Gem, imagine interface
|
15
|
+
bin/closest-weightlifting-gem
|
16
|
+
Print a greeting
|
17
|
+
Search By Address
|
18
|
+
<user input>
|
19
|
+
1. "Distance - Gym Name - Website - Phone - Email"
|
20
|
+
2. "Distance - Gym Name - Website - Phone - Email"
|
21
|
+
3. "Distance - Gym Name - Website - Phone - Email"
|
22
|
+
To find out more about a gym, enter the number on the left or
|
23
|
+
to search again, type 'search' ('exit' to leave)
|
24
|
+
go to gym page
|
25
|
+
open to web page or google maps
|
26
|
+
|
27
|
+
|
28
|
+
|
29
|
+
|
30
|
+
|
31
|
+
|
32
|
+
|
33
|
+
|
34
|
+
Basic URI for accessing each state's individual page
|
35
|
+
https://webpoint.usaweightlifting.org/wp15/Companies/Clubs.wp?frm=t&CompanyValue=#{state}
|
36
|
+
|
37
|
+
|
metadata
ADDED
@@ -0,0 +1,163 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: closest_weightlifting_gem
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.2
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- zacscodingclub
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-03-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: '1.11'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.11'
|
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.10.3
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: 0.10.3
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: nokogiri
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: 1.6.7.2
|
76
|
+
type: :runtime
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: 1.6.7.2
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: require_all
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: 1.3.3
|
90
|
+
type: :runtime
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: 1.3.3
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: titleize
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - "~>"
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: 1.4.0
|
104
|
+
type: :runtime
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - "~>"
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: 1.4.0
|
111
|
+
description: This gem uses the data available on the USA Weightlifting website (http://www.teamusa.org/usa-weightlifting/clubs-lwc/find-a-club)
|
112
|
+
to create a simple CLI interface with all the gyms.
|
113
|
+
email:
|
114
|
+
- zbaston@gmail.com
|
115
|
+
executables: []
|
116
|
+
extensions: []
|
117
|
+
extra_rdoc_files: []
|
118
|
+
files:
|
119
|
+
- ".gitignore"
|
120
|
+
- ".rspec"
|
121
|
+
- ".travis.yml"
|
122
|
+
- Gemfile
|
123
|
+
- LICENSE.txt
|
124
|
+
- README.md
|
125
|
+
- Rakefile
|
126
|
+
- bin/closest-weightlifting-gem
|
127
|
+
- bin/console
|
128
|
+
- bin/setup
|
129
|
+
- closest_weightlifting_gem-0.1.0.gem
|
130
|
+
- closest_weightlifting_gem-0.1.1.gem
|
131
|
+
- closest_weightlifting_gem.gemspec
|
132
|
+
- lib/closest_weightlifting_gem.rb
|
133
|
+
- lib/closest_weightlifting_gem/cli.rb
|
134
|
+
- lib/closest_weightlifting_gem/geocoder.rb
|
135
|
+
- lib/closest_weightlifting_gem/gym.rb
|
136
|
+
- lib/closest_weightlifting_gem/scraper.rb
|
137
|
+
- lib/closest_weightlifting_gem/version.rb
|
138
|
+
- notes.md
|
139
|
+
homepage: http://rubygems.org/gems/closest_weightlifting_gem
|
140
|
+
licenses:
|
141
|
+
- MIT
|
142
|
+
metadata: {}
|
143
|
+
post_install_message:
|
144
|
+
rdoc_options: []
|
145
|
+
require_paths:
|
146
|
+
- lib
|
147
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
148
|
+
requirements:
|
149
|
+
- - ">="
|
150
|
+
- !ruby/object:Gem::Version
|
151
|
+
version: '0'
|
152
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
153
|
+
requirements:
|
154
|
+
- - ">="
|
155
|
+
- !ruby/object:Gem::Version
|
156
|
+
version: '0'
|
157
|
+
requirements: []
|
158
|
+
rubyforge_project:
|
159
|
+
rubygems_version: 2.4.5.1
|
160
|
+
signing_key:
|
161
|
+
specification_version: 4
|
162
|
+
summary: USA Weighlifting Club Gyms
|
163
|
+
test_files: []
|