nasa-neo 1.0.3 → 1.1.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: fa586fc1ff0f8f45e890578299e9e33ec94d686cd5dcd12c1f5f1bc05403d721
4
- data.tar.gz: b73a1db7e23658cdc16fe75116572127cf6255e034df99cb0c2afc1a34e43fa8
3
+ metadata.gz: 1b00b7d123383775849d5299daaa45135b5bc4d10549395d766571084f1ee4fd
4
+ data.tar.gz: 3884a5fc6becc14b07b4ef1236db36f46f6233e3fca8c44ad328198fc6bf71f5
5
5
  SHA512:
6
- metadata.gz: 0bff05d6559b1900a417c69a77e278c15730e3ff4bd9976cadb2c3e6fe1e866d2451a580a5497388e3cc5f3ddb973ab584c304be6fc0f4b83d845fea0b475f95
7
- data.tar.gz: 836aa5a4423b640facaad31564a35e16dd790dbbdbfad88230ba13b0f5ec42f19a63ddcc929c1b362b1b602ab42288805dd611c152576384dc03acad9c556736
6
+ metadata.gz: 07d8facfdd037b5db0946e12f24963b864dbc2b133543311785beed414558ae133f2805cf1404042acfded74740c4d6db3f2703c81ceea85c9253389d2c0dc39
7
+ data.tar.gz: 1592efceec7dab63da270ae678e601ff911fc6afada30b87e613753d3ee660fc29d4c14eacea51fbb295c3b5a09650dcfe12b4ec3ed0fac18e7c728bba6d720d
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- nasa-neo (1.0.3)
4
+ nasa-neo (1.1.0)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
data/README.md CHANGED
@@ -4,7 +4,7 @@ Gives details on the closest Near Earth Object of the day.
4
4
 
5
5
  ## Installation
6
6
 
7
- Uses `Ruby 2.6.1`
7
+ Written using `Ruby 2.6.1`
8
8
 
9
9
  Add this line to your application's Gemfile:
10
10
 
@@ -20,7 +20,9 @@ Or install it yourself as:
20
20
 
21
21
  $ gem install nasa-neo
22
22
 
23
- ## Instructions
23
+ ## Usage
24
+
25
+ ### Configuration
24
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)
25
27
 
26
28
  Create client to make requests to the API (using demo api key):
@@ -29,68 +31,97 @@ Create client to make requests to the API (using demo api key):
29
31
  client = NasaNeo::CloseObj.configure
30
32
  ```
31
33
 
32
- Set the API key (default is DEMO_KEY)
34
+ Set the API key (only needs to be done is you want to use your own API key, default setting is DEMO_KEY)
33
35
  ```
34
36
  client.key = "MyKey"
35
37
  ```
36
38
 
37
- Change the date (default is the current day)
39
+ Change the date (only needs to be done if you want to select another data, default setting is the current day)
38
40
  ```
39
41
  client.date = "2019-04-10"
40
42
  ```
41
43
  Please Note: The first request for information results in an API call, unless the date is changed no more API calls are made as the information of the closet near earth object is stored on the first request.
42
44
 
43
- ##### Retrieving Information
45
+ ### Retrieving Information
44
46
 
45
- Retrieve the name:
47
+ ##### Given name
46
48
 
47
49
  ```
48
50
  client.neo_name
49
-
50
- eg. "(2004 VB)"
51
51
  ```
52
+ Returns:
53
+ ```
54
+ "(2004 VB)"
55
+ ```
56
+
52
57
 
58
+ ##### Potential hazardousness boolean
59
+ ```
60
+ client.hazardous?
61
+ ```
62
+ Returns (hopefully):
63
+ ```
64
+ false
65
+ ```
53
66
 
54
- Retrieve the estimated diameter:
67
+ ##### Estimated diameter
55
68
 
56
69
  ```
57
70
  client.estimated_diameter
