Git Product home page Git Product logo

tweet_pretty's Introduction

TweetPretty

Build Status Dependency Status Code Climate Coverage Status

As the missing formatting tool for the Twitter gem, TweetPretty allows you to easily replace entities in tweets with properly encoded HTML to conform to Twitter's Display Requirements.

Installation

Add this line to your application's Gemfile:

gem 'tweet_pretty'

And then execute:

$ bundle

Or install it yourself as:

$ gem install tweet_pretty

Usage

If you're not working in an environment where gems are auto-loaded, then require the gem to monkey patch the Twitter::Tweet class:

require 'tweet_pretty'

Use the Twitter gem to pull a tweet:

> tweet = Twitter.status(379713438806597632)

Then use the to_html method to convert its text attribute into a properly converted HTML snippet:

> tweet.text
=> "Pardon this test tweet. It's hard to find tweets containing at least one of each entity. #devtest @mherold https://t.co/CbYo8pjDDO"
> tweet.to_html
=> "Pardon this test tweet. It&#39;s hard to find tweets containing at least one of each entity. <a class="hashtag" href="http://twitter.com/search?q=#devtest">#devtest</a> <a class="user-mention" title="Michael Herold" href="http://twitter.com/mherold">@mherold</a> <a class="link" href="https://t.co/CbYo8pjDDO">twitter.com/mherold</a>"

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request

Acknowledgments

  • The original algorithm used to do the text replacements was based on some Javascript code in a gist by @wadey. This little snippet inspired me to encapsulate the functionality for use with the Twitter Ruby gem. This algorithm has since been replaced by a more Ruby-ish approach.
  • The configuration class is based off of that from Geocoder, which is a pretty awesome library for geocoding in Ruby.

Supported Ruby Versions

This library aims to support the same set of Ruby implementations as the twitter gem, which it is extending. Currently, those are:

  • Ruby 1.8.7
  • Ruby 1.9.2
  • Ruby 1.9.3
  • Ruby 2.0.0

Versioning

This library aims to adhere to Semantic Versioning 2.0.0. Violations of this scheme should be reported as bugs. Thus, you should specify a gem dependency using the Pessimistic Version Constraint with two digits of precision:

# In Gemfile
gem 'tweet_pretty', '~> 1.0'

# In .gemspec
spec.add_dependency 'tweet_pretty', '~> 1.0'

Copyright

Copyright (c) 2013 Michael Herold. Open sourced under the terms of the MIT license.

tweet_pretty's People

Contributors

michaelherold avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.