spacex 0.0.4 → 0.0.5
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 +5 -4
- data/README.md +31 -3
- data/lib/spacex.rb +1 -0
- data/lib/spacex/base_request.rb +19 -0
- data/lib/spacex/company_info.rb +1 -17
- data/lib/spacex/launches.rb +1 -17
- data/lib/spacex/version.rb +2 -1
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 26e5f1c2dfc3df1fb6474f11e1566fe3cc82193b
|
4
|
+
data.tar.gz: 48f6adde1cc156854b828b88d51536d666adc419
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2130be20a9251a4a431efdcb325215d9f862d7da3743c715b6f7c448cfd19cb3240607d428fe00bd6b69181b919852a6083d13cee8f4f5bbd515ff2d32ee2568
|
7
|
+
data.tar.gz: 96e6677d0b36a332d172614d22b95d6b9a73192f232895c00693e0d19a8ea122ac6a8b90d1b9e2a087839160698189a6cb4dad1e852a8e3356e93e48c1a90866
|
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-21
|
3
|
+
# on 2018-08-21 21:48:44 -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
|
@@ -22,16 +22,17 @@ Metrics/BlockLength:
|
|
22
22
|
Metrics/LineLength:
|
23
23
|
Max: 247
|
24
24
|
|
25
|
-
# Offense count:
|
25
|
+
# Offense count: 1
|
26
26
|
# Configuration parameters: CountComments.
|
27
27
|
Metrics/MethodLength:
|
28
|
-
Max:
|
28
|
+
Max: 11
|
29
29
|
|
30
|
-
# Offense count:
|
30
|
+
# Offense count: 4
|
31
31
|
Style/Documentation:
|
32
32
|
Exclude:
|
33
33
|
- 'spec/**/*'
|
34
34
|
- 'test/**/*'
|
35
|
+
- 'lib/spacex/base_request.rb'
|
35
36
|
- 'lib/spacex/company_info.rb'
|
36
37
|
- 'lib/spacex/launches.rb'
|
37
38
|
- 'lib/spacex/version.rb'
|
data/README.md
CHANGED
@@ -6,12 +6,29 @@ SpaceX Ruby Client
|
|
6
6
|
|
7
7
|
Ruby library that consumes SpaceX API
|
8
8
|
|
9
|
-
## Install
|
10
9
|
|
11
|
-
|
10
|
+
## Table of Contents
|
12
11
|
|
12
|
+
- [Installation](#installation)
|
13
|
+
- [Usage](#usage)
|
14
|
+
- [Latest Launch](#latest-launch)
|
15
|
+
- [Company Info](#company-info)
|
16
|
+
- [Contributing](#contributing)
|
17
|
+
- [Copyright](#copyright)
|
13
18
|
|
14
|
-
|
19
|
+
|
20
|
+
## Installation
|
21
|
+
|
22
|
+
Add to Gemfile.
|
23
|
+
|
24
|
+
```
|
25
|
+
gem 'spacex'
|
26
|
+
```
|
27
|
+
|
28
|
+
Run `bundle install`.
|
29
|
+
|
30
|
+
|
31
|
+
## Usage
|
15
32
|
|
16
33
|
### Latest Launch
|
17
34
|
|
@@ -108,3 +125,14 @@ company_info.headquarters.city # 'Hawthorne'
|
|
108
125
|
company_info.headquarters.state # 'California'
|
109
126
|
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
127
|
```
|
128
|
+
|
129
|
+
## Contributing
|
130
|
+
|
131
|
+
Want to help? Create an issue, open a pull request. Any help is welcome.
|
132
|
+
|
133
|
+
|
134
|
+
## Copyright
|
135
|
+
|
136
|
+
Copyright (c) Rodolfo Bandeira, 2018
|
137
|
+
|
138
|
+
MIT License, see [LICENSE](https://github.com/rodolfobandeira/spacex/blob/master/LICENSE) for details.
|
data/lib/spacex.rb
CHANGED
@@ -0,0 +1,19 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module SPACEX
|
4
|
+
module BaseRequest
|
5
|
+
def self.get(path)
|
6
|
+
data = Faraday.new(
|
7
|
+
url: "#{SPACEX::ROOT_URI}/#{path}",
|
8
|
+
request: {
|
9
|
+
params_encoder: Faraday::FlatParamsEncoder
|
10
|
+
}
|
11
|
+
) do |c|
|
12
|
+
c.use ::FaradayMiddleware::ParseJson
|
13
|
+
c.use Faraday::Response::RaiseError
|
14
|
+
c.use Faraday::Adapter::NetHttp
|
15
|
+
end
|
16
|
+
Hashie::Mash.new(data.get.body)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
data/lib/spacex/company_info.rb
CHANGED
@@ -1,25 +1,9 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require 'ostruct'
|
4
|
-
|
5
3
|
module SPACEX
|
6
4
|
module CompanyInfo
|
7
|
-
ROOT_URI = 'https://api.spacexdata.com/v2'
|
8
|
-
|
9
5
|
def self.info
|
10
|
-
|
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)
|
6
|
+
SPACEX::BaseRequest.get('info')
|
23
7
|
end
|
24
8
|
end
|
25
9
|
end
|
data/lib/spacex/launches.rb
CHANGED
@@ -1,25 +1,9 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require 'ostruct'
|
4
|
-
|
5
3
|
module SPACEX
|
6
4
|
module Launches
|
7
|
-
ROOT_URI = 'https://api.spacexdata.com/v2'
|
8
|
-
|
9
5
|
def self.latest
|
10
|
-
|
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)
|
6
|
+
SPACEX::BaseRequest.get('launches/latest')
|
23
7
|
end
|
24
8
|
end
|
25
9
|
end
|
data/lib/spacex/version.rb
CHANGED
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.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Rodolfo Bandeira
|
@@ -139,6 +139,7 @@ files:
|
|
139
139
|
- README.md
|
140
140
|
- Rakefile
|
141
141
|
- lib/spacex.rb
|
142
|
+
- lib/spacex/base_request.rb
|
142
143
|
- lib/spacex/company_info.rb
|
143
144
|
- lib/spacex/endpoint.rb
|
144
145
|
- lib/spacex/launches.rb
|