Socket
Book a DemoInstallSign in
Socket

faraday_middleware-reddit

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

faraday_middleware-reddit

0.4.2
bundlerRubygems
Version published
Maintainers
1
Created
Source

FaradayMiddleware::Reddit

A collection of Faraday middleware for use with the Reddit API.

This project is the backbone for reddit-base. If you're building a client from scratch or just want to get up and running quickly you might want to check it out instead.

Installation

Add this line to your application's Gemfile:

gem 'faraday_middleware-reddit'

And then execute:

$ bundle

Or install it yourself as:

$ gem install faraday_middleware-reddit

Requirements

faraday and faraday_middleware are currently gemspec dependencies.

Like faraday_middleware, faraday_middleware-reddit requires a json library. Ruby versions prior to 1.9 will need to have one installed.

Usage

faraday_middleware-reddit currently provides the following middleware:

MiddlewareTypeDescription
:reddit_authenticationrequestAuthentication based on a username, password or pre-generated cookie.
:reddit_force_jsonuseCoerces reddit into returnign JSON for GET and POST requests.
:reddit_modhashuseAutomatic modhash handling.
:reddit_raise_errorresponseRaises errors for common reddit error cases.
:reddit_rate_limituseRate limiting based on reddit's x-ratelimit headers. Accepts a strategy proc to override default linear strategy.

Examples

An example Farday client might look like:

require 'faraday_middleware/reddit'

conn = Faraday.new(url: 'http://www.reddit.com', headers: {'User-Agent' => 'faraday_middleware-reddit example (v 0.0.1)'}) do |faraday|
  faraday.request  :url_encoded
  faraday.request  :reddit_authentication, user: 'yourusername', password: 'yourpassword'
  faraday.request  :retry, max: 2, interval: 2, exceptions: FaradayMiddleware::Reddit::RETRIABLE_ERRORS

  faraday.response :logger
  faraday.response :follow_redirects
  faraday.response :reddit_raise_error

  faraday.use  :reddit_force_json
  faraday.use  :reddit_rate_limit
  faraday.use  :reddit_modhash

  faraday.adapter  Faraday.default_adapter
end

Contributing

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

Contributors

This project is copyright 2014 by its contributors, licensed under Apache License 2.0.

FAQs

Package last updated on 05 Jun 2014

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.