Class: OpsWalrus::PackageFile
- Inherits:
-
Object
- Object
- OpsWalrus::PackageFile
- Defined in:
- lib/opswalrus/package_file.rb
Instance Attribute Summary collapse
-
#package_file_path ⇒ Object
Returns the value of attribute package_file_path.
-
#yaml ⇒ Object
Returns the value of attribute yaml.
Instance Method Summary collapse
- #containing_directory ⇒ Object
-
#dependencies ⇒ Object
returns a map of the form: {“local_package_name” => PackageReference1, … }.
-
#dependency(local_package_name) ⇒ Object
returns a PackageReference.
-
#dirname ⇒ Object
def bundle! bundler_for_package = Bundler.new(dirname) bundler_for_package.update end.
- #eql?(other) ⇒ Boolean
- #hash ⇒ Object
-
#initialize(package_file_path) ⇒ PackageFile
constructor
A new instance of PackageFile.
- #package_file ⇒ Object
Constructor Details
#initialize(package_file_path) ⇒ PackageFile
Returns a new instance of PackageFile.
65 66 67 68 69 |
# File 'lib/opswalrus/package_file.rb', line 65 def initialize(package_file_path) @package_file_path = package_file_path.to_pathname. @yaml = YAML.load(File.read(package_file_path)) if @package_file_path.exist? @yaml ||= {} end |
Instance Attribute Details
#package_file_path ⇒ Object
Returns the value of attribute package_file_path.
62 63 64 |
# File 'lib/opswalrus/package_file.rb', line 62 def package_file_path @package_file_path end |
#yaml ⇒ Object
Returns the value of attribute yaml.
63 64 65 |
# File 'lib/opswalrus/package_file.rb', line 63 def yaml @yaml end |
Instance Method Details
#containing_directory ⇒ Object
92 93 94 |
# File 'lib/opswalrus/package_file.rb', line 92 def containing_directory Pathname.new(@package_file_path).parent end |
#dependencies ⇒ Object
returns a map of the form: {“local_package_name” => PackageReference1, … }
97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 |
# File 'lib/opswalrus/package_file.rb', line 97 def dependencies @dependencies ||= begin dependencies_hash = yaml["dependencies"] || {} dependencies_hash.map do |local_name, package_defn| package_reference = case package_defn in String => package_url PackageReference.new(local_name, package_url) in Hash url = package_defn["url"] version = package_defn["version"] PackageReference.new(local_name, url, version&.to_s) else raise Error, "Unknown package reference in #{package_file_path}:\n #{local_name}: #{package_defn.inspect}" end [local_name, package_reference] end.to_h end end |
#dependency(local_package_name) ⇒ Object
returns a PackageReference
117 118 119 |
# File 'lib/opswalrus/package_file.rb', line 117 def dependency(local_package_name) dependencies[local_package_name] end |
#dirname ⇒ Object
80 81 82 |
# File 'lib/opswalrus/package_file.rb', line 80 def dirname @package_file_path.dirname end |
#eql?(other) ⇒ Boolean
88 89 90 |
# File 'lib/opswalrus/package_file.rb', line 88 def eql?(other) self.class == other.class && self.hash == other.hash end |
#hash ⇒ Object
84 85 86 |
# File 'lib/opswalrus/package_file.rb', line 84 def hash @package_file_path.hash end |
#package_file ⇒ Object
71 72 73 |
# File 'lib/opswalrus/package_file.rb', line 71 def package_file self end |