Skip to content

Commit

Permalink
Merge pull request #4 from rodolfobandeira/add-roadster
Browse files Browse the repository at this point in the history
Add Roadster
  • Loading branch information
rodolfobandeira authored Aug 22, 2018
2 parents 387beac + 5362c14 commit 22f7453
Show file tree
Hide file tree
Showing 7 changed files with 154 additions and 6 deletions.
11 changes: 6 additions & 5 deletions .rubocop_todo.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# This configuration was generated by
# `rubocop --auto-gen-config`
# on 2018-08-21 21:48:44 -0400 using RuboCop version 0.51.0.
# on 2018-08-22 09:37:39 -0400 using RuboCop version 0.51.0.
# The point is for the user to remove these configuration records
# one by one as the offenses are removed from the code base.
# Note that changes in the inspected code, or installation of new
Expand All @@ -11,28 +11,29 @@ Lint/AmbiguousOperator:
Exclude:
- 'spec/spacex/launches_spec.rb'

# Offense count: 3
# Offense count: 5
# Configuration parameters: CountComments, ExcludedMethods.
Metrics/BlockLength:
Max: 71

# Offense count: 25
# Offense count: 26
# Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns.
# URISchemes: http, https
Metrics/LineLength:
Max: 247
Max: 494

# Offense count: 1
# Configuration parameters: CountComments.
Metrics/MethodLength:
Max: 11

# Offense count: 4
# Offense count: 5
Style/Documentation:
Exclude:
- 'spec/**/*'
- 'test/**/*'
- 'lib/spacex/base_request.rb'
- 'lib/spacex/company_info.rb'
- 'lib/spacex/launches.rb'
- 'lib/spacex/roadster.rb'
- 'lib/spacex/version.rb'
32 changes: 32 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ Ruby library that consumes SpaceX API
- [Usage](#usage)
- [Latest Launch](#latest-launch)
- [Company Info](#company-info)
- [Roadster](#roadster)
- [Contributing](#contributing)
- [Copyright](#copyright)

Expand Down Expand Up @@ -126,6 +127,37 @@ company_info.headquarters.state # 'California'
company_info.summary # 'SpaceX designs, manufactures and launches advanced rockets and spacecraft. The company was founded in 2002 to revolutionize space technology, with the ultimate goal of enabling people to live on other planets.'
```

### Roadster

```ruby
roadster = SPACEX::Roadster.info

roadster.name # "Elon Musk's Tesla Roadster"
roadster.launch_date_utc # '2018-02-06T20:45:00.000Z'
roadster.launch_date_unix # 1_517_949_900
roadster.launch_date_kg # nil
roadster.launch_date_lbs # nil
roadster.norad_id # 43_205
roadster.epoch_jd # 2_458_353.027800926
roadster.orbit_type # 'heliocentric'
roadster.apoapsis_au # 1.663757412460597
roadster.periapsis_au # 0.9860953641129515
roadster.semo_major_axis_au # nil
roadster.eccentricity # 0.2557357353354217
roadster.inclination # 1.077474057737451
roadster.longitude # 317.0962040947829
roadster.periapsis_arg # 177.491390597234
roadster.speed_kph # 76_703.72399999999
roadster.speed_mph # 47_661.469685603995
roadster.earth_distance_km # 172_954_806.23899576
roadster.earth_distance_mi # 107_469_100.90753104
roadster.mars_distance_km # 147_648_108.6344399
roadster.mars_distance_mi # 91_744_252.91029055
roadster.wikipedia # 'https://en.wikipedia.org/wiki/Elon_Musk%27s_Tesla_Roadster'
roadster.details # "Elon Musk's Tesla Roadster is an electric sports car that served as the dummy payload for the February 2018 Falcon Heavy test flight and is now an artificial satellite of the Sun. Starman, a mannequin dressed in a spacesuit, occupies the driver's seat. The car and rocket are products of Tesla and SpaceX, both companies founded by Elon Musk. This 2008-model Roadster was previously used by Musk for commuting, and is the only consumer car sent into space."
```


## Contributing

Want to help? Create an issue, open a pull request. Any help is welcome.
Expand Down
1 change: 1 addition & 0 deletions lib/spacex.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@
require_relative 'spacex/version'
require_relative 'spacex/launches'
require_relative 'spacex/company_info'
require_relative 'spacex/roadster'
9 changes: 9 additions & 0 deletions lib/spacex/roadster.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# frozen_string_literal: true

module SPACEX
module Roadster
def self.info
SPACEX::BaseRequest.get('info/roadster')
end
end
end
2 changes: 1 addition & 1 deletion lib/spacex/version.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# frozen_string_literal: true

module SPACEX
VERSION = '0.0.5'
VERSION = '0.0.6'
ROOT_URI = 'https://api.spacexdata.com/v2'

def self.help
Expand Down
69 changes: 69 additions & 0 deletions spec/fixtures/spacex/roadster/info.yml

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

36 changes: 36 additions & 0 deletions spec/spacex/roadster_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# frozen_string_literal: true

require 'spec_helper'

describe SPACEX do
context 'Roadster Information', vcr: { cassette_name: 'roadster/info' } do
subject do
SPACEX::Roadster.info
end
it 'returns Roadster launch info' do
expect(subject.name).to eq "Elon Musk's Tesla Roadster"
expect(subject.launch_date_utc).to eq '2018-02-06T20:45:00.000Z'
expect(subject.launch_date_unix).to eq 1_517_949_900
expect(subject.launch_date_kg).to eq nil
expect(subject.launch_date_lbs).to eq nil
expect(subject.norad_id).to eq 43_205
expect(subject.epoch_jd).to eq 2_458_353.027800926
expect(subject.orbit_type).to eq 'heliocentric'
expect(subject.apoapsis_au).to eq 1.663757412460597
expect(subject.periapsis_au).to eq 0.9860953641129515
expect(subject.semo_major_axis_au).to eq nil
expect(subject.eccentricity).to eq 0.2557357353354217
expect(subject.inclination).to eq 1.077474057737451
expect(subject.longitude).to eq 317.0962040947829
expect(subject.periapsis_arg).to eq 177.491390597234
expect(subject.speed_kph).to eq 76_703.72399999999
expect(subject.speed_mph).to eq 47_661.469685603995
expect(subject.earth_distance_km).to eq 172_954_806.23899576
expect(subject.earth_distance_mi).to eq 107_469_100.90753104
expect(subject.mars_distance_km).to eq 147_648_108.6344399
expect(subject.mars_distance_mi).to eq 91_744_252.91029055
expect(subject.wikipedia).to eq 'https://en.wikipedia.org/wiki/Elon_Musk%27s_Tesla_Roadster'
expect(subject.details).to eq "Elon Musk's Tesla Roadster is an electric sports car that served as the dummy payload for the February 2018 Falcon Heavy test flight and is now an artificial satellite of the Sun. Starman, a mannequin dressed in a spacesuit, occupies the driver's seat. The car and rocket are products of Tesla and SpaceX, both companies founded by Elon Musk. This 2008-model Roadster was previously used by Musk for commuting, and is the only consumer car sent into space."
end
end
end

0 comments on commit 22f7453

Please sign in to comment.