Sha256: 675769c1963c3f310a5f24d08332e647327d7e2754745ebb7ad6439e6d7ffd88
Contents?: true
Size: 1.53 KB
Versions: 3
Compression:
Stored size: 1.53 KB
Contents
require 'pry' module Lanes module Components @@enabled = [] class << self # @param names [Symbol] list of components to include in applications def enable(*names) @@enabled += names.map(&:to_sym) @@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 | depends = component_configuration(component, env.environment)['depends'] depends.each{ |d| yield d } if depends 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("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
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
lanes-0.1.0 | lib/lanes/components.rb |
lanes-0.0.8 | lib/lanes/components.rb |
lanes-0.0.5 | lib/lanes/components.rb |