Sha256: 61df279b319665ee98ef426b8a181eec5dd89e679910021601b25e82ce3e4376

Contents?: true

Size: 1.42 KB

Versions: 4

Compression:

Stored size: 1.42 KB

Contents

#!/usr/bin/env ruby

LIBDIR = 'lib'
REDIR = 'facet'
SRCDIR = 'facets'

desc "Generate facet/ redirection dir"

task :redirect do
  #puts "Creating redirection folder #{REDIR}/ ..."
  count = 0
  dest = File.join( LIBDIR, REDIR )
  FileUtils.rm_r(dest) if File.directory?(dest)
  Dir.chdir( LIBDIR ) do
    ['core','more'].each{ |d|
      from = File.join( SRCDIR, d )
      files = Dir.glob( File.join( from, '**/*.rb' ) )
      files.each { |e|
        re = Regexp.new( Regexp.escape( from + '/' ) )
        link = e.sub( re, 'facet/')
        FileUtils.mkdir_p( File.dirname( link ) )
        File.open( link, "w+" ) { |w| w << "require '#{e}'" }
        count += 1
      }
    }
  end
  puts "Created #{count} redirection files in #{REDIR}/ folder."
end

# List core methods

desc "Output a list of all methods"

task :list => [ :index_methods ] do
  puts method_list_outline
end

# Read in the facets directory and sort-out per class

METHODS = {}
MTHPATH = "lib/facets/core"

task :index_methods do
  Dir.chdir(MTHPATH) do
    dg = Dir.glob('*/**/*.rb')
    dg.each { |f|
      klass, *meth= f.split('/')
      METHODS[ klass ] ||= []
      METHODS[ klass ] << "#{meth.join('/').chomp('.rb')}"
    }
    METHODS.keys.each { |k| METHODS[k].sort! }
  end
end

def method_list_outline
  s = ''
  METHODS.keys.sort.each { |k|
  ms = METHODS[k].collect{|m| m.gsub(%r{^self\/},'::')}.sort
    s << "#{k}:\n"
    ms.each { |m| s << "  #{m}\n" }
  }
  s
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
facets-1.8.20 work/yore/Reapfile
facets-1.8.0 work/yore/Reapfile
facets-1.8.49 work/yore/Reapfile
facets-1.8.8 work/yore/Reapfile