meeting_finder 0.0.2
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 +17 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +43 -0
- data/Rakefile +1 -0
- data/lib/meeting_finder/meeting.rb +15 -0
- data/lib/meeting_finder/search.rb +67 -0
- data/lib/meeting_finder/version.rb +3 -0
- data/lib/meeting_finder.rb +6 -0
- data/meeting_finder.gemspec +30 -0
- data/spec/meeting_finder_spec.rb +31 -0
- data/spec/spec_helper.rb +13 -0
- data/spec/vcr/find_by.yml +3663 -0
- data/spec/vcr/find_by_zip.yml +4884 -0
- data/spec/vcr/find_lat_long.yml +115 -0
- metadata +181 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: ae94dceb46151f1ec032fd6a57d230702e9734a8
|
4
|
+
data.tar.gz: 990b621724e2c13760e3ccaf6995a41e5bd0e6fa
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: ca2f98a43ec5dd913eff90e2643f3bfedebcf96757dcd36ce51d6ce4cb4da8b3bcd73b7969b87d6bac5a9ad126573b7d000e6ab85b106181630774d2fc5a9564
|
7
|
+
data.tar.gz: 5285709939c550d20d766e1704efeaa48130fcdf9d2996543e7f3ba9adacfa362f582540589811923717166625451ae843f453a50228cfda173131c8554b7447
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 Ben Lewis
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,43 @@
|
|
1
|
+
# MeetingFinder
|
2
|
+
|
3
|
+
Gem to assist in searching for AA meetings at intherooms.com
|
4
|
+
|
5
|
+
## Methods
|
6
|
+
|
7
|
+
Find meetings by name, location, address, day, time, fellowship, latitude, longitude
|
8
|
+
MeetingFinder::Search.find_by takes a search hash with those attributes as keys and the search strings as values.
|
9
|
+
|
10
|
+
For example:
|
11
|
+
|
12
|
+
```ruby
|
13
|
+
MeetingFinder::Search.find_by({"latitude" => 39.7316982, "longitude" => -104.9213643})
|
14
|
+
```
|
15
|
+
|
16
|
+
This gives back a MeetingFinder::Meeting object, from which you can access the various attributes using the following methods:
|
17
|
+
name, location, address, day, time, fellowship, lat, lng
|
18
|
+
|
19
|
+
## Installation
|
20
|
+
|
21
|
+
Add this line to your application's Gemfile:
|
22
|
+
|
23
|
+
gem 'meeting_finder'
|
24
|
+
|
25
|
+
And then execute:
|
26
|
+
|
27
|
+
$ bundle
|
28
|
+
|
29
|
+
Or install it yourself as:
|
30
|
+
|
31
|
+
$ gem install meeting_finder
|
32
|
+
|
33
|
+
## Usage
|
34
|
+
|
35
|
+
TODO: Write usage instructions here
|
36
|
+
|
37
|
+
## Contributing
|
38
|
+
|
39
|
+
1. Fork it
|
40
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
41
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
42
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
43
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module MeetingFinder
|
2
|
+
class Meeting
|
3
|
+
attr_reader :name, :location, :address, :day, :time, :fellowship, :lat, :lng
|
4
|
+
def initialize(attributes={})
|
5
|
+
@name = attributes['name']
|
6
|
+
@location = attributes['location']
|
7
|
+
@address = attributes['address']
|
8
|
+
@day = attributes['day']
|
9
|
+
@time = attributes['time']
|
10
|
+
@fellowship = attributes['fellowship']
|
11
|
+
@lat = attributes['lat']
|
12
|
+
@lng = attributes['lng']
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,67 @@
|
|
1
|
+
require 'nokogiri'
|
2
|
+
require 'open-uri'
|
3
|
+
require 'geocoder'
|
4
|
+
|
5
|
+
module MeetingFinder
|
6
|
+
class Search
|
7
|
+
class << self
|
8
|
+
|
9
|
+
def find_by(values={})
|
10
|
+
search_string = values.map do |parameter, value|
|
11
|
+
"&#{parameter}=#{value}"
|
12
|
+
end.join
|
13
|
+
response = Nokogiri::HTML(open(search_url + search_string))
|
14
|
+
meetings = []
|
15
|
+
response.css('.all-meetings tr').each_with_object({}) do |meeting, attributes|
|
16
|
+
attributes['name'] = meeting.children[0].text
|
17
|
+
attributes['location'] = meeting.children[2].text
|
18
|
+
attributes['address'] = meeting.children[4].text
|
19
|
+
attributes['day'] = meeting.children[6].text
|
20
|
+
attributes['time'] = meeting.children[8].text
|
21
|
+
attributes['fellowship'] = meeting.children[10].text
|
22
|
+
attributes['lat'], attributes['lng'] = find_lat_long_from(attributes['address'])
|
23
|
+
meetings << MeetingFinder::Meeting.new(attributes)
|
24
|
+
end
|
25
|
+
meetings.shift
|
26
|
+
meetings
|
27
|
+
end
|
28
|
+
|
29
|
+
def find_lat_long_from(address)
|
30
|
+
result = Geocoder.search(address)
|
31
|
+
location = result.first.data["geometry"]["location"]
|
32
|
+
lat, lng = location["lat"], location["lng"]
|
33
|
+
[lat, lng]
|
34
|
+
end
|
35
|
+
|
36
|
+
def by_lat_lng(lat, lng)
|
37
|
+
find_by({ "latitude" => lat, "longitude" => lng })
|
38
|
+
end
|
39
|
+
|
40
|
+
def by_zip(zip)
|
41
|
+
find_by({ "zip" => zip })
|
42
|
+
end
|
43
|
+
|
44
|
+
def search_url
|
45
|
+
'http://meetings.intherooms.com/meetings/search?search=&proximity=10'
|
46
|
+
end
|
47
|
+
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
# http://meetings.intherooms.com/meetings/search?search=
|
53
|
+
# &fellowship=AA
|
54
|
+
# &zip=80220
|
55
|
+
# &proximity=500
|
56
|
+
# &day=
|
57
|
+
# &start_hour=1
|
58
|
+
# &start_min=00
|
59
|
+
# &start_am_pm=AM
|
60
|
+
# &end_hour=1
|
61
|
+
# &end_min=00
|
62
|
+
# &end_am_pm=AM
|
63
|
+
# &latitude=39.7316982
|
64
|
+
# &longitude=-104.9213643
|
65
|
+
# &process=1
|
66
|
+
# &page_city=
|
67
|
+
# &page_state=
|
@@ -0,0 +1,30 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'meeting_finder/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "meeting_finder"
|
8
|
+
spec.version = MeetingFinder::VERSION
|
9
|
+
spec.authors = ["Ben Lewis", "Ben Horne", "Billy Griffin"]
|
10
|
+
spec.email = ["bennlewis@gmail.com", "benhorne44@gmail.com", "navyosu@gmail.com"]
|
11
|
+
spec.description = "Gem to assist in searching for AA meetings at intherooms.com"
|
12
|
+
spec.summary = "Find AA Meetings more easily!"
|
13
|
+
spec.homepage = ""
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files`.split($/)
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_development_dependency "bundler", "~> 1.3"
|
22
|
+
spec.add_development_dependency "rake"
|
23
|
+
spec.add_development_dependency "vcr"
|
24
|
+
spec.add_development_dependency "webmock"
|
25
|
+
spec.add_development_dependency "rspec"
|
26
|
+
|
27
|
+
spec.add_runtime_dependency "faraday"
|
28
|
+
spec.add_runtime_dependency "nokogiri"
|
29
|
+
spec.add_runtime_dependency "geocoder"
|
30
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
require './spec/spec_helper'
|
2
|
+
|
3
|
+
describe MeetingFinder::Search do
|
4
|
+
|
5
|
+
it "should find by with valid params" do
|
6
|
+
VCR.use_cassette('find_by') do
|
7
|
+
result = MeetingFinder::Search.find_by({"latitude" => 39.7316982, "longitude" => -104.9213643})
|
8
|
+
first_meeting = result.first
|
9
|
+
expect(first_meeting.name).to eq('Church')
|
10
|
+
expect(first_meeting.lat).to eq(39.7338507)
|
11
|
+
expect(first_meeting.lng).to eq(-104.9524757)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
it "should find by zip" do
|
16
|
+
VCR.use_cassette('find_by_zip') do
|
17
|
+
result = MeetingFinder::Search.by_zip(80203)
|
18
|
+
first_meeting = result.first
|
19
|
+
expect(first_meeting.name).to eq('Recovery Spoken Here AFG')
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
it 'should be able to find lat and long' do
|
24
|
+
VCR.use_cassette('find_lat_long') do
|
25
|
+
result = MeetingFinder::Search.find_lat_long_from("1100 Fillmore StreetDenver, CO 80206-3334")
|
26
|
+
expect(result).to eq([39.7338507, -104.9524757])
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
|
31
|
+
end
|
data/spec/spec_helper.rb
ADDED