science 0.0.1a → 0.0.1b
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile.lock +24 -1
- data/README.md +9 -1
- data/Rakefile +6 -0
- data/VERSION +1 -1
- data/examples/science/physical_geography/earth/elevation.rb +16 -0
- data/lib/science.rb +8 -1
- data/lib/science/helpers.rb +34 -0
- data/lib/science/physical_geography.rb +9 -0
- data/lib/science/physical_geography/earth.rb +14 -0
- data/lib/science/physical_geography/earth/elevation.rb +39 -0
- data/science.gemspec +6 -3
- metadata +24 -3
data/Gemfile.lock
CHANGED
@@ -1,12 +1,17 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
science (0.
|
4
|
+
science (0.0.1a)
|
5
|
+
savon (~> 2.1.0)
|
5
6
|
version (~> 1.0)
|
6
7
|
|
7
8
|
GEM
|
8
9
|
remote: https://rubygems.org/
|
9
10
|
specs:
|
11
|
+
akami (1.2.0)
|
12
|
+
gyoku (>= 0.4.0)
|
13
|
+
nokogiri (>= 1.4.0)
|
14
|
+
builder (3.2.0)
|
10
15
|
coderay (1.0.8)
|
11
16
|
diff-lcs (1.1.3)
|
12
17
|
fuubar (1.1.0)
|
@@ -25,13 +30,20 @@ GEM
|
|
25
30
|
guard-yard (2.0.1)
|
26
31
|
guard (>= 1.1.0)
|
27
32
|
yard (>= 0.7.0)
|
33
|
+
gyoku (1.0.0)
|
34
|
+
builder (>= 2.1.2)
|
35
|
+
httpi (2.0.2)
|
36
|
+
rack
|
28
37
|
listen (0.6.0)
|
29
38
|
lumberjack (1.0.2)
|
30
39
|
method_source (0.8.1)
|
40
|
+
nokogiri (1.5.6)
|
41
|
+
nori (2.0.3)
|
31
42
|
pry (0.9.10)
|
32
43
|
coderay (~> 1.0.5)
|
33
44
|
method_source (~> 0.8)
|
34
45
|
slop (~> 3.3.1)
|
46
|
+
rack (1.5.2)
|
35
47
|
rb-fsevent (0.9.2)
|
36
48
|
redcarpet (2.2.2)
|
37
49
|
rspec (2.12.0)
|
@@ -44,9 +56,20 @@ GEM
|
|
44
56
|
rspec-instafail (0.2.4)
|
45
57
|
rspec-mocks (2.12.0)
|
46
58
|
ruby-progressbar (1.0.2)
|
59
|
+
savon (2.1.0)
|
60
|
+
akami (~> 1.2.0)
|
61
|
+
builder (>= 2.1.2)
|
62
|
+
gyoku (~> 1.0.0)
|
63
|
+
httpi (~> 2.0.2)
|
64
|
+
nokogiri (>= 1.4.0)
|
65
|
+
nori (~> 2.0.3)
|
66
|
+
wasabi (~> 3.0.0)
|
47
67
|
slop (3.3.3)
|
48
68
|
thor (0.16.0)
|
49
69
|
version (1.0.0)
|
70
|
+
wasabi (3.0.0)
|
71
|
+
httpi (~> 2.0)
|
72
|
+
nokogiri (>= 1.4.0)
|
50
73
|
yard (0.8.3)
|
51
74
|
|
52
75
|
PLATFORMS
|
data/README.md
CHANGED
@@ -14,6 +14,14 @@ Science, as homosapiens understand it, written in Ruby.
|
|
14
14
|
|
15
15
|
## Usage
|
16
16
|
|
17
|
+
## TODO
|
18
|
+
|
19
|
+
* Alot. I mean, a *whole* lot. see the `Contributing` section below to help!
|
20
|
+
* Each and every module may have different dependencies.
|
21
|
+
Because of this, each module must be abstracted to it's own gem.
|
22
|
+
For example, the `Science::PhysicalGeography::Elevation` module will be abstracted to the
|
23
|
+
`science-physical_geography-elevation` gem, which will then become a dependency of this gem.
|
24
|
+
|
17
25
|
## Contributing
|
18
26
|
|
19
27
|
* Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet
|
@@ -22,7 +30,7 @@ Science, as homosapiens understand it, written in Ruby.
|
|
22
30
|
* Start a feature/bugfix branch
|
23
31
|
* Commit and push until you are happy with your contribution
|
24
32
|
* Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
|
25
|
-
* Please try not to mess with the Rakefile
|
33
|
+
* Please try not to mess with the Rakefile or VERSION.
|
26
34
|
|
27
35
|
## Copyright
|
28
36
|
|
data/Rakefile
CHANGED
@@ -20,7 +20,13 @@ spec = Gem::Specification.new do |s|
|
|
20
20
|
s.description = 'Knowledge.'
|
21
21
|
|
22
22
|
# Dependencies
|
23
|
+
|
24
|
+
# science
|
23
25
|
s.add_dependency 'version', '~> 1.0'
|
26
|
+
|
27
|
+
# science-physical_geography-elevation
|
28
|
+
s.add_dependency 'savon', '~> 2.1.0'
|
29
|
+
|
24
30
|
s.add_development_dependency 'guard-rspec', '~> 2.1'
|
25
31
|
s.add_development_dependency 'guard-yard', '~> 2.0'
|
26
32
|
s.add_development_dependency 'rb-fsevent', '~> 0.9'
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.1b
|
@@ -0,0 +1,16 @@
|
|
1
|
+
require 'bundler/setup'
|
2
|
+
require 'science/physical_geography/earth/elevation'
|
3
|
+
|
4
|
+
include Science::PhysicalGeography::Earth
|
5
|
+
|
6
|
+
locations = {
|
7
|
+
house: { latitude: 42.72664, longitude: -73.68996 },
|
8
|
+
park: { latitude: 42.72423, longitude: -73.68501 }
|
9
|
+
}
|
10
|
+
|
11
|
+
locations[:house][:elevation] = Elevation.usgs( locations[:house].merge(log: false) )
|
12
|
+
locations[:park][:elevation] = Elevation.usgs( locations[:park].merge(log: false) )
|
13
|
+
|
14
|
+
require 'pp'
|
15
|
+
|
16
|
+
pp locations
|
data/lib/science.rb
CHANGED
@@ -1,3 +1,6 @@
|
|
1
|
+
require 'science/helpers'
|
2
|
+
require 'logger'
|
3
|
+
|
1
4
|
module Science
|
2
5
|
|
3
6
|
# Modules:
|
@@ -15,7 +18,7 @@ module Science
|
|
15
18
|
|
16
19
|
# Cosmology, ExtragalacticAstronomy, GalacticAstronomy, PlanetaryAstronomy, StellarAstronomy, SolarAstronomy
|
17
20
|
|
18
|
-
# Meteorology, Climatology, Ecology, Environmental, Geodesy, Geology, Geomorphology,
|
21
|
+
# Meteorology, Climatology, Ecology, Environmental, Geodesy, Geology, Geomorphology, GeoPhysics, Glaciology, Hydrology,
|
19
22
|
# Limnology, Oceanography, Paleoclimatology, Paleoecology, Palynology, Geography, Pedology, Edaphology
|
20
23
|
|
21
24
|
# Anatomy, AstroBiology, BioGeography, BehavioralNeuroscience, BotanyCellBiology, ConservationBiology, CryoBiology
|
@@ -36,4 +39,8 @@ module Science
|
|
36
39
|
# ArtificialIntelligence, Bioethics, Bioinformatics, Biostatistics, CognitiveScience, Cultural, Cybernetics
|
37
40
|
# Ethnics, EvolutionaryPsychology, Forestry, Military, Semiotics
|
38
41
|
|
42
|
+
def self.logger
|
43
|
+
@@logger ||= Logger.new(STDOUT)
|
44
|
+
end
|
45
|
+
|
39
46
|
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
module Science
|
2
|
+
|
3
|
+
# General helpers for the internals of this gem.
|
4
|
+
# In time, most of these should be abstracted to gems.
|
5
|
+
module Helpers
|
6
|
+
|
7
|
+
# TODO: Abstract to `convertable` and `error` gems.
|
8
|
+
def validate_and_convert_hash(name, object)
|
9
|
+
raise TypeError, "`#{name}` should be a Hash or respond to :to_hash or :to_h" unless object.is_a?(Hash) || object.respond_to?(:to_hash) || object.respond_to?(:to_h)
|
10
|
+
object = object.to_hash rescue object.to_h unless object.is_a?(Hash)
|
11
|
+
|
12
|
+
object
|
13
|
+
end
|
14
|
+
|
15
|
+
# TODO: Abstract to `convertable` and `error` gems.
|
16
|
+
def validate_and_convert_float(name, object)
|
17
|
+
raise TypeError, "`#{name}` should be a Float or respond to :to_f" unless object.is_a?(Float) || object.respond_to?(:to_f)
|
18
|
+
object = object.to_f unless object.is_a?(Float)
|
19
|
+
|
20
|
+
object
|
21
|
+
end
|
22
|
+
|
23
|
+
# TODO: Abstract to `convertable` gem
|
24
|
+
def validate_hash_keys(name, hash, *keys)
|
25
|
+
keys.each do |key|
|
26
|
+
raise "`#{name}` requires key #{key.inspect}" unless hash.has_key?(key)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
extend self
|
31
|
+
|
32
|
+
end
|
33
|
+
|
34
|
+
end
|
@@ -0,0 +1,9 @@
|
|
1
|
+
module Science
|
2
|
+
|
3
|
+
# Physical geography is one of the two major subfields of geography which deals with the study of processes
|
4
|
+
# and patterns in the natural environment like the atmosphere, hydrosphere, biosphere, and geosphere.
|
5
|
+
module PhysicalGeography
|
6
|
+
|
7
|
+
end
|
8
|
+
|
9
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
require 'science'
|
2
|
+
require 'savon'
|
3
|
+
|
4
|
+
module Science
|
5
|
+
module PhysicalGeography
|
6
|
+
module Earth
|
7
|
+
|
8
|
+
# Access elevation data from various sources
|
9
|
+
module Elevation
|
10
|
+
|
11
|
+
USGS_API_URL = 'http://gisdata.usgs.gov/xmlwebservices2/elevation_service.asmx?WSDL'
|
12
|
+
|
13
|
+
# Retrieve the elevation at a specific latitude and longitude through the
|
14
|
+
# United States Geological Survey (USGS) Elevation Service API.
|
15
|
+
def usgs(options={})
|
16
|
+
options = Science::Helpers.validate_and_convert_hash('options', options)
|
17
|
+
Science::Helpers.validate_hash_keys('options', options, :latitude, :longitude)
|
18
|
+
latitude = Science::Helpers.validate_and_convert_float( 'options[:latitude]', options.delete(:latitude) )
|
19
|
+
longitude = Science::Helpers.validate_and_convert_float( 'options[:longitude]', options.delete(:longitude) )
|
20
|
+
|
21
|
+
options.merge!(wsdl: USGS_API_URL)
|
22
|
+
|
23
|
+
client = Savon.client(options)
|
24
|
+
message = { 'Y_Value' => latitude, 'X_Value' => longitude } # Note that USGS seems to have X and Y backwards: X should be latitude and Y should be longitude.
|
25
|
+
|
26
|
+
response = client.call(:get_elevation, message: message)
|
27
|
+
response_message = response.body[:get_elevation_response][:get_elevation_result][:usgs_elevation_web_service_query][:elevation_query]
|
28
|
+
|
29
|
+
response_message[:elevation].to_f # TODO: Use a unit library to say this is measured in feet.
|
30
|
+
end
|
31
|
+
|
32
|
+
extend self
|
33
|
+
|
34
|
+
end
|
35
|
+
|
36
|
+
end
|
37
|
+
|
38
|
+
end
|
39
|
+
end
|
data/science.gemspec
CHANGED
@@ -2,14 +2,14 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.name = "science"
|
5
|
-
s.version = "0.0.
|
5
|
+
s.version = "0.0.1b"
|
6
6
|
|
7
7
|
s.required_rubygems_version = Gem::Requirement.new("> 1.3.1") if s.respond_to? :required_rubygems_version=
|
8
8
|
s.authors = ["Ryan Scott Lewis"]
|
9
|
-
s.date = "2013-02-
|
9
|
+
s.date = "2013-02-25"
|
10
10
|
s.description = "Knowledge."
|
11
11
|
s.email = "ryan@rynet.us"
|
12
|
-
s.files = [".gitignore", ".rvmrc", "Gemfile", "Gemfile.lock", "Guardfile", "LICENSE", "README.md", "Rakefile", "VERSION", "lib/science.rb", "spec/science_spec.rb", "spec/spec_helper.rb"]
|
12
|
+
s.files = [".gitignore", ".rvmrc", "Gemfile", "Gemfile.lock", "Guardfile", "LICENSE", "README.md", "Rakefile", "VERSION", "examples/science/physical_geography/earth/elevation.rb", "lib/science.rb", "lib/science/helpers.rb", "lib/science/physical_geography.rb", "lib/science/physical_geography/earth.rb", "lib/science/physical_geography/earth/elevation.rb", "science.gemspec", "spec/science_spec.rb", "spec/spec_helper.rb"]
|
13
13
|
s.homepage = "http://github.com/RyanScottLewis/science"
|
14
14
|
s.require_paths = ["lib"]
|
15
15
|
s.rubygems_version = "1.8.25"
|
@@ -20,6 +20,7 @@ Gem::Specification.new do |s|
|
|
20
20
|
|
21
21
|
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
22
22
|
s.add_runtime_dependency(%q<version>, ["~> 1.0"])
|
23
|
+
s.add_runtime_dependency(%q<savon>, ["~> 2.1.0"])
|
23
24
|
s.add_development_dependency(%q<guard-rspec>, ["~> 2.1"])
|
24
25
|
s.add_development_dependency(%q<guard-yard>, ["~> 2.0"])
|
25
26
|
s.add_development_dependency(%q<rb-fsevent>, ["~> 0.9"])
|
@@ -28,6 +29,7 @@ Gem::Specification.new do |s|
|
|
28
29
|
s.add_development_dependency(%q<github-markup>, ["~> 0.7"])
|
29
30
|
else
|
30
31
|
s.add_dependency(%q<version>, ["~> 1.0"])
|
32
|
+
s.add_dependency(%q<savon>, ["~> 2.1.0"])
|
31
33
|
s.add_dependency(%q<guard-rspec>, ["~> 2.1"])
|
32
34
|
s.add_dependency(%q<guard-yard>, ["~> 2.0"])
|
33
35
|
s.add_dependency(%q<rb-fsevent>, ["~> 0.9"])
|
@@ -37,6 +39,7 @@ Gem::Specification.new do |s|
|
|
37
39
|
end
|
38
40
|
else
|
39
41
|
s.add_dependency(%q<version>, ["~> 1.0"])
|
42
|
+
s.add_dependency(%q<savon>, ["~> 2.1.0"])
|
40
43
|
s.add_dependency(%q<guard-rspec>, ["~> 2.1"])
|
41
44
|
s.add_dependency(%q<guard-yard>, ["~> 2.0"])
|
42
45
|
s.add_dependency(%q<rb-fsevent>, ["~> 0.9"])
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: science
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.1b
|
5
5
|
prerelease: 5
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-02-
|
12
|
+
date: 2013-02-25 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: version
|
@@ -27,6 +27,22 @@ dependencies:
|
|
27
27
|
- - ~>
|
28
28
|
- !ruby/object:Gem::Version
|
29
29
|
version: '1.0'
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: savon
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ~>
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: 2.1.0
|
38
|
+
type: :runtime
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ~>
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: 2.1.0
|
30
46
|
- !ruby/object:Gem::Dependency
|
31
47
|
name: guard-rspec
|
32
48
|
requirement: !ruby/object:Gem::Requirement
|
@@ -138,7 +154,12 @@ files:
|
|
138
154
|
- README.md
|
139
155
|
- Rakefile
|
140
156
|
- VERSION
|
157
|
+
- examples/science/physical_geography/earth/elevation.rb
|
141
158
|
- lib/science.rb
|
159
|
+
- lib/science/helpers.rb
|
160
|
+
- lib/science/physical_geography.rb
|
161
|
+
- lib/science/physical_geography/earth.rb
|
162
|
+
- lib/science/physical_geography/earth/elevation.rb
|
142
163
|
- science.gemspec
|
143
164
|
- spec/science_spec.rb
|
144
165
|
- spec/spec_helper.rb
|
@@ -156,7 +177,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
156
177
|
version: '0'
|
157
178
|
segments:
|
158
179
|
- 0
|
159
|
-
hash:
|
180
|
+
hash: -731604041832293251
|
160
181
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
161
182
|
none: false
|
162
183
|
requirements:
|