module Lanes::Components

Public Class Methods

component_configuration(component, env) click to toggle source

@param component [String,Symbol] component name to lookup @return Hash configuration for component, read from a config.json file in the components directory, or an empty hash if no configuration is present

# File lib/lanes/components.rb, line 33
def component_configuration(component, env)
    if asset = env.find_asset("lanes/components/#{component}")
        config_file = asset.pathname.dirname.join("config.json")
        if config_file.exist?
            return Oj.load(config_file.read)
        end
    end
    return {}
end
enable(*names) click to toggle source

@param names [Symbol] list of components to include in applications

# File lib/lanes/components.rb, line 9
def enable(*names)
    @@enabled += names.map(&:to_s)
    @@enabled.uniq!
end
enabled() { |component| ... } click to toggle source
# File lib/lanes/components.rb, line 14
def enabled(&block)
    @@enabled.each{ |component| yield component }
end
enabled_with_dependencies(env) { |d| ... } click to toggle source

Called by sprockets during processing from the client/components/enabled.js.erb Requires the enabled components and all of their dependencies

# File lib/lanes/components.rb, line 20
def enabled_with_dependencies(env, &block)
    enabled do | component |
        config = component_configuration(component, env.environment)
        if config['depends']
            config['depends'].each{ |d| yield d }
        end
        yield component
    end
end