1

Can someone point me to some documentation/libraries for working with files in a Rails app?

Specifically I need to scan folders for files and for each one read & parse some data from it. I've not done this in Ruby before so not sure where to look.

Thanks!

Meltemi
  • 37,979
  • 50
  • 195
  • 293

1 Answers1

2

Parsing files is very easy in Ruby. To do it in Rails, you simply use the Ruby file libraries. Without knowing what you want to do I can't give you any examples, but I can point you to the Ruby API.

File: http://www.ruby-doc.org/core-1.9.3/File.html

Directory: http://www.ruby-doc.org/core-1.9.3/Dir.html

Max
  • 15,157
  • 17
  • 82
  • 127
  • Thanks for the links. Feel free to take a stab at [this SO question](http://stackoverflow.com/questions/12397070/ruby-rails-traverse-folders-and-parse-metadata-to-seed-db) (no answers yet..stumper?) so I "dumbed" it down with this post so I could at least get started trying to crack it myself. – Meltemi Sep 13 '12 at 18:05
  • 1
    Note: Ruby's `File` inherits from [`IO`](http://www.ruby-doc.org/core-1.9.3/IO.html), so you need to look there for the file-reading information. Because `File` inherits from `IO`, you can use `File.open` or `File.read` instead of `IO.open` or `IO.read` if you want, for readability. – the Tin Man Sep 14 '12 at 03:47