File: provides.rb

package info (click to toggle)
ruby-innate 2013.02.21-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 848 kB
  • ctags: 622
  • sloc: ruby: 4,340; makefile: 2
file content (31 lines) | stat: -rw-r--r-- 770 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
require 'rubygems'
require 'innate'
require 'yaml'

ARTICLES = {
  'hello' => {
    :author => 'manveru',
    :title => 'Hello, World!',
    :text => 'Some text'
  }
}

class BlogArticles
  Innate.node('/')

  # provide a content representation for requests to /<action>.yaml
  # If you request `/list.yaml`, you will get the `ARTICLES object serialized
  # to YAML.
  provide(:yaml, :type => 'text/yaml'){|action, value| value.to_yaml }

  # Since there will always be an `html` representation (the default), you have
  # to take care of it. If you simply want to return an empty page, use following.
  provide(:html){|action, value| '' }

  # The return value of this method is the `value` in the provides above.
  def list
    return ARTICLES
  end
end

Innate.start