ouch 1.0.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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: f2c011d91fdbf6eea99d6f884f0cd222ad31fe87
4
+ data.tar.gz: 13c03c63910acbb3d5b9ecc539fea067addb9975
5
+ SHA512:
6
+ metadata.gz: 26eee2cde6faf81ed68692d2343bcca542fd80323b0efa37dc3c966a85341699ed8ef0cbfdfc432f8520240a77a6d0f508c27b7a3fdfe96fc7dd8987ffc21a1a
7
+ data.tar.gz: 1173896df3153928a07460c59e7685af7f10dee33a7693065ae3099c7eba280830382497c4db3537687877ef79d97331aca6593bb8b1c3c6e01c4a9c05181fcb
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/.travis.yml ADDED
@@ -0,0 +1,3 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.0.0
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in ouch.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 dickeyxxx
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,42 @@
1
+ # Ouch [![Build Status](https://travis-ci.org/dickeyxxx/ouch.png?branch=master)](https://travis-ci.org/dickeyxxx/ouch)
2
+
3
+ Finds you a hospital.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'ouch'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ ```bash
16
+ $ bundle
17
+ ```
18
+
19
+ Or install it yourself as:
20
+
21
+ ```bash
22
+ $ gem install ouch
23
+ ```
24
+
25
+ ## Usage
26
+
27
+ ```ruby
28
+ require 'ouch'
29
+ hospital = Ouch.find(lat: 34.0736204, lng: -118.4003563)
30
+ hospital.name # => "Cedars-Sinai Medical Center"
31
+ hospital.address # => "8700 Beverly Boulevard Los Angeles, CA 90048-1865"
32
+ hospital.phone # => "310-423-5000"
33
+ hospital.number_of_beds # => 914
34
+ ```
35
+
36
+ ## Contributing
37
+
38
+ 1. Fork it
39
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
40
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
41
+ 4. Push to the branch (`git push origin my-new-feature`)
42
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,10 @@
1
+ require "bundler/gem_tasks"
2
+
3
+ require 'rake/testtask'
4
+
5
+ task :default => :test
6
+
7
+ Rake::TestTask.new do |t|
8
+ t.libs << 'test'
9
+ t.pattern = "test/*_test.rb"
10
+ end
data/lib/ouch/info.rb ADDED
@@ -0,0 +1,32 @@
1
+ require 'faraday'
2
+ require 'nokogiri'
3
+
4
+ module Ouch
5
+ class Info
6
+ def initialize(lat: nil, lng: nil)
7
+ conn = Faraday.new("http://www.ushospitalfinder.com")
8
+ response = conn.get '/hospitals/search', { search_query: 'hospital', lat: lat, lng: lng }
9
+ page = Nokogiri::HTML.parse(response.body)
10
+ url = page.css('#list tr:first a')[0][:href]
11
+ response = conn.get(url)
12
+ page = Nokogiri::HTML.parse(response.body)
13
+ details = page.css('#detail-center p:has(b)')
14
+ @data = details.inject({}) do |data, detail|
15
+ data[detail.children[1].children[0].text] = detail.children[2].text.split.join(' ').strip
16
+ data
17
+ end
18
+ end
19
+
20
+ def name
21
+ @data["Name:"]
22
+ end
23
+
24
+ def address
25
+ @data["Address:"]
26
+ end
27
+
28
+ def phone
29
+ @data["Phone:"]
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,3 @@
1
+ module Ouch
2
+ VERSION = "1.0.0"
3
+ end
data/lib/ouch.rb ADDED
@@ -0,0 +1,8 @@
1
+ require "ouch/version"
2
+ require "ouch/info"
3
+
4
+ module Ouch
5
+ def self.find(lat: nil, lng: nil)
6
+ Info.new(lat: lat, lng: lng)
7
+ end
8
+ end
data/ouch.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 'ouch/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "ouch"
8
+ spec.version = Ouch::VERSION
9
+ spec.authors = ["dickeyxxx"]
10
+ spec.email = ["jeff@dickey.xxx"]
11
+ spec.description = %q{Finds a hospital based on lat/lon}
12
+ spec.summary = %q{Uses ushospitalfinder.com}
13
+ spec.homepage = "https://github.com/dickeyxxx/ouch"
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
+
24
+ spec.add_dependency "faraday"
25
+ spec.add_dependency "nokogiri"
26
+ end
data/test/ouch_test.rb ADDED
@@ -0,0 +1,24 @@
1
+ require 'minitest/autorun'
2
+ require 'ouch'
3
+
4
+ class TestOuch < MiniTest::Unit::TestCase
5
+ def setup
6
+ @hospital = Ouch.find(lat: 34.0736204, lng: -118.4003563)
7
+ end
8
+
9
+ def test_name
10
+ @hospital.name.must_equal "Cedars-Sinai Medical Center"
11
+ end
12
+
13
+ def test_address
14
+ @hospital.address.must_equal "8700 Beverly Boulevard Los Angeles, CA 90048-1865"
15
+ end
16
+
17
+ def test_phone
18
+ @hospital.phone.must_equal "310-423-5000"
19
+ end
20
+
21
+ def number_of_beds
22
+ @hospital.phone.must_equal 914
23
+ end
24
+ end
metadata ADDED
@@ -0,0 +1,112 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: ouch
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - dickeyxxx
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2013-06-13 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.3'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: '1.3'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: faraday
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - '>='
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: nokogiri
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - '>='
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ description: Finds a hospital based on lat/lon
70
+ email:
71
+ - jeff@dickey.xxx
72
+ executables: []
73
+ extensions: []
74
+ extra_rdoc_files: []
75
+ files:
76
+ - .gitignore
77
+ - .travis.yml
78
+ - Gemfile
79
+ - LICENSE.txt
80
+ - README.md
81
+ - Rakefile
82
+ - lib/ouch.rb
83
+ - lib/ouch/info.rb
84
+ - lib/ouch/version.rb
85
+ - ouch.gemspec
86
+ - test/ouch_test.rb
87
+ homepage: https://github.com/dickeyxxx/ouch
88
+ licenses:
89
+ - MIT
90
+ metadata: {}
91
+ post_install_message:
92
+ rdoc_options: []
93
+ require_paths:
94
+ - lib
95
+ required_ruby_version: !ruby/object:Gem::Requirement
96
+ requirements:
97
+ - - '>='
98
+ - !ruby/object:Gem::Version
99
+ version: '0'
100
+ required_rubygems_version: !ruby/object:Gem::Requirement
101
+ requirements:
102
+ - - '>='
103
+ - !ruby/object:Gem::Version
104
+ version: '0'
105
+ requirements: []
106
+ rubyforge_project:
107
+ rubygems_version: 2.0.2
108
+ signing_key:
109
+ specification_version: 4
110
+ summary: Uses ushospitalfinder.com
111
+ test_files:
112
+ - test/ouch_test.rb