emoji_data 0.1.0.rc1 → 0.1.0.rc2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +1 -0
- data/lib/emoji_data.rb +3 -17
- data/lib/emoji_data/version.rb +1 -1
- 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: 671af8082390de92a6fe0d117ba06ac889432139
|
4
|
+
data.tar.gz: 8936a23eaae21c2de5c9c4ed7b64e8c65502c299
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 48fd69617af75d22deadd75a6c3eefeea4e5614c8e8d2a93340a73d0a7b4a7aca9bc947c33e0c1d6f2d6dace4266ad8c647d0a449e0e68200d2732def98b748c
|
7
|
+
data.tar.gz: 54e3b3ce6716a80301dbc769061ac699c495c010c690e2a95467055fbb48f8c7b81563a178f3a5b4c080ca06f237554ad6be197239f59f4102bdc1d82775494b
|
data/CHANGELOG.md
CHANGED
@@ -5,6 +5,7 @@
|
|
5
5
|
* Add support for Unicode variant encodings, used by MacOSX 10.9 / iOS 7.
|
6
6
|
- For more info: http://www.unicode.org/L2/L2011/11438-emoji-var.pdf
|
7
7
|
- By default, `EmojiChar.to_s()` and `.char()` will now use the variant encoding.
|
8
|
+
* With adding support for variants, the speed of `find_by_str` regressed by approximately 20% (because there are more codepoints to match against). To counter this, we switched to a Regex based scan than improves performance of the method by over 250x(!). A complete sorted search against 1000 strings now takes ~2ms where before it would take around a half second.
|
8
9
|
* Import latest version of iamcal/emoji-data.
|
9
10
|
* 100% test coverage. :sunglasses:
|
10
11
|
|
data/lib/emoji_data.rb
CHANGED
@@ -64,11 +64,10 @@ module EmojiData
|
|
64
64
|
EMOJICHAR_UNIFIED_MAP[cp.upcase]
|
65
65
|
end
|
66
66
|
|
67
|
+
FBS_REGEXP = Regexp.new("(?:#{EmojiData.chars({include_variants: true}).join("|")})")
|
67
68
|
def self.find_by_str(str)
|
68
|
-
str.
|
69
|
-
|
70
|
-
matches = EMOJI_CHARS.select { |ec| str.include_any? ec.chars }
|
71
|
-
matches.sort_by { |mc| str.index_first(mc.chars) }
|
69
|
+
matches = str.scan(FBS_REGEXP)
|
70
|
+
matches.map { |m| EmojiData.find_by_unified(EmojiData.char_to_unified(m)) }
|
72
71
|
end
|
73
72
|
|
74
73
|
def self.find_by_name(name)
|
@@ -84,17 +83,4 @@ module EmojiData
|
|
84
83
|
self.all.select { |char| char.send(field).include? value }
|
85
84
|
end
|
86
85
|
|
87
|
-
module StringUtils
|
88
|
-
def include_any?(charstr)
|
89
|
-
charstr.any? { |char| self.include? char }
|
90
|
-
end
|
91
|
-
|
92
|
-
def index_first(charstr)
|
93
|
-
charstr.each do |char|
|
94
|
-
return self.index(char) if !self.index(char).nil?
|
95
|
-
end
|
96
|
-
nil
|
97
|
-
end
|
98
|
-
end
|
99
|
-
|
100
86
|
end
|
data/lib/emoji_data/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: emoji_data
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.0.
|
4
|
+
version: 0.1.0.rc2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Matthew Rothenberg
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-05-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|