Class: Composer::Package::BasePackage
- Inherits:
-
Object
- Object
- Composer::Package::BasePackage
- Defined in:
- lib/composer/package/base_package.rb
Overview
Base class for packages providing name storage and default match implementation
Direct Known Subclasses
Constant Summary collapse
- STABILITY_STABLE =
0
- STABILITY_RC =
5
- STABILITY_BETA =
10
- STABILITY_ALPHA =
15
- STABILITY_DEV =
20
- SUPPORTED_LINK_TYPES =
{ '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
-
#id ⇒ Object
base package attributes.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#pretty_name ⇒ Object
readonly
Returns the value of attribute pretty_name.
-
#pretty_version ⇒ Object
readonly
Returns the value of attribute pretty_version.
-
#repository ⇒ Object
Get package repository.
-
#stability ⇒ Object
readonly
Returns the value of attribute stability.
-
#transport_options ⇒ Object
base package attributes.
-
#version ⇒ Object
readonly
Returns the value of attribute version.
Class Method Summary collapse
Instance Method Summary collapse
- #attributes ⇒ Object
-
#initialize(name) ⇒ BasePackage
constructor
Creates a new in memory package.
- #pretty_string ⇒ Object
- #to_s ⇒ Object
-
#type ⇒ Object
Get package type Return: string.
-
#type=(type) ⇒ Object
Set package type Param: string type.
-
#unique_name ⇒ Object
Returns package unique name, constructed from name, version and release type.
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
#id ⇒ Object
base package attributes
22 23 24 |
# File 'lib/composer/package/base_package.rb', line 22 def id @id end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
23 24 25 |
# File 'lib/composer/package/base_package.rb', line 23 def name @name end |
#pretty_name ⇒ Object (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_version ⇒ Object (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 |
#repository ⇒ Object
Get package repository
22 23 24 |
# File 'lib/composer/package/base_package.rb', line 22 def repository @repository end |
#stability ⇒ Object (readonly)
Returns the value of attribute stability.
23 24 25 |
# File 'lib/composer/package/base_package.rb', line 23 def stability @stability end |
#transport_options ⇒ Object
base package attributes
22 23 24 |
# File 'lib/composer/package/base_package.rb', line 22 def @transport_options end |
#version ⇒ Object (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
.stabilities ⇒ Object
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
#attributes ⇒ Object
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_string ⇒ Object
120 121 122 |
# File 'lib/composer/package/base_package.rb', line 120 def pretty_string "#{pretty_name} #{pretty_version}" end |
#to_s ⇒ Object
124 125 126 |
# File 'lib/composer/package/base_package.rb', line 124 def to_s unique_name end |
#type ⇒ Object
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_name ⇒ Object
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 |