purlocation 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +17 -0
- data/.rspec +2 -0
- data/.travis.yml +6 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +51 -0
- data/Rakefile +6 -0
- data/lib/purlocation.rb +8 -0
- data/lib/purlocation/location.rb +31 -0
- data/lib/purlocation/version.rb +3 -0
- data/purlocation.gemspec +26 -0
- data/spec/purlocation_spec.rb +18 -0
- data/spec/spec_helper.rb +8 -0
- metadata +149 -0
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 Scott Opell
|
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,51 @@
|
|
1
|
+
# Purlocation
|
2
|
+
|
3
|
+
This gem will take a Purdue building abbreviation, such as "MTHW" and return a Location object with any and all available information. See usage below for a list of exactly what is available.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
gem 'purlocation'
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
$ gem install purlocation
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
Include the gem, then get a location object by like so `location = Purlocation.get_location "BRNG"`
|
22
|
+
Once you have the location object, you can call any of the following methods on it.
|
23
|
+
EX: `puts "BRNG has a full name of #{location.name}"`
|
24
|
+
|
25
|
+
```
|
26
|
+
name
|
27
|
+
abbreviation
|
28
|
+
lat
|
29
|
+
lng
|
30
|
+
image
|
31
|
+
streetaddress
|
32
|
+
citystatezip
|
33
|
+
phone
|
34
|
+
virtualtour
|
35
|
+
webpage
|
36
|
+
category
|
37
|
+
tourcategory
|
38
|
+
icontype
|
39
|
+
details
|
40
|
+
```
|
41
|
+
|
42
|
+
Its worth noting that the source of this information is used in an interactive map, hence the "virtualtour" and "icontype" fields.
|
43
|
+
|
44
|
+
|
45
|
+
## Contributing
|
46
|
+
|
47
|
+
1. Fork it ( http://github.com/<my-github-username>/purlocation/fork )
|
48
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
49
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
50
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
51
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
data/lib/purlocation.rb
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
require 'net/http'
|
2
|
+
require 'nori'
|
3
|
+
require 'pry'
|
4
|
+
|
5
|
+
class Location
|
6
|
+
attr_accessor :name, :abbr, :lat, :long, :street_address, :city, :state, :zip
|
7
|
+
MARKERS_URL = "http://www.purdue.edu/campus_map/xml/MarkersAll5.xml"
|
8
|
+
|
9
|
+
def self.markers_hash
|
10
|
+
@markers_hash ||= populate_markers
|
11
|
+
end
|
12
|
+
|
13
|
+
def self.populate_markers
|
14
|
+
xml_data = Net::HTTP.get_response(URI.parse(MARKERS_URL)).body
|
15
|
+
parser = Nori.new( :parser=> :rexml)
|
16
|
+
@markers_hash = parser.parse(xml_data)["markers"].first[1]
|
17
|
+
end
|
18
|
+
|
19
|
+
def initialize abbr
|
20
|
+
@me = self.class.markers_hash.select do |marker|
|
21
|
+
marker["@abbreviation"] == abbr
|
22
|
+
end.first
|
23
|
+
|
24
|
+
@me.keys.each do |k|
|
25
|
+
meth = k[1..-1]
|
26
|
+
self.class.send( :define_method, meth ) do
|
27
|
+
return @me["@#{meth}"]
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
data/purlocation.gemspec
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'purlocation/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "purlocation"
|
8
|
+
spec.version = Purlocation::VERSION
|
9
|
+
spec.authors = ["Scott Opell"]
|
10
|
+
spec.email = ["me@scottopell.com"]
|
11
|
+
spec.summary = %q{Translates a Purdue building code to a location}
|
12
|
+
spec.description = %q{Example: BRNG => Beering Hall}
|
13
|
+
spec.homepage = ""
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0")
|
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.5"
|
22
|
+
spec.add_development_dependency "rake"
|
23
|
+
spec.add_development_dependency "rspec"
|
24
|
+
spec.add_development_dependency "pry"
|
25
|
+
spec.add_dependency "nori"
|
26
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Purlocation do
|
4
|
+
it "gets Beering's full name" do
|
5
|
+
location = Purlocation.get_location "BRNG"
|
6
|
+
location.name.should eq("Beering Hall of Liberal Arts and Education")
|
7
|
+
end
|
8
|
+
|
9
|
+
it "gets the street address of mathews hall" do
|
10
|
+
location = Purlocation.get_location "MTHW"
|
11
|
+
location.streetaddress.should eq("812 W. State Street")
|
12
|
+
end
|
13
|
+
|
14
|
+
it "gets the phone number for shreve" do
|
15
|
+
location = Purlocation.get_location "SHRV"
|
16
|
+
location.phone.should eq("(765) 494-2569")
|
17
|
+
end
|
18
|
+
end
|
data/spec/spec_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,149 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: purlocation
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 29
|
5
|
+
prerelease:
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 0
|
9
|
+
- 1
|
10
|
+
version: 0.0.1
|
11
|
+
platform: ruby
|
12
|
+
authors:
|
13
|
+
- Scott Opell
|
14
|
+
autorequire:
|
15
|
+
bindir: bin
|
16
|
+
cert_chain: []
|
17
|
+
|
18
|
+
date: 2014-04-22 00:00:00 Z
|
19
|
+
dependencies:
|
20
|
+
- !ruby/object:Gem::Dependency
|
21
|
+
name: bundler
|
22
|
+
prerelease: false
|
23
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
24
|
+
none: false
|
25
|
+
requirements:
|
26
|
+
- - ~>
|
27
|
+
- !ruby/object:Gem::Version
|
28
|
+
hash: 5
|
29
|
+
segments:
|
30
|
+
- 1
|
31
|
+
- 5
|
32
|
+
version: "1.5"
|
33
|
+
type: :development
|
34
|
+
version_requirements: *id001
|
35
|
+
- !ruby/object:Gem::Dependency
|
36
|
+
name: rake
|
37
|
+
prerelease: false
|
38
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
39
|
+
none: false
|
40
|
+
requirements:
|
41
|
+
- - ">="
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
hash: 3
|
44
|
+
segments:
|
45
|
+
- 0
|
46
|
+
version: "0"
|
47
|
+
type: :development
|
48
|
+
version_requirements: *id002
|
49
|
+
- !ruby/object:Gem::Dependency
|
50
|
+
name: rspec
|
51
|
+
prerelease: false
|
52
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
53
|
+
none: false
|
54
|
+
requirements:
|
55
|
+
- - ">="
|
56
|
+
- !ruby/object:Gem::Version
|
57
|
+
hash: 3
|
58
|
+
segments:
|
59
|
+
- 0
|
60
|
+
version: "0"
|
61
|
+
type: :development
|
62
|
+
version_requirements: *id003
|
63
|
+
- !ruby/object:Gem::Dependency
|
64
|
+
name: pry
|
65
|
+
prerelease: false
|
66
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
67
|
+
none: false
|
68
|
+
requirements:
|
69
|
+
- - ">="
|
70
|
+
- !ruby/object:Gem::Version
|
71
|
+
hash: 3
|
72
|
+
segments:
|
73
|
+
- 0
|
74
|
+
version: "0"
|
75
|
+
type: :development
|
76
|
+
version_requirements: *id004
|
77
|
+
- !ruby/object:Gem::Dependency
|
78
|
+
name: nori
|
79
|
+
prerelease: false
|
80
|
+
requirement: &id005 !ruby/object:Gem::Requirement
|
81
|
+
none: false
|
82
|
+
requirements:
|
83
|
+
- - ">="
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
hash: 3
|
86
|
+
segments:
|
87
|
+
- 0
|
88
|
+
version: "0"
|
89
|
+
type: :runtime
|
90
|
+
version_requirements: *id005
|
91
|
+
description: "Example: BRNG => Beering Hall"
|
92
|
+
email:
|
93
|
+
- me@scottopell.com
|
94
|
+
executables: []
|
95
|
+
|
96
|
+
extensions: []
|
97
|
+
|
98
|
+
extra_rdoc_files: []
|
99
|
+
|
100
|
+
files:
|
101
|
+
- .gitignore
|
102
|
+
- .rspec
|
103
|
+
- .travis.yml
|
104
|
+
- Gemfile
|
105
|
+
- LICENSE.txt
|
106
|
+
- README.md
|
107
|
+
- Rakefile
|
108
|
+
- lib/purlocation.rb
|
109
|
+
- lib/purlocation/location.rb
|
110
|
+
- lib/purlocation/version.rb
|
111
|
+
- purlocation.gemspec
|
112
|
+
- spec/purlocation_spec.rb
|
113
|
+
- spec/spec_helper.rb
|
114
|
+
homepage: ""
|
115
|
+
licenses:
|
116
|
+
- MIT
|
117
|
+
post_install_message:
|
118
|
+
rdoc_options: []
|
119
|
+
|
120
|
+
require_paths:
|
121
|
+
- lib
|
122
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
123
|
+
none: false
|
124
|
+
requirements:
|
125
|
+
- - ">="
|
126
|
+
- !ruby/object:Gem::Version
|
127
|
+
hash: 3
|
128
|
+
segments:
|
129
|
+
- 0
|
130
|
+
version: "0"
|
131
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
132
|
+
none: false
|
133
|
+
requirements:
|
134
|
+
- - ">="
|
135
|
+
- !ruby/object:Gem::Version
|
136
|
+
hash: 3
|
137
|
+
segments:
|
138
|
+
- 0
|
139
|
+
version: "0"
|
140
|
+
requirements: []
|
141
|
+
|
142
|
+
rubyforge_project:
|
143
|
+
rubygems_version: 1.8.15
|
144
|
+
signing_key:
|
145
|
+
specification_version: 3
|
146
|
+
summary: Translates a Purdue building code to a location
|
147
|
+
test_files:
|
148
|
+
- spec/purlocation_spec.rb
|
149
|
+
- spec/spec_helper.rb
|