Class: Lono::Jade
- Inherits:
-
Object
- Object
- Lono::Jade
- Extended by:
- Memoist
- Includes:
- Circular
- Defined in:
- lib/lono/jade.rb,
lib/lono/jade/circular.rb,
lib/lono/jade/registry.rb,
lib/lono/jade/materializer.rb
Defined Under Namespace
Modules: Circular Classes: Materializer, Registry
Instance Attribute Summary collapse
-
#dependencies ⇒ Object
Returns the value of attribute dependencies.
-
#depends_ons ⇒ Object
Returns the value of attribute depends_ons.
-
#from ⇒ Object
Returns the value of attribute from.
-
#jadespec ⇒ Object
readonly
Returns the value of attribute jadespec.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#registry ⇒ Object
readonly
Returns the value of attribute registry.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Instance Method Summary collapse
-
#download ⇒ Object
Must return config to set @jadespec in materialize Only allow download of Lono::Blueprint::Configset::Jade Other configsets should be configured in project Gemfile.
- #evaluate_meta_rb ⇒ Object
- #finder ⇒ Object
-
#initialize(name, type, registry = {}) ⇒ Jade
constructor
A new instance of Jade.
- #materialize ⇒ Object
- #repo ⇒ Object
- #resolved! ⇒ Object
- #resolved? ⇒ Boolean
- #resource_from_parent ⇒ Object
-
#root ⇒ Object
root is kind of special.
Methods included from Circular
#check_for_circular_dependency!, #circular_dependency?, #parent_names
Constructor Details
#initialize(name, type, registry = {}) ⇒ Jade
Returns a new instance of Jade.
10 11 12 13 14 15 16 17 |
# File 'lib/lono/jade.rb', line 10 def initialize(name, type, registry={}) # type: one of blueprint, configset, blueprint/configset # registry holds either original registry from configset definition or parent jade which can be used to get the original configset defintion @name, @type, @registry = name, type, registry @materialized = false @resolved = false @depends_ons = [] end |
Instance Attribute Details
#dependencies ⇒ Object
Returns the value of attribute dependencies.
8 9 10 |
# File 'lib/lono/jade.rb', line 8 def dependencies @dependencies end |
#depends_ons ⇒ Object
Returns the value of attribute depends_ons.
8 9 10 |
# File 'lib/lono/jade.rb', line 8 def depends_ons @depends_ons end |
#from ⇒ Object
Returns the value of attribute from.
8 9 10 |
# File 'lib/lono/jade.rb', line 8 def from @from end |
#jadespec ⇒ Object (readonly)
Returns the value of attribute jadespec.
9 10 11 |
# File 'lib/lono/jade.rb', line 9 def jadespec @jadespec end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
9 10 11 |
# File 'lib/lono/jade.rb', line 9 def name @name end |
#registry ⇒ Object (readonly)
Returns the value of attribute registry.
9 10 11 |
# File 'lib/lono/jade.rb', line 9 def registry @registry end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
9 10 11 |
# File 'lib/lono/jade.rb', line 9 def type @type end |
Instance Method Details
#download ⇒ Object
Must return config to set @jadespec in materialize Only allow download of Lono::Blueprint::Configset::Jade Other configsets should be configured in project Gemfile.
Cases:
1a) blueprint/configset top-level - download
1b) blueprint/configset depends_on - download
2a) configset top-level - dont download, will report to user with validate_all!
2b) configset depends_on - download
3) extension - download
80 81 82 83 84 85 86 87 88 |
# File 'lib/lono/jade.rb', line 80 def download return if finder.find(@name, local_only: true) # no need to download because locally found return unless %w[blueprint/configset configset extension].include?(@type) # Comment out. Unsure if this complexity is worth it. Always download jades. # Only download jades that came from depends_on # return unless @registry.parent || %w[blueprint/configset extension].include?(@type) materializer = Materializer.new(self) materializer.build end |
#evaluate_meta_rb ⇒ Object
91 92 93 94 95 |
# File 'lib/lono/jade.rb', line 91 def return unless %w[blueprint/configset configset].include?(@type) = Lono::Configset::Meta.new(self) .evaluate end |
#finder ⇒ Object
105 106 107 |
# File 'lib/lono/jade.rb', line 105 def finder "Lono::Finder::#{@type.camelize}".constantize.new end |
#materialize ⇒ Object
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/lono/jade.rb', line 48 def materialize @jadespec = finder.find(@name) download unless @jadespec # Pretty tricky. Flush memoized finder(true) since download changes filesystem. Not memoizing at all is 2x slower @jadespec = finder(true).find(@name) return nil unless @jadespec if @jadespec.source_type == "materialized" # possible "duplicated" jade instances with same name but will uniq in final materialized Gemfile case @jadespec.lono_type when "configset" Lono::Jade::Registry.downloaded_configsets << self when "extension" Lono::Jade::Registry.downloaded_extensions << self end end @jadespec end |
#repo ⇒ Object
19 20 21 |
# File 'lib/lono/jade.rb', line 19 def repo @registry.[:repo] || @name end |
#resolved! ⇒ Object
97 98 99 |
# File 'lib/lono/jade.rb', line 97 def resolved! @resolved = true end |
#resolved? ⇒ Boolean
101 102 103 |
# File 'lib/lono/jade.rb', line 101 def resolved? @resolved end |
#resource_from_parent ⇒ Object
38 39 40 41 42 43 44 45 46 |
# File 'lib/lono/jade.rb', line 38 def resource_from_parent parent = registry.parent # using local variable intentionally resource = nil while parent # go all the way to the highest parent resource = parent.registry.resource parent = parent.registry.parent end resource end |
#root ⇒ Object
root is kind of special. root is needed for materialization but can accidentally get called too early before materialization. So treat it specially with an error.
25 26 27 28 |
# File 'lib/lono/jade.rb', line 25 def root raise "ERROR: root is not available until jade has been materialized" unless @jadespec @jadespec.root end |