rumoji 0.3.0 → 0.3.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: bf0ea637726fd3740573925b2493779578d668f2
4
- data.tar.gz: 4a7f853c96be89f634dc595f9066baf6e235ab27
3
+ metadata.gz: c8b7c62e0e1733933104c59ab3ac4d0312baafac
4
+ data.tar.gz: 19ae2ccc6e4703995a5e12e2a5fc0579e0e399f7
5
5
  SHA512:
6
- metadata.gz: 5cd83e867da5fb3dfb5a0e7b236836a5b725459fa9680f22848d2b370b9f96f2228f21f0c303830d967538e1f9fffde3be6102c2044e2dc1448c0f2e555d96d8
7
- data.tar.gz: 103e290099c4e868be870a007e4103a7a8cbcb5856b22c9d903f1370d84bb2c6e857d98ed9acf6349068f5996175eea6dee305d01707689c8bcc1c98492b1766
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
- [codepoint].pack("U")
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
@@ -1,3 +1,3 @@
1
1
  module Rumoji
2
- VERSION = "0.3.0"
2
+ VERSION = "0.3.1"
3
3
  end
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.0
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-08-27 00:00:00.000000000 Z
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: