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
1 parent
55517e7
commit 92c919b
Showing
5 changed files
with
64 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,8 @@ | ||
require 'regexy/version' | ||
|
||
module Regexy | ||
autoload :Regexp, 'regexy/regexp' | ||
autoload :Regexp, 'regexy/regexp' | ||
autoload :RegexpWithMode, 'regexy/regexp' | ||
autoload :Web, 'regexy/web' | ||
autoload :Web, 'regexy/web' | ||
autoload :Text, 'regexy/text' | ||
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,5 @@ | ||
module Regexy | ||
module Text | ||
autoload :Smile, 'regexy/text/smile' | ||
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,11 @@ | ||
module Regexy | ||
module Text | ||
class Smile < Regexy::Regexp | ||
SMILE_REGEX = /\A((?<![\\:;x])[:8bx;][-=]?[dx\)\(0op\*\#s\\\/](?![\)\(\*\/\\\#]))\z/i | ||
|
||
def initialize(*args) | ||
super(SMILE_REGEX, *args) | ||
end | ||
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,35 @@ | ||
describe Regexy::Text::Smile do | ||
VALID_SMILES = [ | ||
':)', ':=)', ':-)', ':(', | ||
':=(', ':-(', ':D', ':=D', | ||
':-D', ':d', ':=d', ':-d', | ||
'8=)', '8-)', 'B=)', 'B-)', | ||
';)', ';-)', ';=)', ':o', | ||
':=o', ':-o', ':O', ':=O', | ||
':-O', ';(', ';-(', ';=(', | ||
':*', ':=*', ':-*', ':P', | ||
':=P', ':-P', ':p', ':=p', | ||
':-p', ':S', ':-S', ':=S', | ||
':s', ':-s', ':=s', ':x', | ||
':-X', ':#', ':-#', ':=x', | ||
':=X', ':=#', 'xd', ':\\', ':D', ':/' | ||
] | ||
|
||
INVALID_SMILES = [ | ||
'://', '::)' | ||
] | ||
|
||
let(:r) { Regexy::Text::Smile.new } | ||
|
||
it 'accept valid smiles' do | ||
VALID_SMILES.each do |smile| | ||
expect(smile =~ r).to be_truthy | ||
end | ||
end | ||
|
||
it 'does not accept invalid smiles' do | ||
INVALID_SMILES.each do |smile| | ||
expect(smile =~ r).to be_nil | ||
end | ||
end | ||
end |