class Composer::Package::BasePackage

Base class for packages providing name storage and default match implementation @php_author Nils Adermann <naderman@naderman.de> @author Ioannis Kappas <ikappas@devworks.gr>

Constants

STABILITY_ALPHA
STABILITY_BETA
STABILITY_DEV
STABILITY_RC
STABILITY_STABLE

Attributes

id[RW]

base package attributes

name[R]
pretty_name[R]
pretty_version[R]
repository[RW]

base package attributes

stability[R]
transport_options[RW]

base package attributes

version[R]

Public Class Methods

new(name) click to toggle source

Creates a new in memory package. Param: string name The package’s name Param: string version The package’s version Param: string pretty_version The package’s non-normalized version

# File lib/composer/package/base_package.rb, line 72
def initialize(name)
  @pretty_name = name
  @name = name.downcase
  @id = -1
  @transport_options = []
end
stabilities() click to toggle source
# File lib/composer/package/base_package.rb, line 56
def stabilities
  @stabilities ||= {
    'stable' => STABILITY_STABLE,
    'RC'     => STABILITY_RC,
    'beta'   => STABILITY_BETA,
    'alpha'  => STABILITY_ALPHA,
    'dev'    => STABILITY_DEV,
  }.freeze()
end

Public Instance Methods

attributes() click to toggle source
# File lib/composer/package/base_package.rb, line 79
def attributes
  dumper = Composer::Package::Dumper::HashDumper.new
  dumper.dump(self)
end
pretty_string() click to toggle source
# File lib/composer/package/base_package.rb, line 120
def pretty_string
  "#{pretty_name} #{pretty_version}"
end
repository=(repository) click to toggle source

Set package repository

# File lib/composer/package/base_package.rb, line 97
def repository=(repository)
  if (@repository && repository != @repository)
    raise LogicError, 'A package can only be added to one repository'
  end
  @repository = repository
end
to_s() click to toggle source
# File lib/composer/package/base_package.rb, line 124
def to_s
  unique_name
end
type() click to toggle source

Get package type Return: string

# File lib/composer/package/base_package.rb, line 92
def type
  @type ? @type : 'library'
end
type=(type) click to toggle source

Set package type Param: string type

# File lib/composer/package/base_package.rb, line 86
def type=(type)
  @type = type
end
unique_name() click to toggle source

Returns package unique name, constructed from name, version and release type. Return: string

# File lib/composer/package/base_package.rb, line 116
def unique_name
  "#{name}-#{version}"
end