emojimmy 0.2 โ 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -8
- data/Rakefile +10 -0
- data/lib/emojimmy.rb +11 -7
- data/lib/emojimmy/version.rb +1 -1
- data/spec/emojimmy_spec.rb +56 -4
- 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: 3b91602af2bd44ac75a15100c5adce6812714b88
|
4
|
+
data.tar.gz: 78a51100063dd6eecedd9609b86ab887c579a89c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7dbf6643c4f6e8aed569aab2a4421827b6ba99035e55d612f92fb230f8e135d3d3982367be1c597295acef2d0681e80d6dfbe77fdfe41abe38d449ceedaffeb4
|
7
|
+
data.tar.gz: 471b750553f24b09955a70c04e8205ef0c4f6fc3c815294dcaee1972929acd8500e27ccfb474f68fa226acec42fca9146eaae539c0d42f542345ca8f0eb9a377
|
data/README.md
CHANGED
@@ -26,16 +26,9 @@ gem 'emojimmy'
|
|
26
26
|
|
27
27
|
### Usage
|
28
28
|
|
29
|
-
First, you must enable Emojimmy in an initializer (when your application boots):
|
30
|
-
|
31
|
-
```ruby
|
32
|
-
# config/initializers/emojimmy.rb
|
33
|
-
Emojimmy.initialize!
|
34
|
-
```
|
35
|
-
|
36
29
|
#### ActiveRecord
|
37
30
|
|
38
|
-
|
31
|
+
You have to edit your models to specify which fields will be storing emoji characters:
|
39
32
|
|
40
33
|
```ruby
|
41
34
|
# app/models/comment.rb
|
data/Rakefile
CHANGED
@@ -9,3 +9,13 @@ desc 'Run all specs'
|
|
9
9
|
RSpec::Core::RakeTask.new(:spec) do |task|
|
10
10
|
task.pattern = 'spec/**/*_spec.rb'
|
11
11
|
end
|
12
|
+
|
13
|
+
desc 'Start an IRB session with the gem'
|
14
|
+
task :console do
|
15
|
+
$:.unshift File.expand_path('..', __FILE__)
|
16
|
+
require 'emojimmy'
|
17
|
+
require 'irb'
|
18
|
+
|
19
|
+
ARGV.clear
|
20
|
+
IRB.start
|
21
|
+
end
|
data/lib/emojimmy.rb
CHANGED
@@ -18,13 +18,8 @@ module Emojimmy
|
|
18
18
|
# Encode the string with Rumoji
|
19
19
|
content = Rumoji.encode(content)
|
20
20
|
|
21
|
-
#
|
22
|
-
content
|
23
|
-
point = c.each_codepoint.to_a.first
|
24
|
-
point <= 65535
|
25
|
-
end
|
26
|
-
|
27
|
-
content.join
|
21
|
+
# Return the text without any other weird characters
|
22
|
+
Emojimmy.strip(content)
|
28
23
|
end
|
29
24
|
|
30
25
|
# Loop through each {U+...} token in the string and
|
@@ -34,4 +29,13 @@ module Emojimmy
|
|
34
29
|
|
35
30
|
Rumoji.decode(content)
|
36
31
|
end
|
32
|
+
|
33
|
+
# Loop through each character in the string and
|
34
|
+
# remove the all emoji ones
|
35
|
+
def self.strip(content)
|
36
|
+
content.chars.select do |c|
|
37
|
+
point = c.each_codepoint.to_a.first
|
38
|
+
point <= 65535
|
39
|
+
end.join
|
40
|
+
end
|
37
41
|
end
|
data/lib/emojimmy/version.rb
CHANGED
data/spec/emojimmy_spec.rb
CHANGED
@@ -11,10 +11,62 @@ describe Emojimmy do
|
|
11
11
|
end
|
12
12
|
|
13
13
|
describe :emoji_to_token do
|
14
|
-
|
15
|
-
|
14
|
+
context 'with a few emoji characters' do
|
15
|
+
let(:received_text) { 'Hello ๐๐ you ๐ ๐ธ!' }
|
16
|
+
let(:stored_text) { 'Hello :grin::grin: you :smiling_imp: :frog:!' }
|
17
|
+
|
18
|
+
subject { Emojimmy.emoji_to_token(received_text) }
|
19
|
+
it { should eql stored_text }
|
20
|
+
end
|
21
|
+
|
22
|
+
context 'with *all* iOS emoji' do
|
23
|
+
let(:received_text) do
|
24
|
+
'๐๐๐๐โบ๐๐๐๐๐๐๐๐๐๐ณ๐๐๐๐๐๐ฃ
|
25
|
+
๐ข๐๐ญ๐ช๐ฅ๐ฐ๐
๐๐ฉ๐ซ๐จ๐ฑ๐ ๐ก๐ค๐๐๐๐ท๐๐ด
|
26
|
+
๐ต๐ฒ๐๐ฆ๐ง๐๐ฟ๐ฎ๐ฌ๐๐๐ฏ๐ถ๐๐๐๐ฒ๐ณ๐ฎ๐ท๐
|
27
|
+
๐ถ๐ฆ๐ง๐จ๐ฉ๐ด๐ต๐ฑ๐ผ๐ธ๐บ๐ธ๐ป๐ฝ๐ผ๐๐ฟ๐น๐พ๐น๐บ
|
28
|
+
๐๐๐๐๐ฝ๐ฉ๐ฅโจ๐๐ซ๐ฅ๐ข๐ฆ๐ง๐ค๐จ๐๐๐๐
๐
|
29
|
+
๐๐๐๐โโ๐โ๐๐๐๐๐๐๐โ๐๐ช๐ถ๐๐
|
30
|
+
๐ซ๐ช๐ฌ๐ญ๐๐๐ฏ๐๐
๐๐๐๐๐
๐ฐ๐๐๐๐ฉ๐๐
|
31
|
+
๐๐๐ก๐ ๐ข๐๐๐๐๐ฝ๐๐๐๐ผ๐๐๐๐๐๐๐
|
32
|
+
๐๐๐๐โค๐๐๐๐๐๐๐๐๐๐๐๐ค๐ฅ๐ฌ๐ฃ๐ญ
|
33
|
+
๐ถ๐บ๐ฑ๐ญ๐น๐ฐ๐ธ๐ฏ๐จ๐ป๐ท๐ฝ๐ฎ๐๐ต๐๐ด๐๐๐ผ๐ง
|
34
|
+
๐ฆ๐ค๐ฅ๐ฃ๐๐๐ข๐๐๐๐๐๐๐๐ ๐๐ฌ๐ณ๐๐๐
|
35
|
+
๐๐๐
๐๐๐๐๐๐๐๐๐๐ฒ๐ก๐๐ซ๐ช๐๐๐ฉ๐พ
|
36
|
+
๐๐ธ๐ท๐๐น๐ป๐บ๐๐๐๐ฟ๐พ๐๐ต๐ด๐ฒ๐ณ๐ฐ๐ฑ๐ผ๐
|
37
|
+
๐๐๐๐๐๐๐๐๐๐๐๐๐๐๐๐๐ โญ
|
38
|
+
โโ
โโกโโโ๐๐๐๐
|
39
|
+
๐ ๐ก๐ซ๐ข๐ฃ๐ฅ๐ฆ๐ช๐ฉ๐จ๐โช๐ฌ๐ค๐๐๐ฏ๐ฐโบ๐ญ๐ผ
|
40
|
+
๐พ๐ป๐๐
๐๐ฝ๐๐ ๐กโฒ๐ข๐ขโต๐ค๐ฃโ๐โ๐บ๐๐
|
41
|
+
๐๐๐๐๐๐
๐๐๐๐๐๐๐๐๐๐๐๐๐๐๐
|
42
|
+
๐จ๐๐๐๐๐๐ฒ๐ก๐๐ ๐๐๐๐ซ๐ฆ๐ฅโ ๐ง๐ฐโฝ๐ฎ
|
43
|
+
๐ฐโจ๐ฟ๐ช๐ญ๐๐ฉ๐ฏ๐ต๐ฐ๐ท๐ฉ๐ช๐จ๐ณ๐บ๐ธ๐ซ๐ท๐ช๐ธ๐ฎ๐น๐ท๐บ๐ฌ๐ง
|
44
|
+
1โฃ2โฃ3โฃ4โฃ5โฃ6โฃ7โฃ8โฃ9โฃ0โฃ๐๐ข#โฃ๐ฃโฌโฌโฌ
โก๐ ๐ก๐ค
|
45
|
+
โโโโโโ๐โโถ๐ผ๐ฝโฉโชโนโชโฉโซโฌโคตโคด๐
|
46
|
+
๐๐๐๐๐๐๐๐๐ถ๐ฆ๐๐ฏ๐ณ๐ต๐ด๐ฒ๐๐น๐บ๐ถ๐
|
47
|
+
๐ป๐น๐บ๐ผ๐พ๐ฐ๐ฎ๐
ฟโฟ๐ญ๐ท๐ธ๐โ๐๐๐
๐๐ใใ
|
48
|
+
๐๐๐๐ซ๐๐ต๐ฏ๐ฑ๐ณ๐ท๐ธโโณโโโ
โด๐๐๐ณ๐ด
|
49
|
+
๐
ฐ๐
ฑ๐๐
พ๐ โฟโปโโโโโโโโโโโโโ๐ฏ
|
50
|
+
๐ง๐น๐ฒ๐ฑยฉยฎโขโโผโโโโโโญ๐๐๐๐๐๐
|
51
|
+
๐๐ง๐๐๐๐๐๐๐๐๐๐ ๐๐ก๐๐ข๐๐ฃ๐๐ค๐
|
52
|
+
๐ฅ๐๐ฆโโโโโ โฅโฃโฆ๐ฎ๐ฏโโ๐๐โฐใฐใฝ๐ฑ
|
53
|
+
โผโปโพโฝโชโซ๐บ๐ฒ๐ณโซโช๐ด๐ต๐ปโฌโฌ๐ถ๐ท๐ธ๐น
|
54
|
+
๐๐โ๐๐๐ขโ๐๐๐โ
|
55
|
+
๐๐๐
๐๐'
|
56
|
+
end
|
57
|
+
|
58
|
+
let(:stored_text) { Emojimmy.emoji_to_token(received_text) }
|
59
|
+
it { expect(stored_text.each_codepoint.to_a.max).to be <= 65535 }
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
describe :strip do
|
64
|
+
context 'with a few emoji characters' do
|
65
|
+
let(:received_text) { 'Hello ๐๐ you ๐ ๐ธ!' }
|
66
|
+
let(:stripped_text) { 'Hello you !' }
|
16
67
|
|
17
|
-
|
18
|
-
|
68
|
+
subject { Emojimmy.strip(received_text) }
|
69
|
+
it { should eql stripped_text }
|
70
|
+
end
|
19
71
|
end
|
20
72
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: emojimmy
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Rรฉmi Prรฉvost
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-
|
11
|
+
date: 2013-12-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|