Sha256: 57bd5ae9fbbb02a47dd5d428907d05c1ea4085fc3d15053c41dc8a7c4d0abe1c

Contents?: true

Size: 1.47 KB

Versions: 9

Compression:

Stored size: 1.47 KB

Contents

require 'closure_tree'
require 'dragonfly'

module PushType

  class << self

    def version
      PushType::VERSION
    end

    def config
      PushType::Config
    end

    def setup(&block)
      yield config if block
    end

    def root_nodes
      subclasses_from_list(:node, config.root_nodes)
    end

    def unexposed_nodes
      subclasses_from_list(:node, config.unexposed_nodes)
    end

    def unexposed_taxonomies
      subclasses_from_list(:taxonomy, config.unexposed_taxonomies)
    end

    def subclasses_from_list(scope, types = nil)
      return [] unless types
      descendants = "push_type/#{ scope }".camelcase.constantize.descendants.map { |c| c.name.underscore }
      types_array = Array.wrap(types)

      if types_array.include? :all
        descendants
      else
        descendants & types_array.map(&:to_s)
      end.sort
    end

    def dragonfly_app_setup!
      Dragonfly.app.configure do
        plugin      :imagemagick
        url_format  "/media/:job/:name"
        secret      PushType.config.dragonfly_secret
        datastore   PushType.config.dragonfly_datastore, PushType.config.dragonfly_datastore_options
      end
    end

    def menu(key, &block)
      PushType::MenuBuilder.select(key, &block)
    end

  end

  module Core
  end
end

require 'push_type/config'
require 'push_type/core/engine'
require 'push_type/rails/routes'
require 'push_type/field_type'
require 'push_type/menu_builder'
require 'push_type/presenter'
require 'push_type/version'

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
push_type_core-0.5.1 lib/push_type/core.rb
push_type_core-0.5.0 lib/push_type/core.rb
push_type_core-0.5.0.alpha.5 lib/push_type/core.rb
push_type_core-0.5.0.alpha.4 lib/push_type/core.rb
push_type_core-0.5.0.alpha.3 lib/push_type/core.rb
push_type_core-0.5.0.alpha.2 lib/push_type/core.rb
push_type_core-0.5.0.alpha.1 lib/push_type/core.rb
push_type_core-0.4.0 lib/push_type/core.rb
push_type_core-0.4.0.beta.3 lib/push_type/core.rb