nasa-neo 1.3.4 → 1.4.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 +24 -6
- data/lib/nasa-neo/client.rb +21 -3
- data/lib/nasa-neo/configuration.rb +1 -1
- data/lib/nasa-neo/version.rb +1 -1
- data/nasa-neo.gemspec +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 678cc5393770218011a9bf255c32dd0f473a369481960690c52b3b0b81caa61a
|
|
4
|
+
data.tar.gz: 19b6c4c0e4a91c07d928ac150d30b8d51eb9f0785e9fa8d12d9b0af82e7f6d60
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: b115799b57f72e9da828895b45df3f5791e3ea318a0357b32b9e46295d84bfa4ba47d94427309734921282a1687430158b51c8e28ecc362fc5c94a2434474171
|
|
7
|
+
data.tar.gz: d51e25603e176b084c10165fdc258615fcee0ac8ff9a69e14833a269caaf1597772a7bbf2428bb9ebb6024d4575c8c3a460d43a25765e629d14e29f169e805ec
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
|
@@ -36,14 +36,13 @@ client = NasaNeo::CloseObj.configure
|
|
|
36
36
|
|
|
37
37
|
|
|
38
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)
|
|
39
|
+
The default setting is DEMO_KEY. This only needs to be set if you want to use your own API key.
|
|
41
40
|
```
|
|
42
41
|
client.key = "MyKey"
|
|
43
42
|
```
|
|
44
43
|
|
|
45
44
|
#### Change the date
|
|
46
|
-
|
|
45
|
+
Default setting is the current day, only needs to be set if you want another day. Format: YYYY-MM-DD)
|
|
47
46
|
```
|
|
48
47
|
client.date = "2019-04-10"
|
|
49
48
|
```
|
|
@@ -55,7 +54,7 @@ client.update
|
|
|
55
54
|
```
|
|
56
55
|
|
|
57
56
|
#### 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.
|
|
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.
|
|
59
58
|
|
|
60
59
|
Example(selects 2nd closest Near Earth Object):
|
|
61
60
|
```
|
|
@@ -67,6 +66,16 @@ Please Note: If the date or key is changed the next method requesting informatio
|
|
|
67
66
|
|
|
68
67
|
### Retrieving Information
|
|
69
68
|
|
|
69
|
+
#### Find the number of API calls remaining using current key
|
|
70
|
+
```
|
|
71
|
+
client.calls_remaining
|
|
72
|
+
```
|
|
73
|
+
Example return:
|
|
74
|
+
```
|
|
75
|
+
29
|
|
76
|
+
```
|
|
77
|
+
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
|
+
|
|
70
79
|
#### Find the total Near Earth Objects recorded for the date
|
|
71
80
|
|
|
72
81
|
```
|
|
@@ -92,7 +101,7 @@ Example return:
|
|
|
92
101
|
```
|
|
93
102
|
client.hazardous?
|
|
94
103
|
```
|
|
95
|
-
Example return
|
|
104
|
+
Example return:
|
|
96
105
|
```
|
|
97
106
|
false
|
|
98
107
|
```
|
|
@@ -210,7 +219,7 @@ Returns:
|
|
|
210
219
|
nil
|
|
211
220
|
```
|
|
212
221
|
---
|
|
213
|
-
Example of return if
|
|
222
|
+
Example of return if any information not present (would return nil for any of the methods attempting to retrieve information). It would most likely mean that it's outside the year range.
|
|
214
223
|
```
|
|
215
224
|
client.date = "2400-01-01"
|
|
216
225
|
client.miss_distance("miles")
|
|
@@ -219,6 +228,15 @@ Returns:
|
|
|
219
228
|
```
|
|
220
229
|
nil
|
|
221
230
|
```
|
|
231
|
+
---
|
|
232
|
+
Example of return if method requesting the number of API calls left using the current key is made before any API calls are made.
|
|
233
|
+
```
|
|
234
|
+
client.calls_remaining
|
|
235
|
+
```
|
|
236
|
+
Returns:
|
|
237
|
+
```
|
|
238
|
+
{:error>=>"make new API call first"}
|
|
239
|
+
```
|
|
222
240
|
|
|
223
241
|
|
|
224
242
|
### Testing
|
data/lib/nasa-neo/client.rb
CHANGED
|
@@ -17,10 +17,12 @@ module NasaNeo
|
|
|
17
17
|
MISS_DISTANCE_KEYS = ["close_approach_data", 0, "miss_distance"]
|
|
18
18
|
VELOCITY_KEYS = ["close_approach_data", 0, "relative_velocity"]
|
|
19
19
|
|
|
20
|
-
attr_accessor :date
|
|
20
|
+
attr_accessor :date
|
|
21
|
+
attr_reader :key
|
|
21
22
|
|
|
22
23
|
def initialize(config)
|
|
23
24
|
@config = config
|
|
25
|
+
@calls_remaining = nil
|
|
24
26
|
@key = config.api_key
|
|
25
27
|
@date = parsed_date
|
|
26
28
|
@full_url = nil
|
|
@@ -28,6 +30,16 @@ module NasaNeo
|
|
|
28
30
|
@neo_position = 0
|
|
29
31
|
end
|
|
30
32
|
|
|
33
|
+
def key=(value)
|
|
34
|
+
@calls_remaining = nil
|
|
35
|
+
@key = value
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
def calls_remaining
|
|
39
|
+
@calls_remaining == nil ? error_feedback("make new API call first")
|
|
40
|
+
: @calls_remaining
|
|
41
|
+
end
|
|
42
|
+
|
|
31
43
|
def estimated_diameter(measurement = nil, min_max = nil)
|
|
32
44
|
retrieve_specific(ESTIMATED_DIAMETER_OPTIONS, ESTIMATED_DIAMETER_KEYS, measurement, min_max)
|
|
33
45
|
end
|
|
@@ -48,6 +60,10 @@ module NasaNeo
|
|
|
48
60
|
call_and_rescue { retrieve_neo }
|
|
49
61
|
end
|
|
50
62
|
|
|
63
|
+
def neo_data_verbose
|
|
64
|
+
|
|
65
|
+
end
|
|
66
|
+
|
|
51
67
|
def neo_total
|
|
52
68
|
if @full_url != set_full_url
|
|
53
69
|
call_and_rescue { get_api_data["element_count"]}
|
|
@@ -71,7 +87,9 @@ module NasaNeo
|
|
|
71
87
|
private
|
|
72
88
|
|
|
73
89
|
def buffer_url
|
|
74
|
-
open(@full_url)
|
|
90
|
+
api_data = open(@full_url)
|
|
91
|
+
@calls_remaining = api_data.meta['x-ratelimit-remaining'].to_i
|
|
92
|
+
api_data.read
|
|
75
93
|
end
|
|
76
94
|
|
|
77
95
|
def call_and_rescue
|
|
@@ -121,7 +139,7 @@ module NasaNeo
|
|
|
121
139
|
end
|
|
122
140
|
|
|
123
141
|
def set_full_url
|
|
124
|
-
"#{@config.host}?start_date=#{@date}&end_date=#{@date}&detailed=false&api_key=#{@key}"
|
|
142
|
+
"#{@config.host}/feed?start_date=#{@date}&end_date=#{@date}&detailed=false&api_key=#{@key}"
|
|
125
143
|
end
|
|
126
144
|
|
|
127
145
|
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.4.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 objects on any given day using the NASA NEO API. "
|