Sha256: 12961b623b806345c8023a4f069ff8867169aa9af4d1d8d7b682b31e43b9fac8

Contents?: true

Size: 1.06 KB

Versions: 1

Compression:

Stored size: 1.06 KB

Contents

module Hatio
  $HATIO_BUNDLES = [] unless defined? $HATIO_BUNDLES

  class Bundle
    attr_accessor :name, :module, :version, :summary, :author, :email, :url, :description, :changes, :entities, :dependencies, :bootstrap_controllers

    def initialize(name, version)
      self.name = name
      self.version = version
      self.module = Kernel.const_get(name.gsub('-', '_').classify)
      self.entities = []
      self.dependencies = []
      self.bootstrap_controllers = []

      yield self if block_given?

      $HATIO_BUNDLES << self
    end

    def self.ordered_bundle_list
      ordered_list = []
      $HATIO_BUNDLES.each do |bundle|
        ordering_bundles bundle, ordered_list
      end
      ordered_list
    end

    def self.ordering_bundles bundle, ordered_list
      return if ordered_list.include? bundle
      bundle.dependencies.each do |dep|
        dep_bundle = $HATIO_BUNDLES.detect{|b| b.name == dep}
        ordering_bundles dep_bundle, ordered_list if dep_bundle
      end
      ordered_list << bundle unless ordered_list.include? bundle
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
hatio-core-0.0.6 lib/hatio-core/bundle/hatio_bundle.rb