Sha256: 41dfdbce7e900b799e31fe390008e91be5f48739b25c4c7762a580fb83a43f35

Contents?: true

Size: 910 Bytes

Versions: 1

Compression:

Stored size: 910 Bytes

Contents

class KeyDependency
  
  
  def initialize(attributes={})
    @slug = attributes[:slug]
    @name = attributes.fetch(:as, @slug.titleize)
    @target_versions = attributes.fetch(:target_versions, []).map(&Gem::Version.method(:new))
  end
  
  
  
  attr_reader :slug, :name, :target_versions
  
  def versions
    @versions ||= KeyDependency.versions_for(self)
  end
  
  def latest_version
    versions.first
  end
  
  def to_s
    slug
  end
  
  
  
  def self.all
    @dependency_versions ||= Houston.config.key_dependencies.map do |dependency|
      KeyDependency.new(dependency)
    end
  end
  
  
  
  def self.versions_for(dependency)
    
    # Right now the only supported dependencies are Ruby Gems
    # In the future, as other kinds of dependencies are supported,
    # we'll support different adapters to fetch their version info
    Rubygems::Gem.new(dependency.slug).versions
  end
  
  
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
houston-core-0.5.0.beta1 app/models/key_dependency.rb