nasa_apod 0.0.4 → 0.0.6

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 80116fac324bec440f2d77aaf2798d18a795cc0b
4
- data.tar.gz: 7382f49e368db218cc3eaac3b93223fb84ee1d85
3
+ metadata.gz: 5ea7b208e0dd92004f98e370d5399bf23d2e57a5
4
+ data.tar.gz: 690ece5803322f2ef7926e52343c0a0baf33c47d
5
5
  SHA512:
6
- metadata.gz: 2d68bcc2520d84a5af85a85b9ade6e2f0112a2495f71ade138569f1896e6fb396ff4d3f7a0ba2fcf06c3360b32a5d5b04efc6b894dfa2a223b65eafdf5a178b1
7
- data.tar.gz: 77a72031791b5f5e491bec74b29c16ec9fd9433b217fa86e4c77686e114033d29f1e614a58e3f4d1998d1b33d7bf64017a047f2c9499608dd1dbbf917c4bfd57
6
+ metadata.gz: 7cd9d7f855881d2892b102211d4b5d55cf571f1c0d9a27ba0b51749988eabb89f7df1518ffeb98ffa6d055c1756b94953829be238f82780394c1e3584682212b
7
+ data.tar.gz: f0d41d988873268f7db03ad52864a0573259cbd1cf32568b2b3c0416ffe948dc3cba4097ae08384a4bbe4403d7f52e32fc4031069c8b0bfca1999db5467a4ed6
data/README.md CHANGED
@@ -27,7 +27,7 @@ result
27
27
 
28
28
  Get concept tags with result
29
29
  ```
30
- result = client.search(list_concepts: true)
30
+ result = client.search(concept_tags: true)
31
31
  result.concepts #=> ["Sun","Sunspot","Light",...],
32
32
  ```
33
33
  Note: Not all posts have concept tags.
@@ -3,17 +3,17 @@ 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, :hd
6
+ attr_reader :api_key, :date, :concept_tags, :hd
7
7
 
8
8
  def date=(date)
9
9
  @date = parse_date(date)
10
10
  end
11
11
 
12
- def list_concepts=(list_concepts)
13
- if list_concepts.nil? || list_concepts.blank?
14
- @list_concepts = false
12
+ def concept_tags=(concept_tags)
13
+ if concept_tags.nil? || concept_tags.blank?
14
+ @concept_tags = false
15
15
  else
16
- @list_concepts = list_concepts
16
+ @concept_tags = concept_tags
17
17
  end
18
18
  end
19
19
 
@@ -28,7 +28,7 @@ module NasaApod
28
28
  def initialize(options={})
29
29
  @api_key = options[:api_key] || "DEMO_KEY"
30
30
  self.date = options[:date]
31
- self.list_concepts = options[:list_concepts]
31
+ self.concept_tags = options[:concept_tags]
32
32
  self.hd = options[:hd]
33
33
  end
34
34
 
@@ -44,19 +44,25 @@ module NasaApod
44
44
  # @return [NasaApod::SearchResults] Return APOD post for a specified date.
45
45
  def search(options={})
46
46
  self.date = options[:date] || date
47
- @list_concepts = options[:list_concepts] || list_concepts
47
+ @concept_tags = options[:concept_tags] || concept_tags
48
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}")
49
+ response = HTTParty.get(DEFAULT_URL, { query: attributes })
50
50
  handle_response(response)
51
51
  end
52
52
 
53
53
  def random_post(options={})
54
54
  date = rand(Date.parse("1995-06-16")..Date.today)
55
- search(:date => date)
55
+ search(date: date)
56
56
  end
57
57
 
58
58
  alias_method :wormhole, :random_post
59
59
 
60
+ def attributes
61
+ instance_variables.each_with_object(Hash.new) do |var,hash|
62
+ hash[var.to_s.delete("@")] = instance_variable_get(var)
63
+ end
64
+ end
65
+
60
66
  private
61
67
 
62
68
  def handle_response(response)
@@ -67,14 +73,6 @@ module NasaApod
67
73
  end
68
74
  end
69
75
 
70
- def write_attrs(attributes)
71
- @concepts = attributes["concepts"]
72
- @url = attributes["url"]
73
- @media_type = attributes["media_type"]
74
- @explanation = attributes["explanation"]
75
- @title = attributes["title"]
76
- end
77
-
78
76
  def parse_date(date)
