usno-imagery 0.1.0 → 0.1.2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3111708e4b2554709cc8b5f8478d2c5bf9e2f383
4
- data.tar.gz: 9cae9895b598cda54a7f801c442e0a20e7b2198b
3
+ metadata.gz: fabb79015db48b6037ca726a93948839af3d1b88
4
+ data.tar.gz: e0a6d3688b0efbc0ed415791da8d72485dc101fc
5
5
  SHA512:
6
- metadata.gz: e10fb7cc6dfc408b6118a047453bc679f38b33bb32e46b91d715bbfcb230590d29e047c91e4d413452084af7e533641535b06129a6558eeece60c986c8ce3b8c
7
- data.tar.gz: 71e94813ee4bd84db37e88fb38042e23be75a0f1b29f8a143343dad1d7c46635d0f5717fc5ee3520e28dbf600f9a815f9223924ba43182a4087822878be04d03
6
+ metadata.gz: ecb191db6725f9a28fddaad2564e6fbe9d0fc1cbf82ddf8cf738cf0c73052870255e270ce8c4dbb4adec9bab81e1529350d23b5b21cdc96cc9c5e897a5a892cc
7
+ data.tar.gz: 6c5a7d44b24da88f14820d464f4acb08ee02da8c853b0437f1a0c75f912b9172a6448bed48e673e38a1e6a79d7844f743f4462005d175a1163e28b9cffd34115
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # USNO::Imagery
1
+ # USNO::Imagery [![Code Climate](https://codeclimate.com/github/rthbound/usno-imagery.png)](https://codeclimate.com/github/rthbound/usno-imagery)
2
2
 
3
3
  Builds URLs for consuming USNO's imagery data services
4
4
 
data/lib/usno/imagery.rb CHANGED
@@ -1,5 +1,8 @@
1
1
  require_relative "imagery/version"
2
2
  require_relative "imagery/earth/view"
3
+ require_relative "imagery/earth/earth_view"
4
+ require_relative "imagery/earth/call"
5
+ require_relative "imagery/earth/call_with_time"
3
6
 
4
7
  require_relative "imagery/earth/map"
5
8
  require_relative "imagery/earth/rise"
@@ -0,0 +1,16 @@
1
+ module USNO
2
+ module Imagery
3
+ module Earth
4
+ module Call
5
+ def self.included(base)
6
+ def call
7
+ result true, @usno_imagery_class.new({
8
+ view: @view,
9
+ time: nil
10
+ }).call.data
11
+ end
12
+ end
13
+ end
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,16 @@
1
+ module USNO
2
+ module Imagery
3
+ module Earth
4
+ module CallWithTime
5
+ def self.included(base)
6
+ def call
7
+ result true, @usno_imagery_class.new({
8
+ view: @view,
9
+ time: @time || Time.now
10
+ }).call.data
11
+ end
12
+ end
13
+ end
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,17 @@
1
+ module USNO
2
+ module Imagery
3
+ module Earth
4
+ class EarthView < PayDirt::Base
5
+ def initialize(options = {})
6
+ options = {
7
+ usno_imagery_class: USNO::Imagery::Earth::View
8
+ }.merge(options)
9
+
10
+ # sets instance variables from key value pairs,
11
+ # will fail if any keys given before options aren't in options
12
+ load_options(:view, :usno_imagery_class, options)
13
+ end
14
+ end
15
+ end
16
+ end
17
+ end
@@ -3,23 +3,13 @@ require 'pay_dirt'
3
3
  module USNO
4
4
  module Imagery
5
5
  module Earth
6
- class Map < PayDirt::Base
6
+ class Map < EarthView
7
+ include USNO::Imagery::Earth::CallWithTime
8
+
7
9
  def initialize(options = {})
8
10
  options = {
9
- view: "full",
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
11
+ view: "full"
12
+ }.merge(options) and super
23
13
  end
24
14
  end
25
15
  end
@@ -3,23 +3,13 @@ require 'pay_dirt'
3
3
  module USNO
4
4
  module Imagery
5
5
  module Earth
6
- class Moon < PayDirt::Base
6
+ class Moon < EarthView
7
+ include USNO::Imagery::Earth::CallWithTime
8
+
7
9
  def initialize(options = {})
8
10
  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
11
+ view: "moon"
12
+ }.merge(options) and super
23
13
  end
24
14
  end
25
15
  end
@@ -3,23 +3,13 @@ require 'pay_dirt'
3
3
  module USNO
4
4
  module Imagery
5
5
  module Earth
6
- class Rise < PayDirt::Base
6
+ class Rise < EarthView
7
+ include USNO::Imagery::Earth::Call
8
+
7
9
  def initialize(options = {})
