Sha256: a879b5c4c33b2951b356678c74d93619090e9cc092158bf63a67768d362dfea5
Contents?: true
Size: 1.58 KB
Versions: 18
Compression:
Stored size: 1.58 KB
Contents
module Lanes module Components @@enabled = [] class << self # @param names [Symbol] list of components to include in applications def enable(*names) @@enabled += names.map(&:to_s) @@enabled.uniq! end def enabled(&block) @@enabled.each{ |component| yield component } end # Called by sprockets during processing from the client/components/enabled.js.erb # Requires the enabled components and all of their dependencies 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 # @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 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 end end end
Version data entries
18 entries across 18 versions & 1 rubygems