explore_mars 0.4.4 → 0.5.0

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: 4a796f889c91a18a40ee81414146362fdf7277a7
4
- data.tar.gz: 9ace25496a95003b03db4aae4cd21aa2b01ae158
3
+ metadata.gz: 22c75a285412e6dcd7a67e134b96783a9a8b5a59
4
+ data.tar.gz: 7204f8cfeb12f2ef82f66f47129508ec7422e2c2
5
5
  SHA512:
6
- metadata.gz: eca76e01d4e0d0542fca11248840c6c364cc9e52179e08542b0ad38c7e08fad1437788c8ec3bf7bc4a2768632f2288a9e8adbf4a000f9df12a58698ed0415a7f
7
- data.tar.gz: e1a067c1386529c6b7a1c9f0af56643528f95cb3380334b098b481e05fc9074699d1130d8ffe9b414b872f7d8882cd999d63004835892f32934b10f03cc0fc0c
6
+ metadata.gz: 68e9e99fd2d56407a6f2c87752bb0d7405819fea32b13ced6cae83743802daa02d5c82f985e01e834f1d465bcddfa899e609e6208bb231236f1092e9ea7cc30b
7
+ data.tar.gz: f7c5df361ff475f3a71283f9147d265a2ac61d4b6b3ecdd1b8578eccbeb8a02b030b950d9cd9098887d62a21cb8cb8da103873b47e958c4957ef4b4b0a24d28f
data/README.md CHANGED
@@ -38,7 +38,13 @@ There are only a few parts to this gem so far, so it's relatively simple
38
38
  to use. By calling:
39
39
 
40
40
  ```ruby
41
- ExploreMars.get_by_sol(rover, sol, camera)
41
+ ExploreMars.get_by_sol(rover: <ROVER>, sol: <SOL>, camera: <CAMERA>)
42
+ ```
43
+
44
+ For example:
45
+
46
+ ```ruby
47
+ ExploreMars.get_by_sol(rover: "curiosity", sol: 1000, camera: "FHAZ")
42
48
  ```
43
49
 
44
50
  you can make a call to the API, which will return a set of ```Photos```.
@@ -62,7 +68,7 @@ sensitive. The cameras are as follows:
62
68
  MARDI | Mars Descent Imager
63
69
  NAVCAM | Navigation Camera
64
70
 
65
- ### Opportunity's Cameras
71
+ ### Opportunity's and Spirit's Cameras
66
72
 
67
73
  Abbreviation | Camera
68
74
  ------------ | -----------------------------
@@ -75,31 +81,36 @@ sensitive. The cameras are as follows:
75
81
  You can also make the API call without providing the camera argument to receive all photos that were taken on a particular sol from all cameras:
76
82
 
77
83
  ```ruby
78
- ExploreMars.get(rover, sol)
84
+ ExploreMars.get_by_sol(rover: <ROVER>, sol: <SOL>)
79
85
  ```
80
86
 
81
87
  If you would prefer to query by a particular Earth date instead, you can use:
82
88
 
83
89
  ```ruby
84
- ExploreMars.get_by_date(rover, date, camera)
90
+ ExploreMars.get_by_date(rover: <ROVER>, date: <DATE>, camera: <CAMERA>)
85
91
  ```
86
92
 
87
93
  or
88
94
 
89
95
  ```ruby
90
- ExploreMars.get_by_date(rover, date)
96
+ ExploreMars.get_by_date(rover: <ROVER>, date: <DATE>)
91
97
  ```
92
98
 
93
99
  The date param should be entered as a String, formatted as "yyyy-mm-dd".
94
100
 
101
+ For example:
102
+
103
+ ```ruby
104
+ ExploreMars.get_by_date(rover: "curiosity", date: "2015-12-4")
105
+ ```
95
106
 
96
- The ```Photo``` objects that get returned have five main attributes:
97
- ```rover```, ```sol```, ```camera```, ```earth_date```, and ```src```.
98
- The ```src``` attribute contains the source url of the actual image.
107
+ The `Photo` objects that get returned have five main attributes:
108
+ `rover`, `sol`, `camera`, `earth_date`, and `src`.
109
+ The `src` attribute contains the source url of the actual image.
99
110
  In order to display an image in a Rails view for example, I could use:
100
111
 
