Sha256: 86bea15b50fe3ac1dd1e947e1fc3a3d519ca9d3343dca52b0a171e1f4a060e27

Contents?: true

Size: 559 Bytes

Versions: 10

Compression:

Stored size: 559 Bytes

Contents

# frozen_string_literal: true

require "core"

module Pennyworth
  module Loaders
    # Loads an array gems from the Standard Gems API.
    class StandardGem
      include Import[:settings, :http]

      def call endpoint
        http.get("#{settings.standard_gems_api_url}/#{endpoint}")
            .then do |response|
              response.status.success? ? records(response.body.to_s) : Core::EMPTY_HASH
            end
      end

      private

      def records(body) = JSON(body, symbolize_names: true).fetch :gems, Core::EMPTY_ARRAY
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
pennyworth-17.8.0 lib/pennyworth/loaders/standard_gem.rb
pennyworth-17.7.0 lib/pennyworth/loaders/standard_gem.rb
pennyworth-17.6.0 lib/pennyworth/loaders/standard_gem.rb
pennyworth-17.5.0 lib/pennyworth/loaders/standard_gem.rb
pennyworth-17.4.1 lib/pennyworth/loaders/standard_gem.rb
pennyworth-17.4.0 lib/pennyworth/loaders/standard_gem.rb
pennyworth-17.3.0 lib/pennyworth/loaders/standard_gem.rb
pennyworth-17.2.0 lib/pennyworth/loaders/standard_gem.rb
pennyworth-17.1.0 lib/pennyworth/loaders/standard_gem.rb
pennyworth-17.0.0 lib/pennyworth/loaders/standard_gem.rb