├── .dockerignore ├── functions ├── fry-version.fish ├── fry-ls.fish ├── fry-installers.fish ├── fry-installer-ruby-build.fish ├── fry-env.fish ├── __fry_reset.fish ├── fry-rubies.fish ├── __fry_find_version_file.fish ├── fry-find.fish ├── fry.fish ├── fry-install.fish ├── fry-installer-ruby-install.fish ├── fry-help.fish ├── fry-current.fish ├── fry-use.fish └── fry-config.fish ├── test ├── runner.fish ├── test_fry-help.fish ├── test_fry-version.fish ├── test_fry-ls.fish ├── test_fry-rubies.fish ├── test_fry-env.fish ├── helper.fish ├── test_fry-find.fish ├── test_fry.fish ├── test_fry-install.fish ├── test_fry-current.fish ├── test_fry-use.fish └── test_fry-config.fish ├── .projections.json ├── .travis.yml ├── pkg └── fry-0.1.6.tar.gz.asc ├── Dockerfile ├── LICENSE.txt ├── completions └── fry.fish ├── conf.d └── fry.fish ├── CHANGELOG.md ├── man └── man1 │ └── fry.1 ├── Makefile └── README.md /.dockerignore: -------------------------------------------------------------------------------- 1 | .git 2 | .vagrant 3 | Vagrantfile 4 | Dockerfile 5 | pkg 6 | script 7 | -------------------------------------------------------------------------------- /functions/fry-version.fish: -------------------------------------------------------------------------------- 1 | function fry-version --description 'Display the current version of fry' 2 | echo '0.1.6' 3 | end 4 | -------------------------------------------------------------------------------- /test/runner.fish: -------------------------------------------------------------------------------- 1 | set -g tank_runner 1 2 | source (dirname (status -f))/helper.fish 3 | tank_run (dirname (status -f))/test_*.fish 4 | -------------------------------------------------------------------------------- /functions/fry-ls.fish: -------------------------------------------------------------------------------- 1 | function fry-ls --description 'List available rubies' 2 | echo 'system' 3 | command ls -1 $fry_rubies | cat 4 | end 5 | -------------------------------------------------------------------------------- /functions/fry-installers.fish: -------------------------------------------------------------------------------- 1 | function fry-installers --description 'List available installers' 2 | functions | grep fry-installer- | sed 's/fry-installer-//' 3 | end 4 | -------------------------------------------------------------------------------- /test/test_fry-help.fish: -------------------------------------------------------------------------------- 1 | function suite_fry-help 2 | function test_exit_status 3 | assert (fry-help) 4 | end 5 | 6 | function test_output 7 | refute_empty (fry-help) 8 | end 9 | end 10 | 11 | source (dirname (status -f))/helper.fish 12 | -------------------------------------------------------------------------------- /test/test_fry-version.fish: -------------------------------------------------------------------------------- 1 | function suite_fry-version 2 | function test_exit_status 3 | assert (fry-version) 4 | end 5 | 6 | function test_output 7 | refute_empty (fry-version) 8 | end 9 | end 10 | 11 | source (dirname (status -f))/helper.fish 12 | -------------------------------------------------------------------------------- /functions/fry-installer-ruby-build.fish: -------------------------------------------------------------------------------- 1 | function fry-installer-ruby-build --description 'Installer for ruby-build' 2 | function __fry_install_ruby 3 | ruby-build $argv $fry_rubies/$argv 4 | end 5 | 6 | function __fry_install_rubies 7 | ruby-build --definitions 8 | end 9 | end 10 | -------------------------------------------------------------------------------- /functions/fry-env.fish: -------------------------------------------------------------------------------- 1 | function fry-env --description 'POSIX compatible environment output' 2 | set -l ruby_path 3 | 4 | if set -q argv[1] 5 | set ruby_path $fry_rubies/(fry-find $argv[1])/bin 6 | else 7 | set ruby_path '$(fish -c \'fry current --path\')' 8 | end 9 | 10 | echo 'export PATH="'$ruby_path':$PATH"' 11 | end 12 | -------------------------------------------------------------------------------- /.projections.json: -------------------------------------------------------------------------------- 1 | { 2 | "share/fry/functions/*.fish": { 3 | "alternate": "test/test_{}.fish" 4 | }, 5 | "test/test_*.fish": { 6 | "alternate": "share/fry/functions/{}.fish", 7 | "dispatch": "fish %" 8 | }, 9 | "*.md": { 10 | "type": "doc" 11 | }, 12 | "*": { 13 | "make": "make test", 14 | "start": "docker run --rm -it fry" 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /functions/__fry_reset.fish: -------------------------------------------------------------------------------- 1 | function __fry_reset --description 'Remove rubies from path' 2 | set -l new_path 3 | 4 | for i in $fish_user_paths 5 | switch $i 6 | case "$fry_rubies*" 7 | continue 8 | case '*' 9 | set new_path $new_path $i 10 | end 11 | end 12 | 13 | set fish_user_paths $new_path 14 | end 15 | -------------------------------------------------------------------------------- /functions/fry-rubies.fish: -------------------------------------------------------------------------------- 1 | function fry-rubies --description 'List available rubies with the current one highlighted' 2 | set -l current_ruby (fry-current) 3 | 4 | for ruby in (fry-ls) 5 | if test "$ruby" = "$current_ruby" 6 | echo -n '* ' 7 | set_color green 8 | else 9 | echo -n ' ' 10 | end 11 | 12 | echo $ruby(set_color normal) 13 | end 14 | end 15 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | sudo: required 2 | 3 | services: 4 | - docker 5 | 6 | env: 7 | - FISH_REPO=nightly:/master 8 | - FISH_REPO=release:/2 9 | 10 | before_install: 11 | - sudo apt-get update 12 | - sudo apt-get install -o Dpkg::Options::="--force-confold" -y --force-yes docker-engine 13 | 14 | install: 15 | - docker build --build-arg=fish_repo="$FISH_REPO" -t fry . 16 | 17 | script: 18 | - docker run --rm -it fry make test 19 | -------------------------------------------------------------------------------- /test/test_fry-ls.fish: -------------------------------------------------------------------------------- 1 | function suite_fry-ls 2 | function setup 3 | stub_var fry_rubies (stub_dir) 4 | mkdir -p $fry_rubies/ruby-2.0/bin 5 | end 6 | 7 | function test_exit_status 8 | assert (fry-ls) 9 | end 10 | 11 | function test_output 12 | assert_includes system (fry-ls) 13 | assert_includes ruby-2.0 (fry-ls) 14 | end 15 | end 16 | 17 | source (dirname (status -f))/helper.fish 18 | -------------------------------------------------------------------------------- /functions/__fry_find_version_file.fish: -------------------------------------------------------------------------------- 1 | function __fry_find_version_file --description 'Find .ruby-version file' 2 | set -l file .ruby-version 3 | set -l dir $PWD 4 | 5 | while test $dir != '/' 6 | if test -f $dir/$file 7 | echo -n $dir/$file 8 | return 0 9 | end 10 | 11 | set dir (dirname $dir) 12 | end 13 | 14 | if test -f $HOME/$file 15 | echo -n $HOME/$file 16 | return 0 17 | end 18 | 19 | return 1 20 | end 21 | -------------------------------------------------------------------------------- /functions/fry-find.fish: -------------------------------------------------------------------------------- 1 | function fry-find --description 'Find ruby by name' 2 | set -l name $argv[1] 3 | set -l rubyless_name (echo $name | sed 's/^ruby-//') 4 | 5 | if test -d "$fry_rubies/$name" 6 | echo $name 7 | return 8 | end 9 | 10 | for i in (fry-ls | sort -rn) 11 | switch $i 12 | case "$name*" "$rubyless_name*" "ruby-$name*" 13 | echo $i 14 | return 15 | end 16 | end 17 | 18 | return 1 19 | end 20 | -------------------------------------------------------------------------------- /pkg/fry-0.1.6.tar.gz.asc: -------------------------------------------------------------------------------- 1 | -----BEGIN PGP SIGNATURE----- 2 | 3 | iQEcBAABCgAGBQJXEKuqAAoJEDUXX7MnkanddP0IAJIhinpQ8BgryWgOlWDJhWKJ 4 | XGbjkJpKG/0IHRo/ibT8yN6n5O8HJtNjLYFVOk3YcRN3/nP6wAqdGVv6clSEwaak 5 | A+Tx0ngYKjYBTXZXeQXIpKGfWdUwDA6YCwSRzZz+E1gI/fionsKyH2Z6ISQHJays 6 | pbE584WWMlmSaGQYdvYAg6UKVUjff1LQ8RwVCSaCBXuM/6NUgyXI/jnMpSdrsWyK 7 | bs/lKIOVL9PGTgZxtRkMJyfSVpfq+FbyHD+NDJcrZyIkuFagDRQplp2ts/BeKXMo 8 | 4cfzzU2hx5vQhB6n9jKw86nTYP+1goEl2VTpC6+7IxKueaIsmeSsBbZG7K/qQ/w= 9 | =A9SU 10 | -----END PGP SIGNATURE----- 11 | -------------------------------------------------------------------------------- /functions/fry.fish: -------------------------------------------------------------------------------- 1 | function fry --description 'Fishy ruby switcher' 2 | if test (count $argv) -eq 0 3 | set argv rubies 4 | end 5 | 6 | switch $argv[1] 7 | case 'help' '-h' '--help' 8 | fry-help 9 | return 10 | end 11 | 12 | set -l command $argv[1] 13 | set -e argv[1] 14 | set -l func_name "fry-$command" 15 | set -l return_status 0 16 | 17 | if functions -q $func_name 18 | eval $func_name $argv 19 | set return_status $status 20 | else 21 | if test (fry-find $command) 22 | fry-use $command 23 | else 24 | fry-help 25 | end 26 | end 27 | 28 | return $return_status 29 | end 30 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM debian:jessie 2 | MAINTAINER Terje Larsen 3 | 4 | ARG fish_repo=nightly:/master 5 | ARG tank_version=master 6 | 7 | WORKDIR /tmp 8 | RUN echo "deb http://download.opensuse.org/repositories/shells:/fish:/$fish_repo/Debian_8.0/ /" >> /etc/apt/sources.list.d/fish.list \ 9 | && apt-get update && apt-get install -y --force-yes --no-install-recommends \ 10 | fish \ 11 | ca-certificates \ 12 | curl \ 13 | make \ 14 | ruby-build \ 15 | && curl -Lso source.tar.gz https://github.com/terlar/fish-tank/archive/$tank_version.tar.gz \ 16 | && tar -zxf source.tar.gz \ 17 | && cd fish-tank-$tank_version && make install \ 18 | && rm -rf /var/lib/apt/lists/* 19 | 20 | COPY . /usr/src 21 | WORKDIR /usr/src 22 | RUN make install 23 | 24 | CMD [ "fish" ] 25 | -------------------------------------------------------------------------------- /functions/fry-install.fish: -------------------------------------------------------------------------------- 1 | function fry-install --description 'Install rubies (requires an installer)' 2 | if not functions -q __fry_install_ruby 3 | echo 'fatal: This feature requires an installer' 4 | return 1 5 | end 6 | 7 | if test (count $argv) -eq 0 8 | echo 'usage: fry install ' 9 | echo 10 | echo 'Available rubies:' 11 | __fry_install_rubies 12 | return 13 | end 14 | 15 | set -l output (__fry_install_ruby $argv[1]) 16 | 17 | if test $status -eq 0 18 | echo $output 19 | return 0 20 | else 21 | echo 'usage: fry install ' 22 | echo 23 | echo 'Available rubies:' 24 | __fry_install_rubies 25 | return 1 26 | end 27 | end 28 | -------------------------------------------------------------------------------- /test/test_fry-rubies.fish: -------------------------------------------------------------------------------- 1 | function suite_fry-rubies 2 | function setup 3 | stub_var fry_rubies (stub_dir) 4 | mkdir -p $fry_rubies/ruby-1.8/bin 5 | mkdir -p $fry_rubies/ruby-1.9/bin 6 | mkdir -p $fry_rubies/ruby-2.0/bin 7 | stub_var fish_user_paths $fry_rubies/ruby-1.9/bin 8 | end 9 | 10 | function test_exit_status 11 | assert (fry-rubies) 12 | end 13 | 14 | function test_output 15 | set -l normal (set_color normal) 16 | set -l green (set_color green) 17 | 18 | assert_includes ' ruby-1.8'$normal (fry-rubies) 19 | assert_includes '* '$green'ruby-1.9'$normal (fry-rubies) 20 | assert_includes ' ruby-2.0'$normal (fry-rubies) 21 | end 22 | end 23 | 24 | source (dirname (status -f))/helper.fish 25 | -------------------------------------------------------------------------------- /functions/fry-installer-ruby-install.fish: -------------------------------------------------------------------------------- 1 | function fry-installer-ruby-install --description 'Installer for ruby-install' 2 | function __fry_install_ruby 3 | echo $argv | tr - ' ' | read -l implementation ver 4 | ruby-install $implementation $ver -r $fry_rubies 5 | end 6 | 7 | function __fry_install_rubies 8 | set -l implementation 9 | 10 | for line in (ruby-install | grep ' ') 11 | switch $line 12 | case ' *:' 13 | set implementation (echo $line | sed 's/[[:space:]]*\([[:alpha:]]*\):/\1/') 14 | 15 | case '*' 16 | set -l ver (echo $line | sed 's/[[:space:]]*\(.*\)$/\1/') 17 | echo $implementation-$ver 18 | end 19 | end 20 | end 21 | end 22 | -------------------------------------------------------------------------------- /test/test_fry-env.fish: -------------------------------------------------------------------------------- 1 | function suite_fry-env 2 | function setup 3 | stub_var fry_rubies (stub_dir) 4 | mkdir -p $fry_rubies/ruby-1.9/bin 5 | mkdir -p $fry_rubies/ruby-2.0/bin 6 | stub_var fish_user_paths $fry_rubies/ruby-1.9/bin 7 | end 8 | 9 | function test_exit_status 10 | assert (fry-env) 11 | end 12 | 13 | function test_returns_posix_compatible_path 14 | set expected 'export PATH="$(fish -c \'fry current --path\'):$PATH"' 15 | assert_equal $expected (fry-env) 16 | end 17 | 18 | function test_returns_posix_compatible_path_for_specific_ruby 19 | set expected 'export PATH="'$fry_rubies/ruby-2.0/bin':$PATH"' 20 | assert_equal $expected (fry-env ruby-2.0) 21 | end 22 | end 23 | 24 | source (dirname (status -f))/helper.fish 25 | -------------------------------------------------------------------------------- /functions/fry-help.fish: -------------------------------------------------------------------------------- 1 | function fry-help --description 'Display help information' 2 | echo 'usage: fry [|] []' 3 | echo 4 | echo 'Commands:' 5 | echo ' ls List available rubies' 6 | echo ' rubies List available rubies with the current one highlighted' 7 | echo ' find Fuzzy find available ruby' 8 | echo ' current [