usno-imagery 0.0.2 → 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.
- checksums.yaml +4 -4
- data/README.md +17 -18
- data/lib/usno/imagery.rb +4 -1
- data/lib/usno/imagery/earth/map.rb +7 -18
- data/lib/usno/imagery/earth/moon.rb +27 -0
- data/lib/usno/imagery/earth/rise.rb +7 -10
- data/lib/usno/imagery/earth/set.rb +19 -1
- data/lib/usno/imagery/earth/sun.rb +27 -0
- data/lib/usno/imagery/earth/{sphere.rb → view.rb} +10 -4
- data/lib/usno/imagery/version.rb +1 -1
- data/test/test_helper.rb +10 -4
- data/test/unit/usno/imagery/earth/map_test.rb +1 -1
- data/test/unit/usno/imagery/earth/{sphere_test.rb → moon_test.rb} +3 -3
- data/test/unit/usno/imagery/earth/rise_test.rb +5 -2
- data/test/unit/usno/imagery/earth/set_test.rb +5 -2
- data/test/unit/usno/imagery/earth/sun_test.rb +24 -0
- data/test/unit/usno/imagery/earth/view_test.rb +29 -0
- data/usno-imagery.gemspec +1 -0
- metadata +25 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3111708e4b2554709cc8b5f8478d2c5bf9e2f383
|
4
|
+
data.tar.gz: 9cae9895b598cda54a7f801c442e0a20e7b2198b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e10fb7cc6dfc408b6118a047453bc679f38b33bb32e46b91d715bbfcb230590d29e047c91e4d413452084af7e533641535b06129a6558eeece60c986c8ce3b8c
|
7
|
+
data.tar.gz: 71e94813ee4bd84db37e88fb38042e23be75a0f1b29f8a143343dad1d7c46635d0f5717fc5ee3520e28dbf600f9a815f9223924ba43182a4087822878be04d03
|
data/README.md
CHANGED
@@ -18,32 +18,31 @@ Or install it yourself as:
|
|
18
18
|
|
19
19
|
## Usage
|
20
20
|
|
21
|
-
Warning! This library will be changing a lot as I explore the nooks and crannies of USNO's imagery data services.
|
22
|
-
|
23
21
|
#### USNO::Imagery::Earth
|
24
22
|
|
25
23
|
The earth namespace will contain classes for viewing USNO's earth images.
|
26
|
-
Currently there are three classes here: `Map`, `Sphere`, `Rise`, and `Set`
|
27
|
-
|
28
|
-
A view of the earth projected onto a 2D plane (at any given time):
|
29
|
-
|
30
|
-
USNO::Imagery::Earth::Map.new(time: Time.now).call.data
|
31
|
-
#=> "http://api.usno.navy.mil/imagery/earth.png?view=full&date=11/08/2013&time=20:32"
|
32
|
-
|
33
|
-
A spherical view of the earth as seen from the moon (at any given time)
|
34
24
|
|
35
|
-
|
36
|
-
|
25
|
+
```ruby
|
26
|
+
# For an image of the entire earth (Mercator projection) with day / night
|
27
|
+
USNO::Imagery::Earth::Map.new(time: Time.now).call.data
|
28
|
+
#=> "http://api.usno.navy.mil/imagery/earth.png?view=full&date=11/17/2013&time=1:11"
|
37
29
|
|
38
|
-
|
30
|
+
# For an image of the earth as seen from the sun
|
31
|
+
USNO::Imagery::Earth::Sun.new(time: Time.now).call.data
|
32
|
+
#=> "http://api.usno.navy.mil/imagery/earth.png?view=sun&date=11/17/2013&time=1:13"
|
39
33
|
|
40
|
-
|
41
|
-
|
34
|
+
# For an image of the earth as seen from the moon
|
35
|
+
USNO::Imagery::Earth::Moon.new(time: Time.now).call.data
|
36
|
+
#=> "http://api.usno.navy.mil/imagery/earth.png?view=moon&date=11/17/2013&time=1:12"
|
42
37
|
|
43
|
-
|
38
|
+
# For an image of the entire earth at sunrise
|
39
|
+
USNO::Imagery::Earth::Rise.new.call.data
|
40
|
+
#=> "http://api.usno.navy.mil/imagery/earth.png?view=rise"
|
44
41
|
|
45
|
-
|
46
|
-
|
42
|
+
# For an image of the entire earth at sunset
|
43
|
+
USNO::Imagery::Earth::Set.new.call.data
|
44
|
+
#=> "http://api.usno.navy.mil/imagery/earth.png?view=set"
|
45
|
+
```
|
47
46
|
|
48
47
|
## Contributing
|
49
48
|
|
data/lib/usno/imagery.rb
CHANGED
@@ -1,8 +1,11 @@
|
|
1
1
|
require_relative "imagery/version"
|
2
|
+
require_relative "imagery/earth/view"
|
3
|
+
|
2
4
|
require_relative "imagery/earth/map"
|
3
|
-
require_relative "imagery/earth/sphere"
|
4
5
|
require_relative "imagery/earth/rise"
|
5
6
|
require_relative "imagery/earth/set"
|
7
|
+
require_relative "imagery/earth/sun"
|
8
|
+
require_relative "imagery/earth/moon"
|
6
9
|
|
7
10
|
module USNO
|
8
11
|
module Imagery
|
@@ -6,31 +6,20 @@ module USNO
|
|
6
6
|
class Map < PayDirt::Base
|
7
7
|
def initialize(options = {})
|
8
8
|
options = {
|
9
|
-
|
10
|
-
|
11
|
-
resource: self.class.name.downcase.split("::")[1..-2].join("/") + ".png"
|
9
|
+
view: "full",
|
10
|
+
usno_imagery_class: USNO::Imagery::Earth::View
|
12
11
|
}.merge(options)
|
13
12
|
|
14
13
|
# sets instance variables from key value pairs,
|
15
14
|
# will fail if any keys given before options aren't in options
|
16
|
-
load_options(:
|
15
|
+
load_options(:view, :usno_imagery_class, options)
|
17
16
|
end
|
18
17
|
|
19
18
|
def call
|
20
|
-
result
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
def query_for(resource)
|
25
|
-
"#{resource}?view=full&date=#{date}&time=#{time}"
|
26
|
-
end
|
27
|
-
|
28
|
-
def date
|
29
|
-
@time.utc.strftime("%m/%d/%Y")
|
30
|
-
end
|
31
|
-
|
32
|
-
def time
|
33
|
-
@time.utc.strftime("%k:%M").lstrip
|
19
|
+
result true, @usno_imagery_class.new({
|
20
|
+
view: @view,
|
21
|
+
time: @time || Time.now
|
22
|
+
}).call.data
|
34
23
|
end
|
35
24
|
end
|
36
25
|
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
require 'pay_dirt'
|
2
|
+
|
3
|
+
module USNO
|
4
|
+
module Imagery
|
5
|
+
module Earth
|
6
|
+
class Moon < PayDirt::Base
|
7
|
+
def initialize(options = {})
|
8
|
+
options = {
|
9
|
+
view: "moon",
|
10
|
+
usno_imagery_class: USNO::Imagery::Earth::View
|
11
|
+
}.merge(options)
|
12
|
+
|
13
|
+
# sets instance variables from key value pairs,
|
14
|
+
# will fail if any keys given before options aren't in options
|
15
|
+
load_options(:view, :usno_imagery_class, options)
|
16
|
+
end
|
17
|
+
|
18
|
+
def call
|
19
|
+
result true, @usno_imagery_class.new({
|
20
|
+
view: @view,
|
21
|
+
time: @time || Time.now
|
22
|
+
}).call.data
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -6,23 +6,20 @@ module USNO
|
|
6
6
|
class Rise < PayDirt::Base
|
7
7
|
def initialize(options = {})
|
8
8
|
options = {
|
9
|
-
|
10
|
-
|
11
|
-
view: self.class.name.downcase.split("::")[-1]
|
9
|
+
view: "rise",
|
10
|
+
usno_imagery_class: USNO::Imagery::Earth::View
|
12
11
|
}.merge(options)
|
13
12
|
|
14
13
|
# sets instance variables from key value pairs,
|
15
14
|
# will fail if any keys given before options aren't in options
|
16
|
-
load_options(:view, options)
|
15
|
+
load_options(:view, :usno_imagery_class, options)
|
17
16
|
end
|
18
17
|
|
19
18
|
def call
|
20
|
-
result
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
def query_for(resource)
|
25
|
-
"#{resource}?view=#{@view}"
|
19
|
+
result true, @usno_imagery_class.new({
|
20
|
+
view: @view,
|
21
|
+
time: nil
|
22
|
+
}).call.data
|
26
23
|
end
|
27
24
|
end
|
28
25
|
end
|
@@ -1,9 +1,27 @@
|
|
1
1
|
require 'pay_dirt'
|
2
2
|
|
3
|
+
|
3
4
|
module USNO
|
4
5
|
module Imagery
|
5
6
|
module Earth
|
6
|
-
class Set <
|
7
|
+
class Set < PayDirt::Base
|
8
|
+
def initialize(options = {})
|
9
|
+
options = {
|
10
|
+
view: "set",
|
11
|
+
usno_imagery_class: USNO::Imagery::Earth::View
|
12
|
+
}.merge(options)
|
13
|
+
|
14
|
+
# sets instance variables from key value pairs,
|
15
|
+
# will fail if any keys given before options aren't in options
|
16
|
+
load_options(:view, :usno_imagery_class, options)
|
17
|
+
end
|
18
|
+
|
19
|
+
def call
|
20
|
+
result true, @usno_imagery_class.new({
|
21
|
+
view: @view,
|
22
|
+
time: nil
|
23
|
+
}).call.data
|
24
|
+
end
|
7
25
|
end
|
8
26
|
end
|
9
27
|
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
require 'pay_dirt'
|
2
|
+
|
3
|
+
module USNO
|
4
|
+
module Imagery
|
5
|
+
module Earth
|
6
|
+
class Sun < PayDirt::Base
|
7
|
+
def initialize(options = {})
|
8
|
+
options = {
|
9
|
+
view: "sun",
|
10
|
+
usno_imagery_class: USNO::Imagery::Earth::View
|
11
|
+
}.merge(options)
|
12
|
+
|
13
|
+
# sets instance variables from key value pairs,
|
14
|
+
# will fail if any keys given before options aren't in options
|
15
|
+
load_options(:view, :usno_imagery_class, options)
|
16
|
+
end
|
17
|
+
|
18
|
+
def call
|
19
|
+
result true, @usno_imagery_class.new({
|
20
|
+
view: @view,
|
21
|
+
time: @time || Time.now
|
22
|
+
}).call.data
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -3,7 +3,7 @@ require 'pay_dirt'
|
|
3
3
|
module USNO
|
4
4
|
module Imagery
|
5
5
|
module Earth
|
6
|
-
class
|
6
|
+
class View < PayDirt::Base
|
7
7
|
def initialize(options = {})
|
8
8
|
options = {
|
9
9
|
time: Time.now,
|
@@ -13,7 +13,7 @@ module USNO
|
|
13
13
|
|
14
14
|
# sets instance variables from key value pairs,
|
15
15
|
# will fail if any keys given before options aren't in options
|
16
|
-
load_options(:time, :root_url, :resource, options)
|
16
|
+
load_options(:time, :root_url, :resource, :view, options) and validate_state
|
17
17
|
end
|
18
18
|
|
19
19
|
def call
|
@@ -22,7 +22,7 @@ module USNO
|
|
22
22
|
|
23
23
|
private
|
24
24
|
def query_for(resource)
|
25
|
-
"#{resource}?view
|
25
|
+
"#{ resource }?view=#{ @view }" + time
|
26
26
|
end
|
27
27
|
|
28
28
|
def date
|
@@ -30,7 +30,13 @@ module USNO
|
|
30
30
|
end
|
31
31
|
|
32
32
|
def time
|
33
|
-
@time.utc.strftime("%
|
33
|
+
@time ? "&date=#{ date }&time=#{ @time.utc.strftime("%k:%M").lstrip }" : ""
|
34
|
+
end
|
35
|
+
|
36
|
+
def validate_state
|
37
|
+
["full", "moon", "sun", "rise", "set"].include? @view or raise(
|
38
|
+
":view not recognized - #{@view}"
|
39
|
+
)
|
34
40
|
end
|
35
41
|
end
|
36
42
|
end
|
data/lib/usno/imagery/version.rb
CHANGED
data/test/test_helper.rb
CHANGED
@@ -1,12 +1,18 @@
|
|
1
|
-
require 'coveralls'
|
2
|
-
Coveralls.wear!
|
1
|
+
#require 'coveralls'
|
2
|
+
#Coveralls.wear!
|
3
|
+
require 'simplecov'
|
4
|
+
SimpleCov.start
|
3
5
|
|
4
6
|
require "minitest/autorun"
|
5
7
|
|
6
8
|
# The gem
|
7
9
|
$: << File.dirname(__FILE__) + "/../lib"
|
8
10
|
$: << File.dirname(__FILE__)
|
9
|
-
|
10
|
-
require "usno/imagery
|
11
|
+
|
12
|
+
require "usno/imagery"
|
13
|
+
require "usno/imagery/earth/view"
|
14
|
+
require "usno/imagery/earth/sun"
|
15
|
+
require "usno/imagery/earth/moon"
|
11
16
|
require "usno/imagery/earth/rise"
|
12
17
|
require "usno/imagery/earth/set"
|
18
|
+
require "usno/imagery/earth/map"
|
@@ -1,10 +1,10 @@
|
|
1
1
|
require 'test_helper'
|
2
2
|
|
3
|
-
describe USNO::Imagery::Earth::
|
3
|
+
describe USNO::Imagery::Earth::Moon do
|
4
4
|
before do
|
5
|
-
@subject = USNO::Imagery::Earth::
|
5
|
+
@subject = USNO::Imagery::Earth::Moon
|
6
6
|
@params = {
|
7
|
-
|
7
|
+
view: "moon",
|
8
8
|
}
|
9
9
|
end
|
10
10
|
|
@@ -3,17 +3,20 @@ require 'test_helper'
|
|
3
3
|
describe USNO::Imagery::Earth::Rise do
|
4
4
|
before do
|
5
5
|
@subject = USNO::Imagery::Earth::Rise
|
6
|
+
@params = {
|
7
|
+
view: "rise"
|
8
|
+
}
|
6
9
|
end
|
7
10
|
|
8
11
|
describe "as a class" do
|
9
12
|
it "initializes properly" do
|
10
|
-
@subject.new.must_respond_to :call
|
13
|
+
@subject.new(@params).must_respond_to :call
|
11
14
|
end
|
12
15
|
end
|
13
16
|
|
14
17
|
describe "as an instance" do
|
15
18
|
it "executes successfully" do
|
16
|
-
result = @subject.new.call
|
19
|
+
result = @subject.new(@params).call
|
17
20
|
result.successful?.must_equal true
|
18
21
|
result.must_be_kind_of PayDirt::Result
|
19
22
|
end
|
@@ -3,17 +3,20 @@ require 'test_helper'
|
|
3
3
|
describe USNO::Imagery::Earth::Set do
|
4
4
|
before do
|
5
5
|
@subject = USNO::Imagery::Earth::Set
|
6
|
+
@params = {
|
7
|
+
view: "set"
|
8
|
+
}
|
6
9
|
end
|
7
10
|
|
8
11
|
describe "as a class" do
|
9
12
|
it "initializes properly" do
|
10
|
-
@subject.new.must_respond_to :call
|
13
|
+
@subject.new(@params).must_respond_to :call
|
11
14
|
end
|
12
15
|
end
|
13
16
|
|
14
17
|
describe "as an instance" do
|
15
18
|
it "executes successfully" do
|
16
|
-
result = @subject.new.call
|
19
|
+
result = @subject.new(@params).call
|
17
20
|
result.successful?.must_equal true
|
18
21
|
result.must_be_kind_of PayDirt::Result
|
19
22
|
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
describe USNO::Imagery::Earth::Sun do
|
4
|
+
before do
|
5
|
+
@subject = USNO::Imagery::Earth::Sun
|
6
|
+
@params = {
|
7
|
+
view: "sun",
|
8
|
+
}
|
9
|
+
end
|
10
|
+
|
11
|
+
describe "as a class" do
|
12
|
+
it "initializes properly" do
|
13
|
+
@subject.new(@params).must_respond_to :call
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
describe "as an instance" do
|
18
|
+
it "executes successfully" do
|
19
|
+
result = @subject.new(@params).call
|
20
|
+
result.successful?.must_equal true
|
21
|
+
result.must_be_kind_of PayDirt::Result
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
describe USNO::Imagery::Earth::View do
|
4
|
+
before do
|
5
|
+
@subject = USNO::Imagery::Earth::View
|
6
|
+
@params = {
|
7
|
+
time: nil,
|
8
|
+
view: "rise",
|
9
|
+
}
|
10
|
+
end
|
11
|
+
|
12
|
+
describe "as a class" do
|
13
|
+
it "initializes properly" do
|
14
|
+
@subject.new(@params).must_respond_to :call
|
15
|
+
end
|
16
|
+
|
17
|
+
it "errors when initialized without required dependencies" do
|
18
|
+
-> { @subject.new(@params.reject { |k| k.to_s == 'view' }) }.must_raise RuntimeError
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
describe "as an instance" do
|
23
|
+
it "executes successfully" do
|
24
|
+
result = @subject.new(@params).call
|
25
|
+
result.successful?.must_equal true
|
26
|
+
result.must_be_kind_of PayDirt::Result
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
data/usno-imagery.gemspec
CHANGED
@@ -23,6 +23,7 @@ Gem::Specification.new do |spec|
|
|
23
23
|
spec.add_development_dependency "rake"
|
24
24
|
spec.add_development_dependency "pry"
|
25
25
|
spec.add_development_dependency "coveralls"
|
26
|
+
spec.add_development_dependency "simplecov"
|
26
27
|
spec.add_development_dependency "minitest"
|
27
28
|
spec.add_runtime_dependency "pay_dirt"
|
28
29
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: usno-imagery
|
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-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -66,6 +66,20 @@ dependencies:
|
|
66
66
|
- - '>='
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: simplecov
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - '>='
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - '>='
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
69
83
|
- !ruby/object:Gem::Dependency
|
70
84
|
name: minitest
|
71
85
|
requirement: !ruby/object:Gem::Requirement
|
@@ -108,15 +122,19 @@ files:
|
|
108
122
|
- Rakefile
|
109
123
|
- lib/usno/imagery.rb
|
110
124
|
- lib/usno/imagery/earth/map.rb
|
125
|
+
- lib/usno/imagery/earth/moon.rb
|
111
126
|
- lib/usno/imagery/earth/rise.rb
|
112
127
|
- lib/usno/imagery/earth/set.rb
|
113
|
-
- lib/usno/imagery/earth/
|
128
|
+
- lib/usno/imagery/earth/sun.rb
|
129
|
+
- lib/usno/imagery/earth/view.rb
|
114
130
|
- lib/usno/imagery/version.rb
|
115
131
|
- test/test_helper.rb
|
116
132
|
- test/unit/usno/imagery/earth/map_test.rb
|
133
|
+
- test/unit/usno/imagery/earth/moon_test.rb
|
117
134
|
- test/unit/usno/imagery/earth/rise_test.rb
|
118
135
|
- test/unit/usno/imagery/earth/set_test.rb
|
119
|
-
- test/unit/usno/imagery/earth/
|
136
|
+
- test/unit/usno/imagery/earth/sun_test.rb
|
137
|
+
- test/unit/usno/imagery/earth/view_test.rb
|
120
138
|
- usno-imagery.gemspec
|
121
139
|
homepage: ''
|
122
140
|
licenses:
|
@@ -145,6 +163,8 @@ summary: Consumes USNO's imagery data services
|
|
145
163
|
test_files:
|
146
164
|
- test/test_helper.rb
|
147
165
|
- test/unit/usno/imagery/earth/map_test.rb
|
166
|
+
- test/unit/usno/imagery/earth/moon_test.rb
|
148
167
|
- test/unit/usno/imagery/earth/rise_test.rb
|
149
168
|
- test/unit/usno/imagery/earth/set_test.rb
|
150
|
-
- test/unit/usno/imagery/earth/
|
169
|
+
- test/unit/usno/imagery/earth/sun_test.rb
|
170
|
+
- test/unit/usno/imagery/earth/view_test.rb
|