usno-transit 0.0.3 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +51 -2
- data/lib/usno/transit.rb +56 -65
- data/lib/usno/transit/bodies.rb +28 -0
- data/lib/usno/transit/request.rb +34 -0
- data/lib/usno/transit/us_request.rb +4 -26
- data/lib/usno/transit/version.rb +1 -1
- data/lib/usno/transit/worldwide_request.rb +69 -0
- data/test/test_helper.rb +0 -1
- data/test/unit/usno/transit/sun_test.rb +17 -0
- data/test/unit/usno/transit/us_request_test.rb +3 -2
- data/test/unit/usno/transit/view_test.rb +17 -0
- data/test/unit/usno/transit/worldwide_request_test.rb +36 -0
- metadata +9 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cb42793643eef25bb88a643954833e25c1fca9e3
|
4
|
+
data.tar.gz: eccaa1574e6b2ef64573c2fb85f5cd1b631f10ed
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2601b7b13654c916b0299ade6b6b3c3b3b07c19a4c5fad8706e003b8beb7e4c6a63ff063a85ba6a0201bae439fb9034694c6c605f3f6fb77c55073b8ced919be
|
7
|
+
data.tar.gz: 31f5aad67d0ca19afabb846369dbee618cd2006804493313a37b0627da837e6b8ce27a1cb2ee04f20681cf3cb045250be011a64b4ca52c4cd89ee02b31b33ae4
|
data/README.md
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
# Usno::Transit [![Code Climate](https://codeclimate.com/github/rthbound/usno-transit.png)](https://codeclimate.com/github/rthbound/usno-transit)[![Coverage Status](https://coveralls.io/repos/rthbound/usno-transit/badge.png)](https://coveralls.io/r/rthbound/usno-transit)[![Build Status](https://travis-ci.org/rthbound/usno-transit.png?branch=master)](https://travis-ci.org/rthbound/usno-transit)
|
2
2
|
|
3
|
+
This project now supports USNO Rise/Set/Transit Form B (Locations Worldwide). Notes on usage can be found below.
|
4
|
+
|
3
5
|
## Installation
|
4
6
|
|
5
7
|
Add this line to your application's Gemfile:
|
@@ -14,10 +16,11 @@ Or install it yourself as:
|
|
14
16
|
|
15
17
|
$ gem install usno-transit
|
16
18
|
|
17
|
-
## Usage
|
19
|
+
## Usage (US Locations)
|
18
20
|
|
19
21
|
```ruby
|
20
22
|
require "usno/transit"
|
23
|
+
|
21
24
|
USNO::Transit::Sun.new(city: "Birmingham", state: "AL").call.data
|
22
25
|
```
|
23
26
|
|
@@ -56,13 +59,59 @@ the output of the above call will look something like the following
|
|
56
59
|
</html>
|
57
60
|
```
|
58
61
|
|
62
|
+
## Usage (US Locations)
|
63
|
+
|
64
|
+
```ruby
|
65
|
+
require "usno/transit"
|
66
|
+
|
67
|
+
# Just override the default :request_class options and provide a longitude/latitude
|
68
|
+
# For a more precise location, you can provide :long_minutes, :lat_minutes,
|
69
|
+
# :long_seconds, and :lat_seconds
|
70
|
+
USNO::Transit::Sun.new(lat: 0, long: 0, request_class: USNO::Transit::WorldwideRequest).call.data
|
71
|
+
```
|
72
|
+
|
73
|
+
The output from the above command should return something like the following
|
74
|
+
|
75
|
+
```html
|
76
|
+
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
77
|
+
<html>
|
78
|
+
<head>
|
79
|
+
<title>Rise/Set/Transit Table</title>
|
80
|
+
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
|
81
|
+
</head>
|
82
|
+
<body>
|
83
|
+
<pre>
|
84
|
+
Sun
|
85
|
+
|
86
|
+
|
87
|
+
Location: 0°00'00.0", 0°00'00.0", 0m
|
88
|
+
(Longitude referred to Greenwich meridian)
|
89
|
+
|
90
|
+
Time Zone: Greenwich
|
91
|
+
|
92
|
+
Date Begin Rise Az. Transit Alt. Set Az. End
|
93
|
+
(Zone) Civil Civil
|
94
|
+
Twilight Twilight
|
95
|
+
h m h m ° h m ° h m ° h m
|
96
|
+
2013 Nov 24 (Sun) 05:21 05:43 111 11:47 69S 17:50 249 18:12
|
97
|
+
2013 Nov 25 (Mon) 05:21 05:43 111 11:47 69S 17:51 249 18:13
|
98
|
+
2013 Nov 26 (Tue) 05:22 05:44 111 11:47 69S 17:51 249 18:13
|
99
|
+
2013 Nov 27 (Wed) 05:22 05:44 111 11:48 69S 17:51 249 18:14
|
100
|
+
2013 Nov 28 (Thu) 05:22 05:44 111 11:48 69S 17:52 249 18:14
|
101
|
+
|
102
|
+
</pre>
|
103
|
+
<p><a href="javascript:history.go(-1)">Back to form</a></p>
|
104
|
+
</body>
|
105
|
+
</html>
|
106
|
+
```
|
107
|
+
|
59
108
|
## Other USNO libraries
|
60
109
|
|
61
110
|
[usno-imagery](http://github.com/rthbound/usno-transit) builds URLs for consuming USNO's imagery data services. These services provide synthetic views of earth and other selected solar system bodies.
|
62
111
|
|
63
112
|
## Contributing
|
64
113
|
|
65
|
-
If anyone wants to have a go at parsing the text/html output into JSON and/or CSV format (for graphing purposes), have at it!
|
114
|
+
If anyone wants to have a go at parsing the text/html output into JSON and/or CSV format (for graphing purposes), have at it! If not, I'll get to it soon enough :)
|
66
115
|
|
67
116
|
1. Fork it
|
68
117
|
2. Create your feature branch (`git checkout -b my-new-feature`)
|
data/lib/usno/transit.rb
CHANGED
@@ -1,85 +1,76 @@
|
|
1
1
|
require "pay_dirt"
|
2
2
|
require_relative "transit/version"
|
3
3
|
require_relative "transit/states"
|
4
|
+
require_relative "transit/bodies"
|
5
|
+
|
6
|
+
require_relative "transit/request"
|
4
7
|
require_relative "transit/us_request"
|
8
|
+
require_relative "transit/worldwide_request"
|
5
9
|
|
6
10
|
module USNO
|
7
11
|
module Transit
|
8
|
-
BODIES = {
|
9
|
-
"Sun" => 10, "Moon" => 11, "Mercury" => 1,
|
10
|
-
"Venus" => 2,"Jupiter" => 5, "Mars" => 4,
|
11
|
-
"Saturn" => 6, "Uranus" => 7, "Neptune" => 8,
|
12
|
-
"Pluto" => 9, "Achernar" => -1, "Adhara" => -2,
|
13
|
-
"Aldebaran" => -3, "Altair" => -4, "Antares" => -5,
|
14
|
-
"Arcturus" => -6, "Betelgeuse" => -7, "Canopus" => -8,
|
15
|
-
"Capella" => -9, "Deneb" => -10, "Fomalhaut" => -11,
|
16
|
-
"Hadar" => -12, "Mimosa" => -13, "Polaris" => -14,
|
17
|
-
"Pollux" => -15, "Procyon" => -16, "Regulus" => -17,
|
18
|
-
"Rigel" => -18, "RigilKentaurus" => -19, "Vega" => -22,
|
19
|
-
"Sirius" => -20, "Spica" => -21,
|
20
|
-
}
|
21
|
-
|
22
12
|
class View < PayDirt::Base
|
23
13
|
def initialize(options = {})
|
24
|
-
raise "Cannot instantiate this class directly" if self.class.name
|
14
|
+
raise "Cannot instantiate this class directly" if self.class.name.to_s =~ /View/
|
25
15
|
|
26
|
-
|
27
|
-
options = {
|
28
|
-
request_class: USNO::Transit::USRequest,
|
29
|
-
object: USNO::Transit::BODIES.fetch(self.class.name.split("::")[-1]) {
|
30
|
-
raise "Celestial object not recognized"
|
31
|
-
},
|
32
|
-
z_meters: 0,
|
33
|
-
date: Time.now,
|
34
|
-
days: 5,
|
35
|
-
}.merge(options)
|
16
|
+
options = form_options(options)
|
36
17
|
|
37
|
-
load_options(
|
18
|
+
load_options(options)
|
38
19
|
end
|
39
20
|
|
40
21
|
def call
|
41
|
-
result(true, @request_class.new(
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
22
|
+
result(true, @request_class.new(@request_options).call.data)
|
23
|
+
end
|
24
|
+
|
25
|
+
private
|
26
|
+
def form_options(options)
|
27
|
+
options = {
|
28
|
+
request_class: USNO::Transit::USRequest,
|
29
|
+
object: USNO::Transit::Bodies.fetch(self.class.name.to_s.split("::")[-1]),
|
30
|
+
z_meters: 0,
|
31
|
+
date: Time.now,
|
32
|
+
days: 5,
|
33
|
+
}.merge(options)
|
34
|
+
|
35
|
+
options.merge!({
|
36
|
+
request_options: options.reject do |k,_|
|
37
|
+
k.to_s == "request_class"
|
38
|
+
end
|
39
|
+
})
|
49
40
|
end
|
50
41
|
end
|
51
42
|
|
52
|
-
class Sun
|
53
|
-
class Moon
|
54
|
-
class Mercury
|
55
|
-
class Venus
|
56
|
-
class Mars
|
57
|
-
class Jupiter
|
58
|
-
class Saturn
|
59
|
-
class Uranus
|
60
|
-
class Neptune
|
61
|
-
class Pluto
|
62
|
-
class Achernar
|
63
|
-
class Adhara
|
64
|
-
class Aldebaran
|
65
|
-
class Altair
|
66
|
-
class Antares
|
67
|
-
class Arcturus
|
68
|
-
class Betelgeuse
|
69
|
-
class Canopus
|
70
|
-
class Capella
|
71
|
-
class Deneb
|
72
|
-
class Fomalhaut
|
73
|
-
class Hadar
|
74
|
-
class Mimosa
|
75
|
-
class Polaris
|
76
|
-
class Pollux
|
77
|
-
class Procyon
|
78
|
-
class Regulus
|
79
|
-
class Rigel
|
43
|
+
class Sun < View;end
|
44
|
+
class Moon < View;end
|
45
|
+
class Mercury < View;end
|
46
|
+
class Venus < View;end
|
47
|
+
class Mars < View;end
|
48
|
+
class Jupiter < View;end
|
49
|
+
class Saturn < View;end
|
50
|
+
class Uranus < View;end
|
51
|
+
class Neptune < View;end
|
52
|
+
class Pluto < View;end
|
53
|
+
class Achernar < View;end
|
54
|
+
class Adhara < View;end
|
55
|
+
class Aldebaran < View;end
|
56
|
+
class Altair < View;end
|
57
|
+
class Antares < View;end
|
58
|
+
class Arcturus < View;end
|
59
|
+
class Betelgeuse < View;end
|
60
|
+
class Canopus < View;end
|
61
|
+
class Capella < View;end
|
62
|
+
class Deneb < View;end
|
63
|
+
class Fomalhaut < View;end
|
64
|
+
class Hadar < View;end
|
65
|
+
class Mimosa < View;end
|
66
|
+
class Polaris < View;end
|
67
|
+
class Pollux < View;end
|
68
|
+
class Procyon < View;end
|
69
|
+
class Regulus < View;end
|
70
|
+
class Rigel < View;end
|
80
71
|
class RigilKentaurus < View;end
|
81
|
-
class Sirius
|
82
|
-
class Spica
|
83
|
-
class Vega
|
72
|
+
class Sirius < View;end
|
73
|
+
class Spica < View;end
|
74
|
+
class Vega < View;end
|
84
75
|
end
|
85
76
|
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
module USNO
|
2
|
+
module Transit
|
3
|
+
module Bodies
|
4
|
+
def self.fetch(k)
|
5
|
+
self.hash.fetch(k) {
|
6
|
+
raise "Celestial object not recognized - #{k} not found in #{self.hash.keys.join(', ')}"
|
7
|
+
}
|
8
|
+
end
|
9
|
+
|
10
|
+
|
11
|
+
def self.hash
|
12
|
+
{
|
13
|
+
"Sun" => 10, "Moon" => 11, "Mercury" => 1,
|
14
|
+
"Venus" => 2,"Jupiter" => 5, "Mars" => 4,
|
15
|
+
"Saturn" => 6, "Uranus" => 7, "Neptune" => 8,
|
16
|
+
"Pluto" => 9, "Achernar" => -1, "Adhara" => -2,
|
17
|
+
"Aldebaran" => -3, "Altair" => -4, "Antares" => -5,
|
18
|
+
"Arcturus" => -6, "Betelgeuse" => -7, "Canopus" => -8,
|
19
|
+
"Capella" => -9, "Deneb" => -10, "Fomalhaut" => -11,
|
20
|
+
"Hadar" => -12, "Mimosa" => -13, "Polaris" => -14,
|
21
|
+
"Pollux" => -15, "Procyon" => -16, "Regulus" => -17,
|
22
|
+
"Rigel" => -18, "RigilKentaurus" => -19, "Vega" => -22,
|
23
|
+
"Sirius" => -20, "Spica" => -21,
|
24
|
+
}
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
require "uri"
|
2
|
+
require "net/http"
|
3
|
+
|
4
|
+
module USNO
|
5
|
+
module Transit
|
6
|
+
module Request
|
7
|
+
private
|
8
|
+
def request_response
|
9
|
+
response = Net::HTTP.start(@uri.host) do |http|
|
10
|
+
request = Net::HTTP::Post.new(@uri.path)
|
11
|
+
|
12
|
+
http_headers.map { |k, v| request[k] = v }
|
13
|
+
request.body = request_body
|
14
|
+
|
15
|
+
http.request request
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
def start_date
|
20
|
+
@date.strftime("xxy=%Y&xxm=%m&xxd=%d")
|
21
|
+
end
|
22
|
+
|
23
|
+
def http_headers
|
24
|
+
{
|
25
|
+
"Accept" => "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8",
|
26
|
+
"Accept-Language" => "en-US,en;q=0.5",
|
27
|
+
"Accept-Encoding" => "gzip, deflate",
|
28
|
+
"Referer" => "http://aa.usno.navy.mil/data/docs/mrst.php"
|
29
|
+
}
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
@@ -4,6 +4,8 @@ require "net/http"
|
|
4
4
|
module USNO
|
5
5
|
module Transit
|
6
6
|
class USRequest < PayDirt::Base
|
7
|
+
include USNO::Transit::Request
|
8
|
+
|
7
9
|
def initialize(options = {})
|
8
10
|
options = {
|
9
11
|
z_meters: 0,
|
@@ -12,7 +14,7 @@ module USNO
|
|
12
14
|
uri: URI.parse("http://aa.usno.navy.mil/cgi-bin/aa_mrst2.pl")
|
13
15
|
}.merge(options)
|
14
16
|
|
15
|
-
load_options(:city, :state, :days, :date, :
|
17
|
+
load_options(:city, :state, :days, :date, :object, options)
|
16
18
|
end
|
17
19
|
|
18
20
|
def call
|
@@ -20,21 +22,6 @@ module USNO
|
|
20
22
|
end
|
21
23
|
|
22
24
|
private
|
23
|
-
def request_response
|
24
|
-
response = Net::HTTP.start(@uri.host) do |http|
|
25
|
-
request = Net::HTTP::Post.new(@uri.path)
|
26
|
-
|
27
|
-
http_headers.map { |k, v| request[k] = v }
|
28
|
-
request.body = request_body
|
29
|
-
|
30
|
-
http.request request
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
|
-
def start_date
|
35
|
-
@date.strftime("xxy=%Y&xxm=%m&xxd=%d")
|
36
|
-
end
|
37
|
-
|
38
25
|
def place
|
39
26
|
"st=#{@state}&place=#{@city}&hh1=#{@z_meters}"
|
40
27
|
end
|
@@ -45,20 +32,11 @@ module USNO
|
|
45
32
|
ID=AA
|
46
33
|
#{start_date}
|
47
34
|
rep=#{@days}
|
48
|
-
obj=#{@
|
35
|
+
obj=#{@object}
|
49
36
|
#{place}
|
50
37
|
ZZZ=END
|
51
38
|
}.join("&")
|
52
39
|
end
|
53
|
-
|
54
|
-
def http_headers
|
55
|
-
{
|
56
|
-
"Accept" => "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8",
|
57
|
-
"Accept-Language" => "en-US,en;q=0.5",
|
58
|
-
"Accept-Encoding" => "gzip, deflate",
|
59
|
-
"Referer" => "http://aa.usno.navy.mil/data/docs/mrst.php"
|
60
|
-
}
|
61
|
-
end
|
62
40
|
end
|
63
41
|
end
|
64
42
|
end
|
data/lib/usno/transit/version.rb
CHANGED
@@ -0,0 +1,69 @@
|
|
1
|
+
require "uri"
|
2
|
+
require "net/http"
|
3
|
+
|
4
|
+
module USNO
|
5
|
+
module Transit
|
6
|
+
class WorldWideRequest < PayDirt::Base
|
7
|
+
include USNO::Transit::Request
|
8
|
+
|
9
|
+
def initialize(options = {})
|
10
|
+
options = {
|
11
|
+
uri: URI.parse("http://aa.usno.navy.mil/cgi-bin/aa_mrst2.pl"),
|
12
|
+
z_meters: 0,
|
13
|
+
days: 5,
|
14
|
+
date: Time.now,
|
15
|
+
lat_minutes: 0, lat_seconds: 0, long_minutes: 0, long_seconds: 0
|
16
|
+
}.merge(options)
|
17
|
+
|
18
|
+
|
19
|
+
load_options(:long, :lat, :days, :date, :object, options)
|
20
|
+
end
|
21
|
+
|
22
|
+
def call
|
23
|
+
return result(true, request_response.body)
|
24
|
+
end
|
25
|
+
|
26
|
+
private
|
27
|
+
def place
|
28
|
+
%W{
|
29
|
+
place=#{ @place || @city || "None given" }
|
30
|
+
#{elevation}
|
31
|
+
#{coordinates}
|
32
|
+
}.join("&")
|
33
|
+
end
|
34
|
+
|
35
|
+
def elevation
|
36
|
+
"hh1=#{@z_meters}"
|
37
|
+
end
|
38
|
+
|
39
|
+
def coordinates
|
40
|
+
%W{
|
41
|
+
xx0=#{ sign_of(@long) }
|
42
|
+
xx1=#{ @long }
|
43
|
+
xx2=#{ @long_minutes }
|
44
|
+
xx3=#{ @long_seconds }
|
45
|
+
yy1=#{ @lat }
|
46
|
+
yy2=#{ @lat_minutes }
|
47
|
+
yy3=#{ @lat_seconds }
|
48
|
+
yy0=#{ sign_of(@lat) }
|
49
|
+
}.join("&")
|
50
|
+
end
|
51
|
+
|
52
|
+
def sign_of(int)
|
53
|
+
int.zero? ? int.next : int / int.abs
|
54
|
+
end
|
55
|
+
|
56
|
+
def request_body
|
57
|
+
%W{
|
58
|
+
FFX=2
|
59
|
+
ID=AA
|
60
|
+
#{place}
|
61
|
+
#{start_date}
|
62
|
+
rep=#{@days}
|
63
|
+
obj=#{@object}
|
64
|
+
ZZZ=END
|
65
|
+
}.join("&")
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
data/test/test_helper.rb
CHANGED
@@ -0,0 +1,17 @@
|
|
1
|
+
require "test_helper"
|
2
|
+
|
3
|
+
describe USNO::Transit::Sun do
|
4
|
+
before do
|
5
|
+
@subject = USNO::Transit::Sun
|
6
|
+
end
|
7
|
+
|
8
|
+
describe "calling for data" do
|
9
|
+
it "will raise without location dependencies" do
|
10
|
+
-> { @subject.new.call }.must_raise RuntimeError
|
11
|
+
end
|
12
|
+
|
13
|
+
it "wont raise with location dependencies" do
|
14
|
+
@subject.new(city: "Birmingham", state: "Alabama").call.must_respond_to :data
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -5,11 +5,11 @@ describe USNO::Transit::USRequest do
|
|
5
5
|
@subject = USNO::Transit::USRequest
|
6
6
|
@params = {
|
7
7
|
city: "Birmingham",
|
8
|
-
state: "
|
8
|
+
state: "AL",
|
9
9
|
count: 3,
|
10
10
|
date: Time.now,
|
11
11
|
z_meters: 0,
|
12
|
-
|
12
|
+
object: "4"
|
13
13
|
}
|
14
14
|
end
|
15
15
|
|
@@ -28,6 +28,7 @@ describe USNO::Transit::USRequest do
|
|
28
28
|
it "executes successfully" do
|
29
29
|
result = @subject.new(@params).call
|
30
30
|
result.successful?.must_equal true
|
31
|
+
result.data.must_include("BIRMINGHAM, AL")
|
31
32
|
result.must_be_kind_of PayDirt::Result
|
32
33
|
end
|
33
34
|
end
|
@@ -1,7 +1,24 @@
|
|
1
1
|
require "test_helper"
|
2
|
+
include Minitest::Assertions
|
2
3
|
|
3
4
|
describe USNO::Transit::View do
|
4
5
|
it "cannot be instantiated directly" do
|
5
6
|
-> { USNO::Transit::View.new }.must_raise RuntimeError
|
6
7
|
end
|
8
|
+
|
9
|
+
describe "being instantiated by a valid subclass" do
|
10
|
+
before do
|
11
|
+
@valid_subclasses = USNO::Transit::Bodies.hash.keys
|
12
|
+
end
|
13
|
+
|
14
|
+
it "instantiates for each valid subclass" do
|
15
|
+
@valid_subclasses.each do |k|
|
16
|
+
@subject = instance_eval("USNO::Transit::#{k}")
|
17
|
+
|
18
|
+
assert_instance_of(@subject, @subject.new)
|
19
|
+
|
20
|
+
@subject.new.must_respond_to :call, "should respond to #call"
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
7
24
|
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
describe USNO::Transit::WorldWideRequest do
|
4
|
+
before do
|
5
|
+
@subject = USNO::Transit::WorldWideRequest
|
6
|
+
@params = {
|
7
|
+
city: "Greenwich Test",
|
8
|
+
count: 3,
|
9
|
+
date: Time.now,
|
10
|
+
z_meters: 0,
|
11
|
+
long: 0,
|
12
|
+
lat: 0,
|
13
|
+
object: "4"
|
14
|
+
}
|
15
|
+
end
|
16
|
+
|
17
|
+
describe "as a class" do
|
18
|
+
it "initializes properly" do
|
19
|
+
@subject.new(@params).must_respond_to :call
|
20
|
+
end
|
21
|
+
|
22
|
+
it "errors when initialized without required dependencies" do
|
23
|
+
-> { @subject.new(@params.reject { |k| k.to_s == 'lat' }) }.must_raise RuntimeError
|
24
|
+
-> { @subject.new(@params.reject { |k| k.to_s == 'long' }) }.must_raise RuntimeError
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
describe "as an instance" do
|
29
|
+
it "executes successfully" do
|
30
|
+
result = @subject.new(@params).call
|
31
|
+
result.successful?.must_equal true
|
32
|
+
result.data.must_include "Greenwich Test"
|
33
|
+
result.must_be_kind_of PayDirt::Result
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: usno-transit
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ryan T. Hosford
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-11-
|
11
|
+
date: 2013-11-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -95,12 +95,17 @@ files:
|
|
95
95
|
- README.md
|
96
96
|
- Rakefile
|
97
97
|
- lib/usno/transit.rb
|
98
|
+
- lib/usno/transit/bodies.rb
|
99
|
+
- lib/usno/transit/request.rb
|
98
100
|
- lib/usno/transit/states.rb
|
99
101
|
- lib/usno/transit/us_request.rb
|
100
102
|
- lib/usno/transit/version.rb
|
103
|
+
- lib/usno/transit/worldwide_request.rb
|
101
104
|
- test/test_helper.rb
|
105
|
+
- test/unit/usno/transit/sun_test.rb
|
102
106
|
- test/unit/usno/transit/us_request_test.rb
|
103
107
|
- test/unit/usno/transit/view_test.rb
|
108
|
+
- test/unit/usno/transit/worldwide_request_test.rb
|
104
109
|
- usno-transit.gemspec
|
105
110
|
homepage: http://github.com/rthbound/usno-transit
|
106
111
|
licenses:
|
@@ -129,5 +134,7 @@ summary: Consumes USNO resources to return times of rise, set, and transit for t
|
|
129
134
|
major solar system bodies and selected bright stars.
|
130
135
|
test_files:
|
131
136
|
- test/test_helper.rb
|
137
|
+
- test/unit/usno/transit/sun_test.rb
|
132
138
|
- test/unit/usno/transit/us_request_test.rb
|
133
139
|
- test/unit/usno/transit/view_test.rb
|
140
|
+
- test/unit/usno/transit/worldwide_request_test.rb
|