nasa_apod 1.2.0 → 1.2.1

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
  SHA1:
3
- metadata.gz: 61d6d9f7704b23273d740a7209453dd814a39fb1
4
- data.tar.gz: 5ec5a5f6460072032eb478590625e3cc07ac1741
3
+ metadata.gz: 4a5c206c98802c6546d13356b644f9802efb0795
4
+ data.tar.gz: e22c31e2744cd6b994ee40cac8c8830ce0ffb818
5
5
  SHA512:
6
- metadata.gz: d7316997ecbc3a6f01ea70a0189de1983c19cae7155a484788d7c9357a96e57080b4b85016a595078df363364dc130e835a9efe135354c25e5630d345f30ba75
7
- data.tar.gz: b6d01c6d16305eeb275b5241fde5a0a8f1b2b39c40732b2635f74f7fa228227345c03278e09cc5125d004963649e78f3aa8b521ae9da9c5853db9585c2d04bdc
6
+ metadata.gz: 0c310ebf2e1cdd57a47d0ff7544f977f68b1bedef5429d9602ba4f5e842e362fa085820318d4b387c6d863362e7e3cc8666ccb6c24bb1c5132e493ce50574485
7
+ data.tar.gz: a8ad78d0ffce3e94f96e3cc9ee0161cf600d8f1690fda3199bafaf5a1d9bef0f804e0e7610fa05eb4937db6c33a433b95c7b6a0817c46ae1546d9dd762fe3f66
data/README.md CHANGED
@@ -48,11 +48,11 @@ result.url #=> "http://apod.nasa.gov/apod/image/1506/CeresMountain_Dawn_1041.jpg
48
48
 
49
49
  Note: Sometimes result.url will return a video url. You should build logic to handle both media_type: 'image' and media_type: 'video'.
50
50
 
51
- If the media_type: 'video', you can use video_thumbnail_url to get a jpg thumbnail of the video.
51
+ If the media_type: 'video', you can use thumbnail_url to get a jpg thumbnail of the video.
52
52
 
53
53
  ```
54
54
  result = client.search
55
- result.video_thumbnail_url #=> 'http://img.youtube.com/vi/3LdZ_NftIh8/sddefault.jpg'
55
+ result.thumbnail_url #=> 'http://img.youtube.com/vi/3LdZ_NftIh8/sddefault.jpg'
56
56
  ```
57
57
 
58
58
  Get HD image URL:
@@ -2,7 +2,7 @@ module NasaApod
2
2
 
3
3
  class SearchResults
4
4
  attr_accessor :url, :media_type, :title, :explanation, :hd_url, :date, :copyright
5
- attr_reader :video_thumbnail_url
5
+ attr_reader :thumbnail_url
6
6
 
7
7
  def initialize(attributes={})
8
8
  @url = attributes["url"]
@@ -14,9 +14,11 @@ module NasaApod
14
14
  @copyright = attributes["copyright"]
15
15
  end
16
16
 
17
- def video_thumbnail_url
17
+ def thumbnail_url
18
18
  if @media_type == 'video'
19
19
  "http://img.youtube.com/vi/#{youtube_id}/sddefault.jpg"
20
+ else
21
+ url
20
22
  end
21
23
  end
22
24
 
@@ -1,3 +1,3 @@
1
1
  module NasaApod
2
- VERSION = "1.2.0"
2
+ VERSION = "1.2.1"
3
3
  end
@@ -76,8 +76,8 @@ module NasaApod
76
76
  end
77
77
  end
78
78
 
79
- context 'when media_type is video' do
80
- describe "#video_thumbnail_url" do
79
+ describe "#thumbnail_url" do
80
+ context 'when media_type is video' do
81
81
  let(:result) { SearchResults.new(attributes) }
82
82
  let(:attributes) {{"url" => "https://www.youtube.com/embed/3LdZ_NftIh8?rel=0",
83
83
  "media_type" => "video",
@@ -87,7 +87,20 @@ module NasaApod
87
87
  }}
88
88
 
89
89
  it 'returns a image url' do
90
- expect(result.video_thumbnail_url).to eq('http://img.youtube.com/vi/3LdZ_NftIh8/sddefault.jpg')
90
+ expect(result.thumbnail_url).to eq('http://img.youtube.com/vi/3LdZ_NftIh8/sddefault.jpg')
91
+ end
92
+ end
93
+ context 'when media_type is image' do
94
+ let(:result) { SearchResults.new(attributes) }
95
+ let(:attributes) {{"url" => "http://img.youtube.com/vi/3LdZ_NftIh8/sddefault.jpg",
96
+ "media_type" => "image",
97
+ "title" => "Test title",
98
+ "explanation" => "Test explanation",
99
+ "date" => "1995-06-16"
100
+ }}
101
+
102
+ it 'returns a image url' do
103
+ expect(result.thumbnail_url).to eq('http://img.youtube.com/vi/3LdZ_NftIh8/sddefault.jpg')
91
104
  end
92
105
  end
93
106
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nasa_apod
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.0
4
+ version: 1.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gabe Dominguez