Sha256: e34e41bc17684d8230d0bbed1abc2b6f0781dabe9e3fa5611a8993497665f797

Contents?: true

Size: 780 Bytes

Versions: 14

Compression:

Stored size: 780 Bytes

Contents

class Dir

  def self.walk(start_dir, &blk)
    Dir["#{start_dir}/{*,.*}"].each do |item|
      blk.call item
      if File.directory?(item) && !(item =~ /\/\.$/) && !(item =~ /\/\.\.$/)
        walk(item, &blk)
      end
    end
  end

end

module Calatrava

  class Template

    def initialize(directory)
      @directory = directory
    end

    def target_name(item)
      item.sub("#{@directory}/", "")
    end

    def walk_directories(&blk)
      Dir.walk(@directory) do |item|
        if File.directory?(item)
          blk.call target_name(item)
        end
      end
    end

    def walk_files(&blk)
      Dir.walk(@directory) do |item|
        if File.file? item
          blk.call(:path => item, :name => target_name(item))
        end
      end
    end

  end

end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
calatrava-0.6.11 lib/calatrava/template.rb
calatrava-0.6.10 lib/calatrava/template.rb
calatrava-0.6.9 lib/calatrava/template.rb
calatrava-0.6.8 lib/calatrava/template.rb
calatrava-0.6.7 lib/calatrava/template.rb
calatrava-0.6.6 lib/calatrava/template.rb
calatrava-0.6.5 lib/calatrava/template.rb
calatrava-0.6.4 lib/calatrava/template.rb
calatrava-0.6.3 lib/calatrava/template.rb
calatrava-0.6.2 lib/calatrava/template.rb
calatrava-0.6.1 lib/calatrava/template.rb
calatrava-0.6.0 lib/calatrava/template.rb
calatrava-0.5.0 lib/calatrava/template.rb
calatrava-0.0.1 lib/calatrava/template.rb