Created
June 14, 2011 20:54
-
-
Save moos3/1025857 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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