rumoji 0.4.1 → 0.5.0

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: 8bee7e446d40d5d3b472ef20dc39c4ba19c4a6a4
4
- data.tar.gz: 2dbd9169b0e2ad18a0299f6a735a5c06624b2149
3
+ metadata.gz: d83823b144c636ce611e5e87d07fd4623b9197b2
4
+ data.tar.gz: bbf3349521e988be0cabf61970a4cad2faf901e3
5
5
  SHA512:
6
- metadata.gz: 44fbc7120aa1031d77d330f6f246e4a6d8b1503347641925f91b357d9bf47dd3431ef89de03f35e039da4daf72088cb5803cb4f7e16fcfee342521a08d310cc4
7
- data.tar.gz: d8329c723c7ab9288e36f3b0d1510064e684639645b9a7e86330205c7ebf47e1f1558d91b4d4178c60b67c75029f9eaa79a2ac92493a245072d964c1bc7b147f
6
+ metadata.gz: 4046adf578b2bf4d84edfaf06f6d245f54a4d56afda351354aed64b37d16f65f5bf6bb80901e2eab0d651d40e7e7584b1cf6c914b5502b153662dfea4f80e3cf
7
+ data.tar.gz: 1cf5c46f092e4384cd4886f7f2cddbd7feb74513a9dbfa8d240ccddf8586eae40826bd9ccc7c5ed5e69cfe81683fd620aae447d803ecb34701eb4d84a96df848
data/.gitignore CHANGED
@@ -15,3 +15,4 @@ spec/reports
15
15
  test/tmp
16
16
  test/version_tmp
17
17
  tmp
18
+ .idea
@@ -1,9 +1,6 @@
1
1
  language: ruby
2
2
  rvm:
3
- - 1.9.3
4
3
  - 2.0.0
5
4
  - 2.1.0
6
- - rbx
7
- matrix:
8
- allow_failures:
9
- - rvm: rbx
5
+ - 2.2
6
+ before_install: gem install bundler
data/Gemfile CHANGED
@@ -4,8 +4,4 @@ source 'https://rubygems.org'
4
4
  gemspec
5
5
 
6
6
  gem 'rake'
7
-
8
- platforms :rbx do
9
- gem 'rubysl', '~> 2.0'
10
- gem 'minitest'
11
- end
7
+ gem 'minitest'
data/README.md CHANGED
@@ -6,9 +6,13 @@ Why would you want to do this? Read this blog post: http://mwunsch.tumblr.com/po
6
6
 
7
7
  ## tl;dr
8
8
 
9
- >**Do not store emoji unicodes in your database. Store the human-friendly code and support the emoji-cheat-sheet.**
9
+ >By doing this, you can ensure that users across devices can see the
10
+ >author’s intention. You can always show users an image, but you can’t
11
+ >show them a range of characters their system does not support.
10
12
 
11
- >By doing this, you can ensure that users across devices can see the author’s intention. You can always show users an image, but you can’t show them a range of characters their system does not support.
13
+ This gem is primarily for handling emoji characters in user-generated
14
+ content. Depending on your technical stack, these characters could end
15
+ up being lost.
12
16
 
13
17
  ## Usage
14
18
 
@@ -29,7 +33,7 @@ Why would you want to do this? Read this blog post: http://mwunsch.tumblr.com/po
29
33
 
30
34
  gem install rumoji
31
35
 
32
- Note that rumoji has only been tested in Ruby 1.9!!!
36
+ Note that rumoji has only been tested in Rubies >= 1.9!!!
33
37
 
34
38
  ### Some examples:
35
39
 
@@ -53,5 +57,4 @@ _Having trouble discerning what's happening in this README?_ You might be on a d
53
57
  Thanks!
54
58
 
55
59
  ## Copyright
