Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
160 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
module Reusable | ||
# Public: Collection of email related helpers. | ||
module EmailHelpers | ||
extend self | ||
|
||
# Public: Returns anonimized version of the email. It truncates | ||
# username to 3 first characters with the dots. | ||
# | ||
# email - A String email to be escaped | ||
# | ||
# Example | ||
# | ||
# include Reusable::EmailHelpers | ||
# anonimize_email("marty@macfly.com") # => "mar...@macfly.com" | ||
# | ||
# Returns an anonizmized email. | ||
def anonimize_email(email) | ||
name, domain = email.split('@') | ||
name = name.size > 3 ? name.to(2) + '...' : name.first + '...' | ||
name.gsub!(/\.{4,}/, '...') | ||
return [ name, domain ].join('@') | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
require File.expand_path("../../spec_helper", __FILE__) | ||
require 'reusable/apps_foundation' | ||
|
||
module DummyProject | ||
extend Reusable::AppsFoundation | ||
end | ||
|
||
describe Reusable::AppsFoundation do | ||
subject do | ||
DummyProject | ||
end | ||
|
||
describe ".apps" do | ||
it "by default is an empty array" do | ||
subject.apps.should == [] | ||
end | ||
end | ||
|
||
describe ".load_apps" do | ||
it "loads list of registered apps from given directory" do | ||
subject.apps += %w(dummy) | ||
subject.expects(:require).with('/tmp/dummy/app.rb') | ||
subject.load_apps('/tmp') | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
require File.expand_path("../../../spec_helper", __FILE__) | ||
require 'reusable/helpers/email_helpers' | ||
|
||
describe Reusable::EmailHelpers do | ||
describe "#anonimize_email" do | ||
it "returns 3 first characters of username with dots if longer than 3 chars" do | ||
subject.anonimize_email('marty@macfly.com').should == 'mar...@macfly.com' | ||
end | ||
|
||
it "returns first characted of username with dots if shorther than 3 chars" do | ||
subject.anonimize_email('ba@barracus.com').should == 'b...@barracus.com' | ||
end | ||
end | ||
end |