Sha256: c342dd09a9d8bfc84766831e5e655a2b45b4b69836434ad10470cb82b25035de

Contents?: true

Size: 1.54 KB

Versions: 5

Compression:

Stored size: 1.54 KB

Contents

module Kosmos
  module PackageAttrs
    private

    def self.included(base)
      base.extend(Methods)
      base.send(:include, Methods)
    end

    module Methods
      def title(title = nil)
        if title
          @title = title
        else
          @title
        end
      end

      def url(url = nil)
        if url
          @url = url
        else
          @url
        end
      end

      def aliases(*aliases)
        @aliases ||= []

        if aliases.any?
          @aliases = aliases
        else
          @aliases
        end
      end

      def names
        [title, aliases].flatten
      end

      def prerequisites(*prerequisites)
        @prerequisites ||= []

        if prerequisites.any?
          @prerequisites = prerequisites
        else
          @prerequisites
        end
      end

      alias_method :prerequiste, :prerequisites
      alias_method :pre_requisite, :prerequisites
      alias_method :pre_requisites, :prerequisites

      def postrequisites(*postrequisites)
        @postrequisites ||= []

        if postrequisites.any?
          @postrequisites = postrequisites
        else
          @postrequisites
        end
      end

      alias_method :postrequiste, :postrequisites
      alias_method :post_requisite, :postrequisites
      alias_method :post_requisites, :postrequisites

      def resolve_prerequisites
        prerequisites.map { |package_name| find(package_name) }
      end

      def resolve_postrequisites
        postrequisites.map { |package_name| find(package_name) }
      end

    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
kosmos-0.0.3 lib/kosmos/package_attrs.rb
kosmos-0.0.2.pre.test4 lib/kosmos/package_attrs.rb
kosmos-0.0.2.pre.test3 lib/kosmos/package_attrs.rb
kosmos-0.0.2.pre.test2 lib/kosmos/package_attrs.rb
kosmos-0.0.2 lib/kosmos/package_attrs.rb