56
- Copyright (c) 2012 - 2015 Mark Wunsch. Licensed under the [MIT License](http://opensource.org/licenses/mit-license.php).
57
-
60
+ Copyright (c) 2012 - 2016 Mark Wunsch. Licensed under the [MIT License](http://opensource.org/licenses/mit-license.php).
data/bin/rumoji CHANGED
@@ -3,4 +3,8 @@
3
3
 
4
4
  require 'rumoji'
5
5
 
6
- Rumoji.decode_io(STDIN, STDOUT)
6
+ if ARGV.first == 'encode'
7
+ Rumoji.encode_io(STDIN, STDOUT)
8
+ else
9
+ Rumoji.decode_io(STDIN, STDOUT)
10
+ end
@@ -8,49 +8,18 @@ module Rumoji
8
8
 
9
9
  # Transform emoji into its cheat-sheet code
10
10
  def encode(str)
11
- io = StringIO.new(str)
12
- encode_io(io).string
11
+ str.gsub(Emoji::ALL_REGEXP) { |match| (emoji = Emoji.find_by_string(match)) && emoji.code || match }
13
12
  end
14
13
 
15
14
  # Transform a cheat-sheet code into an Emoji
16
15
  def decode(str)
17
- str.gsub(/:([^s:]?[\w-]+):/) {|sym| (Emoji.find($1.intern) || sym).to_s }
16
+ str.gsub(/:([^\s:]?[\w-]+):/) {|sym| (Emoji.find($1.intern) || sym).to_s }
18
17
  end
19
18
 
20
19
  def encode_io(readable, writeable=StringIO.new(""))
21
- previous_codepoints = []
22
-
23
- readable.each_codepoint do |codepoint|
24
- possible_emoji = Emoji.select_by_codepoint(codepoint)
25
-
26
- sequence = if possible_emoji.empty?
27
- # If this codepoint is not part of an emoji
28
- # just write it back out, along with any previously stored codepoints.
29
- dump_codepoints_to_string(previous_codepoints << codepoint)
30
- elsif !possible_emoji.any?(&:multiple?)
31
- # If this codepoint is part of an emoji, but not one
32
- # that contains multiple codepoints, write out the
33
- # first possiblity's cheat code and the previously stored codepoints
34
- dump_codepoints_to_string(previous_codepoints) << possible_emoji.first.code
35
- else
36
- # This codepoint is a part of an emoji with multiple
37
- # codepoints, so push it onto the stack.
38
- previous_codepoints.push(codepoint)
39
- # Check and see if this completes the emoji, otherwise,
40
- # write out an empty string.
41
- if found = possible_emoji.find {|e| e.codepoints.eql?(previous_codepoints) }
42
- previous_codepoints.clear and found.code
43
- else
44
- ""
45
- end
46
- end
47
-
48
- writeable.write sequence
20
+ readable.each_line do |line|
21
+ writeable.write encode(line)
49
22
  end
50
-
51
- # Write any remaining codepoints.
52
- writeable.write dump_codepoints_to_string(previous_codepoints) if previous_codepoints.any?
53
-
54
23
  writeable
55
24
  end
56
25
 
@@ -60,13 +29,4 @@ module Rumoji
60
29
  end
61
30
  writeable
62
31
  end
63
-
64
- private
65
-
66
- def dump_codepoints_to_string(codepoints)
67
- codepoints.pack("U*").tap do
68
- codepoints.clear
69
- end
70
- end
71
-
72
32
  end
@@ -2,9 +2,10 @@
2
2
  module Rumoji
3
3
  class Emoji
4
4
 
5
- attr_reader :name
5
+ attr_reader :name, :string
6
6
 
7
7
  def initialize(string, symbols, name = nil)
8
+ @string = string
8
9
  @codepoints = string.codepoints
9
10
  @cheat_codes = [symbols].flatten
10
11
  @name = name || @cheat_codes.first.to_s.upcase.gsub("_", " ")
@@ -23,7 +24,7 @@ module Rumoji
23
24
  end
24
25
 
25
26
  def to_s
26
- codepoints.pack("U*")
27
+ @string
27
28
  end
28
29
 
29
30
  def hash
@@ -31,7 +32,7 @@ module Rumoji
31
32
  end
32
33
 
33
34
  def hex
34
- @codepoints.map{|point| point.to_s(16).upcase }.join("-")
35
+ @hex ||= @codepoints.map{|point| point.to_s(16).upcase }.join("-")
35
36
  end
36
37
 
37
38
  def codepoints
@@ -50,21 +51,18 @@ module Rumoji
50
51
 
51
52
  ALL = PEOPLE | NATURE | OBJECTS | PLACES | SYMBOLS
52
53
 
54
+ ALL_REGEXP = Regexp.new(ALL.map(&:string).join('|'))
55
+
53
56
  def self.find(symbol)
54
57
  ALL.find {|emoji| emoji.include? symbol }
55
58
  end
56
59
 
57
- def self.find_by_string(string)
58
- ALL.find {|emoji| emoji.to_s == string }
59
- end
60
-
61
- def self.select_by_codepoint(codepoint)
62
- ALL.select {|emoji| emoji.codepoints.include? codepoint }
60
+ STRING_LOOKUP = ALL.each.with_object({}) do |emoji, lookup|
61
+ lookup[emoji.string] = emoji
63
62
  end
64
63
 
65
- def self.find_by_codepoint(codepoint)
66
- ALL.find {|emoji| emoji.hex == codepoint.to_s(16).upcase }
64
+ def self.find_by_string(string)
65
+ STRING_LOOKUP[string]
67
66
  end
68
-
69
67
  end
70
68
  end
@@ -15,6 +15,16 @@ module Rumoji
15
15
  self.new("\u{1F300}", [:cyclone]), # "typhoon, hurricane
16
16
  self.new("\u{1F301}", [:foggy]),
17
17
  self.new("\u{1F30A}", [:ocean], "WATER WAVE"),
18
+ self.new("\u{1F324}", [:sun_behind_small_cloud], "WHITE SUN WITH SMALL CLOUD"),
19
+ self.new("\u{1F325}", [:sun_behind_large_cloud], "WHITE SUN BEHIND CLOUD"),
20
+ self.new("\u{1F326}", [:sun_behind_cloud_with_rain], "WHITE SUN BEHIND CLOUD WITH RAIN"),
21
+ self.new("\u{1F327}", [:cloud_with_rain], "CLOUD WITH RAIN"),
22
+ self.new("\u{1F328}", [:cloud_with_snow], "CLOUD WITH SNOW"),
23
+ self.new("\u{1F329}", [:cloud_with_lightning], "CLOUD WITH LIGHTNING"),
24
+ self.new("\u{1F32A}", [:cloud_with_tornado], "CLOUD WITH TORNADO"),
25
+ self.new("\u{1F32B}", [:fog], "FOG"),
26
+ self.new("\u{1F32C}", [:wind_face], "WIND BLOWING FACE"),
27
+
18
28
  # Animals
19
29
  self.new("\u{1F431}", [:cat], "CAT FACE"),
20
30
  self.new("\u{1F436}", [:dog], "DOG FACE"),
@@ -78,6 +88,15 @@ module Rumoji
78
88
  self.new("\u{1F408}", [:cat2], "CAT"),
79
89
  self.new("\u{1F429}", [:poodle]),
80
90
  self.new("\u{1F43E}", [:paw_prints]),
91
+ self.new("\u{1F981}", [:lion]),
92
+ self.new("\u{1F984}", [:unicorn]),
93
+ self.new("\u{1F983}", [:turkey]),
94
+ self.new("\u{1F980}", [:crab]),
95
+ self.new("\u{1F982}", [:scorpion]),
96
+ self.new("\u{1f577}", [:spider]),
97
+ self.new("\u{1f578}", [:spider_web]),
98
+ self.new("\u{1f54A}", [:dove_of_peace]),
99
+ self.new("\u{1F43F}", [:chipmunk]),
81
100
  # Flowers
82
101
  self.new("\u{1F490}", [:bouquet]),
83
102
  self.new("\u{1F338}", [:cherry_blossom]),
@@ -101,6 +120,7 @@ module Rumoji
101
120
  self.new("\u{1F33E}", [:ear_of_rice]),
102
121
  self.new("\u{1F41A}", [:shell], "SPIRAL SHELL"),
103
122
  self.new("\u{1F310}", [:globe_with_meridians]), # "used to indicate international input source, world clocks with time zones, etc."
123
+ self.new("\u{1F3F5}", [:rosette]),
104
124
  # Moon
105
125
  self.new("\u{1F31E}", [:sun_with_face]),
106
126
  self.new("\u{1F31D}", [:full_moon_with_face]),
@@ -259,7 +259,58 @@ module Rumoji
259
259
  self.new("\u{1f45a}", [:womans_clothes]),
260
260
  self.new("\u{1f452}", [:womans_hat]),
261
261
  self.new("\u{1f527}", [:wrench]),
262
- self.new("\u{1f4b4}", [:yen])
262
+ self.new("\u{1f4b4}", [:yen]),
263
+ self.new("\u{1f6CD}", [:shopping_bags], "SHOPPING BAGS"),
264
+ self.new("\u{1f4ff}", [:prayer_beads], "PRAYER BEADS"),
265
+ self.new("\u{1f336}", [:hot_pepper]),
266
+ self.new("\u{1f9c0}", [:cheese_wedge]),
267
+ self.new("\u{1f32d}", [:hot_dog]),
268
+ self.new("\u{1f32e}", [:taco]),
269
+ self.new("\u{1f32f}", [:burrito]),
270
+ self.new("\u{1f37f}", [:popcorn]),
271
+ self.new("\u{1f37e}", [:bottle_popping_cork]),
272
+ self.new("\u{1f3fa}", [:amphora]),
273
+ self.new("\u{1f579}", [:joystick]),
274
+ self.new("\u{1f3f9}", [:bow_arrow]),
275
+ self.new("\u{1f5e1}", [:dagger_knife]),
276
+ self.new("\u{1f3f3}", [:waving_white_flag]),
277
+ self.new("\u{1f3f4}", [:waving_black_flag]),
278
+ self.new("\u{1f6e2}", [:oil_drum]),
279
+ self.new("\u{1f6e1}", [:shield]),
280
+ self.new("\u{1f5dc}", [:compression]),
281
+ self.new("\u{1f6e0}", [:hammer_wrench]),
282
+ self.new("\u{1f5dd}", [:old_key]),
283
+ self.new("\u{1f5d1}", [:wastebasket]),
284
+ self.new("\u{1f5c4}", [:file_cabinet]),
285
+ self.new("\u{1f5c3}", [:card_file_box]),
286
+ self.new("\u{1f587}", [:linked_paperclips]),
287
+ self.new("\u{1f5d3}", [:spiral_calendar]),
288
+ self.new("\u{1f5d2}", [:spiral_note_pad]),
289
+ self.new("\u{1f5c2}", [:card_index_dividers]),
290
+ self.new("\u{1f58d}", [:lower_left_crayon]),
291
+ self.new("\u{1f58c}", [:lower_left_paintbrush]),
292
+ self.new("\u{1f58a}", [:lower_left_ballpoint]),
293
+ self.new("\u{1f58b}", [:lower_left_fountain]),
294
+ self.new("\u{1f5f3}", [:ballot_box_with_ballot]),
295
+ self.new("\u{1f5de}", [:rollet_newspaper]),
296
+ self.new("\u{1f56f}", [:candle]),
297
+ self.new("\u{1f4f8}", [:camera_flash]),
298
+ self.new("\u{1f4fd}", [:film_projector]),
299
+ self.new("\u{1f5b2}", [:trackball]),
300
+ self.new("\u{1f5b1}", [:three_button_mouse]),
301
+ self.new("\u{1f5a8}", [:printer]),
302
+ self.new("\u{1f4bb}", [:desktop_computer]),
303
+ self.new("\u{1f39b}", [:control_knobs]),
304
+ self.new("\u{1f39a}", [:level_slider]),
305
+ self.new("\u{1f399}", [:studio_microphone]),
306
+ self.new("\u{1f321}", [:thermometer]),
307
+ self.new("\u{1f570}", [:mantelpiece_clock]),
308
+ self.new("\u{1f6cb}", [:couch_lamp]),
309
+ self.new("\u{1f6cf}", [:bed]),
310
+ self.new("\u{1f6cc}", [:person_bed]),
311
+ self.new("\u{1f6ce}", [:bellhop_bell]),
312
+ self.new("\u{1f37d}", [:fork_knife_plate]),
313
+
263
314
  ]
264
315
  end
265
316
  end
@@ -6,7 +6,7 @@ require 'set'
6
6
  module Rumoji
7
7
  class Emoji
8
8
  PEOPLE = Set[
9
- self.new("\u{1F604}", [:smile], "SMILING FACE WITH OPEN MOUTH AND SMILING EYES"),
9
+ self.new("\u{1F604}", [:smile, :simple_smile], "SMILING FACE WITH OPEN MOUTH AND SMILING EYES"),
10
10
  self.new("\u{1F606}", [:laughing], "SMILING FACE WITH OPEN MOUTH AND TIGHTLY-CLOSED EYES"),
11
11
  self.new("\u{1F60A}", [:blush], "SMILING FACE WITH SMILING EYES"),
12
12
  self.new("\u{1F603}", [:smiley], "SMILING FACE WITH OPEN MOUTH"),
@@ -93,6 +93,23 @@ module Rumoji
93
93
  self.new("\u{1F3B6}", [:notes], "MULTIPLE MUSICAL NOTES"), # "dancing notes, mood, melody"
94
94
  self.new("\u{1F3B5}", [:musical_note]), # "music, being in good mood"
95
95
  self.new("\u{1F525}", [:fire], "FIRE"),
96
+ self.new("\u{1F917}", [:hugging], "HUGGING FACE"),
97
+ self.new("\u{1F914}", [:thinking], "THINKING FACE"),
98
+ self.new("\u{1F644}", [:rolling_eyes], "FACE WITH ROLLING EYES"),
99
+ self.new("\u{1F910}", [:zipper_mouth], "ZIPPER-MOUTH FACE"),
100
+ self.new("\u{1F913}", [:nerd], "NERD FACE"),
101
+ self.new("\u{1F643}", [:upside_down], "UPSIDE-DOWN FACE"),
102
+ self.new("\u{1F912}", [:face_thermometer], "FACE WITH THERMOMETER"),
103
+ self.new("\u{1F915}", [:head_bandage], "FACE WITH HEAD-BANDAGE"),
104
+ self.new("\u{1F911}", [:money_mouth], "MONEY-MOUTH FACE"),
105
+ self.new("\u{1F916}", [:robot], "ROBOT FACE"),
106
+ self.new("\u{1F575}", [:sleuth], "SLEUTH OR SPY"),
107
+ self.new("\u{1F3CB}", [:weight_lifter], "WEIGHT LIFTER"),
108
+ self.new("\u{1F3CC}", [:golfer], "GOLFER"),
109
+ self.new("\u{1F574}", [:man_levitating], "MAN IN BUSINESS SUIT LEVITATING"),
110
+ self.new("\u{1F641}", [:slightly_frowning], "SLIGHTLY FROWNING FACE"),
111
+ self.new("\u{1F642}", [:slightly_smiling], "SLIGHTLY SMILING FACE"),
112
+
96
113
  # Poop
97
114
  self.new("\u{1F4A9}", [:poop, :hankey, :shit], "PILE OF POO"), # "dog dirt"
98
115
  self.new("\u{1F44D}", [:thumbsup, :"+1"], "THUMBS UP SIGN"),
@@ -148,6 +165,11 @@ module Rumoji
148
165
  self.new("\u{1F46E}", [:cop], "POLICE OFFICER"),
149
166
  self.new("\u{1F47C}", [:angel], "BABY ANGEL"),
150
167
  self.new("\u{1F478}", [:princess]),
168
+ self.new("\u{1F595}", [:middle_finger], "REVERSED HAND WITH MIDDLE FINGER EXTENDED"),
169
+ self.new("\u{1F596}", [:vulcan_salute], "RAISED HAND WITH PART BETWEEN MIDDLE AND RING FINGERS"), # vulcan salute
170
+ self.new("\u{1F918}", [:sign_horns], "SIGN OF THE HORNS"),
171
+ self.new("\u{1F590}", [:fingers_splayed], "RAISED HAND WITH FINGERS SPLAYED"),
172
+
151
173
  # Cats
152
174
  self.new("\u{1F63A}", [:smiley_cat], "SMILING CAT FACE WITH OPEN MOUTH"),
153
175
  self.new("\u{1F638}", [:smile_cat], "GRINNING CAT FACE WITH SMILING EYES"),
@@ -179,6 +201,17 @@ module Rumoji
179
201
  self.new("\u{1F465}", [:busts_in_silhouette]), # "accounts"
180
202
  self.new("\u{1F4AC}", [:speech_balloon]), # "comic book conversation bubble"
181
203
  self.new("\u{1F4AD}", [:thought_balloon]),
204
+ self.new("\u{1F5E8}", [:left_speech], "LEFT SPEECH BUBBLE"),
205
+ self.new("\u{1F5EF}", [:right_answer], "RIGHT ANSWER BUBBLE"),
206
+ self.new("\u{1F573}", [:hole], "HOLE"),
207
+ self.new("\u{1F576}", [:dark_sunglasses], "DARK SUNGLASSES"),
208
+ self.new("\u{1F5E3}", [:speaking_head]),
209
+ self.new("\u{1F441}", [:eye]),
210
+ self.new("\u{1F3FB}", [:type_1_2]),
211
+ self.new("\u{1F3FC}", [:type_3]),
212
+ self.new("\u{1F3FD}", [:type_4]),
213
+ self.new("\u{1F3FE}", [:type_5]),
214
+ self.new("\u{1F3FF}", [:type_6]),
182
215
  ]
183
216
  end
184
217
  end
@@ -97,6 +97,46 @@ module Rumoji
97
97
  self.new("\u{1f6a6}", [:vertical_traffic_light]),
98
98
  self.new("\u{26a0}" , [:warning]),
99
99
  self.new("\u{1f492}", [:wedding]),
100
+ self.new("\u{1f54b}", [:kaaba]),
101
+ self.new("\u{1f54c}", [:mosque]),
102
+ self.new("\u{1f54d}", [:synagogue]),
103
+ self.new("\u{1f3ce}", [:racing_car]),
104
+ self.new("\u{1f3cd}", [:racing_motorcycle]),
105
+ self.new("\u{1f3c5}", [:sports_medal]),
106
+ self.new("\u{1f3cf}", [:cricket_bat_ball]),
107
+ self.new("\u{1f3d0}", [:volleyball]),
108
+ self.new("\u{1f3d1}", [:field_hockey_stick]),
109
+ self.new("\u{1f3d2}", [:ice_hockey_stick]),
110
+ self.new("\u{1f3d3}", [:table_tennis_paddle]),
111
+ self.new("\u{1f3f8}", [:badminton_racquet]),
112
+ self.new("\u{1f3f7}", [:label]),
113
+ self.new("\u{1f39f}", [:admission_tickets]),
114
+ self.new("\u{1f39e}", [:film_frames]),
115
+ self.new("\u{1f397}", [:reminder_ribbon]),
116
+ self.new("\u{1f396}", [:military_medal]),
117
+ self.new("\u{1f6f0}", [:satellite]),
118
+ self.new("\u{1f6ec}", [:airplane_landing]),
119
+ self.new("\u{1f6eb}", [:airplane_departing]),
120
+ self.new("\u{1f6e9}", [:small_airplane]),
121
+ self.new("\u{1f6e5}", [:motor_boat]),
122
+ self.new("\u{1f6f3}", [:passenger_ship]),
123
+ self.new("\u{1f6e4}", [:railway_track]),
124
+ self.new("\u{1f6e3}", [:motorway]),
125
+ self.new("\u{1f5bc}", [:frame_with_picture]),
126
+ self.new("\u{1f3da}", [:derelict_house_building]),
127
+ self.new("\u{1f3d9}", [:cityscape]),
128
+ self.new("\u{1f3d8}", [:house_buildings]),
129
+ self.new("\u{1f3d7}", [:building_construction]),
130
+ self.new("\u{1f3db}", [:classical_building]),
131
+ self.new("\u{1f3df}", [:stadium]),
132
+ self.new("\u{1f3de}", [:national_park]),
133
+ self.new("\u{1f3dd}", [:desert_island]),
134
+ self.new("\u{1f3dc}", [:desert]),
135
+ self.new("\u{1f3d6}", [:beach_umbrella]),
136
+ self.new("\u{1f3d5}", [:camping]),
137
+ self.new("\u{1f3d4}", [:snow_capped_mountain]),
138
+ self.new("\u{1f5fa}", [:world_map]),
139
+
100
140
  # Regional Indicator Symbols
101
141
  self.new("\u{1f1ef 1f1f5}", [:jp], "REGIONAL INDICATOR SYMBOL LETTERS JP"),
102
142
  self.new("\u{1f1f0 1f1f7}", [:kr], "REGIONAL INDICATOR SYMBOL LETTERS KR"),
@@ -195,7 +195,13 @@ module Rumoji
195
195
  self.new("\u{1f533}", [:white_square_button]),
196
196
  self.new("\u{1f6ba}", [:womens]),
197
197
  self.new("\u{274c}" , [:x]),
198
- self.new("\u{0030 fe0f 20e3}" , [:zero])
198
+ self.new("\u{0030 fe0f 20e3}" , [:zero]),
199
+ self.new("\u{1f3fa}", [:black_circle_record]),
200
+ self.new("\u{1f3f9}", [:black_square_stop]),
201
+ self.new("\u{1f3f8}", [:double_vertical_bar]),
202
+ self.new("\u{1f549}", [:om]),
203
+ self.new("\u{1f6d0}", [:place_worship]),
204
+ self.new("\u{1f54e}", [:menorah]),
199
205
  ]
