Module: Dahistory::Class_Methods

Included in:
Dahistory
Defined in:
lib/Dahistory.rb

Instance Method Summary collapse

Instance Method Details

#find_file_copy(file, *raw_dirs) ⇒ Object



129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
# File 'lib/Dahistory.rb', line 129

def find_file_copy file, *raw_dirs
  standard = File.read(file).gsub("\r", "")
  found    = nil
  dirs     = raw_dirs.flatten
  
  dirs.each { |path| 
    full = File.join( File.expand_path(path), "/*")
    files = Dir.glob( full, File::FNM_DOTMATCH ).select { |unk| File.file?(unk) }

    found = files.detect { |f| 
      raw = File.read(f)
      raw.gsub("\r", "") == standard
    }

    break if found
  }

  found
end