Sha256: a945784bfc169aa9e98c67c615a4307eb5ee1fc8204a6e58f3d56a6acc19b906

Contents?: true

Size: 1.82 KB

Versions: 25

Compression:

Stored size: 1.82 KB

Contents

# -*- coding: utf-8 -*-
require "magellan/cli"

require 'json'
require 'yaml'
require 'active_support/core_ext/string/inflections'

module Magellan
  module Cli
    module Resources

      autoload :Base             , "magellan/cli/resources/base"
      autoload :Organization     , "magellan/cli/resources/organization"
      autoload :Team             , "magellan/cli/resources/team"
      autoload :Project          , "magellan/cli/resources/project"
      autoload :Stage            , "magellan/cli/resources/stage"
      autoload :ClientVersion    , "magellan/cli/resources/client_version"

      autoload :TransactionRouter, "magellan/cli/resources/transaction_router"
      autoload :Worker           , "magellan/cli/resources/worker"

      autoload :Image            , "magellan/cli/resources/image"
      autoload :Container        , "magellan/cli/resources/container"

      autoload :Cloudsql, "magellan/cli/resources/cloudsql"

      autoload :Deletable, "magellan/cli/resources/deletable"


      MAPPING =\
      {
        "Organization"  => "organization",
        "Team"          => "team",
        "Project"       => "project",
        "Stage"         => "stage",
        "ClientVersion" => "client_version",
        #"TransactionRouter" => "tr",
        "Worker"        => "worker",
        "Image"         => "image",
        "Container"     => "container",
        "Cloudsql"      => "cloudsql",
      }

      class << self
        def concrete_classes
          @concrete_classes ||= MAPPING.keys.map{|c| self.const_get(c) }
        end

        def dependants_on(klass)
          name = klass.name.split(/::/).last
          res_name = MAPPING[name] or raise "unknown class named #{klass.name}"
          concrete_classes.select{|c| c.resource_dependency && !!c.resource_dependency[res_name] }
        end
      end

    end
  end
end

Version data entries

25 entries across 25 versions & 1 rubygems

Version Path
magellan-cli-0.3.4 lib/magellan/cli/resources.rb
magellan-cli-0.3.3 lib/magellan/cli/resources.rb
magellan-cli-0.3.2 lib/magellan/cli/resources.rb
magellan-cli-0.3.1 lib/magellan/cli/resources.rb
magellan-cli-0.3.0 lib/magellan/cli/resources.rb