https://github.com/dblock/heroku-commander
Master the Heroku CLI from Ruby.
https://github.com/dblock/heroku-commander
Last synced: 12 months ago
JSON representation
Master the Heroku CLI from Ruby.
- Host: GitHub
- URL: https://github.com/dblock/heroku-commander
- Owner: dblock
- License: mit
- Created: 2013-01-29T21:20:46.000Z (over 13 years ago)
- Default Branch: master
- Last Pushed: 2014-12-30T22:32:12.000Z (over 11 years ago)
- Last Synced: 2024-12-27T21:29:15.865Z (over 1 year ago)
- Language: Ruby
- Homepage:
- Size: 327 KB
- Stars: 7
- Watchers: 5
- Forks: 6
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE.md
Awesome Lists containing this project
README

Heroku::Commander
=================
[](http://badge.fury.io/rb/heroku-commander)
[](https://travis-ci.org/dblock/heroku-commander)
[](https://gemnasium.com/dblock/heroku-commander)
[](https://codeclimate.com/github/dblock/heroku-commander)
Master the Heroku CLI from Ruby.
Usage
-----
Add `heroku` and `heroku-commander` to Gemfile.
``` ruby
gem "heroku"
gem "heroku-commander"
```
Heroku Configuration
--------------------
Returns a hash of an application's configuration (output from `heroku config`).
``` ruby
commander = Heroku::Commander.new({ :app => "heroku-commander" })
commander.config # => a hash of all settings for the heroku-commander app
```
Heroku Processes
----------------
Returns or yields an array of processes by running `heroku ps`.
``` ruby
commander = Heroku::Commander.new({ :app => "heroku-commander" })
commander.processes do |process|
# try process.pid and process.status
end
```
Heroku Run
----------
Executes a command via `heroku run`, pipes and returns output lines. Unlike the heroku client, this also checks the process return code and raises a `Heroku::Commander::Errors::CommandError` if the latter is not zero, which makes this suitable for Rake tasks.
``` ruby
commander = Heroku::Commander.new({ :app => "heroku-commander" })
commander.run "uname -a" # => [ "Linux 2.6.32-348-ec2 #54-Ubuntu SMP x86_64 GNU" ]
```
You can specify the dyno size with `size`.
``` ruby
commander.run "uname -a", { size: "2X" }
```
Heroku Detached Run
-------------------
Executes a command via `heroku run:detached`, spawns a `heroku logs --tail -p pid` for the process started on Heroku, pipes and returns output lines. This also checks the process return code and raises a `Heroku::Commander::Errors::CommandError` if the latter is not zero.
``` ruby
commander = Heroku::Commander.new({ :app => "heroku-commander" })
commander.run("uname -a", { :detached => true }) # => [ "Linux 2.6.32-348-ec2 #54-Ubuntu SMP x86_64 GNU" ]
```
You can examine the output from `heroku logs --tail -p pid` line-by-line.
``` ruby
commander.run("ls -R", { :detached => true }) do |line|
# each line from the output of the command
end
```
You can pass the following options along with `:detached`:
* **size**: dyno size, eg. `2X` for double-dynos.
* **tail_timeout**: number of seconds to wait before terminating `heroku logs --tail`, expecting more output (defaults to 5).
* **tail_retries**: number of times to restart the tail process on error (defaults to 3).
For more information about Heroku one-off dynos see [this documentation](https://devcenter.heroku.com/articles/one-off-dynos).
More Examples
-------------
See [examples](examples) for more.
Contributing
------------
Fork the project. Make your feature addition or bug fix with tests. Send a pull request. Bonus points for topic branches.
Copyright and License
---------------------
MIT License, see [LICENSE](LICENSE.md) for details.
(c) 2013 [Daniel Doubrovkine](http://github.com/dblock), [Frank Macreery](http://github.com/macreery), [Artsy Inc.](http://artsy.net)