esirb 0.2.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: 94353029d857afc9d90b2c82d0f7d0c4f4f0aa907ffbd0f48f94024a88cb8c9b
4
+ data.tar.gz: e73055498ed2e2d6dfcb0c97208b6b4beb8ea2907717b6c405ac357801eed36b
5
+ SHA512:
6
+ metadata.gz: 647a5145b585538150d6cfde39f082292e51989a471757da4092fae87fc59dfe5aff3827f0441cfa54ea9c3832c0a220ed3ac697822326529e0e357f30ab452a
7
+ data.tar.gz: 8811c42691a106c6c8ad888c61248724bf7706ee21def1c7039b0a1ec005df8aa02d1cb58bbc626cc647aef47754f6501b3e5edf6dfa60c8adddf667b8174fc7
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
data/.rubocop.yml ADDED
@@ -0,0 +1,8 @@
1
+ AllCops:
2
+ TargetRubyVersion: 3.1
3
+
4
+ Style/StringLiterals:
5
+ EnforcedStyle: double_quotes
6
+
7
+ Style/StringLiteralsInInterpolation:
8
+ EnforcedStyle: double_quotes
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ ruby-3.4.7
data/CHANGELOG.md ADDED
@@ -0,0 +1,5 @@
1
+ ## [Unreleased]
2
+
3
+ ## [0.1.0] - 2026-06-04
4
+
5
+ - Initial release
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2026 sicks
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,80 @@
1
+ # Esirb
2
+
3
+ Esirb is a light wrapper around Faraday for the purposes of interacting with Eve Online's Swagger API.
4
+
5
+ I wanted something low maintenance, so this gem makes a few assumptions to let you dynamically generate any path that might end up on the ESI.
6
+
7
+ ## Installation
8
+
9
+ Install the gem and add to the application's Gemfile by executing:
10
+
11
+ ```bash
12
+ bundle add esirb
13
+ ```
14
+
15
+ If bundler is not being used to manage dependencies, install the gem by executing:
16
+
17
+ ```bash
18
+ gem install esirb
19
+ ```
20
+
21
+ ## Usage
22
+
23
+
24
+ ### Create a client
25
+ ```ruby
26
+ client = Esirb::Client.new
27
+ ```
28
+ ##### Create a client with a token
29
+ ```ruby
30
+ client = Esirb::Client.new(token: "...")
31
+ ```
32
+
33
+ ### Build the path, with any path parameters
34
+
35
+ Treat ESI static paths as method names, and path parameters as the arguments for those methods. Chain these methods to build the path to the desired ESI endpoint.
36
+
37
+ ```ruby
38
+
39
+ path = client.route(3000142, 30002187)
40
+ path.string # => "/route/3000142/30002187"
41
+
42
+ path = client.ui.autopilot.waypoint
43
+ path.string # => "/ui/autopilot/waypoint"
44
+
45
+ path = client.characters(123456789).location
46
+ path.string # => "/characters/123456789/location"
47
+ ```
48
+
49
+ ### Make the request, with any query parameters or body
50
+
51
+ Call an http verb, optionally passing `params`, `body` or `headers`.
52
+
53
+ ```ruby
54
+ resp = path.get # => #<Faraday::Response>
55
+ resp.status # => 204
56
+ resp.body # => { "solar_system_id": 30000142 }
57
+
58
+ # check ESI documentation to know whether you need to pass query parameters, or a body
59
+ resp = path.post(params:, body:, headers:)
60
+ ```
61
+
62
+ ### All together now
63
+ ```ruby
64
+ client = Esirb::Client.new
65
+ list_of_alliance_ids = client.alliances.get.body # => [...]
66
+ ```
67
+
68
+ ## Development
69
+
70
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
71
+
72
+ 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 the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
73
+
74
+ ## Contributing
75
+
76
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/esirb.
77
+
78
+ ## License
79
+
80
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
data/Rakefile ADDED
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "bundler/gem_tasks"
4
+ require "rspec/core/rake_task"
5
+
6
+ RSpec::Core::RakeTask.new(:spec)
7
+
8
+ require "rubocop/rake_task"
9
+
10
+ RuboCop::RakeTask.new
11
+
12
+ task default: %i[spec rubocop]
@@ -0,0 +1,49 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "faraday"
4
+ require "faraday-http-cache"
5
+
6
+ module Esirb
7
+ class Client
8
+ BASE_URL = "https://esi.evetech.net"
9
+ DEFAULT_HEADERS = {
10
+ "Accept" => "application/json",
11
+ "Accept-Language" => "en",
12
+ "If-Modified-Since" => "",
13
+ "If-None-Match" => "",
14
+ "X-Tenant" => "tranquility",
15
+ "X-Compatibility-Date" => "2026-06-09"
16
+ }
17
+
18
+ attr_reader :token, :path, :tenant, :language, :cache, :cache_store
19
+
20
+ def initialize(token: nil, tenant: "tranquility", language: "en", cache: true, cache_store: nil)
21
+ @token = token
22
+ @tenant = tenant
23
+ @language = language
24
+ @cache = cache
25
+ @cache_store = cache_store
26
+ end
27
+
28
+ def connection
29
+ @connection ||= Faraday.new(BASE_URL) do |c|
30
+ c.request :authorization, "Bearer", token if token
31
+
32
+ if cache
33
+ c.use :http_cache,
34
+ store: cache_store,
35
+ strategy: Faraday::HttpCache::Strategies::ByUrl,
36
+ serializer: Marshal
37
+ end
38
+
39
+ c.request :json
40
+ c.headers = DEFAULT_HEADERS
41
+ c.response :json, content_type: "application/json"
42
+ end
43
+ end
44
+
45
+ def method_missing(m, *args, &block)
46
+ @path = Path.new(client: self).send(m.to_sym, *args)
47
+ end
48
+ end
49
+ end
data/lib/esirb/path.rb ADDED
@@ -0,0 +1,31 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Esirb
4
+ class Path
5
+ attr_reader :client, :string
6
+
7
+ def initialize(client: nil)
8
+ @client = client
9
+ @string = ""
10
+ end
11
+
12
+ %i[get head delete trace post put patch].each do |verb|
13
+ define_method verb do |**args|
14
+ client.connection.send(verb, @string) do |req|
15
+ req.params = args[:params] if args[:params]
16
+ req.body = args[:body] if args[:body]
17
+ req.headers = args[:headers] if args[:headers]
18
+ end
19
+ end
20
+ end
21
+
22
+ def method_missing(m, *args, &block)
23
+ @string += "/#{m}"
24
+ args.each do |arg|
25
+ @string += "/#{arg}"
26
+ end
27
+
28
+ self
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Esirb
4
+ VERSION = "0.2.0"
5
+ end
data/lib/esirb.rb ADDED
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "esirb/version"
4
+ require_relative "esirb/client"
5
+ require_relative "esirb/path"
6
+
7
+ module Esirb
8
+ class Error < StandardError; end
9
+ end
data/sig/esirb.rbs ADDED
@@ -0,0 +1,4 @@
1
+ module Esirb
2
+ VERSION: String
3
+ # See the writing guide of rbs: https://github.com/ruby/rbs#guides
4
+ end
metadata ADDED
@@ -0,0 +1,55 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: esirb
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.2.0
5
+ platform: ruby
6
+ authors:
7
+ - sicks
8
+ bindir: exe
9
+ cert_chain: []
10
+ date: 1980-01-02 00:00:00.000000000 Z
11
+ dependencies: []
12
+ email:
13
+ - esirb@sicks.dev
14
+ executables: []
15
+ extensions: []
16
+ extra_rdoc_files: []
17
+ files:
18
+ - ".rspec"
19
+ - ".rubocop.yml"
20
+ - ".ruby-version"
21
+ - CHANGELOG.md
22
+ - LICENSE.txt
23
+ - README.md
24
+ - Rakefile
25
+ - lib/esirb.rb
26
+ - lib/esirb/client.rb
27
+ - lib/esirb/path.rb
28
+ - lib/esirb/version.rb
29
+ - sig/esirb.rbs
30
+ homepage: https://github.com/sicks/esirb
31
+ licenses:
32
+ - MIT
33
+ metadata:
34
+ allowed_push_host: https://rubygems.org
35
+ homepage_uri: https://github.com/sicks/esirb
36
+ source_code_uri: https://github.com/sicks/esirb
37
+ changelog_uri: https://github.com/sicks/esirb/blob/main/CHANGELOG.md
38
+ rdoc_options: []
39
+ require_paths:
40
+ - lib
41
+ required_ruby_version: !ruby/object:Gem::Requirement
42
+ requirements:
43
+ - - ">="
44
+ - !ruby/object:Gem::Version
45
+ version: 3.1.0
46
+ required_rubygems_version: !ruby/object:Gem::Requirement
47
+ requirements:
48
+ - - ">="
49
+ - !ruby/object:Gem::Version
50
+ version: '0'
51
+ requirements: []
52
+ rubygems_version: 4.0.15
53
+ specification_version: 4
54
+ summary: Ruby interface for Eve Online's Swagger API
55
+ test_files: []