Sha256: f59d24634f362524639c84df108cce64381b858298cb1544d7439556b25e0a8d

Contents?: true

Size: 1.33 KB

Versions: 6

Compression:

Stored size: 1.33 KB

Contents

_.def('Luca.app.Components').extends('Luca.Collection').with

  cachedMethods: [
    "namespaces"
    "classes"
    "roots"
    "views"
    "collections"
    "models"
  ]

  cache_key: "luca_components"

  name: "components"

  initialize: ()->
    @model = Luca.app.Component
    Luca.Collection::initialize.apply(@, arguments)
    
  url: ()->
    "/luca/source-map.js"

  collections: ()->
    @select (component)-> Luca.isCollectionPrototype( component.definition() )

  modelClasses: ()->
    @select (component)-> Luca.isModelPrototype( component.definition() )

  views: ()->
    @select (component)-> Luca.isViewPrototype( component.definition() )

  classes: ()->
    _.uniq( @pluck("className") )

  roots: ()->
    _.uniq( @invoke("root") )

  namespaces: ()->
    _.uniq( @invoke("namespace") )

  asTree: ()->
    classes = @classes()
    namespaces = @namespaces()
    roots = @roots()

    tree = _( roots ).inject (memo,root)->
      memo[ root ] ||= {}
      regexp = new RegExp("^#{ root }")
      memo[root] = _( namespaces ).select (namespace)->
        regexp.exec(namespace) and _( namespaces ).include(namespace) and namespace.split('.').length is 2
      memo
    , {}

    _( tree ).inject (memo, namespaces, root)->
      memo[root] = {}
      _( namespaces ).each (namespace)->
        memo[root][namespace] = {}
      memo
    , {}

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
luca-0.9.76 src/tools/collections/components.coffee
luca-0.9.7 src/tools/collections/components.coffee
luca-0.9.65 src/tools/collections/components.coffee
luca-0.9.6 src/tools/collections/components.coffee
luca-0.9.42 src/tools/collections/components.coffee
luca-0.9.4 src/tools/collections/components.coffee