emoji_data 0.0.1 → 0.0.2
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/CHANGELOG.md +12 -0
- data/README.md +2 -2
- data/emoji_data.gemspec +0 -2
- data/lib/emoji_data.rb +5 -0
- data/lib/emoji_data/emoji_char.rb +2 -0
- data/lib/emoji_data/version.rb +1 -1
- data/spec/emoji_char_spec.rb +6 -0
- data/spec/emoji_data_spec.rb +25 -2
- metadata +4 -17
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f66433b3778b05bcc9534d6a15658b4f060bdcc4
|
4
|
+
data.tar.gz: 1b41a37a76d7e0b01ac6eddb1af67fec59f16a55
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0b7ded0ce8a2a30a38fef2dcb7f6ceb4c663865d4027846550e5beb4957e646bb43cba9c7ea1cfb3f4a32dea82f808a2be98a14a034f567c3354b41850d77f9a
|
7
|
+
data.tar.gz: f5fbf0d2639f0bd3e17bca053e9a6dec6f3d4b64f28fe15634e5155be6b2788b718853d70097b7d7a3e1fcf061fca67b3896ae1c72324e30dd7ac70efa96020f
|
data/CHANGELOG.md
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
# Changelog
|
2
|
+
|
3
|
+
## 0.0.2 (3 December 2013)
|
4
|
+
|
5
|
+
* Remove JSON gem dependency since no longer supporting Ruby 1.8.7 anyhow.
|
6
|
+
* Add `EmojiData.find_by_str` convenience method to match on a string.
|
7
|
+
* Make default `EmojiChar.to_s()` the same as `EmojiChar.char()`
|
8
|
+
|
9
|
+
|
10
|
+
## 0.0.1 (7 June 2013)
|
11
|
+
|
12
|
+
* Initial release
|
data/README.md
CHANGED
@@ -9,7 +9,7 @@ Note, this is mostly useful for low-level operations. If you can avoid having t
|
|
9
9
|
|
10
10
|
This library currently uses `iamcal/emoji-data` as it's library dataset, and thus considers it to be the "source of truth" regarding certain things, such as how to represent doublebyte unified codepoint IDs as strings (seperated by a dash).
|
11
11
|
|
12
|
-
This is basically a helper library for [emojitrack](https://github.com/mroth/emojitrack) and [emojistatic](https://github.com/mroth/emojistatic), but may be useful for other people.
|
12
|
+
This is basically a helper library for my [emojitrack](https://github.com/mroth/emojitrack) and [emojistatic](https://github.com/mroth/emojistatic) projects, but may be useful for other people.
|
13
13
|
|
14
14
|
## Installation
|
15
15
|
|
@@ -49,7 +49,7 @@ Some notable methods to call out:
|
|
49
49
|
|
50
50
|
- `EmojiData.char_to_unified(char)` takes a string containing a unified unicode representation of an emoji character and gives you the unicode ID.
|
51
51
|
|
52
|
-
>> EmojiData.char_to_unified(
|
52
|
+
>> EmojiData.char_to_unified('🚀')
|
53
53
|
=> "1F680"
|
54
54
|
|
55
55
|
- `EmojiData.all` will return an array of all known EmojiChars, so you can map or do whatever funky Enumerable stuff you want to do across the entire character set.
|
data/emoji_data.gemspec
CHANGED
data/lib/emoji_data.rb
CHANGED
@@ -32,6 +32,11 @@ module EmojiData
|
|
32
32
|
EMOJI_CHARS.detect { |ec| ec.unified == cp.upcase }
|
33
33
|
end
|
34
34
|
|
35
|
+
def self.find_by_str(str)
|
36
|
+
matches = EMOJI_CHARS.select { |ec| str.include? ec.char }
|
37
|
+
matches.sort_by { |matched_char| str.index(matched_char.char) }
|
38
|
+
end
|
39
|
+
|
35
40
|
def self.find_by_name(name)
|
36
41
|
# self.all.select { |char| char.name.include? name.upcase }
|
37
42
|
self.find_by_value(:name, name.upcase)
|
data/lib/emoji_data/version.rb
CHANGED
data/spec/emoji_char_spec.rb
CHANGED
@@ -29,6 +29,12 @@ describe EmojiChar do
|
|
29
29
|
@usflag = EmojiChar.new({'unified' => '1F1FA-1F1F8'})
|
30
30
|
end
|
31
31
|
|
32
|
+
describe "#to_s" do
|
33
|
+
it "should return the unicode char as string as default to_s" do
|
34
|
+
@invader.to_s.should eq(@invader.char)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
32
38
|
describe "#char" do
|
33
39
|
it "should render as happy shiny unicode" do
|
34
40
|
@invader.char.should eq("👾")
|
data/spec/emoji_data_spec.rb
CHANGED
@@ -11,6 +11,29 @@ describe EmojiData do
|
|
11
11
|
end
|
12
12
|
end
|
13
13
|
|
14
|
+
describe ".find_by_str" do
|
15
|
+
before(:all) do
|
16
|
+
@exact_results = EmojiData.find_by_str("🚀")
|
17
|
+
@multi_results = EmojiData.find_by_str("flying on my 🚀 to visit the 👾 people.")
|
18
|
+
end
|
19
|
+
it "should find the proper EmojiChar object from a single string char" do
|
20
|
+
@exact_results.should be_kind_of(Array)
|
21
|
+
@exact_results.length.should eq(1)
|
22
|
+
@exact_results.first.should be_kind_of(EmojiChar)
|
23
|
+
@exact_results.first.name.should eq('ROCKET')
|
24
|
+
end
|
25
|
+
it "should match multiple chars from within a string" do
|
26
|
+
@multi_results.should be_kind_of(Array)
|
27
|
+
@multi_results.length.should eq(2)
|
28
|
+
@multi_results[0].should be_kind_of(EmojiChar)
|
29
|
+
@multi_results[1].should be_kind_of(EmojiChar)
|
30
|
+
end
|
31
|
+
it "should return multiple matches in the proper order" do
|
32
|
+
@multi_results[0].name.should eq('ROCKET')
|
33
|
+
@multi_results[1].name.should eq('ALIEN MONSTER')
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
14
37
|
describe ".find_by_unified" do
|
15
38
|
it "should find the proper EmojiChar object" do
|
16
39
|
results = EmojiData.find_by_unified('1f680')
|
@@ -23,7 +46,7 @@ describe EmojiData do
|
|
23
46
|
end
|
24
47
|
|
25
48
|
describe ".find_by_name" do
|
26
|
-
it "returns an array of results" do
|
49
|
+
it "returns an array of results, upcasing input if needed" do
|
27
50
|
EmojiData.find_by_name('tree').should be_kind_of(Array)
|
28
51
|
EmojiData.find_by_name('tree').count.should eq(5)
|
29
52
|
end
|
@@ -35,7 +58,7 @@ describe EmojiData do
|
|
35
58
|
end
|
36
59
|
|
37
60
|
describe ".find_by_short_name" do
|
38
|
-
it "returns an array of results, downcasing if needed" do
|
61
|
+
it "returns an array of results, downcasing input if needed" do
|
39
62
|
EmojiData.find_by_short_name('MOON').should be_kind_of(Array)
|
40
63
|
EmojiData.find_by_short_name('MOON').count.should eq(13)
|
41
64
|
end
|
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.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Matthew Rothenberg
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-
|
11
|
+
date: 2013-12-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -52,20 +52,6 @@ dependencies:
|
|
52
52
|
- - '>='
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0'
|
55
|
-
- !ruby/object:Gem::Dependency
|
56
|
-
name: json
|
57
|
-
requirement: !ruby/object:Gem::Requirement
|
58
|
-
requirements:
|
59
|
-
- - '>='
|
60
|
-
- !ruby/object:Gem::Version
|
61
|
-
version: '0'
|
62
|
-
type: :runtime
|
63
|
-
prerelease: false
|
64
|
-
version_requirements: !ruby/object:Gem::Requirement
|
65
|
-
requirements:
|
66
|
-
- - '>='
|
67
|
-
- !ruby/object:Gem::Version
|
68
|
-
version: '0'
|
69
55
|
description: Provides classes and helpers for dealing with emoji character data as
|
70
56
|
unicode. Wraps a library of all known emoji characters and provides convenience
|
71
57
|
methods.
|
@@ -77,6 +63,7 @@ extra_rdoc_files: []
|
|
77
63
|
files:
|
78
64
|
- .gitignore
|
79
65
|
- .travis.yml
|
66
|
+
- CHANGELOG.md
|
80
67
|
- Gemfile
|
81
68
|
- LICENSE.txt
|
82
69
|
- README.md
|
@@ -109,7 +96,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
109
96
|
version: '0'
|
110
97
|
requirements: []
|
111
98
|
rubyforge_project:
|
112
|
-
rubygems_version: 2.0.
|
99
|
+
rubygems_version: 2.0.14
|
113
100
|
signing_key:
|
114
101
|
specification_version: 4
|
115
102
|
summary: Provides classes and methods for dealing with emoji character data as unicode.
|