79
77
  if date.is_a?(Time)
80
78
  date.strftime("%Y-%m-%d")
@@ -1,3 +1,3 @@
1
1
  module NasaApod
2
- VERSION = "0.0.4"
2
+ VERSION = "0.0.6"
3
3
  end
data/nasa_apod.gemspec CHANGED
@@ -10,7 +10,7 @@ Gem::Specification.new do |spec|
10
10
  spec.email = ["gabe.p.dominguez@gmail.com"]
11
11
  spec.summary = %q{Ruby wrapper for NASA's Astronomy Picture of the Day API}
12
12
  spec.description = %q{A Ruby gem for consuming the NASA Astronomy Picture of the Day API. }
13
- spec.homepage = ""
13
+ spec.homepage = "https://github.com/gdomingu/nasa_apod"
14
14
  spec.license = "MIT"
15
15
 
16
16
  spec.files = `git ls-files -z`.split("\x0")
@@ -19,8 +19,7 @@ Gem::Specification.new do |spec|
19
19
  spec.require_paths = ["lib"]
20
20
 
21
21
  spec.add_development_dependency "bundler", "~> 1.6"
22
- spec.add_development_dependency "rake"
23
- spec.add_development_dependency 'rspec'
24
- spec.add_development_dependency 'httparty'
25
-
22
+ spec.add_development_dependency "rake", "~> 10.1"
23
+ spec.add_development_dependency 'rspec', "~> 3.3"
24
+ spec.add_development_dependency 'httparty', "~> 0.13"
26
25
  end
@@ -10,8 +10,8 @@ module NasaApod
10
10
  expect(client.api_key).to eq("DEMO_KEY")
11
11
  end
12
12
 
13
- it 'list_concepts defaults to false' do
14
- expect(client.list_concepts).to eq(false)
13
+ it 'concept_tags defaults to false' do
14
+ expect(client.concept_tags).to eq(false)
15
15
  end
16
16
 
17
17
  it 'date defaults to a string of today' do
@@ -51,6 +51,16 @@ module NasaApod
51
51
  end
52
52
  end
53
53
 
54
+ describe '#attributes' do
55
+ let(:client) { Client.new }
56
+
57
+ it 'returns a hash of attributes' do
58
+ attributes = client.attributes
59
+ expect(attributes.class).to eq(Hash)
60
+ expect(attributes['api_key']).to eq('DEMO_KEY')
61
+ end
62
+ end
63
+
54
64
  end
55
65
 
56
66
  describe SearchResults do
data/spec/spec_helper.rb CHANGED
@@ -1 +1 @@
1
- require 'nasa_apod'
1
+ require 'nasa_apod'
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
4
+ version: 0.0.6
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-07-01 00:00:00.000000000 Z
11
+ date: 2016-04-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -28,44 +28,44 @@ dependencies:
28
28
  name: rake
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ">="
31
+ - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '0'
33
+ version: '10.1'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - ">="
38
+ - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: '0'
40
+ version: '10.1'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rspec
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - ">="
45
+ - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: '0'
47
+ version: '3.3'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - ">="
52
+ - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: '0'
54
+ version: '3.3'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: httparty
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - ">="
59
+ - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: '0'
61
+ version: '0.13'
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - ">="
66
+ - - "~>"
67
67
  - !ruby/object:Gem::Version
68
- version: '0'
68
+ version: '0.13'
69
69
  description: 'A Ruby gem for consuming the NASA Astronomy Picture of the Day API. '
70
70
  email:
71
71
  - gabe.p.dominguez@gmail.com
@@ -86,7 +86,7 @@ files:
86
86
  - nasa_apod.gemspec
87
87
  - spec/nasa_apod_spec.rb
88
88
  - spec/spec_helper.rb
89
- homepage: ''
89
+ homepage: https://github.com/gdomingu/nasa_apod
90
90
  licenses:
91
91
  - MIT
92
92
  metadata: {}
@@ -106,7 +106,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
106
106
  version: '0'
107
107
  requirements: []
108
108
  rubyforge_project:
109
- rubygems_version: 2.2.2
109
+ rubygems_version: 2.6.2
110
110
  signing_key:
111
111
  specification_version: 4
112
112
  summary: Ruby wrapper for NASA's Astronomy Picture of the Day API