Pistos-ramaze 2008.09
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.markdown +481 -0
- data/Rakefile +228 -0
- data/benchmark/results.txt +131 -0
- data/benchmark/run.rb +362 -0
- data/benchmark/suite/minimal.rb +13 -0
- data/benchmark/suite/no_informer.rb +9 -0
- data/benchmark/suite/no_sessions.rb +10 -0
- data/benchmark/suite/no_template.rb +9 -0
- data/benchmark/suite/simple.rb +7 -0
- data/benchmark/suite/template_amrita2.rb +17 -0
- data/benchmark/suite/template_builder.rb +12 -0
- data/benchmark/suite/template_erubis.rb +10 -0
- data/benchmark/suite/template_ezamar.rb +10 -0
- data/benchmark/suite/template_haml.rb +15 -0
- data/benchmark/suite/template_liquid.rb +13 -0
- data/benchmark/suite/template_markaby.rb +11 -0
- data/benchmark/suite/template_nagoro.rb +10 -0
- data/benchmark/suite/template_redcloth.rb +15 -0
- data/benchmark/suite/template_tenjin.rb +10 -0
- data/benchmark/test.rb +35 -0
- data/bin/ramaze +80 -0
- data/doc/AUTHORS +29 -0
- data/doc/CHANGELOG +19530 -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 +99 -0
- data/doc/meta/configuration.txt +163 -0
- data/doc/meta/internals.txt +278 -0
- data/doc/meta/users.kml +64 -0
- data/doc/readme_chunks/appendix.txt +10 -0
- data/doc/readme_chunks/examples.txt +38 -0
- data/doc/readme_chunks/features.txt +148 -0
- data/doc/readme_chunks/getting_help.txt +5 -0
- data/doc/readme_chunks/getting_started.txt +18 -0
- data/doc/readme_chunks/installing.txt +92 -0
- data/doc/readme_chunks/introduction.txt +18 -0
- data/doc/readme_chunks/principles.txt +56 -0
- data/doc/readme_chunks/thanks.txt +59 -0
- data/doc/tutorial/todolist.html +742 -0
- data/doc/tutorial/todolist.mkd +787 -0
- data/examples/app/auth/auth.rb +54 -0
- data/examples/app/auth/template/layout.haml +20 -0
- data/examples/app/auth/template/login.haml +16 -0
- data/examples/app/blog/README +3 -0
- data/examples/app/blog/controller/main.rb +29 -0
- data/examples/app/blog/model/entry.rb +30 -0
- data/examples/app/blog/public/styles/blog.css +132 -0
- data/examples/app/blog/spec/blog.rb +87 -0
- data/examples/app/blog/start.rb +7 -0
- data/examples/app/blog/view/edit.xhtml +17 -0
- data/examples/app/blog/view/index.xhtml +17 -0
- data/examples/app/blog/view/layout.xhtml +11 -0
- data/examples/app/blog/view/new.xhtml +16 -0
- data/examples/app/chat/model/history.rb +36 -0
- data/examples/app/chat/model/message.rb +7 -0
- data/examples/app/chat/public/css/chat.css +13 -0
- data/examples/app/chat/public/js/chat.js +22 -0
- data/examples/app/chat/public/js/jquery.js +3436 -0
- data/examples/app/chat/start.rb +40 -0
- data/examples/app/chat/view/chat.xhtml +9 -0
- data/examples/app/chat/view/index.xhtml +7 -0
- data/examples/app/chat/view/layout.xhtml +13 -0
- data/examples/app/localization/start.rb +35 -0
- data/examples/app/rapaste/Rakefile +34 -0
- data/examples/app/rapaste/controller/paste.rb +101 -0
- data/examples/app/rapaste/model/paste.rb +58 -0
- data/examples/app/rapaste/public/css/active4d.css +114 -0
- data/examples/app/rapaste/public/css/all_hallows_eve.css +72 -0
- data/examples/app/rapaste/public/css/amy.css +147 -0
- data/examples/app/rapaste/public/css/blackboard.css +88 -0
- data/examples/app/rapaste/public/css/brilliance_black.css +605 -0
- data/examples/app/rapaste/public/css/brilliance_dull.css +599 -0
- data/examples/app/rapaste/public/css/cobalt.css +149 -0
- data/examples/app/rapaste/public/css/dawn.css +121 -0
- data/examples/app/rapaste/public/css/display.css +197 -0
- data/examples/app/rapaste/public/css/eiffel.css +121 -0
- data/examples/app/rapaste/public/css/espresso_libre.css +109 -0
- data/examples/app/rapaste/public/css/idle.css +62 -0
- data/examples/app/rapaste/public/css/iplastic.css +80 -0
- data/examples/app/rapaste/public/css/lazy.css +73 -0
- data/examples/app/rapaste/public/css/mac_classic.css +123 -0
- data/examples/app/rapaste/public/css/magicwb_amiga.css +104 -0
- data/examples/app/rapaste/public/css/pastels_on_dark.css +188 -0
- data/examples/app/rapaste/public/css/slush_poppies.css +85 -0
- data/examples/app/rapaste/public/css/spacecadet.css +51 -0
- data/examples/app/rapaste/public/css/sunburst.css +180 -0
- data/examples/app/rapaste/public/css/twilight.css +137 -0
- data/examples/app/rapaste/public/css/zenburnesque.css +91 -0
- data/examples/app/rapaste/public/js/jquery.js +11 -0
- data/examples/app/rapaste/spec/rapaste.rb +51 -0
- data/examples/app/rapaste/start.rb +25 -0
- data/examples/app/rapaste/view/copy.xhtml +10 -0
- data/examples/app/rapaste/view/index.xhtml +9 -0
- data/examples/app/rapaste/view/layout.xhtml +25 -0
- data/examples/app/rapaste/view/list.xhtml +29 -0
- data/examples/app/rapaste/view/search.xhtml +41 -0
- data/examples/app/rapaste/view/view.xhtml +37 -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/sourceview.rb +77 -0
- data/examples/app/sourceview/template/index.haml +59 -0
- data/examples/app/todolist/README +1 -0
- data/examples/app/todolist/public/favicon.ico +0 -0
- data/examples/app/todolist/public/js/jquery.js +1923 -0
- data/examples/app/todolist/public/ramaze.png +0 -0
- data/examples/app/todolist/spec/todolist.rb +132 -0
- data/examples/app/todolist/src/controller/main.rb +70 -0
- data/examples/app/todolist/src/element/page.rb +31 -0
- data/examples/app/todolist/src/model.rb +14 -0
- data/examples/app/todolist/start.rb +11 -0
- data/examples/app/todolist/template/index.xhtml +17 -0
- data/examples/app/todolist/template/new.xhtml +7 -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 +111 -0
- data/examples/app/wikore/src/controller.rb +80 -0
- data/examples/app/wikore/src/model.rb +53 -0
- data/examples/app/wikore/start.rb +9 -0
- data/examples/app/wikore/template/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 +45 -0
- data/examples/basic/gestalt.rb +27 -0
- data/examples/basic/hello.rb +15 -0
- data/examples/basic/layout.rb +28 -0
- data/examples/basic/linking.rb +29 -0
- data/examples/basic/simple.rb +56 -0
- data/examples/helpers/cache.rb +31 -0
- data/examples/helpers/form_with_sequel.rb +24 -0
- data/examples/helpers/httpdigest.rb +50 -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/provide.rb +23 -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 +32 -0
- data/examples/misc/nagoro_element.rb +43 -0
- data/examples/misc/ramaise.rb +132 -0
- data/examples/misc/rapp.rb +45 -0
- data/examples/misc/sequel_scaffolding.rb +34 -0
- data/examples/misc/simple_auth.rb +35 -0
- data/examples/templates/template/external.amrita +19 -0
- data/examples/templates/template/external.haml +22 -0
- data/examples/templates/template/external.liquid +28 -0
- data/examples/templates/template/external.mab +30 -0
- data/examples/templates/template/external.nag +28 -0
- data/examples/templates/template/external.redcloth +19 -0
- data/examples/templates/template/external.rem +30 -0
- data/examples/templates/template/external.rhtml +28 -0
- data/examples/templates/template/external.tenjin +28 -0
- data/examples/templates/template/external.xsl +57 -0
- data/examples/templates/template/external.zmr +28 -0
- data/examples/templates/template_amrita2.rb +74 -0
- data/examples/templates/template_erubis.rb +53 -0
- data/examples/templates/template_ezamar.rb +50 -0
- data/examples/templates/template_haml.rb +50 -0
- data/examples/templates/template_liquid.rb +65 -0
- data/examples/templates/template_markaby.rb +58 -0
- data/examples/templates/template_nagoro.rb +51 -0
- data/examples/templates/template_redcloth.rb +59 -0
- data/examples/templates/template_remarkably.rb +55 -0
- data/examples/templates/template_tenjin.rb +53 -0
- data/examples/templates/template_xslt.rb +49 -0
- data/lib/proto/controller/init.rb +10 -0
- data/lib/proto/controller/main.rb +20 -0
- data/lib/proto/model/init.rb +4 -0
- data/lib/proto/public/css/ramaze_error.css +90 -0
- data/lib/proto/public/dispatch.fcgi +11 -0
- data/lib/proto/public/favicon.ico +0 -0
- data/lib/proto/public/js/jquery.js +3549 -0
- data/lib/proto/public/ramaze.png +0 -0
- data/lib/proto/spec/main.rb +25 -0
- data/lib/proto/start.rb +8 -0
- data/lib/proto/start.ru +16 -0
- data/lib/proto/view/error.xhtml +64 -0
- data/lib/proto/view/index.xhtml +34 -0
- data/lib/proto/view/page.xhtml +27 -0
- data/lib/ramaze/action/render.rb +191 -0
- data/lib/ramaze/action.rb +153 -0
- data/lib/ramaze/adapter/base.rb +128 -0
- data/lib/ramaze/adapter/cgi.rb +20 -0
- data/lib/ramaze/adapter/ebb.rb +18 -0
- data/lib/ramaze/adapter/evented_mongrel.rb +7 -0
- data/lib/ramaze/adapter/fake.rb +12 -0
- data/lib/ramaze/adapter/fcgi.rb +18 -0
- data/lib/ramaze/adapter/lsws.rb +19 -0
- data/lib/ramaze/adapter/mongrel.rb +21 -0
- data/lib/ramaze/adapter/scgi.rb +18 -0
- data/lib/ramaze/adapter/swiftiplied_mongrel.rb +7 -0
- data/lib/ramaze/adapter/thin.rb +17 -0
- data/lib/ramaze/adapter/webrick.rb +43 -0
- data/lib/ramaze/adapter.rb +97 -0
- data/lib/ramaze/cache/memcached.rb +69 -0
- data/lib/ramaze/cache/memory.rb +6 -0
- data/lib/ramaze/cache/yaml_store.rb +68 -0
- data/lib/ramaze/cache.rb +113 -0
- data/lib/ramaze/contrib/auto_params/get_args.rb +58 -0
- data/lib/ramaze/contrib/auto_params.rb +135 -0
- data/lib/ramaze/contrib/email.rb +84 -0
- data/lib/ramaze/contrib/facebook/facebook.rb +171 -0
- data/lib/ramaze/contrib/facebook.rb +23 -0
- data/lib/ramaze/contrib/file_cache.rb +65 -0
- data/lib/ramaze/contrib/gems.rb +78 -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/gettext.rb +113 -0
- data/lib/ramaze/contrib/gzip_filter.rb +69 -0
- data/lib/ramaze/contrib/maruku_uv.rb +59 -0
- data/lib/ramaze/contrib/profiling.rb +36 -0
- data/lib/ramaze/contrib/rest.rb +17 -0
- data/lib/ramaze/contrib/sequel/create_join.rb +25 -0
- data/lib/ramaze/contrib/sequel/fill.rb +12 -0
- data/lib/ramaze/contrib/sequel/form_field.rb +129 -0
- data/lib/ramaze/contrib/sequel/image.rb +198 -0
- data/lib/ramaze/contrib/sequel/relation.rb +82 -0
- data/lib/ramaze/contrib/sequel_cache.rb +92 -0
- data/lib/ramaze/contrib.rb +82 -0
- data/lib/ramaze/controller/error.rb +46 -0
- data/lib/ramaze/controller/main.rb +2 -0
- data/lib/ramaze/controller/resolve.rb +273 -0
- data/lib/ramaze/controller.rb +280 -0
- data/lib/ramaze/current/request.rb +205 -0
- data/lib/ramaze/current/response.rb +39 -0
- data/lib/ramaze/current/session/flash.rb +87 -0
- data/lib/ramaze/current/session/hash.rb +66 -0
- data/lib/ramaze/current/session.rb +181 -0
- data/lib/ramaze/current.rb +110 -0
- data/lib/ramaze/dispatcher/action.rb +48 -0
- data/lib/ramaze/dispatcher/directory.rb +119 -0
- data/lib/ramaze/dispatcher/error.rb +108 -0
- data/lib/ramaze/dispatcher/file.rb +95 -0
- data/lib/ramaze/dispatcher.rb +145 -0
- data/lib/ramaze/error.rb +24 -0
- data/lib/ramaze/gestalt.rb +124 -0
- data/lib/ramaze/helper/aspect.rb +106 -0
- data/lib/ramaze/helper/auth.rb +125 -0
- data/lib/ramaze/helper/cache.rb +140 -0
- data/lib/ramaze/helper/cgi.rb +39 -0
- data/lib/ramaze/helper/flash.rb +59 -0
- data/lib/ramaze/helper/form.rb +281 -0
- data/lib/ramaze/helper/formatting.rb +158 -0
- data/lib/ramaze/helper/gestalt.rb +15 -0
- data/lib/ramaze/helper/gravatar.rb +15 -0
- data/lib/ramaze/helper/httpdigest.rb +59 -0
- data/lib/ramaze/helper/identity.rb +119 -0
- data/lib/ramaze/helper/link.rb +122 -0
- data/lib/ramaze/helper/markaby.rb +31 -0
- data/lib/ramaze/helper/maruku.rb +7 -0
- data/lib/ramaze/helper/nitroform.rb +14 -0
- data/lib/ramaze/helper/pager.rb +366 -0
- data/lib/ramaze/helper/paginate.rb +234 -0
- data/lib/ramaze/helper/partial.rb +105 -0
- data/lib/ramaze/helper/redirect.rb +82 -0
- data/lib/ramaze/helper/rest.rb +43 -0
- data/lib/ramaze/helper/sendfile.rb +16 -0
- data/lib/ramaze/helper/sequel.rb +55 -0
- data/lib/ramaze/helper/simple_captcha.rb +31 -0
- data/lib/ramaze/helper/stack.rb +77 -0
- data/lib/ramaze/helper/tagz.rb +19 -0
- data/lib/ramaze/helper/thread.rb +17 -0
- data/lib/ramaze/helper/ultraviolet.rb +44 -0
- data/lib/ramaze/helper/user.rb +110 -0
- data/lib/ramaze/helper/xhtml.rb +23 -0
- data/lib/ramaze/helper.rb +79 -0
- data/lib/ramaze/log/analogger.rb +40 -0
- data/lib/ramaze/log/growl.rb +38 -0
- data/lib/ramaze/log/hub.rb +41 -0
- data/lib/ramaze/log/informer.rb +128 -0
- data/lib/ramaze/log/knotify.rb +28 -0
- data/lib/ramaze/log/logger.rb +26 -0
- data/lib/ramaze/log/logging.rb +89 -0
- data/lib/ramaze/log/syslog.rb +51 -0
- data/lib/ramaze/log/xosd.rb +92 -0
- data/lib/ramaze/log.rb +27 -0
- data/lib/ramaze/option/dsl.rb +45 -0
- data/lib/ramaze/option/holder.rb +131 -0
- data/lib/ramaze/option/merger.rb +108 -0
- data/lib/ramaze/option.rb +156 -0
- data/lib/ramaze/reloader.rb +186 -0
- data/lib/ramaze/route.rb +97 -0
- data/lib/ramaze/setup.rb +50 -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/dictionary.rb +504 -0
- data/lib/ramaze/snippets/divide.rb +20 -0
- data/lib/ramaze/snippets/fiber.rb +63 -0
- data/lib/ramaze/snippets/kernel/constant.rb +41 -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/acquire.rb +40 -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/object/traits.rb +76 -0
- data/lib/ramaze/snippets/ordered_set.rb +51 -0
- data/lib/ramaze/snippets/proc/locals.rb +19 -0
- data/lib/ramaze/snippets/ramaze/caller_info.rb +30 -0
- data/lib/ramaze/snippets/ramaze/caller_lines.rb +51 -0
- data/lib/ramaze/snippets/ramaze/deprecated.rb +20 -0
- data/lib/ramaze/snippets/ramaze/fiber.rb +24 -0
- data/lib/ramaze/snippets/ramaze/state.rb +86 -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/each.rb +19 -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/snippets.rb +22 -0
- data/lib/ramaze/spec/helper/bacon.rb +7 -0
- data/lib/ramaze/spec/helper/browser.rb +88 -0
- data/lib/ramaze/spec/helper/mock_http.rb +63 -0
- data/lib/ramaze/spec/helper/pretty_output.rb +82 -0
- data/lib/ramaze/spec/helper/requester.rb +63 -0
- data/lib/ramaze/spec/helper/simple_http.rb +434 -0
- data/lib/ramaze/spec/helper/snippets.rb +14 -0
- data/lib/ramaze/spec/helper.rb +135 -0
- data/lib/ramaze/spec.rb +1 -0
- data/lib/ramaze/store/default.rb +109 -0
- data/lib/ramaze/template/amrita2.rb +45 -0
- data/lib/ramaze/template/builder.rb +28 -0
- data/lib/ramaze/template/erubis.rb +41 -0
- data/lib/ramaze/template/ezamar/element.rb +169 -0
- data/lib/ramaze/template/ezamar/engine.rb +76 -0
- data/lib/ramaze/template/ezamar/morpher.rb +135 -0
- data/lib/ramaze/template/ezamar/render_partial.rb +31 -0
- data/lib/ramaze/template/ezamar/textpow.syntax +34 -0
- data/lib/ramaze/template/ezamar.rb +42 -0
- data/lib/ramaze/template/haml.rb +37 -0
- data/lib/ramaze/template/liquid.rb +36 -0
- data/lib/ramaze/template/markaby.rb +52 -0
- data/lib/ramaze/template/maruku.rb +34 -0
- data/lib/ramaze/template/nagoro.rb +52 -0
- data/lib/ramaze/template/none.rb +14 -0
- data/lib/ramaze/template/redcloth.rb +25 -0
- data/lib/ramaze/template/remarkably.rb +38 -0
- data/lib/ramaze/template/sass.rb +37 -0
- data/lib/ramaze/template/tagz.rb +79 -0
- data/lib/ramaze/template/tenjin.rb +74 -0
- data/lib/ramaze/template/xslt.rb +100 -0
- data/lib/ramaze/template.rb +87 -0
- data/lib/ramaze/tool/create.rb +48 -0
- data/lib/ramaze/tool/daemonize.rb +37 -0
- data/lib/ramaze/tool/localize.rb +202 -0
- data/lib/ramaze/tool/mime.rb +35 -0
- data/lib/ramaze/tool/mime_types.yaml +615 -0
- data/lib/ramaze/tool/project_creator.rb +110 -0
- data/lib/ramaze/tool/record.rb +6 -0
- data/lib/ramaze/tool.rb +9 -0
- data/lib/ramaze/trinity.rb +16 -0
- data/lib/ramaze/version.rb +6 -0
- data/lib/ramaze.rb +133 -0
- data/lib/vendor/bacon.rb +323 -0
- data/rake_tasks/conf.rake +71 -0
- data/rake_tasks/coverage.rake +46 -0
- data/rake_tasks/gem.rake +74 -0
- data/rake_tasks/git.rake +41 -0
- data/rake_tasks/maintenance.rake +386 -0
- data/rake_tasks/metric.rake +24 -0
- data/rake_tasks/release.rake +76 -0
- data/rake_tasks/spec.rake +61 -0
- data/ramaze.gemspec +773 -0
- data/spec/contrib/auto_params.rb +121 -0
- data/spec/contrib/profiling.rb +29 -0
- data/spec/contrib/sequel/fill.rb +47 -0
- data/spec/examples/caching.rb +19 -0
- data/spec/examples/css.rb +15 -0
- data/spec/examples/element.rb +15 -0
- data/spec/examples/hello.rb +11 -0
- data/spec/examples/linking.rb +18 -0
- data/spec/examples/simple.rb +45 -0
- data/spec/examples/simple_auth.rb +32 -0
- data/spec/examples/templates/template_amrita2.rb +16 -0
- data/spec/examples/templates/template_erubis.rb +23 -0
- data/spec/examples/templates/template_ezamar.rb +23 -0
- data/spec/examples/templates/template_haml.rb +23 -0
- data/spec/examples/templates/template_liquid.rb +29 -0
- data/spec/examples/templates/template_markaby.rb +23 -0
- data/spec/examples/templates/template_redcloth.rb +28 -0
- data/spec/examples/templates/template_remarkably.rb +23 -0
- data/spec/examples/templates/template_tenjin.rb +28 -0
- data/spec/helper.rb +3 -0
- data/spec/ramaze/action/basics.rb +36 -0
- data/spec/ramaze/action/cache.rb +87 -0
- data/spec/ramaze/action/file_cache.rb +70 -0
- data/spec/ramaze/action/layout.rb +190 -0
- data/spec/ramaze/action/render.rb +31 -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.xhtml +1 -0
- data/spec/ramaze/action/view/single_wrapper.xhtml +1 -0
- data/spec/ramaze/action/view/sub/sub_wrapper.xhtml +1 -0
- data/spec/ramaze/adapter/ebb.rb +12 -0
- data/spec/ramaze/adapter/mongrel.rb +12 -0
- data/spec/ramaze/adapter/record.rb +31 -0
- data/spec/ramaze/adapter/webrick.rb +12 -0
- data/spec/ramaze/adapter.rb +49 -0
- data/spec/ramaze/cache.rb +140 -0
- data/spec/ramaze/controller/actionless_templates.rb +32 -0
- data/spec/ramaze/controller/resolve.rb +32 -0
- data/spec/ramaze/controller/subclass.rb +36 -0
- data/spec/ramaze/controller/template_resolving.rb +113 -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/controller.rb +180 -0
- data/spec/ramaze/current/request.rb +30 -0
- data/spec/ramaze/current/session.rb +97 -0
- data/spec/ramaze/dispatcher/directory.rb +55 -0
- data/spec/ramaze/dispatcher/file.rb +60 -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/dispatcher.rb +31 -0
- data/spec/ramaze/element.rb +107 -0
- data/spec/ramaze/error.rb +94 -0
- data/spec/ramaze/gestalt.rb +131 -0
- data/spec/ramaze/helper/aspect.rb +101 -0
- data/spec/ramaze/helper/auth.rb +66 -0
- data/spec/ramaze/helper/cache.rb +160 -0
- data/spec/ramaze/helper/cgi.rb +43 -0
- data/spec/ramaze/helper/file.rb +18 -0
- data/spec/ramaze/helper/flash.rb +133 -0
- data/spec/ramaze/helper/form.rb +118 -0
- data/spec/ramaze/helper/formatting.rb +54 -0
- data/spec/ramaze/helper/link.rb +124 -0
- data/spec/ramaze/helper/pager.rb +99 -0
- data/spec/ramaze/helper/partial.rb +88 -0
- data/spec/ramaze/helper/redirect.rb +112 -0
- data/spec/ramaze/helper/simple_captcha.rb +22 -0
- data/spec/ramaze/helper/stack.rb +73 -0
- data/spec/ramaze/helper/user.rb +43 -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/localize.rb +89 -0
- data/spec/ramaze/log/informer.rb +72 -0
- data/spec/ramaze/log/syslog.rb +73 -0
- data/spec/ramaze/morpher.rb +111 -0
- data/spec/ramaze/params.rb +157 -0
- data/spec/ramaze/public/error404.xhtml +1 -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/ebb.rb +9 -0
- data/spec/ramaze/request/mongrel.rb +9 -0
- data/spec/ramaze/request/thin.rb +9 -0
- data/spec/ramaze/request/webrick.rb +5 -0
- data/spec/ramaze/request.rb +185 -0
- data/spec/ramaze/rewrite/file.css +1 -0
- data/spec/ramaze/rewrite.rb +36 -0
- data/spec/ramaze/route.rb +131 -0
- data/spec/ramaze/session.rb +94 -0
- data/spec/ramaze/store/default.rb +71 -0
- data/spec/ramaze/struct.rb +47 -0
- data/spec/ramaze/template/amrita2/external.amrita +6 -0
- data/spec/ramaze/template/amrita2/sum.amrita +1 -0
- data/spec/ramaze/template/amrita2.rb +50 -0
- data/spec/ramaze/template/builder/external.rxml +3 -0
- data/spec/ramaze/template/builder.rb +51 -0
- data/spec/ramaze/template/erubis/sum.rhtml +1 -0
- data/spec/ramaze/template/erubis.rb +41 -0
- data/spec/ramaze/template/ezamar/another/long/action.zmr +1 -0
- data/spec/ramaze/template/ezamar/combined.zmr +1 -0
- data/spec/ramaze/template/ezamar/file_only.zmr +1 -0
- data/spec/ramaze/template/ezamar/index.zmr +1 -0
- data/spec/ramaze/template/ezamar/nested.zmr +1 -0
- data/spec/ramaze/template/ezamar/other__index.xhtml +1 -0
- data/spec/ramaze/template/ezamar/some__long__action.zmr +1 -0
- data/spec/ramaze/template/ezamar/sum.zmr +1 -0
- data/spec/ramaze/template/ezamar.rb +63 -0
- data/spec/ramaze/template/haml/index.haml +5 -0
- data/spec/ramaze/template/haml/locals.haml +2 -0
- data/spec/ramaze/template/haml/with_vars.haml +4 -0
- data/spec/ramaze/template/haml.rb +66 -0
- data/spec/ramaze/template/liquid/index.liquid +1 -0
- data/spec/ramaze/template/liquid/products.liquid +45 -0
- data/spec/ramaze/template/liquid.rb +99 -0
- data/spec/ramaze/template/markaby/external.mab +8 -0
- data/spec/ramaze/template/markaby/sum.mab +1 -0
- data/spec/ramaze/template/markaby.rb +61 -0
- data/spec/ramaze/template/nagoro/another/long/action.nag +1 -0
- data/spec/ramaze/template/nagoro/combined.nag +1 -0
- data/spec/ramaze/template/nagoro/file_only.nag +1 -0
- data/spec/ramaze/template/nagoro/index.nag +1 -0
- data/spec/ramaze/template/nagoro/nested.nag +1 -0
- data/spec/ramaze/template/nagoro/some__long__action.nag +1 -0
- data/spec/ramaze/template/nagoro/sum.nag +1 -0
- data/spec/ramaze/template/nagoro.rb +64 -0
- data/spec/ramaze/template/ramaze/external.test +1 -0
- data/spec/ramaze/template/redcloth/external.redcloth +1 -0
- data/spec/ramaze/template/redcloth.rb +38 -0
- data/spec/ramaze/template/remarkably/external.rem +8 -0
- data/spec/ramaze/template/remarkably/sum.rem +1 -0
- data/spec/ramaze/template/remarkably.rb +58 -0
- data/spec/ramaze/template/sass/file.css.sass +5 -0
- data/spec/ramaze/template/sass.rb +69 -0
- data/spec/ramaze/template/tagz/external.tagz +8 -0
- data/spec/ramaze/template/tagz/sum.tagz +1 -0
- data/spec/ramaze/template/tagz.rb +62 -0
- data/spec/ramaze/template/tenjin/external.tenjin +1 -0
- data/spec/ramaze/template/tenjin.rb +47 -0
- data/spec/ramaze/template/xslt/concat_words.xsl +16 -0
- data/spec/ramaze/template/xslt/index.xsl +14 -0
- data/spec/ramaze/template/xslt/products.xsl +32 -0
- data/spec/ramaze/template/xslt/ruby_version.xsl +14 -0
- data/spec/ramaze/template/xslt.rb +90 -0
- data/spec/ramaze/template.rb +128 -0
- data/spec/snippets/array/put_within.rb +33 -0
- data/spec/snippets/binding/locals.rb +9 -0
- data/spec/snippets/divide.rb +19 -0
- data/spec/snippets/kernel/constant.rb +23 -0
- data/spec/snippets/numeric/filesize_format.rb +12 -0
- data/spec/snippets/numeric/time.rb +12 -0
- data/spec/snippets/object/__dir__.rb +8 -0
- data/spec/snippets/object/acquire.rb +71 -0
- data/spec/snippets/ordered_set.rb +63 -0
- data/spec/snippets/ramaze/caller_info.rb +39 -0
- data/spec/snippets/ramaze/caller_lines.rb +30 -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 +20 -0
- metadata +823 -0
@@ -0,0 +1,18 @@
|
|
1
|
+
# Copyright (c) 2008 Michael Fellinger m.fellinger@gmail.com
|
2
|
+
# All files in this distribution are subject to the terms of the Ruby license.
|
3
|
+
|
4
|
+
module Ramaze
|
5
|
+
Global.test_connections = false
|
6
|
+
|
7
|
+
module Adapter
|
8
|
+
# Our Fcgi adapter acts as wrapper for the Rack::Handler::FastCGI.
|
9
|
+
class Fcgi < Base
|
10
|
+
# start FastCGI in a new thread, host and port parameter are only taken
|
11
|
+
# to make it compatible with other adapters but have no influence and
|
12
|
+
# can be omitted
|
13
|
+
def self.startup(host = nil, port = nil)
|
14
|
+
Thread.new{ Rack::Handler::FastCGI.run(self) }
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# Copyright (c) 2008 Michael Fellinger m.fellinger@gmail.com
|
2
|
+
# All files in this distribution are subject to the terms of the Ruby license.
|
3
|
+
|
4
|
+
module Ramaze
|
5
|
+
Global.test_connections = false
|
6
|
+
|
7
|
+
module Adapter
|
8
|
+
# Our Lsws adapter acts as wrapper for the Rack::Handler::LSWS.
|
9
|
+
class Lsws < Base
|
10
|
+
|
11
|
+
# start Lsws in a new thread, host and port parameter are only taken
|
12
|
+
# to make it compatible with other adapters but have no influence and
|
13
|
+
# can be omitted
|
14
|
+
def self.startup(host = nil, port = nil)
|
15
|
+
Thread.new{ Rack::Handler::LSWS.run(self) }
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# Copyright (c) 2008 Michael Fellinger m.fellinger@gmail.com
|
2
|
+
# All files in this distribution are subject to the terms of the Ruby license.
|
3
|
+
|
4
|
+
require 'mongrel'
|
5
|
+
require 'rack/handler/mongrel'
|
6
|
+
|
7
|
+
module Ramaze
|
8
|
+
module Adapter
|
9
|
+
|
10
|
+
# Our Mongrel adapter acts as wrapper for the Rack::Handler::Mongrel.
|
11
|
+
class Mongrel < Base
|
12
|
+
|
13
|
+
# start server on given host and port.
|
14
|
+
def self.startup(host, port)
|
15
|
+
@server = ::Mongrel::HttpServer.new(host, port)
|
16
|
+
@server.register('/', ::Rack::Handler::Mongrel.new(self))
|
17
|
+
@server.run
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
# Copyright (c) 2008 Jeremy Evans code@jeremyevans.net
|
2
|
+
# All files in this distribution are subject to the terms of the Ruby license.
|
3
|
+
|
4
|
+
require 'rack/handler/scgi'
|
5
|
+
|
6
|
+
module Ramaze
|
7
|
+
module Adapter
|
8
|
+
# Our Scgi adapter acts as wrapper for the Rack::Handler::SCGI.
|
9
|
+
class Scgi < Base
|
10
|
+
# start SCGI in a new thread
|
11
|
+
def self.startup(host, port)
|
12
|
+
Thread.new do
|
13
|
+
Rack::Handler::SCGI.run(self, :Host => host, :Port => port)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,7 @@
|
|
1
|
+
# Copyright (c) 2008 Michael Fellinger m.fellinger@gmail.com
|
2
|
+
# All files in this distribution are subject to the terms of the Ruby license.
|
3
|
+
|
4
|
+
Ramaze::Log.debug "Using Swiftiplied Mongrel"
|
5
|
+
|
6
|
+
require 'swiftcore/swiftiplied_mongrel'
|
7
|
+
require 'ramaze/adapter/mongrel'
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'thin'
|
2
|
+
require 'rack/handler/thin'
|
3
|
+
|
4
|
+
module Ramaze
|
5
|
+
module Adapter
|
6
|
+
class Thin < Base
|
7
|
+
# start server on given host and port.
|
8
|
+
def self.startup(host, port)
|
9
|
+
@server = ::Thin::Server.new(host, port, self)
|
10
|
+
::Thin::Logging.silent = true
|
11
|
+
@server.timeout = 3
|
12
|
+
|
13
|
+
Thread.new{ @server.start }
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
# Copyright (c) 2008 Michael Fellinger m.fellinger@gmail.com
|
2
|
+
# All files in this distribution are subject to the terms of the Ruby license.
|
3
|
+
|
4
|
+
require 'webrick'
|
5
|
+
require 'rack/handler/webrick'
|
6
|
+
|
7
|
+
module Ramaze
|
8
|
+
module Adapter
|
9
|
+
# Our WEBrick adapter acts as wrapper for the Rack::Handler::WEBrick.
|
10
|
+
class WEBrick < Base
|
11
|
+
OPTIONS = {
|
12
|
+
:Logger => Log,
|
13
|
+
:AccessLog => [
|
14
|
+
[Log, ::WEBrick::AccessLog::COMMON_LOG_FORMAT],
|
15
|
+
[Log, ::WEBrick::AccessLog::REFERER_LOG_FORMAT]
|
16
|
+
]
|
17
|
+
}
|
18
|
+
|
19
|
+
def self.startup(host, port)
|
20
|
+
options = OPTIONS.merge(:BindAddress => host, :Port => port)
|
21
|
+
@server = ::WEBrick::HTTPServer.new(options)
|
22
|
+
@server.mount('/', ::Rack::Handler::WEBrick, self)
|
23
|
+
Thread.new{ @server.start }
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
# Extending on WEBrick module
|
30
|
+
module WEBrick
|
31
|
+
|
32
|
+
# Extending on HTTPServlet
|
33
|
+
module HTTPServlet
|
34
|
+
|
35
|
+
# Extending on ProcHandler
|
36
|
+
#
|
37
|
+
# We alias PUT to GET and DELETE to GET so WEBrick handles them as well.
|
38
|
+
class ProcHandler
|
39
|
+
alias do_PUT do_GET
|
40
|
+
alias do_DELETE do_GET
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
@@ -0,0 +1,97 @@
|
|
1
|
+
# Copyright (c) 2008 Michael Fellinger m.fellinger@gmail.com
|
2
|
+
# All files in this distribution are subject to the terms of the Ruby license.
|
3
|
+
|
4
|
+
require 'ramaze/trinity'
|
5
|
+
require 'ramaze/tool/record'
|
6
|
+
require 'ramaze/adapter/base'
|
7
|
+
require 'ramaze/adapter/fake'
|
8
|
+
|
9
|
+
# for OSX compatibility
|
10
|
+
Socket.do_not_reverse_lookup = true
|
11
|
+
|
12
|
+
module Ramaze
|
13
|
+
|
14
|
+
# This module holds all classes and methods related to the adapters like
|
15
|
+
# webrick or mongrel.
|
16
|
+
# It's responsible for starting and stopping them.
|
17
|
+
|
18
|
+
module Adapter
|
19
|
+
class << self
|
20
|
+
|
21
|
+
# Is called by Ramaze.startup and will first call start_adapter and wait
|
22
|
+
# up to 3 seconds for an adapter to appear.
|
23
|
+
# It will then wait for the adapters to finish If Global.run_loose is
|
24
|
+
# set or otherwise pass you on control which is useful for testing or IRB
|
25
|
+
# sessions.
|
26
|
+
|
27
|
+
def startup options = {}
|
28
|
+
start_adapter
|
29
|
+
|
30
|
+
Timeout.timeout(3) do
|
31
|
+
sleep 0.01 until Global.server
|
32
|
+
end
|
33
|
+
|
34
|
+
Global.server.join unless Global.run_loose
|
35
|
+
|
36
|
+
rescue SystemExit
|
37
|
+
Ramaze.shutdown
|
38
|
+
rescue Object => ex
|
39
|
+
Log.error(ex)
|
40
|
+
Ramaze.shutdown
|
41
|
+
end
|
42
|
+
|
43
|
+
# Takes Global.adapter and starts if test_connections is positive that a
|
44
|
+
# connection can be made to the specified host and port.
|
45
|
+
# If you set Global.adapter to false it won't start any but deploy a
|
46
|
+
# dummy which is useful for testing purposes where you just send fake
|
47
|
+
# requests to Dispatcher.
|
48
|
+
|
49
|
+
def start_adapter
|
50
|
+
if adapter = Global.adapter
|
51
|
+
host, port = Global.host, Global.port
|
52
|
+
|
53
|
+
if Global.test_connections
|
54
|
+
test_connection(host, port)
|
55
|
+
Log.info("Ramaze is ready to run on: #{host}:#{port} using #{Global.adapter}")
|
56
|
+
end
|
57
|
+
|
58
|
+
adapter.start(host, port)
|
59
|
+
else
|
60
|
+
Fake.start
|
61
|
+
Log.warn("Seems like Global.adapter is turned off", "Continue without adapter.")
|
62
|
+
end
|
63
|
+
rescue LoadError => ex
|
64
|
+
Log.error(ex)
|
65
|
+
Log.warn("Continue without adapter.")
|
66
|
+
end
|
67
|
+
|
68
|
+
# Calls ::shutdown on all running adapters and waits up to 1 second for
|
69
|
+
# them to finish, then goes on to kill them and exit still.
|
70
|
+
|
71
|
+
def shutdown
|
72
|
+
Timeout.timeout(3) do
|
73
|
+
if Global.server.respond_to?(:shutdown)
|
74
|
+
Global.server.shutdown
|
75
|
+
end
|
76
|
+
end
|
77
|
+
rescue Timeout::Error
|
78
|
+
Global.server.kill!
|
79
|
+
end
|
80
|
+
|
81
|
+
# Opens a TCPServer temporarily and returns true if a connection is
|
82
|
+
# possible and false if none can be made
|
83
|
+
|
84
|
+
def test_connection(host, port)
|
85
|
+
Timeout.timeout(1) do
|
86
|
+
testsock = TCPServer.new(host, port)
|
87
|
+
testsock.close
|
88
|
+
true
|
89
|
+
end
|
90
|
+
rescue => ex
|
91
|
+
Log.error(ex)
|
92
|
+
Log.error("Cannot open connection on #{host}:#{port}")
|
93
|
+
Ramaze.shutdown
|
94
|
+
end
|
95
|
+
end
|
96
|
+
end
|
97
|
+
end
|
@@ -0,0 +1,69 @@
|
|
1
|
+
# Copyright (c) 2008 Michael Fellinger m.fellinger@gmail.com
|
2
|
+
# All files in this distribution are subject to the terms of the Ruby license.
|
3
|
+
require 'memcache'
|
4
|
+
|
5
|
+
module Ramaze
|
6
|
+
|
7
|
+
# Cache based on the memcache library which utilizes the memcache-daemon to
|
8
|
+
# store key/value pairs in namespaces.
|
9
|
+
|
10
|
+
class MemcachedCache
|
11
|
+
|
12
|
+
# Create a new MemcachedCache with host, port and a namespace that defaults
|
13
|
+
# to 'ramaze'
|
14
|
+
#
|
15
|
+
# For your own usage you should use another namespace.
|
16
|
+
|
17
|
+
def initialize(host = 'localhost', port = '11211', namespace = Global.runner)
|
18
|
+
namespace = Digest::SHA1.hexdigest(namespace)[0..16]
|
19
|
+
@cache = MemCache.new(["#{host}:#{port}"], :namespace => namespace, :multithread => true)
|
20
|
+
end
|
21
|
+
|
22
|
+
# please read the documentation of memcache-client for further methods.
|
23
|
+
# also, it is highly recommended to install memcache-client_extensions
|
24
|
+
# for a bit of speedup and more functionality
|
25
|
+
# Some examples:
|
26
|
+
#
|
27
|
+
# [key] #=> get a key
|
28
|
+
# [key] = value #=> set a key
|
29
|
+
# delete(key) #=> delete key
|
30
|
+
# set_many :x => :y, :n => :m #=> set many key/value pairs
|
31
|
+
# get_hash :x, :y #=> return a hash with key/value pairs
|
32
|
+
# stats #=> get some statistics about usage
|
33
|
+
# namespace #=> get the current namespace
|
34
|
+
# namespace = 'ramaze' #=> set a different namespace ('ramaze' is default)
|
35
|
+
# flush_all #=> flush the whole cache (deleting all)
|
36
|
+
# compression #=> see if compression is true/false
|
37
|
+
# compression = false #=> turn off compression (it's by default true)
|
38
|
+
|
39
|
+
def method_missing(*args, &block)
|
40
|
+
@cache.__send__(*args, &block)
|
41
|
+
rescue MemCache::MemCacheError => e
|
42
|
+
Log.error e.to_s
|
43
|
+
nil
|
44
|
+
end
|
45
|
+
|
46
|
+
# Fetch for multiple keys at once.
|
47
|
+
|
48
|
+
def get_multi(*keys)
|
49
|
+
# MemCache only responds to get_multi if the memcache-client_extensions gem
|
50
|
+
# is installed, so we check first and resort to another approach if not.
|
51
|
+
if @cache.respond_to?(:get_multi)
|
52
|
+
@cache.get_multi(*keys)
|
53
|
+
else
|
54
|
+
@cache.get_hash(*keys)
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
# same as get_multi, but returns only the values (in order)
|
59
|
+
|
60
|
+
def values_at(*keys)
|
61
|
+
get_multi(*keys).values_at(*keys)
|
62
|
+
end
|
63
|
+
|
64
|
+
# Flush everything, dangerous!
|
65
|
+
def clear
|
66
|
+
@cache.flush_all
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
@@ -0,0 +1,68 @@
|
|
1
|
+
# Copyright (c) 2008 Michael Fellinger m.fellinger@gmail.com
|
2
|
+
# All files in this distribution are subject to the terms of the Ruby license.
|
3
|
+
require 'yaml/store'
|
4
|
+
|
5
|
+
module Ramaze
|
6
|
+
|
7
|
+
# Cache based on _whys YAML::Store, which uses PStore to serialize objects
|
8
|
+
# as YAML in a thread-safe manner.
|
9
|
+
|
10
|
+
class YAMLStoreCache
|
11
|
+
|
12
|
+
attr_accessor :file
|
13
|
+
|
14
|
+
# create a new YAML::Store with the given file (which will be created if it
|
15
|
+
# is not already there).
|
16
|
+
|
17
|
+
def initialize(file = 'cache.yaml')
|
18
|
+
@file = file
|
19
|
+
@cache = YAML::Store.new(file)
|
20
|
+
end
|
21
|
+
|
22
|
+
# return the values for given keys.
|
23
|
+
|
24
|
+
def values_at(*keys)
|
25
|
+
transaction do |y|
|
26
|
+
keys.map{|k| y[k]}
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
# Loads @file into memory via YAML::load_file
|
31
|
+
|
32
|
+
def underlying_yaml
|
33
|
+
YAML.load_file(@file)
|
34
|
+
end
|
35
|
+
|
36
|
+
# clears the YAML::Store based cache, by emptying the YAML file.
|
37
|
+
|
38
|
+
def clear
|
39
|
+
transaction do |y|
|
40
|
+
File.open(@file, 'w+'){|f| f.puts({}.to_yaml)}
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
# Deletes the key from YAML::Store based cache.
|
45
|
+
|
46
|
+
def delete(key)
|
47
|
+
transaction do |y|
|
48
|
+
y.delete(key)
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
# just a helper to use transactions.
|
53
|
+
|
54
|
+
def transaction(&block)
|
55
|
+
@cache.transaction do
|
56
|
+
yield(@cache)
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
# catch everything else and use a transaction to send it.
|
61
|
+
|
62
|
+
def method_missing(*args, &block)
|
63
|
+
transaction do |y|
|
64
|
+
y.send(*args, &block)
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
data/lib/ramaze/cache.rb
ADDED
@@ -0,0 +1,113 @@
|
|
1
|
+
# Copyright (c) 2008 Michael Fellinger m.fellinger@gmail.com
|
2
|
+
# All files in this distribution are subject to the terms of the Ruby license.
|
3
|
+
|
4
|
+
require 'ramaze/cache/memory'
|
5
|
+
|
6
|
+
module Ramaze
|
7
|
+
autoload :YAMLStoreCache, "ramaze/cache/yaml_store.rb"
|
8
|
+
autoload :MemcachedCache, "ramaze/cache/memcached.rb"
|
9
|
+
|
10
|
+
# This is the wrapper of all caches, providing mechanism
|
11
|
+
# for switching caching from one adapter to another.
|
12
|
+
|
13
|
+
class Cache
|
14
|
+
include Enumerable
|
15
|
+
|
16
|
+
# Holds all the instances of Cache that are being added.
|
17
|
+
CACHES = {} unless defined?(CACHES)
|
18
|
+
|
19
|
+
attr_accessor :cache
|
20
|
+
|
21
|
+
class << self
|
22
|
+
|
23
|
+
# Initializes the Cache for the general caches Ramaze uses.
|
24
|
+
# Cache#startup is called by Ramaze#startup, when initializing the
|
25
|
+
# Ramaze.trait(:essentials).
|
26
|
+
|
27
|
+
def startup(options)
|
28
|
+
Cache.add :compiled, :actions, :patterns,
|
29
|
+
:resolved, :shield, :action_methods
|
30
|
+
end
|
31
|
+
|
32
|
+
# This will define a method to access a new cache directly over
|
33
|
+
# singleton-methods on Cache.
|
34
|
+
#---
|
35
|
+
# The @cache_name is internally used for caches which do not save
|
36
|
+
# different caches in different namespaces, for example memcached.
|
37
|
+
#+++
|
38
|
+
|
39
|
+
def add *keys
|
40
|
+
keys.each{|key|
|
41
|
+
klass = Global.cache_alternative.fetch(key, Global.cache)
|
42
|
+
add_on(key, klass)
|
43
|
+
}
|
44
|
+
Log.dev("Added caches for: #{keys.join(', ')}")
|
45
|
+
end
|
46
|
+
|
47
|
+
# Define a new cache available by Cache::key
|
48
|
+
def add_on(key, cache_class)
|
49
|
+
CACHES[key] = new(cache_class)
|
50
|
+
CACHES[key].instance_variable_set("@cache_name", key)
|
51
|
+
eval("def self.%s; CACHES[%p]; end" % [key, key])
|
52
|
+
end
|
53
|
+
|
54
|
+
end
|
55
|
+
|
56
|
+
# Initializes the cache, defined by Global.cache
|
57
|
+
def initialize(cache = Global.cache)
|
58
|
+
@cache = cache.new
|
59
|
+
end
|
60
|
+
|
61
|
+
# Gets the value for the given key, or +nil+ if not found.
|
62
|
+
def [](key)
|
63
|
+
fetch(key)
|
64
|
+
end
|
65
|
+
|
66
|
+
# Sets _key_ to _value_ with an infinite time to live.
|
67
|
+
def []=(key, value)
|
68
|
+
store(key, value)
|
69
|
+
end
|
70
|
+
|
71
|
+
# Empties this cache.
|
72
|
+
def clear
|
73
|
+
@cache.clear
|
74
|
+
end
|
75
|
+
|
76
|
+
# Deletes each passed key from this cache.
|
77
|
+
def delete(*args)
|
78
|
+
args.each do |arg|
|
79
|
+
@cache.delete("#{@cache_name}:#{arg}")
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
# Gets the value of the given key, or _default_ if not found.
|
84
|
+
def fetch(key, default = nil)
|
85
|
+
return default unless entry = @cache["#{@cache_name}:#{key}"]
|
86
|
+
return entry[:value] if entry[:expires].nil? || entry[:expires] > Time.now
|
87
|
+
@cache.delete("#{@cache_name}:#{key}")
|
88
|
+
default
|
89
|
+
end
|
90
|
+
|
91
|
+
alias get fetch
|
92
|
+
|
93
|
+
# Sets key to value. Supports the following options:
|
94
|
+
# [+:ttl+] time to live in seconds
|
95
|
+
def store(key, value, opts = {})
|
96
|
+
opts = {:ttl => opts} if opts.is_a?(Integer)
|
97
|
+
@cache["#{@cache_name}:#{key}"] = {
|
98
|
+
:expires => opts[:ttl] ? Time.now + opts[:ttl].to_i : nil,
|
99
|
+
:value => value
|
100
|
+
}
|
101
|
+
value
|
102
|
+
end
|
103
|
+
|
104
|
+
alias set store
|
105
|
+
|
106
|
+
# Answers with value for each key.
|
107
|
+
def values_at(*keys)
|
108
|
+
values = []
|
109
|
+
keys.each {|key| values << fetch(key) }
|
110
|
+
values
|
111
|
+
end
|
112
|
+
end
|
113
|
+
end
|
@@ -0,0 +1,58 @@
|
|
1
|
+
# from merb/core_ext/get_args.rb
|
2
|
+
begin
|
3
|
+
require 'parse_tree'
|
4
|
+
require 'ruby2ruby'
|
5
|
+
|
6
|
+
class ParseTreeArray < Array
|
7
|
+
def self.translate(*args)
|
8
|
+
self.new(ParseTree.translate(*args))
|
9
|
+
end
|
10
|
+
|
11
|
+
def deep_array_node(type = nil)
|
12
|
+
each do |node|
|
13
|
+
return ParseTreeArray.new(node) if node.is_a?(Array) && (!type || node[0] == type)
|
14
|
+
next unless node.is_a?(Array)
|
15
|
+
return ParseTreeArray.new(node).deep_array_node(type)
|
16
|
+
end
|
17
|
+
nil
|
18
|
+
end
|
19
|
+
|
20
|
+
def arg_nodes
|
21
|
+
self[1..-1].inject([]) do |sum,item|
|
22
|
+
sum << [item] unless item.is_a?(Array)
|
23
|
+
sum
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
def get_args
|
28
|
+
arg_node = deep_array_node(:args)
|
29
|
+
return nil unless arg_node
|
30
|
+
args = arg_node.arg_nodes
|
31
|
+
default_node = arg_node.deep_array_node(:block)
|
32
|
+
return args unless default_node
|
33
|
+
lasgns = default_node[1..-1]
|
34
|
+
lasgns.each do |asgn|
|
35
|
+
args.assoc(asgn[1]) << eval(RubyToRuby.new.process(asgn[2]))
|
36
|
+
end
|
37
|
+
args
|
38
|
+
end
|
39
|
+
|
40
|
+
end
|
41
|
+
|
42
|
+
module GetArgs
|
43
|
+
def get_args
|
44
|
+
klass, meth = self.to_s.split(/ /).to_a[1][0..-2].split("#")
|
45
|
+
klass = $` if klass =~ /\(/
|
46
|
+
ParseTreeArray.translate(Object.const_get(klass), meth).get_args
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
class UnboundMethod
|
51
|
+
include GetArgs
|
52
|
+
end
|
53
|
+
|
54
|
+
class Method
|
55
|
+
include GetArgs
|
56
|
+
end
|
57
|
+
rescue LoadError
|
58
|
+
end
|