emojidex 0.0.22 → 0.0.23

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: 18eaa63af54aa2ee525eb36a906cdd76936484c6
4
- data.tar.gz: 96d09a92dd33fbd8cefc09ad70d4533979cad1a2
3
+ metadata.gz: c1f1c37ec62d2ad3daa5af377d01369009f4d734
4
+ data.tar.gz: aa303bb871cb90133a0607a5fe2c50ff7af35162
5
5
  SHA512:
6
- metadata.gz: b51d890e00a1bc1f5aa9852fa39b5431b8455bf71750f663b2a289c34ebaf0df9e6f395e336d6bbfad5efc446407a62b8abc999de0e4d0cd31cae310083757af
7
- data.tar.gz: 2cbec3a818d5000c662dd6a1608a6064963e2620493cb2b615fc5dd5ccf4c9a9054314075b144e9ae4d4b0bcdf290c3b43c8ebc662df2184c86702fd712f5530
6
+ metadata.gz: 96ad63027965d46efa54858616f1b5409b8e7cab814ee9d6114ae8273351b993584ca914baccd906dc1d5e0351852eb08f639ca00c5f90e9ddfb6717639c6838
7
+ data.tar.gz: 32bc08ccfe71137b7cc2c900870cbf8e66d5b58e696e0f82e2f969ead86b1514f3baa41ab7a852aca32ab7271d241283e00ae7b0ac669153e2be94bab77c9c0f
@@ -3,8 +3,9 @@ language: ruby
3
3
  rvm:
4
4
  - 1.9.3
5
5
  - 2.0.0
6
- - 2.1.2
7
- - jruby-19mode
6
+ - 2.1.5
7
+ - 2.2.0
8
+ - rbx
8
9
 
9
10
  bundler_args: -j4 --without development
10
11
 
