SnowNasa 0.1.0 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +16 -2
- data/README.md +28 -13
- data/SnowNasa.gemspec +1 -1
- data/lib/SnowNasa/{astro_pic_of_day.rb → apod.rb} +3 -3
- data/lib/SnowNasa/{earth_imagery.rb → earthimg.rb} +6 -6
- data/lib/SnowNasa/{mars_rover_photos.rb → marsroverphotos.rb} +15 -11
- data/lib/SnowNasa/neobjects.rb +13 -0
- data/lib/SnowNasa/version.rb +1 -1
- data/lib/SnowNasa.rb +5 -5
- data/lib/generators/snow_nasa/config/USAGE +5 -0
- data/lib/generators/snow_nasa/config/config_generator.rb +12 -0
- data/lib/generators/snow_nasa/config/templates/config.rb.erb +1 -0
- metadata +9 -6
- data/lib/SnowNasa/near_earth_objects.rb +0 -14
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3cbb447a87150c85434d5af9ae612800fc9b51be
|
4
|
+
data.tar.gz: 01a6d179b06b9a9ca771f902c77b18ecbb14b7e2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6090a0b92d8aa8959ec780ed9d9264730065a84b5c91bc46fc8c2860ca08bb0bb37a3c179f9bfdd84cf1c7874747a9d8f86c577463a765401a6172772ec1a374
|
7
|
+
data.tar.gz: 34db1d91416900a6579b725077f9d1a926c72d8ba7df5a424a2bbc2e835c36a47662c80598154d664987e54ca15ac584e79e980c3885316515d90367f1df37cb
|
data/.travis.yml
CHANGED
@@ -1,4 +1,18 @@
|
|
1
1
|
language: ruby
|
2
|
+
|
3
|
+
|
4
|
+
before_install: gem install bundler -v 1.10.6
|
5
|
+
|
6
|
+
|
7
|
+
env:
|
8
|
+
- RAILS_VERSION="~> 3.2.22"
|
9
|
+
- RAILS_VERSION="~> 4.0.13"
|
10
|
+
- RAILS_VERSION="~> 4.1.13"
|
11
|
+
- RAILS_VERSION="~> 4.2.4"
|
12
|
+
|
2
13
|
rvm:
|
3
|
-
-
|
4
|
-
|
14
|
+
- 1.9.3
|
15
|
+
- 2.0.0
|
16
|
+
- 2.1.4
|
17
|
+
- 2.2.2
|
18
|
+
|
data/README.md
CHANGED
@@ -1,9 +1,5 @@
|
|
1
1
|
# SnowNasa
|
2
2
|
|
3
|
-
Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/SnowNasa`. To experiment with that code, run `bin/console` for an interactive prompt.
|
4
|
-
|
5
|
-
TODO: Delete this and the text above, and describe your gem
|
6
|
-
|
7
3
|
## Installation
|
8
4
|
|
9
5
|
Add this line to your application's Gemfile:
|
@@ -20,22 +16,41 @@ Or install it yourself as:
|
|
20
16
|
|
21
17
|
$ gem install SnowNasa
|
22
18
|
|
23
|
-
##
|
19
|
+
## Install the initializer
|
20
|
+
```ruby
|
21
|
+
rails g snow_nasa:config
|
22
|
+
#this is optional and it makes it easy to set the nasa_api_key only once, otherwise you will need to set the nasa_api_key global each time you make a request.
|
23
|
+
```
|
24
24
|
|
25
|
-
|
25
|
+
## Get the Astronomy Picture of the Day
|
26
26
|
|
27
|
-
|
27
|
+
```ruby
|
28
|
+
SnowNasa::Apod.getAstroPic
|
29
|
+
```
|
28
30
|
|
29
|
-
|
31
|
+
## Get Earth Images
|
30
32
|
|
31
|
-
|
33
|
+
```ruby
|
34
|
+
SnowNasa::Earthimg.getEarthImages(:lat => "1.5", :lon => "100.75", :date => "2014-02-01", :cloud_code => "True")
|
35
|
+
#cloud_code is optional.
|
36
|
+
```
|
32
37
|
|
33
|
-
##
|
38
|
+
## Get Mars Rover Pics
|
34
39
|
|
35
|
-
|
40
|
+
Get a list of cameras attached to the rovers
|
36
41
|
|
42
|
+
```ruby
|
43
|
+
SnowNasa::Marsroverphotos.cameras
|
44
|
+
```
|
37
45
|
|
38
|
-
|
46
|
+
Get pictures from the rover
|
39
47
|
|
40
|
-
|
48
|
+
```ruby
|
49
|
+
SnowNasa::Marsroverphotos.getMarsPics(:sol => "1000", :camera => "fhaz", :page => "1", :rover => "curiosity")
|
50
|
+
```
|
41
51
|
|
52
|
+
## Get Near Earth Objects (Asteroids)
|
53
|
+
|
54
|
+
```ruby
|
55
|
+
SnowNasa::Neobjects.getNeo(:start_date => "2016-05-27", :end_date => "2016-05-31")
|
56
|
+
```
|
data/SnowNasa.gemspec
CHANGED
@@ -6,7 +6,7 @@ require 'SnowNasa/version'
|
|
6
6
|
Gem::Specification.new do |spec|
|
7
7
|
spec.name = "SnowNasa"
|
8
8
|
spec.version = SnowNasa::VERSION
|
9
|
-
spec.authors = ["Justin"]
|
9
|
+
spec.authors = ["Justin Snow"]
|
10
10
|
spec.email = ["jrsnow8921@gmail.com"]
|
11
11
|
|
12
12
|
spec.summary = %q{A gem to interact with Nasa's api}
|
@@ -1,11 +1,11 @@
|
|
1
1
|
module SnowNasa
|
2
|
-
class
|
2
|
+
class Apod
|
3
3
|
include SnowNasa
|
4
4
|
|
5
5
|
def self.getAstroPic
|
6
6
|
base_url = "https://api.nasa.gov/planetary/apod?api_key=#{@@nasa_api_key}"
|
7
7
|
data = open(base_url).read
|
8
8
|
JSON.parse(data)
|
9
|
-
end
|
9
|
+
end
|
10
10
|
end
|
11
|
-
end
|
11
|
+
end
|
@@ -1,20 +1,20 @@
|
|
1
1
|
module SnowNasa
|
2
|
-
class
|
2
|
+
class Earthimg
|
3
3
|
include SnowNasa
|
4
4
|
|
5
5
|
def self.getEarthImages(options = {})
|
6
6
|
lat = options[:lat]
|
7
7
|
lon = options[:lon]
|
8
8
|
dim = options[:dim]
|
9
|
-
date = (options[:date].
|
9
|
+
date = (options[:date].to_date).strftime("%Y-%m-%d")
|
10
10
|
cloud_score = options[:cloud_score]
|
11
11
|
if cloud_score.nil?
|
12
|
-
base_url = "https://api.nasa.gov/planetary/earth/imagery?lon=#{lon}&lat=#{lat}&date=#{date}&api_key=#{nasa_api_key}"
|
12
|
+
base_url = "https://api.nasa.gov/planetary/earth/imagery?lon=#{lon}&lat=#{lat}&date=#{date}&api_key=#{@@nasa_api_key}"
|
13
13
|
else
|
14
|
-
base_url = "https://api.nasa.gov/planetary/earth/imagery?lon=#{lon}&lat=#{lat}&date=#{date}&cloud_score=True&api_key=#{nasa_api_key}"
|
14
|
+
base_url = "https://api.nasa.gov/planetary/earth/imagery?lon=#{lon}&lat=#{lat}&date=#{date}&cloud_score=True&api_key=#{@@nasa_api_key}"
|
15
15
|
end
|
16
16
|
data = open(base_url).read
|
17
17
|
JSON.parse(data)
|
18
18
|
end
|
19
|
-
end
|
20
|
-
end
|
19
|
+
end
|
20
|
+
end
|
@@ -1,5 +1,5 @@
|
|
1
1
|
module SnowNasa
|
2
|
-
class
|
2
|
+
class Marsroverphotos
|
3
3
|
include SnowNasa
|
4
4
|
|
5
5
|
def self.cameras
|
@@ -11,19 +11,19 @@ module SnowNasa
|
|
11
11
|
mardi = "(MARDI)= Mars Descent Imager- This is onboard Curiousity only\n".yellow
|
12
12
|
navcam = "(NAVCAM)= Navigation Camera- This is onboard Curiousity, Opportunity, and Spirit\n".red
|
13
13
|
pancam = "(PANCAM)= Panoramic Camera- This is onboard Opportunity, and Spirit\n".green
|
14
|
-
minites = "(MINITES)= Minature Thermal Emission Spectrometer(Mini-TES)- This in onbard Opportunity, and Spirit\n".yellow
|
14
|
+
minites = "(MINITES)= Minature Thermal Emission Spectrometer(Mini-TES)- This in onbard Opportunity, and Spirit\n".yellow
|
15
15
|
cams =(
|
16
16
|
fhaz +
|
17
17
|
rhaz +
|
18
|
-
mast +
|
18
|
+
mast +
|
19
19
|
chemcam +
|
20
20
|
mahli +
|
21
21
|
mardi +
|
22
|
-
navcam +
|
23
|
-
pancam +
|
22
|
+
navcam +
|
23
|
+
pancam +
|
24
24
|
minites)
|
25
25
|
list_cams = cams.split(/\n+/).each { |x| puts x }
|
26
|
-
return nil
|
26
|
+
return nil
|
27
27
|
end
|
28
28
|
|
29
29
|
def self.getMarsPics(options = {})
|
@@ -32,10 +32,14 @@ module SnowNasa
|
|
32
32
|
page = options[:page].to_i
|
33
33
|
rover = options[:rover]
|
34
34
|
if camera.nil?
|
35
|
-
base_url = "https://api.nasa.gov/mars-photos/api/v1/rovers/#{rover}/photos?sol=#{sol}&api_key=#{nasa_api_key}
|
36
|
-
else
|
37
|
-
base_url = "https://api.nasa.gov/mars-photos/api/v1/rovers/#{rover}/photos?sol=#{sol}&camera=#{camera}&api_key=#{nasa_api_key}
|
38
|
-
end
|
35
|
+
base_url = "https://api.nasa.gov/mars-photos/api/v1/rovers/#{rover}/photos?sol=#{sol}&api_key=#{@@nasa_api_key}"
|
36
|
+
else
|
37
|
+
base_url = "https://api.nasa.gov/mars-photos/api/v1/rovers/#{rover}/photos?sol=#{sol}&camera=#{camera}&api_key=#{@@nasa_api_key}"
|
38
|
+
end
|
39
|
+
data = open(base_url).read
|
40
|
+
JSON.parse(data)
|
39
41
|
end
|
40
|
-
end
|
42
|
+
end
|
41
43
|
end
|
44
|
+
|
45
|
+
|
@@ -0,0 +1,13 @@
|
|
1
|
+
module SnowNasa
|
2
|
+
class Neobjects
|
3
|
+
include SnowNasa
|
4
|
+
|
5
|
+
def self.getNeo(options = {})
|
6
|
+
start_date = (options[:start_date].to_date).strftime("%Y-%m-%d")
|
7
|
+
end_date = (options[:end_date].to_date).strftime("%Y-%m-%d")
|
8
|
+
base_url = "https://api.nasa.gov/neo/rest/v1/feed?start_date=#{start_date}&end_date=#{end_date}&api_key=#{@@nasa_api_key}"
|
9
|
+
data = open(base_url).read
|
10
|
+
JSON.parse(data)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
data/lib/SnowNasa/version.rb
CHANGED
data/lib/SnowNasa.rb
CHANGED
@@ -1,8 +1,8 @@
|
|
1
|
-
require
|
2
|
-
require
|
3
|
-
require
|
4
|
-
require
|
5
|
-
require
|
1
|
+
require 'SnowNasa/version'
|
2
|
+
require 'SnowNasa/apod'
|
3
|
+
require 'SnowNasa/neobjects'
|
4
|
+
require 'SnowNasa/earthimg'
|
5
|
+
require 'SnowNasa/marsroverphotos'
|
6
6
|
|
7
7
|
|
8
8
|
|
@@ -0,0 +1,12 @@
|
|
1
|
+
module SnowNasa
|
2
|
+
module Generators
|
3
|
+
|
4
|
+
class ConfigGenerator < ::Rails::Generators::Base
|
5
|
+
source_root File.expand_path('../templates', __FILE__)
|
6
|
+
|
7
|
+
def generate_config
|
8
|
+
template "config.rb.erb", "config/initializers/snow_nasa.rb"
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
SnowNasa.nasa_api_key('your_nasa_api_key_goes_here')
|
metadata
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: SnowNasa
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
|
-
- Justin
|
7
|
+
- Justin Snow
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
@@ -127,11 +127,14 @@ files:
|
|
127
127
|
- bin/console
|
128
128
|
- bin/setup
|
129
129
|
- lib/SnowNasa.rb
|
130
|
-
- lib/SnowNasa/
|
131
|
-
- lib/SnowNasa/
|
132
|
-
- lib/SnowNasa/
|
133
|
-
- lib/SnowNasa/
|
130
|
+
- lib/SnowNasa/apod.rb
|
131
|
+
- lib/SnowNasa/earthimg.rb
|
132
|
+
- lib/SnowNasa/marsroverphotos.rb
|
133
|
+
- lib/SnowNasa/neobjects.rb
|
134
134
|
- lib/SnowNasa/version.rb
|
135
|
+
- lib/generators/snow_nasa/config/USAGE
|
136
|
+
- lib/generators/snow_nasa/config/config_generator.rb
|
137
|
+
- lib/generators/snow_nasa/config/templates/config.rb.erb
|
135
138
|
homepage: ''
|
136
139
|
licenses:
|
137
140
|
- MIT
|
@@ -1,14 +0,0 @@
|
|
1
|
-
module SnowNasa
|
2
|
-
class NearEarthObjects
|
3
|
-
include SnowNasa
|
4
|
-
|
5
|
-
def self.getNeo(options = {})
|
6
|
-
start_date = (options[:start_date].to_d).strftime("%Y-%m-%d")
|
7
|
-
end_date = (options[:end_date].to_d).strftime("%Y-%m-%d")
|
8
|
-
base_url = "https://api.nasa.gov/neo/rest/v1/feed?start_date=#{start_date}&end_date=#{end_date}&api_key=#{nasa_api_key}"
|
9
|
-
data = open(base_url).read
|
10
|
-
JSON.parse(data)
|
11
|
-
end
|
12
|
-
end
|
13
|
-
end
|
14
|
-
|