spacex_api 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 7283fce7dae0cb04d7da1da3066504604c30ee9a93745b9e409cc80e9d20c8e7
4
+ data.tar.gz: d93599304f096b2ff563e395c4bb27276116a5983808bce2c7ae2416667fa2fb
5
+ SHA512:
6
+ metadata.gz: 5a5bfb4f3ee5b2d7dc6aee02554522a929942347764be1ef7bf1402ef9eb4bc0159c5cd5783b81ce3e0a84dfc34a6348b61dcf5e3ed01d6a5e071081b43c26ba
7
+ data.tar.gz: cbd9517290dfabed23a09dc3d3cf4a9de3093a3fe7dc63ab88309d5805504ac5ce7b229f39d542d70d66a27464b78bc8021b64c994972096fe4422dddacabf3d
@@ -0,0 +1,39 @@
1
+ name: Verify
2
+ on: [push]
3
+
4
+ jobs:
5
+ linters:
6
+ name: Linters
7
+ runs-on: ubuntu-latest
8
+ steps:
9
+ - name: Checkout code
10
+ uses: actions/checkout@v2
11
+
12
+ - name: Setup Ruby and install gems
13
+ uses: ruby/setup-ruby@v1
14
+ with:
15
+ bundler-cache: true
16
+ ruby-version: 2.4
17
+
18
+ - name: Run linters
19
+ run: |
20
+ bundle exec rubocop
21
+ tests:
22
+ name: Tests
23
+ runs-on: ubuntu-latest
24
+ strategy:
25
+ matrix:
26
+ ruby-version: [2.4, 2.5, 2.6, 2.7, 3.0]
27
+ steps:
28
+ - name: Checkout code
29
+ uses: actions/checkout@v2
30
+
31
+ - name: Setup Ruby and install gems
32
+ uses: ruby/setup-ruby@v1
33
+ with:
34
+ bundler-cache: true
35
+ ruby-version: ${{ matrix.ruby-version }}
36
+
37
+ - name: Run tests
38
+ run: |
39
+ bundle exec rake test
data/.gitignore ADDED
@@ -0,0 +1,9 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+ .DS_Store
data/.rubocop.yml ADDED
@@ -0,0 +1,12 @@
1
+ inherit_from: .rubocop_todo.yml
2
+
3
+ AllCops:
4
+ NewCops: enable
5
+ SuggestExtensions: false
6
+ TargetRubyVersion: 2.4
7
+
8
+ Metrics/MethodLength:
9
+ Max: 15
10
+
11
+ Style/StringLiterals:
12
+ EnforcedStyle: double_quotes
data/.rubocop_todo.yml ADDED
@@ -0,0 +1,19 @@
1
+ # This configuration was generated by
2
+ # `rubocop --auto-gen-config`
3
+ # on 2021-04-04 02:35:34 UTC using RuboCop version 1.12.0.
4
+ # The point is for the user to remove these configuration records
5
+ # one by one as the offenses are removed from the code base.
6
+ # Note that changes in the inspected code, or installation of new
7
+ # versions of RuboCop, may require this file to be generated again.
8
+
9
+ # Offense count: 1
10
+ # Configuration parameters: Include.
11
+ # Include: **/*.gemspec
12
+ Gemspec/RequiredRubyVersion:
13
+ Exclude:
14
+ - 'spacex_api.gemspec'
15
+
16
+ # Offense count: 18
17
+ # Configuration parameters: AllowedConstants.
18
+ Style/Documentation:
19
+ Enabled: false
data/CHANGELOG.md ADDED
@@ -0,0 +1,4 @@
1
+ # Changelog
2
+
3
+ ## 1.0.0 - 2021-04-24
4
+ * Public release [@victorperez](https://github.com/victorperez)
@@ -0,0 +1,74 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ In the interest of fostering an open and welcoming environment, we as
6
+ contributors and maintainers pledge to making participation in our project and
7
+ our community a harassment-free experience for everyone, regardless of age, body
8
+ size, disability, ethnicity, gender identity and expression, level of experience,
9
+ nationality, personal appearance, race, religion, or sexual identity and
10
+ orientation.
11
+
12
+ ## Our Standards
13
+
14
+ Examples of behavior that contributes to creating a positive environment
15
+ include:
16
+
17
+ * Using welcoming and inclusive language
18
+ * Being respectful of differing viewpoints and experiences
19
+ * Gracefully accepting constructive criticism
20
+ * Focusing on what is best for the community
21
+ * Showing empathy towards other community members
22
+
23
+ Examples of unacceptable behavior by participants include:
24
+
25
+ * The use of sexualized language or imagery and unwelcome sexual attention or
26
+ advances
27
+ * Trolling, insulting/derogatory comments, and personal or political attacks
28
+ * Public or private harassment
29
+ * Publishing others' private information, such as a physical or electronic
30
+ address, without explicit permission
31
+ * Other conduct which could reasonably be considered inappropriate in a
32
+ professional setting
33
+
34
+ ## Our Responsibilities
35
+
36
+ Project maintainers are responsible for clarifying the standards of acceptable
37
+ behavior and are expected to take appropriate and fair corrective action in
38
+ response to any instances of unacceptable behavior.
39
+
40
+ Project maintainers have the right and responsibility to remove, edit, or
41
+ reject comments, commits, code, wiki edits, issues, and other contributions
42
+ that are not aligned to this Code of Conduct, or to ban temporarily or
43
+ permanently any contributor for other behaviors that they deem inappropriate,
44
+ threatening, offensive, or harmful.
45
+
46
+ ## Scope
47
+
48
+ This Code of Conduct applies both within project spaces and in public spaces
49
+ when an individual is representing the project or its community. Examples of
50
+ representing a project or community include using an official project e-mail
51
+ address, posting via an official social media account, or acting as an appointed
52
+ representative at an online or offline event. Representation of a project may be
53
+ further defined and clarified by project maintainers.
54
+
55
+ ## Enforcement
56
+
57
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
58
+ reported by contacting the project team at victor.mx14@gmail.com. All
59
+ complaints will be reviewed and investigated and will result in a response that
60
+ is deemed necessary and appropriate to the circumstances. The project team is
61
+ obligated to maintain confidentiality with regard to the reporter of an incident.
62
+ Further details of specific enforcement policies may be posted separately.
63
+
64
+ Project maintainers who do not follow or enforce the Code of Conduct in good
65
+ faith may face temporary or permanent repercussions as determined by other
66
+ members of the project's leadership.
67
+
68
+ ## Attribution
69
+
70
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71
+ available at [https://contributor-covenant.org/version/1/4][version]
72
+
73
+ [homepage]: https://contributor-covenant.org
74
+ [version]: https://contributor-covenant.org/version/1/4/
data/Gemfile ADDED
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ source "https://rubygems.org"
4
+
5
+ # Specify your gem's dependencies in spacex_api.gemspec
6
+ gemspec
7
+
8
+ gem "minitest", "~> 5.0"
9
+ gem "rake", "~> 12.0"
data/Gemfile.lock ADDED
@@ -0,0 +1,90 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ spacex_api (1.0.0)
5
+ faraday (~> 1.0)
6
+ faraday_middleware (~> 1.0)
7
+
8
+ GEM
9
+ remote: https://rubygems.org/
10
+ specs:
11
+ addressable (2.7.0)
12
+ public_suffix (>= 2.0.2, < 5.0)
13
+ ast (2.4.2)
14
+ coveralls (0.8.23)
15
+ json (>= 1.8, < 3)
16
+ simplecov (~> 0.16.1)
17
+ term-ansicolor (~> 1.3)
18
+ thor (>= 0.19.4, < 2.0)
19
+ tins (~> 1.6)
20
+ crack (0.4.5)
21
+ rexml
22
+ docile (1.3.5)
23
+ faraday (1.4.1)
24
+ faraday-excon (~> 1.1)
25
+ faraday-net_http (~> 1.0)
26
+ faraday-net_http_persistent (~> 1.1)
27
+ multipart-post (>= 1.2, < 3)
28
+ ruby2_keywords (>= 0.0.4)
29
+ faraday-excon (1.1.0)
30
+ faraday-net_http (1.0.1)
31
+ faraday-net_http_persistent (1.1.0)
32
+ faraday_middleware (1.0.0)
33
+ faraday (~> 1.0)
34
+ hashdiff (1.0.1)
35
+ json (2.5.1)
36
+ minitest (5.14.4)
37
+ multipart-post (2.1.1)
38
+ parallel (1.20.1)
39
+ parser (3.0.1.0)
40
+ ast (~> 2.4.1)
41
+ public_suffix (4.0.6)
42
+ rainbow (3.0.0)
43
+ rake (12.3.3)
44
+ regexp_parser (2.1.1)
45
+ rexml (3.2.5)
46
+ rubocop (1.12.0)
47
+ parallel (~> 1.10)
48
+ parser (>= 3.0.0.0)
49
+ rainbow (>= 2.2.2, < 4.0)
50
+ regexp_parser (>= 1.8, < 3.0)
51
+ rexml
52
+ rubocop-ast (>= 1.2.0, < 2.0)
53
+ ruby-progressbar (~> 1.7)
54
+ unicode-display_width (>= 1.4.0, < 3.0)
55
+ rubocop-ast (1.4.1)
56
+ parser (>= 2.7.1.5)
57
+ ruby-progressbar (1.11.0)
58
+ ruby2_keywords (0.0.4)
59
+ simplecov (0.16.1)
60
+ docile (~> 1.1)
61
+ json (>= 1.8, < 3)
62
+ simplecov-html (~> 0.10.0)
63
+ simplecov-html (0.10.2)
64
+ sync (0.5.0)
65
+ term-ansicolor (1.7.1)
66
+ tins (~> 1.0)
67
+ thor (1.1.0)
68
+ tins (1.28.0)
69
+ sync
70
+ unicode-display_width (2.0.0)
71
+ vcr (6.0.0)
72
+ webmock (3.12.2)
73
+ addressable (>= 2.3.6)
74
+ crack (>= 0.3.2)
75
+ hashdiff (>= 0.4.0, < 2.0.0)
76
+
77
+ PLATFORMS
78
+ ruby
79
+
80
+ DEPENDENCIES
81
+ coveralls (~> 0.8)
82
+ minitest (~> 5.0)
83
+ rake (~> 12.0)
84
+ rubocop (= 1.12)
85
+ spacex_api!
86
+ vcr (~> 6.0)
87
+ webmock (~> 3.12)
88
+
89
+ BUNDLED WITH
90
+ 2.1.2
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2021 Victor Perez Rodriguez
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,280 @@
1
+ # Spacex API
2
+
3
+ Ruby API wrapper to consume the [SpaceX API](https://github.com/r-spacex/SpaceX-API).
4
+
5
+ The gem currently support the latest SpaceX API version (V4).
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'spacex_api'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle install
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install spacex_api
22
+
23
+ ## Usage
24
+
25
+ ### Capsules
26
+
27
+ Detailed info for serialized dragon capsules
28
+
29
+ * Get all capsules: `SpacexApi.client.capsules`
30
+ * Get one capsule: `SpacexApi.client.get_capsule('id')`
31
+ * Query capsules: `SpacexApi.client.query_capsules({}.to_json)`
32
+ * See [query](https://github.com/r-spacex/SpaceX-API/blob/master/docs/v4/queries.md) guide for more details on building queries and paginating
33
+
34
+ ```ruby
35
+ capsule = SpacexApi.client.capsules.first
36
+ capsule.id
37
+ => "5e9e2c5bf35918ed873b2664"
38
+ capsule.last_update
39
+ => "Hanging in atrium at SpaceX HQ in Hawthorne"
40
+ ```
41
+
42
+ ### Company Info
43
+
44
+ Detailed info about SpaceX as a company
45
+
46
+ * Get company info: `SpacexApi.client.company_info`
47
+
48
+ ```ruby
49
+ company_info = SpacexApi.client.company_info
50
+ company_info.employees
51
+ => 9500
52
+ company_info.headquarters.address
53
+ => "Rocket Road"
54
+ ```
55
+
56
+ ### Cores
57
+
58
+ Detailed info for serialized first stage cores
59
+
60
+ * Get all cores: `SpacexApi.client.cores`
61
+ * Get one core: `SpacexApi.client.get_core('id')`
62
+ * Query cores: `SpacexApi.client.query_cores({}.to_json)`
63
+ * See [query](https://github.com/r-spacex/SpaceX-API/blob/master/docs/v4/queries.md) guide for more details on building queries and paginating
64
+
65
+ ```ruby
66
+ core = SpacexApi.client.cores.first
67
+ core.id
68
+ => "5e9e289df35918033d3b2623"
69
+ core.status
70
+ => "lost"
71
+ ```
72
+
73
+ ### Crew
74
+
75
+ Detailed info on dragon crew members
76
+
77
+ * Get all crew members: `SpacexApi.client.crews`
78
+ * Get one crew member: `SpacexApi.client.get_crew('id')`
79
+ * Query crew members: `SpacexApi.client.query_crews({}.to_json)`
80
+ * See [query](https://github.com/r-spacex/SpaceX-API/blob/master/docs/v4/queries.md) guide for more details on building queries and paginating
81
+
82
+ ```ruby
83
+ crew = SpacexApi.client.crews.first
84
+ crew.id
85
+ => "5ebf1a6e23a9a60006e03a7a"
86
+ crew.agency
87
+ => "NASA"
88
+ ```
89
+
90
+ ### Dragons
91
+
92
+ Detailed info on dragon crew members
93
+
94
+ * Get all dragons: `SpacexApi.client.dragons`
95
+ * Get one dragon: `SpacexApi.client.get_dragon('id')`
96
+ * Query dragons: `SpacexApi.client.query_dragons({}.to_json)`
97
+ * See [query](https://github.com/r-spacex/SpaceX-API/blob/master/docs/v4/queries.md) guide for more details on building queries and paginating
98
+
99
+ ```ruby
100
+ dragon = SpacexApi.client.dragons.first
101
+ dragon.id
102
+ => "5e9d058759b1ff74a7ad5f8f"
103
+ dragon.heat_shield.material
104
+ => "PICA-X"
105
+ ```
106
+
107
+ ### Historical events
108
+
109
+ Detailed info on SpaceX historical events
110
+
111
+ * Get all historical events: `SpacexApi.client.historical_events`
112
+ * Get one historical event: `SpacexApi.client.get_historical_event('id')`
113
+ * Query historical events: `SpacexApi.client.query_historical_events({}.to_json)`
114
+ * See [query](https://github.com/r-spacex/SpaceX-API/blob/master/docs/v4/queries.md) guide for more details on building queries and paginating
115
+
116
+ ```ruby
117
+ historical_event = SpacexApi.client.historical_events.first
118
+ historical_event.id
119
+ => "5f6fb2cfdcfdf403df37971e"
120
+ historical_event.event_date_utc
121
+ => "2008-09-28T23:15:00Z"
122
+ ```
123
+
124
+ ### Landpads
125
+
126
+ Detailed info about landing pads and ships
127
+
128
+ * Get all landpads: `SpacexApi.client.landpads`
129
+ * Get one landpad: `SpacexApi.client.get_landpad('id')`
130
+ * Query landpads: `SpacexApi.client.query_landpads({}.to_json)`
131
+ * See [query](https://github.com/r-spacex/SpaceX-API/blob/master/docs/v4/queries.md) guide for more details on building queries and paginating
132
+
133
+ ```ruby
134
+ landpad = SpacexApi.client.landpads.first
135
+ landpad.id
136
+ => "5e9e3032383ecb267a34e7c7"
137
+ landpad.full_name
138
+ => "Landing Zone 1"
139
+ ```
140
+
141
+ ### Launches
142
+
143
+ Detailed info about launches
144
+
145
+ * Get past launches: `SpacexApi.client.past_launches`
146
+ * Get upcoming launches: `SpacexApi.client.upcoming_launches`
147
+ * Get latest launch: `SpacexApi.client.latest_launch`
148
+ * Get next launch: `SpacexApi.client.next_launch`
149
+ * Get all launches: `SpacexApi.client.launches`
150
+ * Get one launch: `SpacexApi.client.get_launch('id')`
151
+ * Query launches: `SpacexApi.client.query_launches({}.to_json)`
152
+ * See [query](https://github.com/r-spacex/SpaceX-API/blob/master/docs/v4/queries.md) guide for more details on building queries and paginating
153
+
154
+ ```ruby
155
+ launch = SpacexApi.client.launches.first
156
+ launch.id
157
+ => "5eb87cd9ffd86e000604b32a"
158
+ launch.name
159
+ => "FalconSat"
160
+ ```
161
+
162
+ ### Launchpads
163
+
164
+ Detailed info about launchpads
165
+
166
+ * Get all launchpads: `SpacexApi.client.launchpads`
167
+ * Get one launchpad: `SpacexApi.client.get_launchpad('id')`
168
+ * Query launchpads: `SpacexApi.client.query_launchpads({}.to_json)`
169
+ * See [query](https://github.com/r-spacex/SpaceX-API/blob/master/docs/v4/queries.md) guide for more details on building queries and paginating
170
+
171
+ ```ruby
172
+ launchpad = SpacexApi.client.launchpads.first
173
+ launchpad.id
174
+ => "5e9e4501f5090910d4566f83"
175
+ launchpad.name
176
+ => "VAFB SLC 3W"
177
+ ```
178
+
179
+ ### Payloads
180
+
181
+ Detailed info about launch payloads
182
+
183
+ * Get all payloads: `SpacexApi.client.payloads`
184
+ * Get one payload: `SpacexApi.client.get_payload('id')`
185
+ * Query payloads: `SpacexApi.client.query_payloads({}.to_json)`
186
+ * See [query](https://github.com/r-spacex/SpaceX-API/blob/master/docs/v4/queries.md) guide for more details on building queries and paginating
187
+
188
+ ```ruby
189
+ payload = SpacexApi.client.payloads.first
190
+ payload.id
191
+ => "5eb0e4b5b6c3bb0006eeb1e1"
192
+ payload.nationalities
193
+ => ["United States"]
194
+ ```
195
+
196
+ ### Roadster info
197
+
198
+ Detailed info about Elon's Tesla roadster's current position
199
+
200
+ * Get roadster info: `SpacexApi.client.roadster`
201
+ * Query roadster info: `SpacexApi.client.query_roadster({}.to_json)`
202
+ * See [query](https://github.com/r-spacex/SpaceX-API/blob/master/docs/v4/queries.md) guide for more details on building queries and paginating
203
+
204
+ ```ruby
205
+ roadster = SpacexApi.client.roadster
206
+ roadster.id
207
+ => "5eb75f0842fea42237d7f3f4"
208
+ roadster.launch_mass_kg
209
+ => 1350
210
+ ```
211
+
212
+ ### Rockets
213
+
214
+ Detailed info about rocket versions
215
+
216
+ * Get all rockets: `SpacexApi.client.rockets`
217
+ * Get one rocket: `SpacexApi.client.get_rocket('id')`
218
+ * Query rockets: `SpacexApi.client.query_rockets({}.to_json)`
219
+ * See [query](https://github.com/r-spacex/SpaceX-API/blob/master/docs/v4/queries.md) guide for more details on building queries and paginating
220
+
221
+ ```ruby
222
+ rocket = SpacexApi.client.rockets.first
223
+ rocket.id
224
+ => "5e9d0d95eda69955f709d1eb"
225
+ rocket.company
226
+ => "SpaceX"
227
+ ```
228
+
229
+ ### Ships
230
+
231
+ Detailed info about ships in the SpaceX fleet
232
+
233
+ * Get all ships: `SpacexApi.client.ships`
234
+ * Get one ship: `SpacexApi.client.get_ship('id')`
235
+ * Query ships: `SpacexApi.client.query_ships({}.to_json)`
236
+ * See [query](https://github.com/r-spacex/SpaceX-API/blob/master/docs/v4/queries.md) guide for more details on building queries and paginating
237
+
238
+ ```ruby
239
+ ship = SpacexApi.client.ships.first
240
+ ship.id
241
+ => "5ea6ed2d080df4000697c901"
242
+ ship.type
243
+ => "Tug"
244
+ ```
245
+
246
+ ### Starlink
247
+
248
+ Detailed info about Starlink satellites and orbits. Includes raw orbit data from [Space Track](https://www.space-track.org/auth/login), updated hourly.
249
+
250
+ * Get all Starlink sats: `SpacexApi.client.starlinks`
251
+ * Get one Starlink sat: `SpacexApi.client.get_starlink('id')`
252
+ * Query Starlink sats: `SpacexApi.client.query_starlinks({}.to_json)`
253
+ * See [query](https://github.com/r-spacex/SpaceX-API/blob/master/docs/v4/queries.md) guide for more details on building queries and paginating
254
+
255
+ ```ruby
256
+ starlink = SpacexApi.client.starlinks.first
257
+ starlink.id
258
+ => "5eed770f096e59000698560d"
259
+ starlink.version
260
+ => "v0.9"
261
+ ```
262
+
263
+ ## Development
264
+
265
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
266
+
267
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
268
+
269
+ ## Contributing
270
+
271
+ Bug reports and pull requests are welcome on GitHub at https://github.com/victorperez/spacex-api-ruby. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/victorperez/spacex-api-ruby/blob/master/CODE_OF_CONDUCT.md).
272
+
273
+
274
+ ## License
275
+
276
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
277
+
278
+ ## Code of Conduct
279
+
280
+ Everyone interacting in the SpacexApi project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/victorperez/spacex-api-ruby/blob/master/CODE_OF_CONDUCT.md).
data/Rakefile ADDED
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "bundler/gem_tasks"
4
+ require "rake/testtask"
5
+
6
+ Rake::TestTask.new(:test) do |t|
7
+ t.libs << "test"
8
+ t.libs << "lib"
9
+ t.test_files = FileList["test/**/*_test.rb"]
10
+ end
11
+
12
+ task default: :test
data/bin/console ADDED
@@ -0,0 +1,15 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require "bundler/setup"
5
+ require "spacex_api"
6
+
7
+ # You can add fixtures and/or initialization code here to make experimenting
8
+ # with your gem easier. You can also use a different console, if you like.
9
+
10
+ # (If you use this, don't forget to add pry to your Gemfile!)
11
+ # require "pry"
12
+ # Pry.start
13
+
14
+ require "irb"
15
+ IRB.start(__FILE__)
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
data/lib/spacex_api.rb ADDED
@@ -0,0 +1,24 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "faraday"
4
+ require "faraday_middleware"
5
+
6
+ require "spacex_api/base_uri"
7
+ require "spacex_api/client"
8
+ require "spacex_api/configuration"
9
+ require "spacex_api/request"
10
+ require "spacex_api/version"
11
+
12
+ module SpacexApi
13
+ def self.client
14
+ SpacexApi::Client.new
15
+ end
16
+
17
+ def self.configuration
18
+ @configuration ||= Configuration.new
19
+ end
20
+
21
+ def self.configure
22
+ yield(configuration)
23
+ end
24
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module SpacexApi
4
+ BASE_URI = "https://api.spacexdata.com"
5
+ end
@@ -0,0 +1,49 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "spacex_api/client/capsules"
4
+ require "spacex_api/client/company_info"
5
+ require "spacex_api/client/cores"
6
+ require "spacex_api/client/crews"
7
+ require "spacex_api/client/dragons"
8
+ require "spacex_api/client/history"
9
+ require "spacex_api/client/landpads"
10
+ require "spacex_api/client/launches"
11
+ require "spacex_api/client/launchpads"
12
+ require "spacex_api/client/payloads"
13
+ require "spacex_api/client/roadster_info"
14
+ require "spacex_api/client/rockets"
15
+ require "spacex_api/client/ships"
16
+ require "spacex_api/client/starlink"
17
+
18
+ module SpacexApi
19
+ class Client
20
+ include SpacexApi::Client::Capsules
21
+ include SpacexApi::Client::CompanyInfo
22
+ include SpacexApi::Client::Cores
23
+ include SpacexApi::Client::Crews
24
+ include SpacexApi::Client::Dragons
25
+ include SpacexApi::Client::History
26
+ include SpacexApi::Client::Landpads
27
+ include SpacexApi::Client::Launches
28
+ include SpacexApi::Client::Launchpads
29
+ include SpacexApi::Client::Payloads
30
+ include SpacexApi::Client::RoadsterInfo
31
+ include SpacexApi::Client::Rockets
32
+ include SpacexApi::Client::Ships
33
+ include SpacexApi::Client::Starlink
34
+
35
+ def get(path)
36
+ request(:get, path)
37
+ end
38
+
39
+ def post(path, body = nil)
40
+ request(:post, path, body)
41
+ end
42
+
43
+ private
44
+
45
+ def request(method, path, body = nil)
46
+ Request.call(method, path, body)
47
+ end
48
+ end
49
+ end
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ module SpacexApi
4
+ class Client
5
+ module Capsules
6
+ def capsules
7
+ get("capsules")
8
+ end
9
+
10
+ def get_capsule(id)
11
+ get("capsules/#{id}")
12
+ end
13
+
14
+ def query_capsules(body = nil)
15
+ post("capsules/query", body)
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ module SpacexApi
4
+ class Client
5
+ module CompanyInfo
6
+ def company_info
7
+ get("company")
8
+ end
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ module SpacexApi
4
+ class Client
5
+ module Cores
6
+ def cores
7
+ get("cores")
8
+ end
9
+
10
+ def get_core(id)
11
+ get("cores/#{id}")
12
+ end
13
+
14
+ def query_cores(body = nil)
15
+ post("cores/query", body)
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ module SpacexApi
4
+ class Client
5
+ module Crews
6
+ def crews
7
+ get("crew")
8
+ end
9
+
10
+ def get_crew(id)
11
+ get("crew/#{id}")
12
+ end
13
+
14
+ def query_crews(body = nil)
15
+ post("crew/query", body)
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ module SpacexApi
4
+ class Client
5
+ module Dragons
6
+ def dragons
7
+ get("dragons")
8
+ end
9
+
10
+ def get_dragon(id)
11
+ get("dragons/#{id}")
12
+ end
13
+
14
+ def query_dragons(body = nil)
15
+ post("dragons/query", body)
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ module SpacexApi
4
+ class Client
5
+ module History
6
+ def historical_events
7
+ get("history")
8
+ end
9
+
10
+ def get_historical_event(id)
11
+ get("history/#{id}")
12
+ end
13
+
14
+ def query_historical_events(body = nil)
15
+ post("history/query", body)
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ module SpacexApi
4
+ class Client
5
+ module Landpads
6
+ def landpads
7
+ get("landpads")
8
+ end
9
+
10
+ def get_landpad(id)
11
+ get("landpads/#{id}")
12
+ end
13
+
14
+ def query_landpads(body = nil)
15
+ post("landpads/query", body)
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,35 @@
1
+ # frozen_string_literal: true
2
+
3
+ module SpacexApi
4
+ class Client
5
+ module Launches
6
+ def past_launches
7
+ get("launches/past")
8
+ end
9
+
10
+ def upcoming_launches
11
+ get("launches/upcoming")
12
+ end
13
+
14
+ def latest_launch
15
+ get("launches/latest")
16
+ end
17
+
18
+ def next_launch
19
+ get("launches/next")
20
+ end
21
+
22
+ def launches
23
+ get("launches")
24
+ end
25
+
26
+ def get_launch(id)
27
+ get("launches/#{id}")
28
+ end
29
+
30
+ def query_launches(body = nil)
31
+ post("launches/query", body)
32
+ end
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ module SpacexApi
4
+ class Client
5
+ module Launchpads
6
+ def launchpads
7
+ get("launchpads")
8
+ end
9
+
10
+ def get_launchpad(id)
11
+ get("launchpads/#{id}")
12
+ end
13
+
14
+ def query_launchpads(body = nil)
15
+ post("launchpads/query", body)
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ module SpacexApi
4
+ class Client
5
+ module Payloads
6
+ def payloads
7
+ get("payloads")
8
+ end
9
+
10
+ def get_payload(id)
11
+ get("payloads/#{id}")
12
+ end
13
+
14
+ def query_payloads(body = nil)
15
+ post("payloads/query", body)
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ module SpacexApi
4
+ class Client
5
+ module RoadsterInfo
6
+ def roadster
7
+ get("roadster")
8
+ end
9
+
10
+ def query_roadster(body = nil)
11
+ post("roadster/query", body)
12
+ end
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ module SpacexApi
4
+ class Client
5
+ module Rockets
6
+ def rockets
7
+ get("rockets")
8
+ end
9
+
10
+ def get_rocket(id)
11
+ get("rockets/#{id}")
12
+ end
13
+
14
+ def query_rockets(body = nil)
15
+ post("rockets/query", body)
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ module SpacexApi
4
+ class Client
5
+ module Ships
6
+ def ships
7
+ get("ships")
8
+ end
9
+
10
+ def get_ship(id)
11
+ get("ships/#{id}")
12
+ end
13
+
14
+ def query_ships(body = nil)
15
+ post("ships/query", body)
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ module SpacexApi
4
+ class Client
5
+ module Starlink
6
+ def starlinks
7
+ get("starlink")
8
+ end
9
+
10
+ def get_starlink(id)
11
+ get("starlink/#{id}")
12
+ end
13
+
14
+ def query_starlinks(body = nil)
15
+ post("starlink/query", body)
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ module SpacexApi
4
+ class Configuration
5
+ attr_accessor :logger, :version
6
+
7
+ def initialize
8
+ @logger = false
9
+ @version = "v4"
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,37 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "ostruct"
4
+
5
+ module SpacexApi
6
+ class Request
7
+ class << self
8
+ def call(method, path, body = nil)
9
+ case method
10
+ when :get
11
+ connection.get(path).body
12
+ when :post
13
+ connection.post do |request|
14
+ request.path = path
15
+ request.body = body if body
16
+ end.body
17
+ end
18
+ end
19
+
20
+ private
21
+
22
+ def connection
23
+ Faraday.new(
24
+ url: "#{SpacexApi::BASE_URI}/#{SpacexApi.configuration.version}",
25
+ headers: { "Content-Type" => "application/json" }
26
+ ) do |connection|
27
+ connection.adapter Faraday.default_adapter
28
+
29
+ connection.response :logger if SpacexApi.configuration.logger
30
+ connection.response :json, content_type: /\bjson$/, parser_options: { object_class: OpenStruct }
31
+
32
+ connection.use Faraday::Response::RaiseError
33
+ end
34
+ end
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module SpacexApi
4
+ VERSION = "1.0.0"
5
+ end
@@ -0,0 +1,37 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "lib/spacex_api/version"
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = "spacex_api"
7
+ spec.version = SpacexApi::VERSION
8
+ spec.authors = ["Victor Perez Rodriguez"]
9
+ spec.email = ["victor.mx14@gmail.com"]
10
+
11
+ spec.summary = "Spacex API Ruby wrapper"
12
+ spec.description = "Ruby API wrapper to consume the SpaceX API"
13
+ spec.homepage = "https://github.com/victorperez/spacex-api-ruby"
14
+ spec.license = "MIT"
15
+ spec.required_ruby_version = Gem::Requirement.new(">= 2.3.0")
16
+
17
+ spec.metadata["homepage_uri"] = spec.homepage
18
+ spec.metadata["source_code_uri"] = spec.homepage
19
+ spec.metadata["changelog_uri"] = "https://github.com/victorperez/spacex-api-ruby/blob/main/CHANGELOG.md"
20
+
21
+ # Specify which files should be added to the gem when it is released.
22
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
23
+ spec.files = Dir.chdir(File.expand_path(__dir__)) do
24
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
25
+ end
26
+ spec.bindir = "exe"
27
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
28
+ spec.require_paths = ["lib"]
29
+
30
+ spec.add_dependency "faraday", "~> 1.0"
31
+ spec.add_dependency "faraday_middleware", "~> 1.0"
32
+
33
+ spec.add_development_dependency "coveralls", "~> 0.8"
34
+ spec.add_development_dependency "rubocop", "1.12"
35
+ spec.add_development_dependency "vcr", "~> 6.0"
36
+ spec.add_development_dependency "webmock", "~> 3.12"
37
+ end
metadata ADDED
@@ -0,0 +1,164 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: spacex_api
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Victor Perez Rodriguez
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2021-04-24 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: faraday
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: faraday_middleware
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: coveralls
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '0.8'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '0.8'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rubocop
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - '='
60
+ - !ruby/object:Gem::Version
61
+ version: '1.12'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - '='
67
+ - !ruby/object:Gem::Version
68
+ version: '1.12'
69
+ - !ruby/object:Gem::Dependency
70
+ name: vcr
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '6.0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '6.0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: webmock
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '3.12'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '3.12'
97
+ description: Ruby API wrapper to consume the SpaceX API
98
+ email:
99
+ - victor.mx14@gmail.com
100
+ executables: []
101
+ extensions: []
102
+ extra_rdoc_files: []
103
+ files:
104
+ - ".github/workflows/verify.yml"
105
+ - ".gitignore"
106
+ - ".rubocop.yml"
107
+ - ".rubocop_todo.yml"
108
+ - CHANGELOG.md
109
+ - CODE_OF_CONDUCT.md
110
+ - Gemfile
111
+ - Gemfile.lock
112
+ - LICENSE.txt
113
+ - README.md
114
+ - Rakefile
115
+ - bin/console
116
+ - bin/setup
117
+ - lib/spacex_api.rb
118
+ - lib/spacex_api/base_uri.rb
119
+ - lib/spacex_api/client.rb
120
+ - lib/spacex_api/client/capsules.rb
121
+ - lib/spacex_api/client/company_info.rb
122
+ - lib/spacex_api/client/cores.rb
123
+ - lib/spacex_api/client/crews.rb
124
+ - lib/spacex_api/client/dragons.rb
125
+ - lib/spacex_api/client/history.rb
126
+ - lib/spacex_api/client/landpads.rb
127
+ - lib/spacex_api/client/launches.rb
128
+ - lib/spacex_api/client/launchpads.rb
129
+ - lib/spacex_api/client/payloads.rb
130
+ - lib/spacex_api/client/roadster_info.rb
131
+ - lib/spacex_api/client/rockets.rb
132
+ - lib/spacex_api/client/ships.rb
133
+ - lib/spacex_api/client/starlink.rb
134
+ - lib/spacex_api/configuration.rb
135
+ - lib/spacex_api/request.rb
136
+ - lib/spacex_api/version.rb
137
+ - spacex_api.gemspec
138
+ homepage: https://github.com/victorperez/spacex-api-ruby
139
+ licenses:
140
+ - MIT
141
+ metadata:
142
+ homepage_uri: https://github.com/victorperez/spacex-api-ruby
143
+ source_code_uri: https://github.com/victorperez/spacex-api-ruby
144
+ changelog_uri: https://github.com/victorperez/spacex-api-ruby/blob/main/CHANGELOG.md
145
+ post_install_message:
146
+ rdoc_options: []
147
+ require_paths:
148
+ - lib
149
+ required_ruby_version: !ruby/object:Gem::Requirement
150
+ requirements:
151
+ - - ">="
152
+ - !ruby/object:Gem::Version
153
+ version: 2.3.0
154
+ required_rubygems_version: !ruby/object:Gem::Requirement
155
+ requirements:
156
+ - - ">="
157
+ - !ruby/object:Gem::Version
158
+ version: '0'
159
+ requirements: []
160
+ rubygems_version: 3.1.2
161
+ signing_key:
162
+ specification_version: 4
163
+ summary: Spacex API Ruby wrapper
164
+ test_files: []