Created
June 13, 2011 18:18
-
-
Save moos3/1023354 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 = Array.new | |
| @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] | |
| # if name.kind_of?(Array) | |
| # @files.concat(name) | |
| # else | |
| @files << name | |
| # end | |
| end | |
| end | |
| end | |
| end | |
| output | |
| "./include/zip/ZipCodes.class" | |
| ["./include/zip/ZipCodes.class"] |
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
| #!/usr/bin/env ruby | |
| require 'rubygems' | |
| require 'Digest' | |
| require 'json' | |
| require 'tire' | |
| require 'pathname' | |
| # include needed library files. | |
| require './lib/Repo.rb' | |
| require './lib/SourceFile.rb' | |
| if ARGV[0] == '--repo' | |
| repo = ARGV[1] | |
| else | |
| puts "must pass it --repo <reponame>" | |
| exit | |
| end | |
| @files = Array.new | |
| @repo = Repo.new(repo,'svn','./'+repo+'/',/.+\.(wdsl|php|inc|js|class)$/) | |
| # file storage bucket | |
| puts @repo.files.inspect | |
| exit | |
| # | |
| #@repo.files.each do |rfile| | |
| # puts rfile.inspect | |
| # if not rfile.kind_of?(Array) | |
| # @files << SourceFile.new(File.basename(rfile),rfile,@repo.repo,File.size(rfile)) | |
| # end | |
| #end | |
| @repo.files.each do |file| | |
| puts file.to_json | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment