emoji_data 0.0.1pre1 → 0.0.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: f191eca7f7de6e6588fd01310ef0b1c9778d811e
4
- data.tar.gz: cabdf97b59c4af32b28f7a20703ae31b1f119d8b
3
+ metadata.gz: dab837b7cd073e03b87f156cc2472c78cfa1a5a5
4
+ data.tar.gz: f6f8aa09037e39585efdfbb9aee1be99eb70973a
5
5
  SHA512:
6
- metadata.gz: 4e54371b53461386c44530d18feb79c1df3821770852da849e5aed3281d4245a5a7eab868aa02edc8e7ab6f3d4a75031c06955e2ec1bc7e4649c0c3e18007ce5
7
- data.tar.gz: 1bebd21c73fe98c48face452a755e6b539c198c7192161125649f9f9f6752e2d5f7e9496b4a08714daa3c90bfe78a1fcccf9dd5a2030809750b8dd77e6561a3c
6
+ metadata.gz: 29bb1371373e4c4b8525f7b32b5b6b44defa1b655505eb263abf1d8656fab671aa11b3084807b2d9a92e71295c612a31b7f5c1b04d6adf106b8c173e0a38b0e5
7
+ data.tar.gz: 2c04729c219a862f94464cb89a16fa220250989cd822fd0618929e64733fae8fafb0a810375943a1a6757affefb72f9df1c85eb946a4f58b82e1cec83505f99a
data/.travis.yml CHANGED
@@ -1,5 +1,10 @@
1
1
  language: ruby
2
2
  rvm:
3
3
  - 1.8.7
4
+ - 1.9.2
4
5
  - 1.9.3
5
6
  - 2.0.0
7
+
8
+ matrix:
9
+ allow_failures:
10
+ - rvm: 1.8.7
data/README.md CHANGED
@@ -1,10 +1,13 @@
1
1
  # emoji_data.rb
2
2
 
