nasa-neo 1.4.0 → 1.5.1
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/CHANGELOG.md +14 -0
- data/Gemfile.lock +1 -1
- data/README.md +35 -17
- data/lib/nasa-neo/client.rb +23 -4
- data/lib/nasa-neo/version.rb +1 -1
- data/nasa-neo.gemspec +2 -1
- metadata +4 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: e304e3dd4fd53330f9cd70ed863ef483c8b24c26ef8c62dc12241bdca5f890cf
|
|
4
|
+
data.tar.gz: c486ed0b64381d11a0afbf0cc5f5871e8dc5b01936c34e56451a74f4198a815c
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 2aa715513cd3759af993e14e3cad6574050a07566ef19182e6c269f8aaa21f1c33e770f07e11de037f676f358cf9803f510a1d3bc4d97ed01bc978fb9513dbd4
|
|
7
|
+
data.tar.gz: 7b3e99bbe0c0f837adc229a762bfff5590f308e6845d91442ae26a7a8d787a936bfe639e2e1ed4043621cb399597d5873a3270003424b90a99f6553a337e6f27
|
data/CHANGELOG.md
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
## [1.5.0] - 2018-04-14
|
|
4
|
+
|
|
5
|
+
### Added
|
|
6
|
+
|
|
7
|
+
- All information about Near Earth Objects can be returned, including all close approach data held on the object (Does require an additional API call within the gem to retrieve the verbose data). Added #neo_data_verbose method to .Client
|
|
8
|
+
- Updated README.md to include suggest environment variable for API key, new usage instructions for above method
|
|
9
|
+
|
|
10
|
+
## [1.4.0] - 2018-04-14
|
|
11
|
+
|
|
12
|
+
### Added
|
|
13
|
+
|
|
14
|
+
- Ability to see how many calls are remaining with your current API key. Added #calls_remaining method to .Client
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
|
@@ -40,6 +40,10 @@ The default setting is DEMO_KEY. This only needs to be set if you want to use yo
|
|
|
40
40
|
```
|
|
41
41
|
client.key = "MyKey"
|
|
42
42
|
```
|
|
43
|
+
or suggest using an environment variable eg.
|
|
44
|
+
```
|
|
45
|
+
client.key = ENV["NASA_API_KEY"]
|
|
46
|
+
```
|
|
43
47
|
|
|
44
48
|
#### Change the date
|
|
45
49
|
Default setting is the current day, only needs to be set if you want another day. Format: YYYY-MM-DD)
|
|
@@ -47,26 +51,20 @@ Default setting is the current day, only needs to be set if you want another day
|
|
|
47
51
|
client.date = "2019-04-10"
|
|
48
52
|
```
|
|
49
53
|
|
|
50
|
-
#### Update
|
|
54
|
+
#### Update API data stored
|
|
51
55
|
OPTIONAL: The Near Earth Object data for the date can be called and stored before any methods are run (otherwise the first information request method will make an API call and store the data)
|
|
52
56
|
```
|
|
53
57
|
client.update
|
|
54
58
|
```
|
|
55
59
|
|
|
56
|
-
#### Select Near Earth Object
|
|
57
|
-
Manually select a Near Earth Object for the date (if not a recognised number all data returned when methods are executed will be `nil`). Note: The intial set default is the first (closest). To find the total number of Near Earth Objects recorded for the date see `Find the total Near Earth Objects recorded for the date` in the next section.
|
|
58
|
-
|
|
59
|
-
Example(selects 2nd closest Near Earth Object):
|
|
60
|
-
```
|
|
61
|
-
client.neo_select(2)
|
|
62
|
-
```
|
|
63
|
-
|
|
64
60
|
Please Note: If the date or key is changed the next method requesting information will make an API call. You can use `update` (as above) to store the data in anticipation of running the methods beforehand if needed but is not necessary. Only one API call is made unless there are changes to the date, API key or `update` is run again.
|
|
65
61
|
|
|
66
62
|
|
|
67
63
|
### Retrieving Information
|
|
68
64
|
|
|
69
|
-
####
|
|
65
|
+
#### General
|
|
66
|
+
|
|
67
|
+
##### Find the number of API calls remaining using current key
|
|
70
68
|
```
|
|
71
69
|
client.calls_remaining
|
|
72
70
|
```
|
|
@@ -76,7 +74,7 @@ Example return:
|
|
|
76
74
|
```
|
|
77
75
|
Note: If an API call has not been made yet then an error hash is returned (`{:error=>"make new API call first"}`) as the calls remaining data is returned in the header of the API call. If an API key is changed then again an API call will need to be made first to retrieve this information.
|
|
78
76
|
|
|
79
|
-
|
|
77
|
+
##### Find the total Near Earth Objects recorded for the date
|
|
80
78
|
|
|
81
79
|
```
|
|
82
80
|
client.neo_total
|
|
@@ -86,7 +84,17 @@ Example return:
|
|
|
86
84
|
10
|
|
87
85
|
```
|
|
88
86
|
|
|
89
|
-
|
|
87
|
+
##### Select Near Earth Object
|
|
88
|
+
Manually select a Near Earth Object for the date (if not a recognised number all data returned when methods are executed will be `nil`). Note: The initial set default is the first (closest).
|
|
89
|
+
|
|
90
|
+
Example(selects 2nd closest Near Earth Object):
|
|
91
|
+
```
|
|
92
|
+
client.neo_select(2)
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
#### Current Selected Near Earth Object
|
|
96
|
+
|
|
97
|
+
##### Given name
|
|
90
98
|
|
|
91
99
|
```
|
|
92
100
|
client.neo_name
|
|
@@ -97,7 +105,8 @@ Example return:
|
|
|
97
105
|
```
|
|
98
106
|
|
|
99
107
|
|
|
100
|
-
|
|
108
|
+
##### Potential hazardousness boolean
|
|
109
|
+
Based on potential future Earth impact
|
|
101
110
|
```
|
|
102
111
|
client.hazardous?
|
|
103
112
|
```
|
|
@@ -106,7 +115,7 @@ Example return:
|
|
|
106
115
|
false
|
|
107
116
|
```
|
|
108
117
|
|
|
109
|
-
|
|
118
|
+
##### Estimated diameter
|
|
110
119
|
|
|
111
120
|
```
|
|
112
121
|
client.estimated_diameter
|
|
@@ -134,7 +143,7 @@ Example return:
|
|
|
134
143
|
183.8886720703
|
|
135
144
|
```
|
|
136
145
|
|
|
137
|
-
|
|
146
|
+
##### Miss distance to earth
|
|
138
147
|
|
|
139
148
|
```
|
|
140
149
|
client.miss_distance
|
|
@@ -154,7 +163,7 @@ Example return (converts string to float):
|
|
|
154
163
|
```
|
|
155
164
|
|
|
156
165
|
|
|
157
|
-
|
|
166
|
+
##### Velocity
|
|
158
167
|
|
|
159
168
|
```
|
|
160
169
|
client.velocity
|
|
@@ -174,7 +183,7 @@ Example return (converts string to float)
|
|
|
174
183
|
```
|
|
175
184
|
|
|
176
185
|
|
|
177
|
-
|
|
186
|
+
##### Raw data of Near Earth Object based on date
|
|
178
187
|
|
|
179
188
|
```
|
|
180
189
|
client.neo_data
|
|
@@ -185,6 +194,15 @@ Example return (all raw data on closest object):
|
|
|
185
194
|
{"links"=>{"self"=>"https://api.nasa.gov/neo/rest/v1/neo/3840869?api_key=DEMO_KEY"}, "id"=>"3840869", "neo_reference_id"=>"3840869", "name"=>"(2019 GK4)", "nasa_jpl_url"=>"http://ssd.jpl.nasa.gov/sbdb.cgi?sstr=3840869", "absolute_magnitude_h"=>23.83, "estimated_diameter"=>{"kilometers"=>{"estimated_diameter_min"=>0.0455569852, "estimated_diameter_max"=>0.1018685158}, "meters"=>{"estimated_diameter_min"=>45.5569852336, "estimated_diameter_max"=>101.8685158322}, "miles"=>{"estimated_diameter_min"=>0.0283077895, "estimated_diameter_max"=>0.0632981416}, "feet"=>{"estimated_diameter_min"=>149.4651794337, "estimated_diameter_max"=>334.214301483}}, "is_potentially_hazardous_asteroid"=>false, "close_approach_data"=>[{"close_approach_date"=>"2019-04-10", "epoch_date_close_approach"=>1554879600000, "relative_velocity"=>{"kilometers_per_second"=>"14.9701946153", "kilometers_per_hour"=>"53892.7006150984", "miles_per_hour"=>"33486.828334976"}, "miss_distance"=>{"astronomical"=>"0.089370038", "lunar"=>"34.7649421692", "kilometers"=>"13369567", "miles"=>"8307464"}, "orbiting_body"=>"Earth"}], "is_sentry_object"=>false}
|
|
186
195
|
```
|
|
187
196
|
|
|
197
|
+
##### All raw data held on selected Near Earth Object
|
|
198
|
+
```
|
|
199
|
+
client.neo_data_verbose
|
|
200
|
+
```
|
|
201
|
+
|
|
202
|
+
Returns all data held on the Near Earth Object. Includes all data on the dates of closest miss distances to Earth.
|
|
203
|
+
|
|
204
|
+
Note: This will initially make an addition API call to retrieve this information, but like the first API call will not make additional calls unless the selected Near Earth Object is changed.
|
|
205
|
+
|
|
188
206
|
### Exceptions
|
|
189
207
|
|
|
190
208
|
Exceptions are returned as a hash
|
data/lib/nasa-neo/client.rb
CHANGED
|
@@ -12,6 +12,7 @@ module NasaNeo
|
|
|
12
12
|
VELOCITY_OPTIONS = ["kilometers_per_second", "kilometers_per_hour", "miles_per_hour"]
|
|
13
13
|
|
|
14
14
|
NEO_NAME_KEYS = ["name"]
|
|
15
|
+
NEO_ID_KEYS = ["id"]
|
|
15
16
|
HAZARDOUS_KEYS = ["is_potentially_hazardous_asteroid"]
|
|
16
17
|
ESTIMATED_DIAMETER_KEYS = ["estimated_diameter"]
|
|
17
18
|
MISS_DISTANCE_KEYS = ["close_approach_data", 0, "miss_distance"]
|
|
@@ -26,7 +27,10 @@ module NasaNeo
|
|
|
26
27
|
@key = config.api_key
|
|
27
28
|
@date = parsed_date
|
|
28
29
|
@full_url = nil
|
|
30
|
+
@full_url_neo = nil
|
|
31
|
+
@neo_id = nil
|
|
29
32
|
@result = nil
|
|
33
|
+
@result_neo = nil
|
|
30
34
|
@neo_position = 0
|
|
31
35
|
end
|
|
32
36
|
|
|
@@ -61,7 +65,7 @@ module NasaNeo
|
|
|
61
65
|
end
|
|
62
66
|
|
|
63
67
|
def neo_data_verbose
|
|
64
|
-
|
|
68
|
+
call_and_rescue { retrieve_neo_verbose }
|
|
65
69
|
end
|
|
66
70
|
|
|
67
71
|
def neo_total
|
|
@@ -86,8 +90,8 @@ module NasaNeo
|
|
|
86
90
|
|
|
87
91
|
private
|
|
88
92
|
|
|
89
|
-
def buffer_url
|
|
90
|
-
api_data = open(
|
|
93
|
+
def buffer_url(url)
|
|
94
|
+
api_data = open(url)
|
|
91
95
|
@calls_remaining = api_data.meta['x-ratelimit-remaining'].to_i
|
|
92
96
|
api_data.read
|
|
93
97
|
end
|
|
@@ -96,13 +100,14 @@ module NasaNeo
|
|
|
96
100
|
yield if block_given?
|
|
97
101
|
rescue OpenURI::HTTPError => e
|
|
98
102
|
@full_url = nil
|
|
103
|
+
@full_url_neo = nil
|
|
99
104
|
error_feedback(e.io.status)
|
|
100
105
|
end
|
|
101
106
|
|
|
102
107
|
def get_api_data
|
|
103
108
|
@full_url = set_full_url
|
|
104
109
|
@neo_position = 0
|
|
105
|
-
buffer = JSON.parse(buffer_url)
|
|
110
|
+
buffer = JSON.parse(buffer_url(@full_url))
|
|
106
111
|
@result = buffer
|
|
107
112
|
end
|
|
108
113
|
|
|
@@ -116,6 +121,16 @@ module NasaNeo
|
|
|
116
121
|
@result.dig(*root_keys + keys)
|
|
117
122
|
end
|
|
118
123
|
|
|
124
|
+
def retrieve_neo_verbose
|
|
125
|
+
@neo_id = retrieve_neo(NEO_ID_KEYS)
|
|
126
|
+
if @full_url_neo != set_full_url_neo
|
|
127
|
+
@full_url_neo = set_full_url_neo
|
|
128
|
+
@result_neo = JSON.parse(buffer_url(@full_url_neo))
|
|
129
|
+
else
|
|
130
|
+
@result_neo
|
|
131
|
+
end
|
|
132
|
+
end
|
|
133
|
+
|
|
119
134
|
def retrieve_specific(options, keys, measurement, min_max = nil)
|
|
120
135
|
if options.include? measurement
|
|
121
136
|
chained_keys = retrieve_neo(keys + ["#{measurement}"])
|
|
@@ -142,6 +157,10 @@ module NasaNeo
|
|
|
142
157
|
"#{@config.host}/feed?start_date=#{@date}&end_date=#{@date}&detailed=false&api_key=#{@key}"
|
|
143
158
|
end
|
|
144
159
|
|
|
160
|
+
def set_full_url_neo
|
|
161
|
+
"#{@config.host}/neo/#{@neo_id}?api_key=#{@key}"
|
|
162
|
+
end
|
|
163
|
+
|
|
145
164
|
end
|
|
146
165
|
end
|
|
147
166
|
end
|
data/lib/nasa-neo/version.rb
CHANGED
data/nasa-neo.gemspec
CHANGED
|
@@ -4,7 +4,7 @@ require "nasa-neo/version"
|
|
|
4
4
|
|
|
5
5
|
Gem::Specification.new do |s|
|
|
6
6
|
s.name = 'nasa-neo'
|
|
7
|
-
s.version = '1.
|
|
7
|
+
s.version = '1.5.1'
|
|
8
8
|
s.date = '2019-04-09'
|
|
9
9
|
s.summary = "This gem provides a simple wrapper for https://api.nasa.gov/api.html#NeoWS API"
|
|
10
10
|
s.description = "Retrieve information about the closest near earth objects on any given day using the NASA NEO API. "
|
|
@@ -12,6 +12,7 @@ Gem::Specification.new do |s|
|
|
|
12
12
|
s.email = 'jrsutherland78@googlemail.com'
|
|
13
13
|
s.homepage = 'https://github.com/LondonJim/NASA-NEO-API-Wrapper'
|
|
14
14
|
s.license = 'MIT'
|
|
15
|
+
s.metadata = { "changelog_uri" => "https://github.com/LondonJim/NASA-NEO-API-Wrapper/blob/master/CHANGELOG.md" }
|
|
15
16
|
|
|
16
17
|
s.files = Dir.chdir(File.expand_path('..', __FILE__)) do
|
|
17
18
|
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: nasa-neo
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.
|
|
4
|
+
version: 1.5.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- James Sutherland
|
|
@@ -88,6 +88,7 @@ files:
|
|
|
88
88
|
- ".gitignore"
|
|
89
89
|
- ".rspec"
|
|
90
90
|
- ".travis.yml"
|
|
91
|
+
- CHANGELOG.md
|
|
91
92
|
- Gemfile
|
|
92
93
|
- Gemfile.lock
|
|
93
94
|
- LICENSE.txt
|
|
@@ -104,7 +105,8 @@ files:
|
|
|
104
105
|
homepage: https://github.com/LondonJim/NASA-NEO-API-Wrapper
|
|
105
106
|
licenses:
|
|
106
107
|
- MIT
|
|
107
|
-
metadata:
|
|
108
|
+
metadata:
|
|
109
|
+
changelog_uri: https://github.com/LondonJim/NASA-NEO-API-Wrapper/blob/master/CHANGELOG.md
|
|
108
110
|
post_install_message:
|
|
109
111
|
rdoc_options: []
|
|
110
112
|
require_paths:
|