All Projects → fetlife → Scallop

fetlife / Scallop

Licence: mit
Ergonomic shell wrapper for Ruby.

Programming Languages

ruby
36898 projects - #4 most used programming language
shell
77523 projects

Labels

Projects that are alternatives of or similar to Scallop

Rhymer
与えられた文章の中から韻を踏んでいるフレーズの組み合わせを見つけ出すライブラリです。
Stars: ✭ 99 (-34%)
Mutual labels:  gem
Counter culture
Turbo-charged counter caches for your Rails app.
Stars: ✭ 1,397 (+831.33%)
Mutual labels:  gem
Foot traffic
Pure Ruby DSL for Chrome scripting based on Ferrum. No Selenium required. Works from any script. Simulate web app usage scenarios in production or locally.
Stars: ✭ 123 (-18%)
Mutual labels:  gem
Hanuman
A responsive, lightning-fast Jekyll theme built using AMP (Accelerated Mobile Pages) to speed up your blogs and websites.
Stars: ✭ 100 (-33.33%)
Mutual labels:  gem
Graphql devise
GraphQL interface on top devise_token_auth
Stars: ✭ 100 (-33.33%)
Mutual labels:  gem
Kovid
A CLI to fetch and compare the 2019 coronavirus pandemic statistics. It also fetches historical data and attempts to draw histograms of it to visualise the rate of infections.
Stars: ✭ 107 (-28.67%)
Mutual labels:  gem
Graf
A simple git log analyzer gem
Stars: ✭ 94 (-37.33%)
Mutual labels:  gem
Unityraytracinggem
💎 Ray tracing gem shader for Unity
Stars: ✭ 140 (-6.67%)
Mutual labels:  gem
Premailer Rails
CSS styled emails without the hassle.
Stars: ✭ 1,382 (+821.33%)
Mutual labels:  gem
Rubicure
All about Japanese battle heroine "Pretty Cure (Precure)"
Stars: ✭ 119 (-20.67%)
Mutual labels:  gem
Instagram api gem
A Ruby wrapper for the Instagram API
Stars: ✭ 100 (-33.33%)
Mutual labels:  gem
Tty Exit
Terminal exit codes.
Stars: ✭ 101 (-32.67%)
Mutual labels:  gem
Searchobjectgraphql
GraphQL plugin for SearchObject gem
Stars: ✭ 118 (-21.33%)
Mutual labels:  gem
Lol dba
lol_dba is a small package of rake tasks that scan your application models and displays a list of columns that probably should be indexed. Also, it can generate .sql migration scripts.
Stars: ✭ 1,363 (+808.67%)
Mutual labels:  gem
Net Http2
NetHttp2 is an HTTP/2 client for Ruby.
Stars: ✭ 126 (-16%)
Mutual labels:  gem
Pagerduty
📟 A Ruby gem for talking to the Pagerduty Events API
Stars: ✭ 94 (-37.33%)
Mutual labels:  gem
Rubocop Rails config
RuboCop configuration which has the same code style checking as official Ruby on Rails.
Stars: ✭ 106 (-29.33%)
Mutual labels:  gem
Wordmove
Multi-stage command line deploy/mirroring and task runner for Wordpress
Stars: ✭ 1,791 (+1094%)
Mutual labels:  gem
Rails sortable
Easy drag & drop sorting with persisting the arranged order for rails
Stars: ✭ 127 (-15.33%)
Mutual labels:  gem
Dry Logic
Predicate logic with rule composition
Stars: ✭ 118 (-21.33%)
Mutual labels:  gem

Gem Version CircleCI Maintainability Test Coverage

Scallop

Ergonomic shell wrapper.

Features:

  • Easy access to command's output (stdout & stderr)
  • Failure handling
  • Parameterization
  • Measuring execution time
  • Built-in string escaping
  • No dependencies

Installation

Add this line to your application's Gemfile:

gem 'scallop'

And then execute:

$ bundle

Or install it yourself as:

$ gem install scallop

Usage

To run sudo -u chuck grep -R /home/chuck

result = Scallop.sudo(:chuck).cmd(:grep, '-R', '/home/chuck').run

You can then check whether command succeeded

result.success?

See its output

result.stdout
result.stderr
result.output # STDOUT and STDERR combined

You can also access information about command execution time

result.timing.real # Elapsed real time
result.timing.stime # System CPU time
result.timing.utime # User CPU time
result.timing.total # Total time, that is utime + stime + cutime + cstime

Handling failures with exceptions

If you replace run with run!, exception will be raised in case command fails

begin
  Scallop.cmd(some_command).run!
rescue Scallop::Errors::CommandFailed => error
  # you can access result right on the error itself
  error.result.stderr
end

Piping

To run cat /some/file | grep something

command = Scallop.cmd(:cat, '/some/file') | Scallop.cmd(:grep, 'something')
command.run

Parameterization

stored_command = Scallop.cmd(:rm, '-rf', Scallop::Param[:path])

stored_command.set(path: '/foo').run # rm -rf /foo
stored_command.set(path: '/bar').run # rm -rf /bar

You can also check specs for examples.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].