Sha256: 272aba03faa383ecfcd9b3b67a6d5ed715bfebc93f3c01f2a5ab83c234d3b9db

Contents?: true

Size: 773 Bytes

Versions: 7

Compression:

Stored size: 773 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('_', '.')
      Semverse::Version.split(ver_string)
      ver_string
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
motherbrain-1.5.0 lib/mb/api/helpers.rb
motherbrain-1.4.0 lib/mb/api/helpers.rb
motherbrain-1.3.0 lib/mb/api/helpers.rb
motherbrain-1.2.1 lib/mb/api/helpers.rb
motherbrain-1.2.0 lib/mb/api/helpers.rb
motherbrain-1.1.3 lib/mb/api/helpers.rb
motherbrain-1.1.2 lib/mb/api/helpers.rb