Class: OpsWalrus::PackageReference
- Inherits:
-
Object
- Object
- OpsWalrus::PackageReference
- Defined in:
- lib/opswalrus/package_file.rb
Overview
these are static package references defined ahead of time in the package file
Direct Known Subclasses
Instance Attribute Summary collapse
-
#local_name ⇒ Object
Returns the value of attribute local_name.
-
#package_uri ⇒ Object
Returns the value of attribute package_uri.
-
#version ⇒ Object
Returns the value of attribute version.
Instance Method Summary collapse
-
#import_resolution_dirname ⇒ Object
important: the import_resolution_dirname implemented as the local_name is critical because Bundler#download_package downloads package dependencies to the name that this method returns, which must match the package reference’s local name so that later, when the package is being looked up on the load path (in LoadPath#resolve_import_reference), the package reference’s referenced git repo or file path may not exist or be available, and so the package reference’s local_name is used to look up the name of the directory that the bundled dependency resides at, and so the package reference’s local_name must be the name of the directory that the dependency is placed in within the bundle_dir.
-
#initialize(local_name, package_uri, version = nil) ⇒ PackageReference
constructor
A new instance of PackageReference.
- #summary ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(local_name, package_uri, version = nil) ⇒ PackageReference
Returns a new instance of PackageReference.
14 15 16 |
# File 'lib/opswalrus/package_file.rb', line 14 def initialize(local_name, package_uri, version = nil) @local_name, @package_uri, @version = local_name, package_uri, version end |
Instance Attribute Details
#local_name ⇒ Object
Returns the value of attribute local_name.
10 11 12 |
# File 'lib/opswalrus/package_file.rb', line 10 def local_name @local_name end |
#package_uri ⇒ Object
Returns the value of attribute package_uri.
11 12 13 |
# File 'lib/opswalrus/package_file.rb', line 11 def package_uri @package_uri end |
#version ⇒ Object
Returns the value of attribute version.
12 13 14 |
# File 'lib/opswalrus/package_file.rb', line 12 def version @version end |
Instance Method Details
#import_resolution_dirname ⇒ Object
important: the import_resolution_dirname implemented as the local_name is critical because Bundler#download_package downloads package dependencies to the name that this method returns, which must match the package reference’s local name so that later, when the package is being looked up on the load path (in LoadPath#resolve_import_reference), the package reference’s referenced git repo or file path may not exist or be available, and so the package reference’s local_name is used to look up the name of the directory that the bundled dependency resides at, and so the package reference’s local_name must be the name of the directory that the dependency is placed in within the bundle_dir. If this implementation changes, then Bundler#download_package and LoadPath#resolve_import_reference must also change in order for the three things to reconcile with respect to one another, since all three bits of logic are what make bundling package dependencies and loading them function properly.
27 28 29 |
# File 'lib/opswalrus/package_file.rb', line 27 def import_resolution_dirname "pkg_#{local_name}_version_#{version}" end |
#summary ⇒ Object
35 36 37 38 39 40 41 |
# File 'lib/opswalrus/package_file.rb', line 35 def summary if version "#{package_uri}:#{version}" else package_uri end end |
#to_s ⇒ Object
31 32 33 |
# File 'lib/opswalrus/package_file.rb', line 31 def to_s "PackageReference(local_name=#{@local_name}, package_uri=#{@package_uri}, version=#{@version})" end |