npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

gumba

v1.0.1

Published

Gumba provides modern language features to your everyday shell scripting

Downloads

9

Readme

Gumba

Build Status

Gumba likes to live between your shell pipes. When writing scripts is too much hassle and writing shell function is too much magic you use Gumba.

Installation

Make sure you have Node.js & npm installed. You can install Gumba using npm command:

npm install -g coffee-script

Also if you are going to using to use it frequently and I hope so, add a shorthand to your shell init file:

alias u='gumba'

Usage

With gumba you can use coffescript language powered by underscore & underscore.string inside your command line. Think of Gumba as a kind of awk or sed.

Look at following examples:

First Example:

before Gumba:

echo '  IdentityFile "file_path"' | cut -d ' ' -f4 | tr -d '"'

after Gumba:

echo '  IdentityFile "file_path"' | u 'clean().words().last().trim("\"")'

Both return file_path. So basically cut -d ' ' -f4 | tr -d becomes u 'clean().words().last().trim("\"")'. Although first is not so bad, the second still feels cleaner and easier to remember. This is a real world example, after which I decided to make Gumba.

Second Example — Sed replacement:

Another real world example comes from the question on StackOverflow — (How to trim whitespace?)[http://stackoverflow.com/questions/369758/how-to-trim-whitespace-from-bash-variable]

before Gumba:

echo ' test test test ' | sed -e 's/^ *//g' -e 's/ *$//g'

Seriously?

after Gumba:

echo ' test test test ' | u 'trim()'

More Examples:

Gumba uses just coffeescript so you can make regex replaces easily using standard javascript functions:

echo "['bulbasaur' 'chermander' 'pikachu'];" |
u "trim('[];')\                                             # -> 'bulbasaur' 'chermander' 'pikachu'
.replace(/'.*?'/g, (match) -> match.trim('\'').humanize())\ # -> Bulbasaur Chermander Pikachu
.words().toSentence()"                                      # -> Bulbasaur, Chermander and Pikachu

Gumba provides take function which provides you ability to use javascript in more flexible way using line object as it's argument:

echo hi | u 'take (line) -> "#{line.toUpperCase()}!"' # -> HI!

Supported methods

Gumba extends standard javascript object prototype with underscore & underscore.string functions. For example on String object you can use either underscore.string, underscore object or default javascript methods:

"Hello World"
  .toUpperCase() # standard javascript
  .capitalize()  # underscore.string
  .isString()    # underscore

To have a look on underscore methods reference go here, for underscore.string — here

Function evaluation

Every time you pipe to gumba it evaluates function passed as argument passed to to each line of piped stream:

echo "Hello World" | u 'toUpperCase().take (line) -> "#{line}!"'

converts to javascript

"HelloWorld"
  .toUpperCase()
  .take(function(line){
    return line + "!";
  })

Contribute

Fork, Pull, Post Issues.

I would love to get any help in project cultivation.

:sunflower: