All pastes #740853 Raw Edit

Miscellany

public text v1 · immutable
·published 2007-10-18 09:22 UTC
rendered paste body
class Adaptor
    
    def initialize(clientbucket = '/var/lib/puppet/clientbucket')
        @clientbucket = clientbucket
    end
        
    def get_newest_contents_file(filename)
        regex = Regexp.compile(Regexp.escape(filename))
        Dir.chdir(@clientbucket)
        Dir['**/paths'].each do |path|
            File.open(path) do |contents|
                contents.grep(regex).max { |a,b| File.mtime(a) <=> File.mtime(b) }
                puts path
                end
            end
        end
    end

end