nasa_apod 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +15 -1
- data/lib/nasa_apod/client.rb +12 -2
- data/lib/nasa_apod/search_results.rb +2 -1
- data/lib/nasa_apod/version.rb +1 -1
- data/spec/nasa_apod_spec.rb +5 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 80116fac324bec440f2d77aaf2798d18a795cc0b
|
4
|
+
data.tar.gz: 7382f49e368db218cc3eaac3b93223fb84ee1d85
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2d68bcc2520d84a5af85a85b9ade6e2f0112a2495f71ade138569f1896e6fb396ff4d3f7a0ba2fcf06c3360b32a5d5b04efc6b894dfa2a223b65eafdf5a178b1
|
7
|
+
data.tar.gz: 77a72031791b5f5e491bec74b29c16ec9fd9433b217fa86e4c77686e114033d29f1e614a58e3f4d1998d1b33d7bf64017a047f2c9499608dd1dbbf917c4bfd57
|
data/README.md
CHANGED
@@ -25,9 +25,23 @@ result = client.search(date: "2015-06-18") #You can also pass in a Ruby Date obj
|
|
25
25
|
result
|
26
26
|
```
|
27
27
|
|
28
|
+
Get concept tags with result
|
29
|
+
```
|
30
|
+
result = client.search(list_concepts: true)
|
31
|
+
result.concepts #=> ["Sun","Sunspot","Light",...],
|
32
|
+
```
|
33
|
+
Note: Not all posts have concept tags.
|
34
|
+
|
35
|
+
Get HD image URL:
|
36
|
+
|
37
|
+
```
|
38
|
+
result = client.search(hd: true)
|
39
|
+
result.hd_url #=> "http://apod.nasa.gov/apod/image/1506/CeresMountain_Dawn_1041.jpg"
|
40
|
+
```
|
41
|
+
|
28
42
|
Random post:
|
29
43
|
```
|
30
|
-
result = client.wormhole
|
44
|
+
result = client.wormhole
|
31
45
|
result
|
32
46
|
```
|
33
47
|
|
data/lib/nasa_apod/client.rb
CHANGED
@@ -3,7 +3,7 @@ module NasaApod
|
|
3
3
|
DEFAULT_URL = 'https://api.nasa.gov/planetary/apod'
|
4
4
|
|
5
5
|
class Client
|
6
|
-
attr_reader :api_key, :date, :list_concepts
|
6
|
+
attr_reader :api_key, :date, :list_concepts, :hd
|
7
7
|
|
8
8
|
def date=(date)
|
9
9
|
@date = parse_date(date)
|
@@ -16,11 +16,20 @@ module NasaApod
|
|
16
16
|
@list_concepts = list_concepts
|
17
17
|
end
|
18
18
|
end
|
19
|
+
|
20
|
+
def hd=(hd)
|
21
|
+
if hd.nil? || hd.blank?
|
22
|
+
@hd = false
|
23
|
+
else
|
24
|
+
@hd = hd
|
25
|
+
end
|
26
|
+
end
|
19
27
|
|
20
28
|
def initialize(options={})
|
21
29
|
@api_key = options[:api_key] || "DEMO_KEY"
|
22
30
|
self.date = options[:date]
|
23
31
|
self.list_concepts = options[:list_concepts]
|
32
|
+
self.hd = options[:hd]
|
24
33
|
end
|
25
34
|
|
26
35
|
# Returns APOD info for specified day.
|
@@ -36,7 +45,8 @@ module NasaApod
|
|
36
45
|
def search(options={})
|
37
46
|
self.date = options[:date] || date
|
38
47
|
@list_concepts = options[:list_concepts] || list_concepts
|
39
|
-
|
48
|
+
@hd = options[:hd] || hd
|
49
|
+
response = HTTParty.get("https://api.nasa.gov/planetary/apod?api_key=#{api_key}&date=#{date}&concept_tags=#{list_concepts}&hd=#{hd}")
|
40
50
|
handle_response(response)
|
41
51
|
end
|
42
52
|
|
@@ -1,7 +1,7 @@
|
|
1
1
|
module NasaApod
|
2
2
|
|
3
3
|
class SearchResults
|
4
|
-
attr_accessor :concepts, :url, :media_type, :title, :explanation
|
4
|
+
attr_accessor :concepts, :url, :media_type, :title, :explanation, :hd_url
|
5
5
|
|
6
6
|
def initialize(attributes={})
|
7
7
|
@concepts = attributes["concepts"]
|
@@ -9,6 +9,7 @@ module NasaApod
|
|
9
9
|
@media_type = attributes["media_type"]
|
10
10
|
@explanation = attributes["explanation"]
|
11
11
|
@title = attributes["title"]
|
12
|
+
@hd_url = attributes["hdurl"]
|
12
13
|
end
|
13
14
|
end
|
14
15
|
|
data/lib/nasa_apod/version.rb
CHANGED
data/spec/nasa_apod_spec.rb
CHANGED
@@ -34,6 +34,11 @@ module NasaApod
|
|
34
34
|
todays_title = results.title
|
35
35
|
expect(yesterdays_title).to_not eq(todays_title)
|
36
36
|
end
|
37
|
+
|
38
|
+
it 'returns a HD image with params' do
|
39
|
+
results = client.search(:hd => true)
|
40
|
+
expect(results.hd_url).to_not be(nil)
|
41
|
+
end
|
37
42
|
end
|
38
43
|
|
39
44
|
describe '#random_post' do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: nasa_apod
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Gabe Dominguez
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-07-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|