58
-
59
- eg. {"kilometers"=>{"estimated_diameter_min"=>0.1838886721, "estimated_diameter_max"=>0.411187571}, "meters"=>{"estimated_diameter_min"=>183.8886720703, "estimated_diameter_max"=>411.1875710413}, "miles"=>{"estimated_diameter_min"=>0.1142630881, "estimated_diameter_max"=>0.2555000322}, "feet"=>{"estimated_diameter_min"=>603.309310875, "estimated_diameter_max"=>1349.040630575}}
71
+ ```
72
+ Returns:
73
+ ```
74
+ {"kilometers"=>{"estimated_diameter_min"=>0.1838886721, "estimated_diameter_max"=>0.411187571}, "meters"=>{"estimated_diameter_min"=>183.8886720703, "estimated_diameter_max"=>411.1875710413}, "miles"=>{"estimated_diameter_min"=>0.1142630881, "estimated_diameter_max"=>0.2555000322}, "feet"=>{"estimated_diameter_min"=>603.309310875, "estimated_diameter_max"=>1349.040630575}}
60
75
  ```
61
76
 
62
77
 
63
- Retrieve the miss distance to earth:
78
+ ##### Miss distance to earth
64
79
 
65
80
  ```
66
81
  client.miss_distance
67
-
68
- eg. {"astronomical"=>"0.1915058335", "lunar"=>"74.4957733154", "kilometers"=>"28648866", "miles"=>"17801580"}
82
+ ```
83
+ Returns:
84
+ ```
85
+ {"astronomical"=>"0.1915058335", "lunar"=>"74.4957733154", "kilometers"=>"28648866", "miles"=>"17801580"}
69
86
  ```
70
87
 
71
88
 
72
- Retrieve the velocity:
89
+ ##### Velocity
73
90
 
74
91
  ```
75
92
  client.velocity
93
+ ```
94
+ Returns:
95
+ ```
96
+ {"kilometers_per_second"=>"14.488889894", "kilometers_per_hour"=>"52160.0036184644", "miles_per_hour"=>"32410.1978039286"}
97
+ ```
76
98
 
77
- eg. {"kilometers_per_second"=>"14.488889894", "kilometers_per_hour"=>"52160.0036184644", "miles_per_hour"=>"32410.1978039286"}
99
+
100
+ ##### All data on closest object
101
+
102
+ ```
103
+ client.neo_data
104
+ ```
105
+
106
+ Returns:
107
+ ```
108
+ {"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}
78
109
  ```
79
110
 
80
- ##### Exceptions
111
+ ### Exceptions
81
112
 
82
113
  Exceptions are returned as a hash (example of wrong date):
83
114
  ```
84
115
  client.date = "123"
85
116
  ```
86
- returns:
117
+ Returns:
87
118
  ```
88
119
  {:error=>["400", ""]}
89
120
  ```
90
121
  If an error is returned the next method request for information will make an API call
91
122
 
92
123
 
93
- ## Testing
124
+ ### Testing
94
125
 
95
126
  Uses `RSpec 3.8`
96
127
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require_relative 'configuration'
2
4
  require_relative 'client'
3
5
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'open-uri'
2
4
  require 'json'
3
5
 
@@ -19,6 +21,10 @@ module NasaNeo
19
21
  call_and_rescue { retrieve_neo["estimated_diameter"] }
20
22
  end
21
23
 
24
+ def hazardous?
25
+ call_and_rescue { retrieve_neo["is_potentially_hazardous_asteroid"]}
26
+ end
27
+
22
28
  def miss_distance
23
29
  call_and_rescue { retrieve_neo["close_approach_data"][0]["miss_distance"] }
24
30
  end
@@ -27,6 +33,10 @@ module NasaNeo
27
33
  call_and_rescue { retrieve_neo["name"] }
28
34
  end
29
35
 
36
+ def neo_data
37
+ call_and_rescue { retrieve_neo }
38
+ end
39
+
30
40
  def velocity
31
41
  call_and_rescue { retrieve_neo["close_approach_data"][0]["relative_velocity"] }
32
42
  end
@@ -1,8 +1,10 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module NasaNeo
2
4
  module CloseObj
3
5
  class Configuration
4
- DEFAULT_HOST = 'https://api.nasa.gov/neo/rest/v1/feed'
5
- DEFAULT_API_KEY = 'DEMO_KEY'
6
+ DEFAULT_HOST = 'https://api.nasa.gov/neo/rest/v1/feed'.freeze
7
+ DEFAULT_API_KEY = 'DEMO_KEY'.freeze
6
8
 
7
9
  attr_accessor :api_key, :host
8
10
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module NasaNeo
2
- VERSION = "1.0.3"
4
+ VERSION = "1.1.0".freeze
3
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.0.3'
7
+ s.version = '1.1.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. "
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.0.3
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Sutherland