class Borrower::Manifest
Attributes
directories[R]
files[R]
Public Class Methods
new()
click to toggle source
# File lib/borrower/manifest.rb, line 9 def initialize @files = {} @directories = [] if Manifest::ConfigFile.present? @manifest_file = Manifest::ConfigFile.new @files = @files.merge( @manifest_file.files ) @directories = @directories.push( *@manifest_file.directories ) end end
Public Instance Methods
dir(dir)
click to toggle source
# File lib/borrower/manifest.rb, line 24 def dir dir @directories.push dir end
file(name, path)
click to toggle source
# File lib/borrower/manifest.rb, line 20 def file name, path @files[name] = path end
find(file)
click to toggle source
# File lib/borrower/manifest.rb, line 28 def find file obj = Content::Item.new(file) return file if obj.remote? || obj.exists? path = check_for_file_in_manifest_files(file) || false return path if path path = check_for_file_in_manifest_directories(file) || false return path if path path = check_for_file_with_expanded_path(file) || false return path if path raise "Could not file #{file}" end
Private Instance Methods
check_for_file_in_manifest_directories(file)
click to toggle source
# File lib/borrower/manifest.rb, line 59 def check_for_file_in_manifest_directories file matches = [] directories.each do |dir| Dir[File.join( dir, '**/*' )].each do |possibility| matches << possibility if possibility.match( Regexp.escape(file) ) end end path = matches.sort { |a,b| a.length <=> b.length }.first end
check_for_file_in_manifest_files(file)
click to toggle source
# File lib/borrower/manifest.rb, line 55 def check_for_file_in_manifest_files file files.fetch(file) { false } end
check_for_file_with_expanded_path(file)
click to toggle source
# File lib/borrower/manifest.rb, line 46 def check_for_file_with_expanded_path file path = File.expand_path(file) if File.exists? path return path else return false end end