Class: Composer::Package::BasePackage

Inherits:
Object
  • Object
show all
Defined in:
lib/composer/package/base_package.rb

Overview

Base class for packages providing name storage and default match implementation

Author:

Direct Known Subclasses

AliasPackage, Package

Constant Summary collapse

STABILITY_STABLE =
0
STABILITY_RC =
5
STABILITY_BETA =
10
STABILITY_ALPHA =
15
STABILITY_DEV =
20
{
  'require' => {
    'description' => 'requires',
    'method' => 'requires'
  },
  'conflict' => {
    'description' => 'conflicts',
    'method' => 'conflicts'
  },
  'provide' => {
    'description' => 'provides',
    'method' => 'provides'
  },
  'replace' => {
    'description' => 'replaces',
    'method' => 'replaces'
  },
  'require-dev' => {
    'description' => 'requires (for development)',
    'method' => 'dev_requires'
  }
}.freeze()

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name) ⇒ BasePackage

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



72
73
74
75
76
77
# File 'lib/composer/package/base_package.rb', line 72

def initialize(name)
  @pretty_name = name
  @name = name.downcase
  @id = -1
  @transport_options = []
end

Instance Attribute Details

#idObject

base package attributes



22
23
24
# File 'lib/composer/package/base_package.rb', line 22

def id
  @id
end

#nameObject (readonly)

Returns the value of attribute name.



23
24
25
# File 'lib/composer/package/base_package.rb', line 23

def name
  @name
end

#pretty_nameObject (readonly)

Returns the value of attribute pretty_name.



23
24
25
# File 'lib/composer/package/base_package.rb', line 23

def pretty_name
  @pretty_name
end

#pretty_versionObject (readonly)

Returns the value of attribute pretty_version.



23
24
25
# File 'lib/composer/package/base_package.rb', line 23

def pretty_version
  @pretty_version
end

#repositoryObject

Get package repository



22
23
24
# File 'lib/composer/package/base_package.rb', line 22

def repository
  @repository
end

#stabilityObject (readonly)

Returns the value of attribute stability.



23
24
25
# File 'lib/composer/package/base_package.rb', line 23

def stability
  @stability
end

#transport_optionsObject

base package attributes



22
23
24
# File 'lib/composer/package/base_package.rb', line 22

def transport_options
  @transport_options
end

#versionObject (readonly)

Returns the value of attribute version.



23
24
25
# File 'lib/composer/package/base_package.rb', line 23

def version
  @version
end

Class Method Details

.stabilitiesObject



56
57
58
59
60
61
62
63
64
# 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

Instance Method Details

#attributesObject



79
80
81
82
# File 'lib/composer/package/base_package.rb', line 79

def attributes
  dumper = Composer::Package::Dumper::HashDumper.new
  dumper.dump(self)
end

#pretty_stringObject



120
121
122
# File 'lib/composer/package/base_package.rb', line 120

def pretty_string
  "#{pretty_name} #{pretty_version}"
end

#to_sObject



124
125
126
# File 'lib/composer/package/base_package.rb', line 124

def to_s
  unique_name
end

#typeObject

Get package type Return: string



92
93
94
# File 'lib/composer/package/base_package.rb', line 92

def type
  @type ? @type : 'library'
end

#type=(type) ⇒ Object

Set package type Param: string type



86
87
88
# File 'lib/composer/package/base_package.rb', line 86

def type=(type)
  @type = type
end

#unique_nameObject

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



116
117
118
# File 'lib/composer/package/base_package.rb', line 116

def unique_name
  "#{name}-#{version}"
end