class Trop::FileFinder

Public Class Methods

collect_dir_tree(path) click to toggle source
# File lib/trop/file_finder.rb, line 164
def self.collect_dir_tree(path)
  finder = FileFinder.new
  finder.collect_dir_tree(path)
end
collect_md_tree(path) click to toggle source
# File lib/trop/file_finder.rb, line 159
def self.collect_md_tree(path)
  finder = FileFinder.new
  finder.collect_md_tree(path)
end
collect_sorted_readme(path) click to toggle source
# File lib/trop/file_finder.rb, line 154
def self.collect_sorted_readme(path)
  finder = FileFinder.new
  finder.collect_sorted_readme(File.expand_path(path))
end
my_gemspec_fffind(*path) click to toggle source
# File lib/trop/file_finder.rb, line 169
def self.my_gemspec_fffind(*path)
  finder = FileFinder.new
  finder.collect_gem_tree(*path)
end
new() click to toggle source
# File lib/trop/file_finder.rb, line 13
def initialize
end

Public Instance Methods

collect_dir_tree(spath) click to toggle source
# File lib/trop/file_finder.rb, line 64
def collect_dir_tree(spath)
  @dirs = []

  files = dffind(spath)
  return files
end
collect_gem_tree(path) click to toggle source
# File lib/trop/file_finder.rb, line 71
def collect_gem_tree(path)
  files = []
  if path.is_a? Array
    path.each {|s| files += fffind(s) }
  else
    files += fffind(path)
  end

  out=[]
  files.each do |f|
    f = f.delete_prefix('/home/werner/rails/trop/')
    next unless f.to_s.end_with?('.rb')

    out << f
  end


  return out
end
collect_md_tree(spath) click to toggle source
# File lib/trop/file_finder.rb, line 130
def collect_md_tree(spath)
  @mds = []

  files = fffind(spath)
  files.each do |page|
    page = Pathname.new(page)
    next if page.directory?
    fbase = page.basename.to_s.upcase
    if page.file? && fbase.include?('.MD')
      puts "Found : #{page.to_path}".cyan   if $DEBUG
      @mds << page.to_s
    else
      Sh.info "skip: #{page.to_path}".blue if $DEBUG
    end
  end
  @mds
end
collect_readme_md_tree(spath) click to toggle source
# File lib/trop/file_finder.rb, line 112
def collect_readme_md_tree(spath)
  @readmes = []

  files = fffind(spath)
  files.each do |page|
    page = Pathname.new(page)
    next if page.directory?
    fbase = page.basename.to_s.upcase
    if page.file? && fbase.include?('README') && fbase.include?('.MD')
      puts "Found : #{page.to_path}".cyan   if $DEBUG
      @readmes << page.to_s
    else
      Sh.info "skip: #{page.to_path}".blue if $DEBUG
    end
  end
  @readmes
end
collect_sorted_readme(spath) click to toggle source

@param spath to search in

# File lib/trop/file_finder.rb, line 91
def collect_sorted_readme(spath)
  @readmes = []

  files = fffind(spath)
  files.each do |page|
    page = Pathname.new(page)
    next if page.directory?
    fbase = page.basename.to_s.upcase
    if page.file? && fbase.include?('README') ##&& fbase.include?('.MD')
      puts "Found : #{page.to_path}".red  if Sh.verbose?
      @readmes << page.to_s
    else
      Sh.info "skip: #{page.to_path}".blue  if $DEBUG
    end
  end
  @readmes = @readmes.sort
  @readmes = @readmes.uniq
  res1, res2, res3 = filter_pages(@readmes)
  return res1, res2, res3
end
dffind(_path) click to toggle source
# File lib/trop/file_finder.rb, line 30
def dffind(_path)
  _path = Dir.getwd.to_s if _path.equal?('.')
  _path = File.expand_path(_path)
  @path = _path
  rule = FileFind.new(
      :ftype => 'directory',
      :follow => true,
      :path => _path.to_s

  )
  tree = rule.find
  tree
end
fffind(_path) click to toggle source
# File lib/trop/file_finder.rb, line 16
def fffind(_path)
  _path = Dir.getwd.to_s if _path.equal?('.')
  _path = File.expand_path(_path)
  @path = _path
  rule = FileFind.new(
      :ftype => 'file',
      :follow => true,
      :path => _path.to_s

  )
  tree = rule.find
  tree
end
filter_pages(pages) click to toggle source
# File lib/trop/file_finder.rb, line 44
def filter_pages(pages)
  tops = []
  generics = []
  contents = []
  pages.each do |p|
    if p.start_with?(File.join(@path, 'doc/README.md'))
      tops << p
    elsif p.start_with?(File.join(@path, 'generic/doc/README.md'))
      tops << p 
    elsif p.start_with?(File.join(@path, 'doc/'))
      tops << p
    elsif p.start_with?(File.join(@path, 'generic/'))
      generics << p
    else
      contents << p
    end
  end
  return tops, generics, contents
end