Class: Mxrb::OfficialMarketplace::DependencyPlan
- Inherits:
-
Object
- Object
- Mxrb::OfficialMarketplace::DependencyPlan
- Defined in:
- lib/mxrb/official_marketplace/dependency_resolver.rb
Overview
Preview for a recursively verified dependency installation.
Instance Attribute Summary collapse
-
#blockers ⇒ Object
readonly
Returns the value of attribute blockers.
-
#dependencies ⇒ Object
readonly
Returns the value of attribute dependencies.
-
#root ⇒ Object
readonly
Returns the value of attribute root.
-
#widget_dependencies ⇒ Object
readonly
Returns the value of attribute widget_dependencies.
Instance Method Summary collapse
- #applied? ⇒ Boolean
- #apply! ⇒ Object
- #apply_operation ⇒ Object
- #apply_resolved! ⇒ Object
- #changes ⇒ Object
- #expire! ⇒ Object
-
#initialize(root:, dependencies:, blockers:, widget_dependencies: [], &operation) ⇒ DependencyPlan
constructor
A new instance of DependencyPlan.
- #safe? ⇒ Boolean
Constructor Details
#initialize(root:, dependencies:, blockers:, widget_dependencies: [], &operation) ⇒ DependencyPlan
Returns a new instance of DependencyPlan.
12 13 14 15 16 17 18 19 |
# File 'lib/mxrb/official_marketplace/dependency_resolver.rb', line 12 def initialize(root:, dependencies:, blockers:, widget_dependencies: [], &operation) @root = root @dependencies = dependencies.freeze @widget_dependencies = .freeze @blockers = blockers.freeze @operation = operation @applied = false end |
Instance Attribute Details
#blockers ⇒ Object (readonly)
Returns the value of attribute blockers.
10 11 12 |
# File 'lib/mxrb/official_marketplace/dependency_resolver.rb', line 10 def blockers @blockers end |
#dependencies ⇒ Object (readonly)
Returns the value of attribute dependencies.
10 11 12 |
# File 'lib/mxrb/official_marketplace/dependency_resolver.rb', line 10 def dependencies @dependencies end |
#root ⇒ Object (readonly)
Returns the value of attribute root.
10 11 12 |
# File 'lib/mxrb/official_marketplace/dependency_resolver.rb', line 10 def root @root end |
#widget_dependencies ⇒ Object (readonly)
Returns the value of attribute widget_dependencies.
10 11 12 |
# File 'lib/mxrb/official_marketplace/dependency_resolver.rb', line 10 def @widget_dependencies end |
Instance Method Details
#applied? ⇒ Boolean
22 |
# File 'lib/mxrb/official_marketplace/dependency_resolver.rb', line 22 def applied? = @applied |
#apply! ⇒ Object
29 30 31 32 33 34 35 |
# File 'lib/mxrb/official_marketplace/dependency_resolver.rb', line 29 def apply! raise MarketplaceError, 'Marketplace dependency plan was already applied' if applied? raise MarketplaceError, "Marketplace dependency plan is blocked: #{blockers.join('; ')}" unless safe? raise MarketplaceError, 'Marketplace dependency preview expired; rerun with apply enabled' unless @operation apply_operation end |
#apply_operation ⇒ Object
44 45 46 47 48 |
# File 'lib/mxrb/official_marketplace/dependency_resolver.rb', line 44 def apply_operation @operation.call @applied = true self end |
#apply_resolved! ⇒ Object
37 38 39 40 41 42 |
# File 'lib/mxrb/official_marketplace/dependency_resolver.rb', line 37 def apply_resolved! raise MarketplaceError, 'Marketplace dependency plan was already applied' if applied? raise MarketplaceError, 'Marketplace dependency preview expired; rerun with apply enabled' unless @operation apply_operation end |
#changes ⇒ Object
24 25 26 27 |
# File 'lib/mxrb/official_marketplace/dependency_resolver.rb', line 24 def changes dependencies.map { "install #{_1.module_name} #{_1.package.version}" } + .map { "install widget bundle #{_1.package.name} #{_1.package.version}" } end |
#expire! ⇒ Object
50 51 52 53 |
# File 'lib/mxrb/official_marketplace/dependency_resolver.rb', line 50 def expire! @operation = nil unless applied? self end |
#safe? ⇒ Boolean
21 |
# File 'lib/mxrb/official_marketplace/dependency_resolver.rb', line 21 def safe? = blockers.empty? |