Sha256: 5576ba9ba5ccf5f68cf1382fe3f2cd446d19364f6b09525264e6865eeac40db0

Contents?: true

Size: 626 Bytes

Versions: 2

Compression:

Stored size: 626 Bytes

Contents

module NSWTopo
  def layers(state: nil)
    paths = layer_dirs.grep_v(Pathname.pwd).flat_map do |directory|
      Array(state).inject(directory, &:/).glob("*")
    end.sort
    log_warn "no layers installed" if paths.none?

    TreeIndenter.new(paths) do |paths|
      paths.map do |path|
        case
        when path.glob("**/*.yml").any?
          [path.basename.sub_ext(""), path.children.sort]
        when path.sub_ext("").directory?
        when path.extname == ".yml"
          path.basename.sub_ext("")
        end
      end.compact
    end.each do |indents, name|
      puts [*indents, name].join
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
nswtopo-3.0.1 lib/nswtopo/commands/layers.rb
nswtopo-3.0 lib/nswtopo/commands/layers.rb