class Lono::Jade
Attributes
dependencies[RW]
depends_ons[RW]
from[RW]
jadespec[R]
name[R]
registry[R]
type[R]
Public Class Methods
new(name, type, registry={})
click to toggle source
# 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
Public Instance Methods
download()
click to toggle source
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
# 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()
click to toggle source
# File lib/lono/jade.rb, line 91 def evaluate_meta_rb return unless %w[blueprint/configset configset].include?(@type) meta = Lono::Configset::Meta.new(self) meta.evaluate end
finder()
click to toggle source
# File lib/lono/jade.rb, line 105 def finder "Lono::Finder::#{@type.camelize}".constantize.new end
materialize()
click to toggle source
# 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 evaluate_meta_rb @jadespec end
repo()
click to toggle source
# File lib/lono/jade.rb, line 19 def repo @registry.options[:repo] || @name end
resolved!()
click to toggle source
# File lib/lono/jade.rb, line 97 def resolved! @resolved = true end
resolved?()
click to toggle source
# File lib/lono/jade.rb, line 101 def resolved? @resolved end
resource_from_parent()
click to toggle source
# 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()
click to toggle source
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.
# 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