101
112
  ```ruby
102
- photos = ExploreMars::Call.get("curiosity", 869, "FHAZ")
113
+ photos = ExploreMars.get_by_sol("curiosity", 869, "FHAZ")
103
114
 
104
115
  photos.each do |photo|
105
116
  image_tag(photo.src)
@@ -23,6 +23,7 @@ Gem::Specification.new do |spec|
23
23
 
24
24
  spec.add_development_dependency "rake", "~> 10.0"
25
25
  spec.add_development_dependency "rspec"
26
+ spec.add_development_dependency "pry"
26
27
  spec.add_development_dependency "shoulda-matchers"
27
28
  spec.add_development_dependency "valid_attribute"
28
29
  end
@@ -13,8 +13,8 @@ require "explore_mars/date_query"
13
13
 
14
14
  module ExploreMars
15
15
  def self.help
16
- puts "- use ExploreMars#get_by_sol(rover, sol, camera) to receive a collection of photos by sol"
17
- puts "- use ExploreMars#get_by_date(rover, date, camera) to receive a collection of photos by Earth date"
16
+ puts "- use ExploreMars#get_by_sol(rover: <ROVER>, sol: <SOL>, camera: <CAMERA>) to receive a collection of photos by sol"
17
+ puts "- use ExploreMars#get_by_date(rover: <ROVER>, date: <DATE>, camera: <CAMERA>) to receive a collection of photos by Earth date"
18
18
  puts "-- rover argument should be the name of one of NASA's Mars rovers"
19
19
  puts "-- sol argument should be a number representing the Martian day on which the photo was taken"
20
20
  puts "-- date argument should be a string formmated as yyyy-mm-dd"
@@ -29,11 +29,13 @@ module ExploreMars
29
29
  puts "- ExploreMars::Photo#src will return the source url for the photo"
30
30
  end
31
31
 
32
- def self.get_by_sol(rover, sol, camera=nil)
33
- SolQuery.new(rover, sol, camera).get
32
+ def self.get_by_sol(params)
33
+ fail "Rover and Sol are required" if (params[:rover].blank? || params[:sol].blank?)
34
+ SolQuery.new(params[:rover], params[:sol], params[:camera]).get
34
35
  end
35
36
 
36
- def self.get_by_date(rover, date, camera=nil)
37
- DateQuery.new(rover, date, camera).get
37
+ def self.get_by_date(params)
38
+ fail "Rover and Date are required" if (params[:rover].blank? || params[:date].blank?)
39
+ DateQuery.new(params[:rover], params[:date], params[:camera]).get
38
40
  end
39
41
  end
@@ -19,7 +19,7 @@ module ExploreMars
19
19
 
20
20
  def check_cameras(camera)
21
21
  if !camera.empty? && !CAMERAS.include?(camera.upcase)
22
- raise "Camera argument must be one of #{CAMERAS.join(', ')}"
22
+ fail "Camera argument must be one of #{CAMERAS.join(', ')}"
23
23
  end
24
24
  end
25
25
  end
@@ -1,3 +1,3 @@
1
1
  module ExploreMars
2
- VERSION = "0.4.4"
2
+ VERSION = "0.5.0"
3
3
  end
@@ -2,7 +2,7 @@ require "spec_helper"
2
2
 
3
3
  describe ExploreMars::Call do
4
4
  it "should have proper constants" do
5
- expect(ExploreMars::Call::BASE_URI).to eq "https://mars-curiosity-api.herokuapp.com/api/v1/rovers/"
5
+ expect(ExploreMars::Call::BASE_URI).to eq "https://mars-photos.herokuapp.com/api/v1/rovers/"
6
6
  expect(ExploreMars::Call::CAMERAS).to eq ["FHAZ", "RHAZ", "MAST", "CHEMCAM", "NAVCAM", "MAHLI", "MARDI", "PANCAM", "MINITES"]
7
7
  end
8
8
  end
@@ -1,6 +1,7 @@
1
1
  require "spec_helper"
2
2
 
3
3
  describe ExploreMars::SolQuery do
4
+
4
5
  describe "attributes" do
5
6
  it "should have a sol and a camera" do
6
7
  query = ExploreMars::SolQuery.new("curiosity", 940, "FHAZ")
@@ -12,14 +13,17 @@ describe ExploreMars::SolQuery do
12
13
  end
13
14
 
14
15
  describe "cameras" do
15
- it "should be valid" do
16
+ it "handles a correct Camera" do
16
17
  expect{
17
18
  ExploreMars::SolQuery.new("curiosity", 940, "FHAZ").get
18
19
  }.not_to raise_error
20
+ end
19
21
 
22
+ it "raises an error when Camera is invalid" do
23
+ stub_const("CAMERAS", ["FHAZ", "RHAZ", "MAST", "CHEMCAM", "NAVCAM", "MAHLI", "MARDI", "PANCAM", "MINITES"])
20
24
  expect{
21
25
  ExploreMars::SolQuery.new("curiosity", 940, "Not a camera").get
22
- }.to raise_error
26
+ }.to raise_error("Camera argument must be one of #{CAMERAS.join(', ')}")
23
27
  end
24
28
  end
25
29
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: explore_mars
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.4
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris C Cerami
@@ -38,6 +38,20 @@ dependencies:
38
38
  - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: pry
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
41
55
  - !ruby/object:Gem::Dependency
42
56
  name: shoulda-matchers
43
57
  requirement: !ruby/object:Gem::Requirement
@@ -115,7 +129,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
115
129
  version: '0'
116
130
  requirements: []
117
131
  rubyforge_project:
118
- rubygems_version: 2.4.5
132
+ rubygems_version: 2.2.2
119
133
  signing_key:
120
134
  specification_version: 4
121
135
  summary: Browse photos from the Mars rover Curiosity