Sha256: 3f22bf76b5fcc8136796cfcb1e0a0dd20e284ca1ff125a72d23abdc1dc1a2379

Contents?: true

Size: 1.34 KB

Versions: 1

Compression:

Stored size: 1.34 KB

Contents

require 'net/http'
require 'yaml'

module KPM
  class PluginsDirectory
    def self.all(latest=false)
      if latest
        # Look at GitHub (source of truth)
        uri = URI('https://raw.githubusercontent.com/killbill/killbill-cloud/master/kpm/lib/kpm/plugins_directory.yml')
        source = Net::HTTP.get(uri)
        YAML.load(source)
      else
        source = File.join(File.expand_path(File.dirname(__FILE__)), 'plugins_directory.yml')
        YAML.load_file(source)
      end
    end

    def self.lookup(plugin_name, latest=false)
      plugin = all(latest)[plugin_name.to_s.downcase.to_sym]
      return nil if plugin.nil?

      type = plugin[:type]
      is_ruby = type == :ruby

      group_id    = plugin[:group_id] || (is_ruby ? KPM::BaseArtifact::KILLBILL_RUBY_PLUGIN_GROUP_ID : KPM::BaseArtifact::KILLBILL_JAVA_PLUGIN_GROUP_ID)
      artifact_id = plugin[:artifact_id] || "#{plugin.to_s}-plugin"
      packaging   = plugin[:packaging] || (is_ruby ? KPM::BaseArtifact::KILLBILL_RUBY_PLUGIN_PACKAGING : KPM::BaseArtifact::KILLBILL_JAVA_PLUGIN_PACKAGING)
      classifier  = plugin[:classifier] || (is_ruby ? KPM::BaseArtifact::KILLBILL_RUBY_PLUGIN_CLASSIFIER : KPM::BaseArtifact::KILLBILL_JAVA_PLUGIN_CLASSIFIER)
      version     = plugin[:stable_version] || 'LATEST'

      [group_id, artifact_id, packaging, classifier, version, type]
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
kpm-0.0.9 lib/kpm/plugins_directory.rb