Class: QueryPackwerk::Package
- Inherits:
-
Object
- Object
- QueryPackwerk::Package
- Extended by:
- T::Sig
- Defined in:
- lib/query_packwerk/package.rb
Overview
Represents a Packwerk package with enhanced querying capabilities. Wraps around ParsePackwerk::Package to provide additional methods for accessing package properties, dependencies, violations, and consumer information.
Instance Attribute Summary collapse
-
#original_package ⇒ Object
readonly
Returns the value of attribute original_package.
Instance Method Summary collapse
- #config ⇒ Object
- #consumer_counts ⇒ Object
- #consumer_names ⇒ Object
- #consumers ⇒ Object
- #deconstruct_keys(keys) ⇒ Object
- #dependencies ⇒ Object
- #dependency_names ⇒ Object
- #directory ⇒ Object
- #enforce_dependencies ⇒ Object
- #enforce_privacy ⇒ Object
-
#initialize(original_package:) ⇒ Package
constructor
A new instance of Package.
- #inspect ⇒ Object
- #metadata ⇒ Object
- #name ⇒ Object
- #owner ⇒ Object
- #parent_name ⇒ Object
- #todos ⇒ Object (also: #outgoing_violations)
- #violations ⇒ Object (also: #incoming_violations)
Constructor Details
#initialize(original_package:) ⇒ Package
Returns a new instance of Package.
15 16 17 |
# File 'lib/query_packwerk/package.rb', line 15 def initialize(original_package:) @original_package = original_package end |
Instance Attribute Details
#original_package ⇒ Object (readonly)
Returns the value of attribute original_package.
12 13 14 |
# File 'lib/query_packwerk/package.rb', line 12 def original_package @original_package end |
Instance Method Details
#config ⇒ Object
40 41 42 |
# File 'lib/query_packwerk/package.rb', line 40 def config @original_package.config end |
#consumer_counts ⇒ Object
96 97 98 |
# File 'lib/query_packwerk/package.rb', line 96 def consumer_counts violations.consumers end |
#consumer_names ⇒ Object
90 91 92 |
# File 'lib/query_packwerk/package.rb', line 90 def consumer_names violations.consumers.keys end |
#consumers ⇒ Object
84 85 86 |
# File 'lib/query_packwerk/package.rb', line 84 def consumers Packages.where(name: consumer_names) end |
#deconstruct_keys(keys) ⇒ Object
110 111 112 113 114 115 116 117 118 119 120 121 122 |
# File 'lib/query_packwerk/package.rb', line 110 def deconstruct_keys(keys) all_values = { name: name, owner: owner, owned: owner != Packages::UNOWNED, dependencies: dependency_names, # Used for future implementations of NestedPacks parent_name: parent_name } keys.nil? ? all_values : all_values.slice(*T.unsafe(keys)) end |
#dependencies ⇒ Object
45 46 47 |
# File 'lib/query_packwerk/package.rb', line 45 def dependencies Packages.where(name: @original_package.dependencies) end |
#dependency_names ⇒ Object
50 51 52 |
# File 'lib/query_packwerk/package.rb', line 50 def dependency_names @original_package.dependencies end |
#directory ⇒ Object
60 61 62 |
# File 'lib/query_packwerk/package.rb', line 60 def directory Pathname.new(name).cleanpath end |
#enforce_dependencies ⇒ Object
25 26 27 |
# File 'lib/query_packwerk/package.rb', line 25 def enforce_dependencies !!@original_package.enforce_dependencies end |
#enforce_privacy ⇒ Object
30 31 32 |
# File 'lib/query_packwerk/package.rb', line 30 def enforce_privacy !!@original_package.enforce_privacy end |
#inspect ⇒ Object
125 126 127 |
# File 'lib/query_packwerk/package.rb', line 125 def inspect "#<#{self.class.name} #{name}>" end |
#metadata ⇒ Object
35 36 37 |
# File 'lib/query_packwerk/package.rb', line 35 def @original_package. end |
#name ⇒ Object
20 21 22 |
# File 'lib/query_packwerk/package.rb', line 20 def name @original_package.name end |
#owner ⇒ Object
55 56 57 |
# File 'lib/query_packwerk/package.rb', line 55 def owner config['owner'] || Packages::UNOWNED end |
#parent_name ⇒ Object
101 102 103 |
# File 'lib/query_packwerk/package.rb', line 101 def parent_name directory.dirname.to_s end |
#todos ⇒ Object Also known as: outgoing_violations
68 69 70 |
# File 'lib/query_packwerk/package.rb', line 68 def todos QueryPackwerk::Violations.where(consuming_pack: name) end |
#violations ⇒ Object Also known as: incoming_violations
77 78 79 |
# File 'lib/query_packwerk/package.rb', line 77 def violations QueryPackwerk::Violations.where(producing_pack: name) end |