antipodes 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f1f7eff9c48b4298fcfe0097db0e46cbfe4c6bce
4
- data.tar.gz: db893ed1e8c996442c79ee9a1df6bfeac0750900
3
+ metadata.gz: 29baacb8cf6f2c78277bfea59292f9f65a0974db
4
+ data.tar.gz: a2c961bcadc00e272f4216523579914c597b593f
5
5
  SHA512:
6
- metadata.gz: c955ecb18a31bf7d97ad111e2ed0a8665ec2c5da1df4f7c7af9110fbe55d2ef61dc9f3b2b3afe17a78069936549e3dad0a8fcf7b42c6115567c781abf471b06c
7
- data.tar.gz: 61eb34ab89f0fbb8f048e2a2ad11f16bf148ac93a943c871355102726d2761eb7b6cf02714de391dc9de172effac449b4934efe181ca875b68e4171fd060e4db
6
+ metadata.gz: c35b4b55f26bf224befcec5cc7200188599642ddf8a15bcc40c629a2a139c8f047261e227e834518d3558a1369002f203d9b582c22d35b8aefd569166f13d0ec
7
+ data.tar.gz: 393815d1d91e589773fbac99d5d6cf235dab20fe23e2c71df4fdeb3f0ae3b65e3245885e9c800408b8a250558215dfd1f8171d7f67c74d6edfed631cc79ced16
data/.gitignore CHANGED
@@ -15,3 +15,4 @@ spec/reports
15
15
  test/tmp
16
16
  test/version_tmp
17
17
  tmp
18
+ *.swp
data/README.md CHANGED
@@ -1,29 +1,23 @@
1
1
  # Antipodes
2
2
 
3
- TODO: Write a gem description
3
+ This is a silly gem of no consequence with exactly one feature: to find the
4
+ [antipodes](http://en.wikipedia.org/wiki/Antipodes) of a given place on Earth.
4
5
 
5
- ## Installation
6
+ Both latitude/longitude coordinates and place names are accepted as input. If a
7
+ place name is used, it is geocoded with the
8
+ [Geocoder](https://github.com/alexreisner/geocoder) gem.
6
9
 
7
- Add this line to your application's Gemfile:
10
+ ```ruby
11
+ Antipodes.for(47.6062095, -122.3320708) #=> [-47.6062095, 57.6679292]
8
12
 
9
- gem 'antipodes'
13
+ Antipodes.for(-47.6062095, 57.6679292) #=> [47.6062095, -122.3320708]
10
14
 
11
- And then execute:
15
+ Antipodes.for('Beijing') #=> [-39.90403, -63.592473999999996]
12
16
 
13
- $ bundle
17
+ Antipodes.for('Buenos Aires') #=> [34.6037232, 121.6184069]
18
+ ```
14
19
 
15
- Or install it yourself as:
16
-
17
- $ gem install antipodes
18
-
19
- ## Usage
20
-
21
- TODO: Write usage instructions here
22
-
23
- ## Contributing
24
-
25
- 1. Fork it
26
- 2. Create your feature branch (`git checkout -b my-new-feature`)
27
- 3. Commit your changes (`git commit -am 'Add some feature'`)
28
- 4. Push to the branch (`git push origin my-new-feature`)
29
- 5. Create new Pull Request
20
+ While it would be cool to get a corresponding place name (instead of
21
+ lat/lon), it’s neither practical (most places don’t have land antipodes, since
22
+ most of Earth is covered in water) nor possible given the current range of
23
+ geocoding options.
@@ -1,3 +1,3 @@
1
1
  module Antipodes
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
data/lib/antipodes.rb CHANGED
@@ -2,7 +2,7 @@ require 'antipodes/version'
2
2
  require 'geocoder'
3
3
 
4
4
  module Antipodes
5
- def self.new(*params)
5
+ def self.for(*params)
6
6
  latitude, longitude = params.size > 1 ? params : Geocoder.search(params.first).first.coordinates
7
7
 
8
8
  antipodal_latitude = latitude > 0 ? -latitude : latitude.abs
@@ -0,0 +1,72 @@
1
+ require 'antipodes'
2
+
3
+ describe Antipodes do
4
+ context 'with latitude and longitude' do
5
+ subject { Antipodes.for(latitude, longitude) }
6
+
7
+ context 'with positive latitude' do
8
+ let(:latitude) { 47.6062095 }
9
+
10
+ context 'with positive longitude' do
11
+ let(:longitude) { 122.3320708 }
12
+
13
+ it 'gets the antipodes' do
14
+ expect(subject).to eq([ -47.6062095, -57.6679292 ])
15
+ end
16
+ end
17
+
18
+ context 'with negative longitude' do
19
+ let(:longitude) { -122.3320708 }
20
+
21
+ it 'gets the antipodes' do
22
+ expect(subject).to eq([ -47.6062095, 57.6679292 ])
23
+ end
24
+ end
25
+ end
26
+
27
+ context 'with negative latitude' do
28
+ let(:latitude) { -47.6062095 }
29
+
30
+ context 'with positive longitude' do
31
+ let(:longitude) { 57.6679292 }
32
+
33
+ it 'gets the antipodes' do
34
+ expect(subject).to eq([ 47.6062095, -122.3320708 ])
35
+ end
36
+ end
37
+
38
+ context 'with negative longitude' do
39
+ let(:longitude) { -57.6679292 }
40
+
41
+ it 'gets the antipodes' do
42
+ expect(subject).to eq([ 47.6062095, 122.3320708 ])
43
+ end
44
+ end
45
+ end
46
+ end
47
+
48
+ context 'with place name' do
49
+ subject { Antipodes.for('Seattle') }
50
+
51
+ before do
52
+ Geocoder.configure(:lookup => :test)
53
+ Geocoder::Lookup::Test.add_stub(
54
+ 'Seattle',
55
+ [{
56
+ 'latitude' => 47.6062095,
57
+ 'longitude' => -122.3320708,
58
+ 'address' => 'Seattle, WA, USA',
59
+ 'state' => 'Washington',
60
+ 'state_code' => 'WA',
61
+ 'country' => 'United States',
62
+ 'country_code' => 'US'
63
+ }]
64
+ )
65
+ end
66
+
67
+ it 'gets the antipodes' do
68
+ expect(subject).to eq([ -47.6062095, 57.6679292 ])
69
+ end
70
+ end
71
+ end
72
+
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: antipodes
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Josh Leitzel
@@ -96,6 +96,7 @@ files:
96
96
  - antipodes.gemspec
97
97
  - lib/antipodes.rb
98
98
  - lib/antipodes/version.rb
99
+ - spec/antipodes_spec.rb
99
100
  homepage: https://github.com/joshleitzel/antipodes
100
101
  licenses:
101
102
  - MIT
@@ -120,4 +121,5 @@ rubygems_version: 2.1.10
120
121
  signing_key:
121
122
  specification_version: 4
122
123
  summary: Geographical antipodes calculator
123
- test_files: []
124
+ test_files:
125
+ - spec/antipodes_spec.rb