3
- Provides classes and methods for dealing with emoji character data as unicode.
3
+ [![Gem Version](https://badge.fury.io/rb/emoji_data.png)](http://badge.fury.io/rb/emoji_data)
4
+ [![Build Status](https://travis-ci.org/mroth/emoji_data.rb.png?branch=master)](https://travis-ci.org/mroth/emoji_data.rb)
4
5
 
5
- Note, this is more useful for low-level operations. If you can avoid having to deal with unicode character data extensively and just want to encode/decode stuff, [rumoji](https://github.com/mwunsch/rumoji) is probably a better bet for you.
6
+ Provides classes and helpers for dealing with emoji character data as unicode. Wraps a library of all known emoji characters and provides convenience methods.
6
7
 
7
- This library currently considers `iamcal/emoji-data` to be the "source of truth" regarding certain things, such as how to represent doublebyte unified codepoints as strings.
8
+ Note, this is mostly useful for low-level operations. If you can avoid having to deal with unicode character data extensively and just want to encode/decode stuff, [rumoji](https://github.com/mwunsch/rumoji) might be a better bet for you.
9
+
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).
8
11
 
9
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.
10
13
 
@@ -22,10 +25,44 @@ Or install it yourself as:
22
25
 
23
26
  $ gem install emoji_data
24
27
 
25
- ## Usage
28
+ Currently requires Ruby 1.9 or more recent.
29
+
30
+ ## Library Usage
31
+
32
+ Pretty straightforward, read the source. But here are some things you might care about:
33
+
34
+ ### EmojiData
35
+
36
+ The `EmojiData` module provides some convenience methods for dealing with the library of known emoji characters. Check out the source to see what's up.
37
+
38
+ Some notable methods to call out:
39
+
40
+ - `EmojiData.find_by_unified(id)` gives you a quick way to grab a specific EmojiChar.
41
+
42
+ >> EmojiData.find_by_unified('1f680')
43
+ => #<EmojiData::EmojiChar:0x007fd455ab2ff8 @name="ROCKET", @unified="1F680", @docomo="", @au="E5C8", @softbank="E10D", @google="FE7ED", @image="1f680.png", @sheet_x=21, @sheet_y=28, @short_name="rocket", @short_names=["rocket"], @text=nil>
44
+
45
+ - `EmojiData.find_by_name(name)` and `.find_by_short_name(name)` do pretty much what you'd expect:
46
+
47
+ >> EmojiData.find_by_name('thumb')
48
+ => [#<EmojiData::EmojiChar:0x007f9db214a558 @name="THUMBS UP SIGN", @unified="1F44D", @docomo="E727", @au="E4F9", @softbank="E00E", @google="FEB97", @image="1f44d.png", @sheet_x=10, @sheet_y=17, @short_name="+1", @short_names=["+1", "thumbsup"], @text=nil>, #<EmojiData::EmojiChar:0x007f9db2149720 @name="THUMBS DOWN SIGN", @unified="1F44E", @docomo="E700", @au="EAD5", @softbank="E421", @google="FEBA0", @image="1f44e.png", @sheet_x=10, @sheet_y=18, @short_name="-1", @short_names=["-1", "thumbsdown"], @text=nil>]
49
+
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
+
52
+ >> EmojiData.char_to_unified(:rocket:)
53
+ => "1F680"
54
+
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.
56
+
57
+ #gimmie the shortname of all doublebyte chars
58
+ >> EmojiData.all.select(&:doublebyte?).map(&:short_name)
59
+ => ["hash", "zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine", "cn", "de", "es", "fr", "gb", "it", "jp", "kr", "ru", "us"]
60
+
61
+
62
+ ### EmojiData::EmojiChar
63
+
64
+ `EmojiData::EmojiChar` is a class representing a single emoji character. All the variables from the `iamcal/emoji-data` dataset have dynamically generated getter methods.
26
65
 
27
- Things you might care about:
66
+ There are some additional convenience methods, such as `#doublebyte?` etc. Most important addition is the `#char` method which will output a properly unicode encoded string containing the character.
28
67
 
29
- `EmojiData::EmojiChar`: is a class representing a single emoji character. All the variables from `emoji-data` have dynamically generated getter methods. There are some additional convenience methods, such as `#doublebyte?` etc. Most important addition is the `#char` method which will output a properly unicode encoded string containing the character.
30
68
 
31
- The `EmojiData` module itself has some convenience methods. Check out the source to see what's up. Probably most useful is `.all` which gives you an array of all known EmojiChars, so you can map or do whatever funky Enumerable stuff you need to do across the entire character set.
data/emoji_data.gemspec CHANGED
@@ -8,7 +8,7 @@ Gem::Specification.new do |spec|
8
8
  spec.version = EmojiData::VERSION
9
9
  spec.authors = ["Matthew Rothenberg"]
10
10
  spec.email = ["mrothenberg@gmail.com"]
11
- spec.description = %q{Provides classes and methods for dealing with emoji character data as unicode.}
11
+ spec.description = %q{Provides classes and helpers for dealing with emoji character data as unicode. Wraps a library of all known emoji characters and provides convenience methods.}
12
12
  spec.summary = %q{Provides classes and methods for dealing with emoji character data as unicode.}
13
13
  spec.homepage = "https://github.com/mroth/emoji_data.rb"
14
14
  spec.license = "MIT"
@@ -23,4 +23,6 @@ Gem::Specification.new do |spec|
23
23
  spec.add_development_dependency "rspec"
24
24
 
25
25
  spec.add_dependency "json"
26
+
27
+ spec.required_ruby_version = '>= 1.9.2'
26
28
  end
data/lib/emoji_data.rb CHANGED
@@ -29,13 +29,22 @@ module EmojiData
29
29
  end
30
30
 
31
31
  def self.find_by_unified(cp)
32
- EMOJI_CHARS.detect { |ec| ec.unified == cp }
32
+ EMOJI_CHARS.detect { |ec| ec.unified == cp.upcase }
33
+ end
34
+
35
+ def self.find_by_name(name)
36
+ # self.all.select { |char| char.name.include? name.upcase }
37
+ self.find_by_value(:name, name.upcase)
38
+ end
39
+
40
+ def self.find_by_short_name(short_name)
41
+ # self.all.select { |char| char.short_name.include? name.downcase }
42
+ self.find_by_value(:short_name, short_name.downcase)
43
+ end
44
+
45
+ protected
46
+ def self.find_by_value(field,value)
47
+ self.all.select { |char| char.send(field).include? value }
33
48
  end
34
49
 
35
- # not sure why the below doesnt work... but maybe fuck reverse compatibility for MYSELF
36
- # self.module_eval do
37
- # alias_method :find_by_codepoint, :find_by_unified
38
- # alias_method :char_to_codepoint, :char_to_unified
39
- # alias_method :codepoint_to_char, :unified_to_char
40
- # end
41
50
  end
@@ -1,3 +1,3 @@
1
1
  module EmojiData
2
- VERSION = "0.0.1pre1"
2
+ VERSION = "0.0.1"
3
3
  end
@@ -1,3 +1,4 @@
1
+ #encoding: UTF-8
1
2
  require 'spec_helper'
2
3
 
3
4
  describe EmojiChar do
@@ -11,6 +11,41 @@ describe EmojiData do
11
11
  end
12
12
  end
13
13
 
14
+ describe ".find_by_unified" do
15
+ it "should find the proper EmojiChar object" do
16
+ results = EmojiData.find_by_unified('1f680')
17
+ results.should be_kind_of(EmojiChar)
18
+ results.name.should eq('ROCKET')
19
+ end
20
+ it "should normallise capitalization for hex values" do
21
+ EmojiData.find_by_unified('1f680').should_not be_nil
22
+ end
23
+ end
24
+
25
+ describe ".find_by_name" do
26
+ it "returns an array of results" do
27
+ EmojiData.find_by_name('tree').should be_kind_of(Array)
28
+ EmojiData.find_by_name('tree').count.should eq(5)
29
+ end
30
+ it "returns [] if nothing is found" do
31
+ EmojiData.find_by_name('sdlkfjlskdfj').should_not be_nil
32
+ EmojiData.find_by_name('sdlkfjlskdfj').should be_kind_of(Array)
33
+ EmojiData.find_by_name('sdlkfjlskdfj').count.should eq(0)
34
+ end
35
+ end
36
+
37
+ describe ".find_by_short_name" do
38
+ it "returns an array of results, downcasing if needed" do
39
+ EmojiData.find_by_short_name('MOON').should be_kind_of(Array)
40
+ EmojiData.find_by_short_name('MOON').count.should eq(13)
41
+ end
42
+ it "returns [] if nothing is found" do
43
+ EmojiData.find_by_short_name('sdlkfjlskdfj').should_not be_nil
44
+ EmojiData.find_by_short_name('sdlkfjlskdfj').should be_kind_of(Array)
45
+ EmojiData.find_by_short_name('sdlkfjlskdfj').count.should eq(0)
46
+ end
47
+ end
48
+
14
49
  describe ".char_to_unified" do
15
50
  it "converts normal emoji to unified codepoint" do
16
51
  EmojiData.char_to_unified("👾").should eq('1F47E')
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: emoji_data
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1pre1
4
+ version: 0.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matthew Rothenberg
@@ -66,8 +66,9 @@ dependencies:
66
66
  - - '>='
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
- description: Provides classes and methods for dealing with emoji character data as
70
- unicode.
69
+ description: Provides classes and helpers for dealing with emoji character data as
70
+ unicode. Wraps a library of all known emoji characters and provides convenience
71
+ methods.
71
72
  email:
72
73
  - mrothenberg@gmail.com
73
74
  executables: []
@@ -100,12 +101,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
100
101
  requirements:
101
102
  - - '>='
102
103
  - !ruby/object:Gem::Version
103
- version: '0'
104
+ version: 1.9.2
104
105
  required_rubygems_version: !ruby/object:Gem::Requirement
105
106
  requirements:
106
- - - '>'
107
+ - - '>='
107
108
  - !ruby/object:Gem::Version
108
- version: 1.3.1
109
+ version: '0'
109
110
  requirements: []
110
111
  rubyforge_project:
111
112
  rubygems_version: 2.0.2