Sha256: 0aa4c2880167ec5ec4eaa1b1292d6dd9419106e77426f9a6920138059a70ac70

Contents?: true

Size: 850 Bytes

Versions: 9

Compression:

Stored size: 850 Bytes

Contents

class SidebarRegistry
  class << self
    def register_sidebar(klass_name)
      registered_sidebars << klass_name.to_s
    end

    def available_sidebars
      registered_sidebars.sort.map(&:constantize)
    end

    def available_sidebar_types
      registered_sidebars.sort
    end

    def register_sidebar_directory(plugins_root, paths)
      separator = plugins_root.include?('/') ? '/' : '\\'

      Dir.glob(File.join(plugins_root, '*_sidebar')).select do |file|
        plugin_name = file.split(separator).last
        register_sidebar plugin_name.classify
        # TODO: Move Sidebars to app/models, and views to app/views so this can
        # be simplified.
        paths << File.join(plugins_root, plugin_name, 'lib')
      end
    end

    private

    def registered_sidebars
      @registered_sidebars ||= Set.new
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
publify_core-9.1.0 lib/sidebar_registry.rb
publify_core-9.0.1 lib/sidebar_registry.rb
publify_core-9.0.0 lib/sidebar_registry.rb
publify_core-9.0.0.pre6 lib/sidebar_registry.rb
publify_core-9.0.0.pre5 lib/sidebar_registry.rb
publify_core-9.0.0.pre4 lib/sidebar_registry.rb
publify_core-9.0.0.pre3 lib/sidebar_registry.rb
publify_core-9.0.0.pre2 lib/sidebar_registry.rb
publify_core-9.0.0.pre1 lib/sidebar_registry.rb