ProductPromotion
Logo

Ruby

made by https://0x3d.site

GitHub - wpeterson/emoji: A gem. For Emoji. For everyone. ❤
A gem. For Emoji. For everyone. ❤. Contribute to wpeterson/emoji development by creating an account on GitHub.
Visit Site

GitHub - wpeterson/emoji: A gem. For Emoji. For everyone. ❤

GitHub - wpeterson/emoji: A gem. For Emoji. For everyone. ❤

Emoji

Build Status

A Ruby gem. For emoji. For everyone. :heart:

This gem exposes the Phantom Open Emoji library unicode/image assets and APIs for working with them.

Easily look up emoji's name, unicode character, or image assets and convert it into emoji representations.

Table of Contents

Installation

First, add this line to your application's Gemfile:

gem 'emoji'

And then execute:

$ bundle

Or install it yourself as:

$ gem install emoji

Finally, install the emoji image library assets:

$ rake emoji:install_assets
====================================================================
= emoji image assets install
= Target: /Users/user/src/rails-app/app/assets/images/emoji
= Source: /Users/user/src/emoji/assets/images
====================================================================
- Creating /Users/user/src/rails-app/app/assets/images/emoji...
- Installing assets...

Usage

You can use this gem to replace unicode emoji characters with img tags linking to the appropriate emoji image.

Image Replacement APIs:

> Emoji.replace_unicode_moji_with_images('I ❤ Emoji')
=> "I <img alt=\"❤\" class=\"emoji\" src=\"http://localhost:3000/assets/emoji/heart.png\"> Emoji"

> Emoji.image_url_for_unicode_moji('❤')
=> "http://localhost:3000/assets/emoji/heart.png"

> Emoji.image_url_for_name('heart')
=> "http://localhost:3000/assets/emoji/heart.png"

Emoji Library Index APIs:

> index = Emoji::Index.new

> index.find_by_name('heart')
=> {"moji"=>"❤", "name"=>"heart", "name-ja"=>"ハート", "category"=>"abstract", "unicode"=>"2764"}

> index.find_by_moji('❤')
=> {"moji"=>"❤", "name"=>"heart", "name-ja"=>"ハート", "category"=>"abstract", "unicode"=>"2764"}

> index.find_by_unicode('2764')
=> {"moji"=>"❤", "name"=>"heart", "name-ja"=>"ハート", "category"=>"abstract", "unicode"=>"2764"}

Default configuration integrates with Rails, but you can change it with an initializer:

# config/initializers/emoji.rb
Emoji.asset_host = "emoji.cdn.com"
Emoji.asset_path = '/assets/emoji'
Emoji.use_plaintext_alt_tags = true

String Helper Methods:

You can also include the string helper module

require 'emoji/string_ext'

and call methods directly on your string to return the same results:

> 'I ❤ Emoji'.with_emoji_images
=> "I <img alt=\"❤\" class=\"emoji\" src=\"http://localhost:3000/assets/emoji/heart.png\"> Emoji"

> 'heart'.image_url
> '❤'.image_url
=> "http://localhost:3000/assets/emoji.heart.png"

> 'heart'.emoji_data
> '❤'.emoji_data
=> {"moji"=>"❤", "name"=>"heart", "name-ja"=>"ハート", "category"=>"abstract", "unicode"=>"2764"}

Emoji Asset Host

By default when used with Rails, this gem will inherit Rails configured Rails.asset_host. Otherwise, you will need to manually configure the Emoji.asset_host as a string URL or a lambda/proc.

# String URL
Emoji.asset_host = 'http://your.com'

# Custom Host Proc, takes asset path as a param
Emoji.asset_host = lambda {|path| path.size % 2 == 0 ? 'http://even.com' : 'http://odd.com'}

HTML Safety and Performance

This gem uses pure Ruby code for compatibility with different Ruby virtual machines. However, there can be significant performance gains to escaping incoming HTML strings using optimized, native code in the escape_utils gem.

The emoji gem will try to use escape_utils if it's available, but does not require it. Benchmarks show a 10x-100x improvement in HTML escaping performance, based on the size of the string being processed.

To enable native HTML escaping, add this line to your application's Gemfile:

gem 'escape_utils'

Contributors: :heart:

This project was spawned from conversation at the BurlingtonRB conference between Steve/Winfield. Together, they built the the initial gem. Huge thanks to everyone else who's submitted code and work to the project.

Contributing

  1. Fork the repo
  2. Bundle Install (bundle install)
  3. Run the Tests (rake test)
  4. Create your feature branch (git checkout -b my-new-feature)
  5. Commit your changes (git commit -am 'Add some feature')
  6. Push to the branch (git push origin my-new-feature)
  7. Create new Pull Request

More Resources
to explore the angular.

mail [email protected] to add your project or resources here 🔥.

Related Articles
to learn about angular.

FAQ's
to learn more about Angular JS.

mail [email protected] to add more queries here 🔍.

More Sites
to check out once you're finished browsing here.

0x3d
https://www.0x3d.site/
0x3d is designed for aggregating information.
NodeJS
https://nodejs.0x3d.site/
NodeJS Online Directory
Cross Platform
https://cross-platform.0x3d.site/
Cross Platform Online Directory
Open Source
https://open-source.0x3d.site/
Open Source Online Directory
Analytics
https://analytics.0x3d.site/
Analytics Online Directory
JavaScript
https://javascript.0x3d.site/
JavaScript Online Directory
GoLang
https://golang.0x3d.site/
GoLang Online Directory
Python
https://python.0x3d.site/
Python Online Directory
Swift
https://swift.0x3d.site/
Swift Online Directory
Rust
https://rust.0x3d.site/
Rust Online Directory
Scala
https://scala.0x3d.site/
Scala Online Directory
Ruby
https://ruby.0x3d.site/
Ruby Online Directory
Clojure
https://clojure.0x3d.site/
Clojure Online Directory
Elixir
https://elixir.0x3d.site/
Elixir Online Directory
Elm
https://elm.0x3d.site/
Elm Online Directory
Lua
https://lua.0x3d.site/
Lua Online Directory
C Programming
https://c-programming.0x3d.site/
C Programming Online Directory
C++ Programming
https://cpp-programming.0x3d.site/
C++ Programming Online Directory
R Programming
https://r-programming.0x3d.site/
R Programming Online Directory
Perl
https://perl.0x3d.site/
Perl Online Directory
Java
https://java.0x3d.site/
Java Online Directory
Kotlin
https://kotlin.0x3d.site/
Kotlin Online Directory
PHP
https://php.0x3d.site/
PHP Online Directory
React JS
https://react.0x3d.site/
React JS Online Directory
Angular
https://angular.0x3d.site/
Angular JS Online Directory