Sha256: 861819c89599be5f7ce5585fa68a32573d3cc17b03ce203b0e6fd04031bdea9b

Contents?: true

Size: 825 Bytes

Versions: 2

Compression:

Stored size: 825 Bytes

Contents

require 'mirrors/mirror'
require 'mirrors/package_inference'

module Mirrors
  class PackageMirror < Mirror
    def name
      @subject.sub(/.*:/, '')
    end

    def fullname
      @subject
    end

    def children
      names = PackageInference.contents_of_package(@subject)
      classes = (names || [])
        .map { |n| Object.const_get(n) }
        .select { |c| c.is_a?(Module) }
        .sort_by(&:name)
      class_mirrors = mirrors(classes)

      # .map    { |pkg| pkg.sub(/#{Regexp.quote(@subject)}:.*?:.*/) }
      subpackages = PackageInference.qualified_packages
        .select { |pkg| pkg.start_with?("#{@subject}:") }
        .sort

      puts subpackages.inspect

      package_mirrors = subpackages.map { |pkg| PackageMirror.reflect(pkg) }
      package_mirrors.concat(class_mirrors)
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
mirrors-0.0.2 lib/mirrors/package_mirror.rb
mirrors-0.0.1 lib/mirrors/package_mirror.rb