rumoji 0.3.0 → 0.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/rumoji.rb +15 -2
- data/lib/rumoji/version.rb +1 -1
- data/spec/rumoji_spec.rb +7 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c8b7c62e0e1733933104c59ab3ac4d0312baafac
|
4
|
+
data.tar.gz: 19ae2ccc6e4703995a5e12e2a5fc0579e0e399f7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 29dfadb2c22ea87ba8a4d5f1d4cc7dc126168fcd5d3c72bacbbedfdbfa898fab0af4abd39c8559feb9707ea6dc26cb9e2ed79ebbc74e41ef536c35e6cd1c4209
|
7
|
+
data.tar.gz: 3d56797e19ad1558e4a44198bfb2f6e2f11b35734ef7ecd2e8244232e87a6ad10d82395e0dba5ffdb5185804e98a7dd233161dbd2e617d7044fc71441f0a7f27
|
data/lib/rumoji.rb
CHANGED
@@ -26,8 +26,9 @@ module Rumoji
|
|
26
26
|
last_emoji = previous_emoji.pop
|
27
27
|
|
28
28
|
sequence = if last_emoji.nil? || !last_emoji.codepoints.include?(codepoint)
|
29
|
-
if possible_emoji.empty?
|
30
|
-
|
29
|
+
if possible_emoji.empty? || last_emoji
|
30
|
+
last_codepoint = last_emoji && last_emoji.codepoints.first
|
31
|
+
sequence_from_codepoints(last_codepoint, codepoint)
|
31
32
|
else
|
32
33
|
multiple_codepoint_emoji = possible_emoji.select(&:multiple?)
|
33
34
|
if multiple_codepoint_emoji.empty?
|
@@ -42,6 +43,14 @@ module Rumoji
|
|
42
43
|
|
43
44
|
writer.write sequence
|
44
45
|
end
|
46
|
+
|
47
|
+
# If the last character was the beginning of a possible emoji, tack the
|
48
|
+
# first codepoint onto the end.
|
49
|
+
if last_emoji = previous_emoji.pop
|
50
|
+
writeable.write sequence_from_codepoints(last_emoji.codepoints.first)
|
51
|
+
end
|
52
|
+
|
53
|
+
writeable
|
45
54
|
end
|
46
55
|
|
47
56
|
def decode_io(readable, writeable=StringIO.new(""))
|
@@ -53,5 +62,9 @@ module Rumoji
|
|
53
62
|
|
54
63
|
private
|
55
64
|
|
65
|
+
def sequence_from_codepoints(*codepoints)
|
66
|
+
compacted = codepoints.flatten.compact
|
67
|
+
compacted.pack("U" * compacted.size)
|
68
|
+
end
|
56
69
|
|
57
70
|
end
|
data/lib/rumoji/version.rb
CHANGED
data/spec/rumoji_spec.rb
CHANGED
@@ -30,6 +30,13 @@ describe Rumoji do
|
|
30
30
|
Rumoji.encode_io(io).string.must_equal ":smile:"
|
31
31
|
end
|
32
32
|
|
33
|
+
it "keeps codepoints that match the beginnings of multi-codepoint emoji" do
|
34
|
+
text = "i like #hashtags and 1direction they are the #1 band. end with 9"
|
35
|
+
io = StringIO.new(text)
|
36
|
+
|
37
|
+
Rumoji.encode_io(io).string.must_equal text
|
38
|
+
end
|
39
|
+
|
33
40
|
describe "with multiple codepoints" do
|
34
41
|
it "transforms a stream" do
|
35
42
|
io1 = StringIO.new("#{@zero}")
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rumoji
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mark Wunsch
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-
|
11
|
+
date: 2013-09-06 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Transcode emoji utf-8 characters into emoji-cheat-sheet form
|
14
14
|
email:
|