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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4e165e4927169f37bcc54140b52448576c951867
4
- data.tar.gz: 8469c079c876d5d79c488580e07debcaf1ff0c7e
3
+ metadata.gz: 26e5f1c2dfc3df1fb6474f11e1566fe3cc82193b
4
+ data.tar.gz: 48f6adde1cc156854b828b88d51536d666adc419
5
5
  SHA512:
6
- metadata.gz: b05e00e900136a58891fbc5529bd605e88ea5453a7362e972acf550c04fd2460008f9553c0dbc099695bdcfa983076505312fd7fddfc9102ee07334535c21fb7
7
- data.tar.gz: 6726db41404c238a394648036d9413fece871d691176f35b3a904da41a0188253cdd319b5774dd591ca45014220f8280955d6b99611f8a9128de440e8e6f170f
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 20:52:04 -0400 using RuboCop version 0.51.0.
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: 2
25
+ # Offense count: 1
26
26
  # Configuration parameters: CountComments.
27
27
  Metrics/MethodLength:
28
- Max: 12
28
+ Max: 11
29
29
 
30
- # Offense count: 3
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
- `gem install spacex`
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
- ## Using
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
@@ -5,6 +5,7 @@ require 'faraday_middleware'
5
5
  require 'faraday_middleware/response_middleware'
6
6
  require 'hashie'
7
7
 
8
+ require_relative 'spacex/base_request'
8
9
  require_relative 'spacex/version'
9
10
  require_relative 'spacex/launches'
10
11
  require_relative 'spacex/company_info'
@@ -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
@@ -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
- 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)
6
+ SPACEX::BaseRequest.get('info')
23
7
  end
24
8
  end
25
9
  end
@@ -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
- path = 'launches/latest'
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
@@ -1,7 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module SPACEX
4
- VERSION = '0.0.4'
4
+ VERSION = '0.0.5'
5
+ ROOT_URI = 'https://api.spacexdata.com/v2'
5
6
 
6
7
  def self.help
7
8
  puts 'https://github.com/rodolfobandeira/spacex'
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
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