Sha256: 986b3df3887533eb231e2f2e91d2a3b34222a7b756254cd29c335527c3e09279

Contents?: true

Size: 770 Bytes

Versions: 8

Compression:

Stored size: 770 Bytes

Contents

module MotherBrain::API
  module Helpers
    include MB::Mixin::Services

    # @param [String] name
    # @param [String] version (nil)
    #
    # @return [Plugin]
    def find_plugin!(name, version = nil)
      version = convert_uri_version(version)

      unless plugin = plugin_manager.find(name, version)
        raise MB::PluginNotFound.new(name, version)
      end

      plugin
    end

    # @param [String] id
    #
    # @return [JobRecord]
    def find_job!(id)
      unless job = job_manager.find(id)
        raise MB::JobNotFound.new(id)
      end

      job
    end

    def convert_uri_version(version)
      return nil if version.nil?

      ver_string = version.gsub('_', '.')
      Solve::Version.split(ver_string)
      ver_string
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
motherbrain-1.1.1 lib/mb/api/helpers.rb
motherbrain-1.1.0 lib/mb/api/helpers.rb
motherbrain-1.0.0 lib/mb/api/helpers.rb
motherbrain-0.14.5 lib/mb/api/helpers.rb
motherbrain-0.14.4 lib/mb/api/helpers.rb
motherbrain-0.14.3 lib/mb/api/helpers.rb
motherbrain-0.14.2 lib/mb/api/helpers.rb
motherbrain-0.13.1 lib/mb/api/helpers.rb