data/README.md CHANGED
@@ -12,6 +12,23 @@ Assets
12
12
  You can find Vectors here: [emojidex-vectors](https://github.com/emojidex/emojidex-vectors)
13
13
  You can find Rasters here: [emojidex-rasters](https://github.com/emojidex/emojidex-rasters)
14
14
 
15
+ Notes / Caution
16
+ ===============
17
+
18
+ Pre 1.8 or non 1.9+ compliant Ruby
19
+ ----------------------------------
20
+ emojidex uses a variety of tricks and extensively utilizes UTF8/Unicode in ways most other code does not. As such, we do not recommend attempting
21
+ to run emojidex on non 1.9+ compliant Ruby variants, and instead recommend the latest official Ruby. If you are/must use a non 1.9+ official Ruby
22
+ and find an issue that can be remedied without imparing functionality or significantly impacting performance please notify us with an issue or
23
+ submit a pull request with a patch.
24
+
25
+ jRuby
26
+ -----
27
+ From 1.9 on Ruby is an m17n compliant Code Set Independent languge. jRuby, however, does not fulfill this requirement and has a variety of issues
28
+ dealing with UTF8 code -and- content. It should be noted that this is NOT so much a fault of jRuby as it is the JRE/JVM, which simply imposes a
29
+ code set (which in many/most cases is NOT UTF8) on jRuby. Due to this, caution must be excercised when using jRuby. You must make absolutely sure
30
+ that the Java environment you are using is being run with UTF8 as the code set.
31
+
15
32
  License
16
33
  =======
17
34
  emojidex and emojidex tools are licensed under the [emojidex Open License](https://www.emojidex.com/emojidex/emojidex_open_license).
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'emojidex'
3
- s.version = '0.0.22'
3
+ s.version = '0.0.23'
4
4
  s.license = 'emojiOL'
5
5
  s.summary = 'emojidex Ruby tools'
6
6
  s.description = 'emojidex emoji handling, search and lookup, listing and caching functionality' \
@@ -6,7 +6,7 @@ module Emojidex
6
6
  attr_accessor :code, :en, :ja
7
7
 
8
8
  def initialize(details = {})
9
- @code = details[:code]
9
+ @code = details[:code].to_sym
10
10
  @en = details[:en]
11
11
  @ja = details[:ja]
12
12
  end
@@ -54,11 +54,10 @@ module Emojidex
54
54
  # Retreives an Emoji object by the actual moji code/character code
55
55
  # Will likely only return moji from UTF collection
56
56
  def find_by_moji(moji)
57
- result = nil
58
- each do |emoji|
59
- result = emoji if emoji[:moji] == moji
57
+ each do |m|
58
+ return m if m[:moji] == moji
60
59
  end
61
- result
60
+ nil
62
61
  end
63
62
 
64
63
  alias_method :文字検索, :find_by_moji
@@ -73,13 +72,22 @@ module Emojidex
73
72
  # Only applies to collections that contain JA codes, this function is mapped to
74
73
  # find_by_code for all other implementations (such as client)
75
74
  def find_by_code_ja(code_ja)
76
- each do |emoji|
77
- return emoji if emoji[:code_ja] == code_ja
75
+ each do |m|
76
+ return m if m[:code_ja] == code_ja
78
77
  end
78
+ nil
79
79
  end
80
80
 
81
81
  alias_method :コード検索, :find_by_code_ja
82
82
 
83
+ def find_by_unicode(unicode)
84
+ unicode = unicode.downcase
85
+ each do |m|
86
+ return m if m[:unicode] == unicode
87
+ end
88
+ nil
89
+ end
90
+
83
91
  def search(criteria = {})
84
92
  Emojidex::Collection.new _sub_search(@emoji.values.dup, criteria)
85
93
  end
@@ -109,6 +117,7 @@ module Emojidex
109
117
  end
110
118
  end
111
119
  categorize
120
+ associate_variants
112
121
  condense_moji_code_data
113
122
  @emoji
114
123
  end
@@ -123,6 +132,19 @@ module Emojidex
123
132
  @categories.uniq!
124
133
  end
125
134
 
135
+ def associate_variants
136
+ @emoji.values.each do |emoji_obj|
137
+ if emoji_obj.code.match(/\(.*\)$/) # this emoji is a variant
138
+ # check for base
139
+ base_code = emoji_obj.code.sub(/\(.*\)$/, '').to_sym
140
+ if @emoji.has_key? base_code
141
+ @emoji[base_code].variants << emoji_obj.code.to_sym
142
+ emoji_obj.base = base_code
143
+ end
144
+ end
145
+ end
146
+ end
147
+
126
148
  def _sub_search(list, criteria = {})
127
149
  cr = criteria.shift
128
150
  return list if cr.nil?
@@ -4,7 +4,7 @@ module Emojidex
4
4
  # emoji base class
5
5
  class Emoji
6
6
  attr_accessor :moji, :category, :code, :code_ja,
7
- :unicode, :tags, :emoticon
7
+ :unicode, :tags, :emoticon, :variants, :base
8
8
 
9
9
  include Emojidex::EmojiAssetInformation
10
10
 
@@ -16,6 +16,7 @@ module Emojidex
16
16
  @category = details[:category] ? details[:category].to_sym : :other
17
17
  @tags = details[:tags].map { |tag| tag.to_sym } unless details[:tags].nil?
18
18
  @link = details[:link]
19
+ @variants, @base = details[:variants] || [], details[:base]
19
20
  @is_wide = details[:is_wide]
20
21
  end
21
22
 
@@ -95,13 +95,13 @@ describe Emojidex::Extended do
95
95
  end
96
96
 
97
97
  it 'returns all emoji containing the search term as a substring' do
98
- expect(ext.search(code: 'round', category: 'symbols').emoji.count).to be > 12
98
+ expect(ext.search(code: 'square', category: 'symbols').emoji.count).to be > 12
99
99
  end
100
100
 
101
101
  it 'evaluates regular expressions' do
102
- col = ext.search(code: 'Taurus.(?!round).+', category: 'symbols')
103
- expect(col.find_by_code('Taurus_plain')).to be_an_instance_of Emojidex::Emoji
104
- expect(col.find_by_code('Taurus_round')).to be_nil
102
+ col = ext.search(code: 'emoji(?!.*dex$).*', category: 'symbols')
103
+ expect(col.find_by_code('emoji')).to be_an_instance_of Emojidex::Emoji
104
+ expect(col.find_by_code('emojidex')).to be_nil
105
105
  end
106
106
  end
107
107
  end
@@ -52,6 +52,14 @@ describe Emojidex::UTF do
52
52
  end
53
53
  end
54
54
 
55
+ describe 'emoji[#code].variants' do
56
+ it 'has collected variants for an emoji' do
57
+ expect(utf.emoji[:ice_skate].variants).to be_empty
58
+ expect(utf.emoji[:persevere].variants).to include(:"persevere(p)")
59
+ expect(utf.emoji[:"persevere(p)"].base).to be(:persevere)
60
+ end
61
+ end
62
+
55
63
  describe '.cache!' do
56
64
  it 'caches emoji to local storage cache' do
57
65
  tmp_cache_path = File.expand_path('../support/tmpcache', __FILE__)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: emojidex
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.22
4
+ version: 0.0.23
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rei Kagetsuki
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-02-27 00:00:00.000000000 Z
11
+ date: 2015-03-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday