@@ -30,17 +30,15 @@ Note: `excoveralls` is currently lying, actual test coverage is :100:.
30
30
Installation
31
31
------------
32
32
33
- Add it to your deps list in your ` mix.exs ` . Once this package has been released
34
- _ (e.g. not yet)_ , you will be able to do:
33
+ Add it to your deps list in your ` mix.exs ` .
35
34
36
35
``` elixir
37
36
defp deps do
38
- [{:exmoji , " ~> 0.0.1 " }]
37
+ [{:exmoji , " ~> 0.2.0 " }]
39
38
end
40
39
```
41
40
42
- In the meantime, or to get the development version, you can pull directly from
43
- GitHub:
41
+ To get the development version, you can pull directly from GitHub:
44
42
45
43
``` elixir
46
44
defp deps do
@@ -61,19 +59,22 @@ The main library, with detailed search and conversion functions.
61
59
Some examples:
62
60
63
61
``` iex
64
- iex> Exmoji.from_unified("1F680")
65
- %Exmoji.EmojiChar{name: "ROCKET ", short_name: "rocket ", short_names: ["rocket "],
66
- text: nil, unified: "1F680 ", variations: []}
62
+ iex> Exmoji.from_unified "0023-20E3"
63
+ %Exmoji.EmojiChar{name: "HASH KEY ", short_name: "hash ", short_names: ["hash "],
64
+ text: nil, unified: "0023-20E3 ", variations: ["0023-FE0F-20E3" ]}
67
65
68
- iex> Exmoji.find_by_short_name("MOON") |> Enum.count
66
+ iex> Exmoji.all |> Enum.count
67
+ 845
68
+
69
+ iex> Exmoji.all_with_variants |> Enum.count
70
+ 107
71
+
72
+ iex> Exmoji.find_by_short_name("moon") |> Enum.count
69
73
13
70
74
71
75
iex> for t <- Exmoji.find_by_name("tree"), do: t.name
72
76
["EVERGREEN TREE", "DECIDUOUS TREE", "PALM TREE", "CHRISTMAS TREE",
73
77
"TANABATA TREE"]
74
-
75
- iex> Exmoji.all_doublebyte |> Enum.count
76
- 21
77
78
```
78
79
79
80
#### Exmoji.EmojiChar
@@ -86,33 +87,45 @@ representation of an Emoji character suitable for transmission. It understands
86
87
which Emoji have variant encodings and will do the right thing to make sure they
87
88
are likely to display correctly on the other end.
88
89
90
+ ``` iex
91
+ iex> alias Exmoji.EmojiChar
92
+ nil
93
+
94
+ iex> for e <- Exmoji.all, EmojiChar.doublebyte?(e), do: e.short_name
95
+ ["hash", "zero", "one", "two", "three", "four", "five", "six", "seven", "eight",
96
+ "nine", "cn", "de", "es", "fr", "gb", "it", "jp", "kr", "ru", "us"]
97
+
98
+ iex> for m <- Exmoji.find_by_short_name("moon"), do: EmojiChar.render(m)
99
+ ["🌑", "🌒", "🌓", "🌔", "🌕", "🌖", "🌗", "🌘", "🌙", "🌚", "🌛", "🌜", "🌝"]
100
+
101
+ ```
102
+
89
103
#### Exmoji.Scanner
90
104
Provides very fast searches against binary strings for the presence of UTF-8
91
105
encoded Emoji glyphs. Whereas the Ruby and NodeJS versions of this library
92
- accomplish this via regular expressions, the Elixir version relies on binary
93
- pattern matching, making it faster.
106
+ accomplish this via regular expressions, the Elixir version relies on optmized
107
+ binary pattern matching, making it faster.
94
108
95
109
An example:
96
110
97
111
``` iex
98
- iex> Exmoji.Scanner.scan("flying on my 🚀 to visit the 👾 people.")
99
- [%Exmoji.EmojiChar{name: "ROCKET", short_name: "rocket",
100
- short_names: ["rocket"], text: nil, unified: "1F680", variations: []},
101
- %Exmoji.EmojiChar{name: "ALIEN MONSTER", short_name: "space_invader",
102
- short_names: ["space_invader"], text: nil, unified: "1F47E", variations: []}]
112
+ iex> for ec <- Exmoji.Scanner.scan("I ♥ when marketers talk about the ☁.") do
113
+ ...> IO.puts "Found some #{ec.short_name}!"
114
+ ...> end
115
+ Found some hearts!
116
+ Found some cloud!
117
+ [:ok, :ok]
118
+
103
119
```
104
120
121
+ ## Contributing
122
+
123
+ Please be sure to run ` mix test ` and help keep test coverage at :100 : .
105
124
106
- Terminology Note
107
- ----------------
108
- This library uses the term "char" extensively to refer to a single emoji glyph
109
- in string encoding. In Elixir/Erlang ` char ` means something specific, which
110
- may be confusing because of the charlist/bitstring division (this library uses
111
- bitstrings). I may rename all those API functions for this version of the lib
112
- because of that, but for now I'm keeping it consistent with the official Unicode
113
- names for things...
125
+ There is a full benchmark suite available via ` mix bench ` . Please
126
+ run before and after your changes to ensure you have not caused a performance
127
+ regression.
114
128
129
+ ## License
115
130
116
- License
117
- -----------
118
131
[ The MIT License (MIT)] ( LICENSE )
0 commit comments