usno-imagery 0.1.2 → 0.1.3

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: fabb79015db48b6037ca726a93948839af3d1b88
4
- data.tar.gz: e0a6d3688b0efbc0ed415791da8d72485dc101fc
3
+ metadata.gz: 2f654cefba23e4a353a4c83f41334f0e0e59ed4c
4
+ data.tar.gz: 18e3bc626eb939f31c4533b74f119825d7d80a89
5
5
  SHA512:
6
- metadata.gz: ecb191db6725f9a28fddaad2564e6fbe9d0fc1cbf82ddf8cf738cf0c73052870255e270ce8c4dbb4adec9bab81e1529350d23b5b21cdc96cc9c5e897a5a892cc
7
- data.tar.gz: 6c5a7d44b24da88f14820d464f4acb08ee02da8c853b0437f1a0c75f912b9172a6448bed48e673e38a1e6a79d7844f743f4462005d175a1163e28b9cffd34115
6
+ metadata.gz: 41617555b39d85c5cea44a75db1d6b10ef922c2d060ba81344b332e9d3c0240711df8d15934282161112372ed4cfb66b6e44c3027204a05a51514f653ddcfa43
7
+ data.tar.gz: 968a73b0db6d2df7b7bfa87dfa2bb6f9e9fecd23ed0ca7169450b8acca9a9d239474a05fc25e4a1255dbd7c3a8f5a784a0cddfa17023acf5ddb59eb772b61b04
@@ -0,0 +1,13 @@
1
+ language: ruby
2
+
3
+ matrix:
4
+ allow_failures:
5
+ - rvm: ruby-head
6
+
7
+ rvm:
8
+ - 2.0.0
9
+ - 1.9.3
10
+ - 1.9.2
11
+ - ruby-head
12
+
13
+ script: bundle exec rake test
data/README.md CHANGED
@@ -1,6 +1,8 @@
1
- # USNO::Imagery [![Code Climate](https://codeclimate.com/github/rthbound/usno-imagery.png)](https://codeclimate.com/github/rthbound/usno-imagery)
1
+ # USNO::Imagery [![Code Climate](https://codeclimate.com/github/rthbound/usno-imagery.png)](https://codeclimate.com/github/rthbound/usno-imagery)[![Coverage Status](https://coveralls.io/repos/rthbound/usno-imagery/badge.png?branch=master)](https://coveralls.io/r/rthbound/usno-imagery?branch=master)[![Build Status](https://travis-ci.org/rthbound/usno-imagery.png?branch=master)](https://travis-ci.org/rthbound/usno-imagery)
2
2
 
