swapi_dev 0.1.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: '009142a54f57b5635f5dfdd7c4b91a78929c64826e4db1ce7feb7821a6f8447d'
4
+ data.tar.gz: c9394eb3c74fe0a50c66159fd29c35c829532df41d087330b9da169f4432e84f
5
+ SHA512:
6
+ metadata.gz: a223909ee91cc5d85f42db39d0188a1bdb0624e518a7070d0ed125a88453ed265f09ae5af680d263f6f5f6da9dde66100039700bb64c83931a994ed5b912588a
7
+ data.tar.gz: dd33feb0faf9e65be53a0c3200ff4db27ceea15e21c8e349c299432faf9a9dc46664db898b63fef933220494a67f2efeef7d1234089e83040cfb426fa0818b65
data/.gitignore ADDED
@@ -0,0 +1,8 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
data/CHANGELOG.md ADDED
@@ -0,0 +1,5 @@
1
+ ## [Unreleased]
2
+
3
+ ## [0.1.0] - 2021-12-29
4
+
5
+ - Initial release
@@ -0,0 +1,84 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ We as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone, regardless of age, body size, visible or invisible disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, religion, or sexual identity and orientation.
6
+
7
+ We pledge to act and interact in ways that contribute to an open, welcoming, diverse, inclusive, and healthy community.
8
+
9
+ ## Our Standards
10
+
11
+ Examples of behavior that contributes to a positive environment for our community include:
12
+
13
+ * Demonstrating empathy and kindness toward other people
14
+ * Being respectful of differing opinions, viewpoints, and experiences
15
+ * Giving and gracefully accepting constructive feedback
16
+ * Accepting responsibility and apologizing to those affected by our mistakes, and learning from the experience
17
+ * Focusing on what is best not just for us as individuals, but for the overall community
18
+
19
+ Examples of unacceptable behavior include:
20
+
21
+ * The use of sexualized language or imagery, and sexual attention or
22
+ advances of any kind
23
+ * Trolling, insulting or derogatory comments, and personal or political attacks
24
+ * Public or private harassment
25
+ * Publishing others' private information, such as a physical or email
26
+ address, without their explicit permission
27
+ * Other conduct which could reasonably be considered inappropriate in a
28
+ professional setting
29
+
30
+ ## Enforcement Responsibilities
31
+
32
+ Community leaders are responsible for clarifying and enforcing our standards of acceptable behavior and will take appropriate and fair corrective action in response to any behavior that they deem inappropriate, threatening, offensive, or harmful.
33
+
34
+ Community leaders have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, and will communicate reasons for moderation decisions when appropriate.
35
+
36
+ ## Scope
37
+
38
+ This Code of Conduct applies within all community spaces, and also applies when an individual is officially representing the community in public spaces. Examples of representing our community include using an official e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event.
39
+
40
+ ## Enforcement
41
+
42
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the community leaders responsible for enforcement at jramos@arkusnexus.com. All complaints will be reviewed and investigated promptly and fairly.
43
+
44
+ All community leaders are obligated to respect the privacy and security of the reporter of any incident.
45
+
46
+ ## Enforcement Guidelines
47
+
48
+ Community leaders will follow these Community Impact Guidelines in determining the consequences for any action they deem in violation of this Code of Conduct:
49
+
50
+ ### 1. Correction
51
+
52
+ **Community Impact**: Use of inappropriate language or other behavior deemed unprofessional or unwelcome in the community.
53
+
54
+ **Consequence**: A private, written warning from community leaders, providing clarity around the nature of the violation and an explanation of why the behavior was inappropriate. A public apology may be requested.
55
+
56
+ ### 2. Warning
57
+
58
+ **Community Impact**: A violation through a single incident or series of actions.
59
+
60
+ **Consequence**: A warning with consequences for continued behavior. No interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, for a specified period of time. This includes avoiding interactions in community spaces as well as external channels like social media. Violating these terms may lead to a temporary or permanent ban.
61
+
62
+ ### 3. Temporary Ban
63
+
64
+ **Community Impact**: A serious violation of community standards, including sustained inappropriate behavior.
65
+
66
+ **Consequence**: A temporary ban from any sort of interaction or public communication with the community for a specified period of time. No public or private interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, is allowed during this period. Violating these terms may lead to a permanent ban.
67
+
68
+ ### 4. Permanent Ban
69
+
70
+ **Community Impact**: Demonstrating a pattern of violation of community standards, including sustained inappropriate behavior, harassment of an individual, or aggression toward or disparagement of classes of individuals.
71
+
72
+ **Consequence**: A permanent ban from any sort of public interaction within the community.
73
+
74
+ ## Attribution
75
+
76
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 2.0,
77
+ available at https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
78
+
79
+ Community Impact Guidelines were inspired by [Mozilla's code of conduct enforcement ladder](https://github.com/mozilla/diversity).
80
+
81
+ [homepage]: https://www.contributor-covenant.org
82
+
83
+ For answers to common questions about this code of conduct, see the FAQ at
84
+ https://www.contributor-covenant.org/faq. Translations are available at https://www.contributor-covenant.org/translations.
data/Gemfile ADDED
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: true
2
+
3
+ source "https://rubygems.org"
4
+
5
+ # Specify your gem's dependencies in swapi_dev.gemspec
6
+ gemspec
7
+
8
+ gem "minitest", "~> 5.0"
9
+ gem "rake", "~> 13.0"
10
+ gem "standardrb", "~> 1.0"
11
+
12
+ group :test do
13
+ gem "webmock"
14
+ end
data/Gemfile.lock ADDED
@@ -0,0 +1,61 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ swapi_dev (0.1.0)
5
+
6
+ GEM
7
+ remote: https://rubygems.org/
8
+ specs:
9
+ addressable (2.8.0)
10
+ public_suffix (>= 2.0.2, < 5.0)
11
+ ast (2.4.2)
12
+ crack (0.4.5)
13
+ rexml
14
+ hashdiff (1.0.1)
15
+ minitest (5.15.0)
16
+ parallel (1.21.0)
17
+ parser (3.0.3.2)
18
+ ast (~> 2.4.1)
19
+ public_suffix (4.0.6)
20
+ rainbow (3.0.0)
21
+ rake (13.0.6)
22
+ regexp_parser (2.2.0)
23
+ rexml (3.2.5)
24
+ rubocop (1.23.0)
25
+ parallel (~> 1.10)
26
+ parser (>= 3.0.0.0)
27
+ rainbow (>= 2.2.2, < 4.0)
28
+ regexp_parser (>= 1.8, < 3.0)
29
+ rexml
30
+ rubocop-ast (>= 1.12.0, < 2.0)
31
+ ruby-progressbar (~> 1.7)
32
+ unicode-display_width (>= 1.4.0, < 3.0)
33
+ rubocop-ast (1.15.0)
34
+ parser (>= 3.0.1.1)
35
+ rubocop-performance (1.12.0)
36
+ rubocop (>= 1.7.0, < 2.0)
37
+ rubocop-ast (>= 0.4.0)
38
+ ruby-progressbar (1.11.0)
39
+ standard (1.5.0)
40
+ rubocop (= 1.23.0)
41
+ rubocop-performance (= 1.12.0)
42
+ standardrb (1.0.0)
43
+ standard
44
+ unicode-display_width (2.1.0)
45
+ webmock (3.14.0)
46
+ addressable (>= 2.8.0)
47
+ crack (>= 0.3.2)
48
+ hashdiff (>= 0.4.0, < 2.0.0)
49
+
50
+ PLATFORMS
51
+ x86_64-darwin-21
52
+
53
+ DEPENDENCIES
54
+ minitest (~> 5.0)
55
+ rake (~> 13.0)
56
+ standardrb (~> 1.0)
57
+ swapi_dev!
58
+ webmock
59
+
60
+ BUNDLED WITH
61
+ 2.2.15
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2021 Eduardo Lopez
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,95 @@
1
+ # SwapiDev
2
+
3
+ A Ruby wrapper for the Star Wars API
4
+
5
+
6
+ # Api documentation
7
+ here is the documentation of [The Star War API](https://swapi.dev/)
8
+ # Installation
9
+
10
+ Add this line to your application's Gemfile:
11
+
12
+ ```ruby
13
+ gem 'swapi_dev'
14
+ ```
15
+
16
+ And then execute:
17
+
18
+ $ bundle install
19
+
20
+ Or install it yourself as:
21
+
22
+ $ gem install swapi_dev
23
+
24
+ # Usage
25
+
26
+ First you need to require the gem
27
+
28
+ ```ruby
29
+ require "swapi_dev"
30
+ ```
31
+
32
+ ## Methods
33
+
34
+ There is 6 diferents statistics to request
35
+ ### People
36
+
37
+ ```ruby
38
+ SwapiDev.people_all
39
+ SwapiDev.people_id(id)
40
+ SwapiDev.people_name(name)
41
+ ```
42
+
43
+ ### Films
44
+
45
+ ```ruby
46
+ SwapiDev.film_all
47
+ SwapiDev.film_id(id)
48
+ SwapiDev.film_title(title)
49
+ ```
50
+
51
+ ### Planets
52
+
53
+ ```ruby
54
+ SwapiDev.planet_all
55
+ SwapiDev.planet_id(id)
56
+ SwapiDev.planet_name(name)
57
+ ```
58
+
59
+ ### Species
60
+
61
+ ```ruby
62
+ SwapiDev.specie_all
63
+ SwapiDev.specie_id(id)
64
+ SwapiDev.specie_name(name)
65
+ ```
66
+
67
+ ### Starships
68
+
69
+ ```ruby
70
+ SwapiDev.starship_all
71
+ SwapiDev.starship_id(id)
72
+ SwapiDev.starship_name(name)
73
+ SwapiDev.starship_model(model)
74
+ ```
75
+
76
+ ### Vehicles
77
+
78
+ ```ruby
79
+ SwapiDev.vehicle_all
80
+ SwapiDev.vehicle_id(id)
81
+ SwapiDev.vehicle_name(name)
82
+ SwapiDev.vehicle_model(model)
83
+ ```
84
+
85
+ ## Contributing
86
+
87
+ Bug reports and pull requests are welcome on GitHub at https://github.com/Eduardo-Lpz/swapi_dev. 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/[USERNAME]/swapi_dev/blob/master/CODE_OF_CONDUCT.md).
88
+
89
+ ## License
90
+
91
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
92
+
93
+ ## Code of Conduct
94
+
95
+ Everyone interacting in the SwapiDev project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/swapi_dev/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 "swapi_dev"
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
@@ -0,0 +1,23 @@
1
+ # frozen_string_literal: true
2
+
3
+ module SwapiDev
4
+ class AsyncStream
5
+ def initialize(enumerable)
6
+ @enumerable = enumerable
7
+ end
8
+
9
+ def map
10
+ enumerable.map do |item|
11
+ Thread.new { yield(item) }
12
+ end.map(&:value)
13
+ end
14
+
15
+ def sum(&block)
16
+ map(&block).inject(:+)
17
+ end
18
+
19
+ private
20
+
21
+ attr_reader :enumerable
22
+ end
23
+ end
@@ -0,0 +1,41 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "net/http"
4
+
5
+ module SwapiDev
6
+ class Client
7
+ def initialize(base_url)
8
+ @uri_builder = UriBuilder.new(base_url)
9
+ end
10
+
11
+ def get(resource, **args)
12
+ request(resource, **args) { |uri| Net::HTTP::Get.new(uri) }
13
+ end
14
+
15
+ def post(resource, **args)
16
+ request(resource, **args) { |uri| Net::HTTP::Post.new(uri) }
17
+ end
18
+
19
+ def put(resource, **args)
20
+ request(resource, **args) { |uri| Net::HTTP::Put.new(uri) }
21
+ end
22
+
23
+ def delete(resource, **args)
24
+ request(resource, **args) { |uri| Net::HTTP::Delete.new(uri) }
25
+ end
26
+
27
+ private
28
+
29
+ attr_reader :uri_builder
30
+
31
+ def request(resource, **args)
32
+ uri = uri_builder.build(resource, **args)
33
+ http_response = Net::HTTP.start(uri.host, uri.port, use_ssl: true) do |http|
34
+ request = yield(uri)
35
+ request["Content-Type"] = "application/json" if request.instance_of?(Net::HTTP::Put) || request.instance_of?(Net::HTTP::Post)
36
+ http.request(request)
37
+ end
38
+ Response.handle(http_response, **args)
39
+ end
40
+ end
41
+ end
@@ -0,0 +1,52 @@
1
+ # frozen_string_literal: true
2
+
3
+ module SwapiDev
4
+ class Endpoint
5
+ def initialize
6
+ @client = Client.new("https://swapi.dev/api/")
7
+ end
8
+
9
+ def all
10
+ response = client.get(resource)
11
+ return response if response[:next].nil?
12
+
13
+ range = (2..(response[:count] / 10.0).ceil)
14
+ response[:results] + AsyncStream.new(range).sum { |page| list(page) }
15
+ end
16
+
17
+ def list(page = nil)
18
+ client.get(resource, page: page)[:results]
19
+ end
20
+
21
+ def find(id)
22
+ client.get("#{resource}/#{id}")
23
+ end
24
+
25
+ def search(field)
26
+ client.get(resource, search: field.to_s)
27
+ end
28
+
29
+ def update(**data)
30
+ client.put(resource, **data)
31
+ end
32
+
33
+ def create(**data)
34
+ client.post(resource, **data)
35
+ end
36
+
37
+ def delete(**data)
38
+ client.delete(resource, **data)
39
+ end
40
+
41
+ private
42
+
43
+ attr_reader :client
44
+
45
+ def resource
46
+ @resource ||= self.class.name.split("::").last.downcase
47
+ @resource << "s" unless @resource == "people"
48
+
49
+ @resource
50
+ end
51
+ end
52
+ end
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ module SwapiDev
4
+ class Response
5
+ def self.handle(http_response, **args)
6
+ serializer = args[:format] == "wookiee" ? WookieeSerializer : JsonSerializer
7
+
8
+ case http_response
9
+ when Net::HTTPSuccess
10
+ serializer.call(http_response.body)
11
+ when Net::HTTPOK
12
+ serializer.call(http_response.body)
13
+ else
14
+ ErrorSerializer.call(http_response)
15
+ end
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+
3
+ module SwapiDev
4
+ class UriBuilder
5
+ def initialize(base_url)
6
+ @base_url = base_url
7
+ end
8
+
9
+ def build(resource, **options)
10
+ uri = URI.join(@base_url, resource)
11
+ uri.query = URI.encode_www_form(options.slice(:format, :search, :page))
12
+ yield if block_given?
13
+ uri
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,6 @@
1
+ # frozen_string_literal: true
2
+
3
+ module SwapiDev
4
+ class Film < Endpoint
5
+ end
6
+ end
@@ -0,0 +1,6 @@
1
+ # frozen_string_literal: true
2
+
3
+ module SwapiDev
4
+ class People < Endpoint
5
+ end
6
+ end
@@ -0,0 +1,6 @@
1
+ # frozen_string_literal: true
2
+
3
+ module SwapiDev
4
+ class Planet < Endpoint
5
+ end
6
+ end
@@ -0,0 +1,6 @@
1
+ # frozen_string_literal: true
2
+
3
+ module SwapiDev
4
+ class Specie < Endpoint
5
+ end
6
+ end
@@ -0,0 +1,6 @@
1
+ # frozen_string_literal: true
2
+
3
+ module SwapiDev
4
+ class Starship < Endpoint
5
+ end
6
+ end
@@ -0,0 +1,6 @@
1
+ # frozen_string_literal: true
2
+
3
+ module SwapiDev
4
+ class Vehicle < Endpoint
5
+ end
6
+ end
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ module SwapiDev
4
+ class BaseSerializer
5
+ def self.call(_content)
6
+ raise NoMethodError
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "json"
4
+
5
+ module SwapiDev
6
+ class ErrorSerializer < BaseSerializer
7
+ def self.call(content)
8
+ JSON.parse(content.body, symbolize_names: true).merge(
9
+ {
10
+ message: content.message,
11
+ code: content.code
12
+ }
13
+ )
14
+ rescue
15
+ nil
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "json"
4
+
5
+ module SwapiDev
6
+ class JsonSerializer < BaseSerializer
7
+ def self.call(content)
8
+ JSON.parse(content, symbolize_names: true)
9
+ rescue JSON::ParserError
10
+ nil
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "json"
4
+
5
+ module SwapiDev
6
+ class WookieeSerializer < BaseSerializer
7
+ def self.call(content)
8
+ # this encoding is identical to JSON except with wookiee translations.
9
+ # for some reason json does not work
10
+ # TODO Wookie transalation
11
+ JSON.parse(content, symbolize_names: true)
12
+ rescue JSON::ParserError
13
+ nil
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module SwapiDev
4
+ VERSION = "0.1.0"
5
+ end
data/lib/swapi_dev.rb ADDED
@@ -0,0 +1,105 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "swapi_dev/version"
4
+
5
+ require_relative "swapi_dev/client/client"
6
+ require_relative "swapi_dev/client/uri_builder"
7
+ require_relative "swapi_dev/client/endpoint"
8
+ require_relative "swapi_dev/client/response"
9
+ require_relative "swapi_dev/client/async_stream"
10
+
11
+ require_relative "swapi_dev/serializers/base_serializer"
12
+ require_relative "swapi_dev/serializers/error_serializer"
13
+ require_relative "swapi_dev/serializers/json_serializer"
14
+ require_relative "swapi_dev/serializers/wookiee_serializer"
15
+
16
+ require_relative "swapi_dev/resources/people"
17
+ require_relative "swapi_dev/resources/starship"
18
+ require_relative "swapi_dev/resources/film"
19
+ require_relative "swapi_dev/resources/planet"
20
+ require_relative "swapi_dev/resources/vehicle"
21
+ require_relative "swapi_dev/resources/specie"
22
+
23
+ module SwapiDev
24
+ class Error < StandardError; end
25
+
26
+ def self.people_all
27
+ People.new.all
28
+ end
29
+
30
+ def self.people_id(id)
31
+ People.new.find(id)
32
+ end
33
+
34
+ def self.people_name(name)
35
+ People.new.search(name)
36
+ end
37
+
38
+ def self.film_all
39
+ Film.new.all
40
+ end
41
+
42
+ def self.film_id(id)
43
+ Film.new.find(id)
44
+ end
45
+
46
+ def self.film_title(name)
47
+ Film.new.search(name)
48
+ end
49
+
50
+ def self.planet_all
51
+ Planet.new.all
52
+ end
53
+
54
+ def self.planet_id(id)
55
+ Planet.new.find(id)
56
+ end
57
+
58
+ def self.planet_name(name)
59
+ Planet.new.search(name)
60
+ end
61
+
62
+ def self.specie_all
63
+ Specie.new.all
64
+ end
65
+
66
+ def self.specie_id(id)
67
+ Specie.new.find(id)
68
+ end
69
+
70
+ def self.specie_name(name)
71
+ Specie.new.search(name)
72
+ end
73
+
74
+ def self.starship_all
75
+ Starship.new.all
76
+ end
77
+
78
+ def self.starship_id(id)
79
+ Starship.new.find(id)
80
+ end
81
+
82
+ def self.starship_name(name)
83
+ Starship.new.search(name)
84
+ end
85
+
86
+ def self.starship_model(model)
87
+ Starship.new.search(model)
88
+ end
89
+
90
+ def self.vehicle_all
91
+ Vehicle.new.all
92
+ end
93
+
94
+ def self.vehicle_id(id)
95
+ Vehicle.new.find(id)
96
+ end
97
+
98
+ def self.vehicle_name(name)
99
+ Vehicle.new.search(name)
100
+ end
101
+
102
+ def self.vehicle_model(model)
103
+ Vehicle.new.search(model)
104
+ end
105
+ end
data/swapi_dev.gemspec ADDED
@@ -0,0 +1,40 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "lib/swapi_dev/version"
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = "swapi_dev"
7
+ spec.version = SwapiDev::VERSION
8
+ spec.authors = ["Eduardo Lopez"]
9
+ spec.email = ["jramos@arkusnexus.com"]
10
+
11
+ spec.summary = "SWAPI Wrapper"
12
+ spec.description = "Ruby wrapper for The Star Wars API"
13
+ spec.homepage = "https://github.com/Eduardo-Lpz/swapi_dev"
14
+ spec.license = "MIT"
15
+ spec.required_ruby_version = Gem::Requirement.new(">= 2.6.0")
16
+
17
+ # spec.metadata["allowed_push_host"] = "TODO: Set to 'http://mygemserver.com'"
18
+
19
+ spec.metadata["homepage_uri"] = spec.homepage
20
+ spec.metadata["source_code_uri"] = "https://github.com/Eduardo-Lpz/swapi_dev"
21
+ # spec.metadata["changelog_uri"] = "TODO: Put your gem's CHANGELOG.md URL here."
22
+
23
+ # Specify which files should be added to the gem when it is released.
24
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
25
+ spec.files = Dir.chdir(File.expand_path(__dir__)) do
26
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{\A(?:test|spec|features)/}) }
27
+ end
28
+ spec.bindir = "exe"
29
+ spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
30
+ spec.require_paths = ["lib"]
31
+
32
+ # Uncomment to register a new dependency of your gem
33
+ # spec.add_dependency "example-gem", "~> 1.0"
34
+
35
+ # For more information and examples about making a new gem, checkout our
36
+ # guide at: https://bundler.io/guides/creating_gem.html
37
+ spec.metadata = {
38
+ "rubygems_mfa_required" => "true"
39
+ }
40
+ end
metadata ADDED
@@ -0,0 +1,72 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: swapi_dev
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Eduardo Lopez
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2021-12-30 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: Ruby wrapper for The Star Wars API
14
+ email:
15
+ - jramos@arkusnexus.com
16
+ executables: []
17
+ extensions: []
18
+ extra_rdoc_files: []
19
+ files:
20
+ - ".gitignore"
21
+ - CHANGELOG.md
22
+ - CODE_OF_CONDUCT.md
23
+ - Gemfile
24
+ - Gemfile.lock
25
+ - LICENSE.txt
26
+ - README.md
27
+ - Rakefile
28
+ - bin/console
29
+ - bin/setup
30
+ - lib/swapi_dev.rb
31
+ - lib/swapi_dev/client/async_stream.rb
32
+ - lib/swapi_dev/client/client.rb
33
+ - lib/swapi_dev/client/endpoint.rb
34
+ - lib/swapi_dev/client/response.rb
35
+ - lib/swapi_dev/client/uri_builder.rb
36
+ - lib/swapi_dev/resources/film.rb
37
+ - lib/swapi_dev/resources/people.rb
38
+ - lib/swapi_dev/resources/planet.rb
39
+ - lib/swapi_dev/resources/specie.rb
40
+ - lib/swapi_dev/resources/starship.rb
41
+ - lib/swapi_dev/resources/vehicle.rb
42
+ - lib/swapi_dev/serializers/base_serializer.rb
43
+ - lib/swapi_dev/serializers/error_serializer.rb
44
+ - lib/swapi_dev/serializers/json_serializer.rb
45
+ - lib/swapi_dev/serializers/wookiee_serializer.rb
46
+ - lib/swapi_dev/version.rb
47
+ - swapi_dev.gemspec
48
+ homepage: https://github.com/Eduardo-Lpz/swapi_dev
49
+ licenses:
50
+ - MIT
51
+ metadata:
52
+ rubygems_mfa_required: 'true'
53
+ post_install_message:
54
+ rdoc_options: []
55
+ require_paths:
56
+ - lib
57
+ required_ruby_version: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: 2.6.0
62
+ required_rubygems_version: !ruby/object:Gem::Requirement
63
+ requirements:
64
+ - - ">="
65
+ - !ruby/object:Gem::Version
66
+ version: '0'
67
+ requirements: []
68
+ rubygems_version: 3.2.15
69
+ signing_key:
70
+ specification_version: 4
71
+ summary: SWAPI Wrapper
72
+ test_files: []