Hello! I''m trying to make a simple Ruby code beautifier to set me at ease. I know there''s already rbeautify: http://www.arachnoid.com/ruby/rbeautify.rb.html But I need to do some more: Like making, # comments like these Into, # # Comments like these. # E.g. making sure the first letter after "^# " (if any) is always uppercase and that every comment line ends with a dot. As well as, # comments like these. # bla bla. # bla blaaa. Into, # # Comments like these. Bla bla. Bla blaaa. # Every comment is always joined into one line. I''m not sure exactly what approach to take. Whether to build on rbeautify or not. I also need the functionality from my old shell script: #!/usr/bin/env zsh for file in $PWD/**/*(.); do # Check if file is text. # if file -b $file | grep -q ''text''; then # Remove CRLF, blank lines and trailing white space. # # In FreeBSD use: sed -e # tr -d ''\r'' < $file | sed -E -e ''v/\S/d'' -e ''s/[[:space:]]+$//'' > $file.tmp mv -f $file.tmp $file echo "$file" fi done Would love to hear what you guys think. All the best, Kyrre --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Kyrre Nygård wrote:> # comments like these. > # bla bla. > # bla blaaa.Comments..? COMMENTS??? Look around you! Do you see any comments in these programs? (Besides the RDoc meat..;) -- Phlip --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
> E.g. making sure the first letter after "^# " (if any) is always > uppercase and that every comment line ends with a dot.[...]> Every comment is always joined into one line.- Get a list of files you want to "beautify" (e.g. by means of Dir.glob) - Load the contents of these files - Use regex to find/replace & upcase for your uppercasing needs - Save. Google will be a wonderful resource for all "yeah, but how?" issues you might run into along the way. It will be a brief, yet interesting, programming exercise. Gaining some regex experience never hurts :) Cheers, Niels --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Niels Ganser wrote:> Google will be a wonderful resource for all "yeah, but how?" issues you > might run into along the way. It will be a brief, yet interesting, > programming exercise. Gaining some regex experience never hurts :)Yeah! What he sed! --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Thanks man :) I appreciate it. I wonder why though nobody''s done this kind of thing before. Where''s the love? Kyrre ----- Original Message ----- From: Niels Ganser <niels-nRYBEV4l/tGYhCYXZFeMvg@public.gmane.org> Date: Tuesday, March 18, 2008 10:44 pm Subject: [Rails] Re: Making all my Ruby files pretty To: rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> > > E.g. making sure the first letter after "^# " (if any) is > always > > uppercase and that every comment line ends with a dot. > [...] > > Every comment is always joined into one line. > > - Get a list of files you want to "beautify" (e.g. by means of > Dir.glob)- Load the contents of these files > - Use regex to find/replace & upcase for your uppercasing needs > - Save. > > Google will be a wonderful resource for all "yeah, but how?" > issues you > might run into along the way. It will be a brief, yet > interesting, > programming exercise. Gaining some regex experience never hurts :) > > Cheers, > Niels > > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---