purlocation 0.0.1

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.
data/.gitignore ADDED
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --format documentation
data/.travis.yml ADDED
@@ -0,0 +1,6 @@
1
+ language: "ruby"
2
+ script: "bundle exec rake"
3
+ rvm:
4
+ - 1.9.3
5
+ - 2.0
6
+ - 2.1.0
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in purlocation.gemspec
4
+ gemspec
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
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require 'rspec/core/rake_task'
3
+
4
+ RSpec::Core::RakeTask.new('spec')
5
+
6
+ task :default => :spec
@@ -0,0 +1,8 @@
1
+ require "purlocation/version"
2
+ require "purlocation/location.rb"
3
+
4
+ module Purlocation
5
+ def self.get_location abbr
6
+ Location.new abbr
7
+ end
8
+ end
@@ -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
@@ -0,0 +1,3 @@
1
+ module Purlocation
2
+ VERSION = "0.0.1"
3
+ end
@@ -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
@@ -0,0 +1,8 @@
1
+ require 'bundler/setup'
2
+ Bundler.setup
3
+
4
+ require 'purlocation'
5
+
6
+ RSpec.configure do |config|
7
+ # optional
8
+ end
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