Class: Tatami::Couch::App
- Inherits:
-
Object
- Object
- Tatami::Couch::App
- Defined in:
- lib/tatami/app.rb
Instance Method Summary collapse
Instance Method Details
#attachments(file_path) ⇒ Object
3 4 5 6 7 8 9 10 11 12 13 14 |
# File 'lib/tatami/app.rb', line 3 def file_path Dir.chdir file_path do Dir["**/*.*"].each_with_object({}) do |path,o| ext = File.extname(path)[1..-1] base64 = [IO.read(path)].pack('m') o[path] = { "content_type" => content_type(ext), "data" => base64 } end end end |
#content_type(ext) ⇒ Object
16 17 18 19 |
# File 'lib/tatami/app.rb', line 16 def content_type ext subtype = ext.sub(/^js$/, 'javascript') "text/#{subtype}" end |