No release in over 3 years
Sanitize X Post (formerly Twitter Tweet)
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
 Dependencies

Development

>= 0
~> 13.0
>= 0
~> 3.0
>= 0
>= 0
 Project Readme

XPostSanitizer

Sanitize X Post (formerly Twitter Tweet)

Gem Version test

Installation

Install the gem and add to the application's Gemfile by executing:

bundle add x_post_sanitizer

If bundler is not being used to manage dependencies, install the gem by executing:

gem install x_post_sanitizer

Usage

Use XPostSanitizer.sanitize_text

e.g.

require "json"
require "x_post_sanitizer"

# https://x.com/github/status/866677968608927744
tweet = JSON.parse(File.read("spec/support/fixtures/full_text_tweet1.json"))

tweet["full_text"]
#=> "Introducing GitHub Marketplace, a new place to browse and buy integrations using your GitHub account. https://t.co/mPTtAxnU5z https://t.co/Wz2mUql2lc"

XPostSanitizer.sanitize_text(tweet)
#=> "Introducing GitHub Marketplace, a new place to browse and buy integrations using your GitHub account. https://github.com/blog/2359-introducing-github-marketplace-and-more-tools-to-customize-your-workflow"

Features

  • Expand urls in text or full_text (e.g. t.co url -> original url)
  • Remove media urls in text or full_text
  • Unescape special html characters in text or full_text (e.g. (&gt; &lt;) -> (> <))

All methods and options are followings

https://sue445.github.io/x_post_sanitizer/XPostSanitizer.html

vs. tweet_sanitizer

This has the same features as tweet_sanitizer but with the following differences

Development

After checking out the repo, run bin/setup to install dependencies. Then, run rake spec to run the tests. You can also run bin/console for an interactive prompt that will allow you to experiment.

To install this gem onto your local machine, run bundle exec rake install. To release a new version, update the version number in version.rb, and then run bundle exec rake release, which will create a git tag for the version, push git commits and the created tag, and push the .gem file to rubygems.org.

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/sue445/x_post_sanitizer.

License

The gem is available as open source under the terms of the MIT License.