200
206
  end
201
207
  end
@@ -1,3 +1,3 @@
1
1
  module Rumoji
2
- VERSION = "0.4.1"
2
+ VERSION = "0.5.0"
3
3
  end
@@ -69,12 +69,5 @@ describe Rumoji::Emoji do
69
69
  it "finds an emoji from a string" do
70
70
  subject.find_by_string(smile_str).symbol.must_equal smile_sym
71
71
  end
72
-
73
- it "finds an emoji from a codepoint" do
74
- smile_str.codepoints.map do |point|
75
- subject.find_by_codepoint(point).symbol.must_equal smile_sym
76
- end
77
- end
78
72
  end
79
-
80
73
  end
@@ -18,6 +18,44 @@ describe Rumoji do
18
18
  Rumoji.encode(@smile).must_equal ":smile:"
19
19
  Rumoji.encode("#{@smile}").must_equal ":smile:"
20
20
  end
21
+
22
+ it "keeps codepoints that match the beginnings of multi-codepoint emoji" do
23
+ text = "i like #hashtags and 1direction they are the #1 band. end with 9"
24
+ Rumoji.encode(text).must_equal text
25
+ end
26
+
27
+ describe "with multiple codepoints" do
28
+ it "transforms a stream" do
29
+ Rumoji.encode("#{@zero}").must_equal ":zero:"
30
+ Rumoji.encode("#{@us}").must_equal ":us:"
31
+ end
32
+
33
+ it "transforms a stream of many emoji" do
34
+ num = ":one: :two: :three: :four: :five: :six: :seven: :eight: :nine: :zero: :hash:"
35
+ emoji = "1️⃣ 2️⃣ 3️⃣ 4️⃣ 5️⃣ 6️⃣ 7️⃣ 8️⃣ 9️⃣ 0️⃣ #️⃣"
36
+ Rumoji.encode(emoji).must_equal num
37
+ end
38
+
39
+ it "does not encode double digits" do
40
+ num = ":zero: :one: :two: :three: :four: :five: :six: :seven: :eight: :nine: :hash:"
41
+ double_digits = "00 11 22 33 44 55 66 77 88 99 ##"
42
+ Rumoji.encode(double_digits).wont_equal num
43
+ end
44
+
45
+ describe "with leading and trailing characters" do
46
+ it "is able to pull multipoint emoji out of a sequence" do
47
+ string = "An example of a multipoint emoji is the #{@us} flag."
48
+ Rumoji.encode(string).must_equal "An example of a multipoint emoji is the :us: flag."
49
+ end
50
+ end
51
+
52
+ describe "with trailing emoji" do
53
+ it "writes characters that are in a multipoint emoji followed by an emoji" do
54
+ string = "I would like 0#{@poop}"
55
+ Rumoji.encode(string).must_equal "I would like 0:poop:"
56
+ end
57
+ end
58
+ end
21
59
  end
22
60
 
23
61
  describe "#decode" do
@@ -32,10 +70,14 @@ describe Rumoji do
32
70
  it "transforms a cheat-sheet code with a dash into an emoji" do
33
71
  Rumoji.decode(":non-potable_water:").must_equal @non_potable_water
34
72
  end
35
-
73
+
36
74
  it "does not transform an arbitrary string wrapped in colons" do
37
75
  Rumoji.decode(":this-is-just-a-string:").must_equal ":this-is-just-a-string:"
38
76
  end
77
+
78
+ it "transforms a cheat-sheet code into an emoji with line brake" do
79
+ Rumoji.decode(":\nabc:poop:").must_equal ":\nabc" + @poop
80
+ end
39
81
  end
40
82
 
41
83
  describe "#encode_io" do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rumoji
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.1
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mark Wunsch
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-06-11 00:00:00.000000000 Z
11
+ date: 2016-05-05 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Transcode emoji utf-8 characters into emoji-cheat-sheet form
14
14
  email:
@@ -55,7 +55,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
55
55
  version: '0'
56
56
  requirements: []
57
57
  rubyforge_project:
58
- rubygems_version: 2.2.2
58
+ rubygems_version: 2.5.1
59
59
  signing_key:
60
60
  specification_version: 4
61
61
  summary: Transcode emoji utf-8 characters into emoji-cheat-sheet form