Sha256: 0600eda26a12da06d42ba7e7e1efdc40ca4c6ec38142e3e76c9776f1d5c33170

Contents?: true

Size: 1.17 KB

Versions: 2

Compression:

Stored size: 1.17 KB

Contents

require 'rid/actions/base'

module Rid
  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(Rid.database, '_design', File.basename(Rid.database), File.basename(file))
      end

      def list_url(list, view)
        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

2 entries across 2 versions & 1 rubygems

Version Path
rid-0.3.1 lib/rid/actions/routes.rb
rid-0.3.0 lib/rid/actions/routes.rb