usno-imagery 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 1c1b3ba1b9effe66bf0a3976ef6de7fb9acec322
4
+ data.tar.gz: c9a1e8526cf9f2a1d9ea66cedb43994fdc0cbfd4
5
+ SHA512:
6
+ metadata.gz: 26b5b9e8345f3ba9b2cfc43b85339c9944183deeab81cbe240db56e20c41964e24f79a37353953095d704d1f0f7e7f3ccfa0741b27e1d6bd7f422018220ee380
7
+ data.tar.gz: 6e7485b7c70843235b074fe41341ee303dfc4018b6c2a755d94c11ba70698ffb60bbfb04df82c0e4d86d4372d825d1291eb1dd70b6eadb201833f721701a2237
data/.gitignore ADDED
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in usno-imagery.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 Ryan T. Hosford
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,56 @@
1
+ # USNO::Imagery
2
+
3
+ Consumes USNO's imagery data services
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'usno-imagery'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install usno-imagery
18
+
19
+ ## Usage
20
+
21
+ `require 'usno/imagery'`
22
+
23
+ ### USNO::Imagery
24
+
25
+ #### USNO::Imagery::Earth
26
+
27
+ The earth namespace will contain classes for viewing USNO's earth images.
28
+ Currently there are three classes here, `Map`, `Sphere` ``
29
+
30
+ A view of the earth projected onto a 2D plane (at any given time):
31
+
32
+ USNO::Imagery::Earth::Map.new(time: Time.now).call.data
33
+ #=> "http://api.usno.navy.mil/imagery/earth.png?view=full&date=11/08/2013&time=20:32"
34
+
35
+ A spherical view of the earth as seen from the moon (at any given time)
36
+
37
+ USNO::Imagery::Earth::Sphere.new(time: Time.now).call.data
38
+ #=> "http://api.usno.navy.mil/imagery/earth.png?view=moon&date=11/08/2013&time=20:31"
39
+
40
+ A current view of the earth's sunrise
41
+
42
+ USNO::Imagery::Earth::Rise.new.call.data
43
+ => "http://api.usno.navy.mil/imagery/earth.png?view=rise"
44
+
45
+ A current view of the earth's sunset
46
+
47
+ USNO::Imagery::Earth::Set.new.call.data
48
+ #=> "http://api.usno.navy.mil/imagery/earth.png?view=set"
49
+
50
+ ## Contributing
51
+
52
+ 1. Fork it
53
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
54
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
55
+ 4. Push to the branch (`git push origin my-new-feature`)
56
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,9 @@
1
+ require "bundler/gem_tasks"
2
+ require "rake/testtask"
3
+
4
+ Rake::TestTask.new do |t|
5
+ t.pattern = 'test/**/*_test.rb'
6
+ t.libs.push 'test'
7
+ end
8
+
9
+ task :default => :test
@@ -0,0 +1,12 @@
1
+ require_relative "imagery/version"
2
+ require_relative "imagery/earth/map"
3
+ require_relative "imagery/earth/sphere"
4
+ require_relative "imagery/earth/rise"
5
+ require_relative "imagery/earth/set"
6
+
7
+ module USNO
8
+ module Imagery
9
+ module Earth
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,38 @@
1
+ require 'pay_dirt'
2
+
3
+ module USNO
4
+ module Imagery
5
+ module Earth
6
+ class Map < PayDirt::Base
7
+ def initialize(options = {})
8
+ options = {
9
+ time: Time.now,
10
+ root_url: "http://api.usno.navy.mil/",
11
+ resource: self.class.name.downcase.split("::")[1..-2].join("/") + ".png"
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(:time, :root_url, :resource, options)
17
+ end
18
+
19
+ def call
20
+ result(true, query_for(@root_url + @resource))
21
+ end
22
+
23
+ private
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("%H:%M")
34
+ end
35
+ end
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,30 @@
1
+ require 'pay_dirt'
2
+
3
+ module USNO
4
+ module Imagery
5
+ module Earth
6
+ class Rise < PayDirt::Base
7
+ def initialize(options = {})
8
+ options = {
9
+ root_url: "http://api.usno.navy.mil/",
10
+ resource: self.class.name.downcase.split("::")[1..-2].join("/") + ".png",
11
+ view: self.class.name.downcase.split("::")[-1]
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, options)
17
+ end
18
+
19
+ def call
20
+ result(true, query_for(@root_url + @resource))
21
+ end
22
+
23
+ private
24
+ def query_for(resource)
25
+ "#{resource}?view=#{@view}"
26
+ end
27
+ end
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,10 @@
1
+ require 'pay_dirt'
2
+
3
+ module USNO
4
+ module Imagery
5
+ module Earth
6
+ class Set < Rise
7
+ end
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,38 @@
1
+ require 'pay_dirt'
2
+
3
+ module USNO
4
+ module Imagery
5
+ module Earth
6
+ class Sphere < PayDirt::Base
7
+ def initialize(options = {})
8
+ options = {
9
+ time: Time.now,
10
+ root_url: "http://api.usno.navy.mil/",
11
+ resource: self.class.name.downcase.split("::")[1..-2].join("/") + ".png"
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(:time, :root_url, :resource, options)
17
+ end
18
+
19
+ def call
20
+ result(true, query_for(@root_url + @resource))
21
+ end
22
+
23
+ private
24
+ def query_for(resource)
25
+ "#{resource}?view=moon&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("%H:%M")
34
+ end
35
+ end
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,5 @@
1
+ module USNO
2
+ module Imagery
3
+ VERSION = "0.0.1"
4
+ end
5
+ end
@@ -0,0 +1,12 @@
1
+ require 'coveralls'
2
+ Coveralls.wear!
3
+
4
+ require "minitest/autorun"
5
+
6
+ # The gem
7
+ $: << File.dirname(__FILE__) + "/../lib"
8
+ $: << File.dirname(__FILE__)
9
+ require "usno/imagery/earth/map"
10
+ require "usno/imagery/earth/sphere"
11
+ require "usno/imagery/earth/rise"
12
+ require "usno/imagery/earth/set"
@@ -0,0 +1,24 @@
1
+ require 'test_helper'
2
+
3
+ describe USNO::Imagery::Earth::Map do
4
+ before do
5
+ @subject = USNO::Imagery::Earth::Map
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
+ end
24
+ end
@@ -0,0 +1,21 @@
1
+ require 'test_helper'
2
+
3
+ describe USNO::Imagery::Earth::Rise do
4
+ before do
5
+ @subject = USNO::Imagery::Earth::Rise
6
+ end
7
+
8
+ describe "as a class" do
9
+ it "initializes properly" do
10
+ @subject.new.must_respond_to :call
11
+ end
12
+ end
13
+
14
+ describe "as an instance" do
15
+ it "executes successfully" do
16
+ result = @subject.new.call
17
+ result.successful?.must_equal true
18
+ result.must_be_kind_of PayDirt::Result
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,21 @@
1
+ require 'test_helper'
2
+
3
+ describe USNO::Imagery::Earth::Set do
4
+ before do
5
+ @subject = USNO::Imagery::Earth::Set
6
+ end
7
+
8
+ describe "as a class" do
9
+ it "initializes properly" do
10
+ @subject.new.must_respond_to :call
11
+ end
12
+ end
13
+
14
+ describe "as an instance" do
15
+ it "executes successfully" do
16
+ result = @subject.new.call
17
+ result.successful?.must_equal true
18
+ result.must_be_kind_of PayDirt::Result
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,24 @@
1
+ require 'test_helper'
2
+
3
+ describe USNO::Imagery::Earth::Sphere do
4
+ before do
5
+ @subject = USNO::Imagery::Earth::Sphere
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
+ end
24
+ end
@@ -0,0 +1,28 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'usno/imagery/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "usno-imagery"
8
+ spec.version = USNO::Imagery::VERSION
9
+ spec.authors = ["Ryan T. Hosford"]
10
+ spec.email = ["tad.hosford@gmail.com"]
11
+ spec.description = %q{Consumes USNO's imagery data services}
12
+
13
+ spec.summary = %q{Consumes USNO's imagery data services}
14
+ spec.homepage = ""
15
+ spec.license = "MIT"
16
+
17
+ spec.files = `git ls-files`.split($/)
18
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
19
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
20
+ spec.require_paths = ["lib"]
21
+
22
+ spec.add_development_dependency "bundler", "~> 1.3"
23
+ spec.add_development_dependency "rake"
24
+ spec.add_development_dependency "pry"
25
+ spec.add_development_dependency "coveralls"
26
+ spec.add_development_dependency "minitest"
27
+ spec.add_runtime_dependency "pay_dirt"
28
+ end
metadata ADDED
@@ -0,0 +1,150 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: usno-imagery
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Ryan T. Hosford
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2013-11-08 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ~>
18
+ - !ruby/object:Gem::Version
19
+ version: '1.3'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: '1.3'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: pry
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - '>='
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: coveralls
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - '>='
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: minitest
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'
83
+ - !ruby/object:Gem::Dependency
84
+ name: pay_dirt
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - '>='
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :runtime
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - '>='
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ description: Consumes USNO's imagery data services
98
+ email:
99
+ - tad.hosford@gmail.com
100
+ executables: []
101
+ extensions: []
102
+ extra_rdoc_files: []
103
+ files:
104
+ - .gitignore
105
+ - Gemfile
106
+ - LICENSE.txt
107
+ - README.md
108
+ - Rakefile
109
+ - lib/usno/imagery.rb
110
+ - lib/usno/imagery/earth/map.rb
111
+ - lib/usno/imagery/earth/rise.rb
112
+ - lib/usno/imagery/earth/set.rb
113
+ - lib/usno/imagery/earth/sphere.rb
114
+ - lib/usno/imagery/version.rb
115
+ - test/test_helper.rb
116
+ - test/unit/usno/imagery/earth/map_test.rb
117
+ - test/unit/usno/imagery/earth/rise_test.rb
118
+ - test/unit/usno/imagery/earth/set_test.rb
119
+ - test/unit/usno/imagery/earth/sphere_test.rb
120
+ - usno-imagery.gemspec
121
+ homepage: ''
122
+ licenses:
123
+ - MIT
124
+ metadata: {}
125
+ post_install_message:
126
+ rdoc_options: []
127
+ require_paths:
128
+ - lib
129
+ required_ruby_version: !ruby/object:Gem::Requirement
130
+ requirements:
131
+ - - '>='
132
+ - !ruby/object:Gem::Version
133
+ version: '0'
134
+ required_rubygems_version: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - '>='
137
+ - !ruby/object:Gem::Version
138
+ version: '0'
139
+ requirements: []
140
+ rubyforge_project:
141
+ rubygems_version: 2.0.3
142
+ signing_key:
143
+ specification_version: 4
144
+ summary: Consumes USNO's imagery data services
145
+ test_files:
146
+ - test/test_helper.rb
147
+ - test/unit/usno/imagery/earth/map_test.rb
148
+ - test/unit/usno/imagery/earth/rise_test.rb
149
+ - test/unit/usno/imagery/earth/set_test.rb
150
+ - test/unit/usno/imagery/earth/sphere_test.rb