spacex 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop_todo.yml +6 -5
- data/README.md +38 -4
- data/lib/spacex.rb +1 -0
- data/lib/spacex/company_info.rb +25 -0
- data/lib/spacex/version.rb +1 -1
- data/spacex.gemspec +2 -0
- data/spec/fixtures/spacex/company_info/info.yml +68 -0
- data/spec/spacex/company_info_spec.rb +29 -0
- metadata +6 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4e165e4927169f37bcc54140b52448576c951867
|
4
|
+
data.tar.gz: 8469c079c876d5d79c488580e07debcaf1ff0c7e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b05e00e900136a58891fbc5529bd605e88ea5453a7362e972acf550c04fd2460008f9553c0dbc099695bdcfa983076505312fd7fddfc9102ee07334535c21fb7
|
7
|
+
data.tar.gz: 6726db41404c238a394648036d9413fece871d691176f35b3a904da41a0188253cdd319b5774dd591ca45014220f8280955d6b99611f8a9128de440e8e6f170f
|
data/.rubocop_todo.yml
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# This configuration was generated by
|
2
2
|
# `rubocop --auto-gen-config`
|
3
|
-
# on 2018-08-20
|
3
|
+
# on 2018-08-21 20:52:04 -0400 using RuboCop version 0.51.0.
|
4
4
|
# The point is for the user to remove these configuration records
|
5
5
|
# one by one as the offenses are removed from the code base.
|
6
6
|
# Note that changes in the inspected code, or installation of new
|
@@ -16,21 +16,22 @@ Lint/AmbiguousOperator:
|
|
16
16
|
Metrics/BlockLength:
|
17
17
|
Max: 71
|
18
18
|
|
19
|
-
# Offense count:
|
19
|
+
# Offense count: 25
|
20
20
|
# Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns.
|
21
21
|
# URISchemes: http, https
|
22
22
|
Metrics/LineLength:
|
23
|
-
Max:
|
23
|
+
Max: 247
|
24
24
|
|
25
|
-
# Offense count:
|
25
|
+
# Offense count: 2
|
26
26
|
# Configuration parameters: CountComments.
|
27
27
|
Metrics/MethodLength:
|
28
28
|
Max: 12
|
29
29
|
|
30
|
-
# Offense count:
|
30
|
+
# Offense count: 3
|
31
31
|
Style/Documentation:
|
32
32
|
Exclude:
|
33
33
|
- 'spec/**/*'
|
34
34
|
- 'test/**/*'
|
35
|
+
- 'lib/spacex/company_info.rb'
|
35
36
|
- 'lib/spacex/launches.rb'
|
36
37
|
- 'lib/spacex/version.rb'
|
data/README.md
CHANGED
@@ -1,11 +1,22 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
SpaceX Ruby Client
|
2
|
+
===============
|
3
3
|
|
4
|
-
|
4
|
+
[![Gem Version](https://badge.fury.io/rb/spacex.svg)](https://badge.fury.io/rb/spacex)
|
5
|
+
[![Build Status](https://travis-ci.com/rodolfobandeira/spacex.svg?branch=master)](https://travis-ci.org/rodolfobandeira/spacex)
|
5
6
|
|
6
|
-
|
7
|
+
Ruby library that consumes SpaceX API
|
8
|
+
|
9
|
+
## Install
|
10
|
+
|
11
|
+
`gem install spacex`
|
12
|
+
|
13
|
+
|
14
|
+
## Using
|
15
|
+
|
16
|
+
### Latest Launch
|
7
17
|
|
8
18
|
```ruby
|
19
|
+
require 'spacex'
|
9
20
|
latest_launch = SPACEX::Launches.latest
|
10
21
|
|
11
22
|
latest_launch.flight_number # 67
|
@@ -74,3 +85,26 @@ latest_launch.upcoming # false
|
|
74
85
|
latest_launch.static_fire_date_utc # '2018-08-02T15:53:00.000Z'
|
75
86
|
```
|
76
87
|
|
88
|
+
|
89
|
+
### Company Info
|
90
|
+
|
91
|
+
```ruby
|
92
|
+
company_info = SPACEX::CompanyInfo.info
|
93
|
+
|
94
|
+
company_info.name # 'SpaceX'
|
95
|
+
company_info.founder # 'Elon Musk'
|
96
|
+
company_info.founded # 2002
|
97
|
+
company_info.employees # 7000
|
98
|
+
company_info.vehicles # 3
|
99
|
+
company_info.launche_sites # nil
|
100
|
+
company_info.test_sites # 1
|
101
|
+
company_info.ceo # 'Elon Musk'
|
102
|
+
company_info.cto # 'Elon Musk'
|
103
|
+
company_info.coo # 'Gwynne Shotwell'
|
104
|
+
company_info.cto_propulsion # 'Tom Mueller'
|
105
|
+
company_info.valuation # 15_000_000_000
|
106
|
+
company_info.headquarters.address # 'Rocket Road'
|
107
|
+
company_info.headquarters.city # 'Hawthorne'
|
108
|
+
company_info.headquarters.state # 'California'
|
109
|
+
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.'
|
110
|
+
```
|
data/lib/spacex.rb
CHANGED
@@ -0,0 +1,25 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'ostruct'
|
4
|
+
|
5
|
+
module SPACEX
|
6
|
+
module CompanyInfo
|
7
|
+
ROOT_URI = 'https://api.spacexdata.com/v2'
|
8
|
+
|
9
|
+
def self.info
|
10
|
+
path = 'info'
|
11
|
+
|
12
|
+
data = Faraday.new(
|
13
|
+
url: "#{ROOT_URI}/#{path}",
|
14
|
+
request: {
|
15
|
+
params_encoder: Faraday::FlatParamsEncoder
|
16
|
+
}
|
17
|
+
) do |c|
|
18
|
+
c.use ::FaradayMiddleware::ParseJson
|
19
|
+
c.use Faraday::Response::RaiseError
|
20
|
+
c.use Faraday::Adapter::NetHttp
|
21
|
+
end
|
22
|
+
Hashie::Mash.new(data.get.body)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
data/lib/spacex/version.rb
CHANGED
data/spacex.gemspec
CHANGED
@@ -0,0 +1,68 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: get
|
5
|
+
uri: https://api.spacexdata.com/v2/info
|
6
|
+
body:
|
7
|
+
encoding: US-ASCII
|
8
|
+
string: ''
|
9
|
+
headers:
|
10
|
+
User-Agent:
|
11
|
+
- Faraday v0.15.2
|
12
|
+
Accept-Encoding:
|
13
|
+
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
|
14
|
+
Accept:
|
15
|
+
- "*/*"
|
16
|
+
response:
|
17
|
+
status:
|
18
|
+
code: 200
|
19
|
+
message: OK
|
20
|
+
headers:
|
21
|
+
Date:
|
22
|
+
- Tue, 21 Aug 2018 20:39:09 GMT
|
23
|
+
Content-Type:
|
24
|
+
- application/json; charset=utf-8
|
25
|
+
Transfer-Encoding:
|
26
|
+
- chunked
|
27
|
+
Connection:
|
28
|
+
- keep-alive
|
29
|
+
Set-Cookie:
|
30
|
+
- __cfduid=d1ba4d49d7091324dcf832d773eb43b981534883949; expires=Wed, 21-Aug-19
|
31
|
+
20:39:09 GMT; path=/; domain=.spacexdata.com; HttpOnly; Secure
|
32
|
+
Vary:
|
33
|
+
- Accept-Encoding, Origin
|
34
|
+
X-Dns-Prefetch-Control:
|
35
|
+
- 'off'
|
36
|
+
X-Frame-Options:
|
37
|
+
- SAMEORIGIN
|
38
|
+
Strict-Transport-Security:
|
39
|
+
- max-age=15552000; includeSubDomains
|
40
|
+
X-Download-Options:
|
41
|
+
- noopen
|
42
|
+
X-Content-Type-Options:
|
43
|
+
- nosniff
|
44
|
+
X-Xss-Protection:
|
45
|
+
- 1; mode=block
|
46
|
+
Access-Control-Allow-Origin:
|
47
|
+
- "*"
|
48
|
+
X-Koa-Redis-Cache:
|
49
|
+
- 'true'
|
50
|
+
X-Response-Time:
|
51
|
+
- 2ms
|
52
|
+
Expect-Ct:
|
53
|
+
- max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct"
|
54
|
+
Server:
|
55
|
+
- cloudflare
|
56
|
+
Cf-Ray:
|
57
|
+
- 44dfe84c7ee53024-YYZ
|
58
|
+
body:
|
59
|
+
encoding: ASCII-8BIT
|
60
|
+
string: '{"name":"SpaceX","founder":"Elon Musk","founded":2002,"employees":7000,"vehicles":3,"launch_sites":3,"test_sites":1,"ceo":"Elon
|
61
|
+
Musk","cto":"Elon Musk","coo":"Gwynne Shotwell","cto_propulsion":"Tom Mueller","valuation":15000000000,"headquarters":{"address":"Rocket
|
62
|
+
Road","city":"Hawthorne","state":"California"},"summary":"SpaceX designs,
|
63
|
+
manufactures and launches advanced rockets and spacecraft. The company was
|
64
|
+
founded in 2002 to revolutionize space technology, with the ultimate goal
|
65
|
+
of enabling people to live on other planets."}'
|
66
|
+
http_version:
|
67
|
+
recorded_at: Tue, 21 Aug 2018 20:39:09 GMT
|
68
|
+
recorded_with: VCR 4.0.0
|
@@ -0,0 +1,29 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
describe SPACEX do
|
6
|
+
context 'CompanyInfo', vcr: { cassette_name: 'company_info/info' } do
|
7
|
+
subject do
|
8
|
+
SPACEX::CompanyInfo.info
|
9
|
+
end
|
10
|
+
it 'returns company info' do
|
11
|
+
expect(subject.name).to eq 'SpaceX'
|
12
|
+
expect(subject.founder).to eq 'Elon Musk'
|
13
|
+
expect(subject.founded).to eq 2002
|
14
|
+
expect(subject.employees).to eq 7000
|
15
|
+
expect(subject.vehicles).to eq 3
|
16
|
+
expect(subject.launche_sites).to eq nil
|
17
|
+
expect(subject.test_sites).to eq 1
|
18
|
+
expect(subject.ceo).to eq 'Elon Musk'
|
19
|
+
expect(subject.cto).to eq 'Elon Musk'
|
20
|
+
expect(subject.coo).to eq 'Gwynne Shotwell'
|
21
|
+
expect(subject.cto_propulsion).to eq 'Tom Mueller'
|
22
|
+
expect(subject.valuation).to eq 15_000_000_000
|
23
|
+
expect(subject.headquarters.address).to eq 'Rocket Road'
|
24
|
+
expect(subject.headquarters.city).to eq 'Hawthorne'
|
25
|
+
expect(subject.headquarters.state).to eq 'California'
|
26
|
+
expect(subject.summary).to eq '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.'
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: spacex
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Rodolfo Bandeira
|
@@ -139,12 +139,15 @@ files:
|
|
139
139
|
- README.md
|
140
140
|
- Rakefile
|
141
141
|
- lib/spacex.rb
|
142
|
+
- lib/spacex/company_info.rb
|
142
143
|
- lib/spacex/endpoint.rb
|
143
144
|
- lib/spacex/launches.rb
|
144
145
|
- lib/spacex/version.rb
|
145
146
|
- rubocop.yml
|
146
147
|
- spacex.gemspec
|
148
|
+
- spec/fixtures/spacex/company_info/info.yml
|
147
149
|
- spec/fixtures/spacex/launches/latest.yml
|
150
|
+
- spec/spacex/company_info_spec.rb
|
148
151
|
- spec/spacex/launches_spec.rb
|
149
152
|
- spec/spacex/version_spec.rb
|
150
153
|
- spec/spec_helper.rb
|
@@ -174,7 +177,9 @@ signing_key:
|
|
174
177
|
specification_version: 4
|
175
178
|
summary: Swap SpaceX API with Ruby
|
176
179
|
test_files:
|
180
|
+
- spec/fixtures/spacex/company_info/info.yml
|
177
181
|
- spec/fixtures/spacex/launches/latest.yml
|
182
|
+
- spec/spacex/company_info_spec.rb
|
178
183
|
- spec/spacex/launches_spec.rb
|
179
184
|
- spec/spacex/version_spec.rb
|
180
185
|
- spec/spec_helper.rb
|