earth-tools 0.1.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.
- data/History.txt +4 -0
- data/Manifest.txt +30 -0
- data/README.rdoc +60 -0
- data/Rakefile +26 -0
- data/lib/earth_tools.rb +64 -0
- data/lib/earth_tools/date.rb +13 -0
- data/lib/earth_tools/height.rb +13 -0
- data/lib/earth_tools/location.rb +12 -0
- data/lib/earth_tools/sun.rb +14 -0
- data/lib/earth_tools/sun/evening.rb +13 -0
- data/lib/earth_tools/sun/morning.rb +14 -0
- data/lib/earth_tools/sun/twilight.rb +14 -0
- data/lib/earth_tools/timezone.rb +18 -0
- data/lib/earth_tools/xml/element.rb +18 -0
- data/script/console +10 -0
- data/script/destroy +14 -0
- data/script/generate +14 -0
- data/spec/earth_tools/date_spec.rb +45 -0
- data/spec/earth_tools/height_spec.rb +50 -0
- data/spec/earth_tools/location_spec.rb +31 -0
- data/spec/earth_tools/sun/evening_spec.rb +36 -0
- data/spec/earth_tools/sun/morning_spec.rb +37 -0
- data/spec/earth_tools/sun/twilight_spec.rb +39 -0
- data/spec/earth_tools/sun_spec.rb +71 -0
- data/spec/earth_tools/timezone_spec.rb +78 -0
- data/spec/earth_tools/xml/element_spec.rb +35 -0
- data/spec/earth_tools_spec.rb +136 -0
- data/spec/spec.opts +1 -0
- data/spec/spec_helper.rb +10 -0
- data/tasks/rspec.rake +21 -0
- metadata +117 -0
data/History.txt
ADDED
data/Manifest.txt
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
History.txt
|
2
|
+
Manifest.txt
|
3
|
+
README.rdoc
|
4
|
+
Rakefile
|
5
|
+
lib/earth_tools.rb
|
6
|
+
lib/earth_tools/date.rb
|
7
|
+
lib/earth_tools/height.rb
|
8
|
+
lib/earth_tools/location.rb
|
9
|
+
lib/earth_tools/sun.rb
|
10
|
+
lib/earth_tools/sun/evening.rb
|
11
|
+
lib/earth_tools/sun/morning.rb
|
12
|
+
lib/earth_tools/sun/twilight.rb
|
13
|
+
lib/earth_tools/timezone.rb
|
14
|
+
lib/earth_tools/xml/element.rb
|
15
|
+
script/console
|
16
|
+
script/destroy
|
17
|
+
script/generate
|
18
|
+
spec/earth_tools/date_spec.rb
|
19
|
+
spec/earth_tools/height_spec.rb
|
20
|
+
spec/earth_tools/location_spec.rb
|
21
|
+
spec/earth_tools/sun/evening_spec.rb
|
22
|
+
spec/earth_tools/sun/morning_spec.rb
|
23
|
+
spec/earth_tools/sun/twilight_spec.rb
|
24
|
+
spec/earth_tools/sun_spec.rb
|
25
|
+
spec/earth_tools/timezone_spec.rb
|
26
|
+
spec/earth_tools/xml/element_spec.rb
|
27
|
+
spec/earth_tools_spec.rb
|
28
|
+
spec/spec.opts
|
29
|
+
spec/spec_helper.rb
|
30
|
+
tasks/rspec.rake
|
data/README.rdoc
ADDED
@@ -0,0 +1,60 @@
|
|
1
|
+
= earth_tools
|
2
|
+
|
3
|
+
* http://github.com/psergi/earth_tools/tree/master
|
4
|
+
|
5
|
+
== DESCRIPTION:
|
6
|
+
|
7
|
+
EarthTools.org Web Services Library
|
8
|
+
|
9
|
+
== SYNOPSIS:
|
10
|
+
|
11
|
+
Current time given a latitude longitude:
|
12
|
+
|
13
|
+
>> EarthTools.timezone(:latitude => 42.3583333, :longitude => -71.0602778).isotime
|
14
|
+
=> "2009-07-02 18:28:37 -0500"
|
15
|
+
|
16
|
+
Timezone offset given a latitude longitude:
|
17
|
+
|
18
|
+
>> EarthTools.timezone(:latitude => 42.3583333, :longitude => -71.0602778).offset
|
19
|
+
=> "-5"
|
20
|
+
|
21
|
+
Sunrise/Sunset times given a latitude longitude and date:
|
22
|
+
|
23
|
+
>> EarthTools.sun(:latitude => 42.3583333, :longitude => -71.0602778, :day => 1, :month => 10).evening.sunset
|
24
|
+
=> "17:24:15"
|
25
|
+
|
26
|
+
>> EarthTools.sun(:latitude => 42.3583333, :longitude => -71.0602778, :day => 1, :month => 10).evening.sunset
|
27
|
+
=> "17:24:15"
|
28
|
+
|
29
|
+
== REQUIREMENTS:
|
30
|
+
|
31
|
+
* Nokogiri
|
32
|
+
|
33
|
+
== INSTALL:
|
34
|
+
|
35
|
+
* gem install earth-tools
|
36
|
+
|
37
|
+
== LICENSE:
|
38
|
+
|
39
|
+
(The MIT License)
|
40
|
+
|
41
|
+
Copyright (c) 2009 Phil Sergi
|
42
|
+
|
43
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
44
|
+
a copy of this software and associated documentation files (the
|
45
|
+
'Software'), to deal in the Software without restriction, including
|
46
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
47
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
48
|
+
permit persons to whom the Software is furnished to do so, subject to
|
49
|
+
the following conditions:
|
50
|
+
|
51
|
+
The above copyright notice and this permission notice shall be
|
52
|
+
included in all copies or substantial portions of the Software.
|
53
|
+
|
54
|
+
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
55
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
56
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
57
|
+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
58
|
+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
59
|
+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
60
|
+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/Rakefile
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
%w[rubygems rake rake/clean fileutils newgem rubigen].each { |f| require f }
|
2
|
+
require File.dirname(__FILE__) + '/lib/earth_tools'
|
3
|
+
|
4
|
+
# Generate all the Rake tasks
|
5
|
+
# Run 'rake -T' to see list of generated tasks (from gem root directory)
|
6
|
+
$hoe = Hoe.new('earth-tools', EarthTools::VERSION) do |p|
|
7
|
+
p.developer('Phil Sergi', 'phil.sergi@gmail.com')
|
8
|
+
p.changes = p.paragraphs_of("History.txt", 0..1).join("\n\n")
|
9
|
+
p.rubyforge_name = p.name
|
10
|
+
p.extra_deps = [
|
11
|
+
['nokogiri','>= 1.2.3'],
|
12
|
+
]
|
13
|
+
p.extra_dev_deps = [
|
14
|
+
['newgem', ">= #{::Newgem::VERSION}"]
|
15
|
+
]
|
16
|
+
|
17
|
+
p.clean_globs |= %w[**/.DS_Store tmp *.log]
|
18
|
+
path = (p.rubyforge_name == p.name) ? p.rubyforge_name : "\#{p.rubyforge_name}/\#{p.name}"
|
19
|
+
p.remote_rdoc_dir = File.join(path.gsub(/^#{p.rubyforge_name}\/?/,''), 'rdoc')
|
20
|
+
p.rsync_args = '-av --delete --ignore-errors'
|
21
|
+
end
|
22
|
+
|
23
|
+
require 'newgem/tasks' # load /tasks/*.rake
|
24
|
+
Dir['tasks/**/*.rake'].each { |t| load t }
|
25
|
+
|
26
|
+
task :default => [:spec]
|
data/lib/earth_tools.rb
ADDED
@@ -0,0 +1,64 @@
|
|
1
|
+
$:.unshift(File.dirname(__FILE__)) unless
|
2
|
+
$:.include?(File.dirname(__FILE__)) || $:.include?(File.expand_path(File.dirname(__FILE__)))
|
3
|
+
|
4
|
+
require 'open-uri'
|
5
|
+
require 'nokogiri'
|
6
|
+
|
7
|
+
require 'earth_tools/xml/element'
|
8
|
+
require 'earth_tools/date'
|
9
|
+
require 'earth_tools/location'
|
10
|
+
require 'earth_tools/height'
|
11
|
+
require 'earth_tools/sun/twilight'
|
12
|
+
require 'earth_tools/sun/evening'
|
13
|
+
require 'earth_tools/sun/morning'
|
14
|
+
require 'earth_tools/sun'
|
15
|
+
require 'earth_tools/timezone'
|
16
|
+
|
17
|
+
module EarthTools
|
18
|
+
VERSION = '0.1.0'
|
19
|
+
|
20
|
+
class << self
|
21
|
+
attr_accessor :base_uri
|
22
|
+
end
|
23
|
+
|
24
|
+
self.base_uri = 'http://www.earthtools.org'
|
25
|
+
|
26
|
+
def self.timezone(params)
|
27
|
+
params = prepare_params(params)
|
28
|
+
response = self.get('timezone', params['version'], params['latitude'], params['longitude'])
|
29
|
+
EarthTools::Timezone.new(response)
|
30
|
+
end
|
31
|
+
|
32
|
+
def self.sun(params)
|
33
|
+
params = { 'timezone' => '99', 'dst' => '0' }.merge(prepare_params(params))
|
34
|
+
response = self.get('sun', params['version'], params['latitude'], params['longitude'], params['day'], params['month'], params['timezone'], params['dst'])
|
35
|
+
EarthTools::Sun.new(response)
|
36
|
+
end
|
37
|
+
|
38
|
+
def self.height(params)
|
39
|
+
params = prepare_params(params)
|
40
|
+
response = self.get('height', params['version'], params['latitude'], params['longitude'])
|
41
|
+
EarthTools::Height.new(response)
|
42
|
+
end
|
43
|
+
|
44
|
+
def self.get(service, version = nil, *params)
|
45
|
+
service = versioned_service(service, version)
|
46
|
+
response = open(File.join(self.base_uri, service, *params))
|
47
|
+
EarthTools::XML::Element.new(Nokogiri::XML(response))
|
48
|
+
end
|
49
|
+
|
50
|
+
private
|
51
|
+
|
52
|
+
def self.versioned_service(service, version)
|
53
|
+
return service if version.nil?
|
54
|
+
"#{service}-#{version}"
|
55
|
+
end
|
56
|
+
|
57
|
+
def self.prepare_params(params)
|
58
|
+
params.inject({}) do |options, (key, value)|
|
59
|
+
options[key.to_s] = value.to_s
|
60
|
+
options
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
module EarthTools
|
2
|
+
class Height
|
3
|
+
attr_accessor :version, :location, :meters, :feet
|
4
|
+
|
5
|
+
def initialize(attrs = {})
|
6
|
+
attrs ||= {}
|
7
|
+
@version = attrs['version']
|
8
|
+
@location = EarthTools::Location.new(attrs['location'])
|
9
|
+
@meters = attrs['meters']
|
10
|
+
@feet = attrs['feet']
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
module EarthTools
|
2
|
+
class Sun
|
3
|
+
attr_accessor :version, :location, :date, :morning, :evening
|
4
|
+
|
5
|
+
def initialize(attrs = {})
|
6
|
+
attrs ||= {}
|
7
|
+
@version = attrs['version']
|
8
|
+
@location = EarthTools::Location.new(attrs['location'])
|
9
|
+
@date = EarthTools::Date.new(attrs['date'])
|
10
|
+
@morning = EarthTools::Sun::Morning.new(attrs['morning'])
|
11
|
+
@evening = EarthTools::Sun::Evening.new(attrs['evening'])
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
module EarthTools
|
2
|
+
class Sun
|
3
|
+
class Twilight
|
4
|
+
attr_accessor :civil, :nautical, :astronomical
|
5
|
+
|
6
|
+
def initialize(attrs = {})
|
7
|
+
attrs ||= {}
|
8
|
+
@civil = attrs['civil']
|
9
|
+
@nautical = attrs['nautical']
|
10
|
+
@astronomical = attrs['astronomical']
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module EarthTools
|
2
|
+
class Timezone
|
3
|
+
attr_accessor :version, :location, :offset, :suffix, :localtime, :isotime, :utctime, :dst
|
4
|
+
|
5
|
+
def initialize(attrs = {})
|
6
|
+
attrs ||= {}
|
7
|
+
@version = attrs['version']
|
8
|
+
@location = EarthTools::Location.new(attrs['location'])
|
9
|
+
@offset = attrs['offset']
|
10
|
+
@suffix = attrs['suffix']
|
11
|
+
@localtime = attrs['localtime']
|
12
|
+
@isotime = attrs['isotime']
|
13
|
+
@utctime = attrs['utctime']
|
14
|
+
@dst = attrs['dst']
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module EarthTools
|
2
|
+
module XML
|
3
|
+
class Element
|
4
|
+
attr_accessor :xml
|
5
|
+
|
6
|
+
def initialize(xml)
|
7
|
+
@xml = xml
|
8
|
+
end
|
9
|
+
|
10
|
+
def [](element)
|
11
|
+
element = @xml.at(element)
|
12
|
+
return unless element
|
13
|
+
element.children.any? { |c| c.element? } ? EarthTools::XML::Element.new(element) : element.text
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
data/script/console
ADDED
@@ -0,0 +1,10 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# File: script/console
|
3
|
+
irb = RUBY_PLATFORM =~ /(:?mswin|mingw)/ ? 'irb.bat' : 'irb'
|
4
|
+
|
5
|
+
libs = " -r irb/completion"
|
6
|
+
# Perhaps use a console_lib to store any extra methods I may want available in the cosole
|
7
|
+
# libs << " -r #{File.dirname(__FILE__) + '/../lib/console_lib/console_logger.rb'}"
|
8
|
+
libs << " -r #{File.dirname(__FILE__) + '/../lib/earth_tools.rb'}"
|
9
|
+
puts "Loading earth_tools gem"
|
10
|
+
exec "#{irb} #{libs} --simple-prompt"
|
data/script/destroy
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
APP_ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..'))
|
3
|
+
|
4
|
+
begin
|
5
|
+
require 'rubigen'
|
6
|
+
rescue LoadError
|
7
|
+
require 'rubygems'
|
8
|
+
require 'rubigen'
|
9
|
+
end
|
10
|
+
require 'rubigen/scripts/destroy'
|
11
|
+
|
12
|
+
ARGV.shift if ['--help', '-h'].include?(ARGV[0])
|
13
|
+
RubiGen::Base.use_component_sources! [:rubygems, :newgem, :newgem_theme, :test_unit]
|
14
|
+
RubiGen::Scripts::Destroy.new.run(ARGV)
|
data/script/generate
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
APP_ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..'))
|
3
|
+
|
4
|
+
begin
|
5
|
+
require 'rubigen'
|
6
|
+
rescue LoadError
|
7
|
+
require 'rubygems'
|
8
|
+
require 'rubigen'
|
9
|
+
end
|
10
|
+
require 'rubigen/scripts/generate'
|
11
|
+
|
12
|
+
ARGV.shift if ['--help', '-h'].include?(ARGV[0])
|
13
|
+
RubiGen::Base.use_component_sources! [:rubygems, :newgem, :newgem_theme, :test_unit]
|
14
|
+
RubiGen::Scripts::Generate.new.run(ARGV)
|
@@ -0,0 +1,45 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper.rb')
|
2
|
+
|
3
|
+
describe EarthTools::Date do
|
4
|
+
before do
|
5
|
+
@date = EarthTools::Date.new
|
6
|
+
end
|
7
|
+
it "should have day accessor" do
|
8
|
+
@date.should respond_to(:day)
|
9
|
+
@date.should respond_to(:day=)
|
10
|
+
end
|
11
|
+
it "should have a month accessor" do
|
12
|
+
@date.should respond_to(:month)
|
13
|
+
@date.should respond_to(:month=)
|
14
|
+
end
|
15
|
+
it "should have a timezone accessor" do
|
16
|
+
@date.should respond_to(:timezone)
|
17
|
+
@date.should respond_to(:timezone=)
|
18
|
+
end
|
19
|
+
it "should have a dst accessor" do
|
20
|
+
@date.should respond_to(:dst)
|
21
|
+
@date.should respond_to(:dst=)
|
22
|
+
end
|
23
|
+
|
24
|
+
describe ".initialize" do
|
25
|
+
before do
|
26
|
+
@element = EarthTools::XML::Element.new(Nokogiri::XML('<date><day>4</day><month>12</month><timezone>-5</timezone><dst>0</dst></date>'))
|
27
|
+
@date = EarthTools::Date.new(@element)
|
28
|
+
end
|
29
|
+
it "should set the day" do
|
30
|
+
@date.day.should == '4'
|
31
|
+
end
|
32
|
+
it "should set the month" do
|
33
|
+
@date.month.should == '12'
|
34
|
+
end
|
35
|
+
it "should set the timezone" do
|
36
|
+
@date.timezone.should == '-5'
|
37
|
+
end
|
38
|
+
it "should set the dst" do
|
39
|
+
@date.dst.should == '0'
|
40
|
+
end
|
41
|
+
it "should not shit if nil is passed" do
|
42
|
+
lambda { EarthTools::Date.new(nil) }.should_not raise_error
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper.rb')
|
2
|
+
|
3
|
+
describe EarthTools::Height do
|
4
|
+
before do
|
5
|
+
@height = EarthTools::Height.new
|
6
|
+
end
|
7
|
+
it "should have a version accessor" do
|
8
|
+
@height.should respond_to(:version)
|
9
|
+
@height.should respond_to(:version=)
|
10
|
+
end
|
11
|
+
it "should have a location accessor" do
|
12
|
+
@height.should respond_to(:location)
|
13
|
+
@height.should respond_to(:location=)
|
14
|
+
end
|
15
|
+
it "should have a meters accessor" do
|
16
|
+
@height.should respond_to(:meters)
|
17
|
+
@height.should respond_to(:meters=)
|
18
|
+
end
|
19
|
+
it "should have a feet accessor" do
|
20
|
+
@height.should respond_to(:feet)
|
21
|
+
@height.should respond_to(:feet=)
|
22
|
+
end
|
23
|
+
|
24
|
+
describe ".initialize" do
|
25
|
+
before do
|
26
|
+
@element = EarthTools::XML::Element.new(Nokogiri::XML('<height xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://www.earthtools.org/height.xsd"> <version>1.0</version> <location> <latitude>52.4822</latitude> <longitude>-1.8946</longitude> </location> <meters>141</meters> <feet>462.6</feet> </height>'))
|
27
|
+
@height = EarthTools::Height.new(@element)
|
28
|
+
end
|
29
|
+
it "should set the version" do
|
30
|
+
@height.version.should == '1.0'
|
31
|
+
end
|
32
|
+
it "should parse the location" do
|
33
|
+
@element.stub!(:[])
|
34
|
+
@element.should_receive(:[]).with('location').and_return('location element')
|
35
|
+
EarthTools::Location.should_receive(:new).with('location element').and_return('location')
|
36
|
+
height = EarthTools::Height.new(@element)
|
37
|
+
height.location.should == 'location'
|
38
|
+
end
|
39
|
+
it "should set the meters" do
|
40
|
+
@height.meters.should == '141'
|
41
|
+
end
|
42
|
+
it "should set the feet" do
|
43
|
+
@height.feet.should == '462.6'
|
44
|
+
end
|
45
|
+
it "should not shit if nil is passed" do
|
46
|
+
lambda { EarthTools::Height.new(nil) }.should_not raise_error
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
@@ -0,0 +1,31 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper.rb')
|
2
|
+
|
3
|
+
describe EarthTools::Location do
|
4
|
+
before do
|
5
|
+
@location = EarthTools::Location.new
|
6
|
+
end
|
7
|
+
it "should have latitude accessor" do
|
8
|
+
@location.should respond_to(:latitude)
|
9
|
+
@location.should respond_to(:latitude=)
|
10
|
+
end
|
11
|
+
it "should have longitude accessor" do
|
12
|
+
@location.should respond_to(:longitude)
|
13
|
+
@location.should respond_to(:longitude=)
|
14
|
+
end
|
15
|
+
|
16
|
+
describe ".initialize" do
|
17
|
+
before do
|
18
|
+
@element = EarthTools::XML::Element.new(Nokogiri::XML('<location><latitude>40.71417</latitude><longitude>-74.00639</longitude></location>'))
|
19
|
+
@location = EarthTools::Location.new(@element)
|
20
|
+
end
|
21
|
+
it "should set the latitude" do
|
22
|
+
@location.latitude.should == '40.71417'
|
23
|
+
end
|
24
|
+
it "should set the longitude" do
|
25
|
+
@location.longitude.should == '-74.00639'
|
26
|
+
end
|
27
|
+
it "should not shit if nil is passed" do
|
28
|
+
lambda { EarthTools::Location.new(nil) }.should_not raise_error
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper.rb')
|
2
|
+
|
3
|
+
describe EarthTools::Sun::Evening do
|
4
|
+
before do
|
5
|
+
@evening = EarthTools::Sun::Evening.new
|
6
|
+
end
|
7
|
+
|
8
|
+
it "should have a sunset accessor" do
|
9
|
+
@evening.should respond_to(:sunset)
|
10
|
+
@evening.should respond_to(:sunset=)
|
11
|
+
end
|
12
|
+
it "should have a twilight accessor" do
|
13
|
+
@evening.should respond_to(:twilight)
|
14
|
+
@evening.should respond_to(:twilight=)
|
15
|
+
end
|
16
|
+
|
17
|
+
describe ".initialize" do
|
18
|
+
before do
|
19
|
+
@element = EarthTools::XML::Element.new(Nokogiri::XML('<evening> <sunset>16:27:01</sunset> <twilight> <civil>16:57:44</civil> <nautical>17:31:59</nautical> <astronomical>18:05:10</astronomical> </twilight> </evening>'))
|
20
|
+
@evening = EarthTools::Sun::Evening.new(@element)
|
21
|
+
end
|
22
|
+
it "should set the sunset" do
|
23
|
+
@evening.sunset.should == '16:27:01'
|
24
|
+
end
|
25
|
+
it "should parse the twilight" do
|
26
|
+
@element.stub!(:[])
|
27
|
+
@element.should_receive(:[]).with('twilight').and_return('twilight element')
|
28
|
+
EarthTools::Sun::Twilight.should_receive(:new).with('twilight element').and_return('twilight')
|
29
|
+
evening = EarthTools::Sun::Evening.new(@element)
|
30
|
+
evening.twilight.should == 'twilight'
|
31
|
+
end
|
32
|
+
it "should not shit if nil is passed" do
|
33
|
+
lambda { EarthTools::Sun::Evening.new(nil) }.should_not raise_error
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper.rb')
|
2
|
+
|
3
|
+
describe EarthTools::Sun::Morning do
|
4
|
+
before do
|
5
|
+
@morning = EarthTools::Sun::Morning.new
|
6
|
+
end
|
7
|
+
|
8
|
+
it "should have a sunrise accessor" do
|
9
|
+
@morning.should respond_to(:sunrise)
|
10
|
+
@morning.should respond_to(:sunrise=)
|
11
|
+
end
|
12
|
+
it "should have a twilight accessor" do
|
13
|
+
@morning.should respond_to(:twilight)
|
14
|
+
@morning.should respond_to(:twilight=)
|
15
|
+
end
|
16
|
+
|
17
|
+
describe ".initialize" do
|
18
|
+
before do
|
19
|
+
@element = EarthTools::XML::Element.new(Nokogiri::XML('<morning> <sunrise>07:05:34</sunrise> <twilight> <civil>06:34:51</civil> <nautical>06:00:36</nautical> <astronomical>05:27:25</astronomical> </twilight> </morning>'))
|
20
|
+
@morning = EarthTools::Sun::Morning.new(@element)
|
21
|
+
end
|
22
|
+
it "should set the sunrise" do
|
23
|
+
@morning.sunrise.should == '07:05:34'
|
24
|
+
end
|
25
|
+
it "should parse the twilight" do
|
26
|
+
@element.stub!(:[])
|
27
|
+
@element.should_receive(:[]).with('twilight').and_return('twilight element')
|
28
|
+
EarthTools::Sun::Twilight.should_receive(:new).with('twilight element').and_return('twilight')
|
29
|
+
morning = EarthTools::Sun::Morning.new(@element)
|
30
|
+
morning.twilight.should == 'twilight'
|
31
|
+
end
|
32
|
+
it "should not shit if nil is passed" do
|
33
|
+
lambda { EarthTools::Sun::Morning.new(nil) }.should_not raise_error
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
@@ -0,0 +1,39 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper.rb')
|
2
|
+
|
3
|
+
describe EarthTools::Sun::Twilight do
|
4
|
+
before do
|
5
|
+
@twilight = EarthTools::Sun::Twilight.new
|
6
|
+
end
|
7
|
+
|
8
|
+
it "should have a civil accessor" do
|
9
|
+
@twilight.should respond_to(:civil)
|
10
|
+
@twilight.should respond_to(:civil=)
|
11
|
+
end
|
12
|
+
it "should have a nautical accessor" do
|
13
|
+
@twilight.should respond_to(:nautical)
|
14
|
+
@twilight.should respond_to(:nautical=)
|
15
|
+
end
|
16
|
+
it "should have a astronomical accessor" do
|
17
|
+
@twilight.should respond_to(:astronomical)
|
18
|
+
@twilight.should respond_to(:astronomical=)
|
19
|
+
end
|
20
|
+
|
21
|
+
describe ".initialize" do
|
22
|
+
before do
|
23
|
+
@element = EarthTools::XML::Element.new(Nokogiri::XML('<twilight> <civil>16:57:44</civil> <nautical>17:31:59</nautical> <astronomical>18:05:10</astronomical> </twilight>'))
|
24
|
+
@twilight = EarthTools::Sun::Twilight.new(@element)
|
25
|
+
end
|
26
|
+
it "should set the civil" do
|
27
|
+
@twilight.civil.should == '16:57:44'
|
28
|
+
end
|
29
|
+
it "should set the nautical" do
|
30
|
+
@twilight.nautical.should == '17:31:59'
|
31
|
+
end
|
32
|
+
it "should set the astronomical" do
|
33
|
+
@twilight.astronomical.should == '18:05:10'
|
34
|
+
end
|
35
|
+
it "should not shit if nil is passed" do
|
36
|
+
lambda { EarthTools::Sun::Twilight.new(nil) }.should_not raise_error
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,71 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper.rb')
|
2
|
+
|
3
|
+
describe EarthTools::Sun do
|
4
|
+
before do
|
5
|
+
@sun = EarthTools::Sun.new
|
6
|
+
end
|
7
|
+
|
8
|
+
it "should have a version accessor" do
|
9
|
+
@sun.should respond_to(:version)
|
10
|
+
@sun.should respond_to(:version=)
|
11
|
+
end
|
12
|
+
it "should have a location accessor" do
|
13
|
+
@sun.should respond_to(:location)
|
14
|
+
@sun.should respond_to(:location=)
|
15
|
+
end
|
16
|
+
it "should have a date accessor" do
|
17
|
+
@sun.should respond_to(:date)
|
18
|
+
@sun.should respond_to(:date=)
|
19
|
+
end
|
20
|
+
it "should have a morning accessor" do
|
21
|
+
@sun.should respond_to(:morning)
|
22
|
+
@sun.should respond_to(:morning=)
|
23
|
+
end
|
24
|
+
it "should have an evening accessor" do
|
25
|
+
@sun.should respond_to(:evening)
|
26
|
+
@sun.should respond_to(:evening=)
|
27
|
+
end
|
28
|
+
|
29
|
+
describe ".initialize" do
|
30
|
+
before do
|
31
|
+
@element = EarthTools::XML::Element.new(Nokogiri::XML('<sun xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://www.earthtools.org/sun.xsd"> <version>1.0</version> <location> <latitude>40.71417</latitude> <longitude>-74.00639</longitude> </location> <date> <day>4</day> <month>12</month> <timezone>-5</timezone> <dst>0</dst> </date> <morning> <sunrise>07:05:34</sunrise> <twilight> <civil>06:34:51</civil> <nautical>06:00:36</nautical> <astronomical>05:27:25</astronomical> </twilight> </morning> <evening> <sunset>16:27:01</sunset> <twilight> <civil>16:57:44</civil> <nautical>17:31:59</nautical> <astronomical>18:05:10</astronomical> </twilight> </evening> </sun>'))
|
32
|
+
@sun = EarthTools::Sun.new(@element)
|
33
|
+
end
|
34
|
+
it "should set the version" do
|
35
|
+
@sun.version.should == '1.0'
|
36
|
+
end
|
37
|
+
describe "complex attributes" do
|
38
|
+
before do
|
39
|
+
@element.stub!(:[])
|
40
|
+
end
|
41
|
+
it "should parse the location" do
|
42
|
+
@element.should_receive(:[]).with('location').and_return('location element')
|
43
|
+
EarthTools::Location.should_receive(:new).with('location element').and_return('location')
|
44
|
+
sun = EarthTools::Sun.new(@element)
|
45
|
+
sun.location.should == 'location'
|
46
|
+
end
|
47
|
+
it "should parse the date" do
|
48
|
+
@element.should_receive(:[]).with('date').and_return('date element')
|
49
|
+
EarthTools::Date.should_receive(:new).with('date element').and_return('date')
|
50
|
+
sun = EarthTools::Sun.new(@element)
|
51
|
+
sun.date.should == 'date'
|
52
|
+
end
|
53
|
+
it "should parse the morning" do
|
54
|
+
@element.should_receive(:[]).with('morning').and_return('morning element')
|
55
|
+
EarthTools::Sun::Morning.should_receive(:new).with('morning element').and_return('morning')
|
56
|
+
sun = EarthTools::Sun.new(@element)
|
57
|
+
sun.morning.should == 'morning'
|
58
|
+
end
|
59
|
+
it "should parse the evening" do
|
60
|
+
@element.should_receive(:[]).with('evening').and_return('evening element')
|
61
|
+
EarthTools::Sun::Evening.should_receive(:new).with('evening element').and_return('evening')
|
62
|
+
sun = EarthTools::Sun.new(@element)
|
63
|
+
sun.evening.should == 'evening'
|
64
|
+
end
|
65
|
+
end
|
66
|
+
it "should not shit if nil is passed" do
|
67
|
+
lambda { EarthTools::Sun.new(nil) }.should_not raise_error
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
@@ -0,0 +1,78 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper.rb')
|
2
|
+
|
3
|
+
describe EarthTools::Timezone do
|
4
|
+
before do
|
5
|
+
@timezone = EarthTools::Timezone.new
|
6
|
+
end
|
7
|
+
|
8
|
+
it "should have a version accessor" do
|
9
|
+
@timezone.should respond_to(:version)
|
10
|
+
@timezone.should respond_to(:version=)
|
11
|
+
end
|
12
|
+
it "should have a location accessor" do
|
13
|
+
@timezone.should respond_to(:location)
|
14
|
+
@timezone.should respond_to(:location=)
|
15
|
+
end
|
16
|
+
it "should have an offset accessor" do
|
17
|
+
@timezone.should respond_to(:offset)
|
18
|
+
@timezone.should respond_to(:offset=)
|
19
|
+
end
|
20
|
+
it "should have a suffix accessor" do
|
21
|
+
@timezone.should respond_to(:suffix)
|
22
|
+
@timezone.should respond_to(:suffix=)
|
23
|
+
end
|
24
|
+
it "should have a localtime accessor" do
|
25
|
+
@timezone.should respond_to(:localtime)
|
26
|
+
@timezone.should respond_to(:localtime=)
|
27
|
+
end
|
28
|
+
it "should have an isotime accessor" do
|
29
|
+
@timezone.should respond_to(:isotime)
|
30
|
+
@timezone.should respond_to(:isotime=)
|
31
|
+
end
|
32
|
+
it "should have a utctime accessor" do
|
33
|
+
@timezone.should respond_to(:utctime)
|
34
|
+
@timezone.should respond_to(:utctime=)
|
35
|
+
end
|
36
|
+
it "should have a dst accessor" do
|
37
|
+
@timezone.should respond_to(:dst)
|
38
|
+
@timezone.should respond_to(:dst=)
|
39
|
+
end
|
40
|
+
|
41
|
+
describe ".initialize" do
|
42
|
+
before do
|
43
|
+
@element = EarthTools::XML::Element.new(Nokogiri::XML('<?xml version="1.0" encoding="ISO-8859-1" ?> <timezone xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://www.earthtools.org/timezone.xsd"> <version>1.1</version> <location> <latitude>40.71417</latitude> <longitude>-74.00639</longitude> </location> <offset>-5</offset> <suffix>R</suffix> <localtime>4 Dec 2005 12:06:56</localtime> <isotime>2005-12-04 12:06:56 -0500</isotime> <utctime>2005-12-04 17:06:56</utctime> <dst>False</dst> </timezone>'))
|
44
|
+
@timezone = EarthTools::Timezone.new(@element)
|
45
|
+
end
|
46
|
+
it "should set the version" do
|
47
|
+
@timezone.version.should == '1.1'
|
48
|
+
end
|
49
|
+
it "should parse the location" do
|
50
|
+
@element.stub!(:[])
|
51
|
+
@element.should_receive(:[]).with('location').and_return('location element')
|
52
|
+
EarthTools::Location.should_receive(:new).with('location element').and_return('location')
|
53
|
+
timezone = EarthTools::Timezone.new(@element)
|
54
|
+
timezone.location.should == 'location'
|
55
|
+
end
|
56
|
+
it "should set the offset" do
|
57
|
+
@timezone.offset.should == '-5'
|
58
|
+
end
|
59
|
+
it "should set the suffix" do
|
60
|
+
@timezone.suffix.should == 'R'
|
61
|
+
end
|
62
|
+
it "should set the localtime" do
|
63
|
+
@timezone.localtime.should == '4 Dec 2005 12:06:56'
|
64
|
+
end
|
65
|
+
it "should set the isotime" do
|
66
|
+
@timezone.isotime.should == '2005-12-04 12:06:56 -0500'
|
67
|
+
end
|
68
|
+
it "should set the utctime" do
|
69
|
+
@timezone.utctime.should == '2005-12-04 17:06:56'
|
70
|
+
end
|
71
|
+
it "should set the dst" do
|
72
|
+
@timezone.dst.should == 'False'
|
73
|
+
end
|
74
|
+
it "should not shit if nil is passed" do
|
75
|
+
lambda { EarthTools::Timezone.new(nil) }.should_not raise_error
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper.rb')
|
2
|
+
|
3
|
+
describe EarthTools::XML::Element do
|
4
|
+
before do
|
5
|
+
@xml = Nokogiri::XML('<item><time>10:20:12</time><nested><time>10:00:00</time></nested></item>')
|
6
|
+
@element = EarthTools::XML::Element.new(@xml)
|
7
|
+
end
|
8
|
+
|
9
|
+
it "should have an xml accessor" do
|
10
|
+
@element.should respond_to(:xml)
|
11
|
+
@element.should respond_to(:xml=)
|
12
|
+
end
|
13
|
+
|
14
|
+
describe "initialize" do
|
15
|
+
it "should take be initialized with an xml object" do
|
16
|
+
element = EarthTools::XML::Element.new(@xml)
|
17
|
+
element.xml.should == @xml
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
describe "['element']" do
|
22
|
+
before do
|
23
|
+
@element = EarthTools::XML::Element.new(@xml)
|
24
|
+
end
|
25
|
+
it "should to parse out the text of the element passed" do
|
26
|
+
@element['time'].should == '10:20:12'
|
27
|
+
end
|
28
|
+
it "should to return nil if the element is not found" do
|
29
|
+
@element['text'].should be_nil
|
30
|
+
end
|
31
|
+
it "should return an EarthTools::XML::Element of the requested element has children" do
|
32
|
+
@element['nested'].should be_kind_of(EarthTools::XML::Element)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,136 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/spec_helper.rb')
|
2
|
+
|
3
|
+
describe EarthTools do
|
4
|
+
it "should have a base uri accessor" do
|
5
|
+
EarthTools.should respond_to(:base_uri)
|
6
|
+
EarthTools.should respond_to(:base_uri=)
|
7
|
+
end
|
8
|
+
it "should set the base_uri to 'http://www.earthtools.org" do
|
9
|
+
EarthTools.base_uri.should == 'http://www.earthtools.org'
|
10
|
+
end
|
11
|
+
|
12
|
+
describe ".get" do
|
13
|
+
before do
|
14
|
+
Nokogiri.stub!(:XML)
|
15
|
+
@response = '<?xml version="1.0" encoding="ISO-8859-1" ?><root></root>'
|
16
|
+
EarthTools.stub!(:open).and_return(@response)
|
17
|
+
end
|
18
|
+
it "should make a request with the base uri" do
|
19
|
+
EarthTools.should_receive(:open).with(Regexp.new(Regexp.escape(EarthTools.base_uri)))
|
20
|
+
EarthTools.get('timezone')
|
21
|
+
end
|
22
|
+
it "should make a request to the service passed" do
|
23
|
+
EarthTools.should_receive(:open).with(File.join(EarthTools.base_uri, "timezone"))
|
24
|
+
EarthTools.get('timezone')
|
25
|
+
end
|
26
|
+
it "should make a versioned request if the version is passed" do
|
27
|
+
EarthTools.should_receive(:open).with(File.join(EarthTools.base_uri, "timezone-1.1"))
|
28
|
+
EarthTools.get('timezone', '1.1')
|
29
|
+
end
|
30
|
+
it "should seperate each of the params with slashes" do
|
31
|
+
EarthTools.should_receive(:open).with(File.join(EarthTools.base_uri, "timezone", "one", "two", "three"))
|
32
|
+
EarthTools.get('timezone', nil, 'one', 'two', 'three')
|
33
|
+
end
|
34
|
+
it "should build a Nokogiri::XML out of the response" do
|
35
|
+
Nokogiri.should_receive(:XML).with(@response)
|
36
|
+
EarthTools.get('timezone')
|
37
|
+
end
|
38
|
+
it "should return a EarthTools::XML::Element build from the Nokogiri document" do
|
39
|
+
Nokogiri.stub!(:XML).and_return('xml')
|
40
|
+
EarthTools::XML::Element.should_receive(:new).with('xml').and_return('earth tools element')
|
41
|
+
EarthTools.get('timezone').should == 'earth tools element'
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
describe ".timezone" do
|
46
|
+
it "should do a get request to the timezone service" do
|
47
|
+
EarthTools.should_receive(:get).with('timezone', anything, anything, anything)
|
48
|
+
EarthTools.timezone('latitude' => '1.1', 'longitude' => '2.1')
|
49
|
+
end
|
50
|
+
it "should do a get request to the timezone service with the version when passed" do
|
51
|
+
EarthTools.should_receive(:get).with('timezone', '1.0', anything, anything)
|
52
|
+
EarthTools.timezone('latitude' => '1.1', 'longitude' => '2.1', 'version' => '1.0')
|
53
|
+
end
|
54
|
+
it "should pass the latitude and longitude to the get method in order" do
|
55
|
+
EarthTools.should_receive(:get).with('timezone', '1.0', '1.1', '2.1')
|
56
|
+
EarthTools.timezone('latitude' => '1.1', 'longitude' => '2.1', 'version' => '1.0')
|
57
|
+
end
|
58
|
+
it "should allow symbols as param keys" do
|
59
|
+
EarthTools.should_receive(:get).with('timezone', '1.0', '1.1', '2.1')
|
60
|
+
EarthTools.timezone(:latitude => '1.1', :longitude => '2.1', :version => '1.0')
|
61
|
+
end
|
62
|
+
it "should allow numbers as param values" do
|
63
|
+
EarthTools.should_receive(:get).with('timezone', '1.0', '1.1', '2.1')
|
64
|
+
EarthTools.timezone(:latitude => 1.1, :longitude => 2.1, :version => 1.0)
|
65
|
+
end
|
66
|
+
it "should return a timezone built from the get response" do
|
67
|
+
EarthTools.should_receive(:get).and_return('response')
|
68
|
+
EarthTools::Timezone.should_receive(:new).with('response').and_return('timezone')
|
69
|
+
EarthTools.timezone(:latitude => 1.1, :longitude => 2.1, :version => 1.0).should == 'timezone'
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
describe ".sun" do
|
74
|
+
it "should do a get request to the sun service" do
|
75
|
+
EarthTools.should_receive(:get).with('sun', anything, anything, anything, anything, anything, anything, anything)
|
76
|
+
EarthTools.sun('latitude' => '1.1', 'longitude' => '2.1', 'day' => '1', 'month' => '12', 'timezone' => '-4', 'dst' => '0')
|
77
|
+
end
|
78
|
+
it "should do a get request to the sun service with the version when passed" do
|
79
|
+
EarthTools.should_receive(:get).with('sun', '1.0', anything, anything, anything, anything, anything, anything)
|
80
|
+
EarthTools.sun('latitude' => '1.1', 'longitude' => '2.1', 'day' => '1', 'month' => '12', 'timezone' => '-4', 'dst' => '0', 'version' => '1.0')
|
81
|
+
end
|
82
|
+
it "should pass the params to the get method in order" do
|
83
|
+
EarthTools.should_receive(:get).with('sun', '1.0', '1.1', '2.1', '1', '12', '-4', '0')
|
84
|
+
EarthTools.sun('latitude' => '1.1', 'longitude' => '2.1', 'day' => '1', 'month' => '12', 'timezone' => '-4', 'dst' => '0', 'version' => '1.0')
|
85
|
+
end
|
86
|
+
it "should allow symbols as param keys" do
|
87
|
+
EarthTools.should_receive(:get).with('sun', '1.0', '1.1', '2.1', '1', '12', '-4', '0')
|
88
|
+
EarthTools.sun(:latitude => '1.1', :longitude => '2.1', :day => '1', :month => '12', :timezone => '-4', :dst => '0', :version => '1.0')
|
89
|
+
end
|
90
|
+
it "should all numbers as param values" do
|
91
|
+
EarthTools.should_receive(:get).with('sun', '1.0', '1.1', '2.1', '1', '12', '-4', '0')
|
92
|
+
EarthTools.sun(:latitude => 1.1, :longitude => 2.1, :day => 1, :month => 12, :timezone => -4, :dst => 0, :version => 1.0)
|
93
|
+
end
|
94
|
+
it "should return a Sun built from the get response" do
|
95
|
+
EarthTools.should_receive(:get).and_return('response')
|
96
|
+
EarthTools::Sun.should_receive(:new).with('response').and_return('sun')
|
97
|
+
EarthTools.sun(:latitude => 1.1, :longitude => 2.1, :day => 1, :month => 12, :timezone => -4, :dst => 0, :version => 1.0).should == 'sun'
|
98
|
+
end
|
99
|
+
it "should default the timezone as '99' if not passed" do
|
100
|
+
EarthTools.should_receive(:get).with('sun', '1.0', '1.1', '2.1', '1', '12', '99', '0')
|
101
|
+
EarthTools.sun(:latitude => 1.1, :longitude => 2.1, :day => 1, :month => 12, :dst => 0, :version => 1.0)
|
102
|
+
end
|
103
|
+
it "should default the dst to '0' if not passed" do
|
104
|
+
EarthTools.should_receive(:get).with('sun', '1.0', '1.1', '2.1', '1', '12', '99', '0')
|
105
|
+
EarthTools.sun(:latitude => 1.1, :longitude => 2.1, :day => 1, :month => 12, :version => 1.0)
|
106
|
+
end
|
107
|
+
end
|
108
|
+
|
109
|
+
describe ".height" do
|
110
|
+
it "should do a get request to the height service" do
|
111
|
+
EarthTools.should_receive(:get).with('height', anything, anything, anything)
|
112
|
+
EarthTools.height('latitude' => '1.1', 'longitude' => '2.1')
|
113
|
+
end
|
114
|
+
it "should do a get request to the height service with the version when passed" do
|
115
|
+
EarthTools.should_receive(:get).with('height', '1.0', anything, anything)
|
116
|
+
EarthTools.height('latitude' => '1.1', 'longitude' => '2.1', 'version' => '1.0')
|
117
|
+
end
|
118
|
+
it "should pass the latitude and longitude to the get method in order" do
|
119
|
+
EarthTools.should_receive(:get).with('height', '1.0', '1.1', '2.1')
|
120
|
+
EarthTools.height('latitude' => '1.1', 'longitude' => '2.1', 'version' => '1.0')
|
121
|
+
end
|
122
|
+
it "should allow symbols as param keys" do
|
123
|
+
EarthTools.should_receive(:get).with('height', '1.0', '1.1', '2.1')
|
124
|
+
EarthTools.height(:latitude => '1.1', :longitude => '2.1', :version => '1.0')
|
125
|
+
end
|
126
|
+
it "should allow numbers as param values" do
|
127
|
+
EarthTools.should_receive(:get).with('height', '1.0', '1.1', '2.1')
|
128
|
+
EarthTools.height(:latitude => 1.1, :longitude => 2.1, :version => 1.0)
|
129
|
+
end
|
130
|
+
it "should return a height built from the get response" do
|
131
|
+
EarthTools.should_receive(:get).and_return('response')
|
132
|
+
EarthTools::Height.should_receive(:new).with('response').and_return('height')
|
133
|
+
EarthTools.height(:latitude => 1.1, :longitude => 2.1, :version => 1.0).should == 'height'
|
134
|
+
end
|
135
|
+
end
|
136
|
+
end
|
data/spec/spec.opts
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--colour
|
data/spec/spec_helper.rb
ADDED
data/tasks/rspec.rake
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
begin
|
2
|
+
require 'spec'
|
3
|
+
rescue LoadError
|
4
|
+
require 'rubygems'
|
5
|
+
require 'spec'
|
6
|
+
end
|
7
|
+
begin
|
8
|
+
require 'spec/rake/spectask'
|
9
|
+
rescue LoadError
|
10
|
+
puts <<-EOS
|
11
|
+
To use rspec for testing you must install rspec gem:
|
12
|
+
gem install rspec
|
13
|
+
EOS
|
14
|
+
exit(0)
|
15
|
+
end
|
16
|
+
|
17
|
+
desc "Run the specs under spec/models"
|
18
|
+
Spec::Rake::SpecTask.new do |t|
|
19
|
+
t.spec_opts = ['--options', "spec/spec.opts"]
|
20
|
+
t.spec_files = FileList['spec/**/*_spec.rb']
|
21
|
+
end
|
metadata
ADDED
@@ -0,0 +1,117 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: earth-tools
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Phil Sergi
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2009-07-02 00:00:00 -04:00
|
13
|
+
default_executable:
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: nokogiri
|
17
|
+
type: :runtime
|
18
|
+
version_requirement:
|
19
|
+
version_requirements: !ruby/object:Gem::Requirement
|
20
|
+
requirements:
|
21
|
+
- - ">="
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: 1.2.3
|
24
|
+
version:
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: newgem
|
27
|
+
type: :development
|
28
|
+
version_requirement:
|
29
|
+
version_requirements: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 1.2.1
|
34
|
+
version:
|
35
|
+
- !ruby/object:Gem::Dependency
|
36
|
+
name: hoe
|
37
|
+
type: :development
|
38
|
+
version_requirement:
|
39
|
+
version_requirements: !ruby/object:Gem::Requirement
|
40
|
+
requirements:
|
41
|
+
- - ">="
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: 1.8.0
|
44
|
+
version:
|
45
|
+
description: EarthTools.org Web Services Library
|
46
|
+
email:
|
47
|
+
- phil.sergi@gmail.com
|
48
|
+
executables: []
|
49
|
+
|
50
|
+
extensions: []
|
51
|
+
|
52
|
+
extra_rdoc_files:
|
53
|
+
- History.txt
|
54
|
+
- Manifest.txt
|
55
|
+
- README.rdoc
|
56
|
+
files:
|
57
|
+
- History.txt
|
58
|
+
- Manifest.txt
|
59
|
+
- README.rdoc
|
60
|
+
- Rakefile
|
61
|
+
- lib/earth_tools.rb
|
62
|
+
- lib/earth_tools/date.rb
|
63
|
+
- lib/earth_tools/height.rb
|
64
|
+
- lib/earth_tools/location.rb
|
65
|
+
- lib/earth_tools/sun.rb
|
66
|
+
- lib/earth_tools/sun/evening.rb
|
67
|
+
- lib/earth_tools/sun/morning.rb
|
68
|
+
- lib/earth_tools/sun/twilight.rb
|
69
|
+
- lib/earth_tools/timezone.rb
|
70
|
+
- lib/earth_tools/xml/element.rb
|
71
|
+
- script/console
|
72
|
+
- script/destroy
|
73
|
+
- script/generate
|
74
|
+
- spec/earth_tools/date_spec.rb
|
75
|
+
- spec/earth_tools/height_spec.rb
|
76
|
+
- spec/earth_tools/location_spec.rb
|
77
|
+
- spec/earth_tools/sun/evening_spec.rb
|
78
|
+
- spec/earth_tools/sun/morning_spec.rb
|
79
|
+
- spec/earth_tools/sun/twilight_spec.rb
|
80
|
+
- spec/earth_tools/sun_spec.rb
|
81
|
+
- spec/earth_tools/timezone_spec.rb
|
82
|
+
- spec/earth_tools/xml/element_spec.rb
|
83
|
+
- spec/earth_tools_spec.rb
|
84
|
+
- spec/spec.opts
|
85
|
+
- spec/spec_helper.rb
|
86
|
+
- tasks/rspec.rake
|
87
|
+
has_rdoc: true
|
88
|
+
homepage: http://github.com/psergi/earth_tools/tree/master
|
89
|
+
licenses: []
|
90
|
+
|
91
|
+
post_install_message:
|
92
|
+
rdoc_options:
|
93
|
+
- --main
|
94
|
+
- README.rdoc
|
95
|
+
require_paths:
|
96
|
+
- lib
|
97
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
98
|
+
requirements:
|
99
|
+
- - ">="
|
100
|
+
- !ruby/object:Gem::Version
|
101
|
+
version: "0"
|
102
|
+
version:
|
103
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
104
|
+
requirements:
|
105
|
+
- - ">="
|
106
|
+
- !ruby/object:Gem::Version
|
107
|
+
version: "0"
|
108
|
+
version:
|
109
|
+
requirements: []
|
110
|
+
|
111
|
+
rubyforge_project: earth-tools
|
112
|
+
rubygems_version: 1.3.3
|
113
|
+
signing_key:
|
114
|
+
specification_version: 3
|
115
|
+
summary: EarthTools.org Web Services Library
|
116
|
+
test_files: []
|
117
|
+
|