What's the Rails.root equivalent in a Rack application? - rack

I'm familiar with the Rails.root in Rails which tells you the directory of your current application. This is quite handy sometimes.
Now I'm developing a Rack application (on which Rails is based). How do I find out the Rails.root equivalent for a Rack application?
Thank you.

This returns the root directory in a string.
Rack::Directory.new('').root
Not sure if there's a better, shorter syntax.

What worked for me is a simple File.expand_path:
File.expand_path(File.join("log", "some_file_#{ENV["RACK_ENV"] || "development"}.log"))

Related

Equivalent for Dancer of Mojolicious Mojolicious::Plugin::PODRenderer?

I would like to generate documentation in a Dancer application in the same way that Mojolicious does with Mojolicious::Plugin::PODRenderer, I mean in the browser, under the /perldoc path.
Does somebody knows a module that can help? I found no ready-made plugin for Dancer. If it don't exist, any recommandation is welcome.
Porting Mojolicious' PODRenderer to Dancer should be fairly simple - it's an example plugin and the code is fairly short. I've done this for my own use in my CGI framework at work.
https://github.com/kraih/mojo/blob/master/lib/Mojolicious/Plugin/PODRenderer.pm#L34
Essentially what the plugin does is define the route /perldoc/:module to call the _perldoc method; the _perldoc method uses Pod::Simple::Search to find a documentation file matching the module param in the #INC directories; If it doesn't, it redirects the search to MetaCPAN. If it does, it uses Pod::Simple::HTML to convert the documentation to HTML, which is then tidied up with Mojo::DOM and wrapped in a lovely template.
Finding the location of that template is left as an exercise for... oh, nevermind, here it is: https://github.com/kraih/mojo/blob/master/lib/Mojolicious/templates/perldoc.html.ep

LoadRunner and wicket application

Doing some research with regards to application framework used on the SUT am going to LoadTest using Loadrunner I fond the application is developed using wickets.
I have generated script using web http/html protocol against a wicket
application and there was some calls recorded in the following
format,script is failing at this URL when i ran the script in VUGen.
http://somem/nnnweb/main/ ?
wicket:interface= :1:someSearchForm :someSearchForm :searchInfo: :IActi
vePageBehaviorListener :0:&wicket: ignoreIfNotActiv e=true&random=
0.038901654740178815",
I find out like when i generate the script which has just views(
viewing tabs) is working fine, but when i edit somefileds and submit
the script is generating the above calls ( http://xxx...) and failing
This guy has explained just the same issue here:
http://tech.groups.yahoo.com/group/LoadRunner/message/27295
I hope it is ok to refer other sites in Stackoverflow?
General question. Does loadrunner support testing of wicket application and is TruClient the best choice here? I actually got it to work with TruClient, but as I understand there are drawbacks with memory footprint using TruClient, but maybe it is time to move on to next generation protocol given my project has decided to use wicket framework?

zend framework under document root in subdir

I developed a application with Zend Framework and now I want to be able to place the app in an subdirectory of a Documentroot.
e.g. http://www.example.com/myapp/
I read quite a lot of Docu how this could work, but all in all these solutions don´t fit my needs. Is there a trivial way to do the subdir thing, without adding the concrete path to any file which generates the pages.
There are some examples in the net, where a basePath is set in the application enviroment and so there is a method call bevor each "form" creation which prepends the path before the link.
$form->setAction($this->_request->getBaseUrl() . $this->_helper->url('sign'));
This was from: http://johnmee.com/2008/11/zend-framework-quickstart-tutorial-deploy-to-a-subdirectory-instead-of-web-root/
But this is only works for small examples, I have tons of forms, tons of views and tons of scripts. I can´t belive this (lets call it hack :) ) is the only solution to do this.
Any ideas?
You don't have to do anything special. See my tutorial at http://akrabat.com/Zend-framework-tutorial which is developed entirely within a sub-directory.
As they say on the web page:
I’m told this last issue has been
lodged has a defect and not necessary
from releases “1.7″ and beyond. The
helper->url will henceforth prepend
the baseUrl to its result.
So you should be fine. Do you actually use the $form->setAction() method on every form already? Because if you use it in combination with the url helper, the baseUrl will already be included.

Loading a private frameworks in MacRuby

I'm attempting to follow this tutorial 'Demystifying Mail.app Plugins on Leopard' to build a Mail.app plugin. Instead of using PyObjC I'm trying to use MacRuby. I've got MacRuby 0.6 loaded up and I've gotten to this step in the tutorial (PyObjC code):
MVMailBundle = objc.lookUpClass('MVMailBundle')
I've search the web a bit but can't seem to find any information about loading the private framework 'MVMailBundle' in MacRuby. Any ideas?
Thanks in advance - AYAL
I think the idea is that this plugin will be loaded into Mail.app, which will already have loaded the private framework in question. So we just want to look up a class at runtime (which is what that Python snippet is doing — not loading a framework). The way to do this in MacRuby is MVMailBundle = NSClassFromString 'MVMailBundle'.
(You will need to include framework 'Cocoa' in order to get the NSClassFromString method, but I assume you'll have already done this.)
MacRuby uses garbage collection and Mail doesn't. You can't load a GC bundle into a non-GC app. So this is a dead-end.

What is this type of redirection called

My website uses Response.Redirect("~/Main/Main.aspx") type redirects all over the place. Worked flawlessly until the Webhost4Life (don't groan) decided to migrate my website and in doing so managed to completely break it.
What is this "~" mechanism actually called?
Thanks, Rob.
PS. The bug is that Response.Redirect("~/main.aspx") from http://backdoor.whatpub.org/default.aspx doesn't go to http://backdoor.whatpub.org/main.aspx (as it did on the old server) but to http://backdoor.whatpub.org/live/main.aspx. Live is the name of the sub-folder containing the website and AFAIK means that the root is getting returned as http://backdoor.whatpub.org/live and not just http://backdoor.whatpub.org
it is a shortcut to HttpRuntime.AppDomainAppVirtualPath property, which refers to the virtual application root, not the root of the web server.