summaryrefslogtreecommitdiff
path: root/app/models/blob_viewer/csv.rb
diff options
context:
space:
mode:
Diffstat (limited to 'app/models/blob_viewer/csv.rb')
-rw-r--r--app/models/blob_viewer/csv.rb21
1 files changed, 21 insertions, 0 deletions
diff --git a/app/models/blob_viewer/csv.rb b/app/models/blob_viewer/csv.rb
new file mode 100644
index 00000000000..c26900c4d35
--- /dev/null
+++ b/app/models/blob_viewer/csv.rb
@@ -0,0 +1,21 @@
+require 'csv'
+
+module BlobViewer
+ class CSV < Base
+ include ServerSide
+
+ self.binary = false
+ self.extensions = %w(csv)
+ self.partial_name = 'csv'
+ self.switcher_icon = 'file-excel-o'
+ self.type = :rich
+
+ def parse(&block)
+ begin
+ ::CSV.parse(blob.data).each_with_index(&block)
+ rescue ::CSV::MalformedCSVError => ex
+ # TODO (rspeicher): How do we want to handle this?
+ end
+ end
+ end
+end