nasa-neo 1.2.0 → 1.3.0
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/Gemfile.lock +1 -1
- data/README.md +49 -6
- data/lib/nasa-neo/client.rb +33 -6
- data/lib/nasa-neo/version.rb +1 -1
- data/nasa-neo.gemspec +3 -3
- metadata +15 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 4e8cccaef829829caefbcee2843bb441f08427449c8076fd8afa1cdbce0ab3c0
|
|
4
|
+
data.tar.gz: 54609efcbeea0aecc441b4296c9407f055c28519aef8694929670a71519b95b5
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 5befcec2be629c56d42b01f51915ca2ff3fcb4c246ccea85cec8f7479413a43c9b89bff52f66bd63652304b82626d1f5d6a0b12e375b48e2a5c2e2c892cfbdbb
|
|
7
|
+
data.tar.gz: 8205c94b409fda38978412190fc30f0d2a233ecea2a9b72189a8f88c32a7d04433229f1aa4050bd062d99b589539008f0bd0632d3cb23e86e40c2bde48c68751
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# NASA Near Earth Object API Wrapper
|
|
2
2
|
|
|
3
|
-
Gives details on the closest Near Earth
|
|
3
|
+
Gives details on the closest Near Earth Objects of the day. All Near Earth Objects can now be individually selected. Currently the NEO API only holds data from 1900 to 2200, any requests for information outside these years will return nil. Data is also limited to encounters with reasonably low uncertainty.
|
|
4
4
|
|
|
5
5
|
## Installation
|
|
6
6
|
|
|
@@ -25,25 +25,58 @@ Or install it yourself as:
|
|
|
25
25
|
### Configuration
|
|
26
26
|
A default api key of DEMO_KEY will let you make up to 30 requests per hour (50 per day), if you have your own api key (https://api.nasa.gov/index.html#apply-for-an-api-key) you can set it as detailed under instructions (developer API keys allow up to 1000 requests an hour)
|
|
27
27
|
|
|
28
|
-
|
|
28
|
+
|
|
29
|
+
#### Create client
|
|
30
|
+
|
|
31
|
+
Set the API key (only needs to be done if you want to use your own API key, default setting is DEMO_KEY)
|
|
29
32
|
|
|
30
33
|
```
|
|
31
34
|
client = NasaNeo::CloseObj.configure
|
|
32
35
|
```
|
|
33
36
|
|
|
34
|
-
|
|
37
|
+
|
|
38
|
+
#### Set the API key
|
|
39
|
+
|
|
40
|
+
(only needs to be done if you want to use your own API key, default setting is DEMO_KEY)
|
|
35
41
|
```
|
|
36
42
|
client.key = "MyKey"
|
|
37
43
|
```
|
|
38
44
|
|
|
39
|
-
Change the date
|
|
45
|
+
#### Change the date
|
|
46
|
+
(only needs to be done if you want to select another date, default setting is the current day. Format: YYYY-MM-DD)
|
|
40
47
|
```
|
|
41
48
|
client.date = "2019-04-10"
|
|
42
49
|
```
|
|
43
|
-
|
|
50
|
+
|
|
51
|
+
#### Update
|
|
52
|
+
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)
|
|
53
|
+
```
|
|
54
|
+
client.update
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
#### Select Near Earth Object
|
|
58
|
+
Manually select a Near Earth Object for the date (if not a recognised number all data returned will be `nil`). Note: The 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.
|
|
59
|
+
|
|
60
|
+
Example(selects 2nd closest Near Earth Object):
|
|
61
|
+
```
|
|
62
|
+
client.neo_select(2)
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
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.
|
|
66
|
+
|
|
44
67
|
|
|
45
68
|
### Retrieving Information
|
|
46
69
|
|
|
70
|
+
#### Find the total Near Earth Objects recorded for the date
|
|
71
|
+
|
|
72
|
+
```
|
|
73
|
+
client.neo_total
|
|
74
|
+
```
|
|
75
|
+
Example return:
|
|
76
|
+
```
|
|
77
|
+
10
|
|
78
|
+
```
|
|
79
|
+
|
|
47
80
|
#### Given name
|
|
48
81
|
|
|
49
82
|
```
|
|
@@ -132,7 +165,7 @@ Example return (converts string to float)
|
|
|
132
165
|
```
|
|
133
166
|
|
|
134
167
|
|
|
135
|
-
#### All data on closest object
|
|
168
|
+
#### All data on closest object selected
|
|
136
169
|
|
|
137
170
|
```
|
|
138
171
|
client.neo_data
|
|
@@ -166,6 +199,16 @@ Returns:
|
|
|
166
199
|
```
|
|
167
200
|
{:error=>["measurement", "check argument"]}
|
|
168
201
|
```
|
|
202
|
+
---
|
|
203
|
+
Example of return if information no present, eg. if selected number of Near Earth Object is not present:
|
|
204
|
+
```
|
|
205
|
+
client.neo_select(99)
|
|
206
|
+
client.neo_name
|
|
207
|
+
```
|
|
208
|
+
Returns:
|
|
209
|
+
```
|
|
210
|
+
nil
|
|
211
|
+
```
|
|
169
212
|
|
|
170
213
|
|
|
171
214
|
### Testing
|
data/lib/nasa-neo/client.rb
CHANGED
|
@@ -15,6 +15,7 @@ module NasaNeo
|
|
|
15
15
|
@date = parsed_date
|
|
16
16
|
@full_url = nil
|
|
17
17
|
@result = nil
|
|
18
|
+
@neo_position = 0
|
|
18
19
|
@estimated_diameter_options = ["kilometers", "meters", "miles", "feet"]
|
|
19
20
|
@miss_distance_options = ["astronomical", "lunar", "kilometers", "miles"]
|
|
20
21
|
@velocity_options = ["kilometers_per_second", "kilometers_per_hour", "miles_per_hour"]
|
|
@@ -35,7 +36,7 @@ module NasaNeo
|
|
|
35
36
|
end
|
|
36
37
|
|
|
37
38
|
def hazardous?
|
|
38
|
-
call_and_rescue {
|
|
39
|
+
call_and_rescue { hazardous_data }
|
|
39
40
|
end
|
|
40
41
|
|
|
41
42
|
def miss_distance(measurement = nil)
|
|
@@ -48,13 +49,26 @@ module NasaNeo
|
|
|
48
49
|
end
|
|
49
50
|
|
|
50
51
|
def neo_name
|
|
51
|
-
call_and_rescue {
|
|
52
|
+
call_and_rescue { neo_name_data }
|
|
52
53
|
end
|
|
53
54
|
|
|
54
55
|
def neo_data
|
|
55
56
|
call_and_rescue { retrieve_neo }
|
|
56
57
|
end
|
|
57
58
|
|
|
59
|
+
def neo_total
|
|
60
|
+
call_and_rescue { get_api_data } if @full_url != set_full_url
|
|
61
|
+
@result["element_count"]
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
def update
|
|
65
|
+
call_and_rescue { get_api_data }
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
def neo_select(n)
|
|
69
|
+
@neo_position = n - 1
|
|
70
|
+
end
|
|
71
|
+
|
|
58
72
|
def velocity(measurement = nil)
|
|
59
73
|
if @velocity_options.include? measurement
|
|
60
74
|
call_and_rescue { velocity_data[measurement].to_f }
|
|
@@ -89,23 +103,36 @@ module NasaNeo
|
|
|
89
103
|
|
|
90
104
|
def retrieve_neo
|
|
91
105
|
get_api_data if @full_url != set_full_url
|
|
92
|
-
@result
|
|
106
|
+
@result.dig("near_earth_objects", "#{@date}", @neo_position)
|
|
93
107
|
end
|
|
94
108
|
|
|
95
109
|
def estimated_diameter_data
|
|
96
|
-
retrieve_neo
|
|
110
|
+
data = retrieve_neo
|
|
111
|
+
data == nil ? nil : data["estimated_diameter"]
|
|
97
112
|
end
|
|
98
113
|
|
|
99
114
|
def error_feedback(error_info)
|
|
100
115
|
{ 'error': error_info }
|
|
101
116
|
end
|
|
102
117
|
|
|
118
|
+
def hazardous_data
|
|
119
|
+
data = retrieve_neo
|
|
120
|
+
data == nil ? nil : data["is_potentially_hazardous_asteroid"]
|
|
121
|
+
end
|
|
122
|
+
|
|
103
123
|
def miss_distance_data
|
|
104
|
-
retrieve_neo
|
|
124
|
+
data = retrieve_neo
|
|
125
|
+
data == nil ? nil : data["close_approach_data"][0]["miss_distance"]
|
|
126
|
+
end
|
|
127
|
+
|
|
128
|
+
def neo_name_data
|
|
129
|
+
data = retrieve_neo
|
|
130
|
+
data == nil ? nil : data["name"]
|
|
105
131
|
end
|
|
106
132
|
|
|
107
133
|
def velocity_data
|
|
108
|
-
retrieve_neo
|
|
134
|
+
data = retrieve_neo
|
|
135
|
+
data == nil ? nil : data["close_approach_data"][0]["relative_velocity"]
|
|
109
136
|
end
|
|
110
137
|
|
|
111
138
|
def set_full_url
|
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.3.0'
|
|
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 object on any given day using the NASA NEO API. "
|
|
@@ -20,8 +20,8 @@ Gem::Specification.new do |s|
|
|
|
20
20
|
s.bindir = 'bin'
|
|
21
21
|
s.require_paths = ['lib']
|
|
22
22
|
|
|
23
|
-
s.add_development_dependency 'bundler', '~> 2.0.1'
|
|
23
|
+
s.add_development_dependency 'bundler', '~> 2.0', '>= 2.0.1'
|
|
24
24
|
s.add_development_dependency 'rake', '~> 10.0'
|
|
25
25
|
s.add_development_dependency 'rspec', '~> 3.8'
|
|
26
|
-
s.add_development_dependency 'webmock', '~> 3.5.1'
|
|
26
|
+
s.add_development_dependency 'webmock', '~> 3.5', '>= 3.5.1'
|
|
27
27
|
end
|
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.3.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- James Sutherland
|
|
@@ -15,6 +15,9 @@ dependencies:
|
|
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
|
16
16
|
requirements:
|
|
17
17
|
- - "~>"
|
|
18
|
+
- !ruby/object:Gem::Version
|
|
19
|
+
version: '2.0'
|
|
20
|
+
- - ">="
|
|
18
21
|
- !ruby/object:Gem::Version
|
|
19
22
|
version: 2.0.1
|
|
20
23
|
type: :development
|
|
@@ -22,6 +25,9 @@ dependencies:
|
|
|
22
25
|
version_requirements: !ruby/object:Gem::Requirement
|
|
23
26
|
requirements:
|
|
24
27
|
- - "~>"
|
|
28
|
+
- !ruby/object:Gem::Version
|
|
29
|
+
version: '2.0'
|
|
30
|
+
- - ">="
|
|
25
31
|
- !ruby/object:Gem::Version
|
|
26
32
|
version: 2.0.1
|
|
27
33
|
- !ruby/object:Gem::Dependency
|
|
@@ -57,6 +63,9 @@ dependencies:
|
|
|
57
63
|
requirement: !ruby/object:Gem::Requirement
|
|
58
64
|
requirements:
|
|
59
65
|
- - "~>"
|
|
66
|
+
- !ruby/object:Gem::Version
|
|
67
|
+
version: '3.5'
|
|
68
|
+
- - ">="
|
|
60
69
|
- !ruby/object:Gem::Version
|
|
61
70
|
version: 3.5.1
|
|
62
71
|
type: :development
|
|
@@ -64,6 +73,9 @@ dependencies:
|
|
|
64
73
|
version_requirements: !ruby/object:Gem::Requirement
|
|
65
74
|
requirements:
|
|
66
75
|
- - "~>"
|
|
76
|
+
- !ruby/object:Gem::Version
|
|
77
|
+
version: '3.5'
|
|
78
|
+
- - ">="
|
|
67
79
|
- !ruby/object:Gem::Version
|
|
68
80
|
version: 3.5.1
|
|
69
81
|
description: 'Retrieve information about the closest near earth object on any given
|
|
@@ -108,7 +120,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
108
120
|
- !ruby/object:Gem::Version
|
|
109
121
|
version: '0'
|
|
110
122
|
requirements: []
|
|
111
|
-
|
|
123
|
+
rubyforge_project:
|
|
124
|
+
rubygems_version: 2.7.9
|
|
112
125
|
signing_key:
|
|
113
126
|
specification_version: 4
|
|
114
127
|
summary: This gem provides a simple wrapper for https://api.nasa.gov/api.html#NeoWS
|