About environment variables - I've just used this in my Camping
helpers to print them all out, but the Rack variables seem to have
multiple values or values with no name:
def envars(theenv)
if theenv == "ENV"
ul do
theenv.each_pair do |name,value|
li { name + " " + value }
end
end
else
ul do
theenv.each do |name|
li { name }
end
end
end
end
called with:
envars(ENV)
envars(@env)
Can some one enlighten me about how Rack env vars are stored, and how
to get a nice printout?
DaveE
Haha! How did you get Spock on board... :-)
I must admit I'm a little confused about the sytnax for
environmental variables, because as well as
@env[HTTP_REFERER]
this also works:
ENV['SCRIPT_NAME']
For a test I just used it like this:
ENV['SCRIPT_NAME'].scan(/\w+\.\w+$/)
to get the Camping file's name (with whatever file extension rb,
rbx, cgi) instead of using __FILE__
I think I'll throw together a quick Camping app that 'nicely' prints
all available environment variables (as they'll vary for each
setup)...
DaveE
Starship Enterprise, Stardate #{Time.now.to_f}. Captain's Log.
network.http.sendrefererheader was set to 0 in my Firefox for
unknown reasons.
Probably Mr Spock, the Chief of security did this.
I make this log entry for those who don't want to spend hours in a
spacedock repairing a working application.
Signing out...
On Sat, Apr 7, 2012 at 6:06 PM, Nokan Emiro <uzleep...@gmail.com>
wrote:
Why does it work without the @ for me?
On Fri, Apr 6, 2012 at 4:26 PM, Magnus Holm <judo...@gmail.com>
wrote:
It should be in @env:
@env['HTTP_REFERER']
(Note that it's misspelled in the spec)
_______________________________________________
Camping-list mailing list
Camping-list@rubyforge.org
http://rubyforge.org/mailman/listinfo/camping-list