Skip to content

Instantly share code, notes, and snippets.

@redsquirrel
Created June 12, 2012 12:10
Show Gist options
  • Save redsquirrel/6e4af716d36893fd5b2b to your computer and use it in GitHub Desktop.
Save redsquirrel/6e4af716d36893fd5b2b to your computer and use it in GitHub Desktop.
I need a gem. Call it whatever you like, but when you're done with this exercise, all I want you to give me is a gem file.
Also, your gem should not depend on any other gems. (Depending on a testing framework like RSpec acceptable.)
Inside the gem, there should be 2 functions. Both functions take a string and a list of words. For example:
obfuscate("big string of big words is bigger", ["big", "words"])
report("big string of big words is bigger", ["big", "words"])
"obfuscate" returns the string with all words from the list obfuscated. For example:
obfuscate("big string of big words is bigger", ["big", "words"])
=> "*** string of *** ***** is bigger"
"report" returns a hash that contains the list of words and their associated frequency in the string. For example:
report("big string of big words is bigger", ["big", "words"])
=> {"big" => 2, "words" => 1}
The functions could be at the top-level or namespaced. Your call.
Thanks.
@thefonso
Copy link

"...gem should not depend on any other gems"

In my rakefile...as in 'require rubygems' or as in 'development dependencies = []'?

@redsquirrel
Copy link
Author

redsquirrel commented Jun 17, 2012 via email

@thefonso
Copy link

I'm sure I've got something more to do...but for now...https://github.com/thefonso/obfu_report

First time i've gone through this process...oh yeah...I got this thing on rubygems also...https://rubygems.org/profiles/57828

@redsquirrel
Copy link
Author

redsquirrel commented Jun 18, 2012 via email

@thefonso
Copy link

@redsquirrel
Copy link
Author

redsquirrel commented Jun 20, 2012 via email

@jtallant
Copy link

I didn't put this into a gem but I just wanted to take a stab at solving it.
https://gist.github.com/3764829

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment