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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: dab837b7cd073e03b87f156cc2472c78cfa1a5a5
4
- data.tar.gz: f6f8aa09037e39585efdfbb9aee1be99eb70973a
3
+ metadata.gz: f66433b3778b05bcc9534d6a15658b4f060bdcc4
4
+ data.tar.gz: 1b41a37a76d7e0b01ac6eddb1af67fec59f16a55
5
5
  SHA512:
6
- metadata.gz: 29bb1371373e4c4b8525f7b32b5b6b44defa1b655505eb263abf1d8656fab671aa11b3084807b2d9a92e71295c612a31b7f5c1b04d6adf106b8c173e0a38b0e5
7
- data.tar.gz: 2c04729c219a862f94464cb89a16fa220250989cd822fd0618929e64733fae8fafb0a810375943a1a6757affefb72f9df1c85eb946a4f58b82e1cec83505f99a
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(:rocket:)
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
@@ -22,7 +22,5 @@ Gem::Specification.new do |spec|
22
22
  spec.add_development_dependency "rake"
23
23
  spec.add_development_dependency "rspec"
24
24
 
25
- spec.add_dependency "json"
26
-
27
25
  spec.required_ruby_version = '>= 1.9.2'
28
26
  end
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)
@@ -19,6 +19,8 @@ module EmojiData
19
19
  def doublebyte?
20
20
  @unified.match(/-/)
21
21
  end
22
+
23
+ alias_method :to_s, :char
22
24
  end
23
25
 
24
26
  end
@@ -1,3 +1,3 @@
1
1
  module EmojiData
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
@@ -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("👾")
@@ -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.1
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-06-07 00:00:00.000000000 Z
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.2
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.