0.0
No commit activity in last 3 years
No release in over 3 years
MotionOcean, for RubyMotion, is an implementation of v2 of the Digital Ocean API
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

>= 1.0.0, ~> 1.0
>= 0.1.0, ~> 0.1
>= 10.3.0, ~> 10.3

Runtime

>= 1.1.0, ~> 1.1
 Project Readme

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

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