require 'couch/actions/base' module Couch module Actions class Routes < Base def routes say 'Static:' Dir.glob(File.join(destination_root, "_attachments/*.html")).each do |file| say ' %s' % attachment_url(file) end say 'Lists:' Dir.glob(File.join(destination_root, "lists/*")).each do |list| Dir.glob(File.join(destination_root, "views/*")).each do |view| say ' %s' % list_url(list, view) end end say 'Shows:' Dir.glob(File.join(destination_root, "shows/*")).each do |show| say ' %s' % show_url(show) say ' %s' % show_url(show, '/:id') end end protected def attachment_url(file) File.join(Couch.database, '_design', File.basename(Couch.database), File.basename(file)) end def list_url(list, view) File.join(Couch.database, '_design', File.basename(Couch.database), '_list', File.basename(view), File.basename(list, '.js')) end def show_url(show, id = '/') File.join(Couch.database, '_design', File.basename(Couch.database), '_show', File.basename(show, '.js'), id) end end end end