rjspotter-ramaze 2009.06.29
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +3 -0
- data/.mailmap +25 -0
- data/MANIFEST +502 -0
- data/README.md +457 -0
- data/Rakefile +88 -0
- data/benchmark/bench_templates/bench.rb +67 -0
- data/benchmark/bench_templates/view/large.erb +79 -0
- data/benchmark/bench_templates/view/large.haml +41 -0
- data/benchmark/bench_templates/view/large.xhtml +79 -0
- data/benchmark/bench_templates/view/small.erb +21 -0
- data/benchmark/bench_templates/view/small.haml +12 -0
- data/benchmark/bench_templates/view/small.xhtml +21 -0
- data/benchmark/results.txt +131 -0
- data/benchmark/run.rb +355 -0
- data/benchmark/suite/minimal.rb +11 -0
- data/benchmark/suite/no_informer.rb +7 -0
- data/benchmark/suite/no_sessions.rb +9 -0
- data/benchmark/suite/no_template.rb +7 -0
- data/benchmark/suite/simple.rb +5 -0
- data/benchmark/suite/template_erubis.rb +8 -0
- data/benchmark/suite/template_etanni.rb +8 -0
- data/benchmark/suite/template_ezamar.rb +8 -0
- data/benchmark/suite/template_haml.rb +13 -0
- data/benchmark/suite/template_liquid.rb +11 -0
- data/benchmark/suite/template_markaby.rb +9 -0
- data/benchmark/suite/template_nagoro.rb +8 -0
- data/benchmark/suite/template_redcloth.rb +13 -0
- data/benchmark/suite/template_tenjin.rb +8 -0
- data/benchmark/test.rb +35 -0
- data/bin/ramaze +15 -0
- data/doc/AUTHORS +44 -0
- data/doc/CHANGELOG +17362 -0
- data/doc/COPYING +56 -0
- data/doc/FAQ +92 -0
- data/doc/GPL +339 -0
- data/doc/INSTALL +92 -0
- data/doc/LEGAL +26 -0
- data/doc/TODO +29 -0
- data/doc/meta/announcement.txt +146 -0
- data/doc/meta/configuration.txt +163 -0
- data/doc/meta/internals.txt +278 -0
- data/doc/meta/users.kml +64 -0
- data/doc/tutorial/todolist.html +1379 -0
- data/doc/tutorial/todolist.txt +920 -0
- data/examples/app/auth/layout/auth.xhtml +25 -0
- data/examples/app/auth/start.rb +23 -0
- data/examples/app/auth/view/index.xhtml +4 -0
- data/examples/app/auth/view/login.xhtml +20 -0
- data/examples/app/auth/view/secret.xhtml +1 -0
- data/examples/app/blog/README +3 -0
- data/examples/app/blog/app.rb +69 -0
- data/examples/app/blog/config.ru +17 -0
- data/examples/app/blog/controller/comment.rb +45 -0
- data/examples/app/blog/controller/entry.rb +85 -0
- data/examples/app/blog/controller/init.rb +86 -0
- data/examples/app/blog/controller/main.rb +20 -0
- data/examples/app/blog/controller/tag.rb +9 -0
- data/examples/app/blog/layout/default.nag +31 -0
- data/examples/app/blog/model/comment.rb +58 -0
- data/examples/app/blog/model/entry.rb +89 -0
- data/examples/app/blog/model/init.rb +15 -0
- data/examples/app/blog/model/tag.rb +36 -0
- data/examples/app/blog/public/css/screen.css +273 -0
- data/examples/app/blog/spec/blog.rb +87 -0
- data/examples/app/blog/start.rb +5 -0
- data/examples/app/blog/view/comment/form.nag +10 -0
- data/examples/app/blog/view/comment/show.nag +16 -0
- data/examples/app/blog/view/entry/edit.nag +14 -0
- data/examples/app/blog/view/entry/feed.atom.nag +8 -0
- data/examples/app/blog/view/entry/feed.rss.nag +7 -0
- data/examples/app/blog/view/entry/index.nag +7 -0
- data/examples/app/blog/view/entry/new.nag +13 -0
- data/examples/app/blog/view/entry/show.nag +36 -0
- data/examples/app/blog/view/feed.atom.nag +18 -0
- data/examples/app/blog/view/feed.rss.nag +25 -0
- data/examples/app/blog/view/index.nag +6 -0
- data/examples/app/blog/view/tag/index.nag +5 -0
- data/examples/app/chat/layout/default.xhtml +13 -0
- data/examples/app/chat/model/history.rb +38 -0
- data/examples/app/chat/model/message.rb +7 -0
- data/examples/app/chat/public/css/chat.css +9 -0
- data/examples/app/chat/public/js/chat.js +28 -0
- data/examples/app/chat/public/js/jquery.js +3436 -0
- data/examples/app/chat/start.rb +39 -0
- data/examples/app/chat/view/chat.xhtml +9 -0
- data/examples/app/chat/view/index.xhtml +7 -0
- data/examples/app/localization/locale/de.yaml +5 -0
- data/examples/app/localization/locale/en.yaml +5 -0
- data/examples/app/localization/locale/ja.yaml +5 -0
- data/examples/app/localization/start.rb +48 -0
- data/examples/app/sourceview/public/coderay.css +104 -0
- data/examples/app/sourceview/public/images/file.gif +0 -0
- data/examples/app/sourceview/public/images/folder.gif +0 -0
- data/examples/app/sourceview/public/images/tv-collapsable-last.gif +0 -0
- data/examples/app/sourceview/public/images/tv-collapsable.gif +0 -0
- data/examples/app/sourceview/public/images/tv-expandable-last.gif +0 -0
- data/examples/app/sourceview/public/images/tv-expandable.gif +0 -0
- data/examples/app/sourceview/public/images/tv-item-last.gif +0 -0
- data/examples/app/sourceview/public/images/tv-item.gif +0 -0
- data/examples/app/sourceview/public/jquery.js +11 -0
- data/examples/app/sourceview/public/jquery.treeview.css +48 -0
- data/examples/app/sourceview/public/jquery.treeview.js +223 -0
- data/examples/app/sourceview/public/sourceview.js +52 -0
- data/examples/app/sourceview/start.rb +79 -0
- data/examples/app/sourceview/view/index.haml +59 -0
- data/examples/app/todolist/controller/init.rb +10 -0
- data/examples/app/todolist/controller/task.rb +39 -0
- data/examples/app/todolist/layout/default.xhtml +14 -0
- data/examples/app/todolist/model/init.rb +14 -0
- data/examples/app/todolist/model/task.rb +39 -0
- data/examples/app/todolist/public/css/screen.css +63 -0
- data/examples/app/todolist/public/favicon.ico +0 -0
- data/examples/app/todolist/start.rb +11 -0
- data/examples/app/todolist/view/index.xhtml +29 -0
- data/examples/app/upload/start.rb +19 -0
- data/examples/app/upload/view/index.xhtml +25 -0
- data/examples/app/whywiki/spec/whywiki.rb +58 -0
- data/examples/app/whywiki/start.rb +46 -0
- data/examples/app/whywiki/template/edit.xhtml +14 -0
- data/examples/app/whywiki/template/show.xhtml +18 -0
- data/examples/app/wikore/spec/wikore.rb +109 -0
- data/examples/app/wikore/src/controller.rb +78 -0
- data/examples/app/wikore/src/model.rb +56 -0
- data/examples/app/wikore/start.rb +9 -0
- data/examples/app/wikore/view/index.xhtml +8 -0
- data/examples/app/wiktacular/README +2 -0
- data/examples/app/wiktacular/mkd/link/2007-07-20_19-45-51.mkd +1 -0
- data/examples/app/wiktacular/mkd/link/current.mkd +1 -0
- data/examples/app/wiktacular/mkd/main/2007-07-20_16-31-33.mkd +1 -0
- data/examples/app/wiktacular/mkd/main/2007-07-20_19-21-12.mkd +1 -0
- data/examples/app/wiktacular/mkd/main/2007-07-20_19-23-10.mkd +2 -0
- data/examples/app/wiktacular/mkd/main/2007-07-20_19-45-07.mkd +2 -0
- data/examples/app/wiktacular/mkd/main/current.mkd +2 -0
- data/examples/app/wiktacular/mkd/markdown/current.mkd +3 -0
- data/examples/app/wiktacular/mkd/testing/2007-07-20_16-43-46.mkd +2 -0
- data/examples/app/wiktacular/mkd/testing/2007-07-20_19-43-50.mkd +3 -0
- data/examples/app/wiktacular/mkd/testing/2007-07-21_18-46-01.mkd +11 -0
- data/examples/app/wiktacular/mkd/testing/2007-07-21_18-46-32.mkd +13 -0
- data/examples/app/wiktacular/mkd/testing/2007-07-21_18-47-08.mkd +17 -0
- data/examples/app/wiktacular/mkd/testing/2007-07-21_18-47-54.mkd +17 -0
- data/examples/app/wiktacular/mkd/testing/current.mkd +17 -0
- data/examples/app/wiktacular/public/favicon.ico +0 -0
- data/examples/app/wiktacular/public/screen.css +72 -0
- data/examples/app/wiktacular/spec/wiktacular.rb +157 -0
- data/examples/app/wiktacular/src/controller.rb +55 -0
- data/examples/app/wiktacular/src/model.rb +102 -0
- data/examples/app/wiktacular/start.rb +8 -0
- data/examples/app/wiktacular/template/edit.xhtml +6 -0
- data/examples/app/wiktacular/template/html_layout.xhtml +27 -0
- data/examples/app/wiktacular/template/index.xhtml +9 -0
- data/examples/app/wiktacular/template/new.xhtml +6 -0
- data/examples/basic/element.rb +47 -0
- data/examples/basic/gestalt.rb +26 -0
- data/examples/basic/hello.rb +14 -0
- data/examples/basic/layout.rb +28 -0
- data/examples/basic/linking.rb +29 -0
- data/examples/basic/partial.rb +26 -0
- data/examples/basic/simple.rb +52 -0
- data/examples/helpers/cache.rb +33 -0
- data/examples/helpers/form_with_sequel.rb +24 -0
- data/examples/helpers/httpdigest.rb +107 -0
- data/examples/helpers/identity.rb +18 -0
- data/examples/helpers/nitro_form.rb +23 -0
- data/examples/helpers/paginate.rb +71 -0
- data/examples/helpers/rest.rb +28 -0
- data/examples/helpers/simple_captcha.rb +29 -0
- data/examples/misc/css.rb +37 -0
- data/examples/misc/facebook.rb +159 -0
- data/examples/misc/memleak_detector.rb +37 -0
- data/examples/misc/nagoro_element.rb +43 -0
- data/examples/misc/ramaise.rb +132 -0
- data/examples/misc/rapp.rb +56 -0
- data/examples/misc/sequel_scaffolding.rb +34 -0
- data/examples/misc/serve_directory.rb +6 -0
- data/examples/templates/template_erubis.rb +52 -0
- data/examples/templates/template_ezamar.rb +51 -0
- data/examples/templates/template_haml.rb +49 -0
- data/examples/templates/template_liquid.rb +66 -0
- data/examples/templates/template_markaby.rb +57 -0
- data/examples/templates/template_nagoro.rb +50 -0
- data/examples/templates/template_redcloth.rb +58 -0
- data/examples/templates/template_remarkably.rb +54 -0
- data/examples/templates/template_tenjin.rb +52 -0
- data/examples/templates/view/external.haml +22 -0
- data/examples/templates/view/external.liquid +28 -0
- data/examples/templates/view/external.mab +30 -0
- data/examples/templates/view/external.nag +28 -0
- data/examples/templates/view/external.redcloth +19 -0
- data/examples/templates/view/external.rem +30 -0
- data/examples/templates/view/external.rhtml +28 -0
- data/examples/templates/view/external.tenjin +28 -0
- data/examples/templates/view/external.zmr +28 -0
- data/lib/proto/app.rb +14 -0
- data/lib/proto/config.ru +20 -0
- data/lib/proto/controller/init.rb +11 -0
- data/lib/proto/controller/main.rb +20 -0
- data/lib/proto/layout/default.xhtml +24 -0
- data/lib/proto/model/init.rb +4 -0
- data/lib/proto/public/.htaccess +24 -0
- data/lib/proto/public/css/screen.css +30 -0
- data/lib/proto/public/dispatch.fcgi +11 -0
- data/lib/proto/public/favicon.ico +0 -0
- data/lib/proto/public/js/jquery.js +4376 -0
- data/lib/proto/public/ramaze.png +0 -0
- data/lib/proto/spec/main.rb +20 -0
- data/lib/proto/start.rb +8 -0
- data/lib/proto/view/index.xhtml +41 -0
- data/lib/ramaze.rb +87 -0
- data/lib/ramaze/app.rb +124 -0
- data/lib/ramaze/cache.rb +19 -0
- data/lib/ramaze/cache/localmemcache.rb +56 -0
- data/lib/ramaze/cache/memcache.rb +124 -0
- data/lib/ramaze/cache/sequel.rb +82 -0
- data/lib/ramaze/contrib/addressable_route.rb +55 -0
- data/lib/ramaze/contrib/app_graph.rb +64 -0
- data/lib/ramaze/contrib/email.rb +88 -0
- data/lib/ramaze/contrib/facebook.rb +23 -0
- data/lib/ramaze/contrib/facebook/facebook.rb +171 -0
- data/lib/ramaze/contrib/gettext.rb +113 -0
- data/lib/ramaze/contrib/gettext/mo.rb +155 -0
- data/lib/ramaze/contrib/gettext/parser.rb +46 -0
- data/lib/ramaze/contrib/gettext/po.rb +109 -0
- data/lib/ramaze/contrib/gzip_filter.rb +1 -0
- data/lib/ramaze/contrib/maruku_uv.rb +59 -0
- data/lib/ramaze/contrib/profiling.rb +36 -0
- data/lib/ramaze/contrib/rest.rb +22 -0
- data/lib/ramaze/contrib/sequel/create_join.rb +26 -0
- data/lib/ramaze/contrib/sequel/form_field.rb +129 -0
- data/lib/ramaze/contrib/sequel/image.rb +196 -0
- data/lib/ramaze/contrib/sequel/relation.rb +98 -0
- data/lib/ramaze/controller.rb +104 -0
- data/lib/ramaze/controller/default.rb +12 -0
- data/lib/ramaze/current.rb +7 -0
- data/lib/ramaze/files.rb +24 -0
- data/lib/ramaze/gestalt.rb +132 -0
- data/lib/ramaze/helper.rb +13 -0
- data/lib/ramaze/helper/auth.rb +84 -0
- data/lib/ramaze/helper/bench.rb +41 -0
- data/lib/ramaze/helper/cache.rb +117 -0
- data/lib/ramaze/helper/disqus.rb +26 -0
- data/lib/ramaze/helper/flash.rb +62 -0
- data/lib/ramaze/helper/form.rb +127 -0
- data/lib/ramaze/helper/formatting.rb +189 -0
- data/lib/ramaze/helper/gestalt.rb +47 -0
- data/lib/ramaze/helper/gravatar.rb +79 -0
- data/lib/ramaze/helper/httpdigest.rb +97 -0
- data/lib/ramaze/helper/identity.rb +119 -0
- data/lib/ramaze/helper/layout.rb +97 -0
- data/lib/ramaze/helper/link.rb +56 -0
- data/lib/ramaze/helper/localize.rb +138 -0
- data/lib/ramaze/helper/markaby.rb +31 -0
- data/lib/ramaze/helper/maruku.rb +16 -0
- data/lib/ramaze/helper/nitroform.rb +14 -0
- data/lib/ramaze/helper/pager.rb +367 -0
- data/lib/ramaze/helper/paginate.rb +242 -0
- data/lib/ramaze/helper/partial.rb +100 -0
- data/lib/ramaze/helper/remarkably.rb +14 -0
- data/lib/ramaze/helper/request_accessor.rb +16 -0
- data/lib/ramaze/helper/sequel.rb +55 -0
- data/lib/ramaze/helper/sequel_form.rb +284 -0
- data/lib/ramaze/helper/simple_captcha.rb +61 -0
- data/lib/ramaze/helper/stack.rb +75 -0
- data/lib/ramaze/helper/tagz.rb +19 -0
- data/lib/ramaze/helper/thread.rb +17 -0
- data/lib/ramaze/helper/ultraviolet.rb +46 -0
- data/lib/ramaze/helper/user.rb +229 -0
- data/lib/ramaze/helper/xhtml.rb +34 -0
- data/lib/ramaze/log.rb +39 -0
- data/lib/ramaze/log/analogger.rb +39 -0
- data/lib/ramaze/log/growl.rb +38 -0
- data/lib/ramaze/log/hub.rb +41 -0
- data/lib/ramaze/log/informer.rb +129 -0
- data/lib/ramaze/log/knotify.rb +28 -0
- data/lib/ramaze/log/logger.rb +26 -0
- data/lib/ramaze/log/logging.rb +83 -0
- data/lib/ramaze/log/rotatinginformer.rb +168 -0
- data/lib/ramaze/log/syslog.rb +51 -0
- data/lib/ramaze/log/xosd.rb +92 -0
- data/lib/ramaze/middleware_compiler.rb +13 -0
- data/lib/ramaze/plugin.rb +69 -0
- data/lib/ramaze/reloader.rb +172 -0
- data/lib/ramaze/reloader/watch_inotify.rb +85 -0
- data/lib/ramaze/reloader/watch_stat.rb +58 -0
- data/lib/ramaze/request.rb +115 -0
- data/lib/ramaze/response.rb +36 -0
- data/lib/ramaze/setup.rb +123 -0
- data/lib/ramaze/snippets.rb +22 -0
- data/lib/ramaze/snippets/array/put_within.rb +44 -0
- data/lib/ramaze/snippets/binding/locals.rb +25 -0
- data/lib/ramaze/snippets/blankslate.rb +7 -0
- data/lib/ramaze/snippets/fiber.rb +63 -0
- data/lib/ramaze/snippets/kernel/pretty_inspect.rb +21 -0
- data/lib/ramaze/snippets/metaid.rb +17 -0
- data/lib/ramaze/snippets/numeric/filesize_format.rb +32 -0
- data/lib/ramaze/snippets/numeric/time.rb +63 -0
- data/lib/ramaze/snippets/object/__dir__.rb +29 -0
- data/lib/ramaze/snippets/object/instance_variable_defined.rb +19 -0
- data/lib/ramaze/snippets/object/pretty.rb +16 -0
- data/lib/ramaze/snippets/object/scope.rb +18 -0
- data/lib/ramaze/snippets/ordered_set.rb +51 -0
- data/lib/ramaze/snippets/proc/locals.rb +19 -0
- data/lib/ramaze/snippets/ramaze/acquire.rb +31 -0
- data/lib/ramaze/snippets/ramaze/deprecated.rb +23 -0
- data/lib/ramaze/snippets/ramaze/dictionary.rb +400 -0
- data/lib/ramaze/snippets/ramaze/fiber.rb +24 -0
- data/lib/ramaze/snippets/ramaze/struct.rb +45 -0
- data/lib/ramaze/snippets/string/camel_case.rb +21 -0
- data/lib/ramaze/snippets/string/color.rb +31 -0
- data/lib/ramaze/snippets/string/end_with.rb +20 -0
- data/lib/ramaze/snippets/string/esc.rb +34 -0
- data/lib/ramaze/snippets/string/ord.rb +21 -0
- data/lib/ramaze/snippets/string/snake_case.rb +21 -0
- data/lib/ramaze/snippets/string/start_with.rb +19 -0
- data/lib/ramaze/snippets/string/unindent.rb +28 -0
- data/lib/ramaze/snippets/thread/into.rb +18 -0
- data/lib/ramaze/spec.rb +33 -0
- data/lib/ramaze/spec/bacon.rb +34 -0
- data/lib/ramaze/spec/helper/bacon.rb +8 -0
- data/lib/ramaze/spec/helper/pretty_output.rb +82 -0
- data/lib/ramaze/spec/helper/snippets.rb +16 -0
- data/lib/ramaze/spec/helper/template_examples.rb +19 -0
- data/lib/ramaze/tool/bin.rb +340 -0
- data/lib/ramaze/tool/create.rb +48 -0
- data/lib/ramaze/tool/project_creator.rb +111 -0
- data/lib/ramaze/version.rb +3 -0
- data/lib/ramaze/view.rb +39 -0
- data/lib/ramaze/view/erubis.rb +23 -0
- data/lib/ramaze/view/ezamar.rb +23 -0
- data/lib/ramaze/view/gestalt.rb +14 -0
- data/lib/ramaze/view/haml.rb +16 -0
- data/lib/ramaze/view/liquid.rb +100 -0
- data/lib/ramaze/view/maruku.rb +15 -0
- data/lib/ramaze/view/nagoro.rb +44 -0
- data/lib/ramaze/view/nagoro/render_partial.rb +32 -0
- data/lib/ramaze/view/redcloth.rb +21 -0
- data/lib/ramaze/view/remarkably.rb +21 -0
- data/lib/ramaze/view/sass.rb +21 -0
- data/lib/ramaze/view/tagz.rb +63 -0
- data/lib/ramaze/view/tenjin.rb +32 -0
- data/lib/vendor/etag.rb +22 -0
- data/lib/vendor/route_exceptions.rb +42 -0
- data/ramaze.gemspec +85 -0
- data/spec/contrib/addressable_route.rb +32 -0
- data/spec/contrib/rest.rb +28 -0
- data/spec/examples/caching.rb +16 -0
- data/spec/examples/css.rb +14 -0
- data/spec/examples/element.rb +15 -0
- data/spec/examples/hello.rb +10 -0
- data/spec/examples/helpers/httpdigest.rb +64 -0
- data/spec/examples/linking.rb +17 -0
- data/spec/examples/simple.rb +40 -0
- data/spec/examples/templates/template_erubis.rb +10 -0
- data/spec/examples/templates/template_ezamar.rb +10 -0
- data/spec/examples/templates/template_haml.rb +10 -0
- data/spec/examples/templates/template_liquid.rb +10 -0
- data/spec/examples/templates/template_markaby.rb +11 -0
- data/spec/examples/templates/template_nagoro.rb +10 -0
- data/spec/examples/templates/template_redcloth.rb +10 -0
- data/spec/examples/templates/template_remarkably.rb +10 -0
- data/spec/examples/templates/template_tenjin.rb +10 -0
- data/spec/helper.rb +9 -0
- data/spec/ramaze/action/render.rb +21 -0
- data/spec/ramaze/action/view/bar.xhtml +1 -0
- data/spec/ramaze/action/view/instancevars/layout.xhtml +1 -0
- data/spec/ramaze/action/view/other_wrapper.erb +1 -0
- data/spec/ramaze/action/view/other_wrapper.xhtml +1 -0
- data/spec/ramaze/action/view/single_wrapper.xhtml +1 -0
- data/spec/ramaze/action/view/sub/sub_wrapper.erb +1 -0
- data/spec/ramaze/action/view/sub/sub_wrapper.xhtml +1 -0
- data/spec/ramaze/app.rb +47 -0
- data/spec/ramaze/bin/ramaze.rb +91 -0
- data/spec/ramaze/cache/localmemcache.rb +49 -0
- data/spec/ramaze/cache/memcache.rb +60 -0
- data/spec/ramaze/cache/sequel.rb +51 -0
- data/spec/ramaze/controller/actionless_templates.rb +36 -0
- data/spec/ramaze/controller/lonely_mapping.rb +16 -0
- data/spec/ramaze/controller/mapping.rb +43 -0
- data/spec/ramaze/controller/provide_inheritance.rb +47 -0
- data/spec/ramaze/controller/resolve.rb +30 -0
- data/spec/ramaze/controller/subclass.rb +36 -0
- data/spec/ramaze/controller/template_resolving.rb +77 -0
- data/spec/ramaze/controller/view/bar.xhtml +1 -0
- data/spec/ramaze/controller/view/base/another.xhtml +1 -0
- data/spec/ramaze/controller/view/greet.xhtml +1 -0
- data/spec/ramaze/controller/view/list.xhtml +1 -0
- data/spec/ramaze/controller/view/other/greet/other.xhtml +1 -0
- data/spec/ramaze/controller/view/other_wrapper.xhtml +1 -0
- data/spec/ramaze/dispatcher/directory.rb +69 -0
- data/spec/ramaze/dispatcher/file.rb +71 -0
- data/spec/ramaze/dispatcher/public/favicon.ico +0 -0
- data/spec/ramaze/dispatcher/public/file name.txt +1 -0
- data/spec/ramaze/dispatcher/public/test_download.css +141 -0
- data/spec/ramaze/error.rb +88 -0
- data/spec/ramaze/files.rb +29 -0
- data/spec/ramaze/files/public_1/plain.txt +1 -0
- data/spec/ramaze/files/public_2/rich.txt +1 -0
- data/spec/ramaze/gestalt.rb +135 -0
- data/spec/ramaze/helper/auth.rb +83 -0
- data/spec/ramaze/helper/bench.rb +18 -0
- data/spec/ramaze/helper/cache.rb +124 -0
- data/spec/ramaze/helper/flash.rb +41 -0
- data/spec/ramaze/helper/form.rb +356 -0
- data/spec/ramaze/helper/formatting.rb +111 -0
- data/spec/ramaze/helper/gestalt.rb +15 -0
- data/spec/ramaze/helper/gravatar.rb +40 -0
- data/spec/ramaze/helper/httpdigest.rb +144 -0
- data/spec/ramaze/helper/layout.rb +79 -0
- data/spec/ramaze/helper/layout/default.xhtml +5 -0
- data/spec/ramaze/helper/link.rb +70 -0
- data/spec/ramaze/helper/localize.rb +62 -0
- data/spec/ramaze/helper/maruku.rb +19 -0
- data/spec/ramaze/helper/pager.rb +96 -0
- data/spec/ramaze/helper/paginate.rb +68 -0
- data/spec/ramaze/helper/request_accessor.rb +19 -0
- data/spec/ramaze/helper/sequel_form.rb +91 -0
- data/spec/ramaze/helper/simple_captcha.rb +45 -0
- data/spec/ramaze/helper/stack.rb +86 -0
- data/spec/ramaze/helper/user.rb +72 -0
- data/spec/ramaze/helper/view/locals.xhtml +1 -0
- data/spec/ramaze/helper/view/loop.xhtml +4 -0
- data/spec/ramaze/helper/view/num.xhtml +1 -0
- data/spec/ramaze/helper/view/partial.xhtml +1 -0
- data/spec/ramaze/helper/view/recursive.xhtml +8 -0
- data/spec/ramaze/helper/view/recursive_local_ivars.xhtml +7 -0
- data/spec/ramaze/helper/view/recursive_locals.xhtml +7 -0
- data/spec/ramaze/helper/view/test_template.xhtml +1 -0
- data/spec/ramaze/helper/xhtml.rb +32 -0
- data/spec/ramaze/log/informer.rb +73 -0
- data/spec/ramaze/log/logging.rb +63 -0
- data/spec/ramaze/log/syslog.rb +73 -0
- data/spec/ramaze/params.rb +153 -0
- data/spec/ramaze/public/favicon.ico +0 -0
- data/spec/ramaze/public/ramaze.png +0 -0
- data/spec/ramaze/public/test_download.css +141 -0
- data/spec/ramaze/request.rb +61 -0
- data/spec/ramaze/rewrite/file.css +1 -0
- data/spec/ramaze/session/memcache.rb +66 -0
- data/spec/ramaze/struct.rb +47 -0
- data/spec/ramaze/template/ramaze/external.test +1 -0
- data/spec/ramaze/view.rb +36 -0
- data/spec/ramaze/view/erubis.rb +73 -0
- data/spec/ramaze/view/erubis/external.rhtml +8 -0
- data/spec/ramaze/view/erubis/sum.rhtml +1 -0
- data/spec/ramaze/view/ezamar.rb +73 -0
- data/spec/ramaze/view/ezamar/external.zmr +8 -0
- data/spec/ramaze/view/ezamar/sum.zmr +1 -0
- data/spec/ramaze/view/gestalt.rb +94 -0
- data/spec/ramaze/view/gestalt/external.ges +8 -0
- data/spec/ramaze/view/haml.rb +86 -0
- data/spec/ramaze/view/haml/external.haml +5 -0
- data/spec/ramaze/view/haml/sum.haml +2 -0
- data/spec/ramaze/view/liquid.rb +73 -0
- data/spec/ramaze/view/liquid/external.liquid +8 -0
- data/spec/ramaze/view/liquid/sum.liquid +1 -0
- data/spec/ramaze/view/nagoro.rb +73 -0
- data/spec/ramaze/view/nagoro/external.nag +8 -0
- data/spec/ramaze/view/nagoro/sum.nag +1 -0
- data/spec/ramaze/view/redcloth.rb +66 -0
- data/spec/ramaze/view/redcloth/external.redcloth +8 -0
- data/spec/ramaze/view/remarkably.rb +49 -0
- data/spec/ramaze/view/remarkably/external.rem +8 -0
- data/spec/ramaze/view/remarkably/sum.rem +1 -0
- data/spec/ramaze/view/sass.rb +73 -0
- data/spec/ramaze/view/sass/file.css.sass +5 -0
- data/spec/ramaze/view/tagz.rb +51 -0
- data/spec/ramaze/view/tagz/external.tagz +8 -0
- data/spec/ramaze/view/tagz/sum.tagz +1 -0
- data/spec/ramaze/view/tenjin.rb +57 -0
- data/spec/ramaze/view/tenjin/external.rbhtml +8 -0
- data/spec/ramaze/view/tenjin/sum.rbhtml +1 -0
- data/spec/snippets/array/put_within.rb +33 -0
- data/spec/snippets/binding/locals.rb +9 -0
- data/spec/snippets/numeric/filesize_format.rb +12 -0
- data/spec/snippets/numeric/time.rb +12 -0
- data/spec/snippets/object/__dir__.rb +14 -0
- data/spec/snippets/ordered_set.rb +63 -0
- data/spec/snippets/ramaze/acquire.rb +77 -0
- data/spec/snippets/ramaze/dictionary.rb +110 -0
- data/spec/snippets/ramaze/struct.rb +12 -0
- data/spec/snippets/string/camel_case.rb +25 -0
- data/spec/snippets/string/color.rb +11 -0
- data/spec/snippets/string/snake_case.rb +24 -0
- data/spec/snippets/string/unindent.rb +43 -0
- data/spec/snippets/thread/into.rb +9 -0
- data/tasks/authors.rake +30 -0
- data/tasks/bacon.rake +66 -0
- data/tasks/changelog.rake +20 -0
- data/tasks/copyright.rake +21 -0
- data/tasks/gem.rake +22 -0
- data/tasks/gem_setup.rake +99 -0
- data/tasks/git.rake +46 -0
- data/tasks/grancher.rake +12 -0
- data/tasks/jquery.rake +15 -0
- data/tasks/manifest.rake +4 -0
- data/tasks/metric_changes.rake +24 -0
- data/tasks/rcov.rake +23 -0
- data/tasks/release.rake +54 -0
- data/tasks/reversion.rake +8 -0
- data/tasks/setup.rake +6 -0
- data/tasks/todo.rake +27 -0
- data/tasks/traits.rake +21 -0
- data/tasks/yard.rake +4 -0
- metadata +720 -0
Binary file
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require 'ramaze'
|
2
|
+
require 'ramaze/spec/bacon'
|
3
|
+
|
4
|
+
require __DIR__('../app')
|
5
|
+
|
6
|
+
describe MainController do
|
7
|
+
behaves_like :rack_test
|
8
|
+
|
9
|
+
should 'show start page' do
|
10
|
+
get('/').status.should == 200
|
11
|
+
last_response['Content-Type'].should == 'text/html'
|
12
|
+
last_response.should =~ /<h1>Welcome to Ramaze!<\/h1>/
|
13
|
+
end
|
14
|
+
|
15
|
+
should 'show /notemplate' do
|
16
|
+
get('/notemplate').status.should == 200
|
17
|
+
last_response['Content-Type'].should == 'text/html'
|
18
|
+
last_response.should =~ /there is no 'notemplate\.xhtml' associated with this action/
|
19
|
+
end
|
20
|
+
end
|
data/lib/proto/start.rb
ADDED
@@ -0,0 +1,8 @@
|
|
1
|
+
# Use this file directly like `ruby start.rb` if you don't want to use the
|
2
|
+
# `ramaze start` command.
|
3
|
+
# All application related things should go into `app.rb`, this file is simply
|
4
|
+
# for options related to running the application locally.
|
5
|
+
|
6
|
+
require File.expand_path('app', File.dirname(__FILE__))
|
7
|
+
|
8
|
+
Ramaze.start(:adapter => :webrick, :port => 7000, :file => __FILE__)
|
@@ -0,0 +1,41 @@
|
|
1
|
+
<p>
|
2
|
+
Ramaze is working correctly with this application, now you can start working.
|
3
|
+
</p>
|
4
|
+
|
5
|
+
<p>
|
6
|
+
To start you can modify:
|
7
|
+
<ol>
|
8
|
+
<li>
|
9
|
+
<code>view/index.xhtml</code>, this page.
|
10
|
+
</li>
|
11
|
+
<li>
|
12
|
+
<code>view/page.xhtml</code>, the layout for this page.
|
13
|
+
</li>
|
14
|
+
<li>
|
15
|
+
<code>controller/main.rb</code>, where you can change the header of this
|
16
|
+
page and the <a href="/notemplate">notemplate</a> action
|
17
|
+
</li>
|
18
|
+
</ol>
|
19
|
+
</p>
|
20
|
+
|
21
|
+
<p>For more documentation, check out <a href="http://ramaze.net">ramaze.net</a> and <a href="http://wiki.ramaze.net">wiki.ramaze.net</a>, which includes:
|
22
|
+
<ul>
|
23
|
+
<li>a <a href="http://wiki.ramaze.net/Walkthrough">getting started</a> guide</li>
|
24
|
+
<li>some <a href="http://wiki.ramaze.net/Screencasts">screencasts</a></li>
|
25
|
+
<li>and an <a href="http://wiki.ramaze.net/Tutorials/Todolist">introductory tutorial</a></li>
|
26
|
+
</ul>
|
27
|
+
</p>
|
28
|
+
|
29
|
+
<p>
|
30
|
+
You can also read the
|
31
|
+
<a href="http://ramaze.rubyforge.org/rdoc/files/doc/README.html">rdocs</a>
|
32
|
+
or browse around the
|
33
|
+
<a href="http://source.ramaze.net">Ramaze source code</a>.
|
34
|
+
</p>
|
35
|
+
|
36
|
+
<p>
|
37
|
+
For help with Ramaze, visit <a href="irc://chat.freenode.net/ramaze">#ramaze on irc.freenode.net</a>.<br />
|
38
|
+
You can use <a href="http://embed.mibbit.com/?server=irc.freenode.net&channel=#ramaze,#ruby-lang&forcePrompt=true">Mibbit</a>, an AJAX based IRC client or <a href="http://java.freenode.net/?channel=ramaze">the official freenode irc java applet</a>.
|
39
|
+
<br />
|
40
|
+
Feel free to post to the <a href="http://groups.google.com/group/ramaze">Ramaze Google Group</a>, your first mail has to go through moderation, so please be patient.
|
41
|
+
</p>
|
data/lib/ramaze.rb
ADDED
@@ -0,0 +1,87 @@
|
|
1
|
+
# Copyright (c) 2009 Michael Fellinger m.fellinger@gmail.com
|
2
|
+
# All files in this distribution are subject to the terms of the Ruby license.
|
3
|
+
|
4
|
+
# Namespace for Ramaze
|
5
|
+
#
|
6
|
+
# THINK:
|
7
|
+
# * for now, we don't extend this with Innate to keep things clean. But we
|
8
|
+
# should eventually do it for a simple API, or people always have to find
|
9
|
+
# out whether something is in Innate or Ramaze.
|
10
|
+
# No matter which way we go, we should keep references point to the
|
11
|
+
# original location to avoid too much confusion for core developers.
|
12
|
+
module Ramaze
|
13
|
+
ROOT = File.expand_path(File.dirname(__FILE__)) unless defined?(Ramaze::ROOT)
|
14
|
+
|
15
|
+
unless $LOAD_PATH.any?{|lp| File.expand_path(lp) == ROOT }
|
16
|
+
$LOAD_PATH.unshift(ROOT)
|
17
|
+
end
|
18
|
+
|
19
|
+
# 3rd party
|
20
|
+
require 'innate'
|
21
|
+
|
22
|
+
@options = Innate.options
|
23
|
+
class << self; attr_accessor :options; end
|
24
|
+
|
25
|
+
# vendored, will go into rack-contrib
|
26
|
+
require 'vendor/etag'
|
27
|
+
require 'vendor/route_exceptions'
|
28
|
+
|
29
|
+
# Ramaze itself
|
30
|
+
require 'ramaze/version'
|
31
|
+
require 'ramaze/log'
|
32
|
+
require 'ramaze/snippets'
|
33
|
+
require 'ramaze/helper'
|
34
|
+
require 'ramaze/view'
|
35
|
+
require 'ramaze/controller'
|
36
|
+
require 'ramaze/cache'
|
37
|
+
require 'ramaze/reloader'
|
38
|
+
require 'ramaze/setup'
|
39
|
+
require 'ramaze/app'
|
40
|
+
require 'ramaze/files'
|
41
|
+
require 'ramaze/middleware_compiler'
|
42
|
+
require 'ramaze/plugin'
|
43
|
+
require 'ramaze/request'
|
44
|
+
require 'ramaze/current'
|
45
|
+
|
46
|
+
# Usually it's just mental overhead to remember which module has which
|
47
|
+
# constant, so we just assign them here as well.
|
48
|
+
# This will not affect any of the module functions on Innate, you still have
|
49
|
+
# to reference the correct module for them.
|
50
|
+
# We do not set constants already set from the requires above.
|
51
|
+
Innate.constants.each do |const|
|
52
|
+
begin
|
53
|
+
Ramaze.const_get(const)
|
54
|
+
rescue NameError
|
55
|
+
Ramaze.const_set(const, Innate.const_get(const))
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
extend Innate::SingletonMethods
|
60
|
+
|
61
|
+
options[:middleware_compiler] = Ramaze::MiddlewareCompiler
|
62
|
+
|
63
|
+
middleware! :dev do |m|
|
64
|
+
m.use Rack::Lint
|
65
|
+
m.use Rack::CommonLogger, Ramaze::Log
|
66
|
+
m.use Rack::ShowExceptions
|
67
|
+
m.use Rack::ShowStatus
|
68
|
+
m.use Rack::RouteExceptions
|
69
|
+
m.use Rack::ContentLength
|
70
|
+
m.use Rack::ConditionalGet
|
71
|
+
m.use Rack::ETag
|
72
|
+
m.use Rack::Head
|
73
|
+
m.use Ramaze::Reloader
|
74
|
+
m.run Ramaze::AppMap
|
75
|
+
end
|
76
|
+
|
77
|
+
middleware! :live do |m|
|
78
|
+
m.use Rack::CommonLogger, Ramaze::Log
|
79
|
+
m.use Rack::RouteExceptions
|
80
|
+
m.use Rack::ShowStatus
|
81
|
+
m.use Rack::ContentLength
|
82
|
+
m.use Rack::ConditionalGet
|
83
|
+
m.use Rack::ETag
|
84
|
+
m.use Rack::Head
|
85
|
+
m.run Ramaze::AppMap
|
86
|
+
end
|
87
|
+
end
|
data/lib/ramaze/app.rb
ADDED
@@ -0,0 +1,124 @@
|
|
1
|
+
module Ramaze
|
2
|
+
# An application is a collection of controllers and options that have a
|
3
|
+
# common name.
|
4
|
+
# Every application has a location it dispatches from, this behaves similar
|
5
|
+
# to Rack::URLMap.
|
6
|
+
|
7
|
+
AppMap = Innate::URLMap.new
|
8
|
+
|
9
|
+
def self.to(object)
|
10
|
+
app_name = object.ancestral_trait[:app]
|
11
|
+
App[app_name].to(object)
|
12
|
+
end
|
13
|
+
|
14
|
+
# App is the superclass for applications and acts as their prototype when it
|
15
|
+
# comes to configuration.
|
16
|
+
#
|
17
|
+
# An application consists of options, a location, and a list of objects. The
|
18
|
+
# objects are usually {Controller}s.
|
19
|
+
#
|
20
|
+
# The options are inherited, the basics are set in Ramaze.options, from there
|
21
|
+
# to Ramaze::App.options, and finally into every instance of App.
|
22
|
+
#
|
23
|
+
# This allows to collect {Controller}s of your application into a common
|
24
|
+
# group that can easily be used in other applications, while retaining the
|
25
|
+
# original options.
|
26
|
+
#
|
27
|
+
# Every instance of {App} is mapped in {AppMap}, which is the default
|
28
|
+
# location to #call from Rack.
|
29
|
+
#
|
30
|
+
# Additionally, every {App} can have custom locations for
|
31
|
+
# root/public/view/layout directories, which allows reuse beyond directory
|
32
|
+
# boundaries.
|
33
|
+
#
|
34
|
+
# In contrast to Innate, where all Nodes share the same middleware, {App}
|
35
|
+
# also has a subset of middleware that handles serving static files, routes
|
36
|
+
# and rewrites.
|
37
|
+
#
|
38
|
+
# To indicate that a {Controller} belongs to a specific application, you can
|
39
|
+
# pass a second argument to {Controller::map}
|
40
|
+
#
|
41
|
+
# @example adding Controller to application
|
42
|
+
#
|
43
|
+
# class WikiController < Ramaze::Controller
|
44
|
+
# map '/', :wiki
|
45
|
+
# end
|
46
|
+
#
|
47
|
+
# The App instance will be created for you and if you don't use any other
|
48
|
+
# applications in your code there is nothing else you have to do. Others can
|
49
|
+
# now come and simply reuse your code in their own applications.
|
50
|
+
#
|
51
|
+
# There is some risk of name collisions if everybody calls their app `:wiki`,
|
52
|
+
# but given that you only use one foreign app of this kind might give less
|
53
|
+
# reason for concern.
|
54
|
+
#
|
55
|
+
# If you still try to use two apps with the same name, you have to be
|
56
|
+
# careful, loading one first, renaming it, then loading the second one.
|
57
|
+
#
|
58
|
+
# The naming of an App has no influence on any other aspects of dispatching
|
59
|
+
# or configuration.
|
60
|
+
class App
|
61
|
+
include Innate::Optioned
|
62
|
+
|
63
|
+
# options not found here will be looked up in Ramaze.options
|
64
|
+
options.dsl do
|
65
|
+
o "Unique identifier for this application",
|
66
|
+
:name, :pristine
|
67
|
+
end
|
68
|
+
|
69
|
+
APP_LIST = {}
|
70
|
+
|
71
|
+
attr_reader :name, :location, :url_map, :options
|
72
|
+
|
73
|
+
def initialize(name, location)
|
74
|
+
@name = name.to_sym
|
75
|
+
@url_map = Innate::URLMap.new
|
76
|
+
self.location = location
|
77
|
+
|
78
|
+
APP_LIST[@name] = self
|
79
|
+
|
80
|
+
@options = self.class.options.sub(@name)
|
81
|
+
end
|
82
|
+
|
83
|
+
def sync
|
84
|
+
AppMap.map(location, self)
|
85
|
+
end
|
86
|
+
|
87
|
+
def location=(location)
|
88
|
+
@location = location.to_str.freeze
|
89
|
+
sync
|
90
|
+
end
|
91
|
+
|
92
|
+
def call(env)
|
93
|
+
to_app.call(env)
|
94
|
+
end
|
95
|
+
|
96
|
+
def to_app
|
97
|
+
files = Ramaze::Files.new(*public_roots)
|
98
|
+
app = Current.new(Route.new(url_map), Rewrite.new(url_map))
|
99
|
+
Rack::Cascade.new([files, app])
|
100
|
+
end
|
101
|
+
|
102
|
+
def map(location, object)
|
103
|
+
url_map.map(location, object)
|
104
|
+
end
|
105
|
+
|
106
|
+
def to(object)
|
107
|
+
return unless mapped = url_map.to(object)
|
108
|
+
[location, mapped].join('/').squeeze('/')
|
109
|
+
end
|
110
|
+
|
111
|
+
def public_roots
|
112
|
+
roots, publics = [*options.roots], [*options.publics]
|
113
|
+
roots.map{|root| publics.map{|public| ::File.join(root, public) }}.flatten
|
114
|
+
end
|
115
|
+
|
116
|
+
def self.find_or_create(name, location = '/')
|
117
|
+
self[name] || new(name, location)
|
118
|
+
end
|
119
|
+
|
120
|
+
def self.[](name)
|
121
|
+
APP_LIST[name.to_sym]
|
122
|
+
end
|
123
|
+
end
|
124
|
+
end
|
data/lib/ramaze/cache.rb
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
# Copyright (c) 2009 Michael Fellinger m.fellinger@gmail.com
|
2
|
+
# All files in this distribution are subject to the terms of the Ruby license.
|
3
|
+
|
4
|
+
require 'innate/cache'
|
5
|
+
|
6
|
+
module Ramaze
|
7
|
+
Cache = Innate::Cache
|
8
|
+
|
9
|
+
class Cache
|
10
|
+
autoload :LocalMemCache, 'ramaze/cache/localmemcache'
|
11
|
+
autoload :MemCache, 'ramaze/cache/memcache'
|
12
|
+
autoload :Sequel, 'ramaze/cache/sequel'
|
13
|
+
|
14
|
+
def self.clear_after_reload
|
15
|
+
action.clear if respond_to?(:action)
|
16
|
+
action_value.clear if respond_to?(:action_value)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,56 @@
|
|
1
|
+
# Copyright (c) 2009 Michael Fellinger m.fellinger@gmail.com
|
2
|
+
# All files in this distribution are subject to the terms of the Ruby license.
|
3
|
+
|
4
|
+
require 'localmemcache'
|
5
|
+
|
6
|
+
module Ramaze
|
7
|
+
class Cache
|
8
|
+
|
9
|
+
# Cache based on the localmemcache library which utilizes mmap to share
|
10
|
+
# strings in memory between ruby instances.
|
11
|
+
class LocalMemCache
|
12
|
+
include Cache::API
|
13
|
+
|
14
|
+
OPTIONS = {
|
15
|
+
:size_mb => 1024,
|
16
|
+
:serialize => true,
|
17
|
+
:serializer => ::Marshal, # something that responds to ::load and ::dump
|
18
|
+
}
|
19
|
+
|
20
|
+
# Connect to localmemcache
|
21
|
+
def cache_setup(host, user, app, name)
|
22
|
+
@namespace = [host, user, app, name].compact.join('-')
|
23
|
+
|
24
|
+
options = {:namespace => @namespace}.merge(OPTIONS)
|
25
|
+
|
26
|
+
@serialize = options.delete(:serialize)
|
27
|
+
@serializer = options.delete(:serializer)
|
28
|
+
|
29
|
+
@store = ::LocalMemCache.new(options)
|
30
|
+
end
|
31
|
+
|
32
|
+
# Wipe out _all_ data in localmemcached, use with care.
|
33
|
+
def cache_clear
|
34
|
+
@store.clear
|
35
|
+
end
|
36
|
+
|
37
|
+
def cache_delete(*args)
|
38
|
+
super{|key| @store.delete(key.to_s); nil }
|
39
|
+
end
|
40
|
+
|
41
|
+
# NOTE:
|
42
|
+
# * We have no way of knowing whether the value really is nil, we
|
43
|
+
# assume you wouldn't cache nil and return the default instead.
|
44
|
+
def cache_fetch(*args)
|
45
|
+
super{|key|
|
46
|
+
value = @store[key.to_s]
|
47
|
+
@serializer.load(value) if value
|
48
|
+
}
|
49
|
+
end
|
50
|
+
|
51
|
+
def cache_store(*args)
|
52
|
+
super{|key, value| @store[key.to_s] = @serializer.dump(value) }
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
@@ -0,0 +1,124 @@
|
|
1
|
+
# Copyright (c) 2009 Michael Fellinger m.fellinger@gmail.com
|
2
|
+
# All files in this distribution are subject to the terms of the Ruby license.
|
3
|
+
|
4
|
+
require 'memcache'
|
5
|
+
|
6
|
+
module Ramaze
|
7
|
+
class Cache
|
8
|
+
|
9
|
+
# Cache based on the memcache library which utilizes the memcache-daemon to
|
10
|
+
# store key/value pairs in namespaces.
|
11
|
+
#
|
12
|
+
# Please read the documentation of memcache-client for further methods.
|
13
|
+
#
|
14
|
+
# It is highly recommended to install memcache-client_extensions for
|
15
|
+
# a bit of speedup and more functionality
|
16
|
+
#
|
17
|
+
# NOTE: There is a big issue with persisting sessions in memcache, not only
|
18
|
+
# can they be dropped at any time, essentially logging the user out
|
19
|
+
# without them noticing, but there is also a low limit to the maximum
|
20
|
+
# time-to-live. After 30 days, your session will be dropped, no
|
21
|
+
# matter what.
|
22
|
+
# Please remember that memcache is, first of all, a cache, not a
|
23
|
+
# persistence mechanism.
|
24
|
+
#
|
25
|
+
# NOTE: If you try to set a higher ttl than allowed, your stored key/value
|
26
|
+
# will be expired immediately.
|
27
|
+
class MemCache
|
28
|
+
MAX_TTL = 2592000
|
29
|
+
|
30
|
+
include Cache::API
|
31
|
+
|
32
|
+
# +:multithread+: May be turned off at your own risk.
|
33
|
+
# +:readonly+: You most likely want that to be false.
|
34
|
+
# +:servers+: Array containing at least one of:
|
35
|
+
# MemCache::Server instance
|
36
|
+
# Strings like "localhost", "localhost:11211", "localhost:11211:1"
|
37
|
+
# That accord to "host:port:weight", only host is required.
|
38
|
+
OPTIONS = {
|
39
|
+
:multithread => true,
|
40
|
+
:readonly => false,
|
41
|
+
:servers => ['localhost:11211:1'],
|
42
|
+
}
|
43
|
+
|
44
|
+
# Connect to memcached
|
45
|
+
def cache_setup(host, user, app, name)
|
46
|
+
@namespace = [host, user, app, name].compact.join('-')
|
47
|
+
options = {:namespace => @namespace}.merge(OPTIONS)
|
48
|
+
servers = options.delete(:servers)
|
49
|
+
@store = ::MemCache.new(servers, options)
|
50
|
+
@warned = false
|
51
|
+
end
|
52
|
+
|
53
|
+
# Wipe out _all_ data in memcached, use with care.
|
54
|
+
def cache_clear
|
55
|
+
@store.flush_all
|
56
|
+
rescue ::MemCache::MemCacheError => e
|
57
|
+
Log.error(e)
|
58
|
+
nil
|
59
|
+
end
|
60
|
+
|
61
|
+
#
|
62
|
+
def cache_delete(*keys)
|
63
|
+
super{|key| @store.delete(key); nil }
|
64
|
+
rescue ::MemCache::MemCacheError => e
|
65
|
+
Log.error(e)
|
66
|
+
nil
|
67
|
+
end
|
68
|
+
|
69
|
+
# NOTE:
|
70
|
+
# * We have no way of knowing whether the value really is nil, we
|
71
|
+
# assume you wouldn't cache nil and return the default instead.
|
72
|
+
def cache_fetch(key, default = nil)
|
73
|
+
value = @store[key]
|
74
|
+
value.nil? ? default : value
|
75
|
+
rescue ::MemCache::MemCacheError => e
|
76
|
+
Log.error(e)
|
77
|
+
nil
|
78
|
+
end
|
79
|
+
|
80
|
+
def cache_store(key, value, options = {})
|
81
|
+
ttl = options[:ttl] || 0
|
82
|
+
|
83
|
+
if ttl > MAX_TTL
|
84
|
+
unless @warned
|
85
|
+
Log.warn('MemCache cannot set a ttl greater than 2592000 seconds.')
|
86
|
+
Log.warn('Modify Ramaze.options.session.ttl to a value <= of that.')
|
87
|
+
@warned = true
|
88
|
+
end
|
89
|
+
|
90
|
+
ttl = MAX_TTL
|
91
|
+
end
|
92
|
+
|
93
|
+
@store.set(key, value, ttl)
|
94
|
+
value
|
95
|
+
rescue ::MemCache::MemCacheError => e
|
96
|
+
Log.error(e)
|
97
|
+
nil
|
98
|
+
end
|
99
|
+
|
100
|
+
# statistics about usage
|
101
|
+
def stats; @store.stats; end
|
102
|
+
|
103
|
+
# current namespace
|
104
|
+
def namespace; @store.namespace; end
|
105
|
+
|
106
|
+
# switch to different namespace
|
107
|
+
def namespace=(ns) @namespace = @store.namespace = ns; end
|
108
|
+
|
109
|
+
# state of compression (true/false)
|
110
|
+
def compression; @store.compression; end
|
111
|
+
|
112
|
+
# turn compression on or off
|
113
|
+
def compression=(bool); @store.compression = bool; end
|
114
|
+
|
115
|
+
# For everything else that we don't care to document right now.
|
116
|
+
def method_missing(*args, &block)
|
117
|
+
@store.__send__(*args, &block)
|
118
|
+
rescue ::MemCache::MemCacheError => e
|
119
|
+
Log.error(e)
|
120
|
+
nil
|
121
|
+
end
|
122
|
+
end
|
123
|
+
end
|
124
|
+
end
|