Sha256: 887dd84c9284cd4f600ad48d78b8189ca1b12bb04f5a382c20396c0c3ebb2c37

Contents?: true

Size: 1.16 KB

Versions: 3

Compression:

Stored size: 1.16 KB

Contents

module Docks
  module Tags
    class Require < Base
      def initialize
        @name = :require
        @multiline = false
        @multiple_allowed = true

        @require_associations = {}
      end

      def process(symbol)
        symbol.update(@name) do |requires|
          Array(requires).map { |a_require| split_on_commas_spaces_and_pipes(a_require) }.flatten
        end

        if requires = symbol[@name]
          requires.each do |required|
            @require_associations[required] ||= []
            @require_associations[required] << symbol
          end
        end
      end

      def setup_post_processors
        after_all(:late) do |pattern_library|
          @require_associations.each do |descriptor, users|
            if result = pattern_library.find(descriptor)
              symbol = result.symbol || result.pattern
              symbol[UsedBy] = users.map { |user| user.to_descriptor }
            end
          end

          @require_associations = {}
        end
      end
    end

    class UsedBy < Base
      def initialize
        @name = :used_by
        @synonyms = [:required_by, :used_in]
        @parseable = false
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
docks_app-0.0.3 lib/docks/tags/require_tag.rb
docks_app-0.0.2 lib/docks/tags/require_tag.rb
docks_app-0.0.1 lib/docks/tags/require_tag.rb