12
votes
6answers
3k views

Use of a regex stored inside yaml file

I installed settingslogic and in the configuration file I put the regex for the email as follows #config/settings.yml defaults: &defaults email_regex: ...
4
votes
2answers
94 views

Refactor highlight matched word in string

I have following method which highlight matched word in text: # Hightlight matched term # # Ex(for term: some): # "<span class="bold">Some</span> CEO Event" # def ...
3
votes
1answer
68 views

Count comments and lines of code in ruby

Hi I wrote a small script as an answer for a stack overflow question, that counts lines of code and comments (in C and C++ style). f = File.open("test.txt") loc = 0 comments = 0 while line = f.gets ...
2
votes
3answers
1k views

Ruby code style / Regular Expression to remove blank lines / test case

Forgive me to put 3 seemingly irrelevant words in the subject line. But they are the purposes of this post. This is basically my first Ruby class, which is to remove all empty lines and blank times ...
2
votes
1answer
107 views

filter out password in xml string

We're storing the xml communications with an external service in a text in the db and in a before_create I've got the following: # filter opera password def remove_password! ...