Created
June 11, 2011 21:03
-
-
Save moos3/1020958 to your computer and use it in GitHub Desktop.
Repo parser
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 | |
| attr_accessor :repo, :scm, :path, :files, :directories, :pattern | |
| # setup new repo | |
| def initialize(repo,scm,path,pattern) | |
| @repo = repo | |
| @scm = scm | |
| @path = path | |
| @files = Array.new | |
| @directories = Array.new | |
| @pattern = pattern | |
| end | |
| # get all directories | |
| def getDirectories(path) | |
| @directories << Dir[path+'/**/*/'] | |
| end | |
| # get all files in a given that matches the given pattern | |
| def getFiles(directory) | |
| Dir[directory].sort.each do |name| | |
| if File.file?(name) and name[@pattern] | |
| @files = name | |
| end | |
| end | |
| end | |
| end | |
| repo = Repo.new('include','svn', './include/', /.+.\php|inc|js|class$/) | |
| repo.getDirectories(repo.path) | |
| puts repo.directories |
Author
moos3
commented
Jun 11, 2011
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment