Sha256: 8055a3a109fec7389406dc1cd7227aeb99a8d95dda57725a5085e8c2ecf3bff7
Contents?: true
Size: 727 Bytes
Versions: 5
Compression:
Stored size: 727 Bytes
Contents
# -*- coding: utf-8 -*- require 'ostruct' cwd = File.expand_path( File.join( File.dirname(__FILE__), "..", "..", "lib" ) ) $:.unshift(cwd) unless $:.include?(cwd) require 'treevisitor' # # Find directories without subdirectories # class DirWithoutSubDir < TreeVisitor::BasicTreeNodeVisitor def initialize super @stack = [] @nr = 0 end def enter_node( pathname ) @nr += 1 info = OpenStruct.new(:nr => @nr, :pathname => pathname) @stack.push( info ) end def exit_node( pathname ) info = @stack.pop if info.nr == @nr puts "leaf: #{pathname}" end end end dtw = TreeVisitor::DirTreeWalker.new( ".." ) dtw.ignore /^\./ dtw.visit_file=false dtw.run( DirWithoutSubDir.new )
Version data entries
5 entries across 5 versions & 2 rubygems