Skip to content

Commit 0982b7f

Browse files
committed
better examples in readme
1 parent 3258165 commit 0982b7f

File tree

1 file changed

+42
-29
lines changed

1 file changed

+42
-29
lines changed

README.md

+42-29
Original file line numberDiff line numberDiff line change
@@ -30,17 +30,15 @@ Note: `excoveralls` is currently lying, actual test coverage is :100:.
3030
Installation
3131
------------
3232

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`.
3534

3635
```elixir
3736
defp deps do
38-
[{:exmoji, "~> 0.0.1"}]
37+
[{:exmoji, "~> 0.2.0"}]
3938
end
4039
```
4140

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:
4442

4543
```elixir
4644
defp deps do
@@ -61,19 +59,22 @@ The main library, with detailed search and conversion functions.
6159
Some examples:
6260

6361
```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"]}
6765
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
6973
13
7074
7175
iex> for t <- Exmoji.find_by_name("tree"), do: t.name
7276
["EVERGREEN TREE", "DECIDUOUS TREE", "PALM TREE", "CHRISTMAS TREE",
7377
"TANABATA TREE"]
74-
75-
iex> Exmoji.all_doublebyte |> Enum.count
76-
21
7778
```
7879

7980
#### Exmoji.EmojiChar
@@ -86,33 +87,45 @@ representation of an Emoji character suitable for transmission. It understands
8687
which Emoji have variant encodings and will do the right thing to make sure they
8788
are likely to display correctly on the other end.
8889

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+
89103
#### Exmoji.Scanner
90104
Provides very fast searches against binary strings for the presence of UTF-8
91105
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.
94108

95109
An example:
96110

97111
```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+
103119
```
104120

121+
## Contributing
122+
123+
Please be sure to run `mix test` and help keep test coverage at :100:.
105124

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.
114128

129+
## License
115130

116-
License
117-
-----------
118131
[The MIT License (MIT)](LICENSE)

0 commit comments

Comments
 (0)