Verified Commit fd9233c2 authored by Hermann Mayer's avatar Hermann Mayer
Browse files

BashRC: Separated development/ruby helpers and added Cocoapods helpers, added more Git shortcuts.

parent 75ca083a
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -24,6 +24,7 @@ bashrcComponent['helper/development/docker']=1
bashrcComponent['helper/development/aws']=1
bashrcComponent['helper/development/git']=1
bashrcComponent['helper/development/svn']=0
bashrcComponent['helper/development/ruby']=1
bashrcComponent['helper/archives']=1
bashrcComponent['helper/features']=1
bashrcComponent['helper/distro/slackware']=0
+2 −0
Original line number Diff line number Diff line
@@ -52,6 +52,8 @@
    l = log
    d = diff
    weg = push -u
    ab = "!sh -c 'git a; git ci -am \"one of many\"; git weg'"
    steil = "!sh -c 'git a; git ci -am \"one of many [ci skip]\"; git weg'"

[merge]
    tool = meld
+0 −41
Original line number Diff line number Diff line
@@ -26,44 +26,3 @@ function generateMAC()
    echo $(dd bs=1 count=6 if=/dev/random 2>/dev/null \
        | hexdump -v -e '/1 "-%02X"' | sed 's/^-//g')
}

function gemlock()
{
    grep -P "^\s*${@} \(\d" Gemfile.lock \
        | cut -d '(' -f2 \
        | grep -oP '[^)]+'
}

function gemdesc()
{
    curl -s "https://rubygems.org/gems/${@}" \
        | pup -p '.gem__intro p text{}' \
        | tr "\n" ' ' \
        | sed 's/  */ /g' \
        | fold -s -w78 - \
        | sed 's/^/# /g' \
        | sed 's/[ \t]*$//'
    echo
}

function gemspec()
{
    curl -s "https://rubygems.org/gems/${@}" \
        | pup -p '#gemfile_text attr{value}'
}

function gemline()
{
    SPEC="gem '${1}', '~> ${2}'"
    if [ -z "${2}" ]; then
        SPEC="$(gemspec ${@})"
    fi

    gemdesc ${1}
    echo ${SPEC}
}

function gemlockline()
{
    gemline "${@}" $(gemlock "${@}")
}
+100 −0
Original line number Diff line number Diff line
#!/bin/bash
#
# @author Hermann Mayer <hermann.mayer92@gmail.com>
# @name development.sh

# +-------------------------------------------------
# | Development/Ruby Helper
# +-------------------------------------------------

function gemlock()
{
    grep -P "^\s*${@} \(\d" Gemfile.lock \
        | cut -d '(' -f2 \
        | grep -oP '[^)]+'
}

function gemdesc()
{
    curl -s "https://rubygems.org/gems/${@}" \
        | pup -p '.gem__intro p text{}' \
        | tr "\n" ' ' \
        | sed 's/  */ /g' \
        | fold -s -w78 - \
        | sed 's/^/# /g' \
        | sed 's/[ \t]*$//'
    echo
}

function gemspec()
{
    curl -s "https://rubygems.org/gems/${@}" \
        | pup -p '#gemfile_text attr{value}'
}

function gemline()
{
    SPEC="gem '${1}', '~> ${2}'"
    if [ -z "${2}" ]; then
        SPEC="$(gemspec ${@})"
    fi

    gemdesc ${1}
    echo ${SPEC}
}

function gemlockline()
{
    gemline "${@}" $(gemlock "${@}")
}

function podlock()
{
    (
        grep -F " ${@}" Podfile.lock;
        grep -F "\"${@}" Podfile.lock;
    ) \
        | grep -P "\(\d" \
        | cut -d '(' -f2 \
        | grep -oP '[^):"]+'
}

function poddesc()
{
    SPEC_URL=$(curl -s "https://cocoapods.org/pods/${@}" \
        | pup -p '.links a:contains("See Podspec") attr{href}')
    RAW_URL=$(curl -s "${SPEC_URL}" \
        | pup -p '#raw-url attr{href}' \
        | sed 's/^/https:\/\/github.com/g')
    curl -sL "${RAW_URL}" \
        | jq -r '.description // .summary' \
        | tr "\n" ' ' \
        | sed 's/  */ /g' \
        | fold -s -w78 - \
        | sed 's/^/# /g' \
        | sed 's/[ \t]*$//'
    echo
}

function podspec()
{
    curl -s "https://cocoapods.org/pods/${@}" \
        | pup -p '#installation_guide pre:nth-of-type(1) code text{}' \
        | grep -oP 'pod .*'
}

function podline()
{
    SPEC="pod '${1}', '~> ${2}'"
    if [ -z "${2}" ]; then
        SPEC="$(podspec ${@})"
    fi

    poddesc ${1}
    echo ${SPEC}
}

function podlockline()
{
    podline "${@}" $(podlock "${@}")
}