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
d0683f78
Commit
d0683f78
authored
Jan 09, 2014
by
Mark Wunsch
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Ensure that built-up codepoints are written in encoding traversal
parent
a20768b9
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
17 additions
and
11 deletions
+17
-11
lib/rumoji.rb
+8
-9
lib/rumoji/emoji/people.rb
+1
-1
spec/rumoji_spec.rb
+8
-1
No files found.
lib/rumoji.rb
View file @
d0683f78
...
...
@@ -26,14 +26,12 @@ module Rumoji
sequence
=
if
possible_emoji
.
empty?
# If this codepoint is not part of an emoji
# just write it back out, along with any previously stored codepoints.
sequence_from_codepoints
(
previous_codepoints
,
codepoint
).
tap
do
previous_codepoints
.
clear
end
dump_codepoints_to_string
(
previous_codepoints
<<
codepoint
)
elsif
!
possible_emoji
.
any?
(
&
:multiple?
)
# If this codepoint is part of an emoji, but not one
# that contains multiple codepoints, write out the
# first possiblity's cheat code
.
possible_emoji
.
first
.
code
# first possiblity's cheat code
and the previously stored codepoints
dump_codepoints_to_string
(
previous_codepoints
)
<<
possible_emoji
.
first
.
code
else
# This codepoint is a part of an emoji with multiple
# codepoints, so push it onto the stack.
...
...
@@ -51,7 +49,7 @@ module Rumoji
end
# Write any remaining codepoints.
writeable
.
write
sequence_from_codepoints
(
previous_codepoints
)
if
previous_codepoints
.
any?
writeable
.
write
dump_codepoints_to_string
(
previous_codepoints
)
if
previous_codepoints
.
any?
writeable
end
...
...
@@ -65,9 +63,10 @@ module Rumoji
private
def
sequence_from_codepoints
(
*
codepoints
)
compacted
=
codepoints
.
flatten
.
compact
compacted
.
pack
(
"U*"
)
def
dump_codepoints_to_string
(
codepoints
)
codepoints
.
pack
(
"U*"
).
tap
do
codepoints
.
clear
end
end
end
lib/rumoji/emoji/people.rb
View file @
d0683f78
...
...
@@ -94,7 +94,7 @@ module Rumoji
self
.
new
(
"
\u
{1F3B5}"
,
[
:musical_note
]),
# "music, being in good mood"
self
.
new
(
"
\u
{1F525}"
,
[
:fire
],
"FIRE"
),
# Poop
self
.
new
(
"
\u
{1F4A9}"
,
[
:
hankey
,
:poop
,
:shit
],
"PILE OF POO"
),
# "dog dirt"
self
.
new
(
"
\u
{1F4A9}"
,
[
:
poop
,
:hankey
,
:shit
],
"PILE OF POO"
),
# "dog dirt"
self
.
new
(
"
\u
{1F44D}"
,
[
:thumbsup
,
:"+1"
],
"THUMBS UP SIGN"
),
self
.
new
(
"
\u
{1F44E}"
,
[
:thumbsdown
,
:"-1"
],
"THUMBS DOWN SIGN"
),
self
.
new
(
"
\u
{1F44C}"
,
[
:ok_hand
],
"OK HAND SIGN"
),
...
...
spec/rumoji_spec.rb
View file @
d0683f78
...
...
@@ -16,6 +16,7 @@ describe Rumoji do
it
"transforms emoji into cheat-sheet form"
do
key
=
:smile
Rumoji
.
encode
(
@smile
).
must_equal
":smile:"
Rumoji
.
encode
(
"
#{
@smile
}
"
).
must_equal
":smile:"
end
end
...
...
@@ -38,7 +39,6 @@ describe Rumoji do
it
"keeps codepoints that match the beginnings of multi-codepoint emoji"
do
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
end
...
...
@@ -68,6 +68,13 @@ describe Rumoji do
Rumoji
.
encode_io
(
io
).
string
.
must_equal
"An example of a multipoint emoji is the :us: flag."
end
end
describe
"with trailing emoji"
do
it
"writes characters that are in a multipoint emoji followed by an emoji"
do
io
=
StringIO
.
new
"I would like 0
#{
@poop
}
"
Rumoji
.
encode_io
(
io
).
string
.
must_equal
"I would like 0:poop:"
end
end
end
end
...
...
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