3
- Builds URLs for consuming USNO's imagery data services
3
+ Builds URLs for consuming USNO's imagery data services. Example:
4
+
5
+ ![Earth at sunrise](https://github.com/rthbound/usno-imagery/blob/master/samples/rise?raw=true)
4
6
 
5
7
  ## Installation
6
8
 
@@ -44,6 +46,50 @@ USNO::Imagery::Earth::Set.new.call.data
44
46
  #=> "http://api.usno.navy.mil/imagery/earth.png?view=set"
45
47
  ```
46
48
 
49
+ #### Other USNO::Imagery libraries
50
+
51
+ ```ruby
52
+ # For an image of our Moon at any time between 1700 & 2100 A.D.
53
+ USNO::Imagery::Moon.new(time: Time.now).call.data
54
+ #=> "http://api.usno.navy.mil/imagery/moon.png?date=11/17/2013&time=1:13"
55
+
56
+ # For an image of Mercury at any time between 1700 & 2100 A.D.
57
+ USNO::Imagery::Mercury.new(time: Time.now).call.data
58
+ #=> "http://api.usno.navy.mil/imagery/mercury.png?date=11/17/2013&time=1:13"
59
+
60
+ # For an image of Venus at any time between 1700 & 2100 A.D.
61
+ USNO::Imagery::Venus.new(time: Time.now).call.data
62
+ #=> "http://api.usno.navy.mil/imagery/venus.png?date=11/17/2013&time=1:13"
63
+
64
+ # For a radar image of Venus at any time between 1700 & 2100 A.D.
65
+ USNO::Imagery::Venus.new(time: Time.now, radar: true).call.data
66
+ #=> "http://api.usno.navy.mil/imagery/venus-radar.png?date=11/17/2013&time=1:13"
67
+
68
+ # For an image of Mars at any time between 1700 & 2100 A.D.
69
+ USNO::Imagery::Mars.new(time: Time.now).call.data
70
+ #=> "http://api.usno.navy.mil/imagery/mars.png?date=11/17/2013&time=1:13"
71
+
72
+ # For an image of Jupiter at any time between 1700 & 2100 A.D.
73
+ USNO::Imagery::Jupiter.new(time: Time.now).call.data
74
+ #=> "http://api.usno.navy.mil/imagery/jupiter.png?date=11/17/2013&time=1:13"
75
+
76
+ # For an image of Jupiter's moon Io at any time between 1700 & 2100 A.D.
77
+ USNO::Imagery::Io.new(time: Time.now).call.data
78
+ #=> "http://api.usno.navy.mil/imagery/io.png?date=11/17/2013&time=1:13"
79
+
80
+ # For an image of Jupiter's moon Europa at any time between 1700 & 2100 A.D.
81
+ USNO::Imagery::Europa.new(time: Time.now).call.data
82
+ #=> "http://api.usno.navy.mil/imagery/europa.png?date=11/17/2013&time=1:13"
83
+
84
+ # For an image of Jupiter's moon Ganymede at any time between 1700 & 2100 A.D.
85
+ USNO::Imagery::Ganymede.new(time: Time.now).call.data
86
+ #=> "http://api.usno.navy.mil/imagery/ganymede.png?date=11/17/2013&time=1:13"
87
+
88
+ # For an image of Jupiter's moon Callisto at any time between 1700 & 2100 A.D.
89
+ USNO::Imagery::Callisto.new(time: Time.now).call.data
90
+ #=> "http://api.usno.navy.mil/imagery/callisto.png?date=11/17/2013&time=1:13"
91
+ ```
92
+
47
93
  ## Contributing
48
94
 
49
95
  1. Fork it
@@ -14,5 +14,46 @@ module USNO
14
14
  module Imagery
15
15
  module Earth
16
16
  end
17
+
18
+ class View < PayDirt::Base
19
+ def initialize(options = {})
20
+ options = {
21
+ time: Time.now,
22
+ root_url: "http://api.usno.navy.mil/",
23
+ resource: self.class.name.downcase.split("::")[1..-1].join("/") + ".png"
24
+ }.merge(options)
25
+
26
+ # sets instance variables from key value pairs,
27
+ # will fail if any keys given before options aren't in options
28
+ load_options(:time, :root_url, :resource, options)
29
+ end
30
+
31
+ def call
32
+ result(true, query_for(@root_url + @resource))
33
+ end
34
+
35
+ private
36
+ def query_for(resource)
37
+ "#{resource}?#{time}"
38
+ end
39
+
40
+ def date
41
+ @time.utc.strftime("%m/%d/%Y")
42
+ end
43
+
44
+ def time
45
+ @time ? "&date=#{ date }&time=#{ @time.utc.strftime("%k:%M").lstrip }" : ""
46
+ end
47
+ end
17
48
  end
18
49
  end
50
+
51
+ require_relative "imagery/ganymede"
52
+ require_relative "imagery/io"
53
+ require_relative "imagery/europa"
54
+ require_relative "imagery/jupiter"
55
+ require_relative "imagery/mars"
56
+ require_relative "imagery/mercury"
57
+ require_relative "imagery/venus"
58
+ require_relative "imagery/moon"
59
+ require_relative "imagery/callisto"
@@ -0,0 +1,6 @@
1
+ module USNO
2
+ module Imagery
3
+ class Callisto < View
4
+ end
5
+ end
6
+ end
@@ -0,0 +1,6 @@
1
+ module USNO
2
+ module Imagery
3
+ class Europa < View
4
+ end
5
+ end
6
+ end
@@ -0,0 +1,6 @@
1
+ module USNO
2
+ module Imagery
3
+ class Ganymede < View
4
+ end
5
+ end
6
+ end
@@ -0,0 +1,6 @@
1
+ module USNO
2
+ module Imagery
3
+ class Io < View
4
+ end
5
+ end
6
+ end
@@ -0,0 +1,6 @@
1
+ module USNO
2
+ module Imagery
3
+ class Jupiter < View
4
+ end
5
+ end
6
+ end
@@ -0,0 +1,6 @@
1
+ module USNO
2
+ module Imagery
3
+ class Mars < View
4
+ end
5
+ end
6
+ end
@@ -0,0 +1,6 @@
1
+ module USNO
2
+ module Imagery
3
+ class Mercury < View
4
+ end
5
+ end
6
+ end
@@ -0,0 +1,6 @@
1
+ module USNO
2
+ module Imagery
3
+ class Moon < View
4
+ end
5
+ end
6
+ end
@@ -0,0 +1,13 @@
1
+ module USNO
2
+ module Imagery
3
+ class Venus < View
4
+ def initialize(options = {})
5
+ if options[:radar]
6
+ options[:resource] = "imagery/venus-radar.png"
7
+ end
8
+
9
+ super
10
+ end
11
+ end
12
+ end
13
+ end
@@ -1,5 +1,5 @@
1
1
  module USNO
2
2
  module Imagery
3
- VERSION = "0.1.2"
3
+ VERSION = "0.1.3"
4
4
  end
5
5
  end
Binary file
@@ -1,7 +1,5 @@
1
- #require 'coveralls'
2
- #Coveralls.wear!
3
- require 'simplecov'
4
- SimpleCov.start
1
+ require 'coveralls'
2
+ Coveralls.wear!
5
3
 
6
4
  require "minitest/autorun"
7
5
 
@@ -0,0 +1,32 @@
1
+ require 'test_helper'
2
+
3
+ describe USNO::Imagery::Callisto do
4
+ before do
5
+ @subject = USNO::Imagery::Callisto
6
+ @params = {
7
+ time: Time.now
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
+
24
+ it "returns the proper url" do
25
+ result = @subject.new(@params).call.data
26
+
27
+ result.must_include @params[:time].strftime("%k:%M").lstrip
28
+ result.must_include @params[:time].strftime("%m/%d/%Y")
29
+ result.must_include "http://api.usno.navy.mil/imagery/callisto.png?"
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,32 @@
1
+ require 'test_helper'
2
+
3
+ describe USNO::Imagery::Europa do
4
+ before do
5
+ @subject = USNO::Imagery::Europa
6
+ @params = {
7
+ time: Time.now
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
+
24
+ it "returns the proper url" do
25
+ result = @subject.new(@params).call.data
26
+
27
+ result.must_include @params[:time].strftime("%k:%M").lstrip
28
+ result.must_include @params[:time].strftime("%m/%d/%Y").lstrip
29
+ result.must_include "http://api.usno.navy.mil/imagery/europa.png?"
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,32 @@
1
+ require 'test_helper'
2
+
3
+ describe USNO::Imagery::Ganymede do
4
+ before do
5
+ @subject = USNO::Imagery::Ganymede
6
+ @params = {
7
+ time: Time.now
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
+
24
+ it "returns the proper url" do
25
+ result = @subject.new(@params).call.data
26
+
27
+ result.must_include @params[:time].strftime("%k:%M").lstrip
28
+ result.must_include @params[:time].strftime("%m/%d/%Y").lstrip
29
+ result.must_include "http://api.usno.navy.mil/imagery/ganymede.png?"
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,32 @@
1
+ require 'test_helper'
2
+
3
+ describe USNO::Imagery::Io do
4
+ before do
5
+ @subject = USNO::Imagery::Io
6
+ @params = {
7
+ time: Time.now
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
+
24
+ it "returns the proper url" do
25
+ result = @subject.new(@params).call.data
26
+
27
+ result.must_include @params[:time].strftime("%k:%M").lstrip
28
+ result.must_include @params[:time].strftime("%m/%d/%Y").lstrip
29
+ result.must_include "http://api.usno.navy.mil/imagery/io.png?"
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,32 @@
1
+ require 'test_helper'
2
+
3
+ describe USNO::Imagery::Jupiter do
4
+ before do
5
+ @subject = USNO::Imagery::Jupiter
6
+ @params = {
7
+ time: Time.now
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
+
24
+ it "returns the proper url" do
25
+ result = @subject.new(@params).call.data
26
+
27
+ result.must_include @params[:time].strftime("%k:%M").lstrip
28
+ result.must_include @params[:time].strftime("%m/%d/%Y").lstrip
29
+ result.must_include "http://api.usno.navy.mil/imagery/jupiter.png?"
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,32 @@
1
+ require 'test_helper'
2
+
3
+ describe USNO::Imagery::Mars do
4
+ before do
5
+ @subject = USNO::Imagery::Mars
6
+ @params = {
7
+ time: Time.now
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
+
24
+ it "returns the proper url" do
25
+ result = @subject.new(@params).call.data
26
+
27
+ result.must_include @params[:time].strftime("%k:%M").lstrip
28
+ result.must_include @params[:time].strftime("%m/%d/%Y").lstrip
29
+ result.must_include "http://api.usno.navy.mil/imagery/mars.png?"
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,32 @@
1
+ require 'test_helper'
2
+
3
+ describe USNO::Imagery::Mercury do
4
+ before do
5
+ @subject = USNO::Imagery::Mercury
6
+ @params = {
7
+ time: Time.now
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
+
24
+ it "returns the proper url" do
25
+ result = @subject.new(@params).call.data
26
+
27
+ result.must_include @params[:time].strftime("%k:%M").lstrip
28
+ result.must_include @params[:time].strftime("%m/%d/%Y").lstrip
29
+ result.must_include "http://api.usno.navy.mil/imagery/mercury.png?"
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,33 @@
1
+ require 'test_helper'
2
+
3
+ describe USNO::Imagery::Moon do
4
+ before do
5
+ @subject = USNO::Imagery::Moon
6
+ @params = {
7
+ view: "full",
8
+ time: Time.now
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
+ end
17
+
18
+ describe "as an instance" do
19
+ it "executes successfully" do
20
+ result = @subject.new(@params).call
21
+ result.successful?.must_equal true
22
+ result.must_be_kind_of PayDirt::Result
23
+ end
24
+
25
+ it "returns the proper url" do
26
+ result = @subject.new(@params).call.data
27
+
28
+ result.must_include @params[:time].strftime("%k:%M").lstrip
29
+ result.must_include @params[:time].strftime("%m/%d/%Y").lstrip
30
+ result.must_include "http://api.usno.navy.mil/imagery/moon.png?"
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,41 @@
1
+ require 'test_helper'
2
+
3
+ describe USNO::Imagery::Venus do
4
+ before do
5
+ @subject = USNO::Imagery::Venus
6
+ @params = {
7
+ view: "full",
8
+ time: Time.now
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
+ end
17
+
18
+ describe "as an instance" do
19
+ it "executes successfully" do
20
+ result = @subject.new(@params).call
21
+ result.successful?.must_equal true
22
+ result.must_be_kind_of PayDirt::Result
23
+ end
24
+
25
+ it "returns the proper url" do
26
+ result = @subject.new(@params).call.data
27
+
28
+ result.must_include @params[:time].strftime("%k:%M").lstrip
29
+ result.must_include @params[:time].strftime("%m/%d/%Y").lstrip
30
+ result.must_include "http://api.usno.navy.mil/imagery/venus.png?"
31
+ end
32
+
33
+ it "it supports a radar view of Venus" do
34
+ result = @subject.new(@params.merge({radar: true})).call.data
35
+
36
+ result.must_include @params[:time].strftime("%k:%M").lstrip
37
+ result.must_include @params[:time].strftime("%m/%d/%Y").lstrip
38
+ result.must_include "http://api.usno.navy.mil/imagery/venus-radar.png?"
39
+ end
40
+ end
41
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: usno-imagery
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryan T. Hosford
@@ -116,11 +116,13 @@ extensions: []
116
116
  extra_rdoc_files: []
117
117
  files:
118
118
  - .gitignore
119
+ - .travis.yml
119
120
  - Gemfile
120
121
  - LICENSE.txt
121
122
  - README.md
122
123
  - Rakefile
123
124
  - lib/usno/imagery.rb
125
+ - lib/usno/imagery/callisto.rb
124
126
  - lib/usno/imagery/earth/call.rb
125
127
  - lib/usno/imagery/earth/call_with_time.rb
126
128
  - lib/usno/imagery/earth/earth_view.rb
@@ -130,14 +132,32 @@ files:
130
132
  - lib/usno/imagery/earth/set.rb
131
133
  - lib/usno/imagery/earth/sun.rb
132
134
  - lib/usno/imagery/earth/view.rb
135
+ - lib/usno/imagery/europa.rb
136
+ - lib/usno/imagery/ganymede.rb
137
+ - lib/usno/imagery/io.rb
138
+ - lib/usno/imagery/jupiter.rb
139
+ - lib/usno/imagery/mars.rb
140
+ - lib/usno/imagery/mercury.rb
141
+ - lib/usno/imagery/moon.rb
142
+ - lib/usno/imagery/venus.rb
133
143
  - lib/usno/imagery/version.rb
144
+ - samples/rise
134
145
  - test/test_helper.rb
146
+ - test/unit/usno/imagery/callisto_test.rb
135
147
  - test/unit/usno/imagery/earth/map_test.rb
136
148
  - test/unit/usno/imagery/earth/moon_test.rb
137
149
  - test/unit/usno/imagery/earth/rise_test.rb
138
150
  - test/unit/usno/imagery/earth/set_test.rb
139
151
  - test/unit/usno/imagery/earth/sun_test.rb
140
152
  - test/unit/usno/imagery/earth/view_test.rb
153
+ - test/unit/usno/imagery/europa_test.rb
154
+ - test/unit/usno/imagery/ganymede_test.rb
155
+ - test/unit/usno/imagery/io_test.rb
156
+ - test/unit/usno/imagery/jupiter_test.rb
157
+ - test/unit/usno/imagery/mars_test.rb
158
+ - test/unit/usno/imagery/mercury_test.rb
159
+ - test/unit/usno/imagery/moon_test.rb
160
+ - test/unit/usno/imagery/venus_test.rb
141
161
  - usno-imagery.gemspec
142
162
  homepage: ''
143
163
  licenses:
@@ -165,9 +185,18 @@ specification_version: 4
165
185
  summary: Consumes USNO's imagery data services
166
186
  test_files:
167
187
  - test/test_helper.rb
188
+ - test/unit/usno/imagery/callisto_test.rb
168
189
  - test/unit/usno/imagery/earth/map_test.rb
169
190
  - test/unit/usno/imagery/earth/moon_test.rb
170
191
  - test/unit/usno/imagery/earth/rise_test.rb
171
192
  - test/unit/usno/imagery/earth/set_test.rb
172
193
  - test/unit/usno/imagery/earth/sun_test.rb
173
194
  - test/unit/usno/imagery/earth/view_test.rb
195
+ - test/unit/usno/imagery/europa_test.rb
196
+ - test/unit/usno/imagery/ganymede_test.rb
197
+ - test/unit/usno/imagery/io_test.rb
198
+ - test/unit/usno/imagery/jupiter_test.rb
199
+ - test/unit/usno/imagery/mars_test.rb
200
+ - test/unit/usno/imagery/mercury_test.rb
201
+ - test/unit/usno/imagery/moon_test.rb
202
+ - test/unit/usno/imagery/venus_test.rb