🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
DemoInstallSign in
Socket

motion_ocean

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

motion_ocean

0.2.1
Rubygems
Version published
Maintainers
1
Created
Source

MotionOcean

Gem Version

RubyMotion library for version 2 of DigitalOcean's API

Please note that version 2 of DigitalOcean's API is in beta, and is still being developed. Everything is subject to change.

Installation

Add this line to your application's Gemfile:

gem 'motion_ocean'

And then execute:

$ bundle

Or install it yourself as:

$ gem install motion_ocean

Initialization

client = MotionOcean::Client.new(access_token: 'token')

or

client = MotionOcean::Client.new do |config|
  config.access_token = 'token'
end

Usage

The API client is based on NSURLSession and every request is executed asynchronously. Every MotionOcean method call therefore requires a block, which yields a MotionOcean::API::Response.

MotionOcean pretty much implements the DO API 1:1, so please check their documentation for the available functions and options.

The response object

success?

You can use success? to check if a successful HTTP status code was returned:

client.droplet.create(options) do |result|
  result.success? # => true
end

data

The response data is assigned to the data-property of the response object. This is a Hash which corresponds with the returned JSON by DigitalOcean.

client.droplet.create(options) do |result|
  result.data # => Hash with the JSON response
end

response

MotionOcean uses NSURLSession. You can use response to get to the original response object:

client.droplet.create(options) do |result|
  result.response # => NSHTTPURLResponse
end

error

When there is an error you can check this for the specific error. If you think it is a bug in MotionOcean, please open an issue or even better: submit a Pull Request with the fix!

Aknowledgements

This library is an adaptation for RubyMotion of barge by Ørjan Blom.

The brilliant MotionInMotion screencasts helped me with implementing the API client using NSURLSession (specifically episode #33) and iOS development using RubyMotion in general.

Contributing

  • Fork it ( https://github.com/datarift/motion_ocean/fork )
  • 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 a new Pull Request

FAQs

Package last updated on 01 Aug 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