Sha256: 1df4314a9f37a4c05add5df946119f93fb4aa96d5b1534b0fc8464d3f1b3b13d

Contents?: true

Size: 1.19 KB

Versions: 1

Compression:

Stored size: 1.19 KB

Contents

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

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
couch-0.2.0 lib/couch/actions/routes.rb