Formatting issues

1 view
Skip to first unread message

rellik

unread,
Apr 15, 2007, 5:44:32 PM4/15/07
to MOle Plugin
I am making a few changes to the way snitch outputs the data, and I
will mention those changes here, in case others might want something
similar:

#old
MyController:my_action args: foo second_arg: bar
#new
MyController : My Action Args: foo, Second Arg: bar

snitch/app/helpers/mole_helper.rb:9
### Code (Old Code Commented Out) ###
#values.keys.sort { |a,b| a.to_s <=> b.to_s }.each { |k| buff <<
"<span>#{k}: #{values[k]}</span>" }
values.keys.sort { |a,b| a.to_s <=> b.to_s }.each { |k| buff <<
"<span>#{k.to_s.titleize}: #{values[k]}</span>" }
#buff.join( " " )
buff.join( ", " )
### End ###

snitch/app/views/mole/_log.rhtml:4
### Code ###
#<div class="log_feature"><%= log.mole_feature.name.gsub( /
Controller/, '')%></div>
<div class="log_feature"><%= log.mole_feature.name.gsub( /
Controller/, '').sub(/(:)(.*)$/) { "#{$1}#{$2.titleize}" } %></div>
### End ###

That second one might be more appropriate as a helper, but in the
interest of diverging as little as possible from the original, I put
it in the view.

rellik

unread,
Apr 15, 2007, 6:25:15 PM4/15/07
to MOle Plugin
One more change, to the same helper as in the last post (mole_helper),
line 48.

This changes the time at the end of the log-line from:
16:57:30
to:
04:57:30 PM

or from:
04/15 16:57:30
to:
Apr 15 : 04:57:30 PM

Which format is better is certainly arguable, but to my american eyes
the time is more readily understood in the 12hr format. As for the
date, I just prefer the word format, and at only 1 addition character
it's more than worth it to me.

### Code ###
# Formats console timestamp
def timestamp( log )
if log.created_at.yday == @now.yday
#log.created_at.strftime( "%H:%M:%S" )
log.created_at.strftime( "%I:%M:%S %p" )
else
#log.created_at.strftime( "%m/%d %H:%M:%S" )
log.created_at.strftime( "%b %d : %I:%M:%S %p" )
end
end
### End ###

Fernand Galiana

unread,
Apr 16, 2007, 3:01:26 AM4/16/07
to mole-...@googlegroups.com
Thanks for the feedback Patrick!
We will incorporate some of these in the next release of the Snitch....

-Fernand
Reply all
Reply to author
Forward
0 new messages