Skip to content

Commit

Permalink
Merge 543ea81 into e6f2b87
Browse files Browse the repository at this point in the history
  • Loading branch information
invacuo committed Oct 2, 2019
2 parents e6f2b87 + 543ea81 commit 781645a
Show file tree
Hide file tree
Showing 8 changed files with 247 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
### 1.0.2 (next)

* Your contribution here.
* [#71](https://github.com/rodolfobandeira/spacex/pull/71): Implement Landing Pads endpoint [@invacuo](http://github.com/invacuo).
* [#65](https://github.com/rodolfobandeira/spacex/pull/65): Add CodeClimate test coverage [@rodolfobandeira](http://github.com/rodolfobandeira).
* [#64](https://github.com/rodolfobandeira/spacex/pull/64): Fix failing build on Travis-CI [@rodolfobandeira](http://github.com/rodolfobandeira).

Expand Down
23 changes: 23 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,29 @@ first_event.links['article'] # http://www.spacex.com/news/2013/02/11/flight-4-la
first_event.links['wikipedia'] # https://en.wikipedia.org/wiki/Falcon_1
```

### LandingPads

- Get information for all LandingPads: `SPACEX::LandingPads.info`
- Get information about a specific LandingPad: `SPACEX::LandingPads.info('LZ-4')`

This code shows how to get the information for a specific LandingPad by id and lists the fields:

```ruby
landing_pad = SPACEX::LandingPads.info('LZ-4')
landing_pad.id # 'LZ-4'
landing_pad.full_name # 'Landing Zone 4'
landing_pad.status # 'active'
landing_pad.location['name'] # 'Vandenberg Air Force Base'
landing_pad.location['region'] # 'California'
landing_pad.location['latitude'] # 34.632989
landing_pad.location['longitude'] # -120.615167
landing_pad.landing_type # 'RTLS'
landing_pad.attempted_landings # 2
landing_pad.successful_landings # 2
landing_pad.wikipedia # "https://en.wikipedia.org/wiki/Vandenberg_AFB_Space_Launch_Complex_4#LZ-4_landing_history"
landing_pad.details # "SpaceX's west coast landing pad. The pad is adjacent to SLC-4E, SpaceX's west coast launch site. The pad was under construction for about a year starting in 2016. After concerns with seal mating season, this pad was first used for the SAOCOM 1A mission in October 2018. Officially referred to as LZ-4 in FCC filings."
```

### Launches

- Get information for all launches: `SPACEX::Launches.all` or `SPACEX::Launches.info`
Expand Down
1 change: 1 addition & 0 deletions lib/spacex.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
require_relative 'spacex/dragon_capsules'
require_relative 'spacex/endpoint'
require_relative 'spacex/history'
require_relative 'spacex/landing_pads'
require_relative 'spacex/launches'
require_relative 'spacex/missions'
require_relative 'spacex/payloads'
Expand Down
2 changes: 1 addition & 1 deletion lib/spacex/base_request.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def conn(path)
) do |c|
c.use ::FaradayMiddleware::ParseJson
c.use Faraday::Response::RaiseError
c.use Faraday::Adapter::NetHttp
c.adapter Faraday::Adapter::NetHttp
end
end
end
Expand Down
11 changes: 11 additions & 0 deletions lib/spacex/landing_pads.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
module SPACEX
module LandingPads
def self.info(id = nil)
SPACEX::BaseRequest.info("landpads/#{id}")
end

def self.all
info
end
end
end
68 changes: 68 additions & 0 deletions spec/fixtures/spacex/landing_pads/info.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

70 changes: 70 additions & 0 deletions spec/fixtures/spacex/landing_pads/info/LZ-4.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

72 changes: 72 additions & 0 deletions spec/spacex/landing_pads_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
require 'spec_helper'

describe SPACEX::LandingPads do
context '#info', vcr: { cassette_name: 'landing_pads/info' } do
subject do
SPACEX::LandingPads.info
end

it "returns all LandingPads' info when no id is passed" do
first_subject = subject.first

expect(subject.class).to eq Array
expect(first_subject.id).to eq 'LZ-1'
expect(first_subject.full_name).to eq 'Landing Zone 1'
expect(first_subject.status).to eq 'active'
expect(first_subject.location).to eq(
'name' => 'Cape Canaveral',
'region' => 'Florida',
'latitude' => 28.485833,
'longitude' => -80.544444
)
expect(first_subject.landing_type).to eq 'RTLS'
expect(first_subject.attempted_landings).to eq 14
expect(first_subject.successful_landings).to eq 13
expect(first_subject.wikipedia).to eq(
'https://en.wikipedia.org/wiki/Landing_Zones_1_and_2'
)
expect(first_subject.details).to eq(
"SpaceX's first east coast landing pad is Landing Zone 1, " \
'where the historic first Falcon 9 landing occurred in December 2015.' \
' LC-13 was originally used as a launch pad for early Atlas missiles ' \
'and rockets from Lockheed Martin. LC-1 was later expanded to ' \
'include Landing Zone 2 for side booster RTLS Falcon Heavy missions, ' \
'and it was first used in February 2018 for that purpose.'
)
end
end

context "#info('LZ-4')", vcr: { cassette_name: 'landing_pads/info/LZ-4' } do
subject do
SPACEX::LandingPads.info('LZ-4')
end

it 'returns LandingPad info for "LZ-4"' do
expect(subject.class).to eq SPACEX::Response
expect(subject.id).to eq 'LZ-4'
expect(subject.full_name).to eq 'Landing Zone 4'
expect(subject.status).to eq 'active'
expect(subject.location).to eq(
'name' => 'Vandenberg Air Force Base',
'region' => 'California',
'latitude' => 34.632989,
'longitude' => -120.615167
)
expect(subject.landing_type).to eq 'RTLS'
expect(subject.attempted_landings).to eq 2
expect(subject.successful_landings).to eq 2
expect(subject.wikipedia).to eq(
'https://en.wikipedia.org/wiki/' \
'Vandenberg_AFB_Space_Launch_Complex_4#LZ-4_landing_history'
)
expect(subject.details).to eq(
"SpaceX's west coast landing pad. The pad is adjacent to SLC-4E, " \
"SpaceX's west coast launch site. The pad was under construction for " \
'about a year starting in 2016. ' \
'After concerns with seal mating season, this pad was first used for ' \
'the SAOCOM 1A mission in October 2018. ' \
'Officially referred to as LZ-4 in FCC filings.'
)
end
end
end

0 comments on commit 781645a

Please sign in to comment.