antipodr 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 +4 -0
- data/Gemfile +4 -0
- data/Gemfile.lock +24 -0
- data/README.md +5 -0
- data/Rakefile +2 -0
- data/antipodr.gemspec +20 -0
- data/lib/antipodr.rb +1 -0
- data/lib/antipodr/location.rb +25 -0
- data/lib/antipodr/version.rb +3 -0
- data/spec/antipodr/location_spec.rb +31 -0
- data/spec/spec_helper.rb +2 -0
- metadata +92 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
antipodr (0.0.1)
|
5
|
+
|
6
|
+
GEM
|
7
|
+
remote: http://rubygems.org/
|
8
|
+
specs:
|
9
|
+
diff-lcs (1.1.2)
|
10
|
+
rspec (2.4.0)
|
11
|
+
rspec-core (~> 2.4.0)
|
12
|
+
rspec-expectations (~> 2.4.0)
|
13
|
+
rspec-mocks (~> 2.4.0)
|
14
|
+
rspec-core (2.4.0)
|
15
|
+
rspec-expectations (2.4.0)
|
16
|
+
diff-lcs (~> 1.1.2)
|
17
|
+
rspec-mocks (2.4.0)
|
18
|
+
|
19
|
+
PLATFORMS
|
20
|
+
ruby
|
21
|
+
|
22
|
+
DEPENDENCIES
|
23
|
+
antipodr!
|
24
|
+
rspec
|
data/README.md
ADDED
data/Rakefile
ADDED
data/antipodr.gemspec
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require "antipodr/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = "antipodr"
|
7
|
+
s.version = Antipodr::VERSION
|
8
|
+
s.platform = Gem::Platform::RUBY
|
9
|
+
s.authors = ["Harold A. Giménez"]
|
10
|
+
s.email = ["harold.gimenez@gmail.com"]
|
11
|
+
s.homepage = "http://awesomeful.net"
|
12
|
+
s.summary = %q{Finds the antipodal point of anywhere on earth. }
|
13
|
+
s.description = %q{Finds the antipodal point of anywhere on earth (and beyond).}
|
14
|
+
|
15
|
+
s.files = `git ls-files`.split("\n")
|
16
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
17
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
18
|
+
s.require_paths = ["lib"]
|
19
|
+
s.add_development_dependency('rspec')
|
20
|
+
end
|
data/lib/antipodr.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require 'antipodr/location'
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module Antipodr
|
2
|
+
class Location
|
3
|
+
attr_accessor :latitude, :longitude
|
4
|
+
|
5
|
+
# Builds Location objects
|
6
|
+
#
|
7
|
+
# @param opts - a hash containing the :latitude and :longitude keys
|
8
|
+
def initialize(opts)
|
9
|
+
@latitude = opts[:latitude]
|
10
|
+
@longitude = opts[:longitude]
|
11
|
+
end
|
12
|
+
|
13
|
+
# Returns the antidopal of as a Location object
|
14
|
+
def antipodal
|
15
|
+
Location.new(:longitude => 180 - (longitude.abs),
|
16
|
+
:latitude => -latitude )
|
17
|
+
end
|
18
|
+
|
19
|
+
# A string representation of this Location,
|
20
|
+
# easy to pass to geolocation services
|
21
|
+
def to_s
|
22
|
+
"#{self.latitude},#{self.longitude}"
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module Antipodr
|
4
|
+
describe Location, '#antipodal' do
|
5
|
+
let(:latitude) { 42.3678321 }
|
6
|
+
let(:longitude) { -71.0717353 }
|
7
|
+
|
8
|
+
subject { Location.new(:latitude => latitude, :longitude => longitude) }
|
9
|
+
|
10
|
+
it 'converts the longitude by adding 180 degrees' do
|
11
|
+
subject.antipodal.longitude.should == 108.9282647
|
12
|
+
end
|
13
|
+
|
14
|
+
it 'converts the latitude by inverting it' do
|
15
|
+
subject.antipodal.latitude.should == -42.3678321
|
16
|
+
end
|
17
|
+
|
18
|
+
it 'returns a Location object' do
|
19
|
+
subject.antipodal.should be_kind_of Location
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
describe Location, 'to_s' do
|
24
|
+
let(:latitude) { 42.3678321 }
|
25
|
+
let(:longitude) { -71.0717353 }
|
26
|
+
|
27
|
+
subject { Location.new(:latitude => latitude, :longitude => longitude) }
|
28
|
+
|
29
|
+
its(:to_s) { should == "#{latitude},#{longitude}" }
|
30
|
+
end
|
31
|
+
end
|
data/spec/spec_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,92 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: antipodr
|
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
|
+
- "Harold A. Gim\xC3\xA9nez"
|
14
|
+
autorequire:
|
15
|
+
bindir: bin
|
16
|
+
cert_chain: []
|
17
|
+
|
18
|
+
date: 2011-01-03 00:00:00 -05:00
|
19
|
+
default_executable:
|
20
|
+
dependencies:
|
21
|
+
- !ruby/object:Gem::Dependency
|
22
|
+
name: rspec
|
23
|
+
prerelease: false
|
24
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ">="
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
hash: 3
|
30
|
+
segments:
|
31
|
+
- 0
|
32
|
+
version: "0"
|
33
|
+
type: :development
|
34
|
+
version_requirements: *id001
|
35
|
+
description: Finds the antipodal point of anywhere on earth (and beyond).
|
36
|
+
email:
|
37
|
+
- harold.gimenez@gmail.com
|
38
|
+
executables: []
|
39
|
+
|
40
|
+
extensions: []
|
41
|
+
|
42
|
+
extra_rdoc_files: []
|
43
|
+
|
44
|
+
files:
|
45
|
+
- .gitignore
|
46
|
+
- Gemfile
|
47
|
+
- Gemfile.lock
|
48
|
+
- README.md
|
49
|
+
- Rakefile
|
50
|
+
- antipodr.gemspec
|
51
|
+
- lib/antipodr.rb
|
52
|
+
- lib/antipodr/location.rb
|
53
|
+
- lib/antipodr/version.rb
|
54
|
+
- spec/antipodr/location_spec.rb
|
55
|
+
- spec/spec_helper.rb
|
56
|
+
has_rdoc: true
|
57
|
+
homepage: http://awesomeful.net
|
58
|
+
licenses: []
|
59
|
+
|
60
|
+
post_install_message:
|
61
|
+
rdoc_options: []
|
62
|
+
|
63
|
+
require_paths:
|
64
|
+
- lib
|
65
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
66
|
+
none: false
|
67
|
+
requirements:
|
68
|
+
- - ">="
|
69
|
+
- !ruby/object:Gem::Version
|
70
|
+
hash: 3
|
71
|
+
segments:
|
72
|
+
- 0
|
73
|
+
version: "0"
|
74
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
75
|
+
none: false
|
76
|
+
requirements:
|
77
|
+
- - ">="
|
78
|
+
- !ruby/object:Gem::Version
|
79
|
+
hash: 3
|
80
|
+
segments:
|
81
|
+
- 0
|
82
|
+
version: "0"
|
83
|
+
requirements: []
|
84
|
+
|
85
|
+
rubyforge_project:
|
86
|
+
rubygems_version: 1.4.1
|
87
|
+
signing_key:
|
88
|
+
specification_version: 3
|
89
|
+
summary: Finds the antipodal point of anywhere on earth.
|
90
|
+
test_files:
|
91
|
+
- spec/antipodr/location_spec.rb
|
92
|
+
- spec/spec_helper.rb
|