Sha256: dc0a4794b7b87f5ecfb620d7edde11a93fbed9e7b1a27bdb9d539ae523053667

Contents?: true

Size: 1.35 KB

Versions: 3

Compression:

Stored size: 1.35 KB

Contents

# frozen_string_literal: true

module Calliope
  class Info
    # @return [String]
    attr_reader :major_version

    # @return [String]
    attr_reader :patch_version

    # @return [String]
    attr_reader :jvm_version

    # @return [String]
    attr_reader :commit_sha

    # @return [Array<String>]
    attr_reader :filters

    # @return [Array<String>]
    attr_reader :sources

    # @return [String]
    attr_reader :version

    # @return [Hash]
    attr_reader :plugins

    # @return [String]
    attr_reader :semver

    # @return [String]
    attr_reader :branch

    # @!visibility private
    # @param payload [Hash]
    def initialize(payload)
      @jvm_version = payload["jvm"]
      @filters = payload["filters"]
      @version = payload["lavaplayer"]
      @sources = payload["sourceManagers"]
      @semver = payload["version"]["semver"]
      @commit_sha = payload["git"]["commit"]
      @major_version = payload["version"]["major"]
      @patch_version = payload["version"]["patch"]
      @branch = payload["git"]["branch"]&.downcase
      @plugins = transform_plugins(payload["plugins"])
    end

    private

    # @!visibility private
    # Transforms the plugins array into a single hash.
    def transform_plugins(plugins)
      plugins.each_with_object({}) do |plugin, result|
        result[plugin["name"]] = plugin["version"]
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
calliope-link-1.0.2 lib/calliope/model/info.rb
calliope-link-1.0.1 lib/calliope/model/info.rb
calliope-link-1.0.0 lib/calliope/model/info.rb