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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 05daf1bedded0b0e75c38f2904a5a0e2cf991d1e4dc0f1a0ed0c0da246564508
4
- data.tar.gz: d1e4a20ff50b5642cb2bf62e0d0cb6ec2ec3915c84e582763d0378f3affecfd8
3
+ metadata.gz: 4e8cccaef829829caefbcee2843bb441f08427449c8076fd8afa1cdbce0ab3c0
4
+ data.tar.gz: 54609efcbeea0aecc441b4296c9407f055c28519aef8694929670a71519b95b5
5
5
  SHA512:
6
- metadata.gz: 2381142f3cf7f95b81b56d968b4c85d61b3089d33fae7ea2d507beac8ec82d2cfda384c9d4ee4836f5af1c6728c64cf306b508a9227525339eb77c23fefdc7d7
7
- data.tar.gz: 2e571042bb5248f03cfcc9fa587e819efa6304666359e23d4595a98497ba095084da700fecf9e6f0d7070f3c69c7991ccf0a1c069ef13599b0036660fa071ed7
6
+ metadata.gz: 5befcec2be629c56d42b01f51915ca2ff3fcb4c246ccea85cec8f7479413a43c9b89bff52f66bd63652304b82626d1f5d6a0b12e375b48e2a5c2e2c892cfbdbb
7
+ data.tar.gz: 8205c94b409fda38978412190fc30f0d2a233ecea2a9b72189a8f88c32a7d04433229f1aa4050bd062d99b589539008f0bd0632d3cb23e86e40c2bde48c68751
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- nasa-neo (1.2.0)
4
+ nasa-neo (1.3.0)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
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 Object of the day.
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
- Create client to make requests to the API (using demo api key):
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
- Set the API key (only needs to be done is you want to use your own API key, default setting is DEMO_KEY)
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 (only needs to be done if you want to select another data, default setting is the current day. Format: YYYY-MM-DD)
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
- Please Note: The first request for information results in an API call, unless the date or API key is changed no more API calls are made as the information of the closet near earth object is stored on the first request.
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
@@ -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 { retrieve_neo["is_potentially_hazardous_asteroid"]}
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 { retrieve_neo["name"] }
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["near_earth_objects"]["#{@date}"][0]
106
+ @result.dig("near_earth_objects", "#{@date}", @neo_position)
93
107
  end
94
108
 
95
109
  def estimated_diameter_data
96
- retrieve_neo["estimated_diameter"]
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["close_approach_data"][0]["miss_distance"]
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["close_approach_data"][0]["relative_velocity"]
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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module NasaNeo
4
- VERSION = "1.2.0".freeze
4
+ VERSION = "1.3.0".freeze
5
5
  end
@@ -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.2.0'
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.2.0
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
- rubygems_version: 3.0.3
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