Sha256: bf2017959faf516243c157ef2c1a774ccddef9e26131552359473b4fa62803e8

Contents?: true

Size: 1.92 KB

Versions: 17

Compression:

Stored size: 1.92 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 :Authority        , "magellan/cli/resources/authority"

      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",
        "Authority"     => "authority",
        "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

17 entries across 17 versions & 1 rubygems

Version Path
magellan-cli-0.8.3 lib/magellan/cli/resources.rb
magellan-cli-0.8.2 lib/magellan/cli/resources.rb
magellan-cli-0.8.1 lib/magellan/cli/resources.rb
magellan-cli-0.8.0 lib/magellan/cli/resources.rb
magellan-cli-0.7.11 lib/magellan/cli/resources.rb
magellan-cli-0.7.10 lib/magellan/cli/resources.rb
magellan-cli-0.7.9 lib/magellan/cli/resources.rb
magellan-cli-0.7.8 lib/magellan/cli/resources.rb
magellan-cli-0.7.7 lib/magellan/cli/resources.rb
magellan-cli-0.7.6 lib/magellan/cli/resources.rb
magellan-cli-0.7.5 lib/magellan/cli/resources.rb
magellan-cli-0.7.4 lib/magellan/cli/resources.rb
magellan-cli-0.7.3 lib/magellan/cli/resources.rb
magellan-cli-0.7.2 lib/magellan/cli/resources.rb
magellan-cli-0.7.1 lib/magellan/cli/resources.rb
magellan-cli-0.7.0 lib/magellan/cli/resources.rb
magellan-cli-0.6.5 lib/magellan/cli/resources.rb