rjspotter-ramaze 2009.06.29
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/.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
@@ -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
|
+
module Ramaze
|
5
|
+
module CoreExtensions
|
6
|
+
|
7
|
+
# Extensions for String
|
8
|
+
|
9
|
+
module String
|
10
|
+
|
11
|
+
# simple transformation to CamelCase from snake_case
|
12
|
+
#
|
13
|
+
# 'foo_bar'.camel_case # => 'FooBar'
|
14
|
+
|
15
|
+
def camel_case
|
16
|
+
split('_').map{|e| e.capitalize}.join
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,31 @@
|
|
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
|
+
module CoreExtensions
|
6
|
+
# Extensions for String
|
7
|
+
|
8
|
+
module String
|
9
|
+
{ :reset => 0,
|
10
|
+
:bold => 1,
|
11
|
+
:dark => 2,
|
12
|
+
:underline => 4,
|
13
|
+
:blink => 5,
|
14
|
+
:negative => 7,
|
15
|
+
:black => 30,
|
16
|
+
:red => 31,
|
17
|
+
:green => 32,
|
18
|
+
:yellow => 33,
|
19
|
+
:blue => 34,
|
20
|
+
:magenta => 35,
|
21
|
+
:cyan => 36,
|
22
|
+
:white => 37,
|
23
|
+
}.each do |key, value|
|
24
|
+
define_method key do
|
25
|
+
"\e[#{value}m" + self + "\e[0m"
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,20 @@
|
|
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
|
+
module CoreExtensions
|
6
|
+
|
7
|
+
# Extensions for String
|
8
|
+
|
9
|
+
module String
|
10
|
+
unless ''.respond_to?(:end_with?)
|
11
|
+
# Compatibility with 1.9
|
12
|
+
def end_with?(other)
|
13
|
+
other = other.to_s
|
14
|
+
self[-other.size, other.size] == other
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
require 'cgi'
|
2
|
+
require 'uri'
|
3
|
+
|
4
|
+
module Ramaze
|
5
|
+
module CoreExtensions
|
6
|
+
|
7
|
+
# Extensions for String
|
8
|
+
|
9
|
+
module String
|
10
|
+
|
11
|
+
# String#escape is an extensible escaping mechanism for string. currently
|
12
|
+
# it suports
|
13
|
+
# '<div>foo bar</div>'.esc(:html)
|
14
|
+
# 'foo bar'.esc(:uri)
|
15
|
+
# 'foo bar'.esc(:cgi)
|
16
|
+
|
17
|
+
def escape which = :html
|
18
|
+
case which
|
19
|
+
when :html
|
20
|
+
Rack::Utils.escape_html(self)
|
21
|
+
when :cgi
|
22
|
+
Rack::Utils.escape(self)
|
23
|
+
when :uri
|
24
|
+
::URI.escape(self)
|
25
|
+
else
|
26
|
+
raise ArgumentError, "do not know how to escape '#{ which }'"
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
alias_method 'esc', 'escape'
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|
34
|
+
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
|
+
module Ramaze
|
5
|
+
module CoreExtensions
|
6
|
+
|
7
|
+
# Extensions for String
|
8
|
+
|
9
|
+
module String
|
10
|
+
unless ''.respond_to?(:ord)
|
11
|
+
|
12
|
+
# compatibility with Ruby 1.9
|
13
|
+
|
14
|
+
def ord
|
15
|
+
self[0]
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
21
|
+
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
|
+
module Ramaze
|
5
|
+
module CoreExtensions
|
6
|
+
|
7
|
+
# Extensions for String
|
8
|
+
|
9
|
+
module String
|
10
|
+
|
11
|
+
# convert to snake_case from CamelCase
|
12
|
+
#
|
13
|
+
# 'FooBar'.snake_case # => 'foo_bar'
|
14
|
+
|
15
|
+
def snake_case
|
16
|
+
gsub(/\B[A-Z][^A-Z]/, '_\&').downcase.gsub(' ', '_')
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module Ramaze
|
2
|
+
module CoreExtensions
|
3
|
+
|
4
|
+
# Extensions for String
|
5
|
+
|
6
|
+
module String
|
7
|
+
|
8
|
+
unless ''.respond_to?(:start_with?)
|
9
|
+
|
10
|
+
# Compatibility with 1.9
|
11
|
+
|
12
|
+
def start_with?(other)
|
13
|
+
other = other.to_s
|
14
|
+
self[0, other.size] == other
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
module Ramaze
|
2
|
+
module CoreExtensions
|
3
|
+
|
4
|
+
# Extensions for String
|
5
|
+
|
6
|
+
module String
|
7
|
+
|
8
|
+
# Useful for writing indented String and unindent on demand, based on the
|
9
|
+
# first line with indentation.
|
10
|
+
def unindent
|
11
|
+
find_indent = proc{ |l| l.find{|l| !l.strip.empty?}.to_s[/^(\s+)/, 1] }
|
12
|
+
|
13
|
+
lines = self.split("\n")
|
14
|
+
space = find_indent[lines]
|
15
|
+
space = find_indent[lines.reverse] unless space
|
16
|
+
|
17
|
+
strip.gsub(/^#{space}/, '')
|
18
|
+
end
|
19
|
+
alias ui unindent
|
20
|
+
|
21
|
+
# Destructive variant of undindent, replacing the String
|
22
|
+
def unindent!
|
23
|
+
self.replace unindent
|
24
|
+
end
|
25
|
+
alias ui! unindent!
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -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
|
+
# Extensions for Thread
|
5
|
+
|
6
|
+
class Thread
|
7
|
+
# Copy all thread variables into the new thread
|
8
|
+
|
9
|
+
def self.into *args
|
10
|
+
Thread.new(Thread.current, *args) do |thread, *args|
|
11
|
+
thread.keys.each do |k|
|
12
|
+
Thread.current[k] = thread[k] unless k.to_s =~ /^__/
|
13
|
+
end
|
14
|
+
|
15
|
+
yield(*args)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
data/lib/ramaze/spec.rb
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
require File.expand_path('../', __FILE__) unless defined?(Ramaze)
|
2
|
+
|
3
|
+
def spec_requires(*libs)
|
4
|
+
spec_precondition 'require' do
|
5
|
+
libs.each{|lib| require(lib) }
|
6
|
+
end
|
7
|
+
end
|
8
|
+
alias spec_require spec_requires
|
9
|
+
|
10
|
+
def spec_precondition(name)
|
11
|
+
yield
|
12
|
+
rescue LoadError => ex
|
13
|
+
puts "Spec require: %p failed: %p" % [name, ex.message]
|
14
|
+
exit 0
|
15
|
+
rescue Exception => ex
|
16
|
+
puts "Spec precondition: %p failed: %p" % [name, ex.message]
|
17
|
+
exit 0
|
18
|
+
end
|
19
|
+
|
20
|
+
module Ramaze
|
21
|
+
Mock::OPTIONS[:app] = Ramaze
|
22
|
+
|
23
|
+
middleware!(:spec){|m| m.run(AppMap) }
|
24
|
+
end
|
25
|
+
|
26
|
+
# FIXME: will remove that in 2009.07, and then we can offer integration with
|
27
|
+
# any other test-framework we like and they can share this code.
|
28
|
+
# Then Ramaze can be:
|
29
|
+
# Any ruby, any ORM, any templating-engine, any test-framework
|
30
|
+
unless defined?(Bacon)
|
31
|
+
Ramaze.deprecated "require('ramaze/spec')", "require('ramaze/spec/bacon')"
|
32
|
+
require 'ramaze/spec/bacon'
|
33
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
begin
|
2
|
+
require 'bacon'
|
3
|
+
rescue LoadError
|
4
|
+
require 'rubygems'
|
5
|
+
require 'bacon'
|
6
|
+
end
|
7
|
+
|
8
|
+
require File.expand_path('../', __FILE__) unless defined?(Ramaze)
|
9
|
+
|
10
|
+
require 'innate/spec/bacon'
|
11
|
+
|
12
|
+
shared :rack_test do
|
13
|
+
Ramaze.setup_dependencies
|
14
|
+
extend Rack::Test::Methods
|
15
|
+
|
16
|
+
def app; Ramaze::AppMap; end
|
17
|
+
end
|
18
|
+
|
19
|
+
shared :webrat do
|
20
|
+
behaves_like :rack_test
|
21
|
+
|
22
|
+
require 'webrat'
|
23
|
+
|
24
|
+
Webrat.configure{|config| config.mode = :rack_test }
|
25
|
+
|
26
|
+
extend Webrat::Methods
|
27
|
+
extend Webrat::Matchers
|
28
|
+
end
|
29
|
+
|
30
|
+
# Backwards compatibility
|
31
|
+
shared(:mock){
|
32
|
+
Ramaze.deprecated('behaves_like(:mock)', 'behaves_like(:rack_test)')
|
33
|
+
behaves_like :rack_test
|
34
|
+
}
|
@@ -0,0 +1,82 @@
|
|
1
|
+
module Bacon
|
2
|
+
module PrettyOutput
|
3
|
+
NAME = ''
|
4
|
+
|
5
|
+
# store name and run
|
6
|
+
def handle_specification(name)
|
7
|
+
NAME.replace name
|
8
|
+
puts NAME
|
9
|
+
yield
|
10
|
+
puts
|
11
|
+
end
|
12
|
+
|
13
|
+
# Core, yields the requirement and outputs problems
|
14
|
+
def handle_requirement(description)
|
15
|
+
print "- #{description}\n"
|
16
|
+
error = yield
|
17
|
+
|
18
|
+
unless error.empty?
|
19
|
+
if defined?(Ramaze::Logging)
|
20
|
+
puts '', " #{NAME} -- #{description} [FAILED]".center(70, '-'), ''
|
21
|
+
colors = Ramaze::Logger::Informer::COLORS
|
22
|
+
|
23
|
+
until RamazeLogger.history.empty?
|
24
|
+
tag, line = RamazeLogger.history.shift
|
25
|
+
out = "%6s | %s" % [tag.to_s, line]
|
26
|
+
puts out.send(colors[tag])
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
general_error
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
# Show nicer output on error
|
35
|
+
def general_error
|
36
|
+
puts "", ErrorLog
|
37
|
+
ErrorLog.scan(/^\s*(.*?):(\d+): #{NAME} - (.*?)$/) do
|
38
|
+
puts "#{ENV['EDITOR'] || 'vim'} #$1 +#$2 # #$3"
|
39
|
+
end
|
40
|
+
ErrorLog.replace ''
|
41
|
+
end
|
42
|
+
|
43
|
+
# output summary
|
44
|
+
def handle_summary
|
45
|
+
puts
|
46
|
+
puts "%d tests, %d assertions, %d failures, %d errors" %
|
47
|
+
Counter.values_at(:specifications, :requirements, :failed, :errors)
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
if defined?(Ramaze::Logging)
|
53
|
+
module Ramaze
|
54
|
+
# Special Logger, stores everything in its history
|
55
|
+
class SpecLogger
|
56
|
+
include Ramaze::Logging
|
57
|
+
include Enumerable
|
58
|
+
|
59
|
+
attr_accessor :history
|
60
|
+
|
61
|
+
# Create new history
|
62
|
+
def initialize
|
63
|
+
@history = []
|
64
|
+
end
|
65
|
+
|
66
|
+
# Yield the history
|
67
|
+
def each
|
68
|
+
@history.each{|e| yield(e) }
|
69
|
+
end
|
70
|
+
|
71
|
+
# general log
|
72
|
+
def log(tag, str)
|
73
|
+
@history << [tag, str]
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
module Bacon::PrettyOutput
|
79
|
+
RamazeLogger = Ramaze::SpecLogger.new
|
80
|
+
Ramaze::Log.loggers = [RamazeLogger]
|
81
|
+
end
|
82
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
if caller
|
2
|
+
snippet = caller.grep(%r!spec/snippets/!).first.split(':').first
|
3
|
+
require File.expand_path(snippet).gsub('/spec/', '/lib/ramaze/')
|
4
|
+
|
5
|
+
if defined?(Ramaze::CoreExtensions)
|
6
|
+
Ramaze::CoreExtensions.constants.each do |const|
|
7
|
+
ext = Ramaze::CoreExtensions.const_get(const)
|
8
|
+
into = Module.const_get(const)
|
9
|
+
into.__send__(:include, ext)
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
require 'bacon'
|
15
|
+
|
16
|
+
Bacon.summary_on_exit
|
@@ -0,0 +1,19 @@
|
|
1
|
+
shared :template_spec do
|
2
|
+
behaves_like :mock
|
3
|
+
|
4
|
+
def spec_template(spec_engine)
|
5
|
+
it 'works on /' do
|
6
|
+
get('/').body.strip.
|
7
|
+
should =~ %r{<a href\s*=\s*"/">Home</a>\s+\|\s+<a href\s*=\s*"/internal">internal</a>\s+\|\s+<a href\s*=\s*"/external">external</a>}
|
8
|
+
end
|
9
|
+
|
10
|
+
%w[/internal /external].each do |url|
|
11
|
+
it "works on #{url}" do
|
12
|
+
html = get(url).body
|
13
|
+
html.should.not == nil
|
14
|
+
html.should =~ %r{<title>Template::#{spec_engine} (internal|external)</title>}
|
15
|
+
html.should =~ %r{<h1>The (internal|external) Template for #{spec_engine}</h1>}
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,340 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
### This module offers the functionality to start, stop, restart, create,
|
3
|
+
### Check status, or run a console of a ramaze application
|
4
|
+
### see ramaze -h for usage
|
5
|
+
module Ramaze
|
6
|
+
module Tool
|
7
|
+
module Bin
|
8
|
+
module Helpers # Helper methods {{{
|
9
|
+
|
10
|
+
def default_pidfile # {{{
|
11
|
+
return @default_pidfile if @default_pidfile
|
12
|
+
require "pathname"
|
13
|
+
@default_pidfile = (Pathname.new(".").expand_path.basename.to_s + ".pid").strip
|
14
|
+
end # }}}
|
15
|
+
|
16
|
+
# We're really only concerned about win32ole, so we focus our check on its
|
17
|
+
# ability to load that
|
18
|
+
def is_windows? # {{{
|
19
|
+
return @is_win if @is_win
|
20
|
+
begin
|
21
|
+
require "win32ole"
|
22
|
+
rescue LoadError
|
23
|
+
end
|
24
|
+
@is_win ||= Object.const_defined?("WIN32OLE")
|
25
|
+
end # }}}
|
26
|
+
|
27
|
+
# Find the path to rackup, by searching for -R (undocumented cli argument),
|
28
|
+
# then checking RUBYLIB for the _first_ rack it can find there, finally
|
29
|
+
# falling back to gems and looking for rackup in the gem bindir.
|
30
|
+
# If we can't find rackup we're raising; not even #usage is sane without
|
31
|
+
# rackup.
|
32
|
+
def rackup_path # {{{
|
33
|
+
return @rackup_path if @rackup_path
|
34
|
+
# Use the supplied path if the user supplied -R
|
35
|
+
if path_supplied = ARGV.delete("-R")
|
36
|
+
@rackup_path = ARGV.delete(@ourargs[@ourargs.index("-R") + 1])
|
37
|
+
if @rackup_path and File.file?(@rackup_path)
|
38
|
+
return @rackup_path
|
39
|
+
else
|
40
|
+
$stderr.puts "rackup does not exist at #{@rackup_path} (given with -R)"
|
41
|
+
end
|
42
|
+
end
|
43
|
+
# Check with 'which' on platforms which support it
|
44
|
+
unless is_windows?
|
45
|
+
@rackup_path = %x{which rackup}.to_s.chomp
|
46
|
+
if @rackup_path.size > 0 and File.file?(@rackup_path)
|
47
|
+
return @rackup_path
|
48
|
+
end
|
49
|
+
end
|
50
|
+
# check for rackup in RUBYLIB
|
51
|
+
libs = ENV["RUBYLIB"].to_s.split(is_windows? ? ";" : ":")
|
52
|
+
if rack_lib = libs.detect { |r| r.match %r<(\\|/)rack\1> }
|
53
|
+
require "pathname"
|
54
|
+
@rackup_path = Pathname.new(rack_lib).parent.join("bin").join("rackup").expand_path
|
55
|
+
return @rackup_path if File.file?(@rackup_path)
|
56
|
+
end
|
57
|
+
begin
|
58
|
+
require "rubygems"
|
59
|
+
require "rack"
|
60
|
+
require "pathname"
|
61
|
+
@rackup_path = Pathname.new(Gem.bindir).join("rackup").to_s
|
62
|
+
return @rackup_path if File.file?(@rackup_path)
|
63
|
+
rescue LoadError
|
64
|
+
nil
|
65
|
+
end
|
66
|
+
@rackup_path = nil
|
67
|
+
raise "Cannot find path to rackup, please supply full path to rackup with -R"
|
68
|
+
end # }}}
|
69
|
+
|
70
|
+
def is_running?(pid) # {{{
|
71
|
+
if is_windows?
|
72
|
+
wmi = WIN32OLE.connect("winmgmts://")
|
73
|
+
processes, ours = wmi.ExecQuery("select * from win32_process where ProcessId = #{pid}"), []
|
74
|
+
processes.each { |process| ours << process.Name }
|
75
|
+
ours.first.nil?
|
76
|
+
else
|
77
|
+
begin
|
78
|
+
prio = Process.getpriority(Process::PRIO_PROCESS, pid)
|
79
|
+
true
|
80
|
+
rescue Errno::ESRCH
|
81
|
+
false
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end # }}}
|
85
|
+
|
86
|
+
def check_running?(pid_file) # {{{
|
87
|
+
return false unless File.file?(pid_file)
|
88
|
+
is_running?(File.read(pid_file).to_i)
|
89
|
+
end # }}}
|
90
|
+
|
91
|
+
def find_pid(pid_file) # {{{
|
92
|
+
if pid_file.nil? or not File.file?(pid_file)
|
93
|
+
pid_file = default_pidfile
|
94
|
+
end
|
95
|
+
unless File.file?(pid_file)
|
96
|
+
$stderr.puts "Could not find running process id."
|
97
|
+
return false
|
98
|
+
end
|
99
|
+
pid_file
|
100
|
+
end # }}}
|
101
|
+
end # End helper methods }}}
|
102
|
+
|
103
|
+
class Cmd # This class contains the command methods {{{
|
104
|
+
include Helpers
|
105
|
+
attr_accessor :command
|
106
|
+
|
107
|
+
def initialize(args = nil)
|
108
|
+
args ||= ARGV
|
109
|
+
raise "arguments must be an array!" unless args.respond_to?(:detect)
|
110
|
+
@ourargs = args.dup
|
111
|
+
@command = args.detect { |arg| arg.match(/^(?:--?)?(?:start|stop|restart|create|h(?:elp)?|v(?:ersion)?|console|status)/) }
|
112
|
+
if command.nil?
|
113
|
+
@command = ""
|
114
|
+
else
|
115
|
+
args.delete(@command)
|
116
|
+
end
|
117
|
+
ARGV.replace(args)
|
118
|
+
end
|
119
|
+
|
120
|
+
# {{{ #run is called when we're interactive ($0 == __FILE__)
|
121
|
+
def self.run(args = nil)
|
122
|
+
cmd = new(args)
|
123
|
+
case cmd.command
|
124
|
+
when /^(?:--?)?status$/
|
125
|
+
cmd.status(cmd.command)
|
126
|
+
when /^(?:--?)?restart$/
|
127
|
+
cmd.stop(cmd.command)
|
128
|
+
cmd.start
|
129
|
+
when /^(?:--?)?start$/
|
130
|
+
cmd.start
|
131
|
+
when /^(?:--?)?create$/
|
132
|
+
cmd.create(cmd.command)
|
133
|
+
when /^(?:--?)?stop$/
|
134
|
+
if cmd.stop(cmd.command)
|
135
|
+
puts "Ramazement has ended, go in peace."
|
136
|
+
$stdout.flush
|
137
|
+
else
|
138
|
+
puts "Ramaze failed to stop (or was not running)"
|
139
|
+
end
|
140
|
+
when /^(?:--?)?console$/
|
141
|
+
require "ramaze"
|
142
|
+
require "irb"
|
143
|
+
require "irb/completion"
|
144
|
+
Ramaze.options.started = true
|
145
|
+
require "start"
|
146
|
+
IRB.start
|
147
|
+
puts "Ramazement has ended, go in peace."
|
148
|
+
when /^(?:--?)?h(elp)?$/
|
149
|
+
puts cmd.usage
|
150
|
+
when /^(?:--?)?v(ersion)?$/
|
151
|
+
cmd.include_ramaze
|
152
|
+
puts Ramaze::VERSION
|
153
|
+
exit
|
154
|
+
when /^$/
|
155
|
+
puts "Must supply a valid command"
|
156
|
+
puts cmd.usage
|
157
|
+
exit 1
|
158
|
+
else
|
159
|
+
puts "#{command} not implemented"
|
160
|
+
puts cmd.usage
|
161
|
+
exit 1
|
162
|
+
end
|
163
|
+
end # }}}
|
164
|
+
|
165
|
+
def include_ramaze # {{{
|
166
|
+
begin
|
167
|
+
$:.unshift File.join(File.dirname(__FILE__), '/../lib')
|
168
|
+
require 'ramaze'
|
169
|
+
rescue LoadError
|
170
|
+
$:.shift
|
171
|
+
|
172
|
+
begin
|
173
|
+
require 'rubygems'
|
174
|
+
rescue LoadError
|
175
|
+
end
|
176
|
+
require 'ramaze'
|
177
|
+
end
|
178
|
+
end # }}}
|
179
|
+
|
180
|
+
def usage # {{{
|
181
|
+
txt = [
|
182
|
+
"\n Usage:",
|
183
|
+
"ramaze <start [PIDFILE]|stop [PIDFILE]|restart [PIDFILE]|status [PIDFILE]|create PROJECT|console> [ruby/rack options]\n",
|
184
|
+
"Commands:\n",
|
185
|
+
" * All commands which take an optional PIDFILE (defaults to PROJECT.pid otherwise).",
|
186
|
+
" * All commands which start a ramaze instance will default to webrick on port 7000",
|
187
|
+
" unless you supply the rack options -p/--port PORT and/or * -s/--server SERVER.\n",
|
188
|
+
" start - Starts an instance of this application.\n",
|
189
|
+
" stop - Stops a running instance of this application.\n",
|
190
|
+
" restart - Stops running instance of this application, then starts it back up. Pidfile",
|
191
|
+
" (if supplied) is used for both stop and start.\n",
|
192
|
+
" status - Gives status of a running ramaze instance\n",
|
193
|
+
" create - Creates a new prototype Ramaze application in a directory named PROJECT in",
|
194
|
+
" the current directory. ramaze create foo would make ./foo containing an",
|
195
|
+
" application prototype. Rack options are ignored here.\n",
|
196
|
+
" console - Starts an irb console with app.rb (and irb completion) loaded. This command",
|
197
|
+
" ignores rack options, ARGV is passed on to IRB.\n\n\t"
|
198
|
+
].join("\n\t")
|
199
|
+
|
200
|
+
if is_windows?
|
201
|
+
txt << %x{ruby #{rackup_path} --help}.split("\n").reject { |line| line.match(/^Usage:/) }.join("\n\t")
|
202
|
+
else
|
203
|
+
txt << %x{#{rackup_path} --help}.split("\n").reject { |line| line.match(/^Usage:/) }.join("\n\t")
|
204
|
+
end
|
205
|
+
|
206
|
+
txt.gsub(/^\t$/, '')
|
207
|
+
end # }}}
|
208
|
+
|
209
|
+
### Methods for commands {{{
|
210
|
+
def start # {{{
|
211
|
+
include_ramaze
|
212
|
+
|
213
|
+
# Find the name of this app
|
214
|
+
app_name = default_pidfile.sub(/\.pid$/,'')
|
215
|
+
rack_args = []
|
216
|
+
|
217
|
+
if daemonize = @ourargs.detect { |arg| arg.match(/^(-[dD]|--daemonize)$/) }
|
218
|
+
if pid_arg = @ourargs.detect { |arg| arg.match(/^(-P|--pid)/) }
|
219
|
+
puts "User supplied pid: #{pid_arg}"
|
220
|
+
pid_file = @ourargs[@ourargs.index(pid_arg) + 1]
|
221
|
+
puts "Starting daemon with user defined pidfile: #{pid_file}"
|
222
|
+
else
|
223
|
+
puts "Starting daemon with default pidfile: #{pid_file = default_pidfile}"
|
224
|
+
rack_args += ["-P", pid_file]
|
225
|
+
end
|
226
|
+
if check_running?(pid_file)
|
227
|
+
$stderr.puts "Ramaze is already running with pidfile: #{pid_file}"
|
228
|
+
exit 127
|
229
|
+
end
|
230
|
+
end
|
231
|
+
|
232
|
+
port = Ramaze.options.adapter.port.to_s
|
233
|
+
rack_args += ["-p", port ] if @ourargs.grep(/^(-p|--port)/).empty?
|
234
|
+
|
235
|
+
handler = Ramaze.options.adapter.handler.to_s
|
236
|
+
rack_args += ["-s", handler] if @ourargs.grep(/^(-s|--server)/).empty?
|
237
|
+
|
238
|
+
if is_windows?
|
239
|
+
exec("ruby", rackup_path.to_s, "config.ru", *(ARGV + rack_args))
|
240
|
+
else
|
241
|
+
exec(rackup_path.to_s, "config.ru", *(ARGV + rack_args))
|
242
|
+
end
|
243
|
+
end # }}}
|
244
|
+
|
245
|
+
def create(command) # {{{
|
246
|
+
opts = {}
|
247
|
+
if forced = @ourargs.detect { |arg| arg.match(/^(--force)/) }
|
248
|
+
puts "Overwriting any existing files as requested."
|
249
|
+
opts[:force] = true
|
250
|
+
@ourargs.delete(forced)
|
251
|
+
end
|
252
|
+
if amended = @ourargs.detect { |arg| arg.match(/^(--amend)/) }
|
253
|
+
puts "Only amending missing files as requested."
|
254
|
+
opts[:amend] = true
|
255
|
+
@ourargs.delete(amended)
|
256
|
+
end
|
257
|
+
project_name = @ourargs[@ourargs.index(command) + 1]
|
258
|
+
if project_name.nil?
|
259
|
+
$stderr.puts "Must supply a project name" if project_name.nil?
|
260
|
+
puts usage
|
261
|
+
exit 1
|
262
|
+
end
|
263
|
+
include_ramaze
|
264
|
+
require 'ramaze/tool/create'
|
265
|
+
Ramaze::Tool::Create.create(project_name, opts)
|
266
|
+
end # }}}
|
267
|
+
|
268
|
+
def stop(command) # {{{
|
269
|
+
unless pid_file = find_pid(@ourargs[@ourargs.index(command) + 1])
|
270
|
+
$stderr.puts "No pid_file found! Cannot stop ramaze (may not be started)."
|
271
|
+
return false
|
272
|
+
end
|
273
|
+
pid = File.read(pid_file).to_i
|
274
|
+
puts "Stopping pid #{pid}"
|
275
|
+
Process.kill("INT", pid)
|
276
|
+
sleep 2
|
277
|
+
if is_running?(pid)
|
278
|
+
$stderr.puts "Process #{pid} did not die, forcing it with -9"
|
279
|
+
Process.kill(9, pid)
|
280
|
+
File.unlink(pid_file) if File.file?(pid_file)
|
281
|
+
true
|
282
|
+
else
|
283
|
+
File.unlink(pid_file) if File.file?(pid_file)
|
284
|
+
true
|
285
|
+
end
|
286
|
+
end # }}}
|
287
|
+
|
288
|
+
def status(command) # {{{
|
289
|
+
unless pid_file = find_pid(@ourargs[@ourargs.index(command) + 1])
|
290
|
+
$stderr.puts "No pid_file found! Ramaze may not be started."
|
291
|
+
exit 1
|
292
|
+
end
|
293
|
+
puts "Pid file #{pid_file} found, PID is #{pid = File.read(pid_file)}"
|
294
|
+
unless is_running?(pid.to_i)
|
295
|
+
$stderr.puts "PID #{pid} is not running"
|
296
|
+
exit 1
|
297
|
+
end
|
298
|
+
if is_windows?
|
299
|
+
wmi = WIN32OLE.connect("winmgmts://")
|
300
|
+
processes, ours = wmi.ExecQuery("select * from win32_process where ProcessId = #{pid}"), []
|
301
|
+
processes.each { |p| ours << [p.Name, p.CommandLine, p.VirtualSize, p.CreationDate, p.ExecutablePath, p.Status ] }
|
302
|
+
puts "Ramaze is running!\n\tName: %s\n\tCommand Line: %s\n\tVirtual Size: %s\n\tStarted: %s\n\tExec Path: %s\n\tStatus: %s" % ours.first
|
303
|
+
else
|
304
|
+
require "pathname"
|
305
|
+
# Check for /proc
|
306
|
+
if File.directory?(proc_dir = Pathname.new("/proc"))
|
307
|
+
proc_dir = proc_dir.join(pid)
|
308
|
+
# If we have a "stat" file, we'll assume linux and get as much info
|
309
|
+
# as we can
|
310
|
+
if File.file?(stat_file = proc_dir.join("stat"))
|
311
|
+
stats = File.read(stat_file).split
|
312
|
+
puts "Ramaze is running!\n\tCommand Line: %s\n\tVirtual Size: %s\n\tStarted: %s\n\tExec Path: %s\n\tStatus: %s" % [
|
313
|
+
File.read(proc_dir.join("cmdline")).split("\000").join(" "),
|
314
|
+
"%s k" % (stats[22].to_f / 1024),
|
315
|
+
File.mtime(proc_dir),
|
316
|
+
File.readlink(proc_dir.join("exe")),
|
317
|
+
stats[2]
|
318
|
+
]
|
319
|
+
exit
|
320
|
+
end
|
321
|
+
end
|
322
|
+
# Fallthrough status, just print a ps
|
323
|
+
puts "Ramaze process #{pid} is running!"
|
324
|
+
begin
|
325
|
+
puts %x{ps l #{pid}}
|
326
|
+
rescue
|
327
|
+
puts "No further information available"
|
328
|
+
end
|
329
|
+
end
|
330
|
+
end # }}}
|
331
|
+
|
332
|
+
### End of command methods }}}
|
333
|
+
end # }}}
|
334
|
+
end
|
335
|
+
end
|
336
|
+
end
|
337
|
+
|
338
|
+
if $0 == __FILE__
|
339
|
+
Ramaze::Tool::Bin::Cmd.run(ARGV)
|
340
|
+
end
|