Giter Club home page Giter Club logo

ruroku's Introduction

Ruroku

Build Status Dependency Status

The better Ruby client for Heroku API, built on top of official heroku.rb gem.

Installation

Add this line to your application's Gemfile:

gem 'ruroku'

And then execute:

$ bundle

Or install it yourself as:

$ gem install ruroku

Usage

Start by initiating a connection with Heroku API:

heroku = Ruroku::API.new api_key: YOUR_HEROKU_API_KEY

(You can leave out :api_key if ENV['HEROKU_API_KEY'] is set instead.)

Now you can interact with Heroku API using Ruroku.

Apps

Each API object has apps associated with the Heroku account. You can access an Array of all the associated apps with #apps:

heroku.apps
# => [#<App>, #<App>, #<App>]

app = heroku.apps.first

To get specific app:

app = heroku.app 'app-name'

# or:

app = heroku.apps['app-name']

# or even:

app = heroku['app-name']

And access its properties such as:

  • id
  • name
  • stack
  • git_url
  • slug_size
  • repo_size
  • dynos
  • workers

Maintenance mode can be turned on and off:

app.maintenance!
app.no_maintenance!

Also, imagine you've created another app after you you queried heroku.app. To refresh collection of apps (or other collections: addons, config vars, collaborators, and so on), just call #reload on collection:

apps.reload

Addons

To get a list of addons used by a particular app:

addons = app.addons
# => [#<Addon>, #<Addon>, #<Addon>]

addon = app.addons.first

It's possible perform several actions on addon collections:

# Add an addon
addons.add 'addon:plan'

# Remove an addon
addons.delete 'addon-name'

# Upgrade an addon
addons.upgrade 'addon:new-plan'

Each addon object is associated with the application. You can delete addons from the app by calling #delete method on the addon object as well:

addon.delete!

Collaborators

List all app collaborators:

collaborators = app.collaborators

get a specific collaborator:

collaborators['[email protected]']

and

# Add a collaborator
collaborators.add '[email protected]'

# Remove a collaborator
collaborators.delete '[email protected]'
# or
collaborator.delete!

Config variables

List all app config vars:

config_vars = app.config_vars

Add or delete a config var:

config_vars.add 'KEY' => 'value'
config_vars.delete 'KEY'

# or:

config_var.delete!

They can also be updated like that:

config_var.value = 'new value'

Get/set a specific var:

config_vars['DEBUG'] # => false
config_vars['DEBUG'] = true

And it'll instantly get updated.

Domains

Access domains used by the application:

domains = app.domains

Same as with other collection objects, they can be added or deleted:

domains.add 'domain.com'
domains.delete 'domain.com'

# or:

domain.delete!

Processes

Get current application processes:

processes = app.processes

You can also run, restart, scale, and stop method collections:

processes.run 'rake evolve'
processes.restart
processes.scale 'worker', 10
processes.stop 'ps' => 'run.1'
processes.stop 'type' => 'worker'

And access specific processes/process groups:

processes['web.1']
processes['web']

Releases

List all app releases:

releases = app.releases

Get specific release:

releases[2]
releases['v2']

Or a range of releases:

releases[1..10]

And rollback to any release:

releases.rollback 'v1'
release.rollback

Stacks

List stacks, available for the app:

app.stacks

Migrate the app to available stack:

stacks.migrate 'stack-name'

Logs

Get the Array of String log lines:

app.logs

User

Get User object associtaed with current heroku account:

heroku.user

Keys

Access all keys:

keys = heroku.keys

Add a key:

keys.add 'content of id_rsa.pub here...'

Delete specific key:

keys.delete '[email protected]'
key.delete!

Delete all keys:

keys.delete_all

Mock

For practice or testing you can also use a simulated Heroku:

require 'ruroku'

heroku = Ruroku::API.new api_key: API_KEY, mock: true

After that commands should still behave the same, but they will only modify some local data instead of updating the state of things on Heroku.

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Added some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request

License

Released under the MIT license.

ruroku's People

Contributors

se7enstar25 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.