Skip to content

Instantly share code, notes, and snippets.

@moos3
Created June 14, 2011 20:54
Show Gist options
  • Select an option

  • Save moos3/1025857 to your computer and use it in GitHub Desktop.

Select an option

Save moos3/1025857 to your computer and use it in GitHub Desktop.
class Repo
# class for Repos
attr_accessor :repo, :scm, :path, :files, :directories, :pattern
# setup new repo
def initialize(repo,scm,path,pattern)
@repo = repo
@scm = scm
@path = path
@files = []
@directories = Array.new
@pattern = pattern
getDirectories(path)
@directories.each do |d|
@files << getFiles(d)
end
end
# get all directories
def getDirectories(path)
@directories.concat(Dir[path+'**/*/'])
end
# get all files in a given that matches the given pattern
def getFiles(directory)
Dir[File.join(directory+'*')].sort.each do |name|
if File.file?(name) and name[@pattern]
@files << name
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment