0.0
No commit activity in last 3 years
No release in over 3 years
Provides methods to add, update, create revisions of bins and obtain bin preview URLs
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 2.7
~> 1.11

Runtime

 Project Readme

jsbin-client

Build Status

jsbin-client is a simple Ruby client for JSBin http://jsbin.com/. It provides basic CRUD methods to retrieve a bin, create a bin, and create a revision for an existing bin.

The library supports anonymous or token authentication if required by the server.

Please see https://github.com/remy/jsbin/pull/605 for more information on JSBin's support API requests

Installation

Using Bundler, add the following to your Gemfile

gem 'jsbin-client'

or install manually using Ruby Gems:

gem install jsbin-client

Code example

client = JsBinClient.new(host: 'jsbin.com', port: 80, ssl: false)

bin = client.create(html: '<html><body></body></html>', javascript: 'console.log("init");', css: 'body { color: red }')
# => {
#   "html"=>"<html><body></body></html>",
#   "javascript": "console.log(\"init\");",
#   "css": "body { color: red }'",
#   "settings": "{ processors: {} }",
#   "url": "[unique-id]",
#   "revision": 1,
#   "streamingKey": "[key]",
#   "id": 7
# }

bin.get(bin[:url])
# returns JSON representation of bin

bin.create_revision(bin[:url], html: 'updated html')
# returns JSON representation of new bin revision

bin.url_for(bin[:url])
# => 'http://jsbin.com:80/[unique-id]/edit'

bin.url_for(bin[:url], preview: true)
# => 'http://jsbin.com:80/[unique-id]'

bin.url_for(bin[:url], embed: true, panels: ['javascript', 'live'])
# => 'http://jsbin.com:80/[unique-id]/embed?javascript,live'

Repository

Please fork, submit patches or feedback at https://github.com/mattheworiordan/jsbin-client

The gem details on RubyGems.org can be found at https://rubygems.org/gems/jsbin-client

About

This gem was written by Matthew O'Riordan

License

Copyright © 2013 Matthew O'Riordan, inc. It is free software, and may be redistributed under the terms specified in the LICENSE file.