8
10
  options = {
9
- view: "rise",
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: nil
22
- }).call.data
11
+ view: "rise"
12
+ }.merge(options) and super
23
13
  end
24
14
  end
25
15
  end
@@ -4,23 +4,13 @@ require 'pay_dirt'
4
4
  module USNO
5
5
  module Imagery
6
6
  module Earth
7
- class Set < PayDirt::Base
7
+ class Set < EarthView
8
+ include USNO::Imagery::Earth::Call
9
+
8
10
  def initialize(options = {})
9
11
  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
12
+ view: "set"
13
+ }.merge(options) and super
24
14
  end
25
15
  end
26
16
  end
@@ -3,23 +3,13 @@ require 'pay_dirt'
3
3
  module USNO
4
4
  module Imagery
5
5
  module Earth
6
- class Sun < PayDirt::Base
6
+ class Sun < EarthView
7
+ include USNO::Imagery::Earth::CallWithTime
8
+
7
9
  def initialize(options = {})
8
10
  options = {
9
11
  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
12
+ }.merge(options) and super
23
13
  end
24
14
  end
25
15
  end
@@ -1,5 +1,5 @@
1
1
  module USNO
2
2
  module Imagery
3
- VERSION = "0.1.0"
3
+ VERSION = "0.1.2"
4
4
  end
5
5
  end
@@ -4,7 +4,8 @@ describe USNO::Imagery::Earth::Map do
4
4
  before do
5
5
  @subject = USNO::Imagery::Earth::Map
6
6
  @params = {
7
- view: "full"
7
+ view: "full",
8
+ time: Time.now
8
9
  }
9
10
  end
10
11
 
@@ -20,5 +21,14 @@ describe USNO::Imagery::Earth::Map do
20
21
  result.successful?.must_equal true
21
22
  result.must_be_kind_of PayDirt::Result
22
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/earth.png"
31
+ result.must_include "?view=full"
32
+ end
23
33
  end
24
34
  end
@@ -5,6 +5,7 @@ describe USNO::Imagery::Earth::Moon do
5
5
  @subject = USNO::Imagery::Earth::Moon
6
6
  @params = {
7
7
  view: "moon",
8
+ time: Time.now
8
9
  }
9
10
  end
10
11
 
@@ -20,5 +21,14 @@ describe USNO::Imagery::Earth::Moon do
20
21
  result.successful?.must_equal true
21
22
  result.must_be_kind_of PayDirt::Result
22
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/earth.png"
31
+ result.must_include "?view=moon"
32
+ end
23
33
  end
24
34
  end
@@ -20,5 +20,12 @@ describe USNO::Imagery::Earth::Rise do
20
20
  result.successful?.must_equal true
21
21
  result.must_be_kind_of PayDirt::Result
22
22
  end
23
+
24
+ it "returns the proper url" do
25
+ result = @subject.new(@params).call.data
26
+
27
+ result.must_include "http://api.usno.navy.mil/imagery/earth.png"
28
+ result.must_include "?view=rise"
29
+ end
23
30
  end
24
31
  end
@@ -20,5 +20,12 @@ describe USNO::Imagery::Earth::Set do
20
20
  result.successful?.must_equal true
21
21
  result.must_be_kind_of PayDirt::Result
22
22
  end
23
+
24
+ it "returns the proper url" do
25
+ result = @subject.new(@params).call.data
26
+
27
+ result.must_include "http://api.usno.navy.mil/imagery/earth.png"
28
+ result.must_include "?view=set"
29
+ end
23
30
  end
24
31
  end
@@ -5,6 +5,7 @@ describe USNO::Imagery::Earth::Sun do
5
5
  @subject = USNO::Imagery::Earth::Sun
6
6
  @params = {
7
7
  view: "sun",
8
+ time: Time.now
8
9
  }
9
10
  end
10
11
 
@@ -20,5 +21,14 @@ describe USNO::Imagery::Earth::Sun do
20
21
  result.successful?.must_equal true
21
22
  result.must_be_kind_of PayDirt::Result
22
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/earth.png"
31
+ result.must_include "?view=sun"
32
+ end
23
33
  end
24
34
  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.0
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryan T. Hosford
@@ -121,6 +121,9 @@ files:
121
121
  - README.md
122
122
  - Rakefile
123
123
  - lib/usno/imagery.rb
124
+ - lib/usno/imagery/earth/call.rb
125
+ - lib/usno/imagery/earth/call_with_time.rb
126
+ - lib/usno/imagery/earth/earth_view.rb
124
127
  - lib/usno/imagery/earth/map.rb
125
128
  - lib/usno/imagery/earth/moon.rb
126
129
  - lib/usno/imagery/earth/rise.rb