Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
R
rumoji
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ikcrm_common
rumoji
Commits
e91ac7aa
Commit
e91ac7aa
authored
Sep 04, 2013
by
Mark Wunsch
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #6 from jakeboxer/possible-emoji-edge-cases
Handle some edge cases with "possible emoji"
parents
4344fabd
b61bf925
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
4 deletions
+15
-4
lib/rumoji.rb
+14
-3
spec/rumoji_spec.rb
+1
-1
No files found.
lib/rumoji.rb
View file @
e91ac7aa
...
...
@@ -26,10 +26,9 @@ module Rumoji
last_emoji
=
previous_emoji
.
pop
sequence
=
if
last_emoji
.
nil?
||
!
last_emoji
.
codepoints
.
include?
(
codepoint
)
if
possible_emoji
.
empty?
if
possible_emoji
.
empty?
||
last_emoji
last_codepoint
=
last_emoji
&&
last_emoji
.
codepoints
.
first
sequence_codepoints
=
[
last_codepoint
,
codepoint
].
compact
sequence_codepoints
.
pack
(
"U"
*
sequence_codepoints
.
size
)
sequence_from_codepoints
(
last_codepoint
,
codepoint
)
else
multiple_codepoint_emoji
=
possible_emoji
.
select
(
&
:multiple?
)
if
multiple_codepoint_emoji
.
empty?
...
...
@@ -44,6 +43,14 @@ module Rumoji
writer
.
write
sequence
end
# If the last character was the beginning of a possible emoji, tack the
# first codepoint onto the end.
if
last_emoji
=
previous_emoji
.
pop
writeable
.
write
sequence_from_codepoints
(
last_emoji
.
codepoints
.
first
)
end
writeable
end
def
decode_io
(
readable
,
writeable
=
StringIO
.
new
(
""
))
...
...
@@ -55,5 +62,9 @@ module Rumoji
private
def
sequence_from_codepoints
(
*
codepoints
)
compacted
=
codepoints
.
flatten
.
compact
compacted
.
pack
(
"U"
*
compacted
.
size
)
end
end
spec/rumoji_spec.rb
View file @
e91ac7aa
...
...
@@ -31,7 +31,7 @@ describe Rumoji do
end
it
"keeps codepoints that match the beginnings of multi-codepoint emoji"
do
text
=
"i like #hashtags and 1direction"
text
=
"i like #hashtags and 1direction
they are the #1 band. end with 9
"
io
=
StringIO
.
new
(
text
)
Rumoji
.
encode_io
(
io
).
string
.
must_equal
text
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment