Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

social_media_parser

Package Overview
Dependencies
Maintainers
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

social_media_parser

  • 0.1.5
  • Rubygems
  • Socket score

Version published
Maintainers
3
Created
Source

SocialMediaParser

Parse social media attributes from url or construct url from attributes.

Gem Version Code Climate Test Coverage Build Status

Installation

Add this line to your application's Gemfile:

gem 'social_media_parser'

And then execute:

$ bundle

Or install it yourself as:

$ gem install social_media_parser

Usage

parser = SocialMediaParser.parse "https://www.facebook.com/teamcoco"
=> #<SocialMediaParser::Provider::Facebook:0x007fe014ef0f78 @url="https://www.facebook.com/teamcoco">

parser.username
=> "teamcoco"

parser.provider
=> "facebook"

parser.url
=> "https://www.facebook.com/teamcoco"

SocialMediaParser.parse accepts either a url string or a hash, that accepts

{
  username: "teamcoco",
  provider: "facebook",
  url: "https://www.facebook.com/teamcoco",
  url_or_username: "teamcoco"
 }

The url_or_username option can be used when you're not sure of the input, like the screenshot below for instance. This gem is built to take user input directly.

screen shot 2014-09-06 at 21 49 51

If the input provided isn't enough for SocialMediaParser to figure out which provider it is, it returns a SocialMediaParser::Link object instead.

link = SocialMediaParser.parse "www.ruby-lang.org/en/"
=> #<SocialMediaParser::Link:0x007fe014fd8350 @url="https://www.ruby-lang.org/en/">

link.url
=> "http://www.ruby-lang.org/en/"

The url method will always return a clean url, prepending http schema if needed and validating the top domain, using public_suffix.

Why?

We use this gem to provide a unified way to describe a social media object, from any given input. Most notably, if you're working with Traackr Api, you'll know they don't provide a url to a social media profile, whereas input directly from a user will likely only have a url.

Requirements

Ruby > 1.9

FAQs

Package last updated on 24 Jul 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

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc