Class: SycLink::FileImporter
- Defined in:
- lib/syclink/file_importer.rb
Constant Summary
Constants inherited from Importer
Instance Attribute Summary
Attributes inherited from Importer
Instance Method Summary collapse
Methods inherited from Importer
Constructor Details
This class inherits a constructor from SycLink::Importer
Instance Method Details
#read ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/syclink/file_importer.rb', line 5 def read root_dir = File.dirname(path).scan(/^[^\*|\?]*/).first regex = Regexp.new("(?<=#{root_dir}).*") Dir.glob(path).map do |file| next if File.directory? file url, name = if File.extname(file).upcase == ".URL" begin [File.read(file).scan(/(?<=\nURL=)(.*)$/) .flatten.first.chomp, url_name(File.basename(file, ".*"))] rescue [file, File.basename(file)] end else [file, File.basename(file)] end description = "" = (File.dirname(file).scan(regex)) [url, name, description, ] end.compact end |