Socket
Book a DemoInstallSign in
Socket

emoji_replace

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

emoji_replace

0.0.0
bundlerRubygems
Version published
Maintainers
1
Created
Source

Build Status Code Climate Test Coverage

EmojiReplace

A library to work around the special UTF8MB4 encoding in Ruby and Ruby on Rails.

Uses the "emoji" gem here: https://github.com/wpeterson/emoji

Install

Add this to your Gemfile and bundle:

gem "emoji_replace"

Seamless usage

Modify your model like this:

class Message < ActiveRecord::Base
  include EmojiReplace::Seamless
  replace_emoji_seamlessly :message
end

You can now call the attributes like normal:

message.message = "I ❤ you"
message.message #=> "I ❤ you"
message.read_attribute(:message) #=> "I %{emoji:heart} you"
message.message(html: true) #=> "I <img alt=\"heart\" class=\"emoji\" src=\"http://localhost:3000/heart.png\"> you"

Manual usage

If you don't want the seamless functionality, you can also perform the replace manually like this:

Replace emoji's to the code format:

replacer = EmojiReplace::Replacer.new(text: "I ❤ you")
replacer.replace
replacer.text #=> "I %{emoji:heart} you"

Replace the code format back to emoji's:

replacer = EmojiReplace::Replacer.new(text: "I %{emoji:heart} you")
replacer.back
replacer.text #=> "I ❤ you"

Replace the code format back to HTML:

replacer = EmojiReplace::Replacer.new(text: "I %{emoji:heart} you")
replacer.back(html: true)
replacer.text #=> "I <img alt=\"heart\" class=\"emoji\" src=\"http://localhost:3000/heart.png\"> you"

Contributing to emoji_replace

  • Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.
  • Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it.
  • Fork the project.
  • Start a feature/bugfix branch.
  • Commit and push until you are happy with your contribution.
  • Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
  • Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.

Copyright (c) 2015 kaspernj. See LICENSE.txt for further details.

FAQs

Package last updated on 28 Sep 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.