Sha256: a36ef8e9a5231388d186fb6a85f79ed059b7f180e8f50607cef6d5c863a49e2e
Contents?: true
Size: 1.55 KB
Versions: 5
Compression:
Stored size: 1.55 KB
Contents
require 'rid/actions/base' module Rid module Actions class Routes < Base def routes static_files = Dir.glob(File.join(destination_root, "_attachments/*.html")) longest_name = (%w[show list] + static_files.map { |f| File.basename(f, '.html') }).map(&:length).sort.last + 1 unless static_files.empty? say 'Static' static_files.each do |file| say ' %s %s' % [(File.basename(file, '.html') + ":").ljust(longest_name), attachment_url(file)] end end Dir.glob(File.join(destination_root, "views/*")).each do |model| model_name = File.basename(model).singularize say model_name.humanize Dir.glob(File.join(destination_root, "shows/#{model_name}*")).each do |show| say ' %s %s' % ["show:".ljust(longest_name), show_url(show, '/:id')] end Dir.glob(File.join(destination_root, "views/#{model_name}*")).each do |view| say ' %s %s' % ["list:".ljust(longest_name), list_url(view, model)] end end end protected def attachment_url(file) File.join(Rid.database, '_design', File.basename(Rid.database), File.basename(file)) end def list_url(view, list) File.join(Rid.database, '_design', File.basename(Rid.database), '_list', File.basename(view), File.basename(list, '.js')) end def show_url(show, id = '/') File.join(Rid.database, '_design', File.basename(Rid.database), '_show', File.basename(show, '.js'), id) end end end end
Version data entries
5 entries across 5 versions & 1 rubygems
Version | Path |
---|---|
rid-0.5.2 | lib/rid/actions/routes.rb |
rid-0.5.1 | lib/rid/actions/routes.rb |
rid-0.5.0 | lib/rid/actions/routes.rb |
rid-0.4.1 | lib/rid/actions/routes.rb |
rid-0.4.0 | lib/rid/actions/routes.rb |