rvm-tui 0.0.1 → 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +10 -0
- data/README.md +9 -0
- data/VERSION +1 -1
- data/bin/rvm-tui-setup +29 -22
- data/lib/rvm-tui.rb +61 -25
- metadata +4 -2
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA256:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: eb887902a94db7f5b472c4a2344c4d619dfbfa820a27e64c43e54ac1d22876a8
         | 
| 4 | 
            +
              data.tar.gz: b6d25cc471a84289c45684b35387933c200cb33ad45e2e614a0f321ebd59e07e
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: 528ea9fa16c7dc9eedf1988cae2c2caaf9b3a83ee93f981d630aa24f4b277a276e922a94ea8b57e8ca284239c03b116471db794f2d6f89987f69fd3f47bfd500
         | 
| 7 | 
            +
              data.tar.gz: df555dd0a0c2c12c6e4697d2709db78326d29d271170eb1bcb0612a0c8c1f12a8e59f88cce455356c0b818207d6fd9c46ec81001752733dceaad75dcaf83125e
         | 
    
        data/CHANGELOG.md
    ADDED
    
    
    
        data/README.md
    CHANGED
    
    | @@ -1,4 +1,5 @@ | |
| 1 1 | 
             
            # Ruby enVironment Manager - Text-based User Interface
         | 
| 2 | 
            +
            [](https://badge.fury.io/rb/rvm-tui)
         | 
| 2 3 |  | 
| 3 4 | 
             
            [RVM](https://rvm.io) is the original Ruby enVironment Manager that is used to:
         | 
| 4 5 | 
             
            - Effortlessly install multiple versions of [Ruby](https://www.ruby-lang.org/en/), including [JRuby](https://www.jruby.org/)
         | 
| @@ -58,6 +59,14 @@ rvm-tui | |
| 58 59 | 
             
                is fine, but please isolate to its own commit so I can cherry-pick
         | 
| 59 60 | 
             
                around it.
         | 
| 60 61 |  | 
| 62 | 
            +
            ## TODO
         | 
| 63 | 
            +
             | 
| 64 | 
            +
            [TODO.md](TODO.md)
         | 
| 65 | 
            +
             | 
| 66 | 
            +
            ## Change Log
         | 
| 67 | 
            +
             | 
| 68 | 
            +
            [CHANGELOG.md](CHANGELOG.md)
         | 
| 69 | 
            +
             | 
| 61 70 | 
             
            ## License
         | 
| 62 71 |  | 
| 63 72 | 
             
            [Apache License, Version 2.0](https://www.apache.org/licenses/LICENSE-2.0)
         | 
    
        data/VERSION
    CHANGED
    
    | @@ -1 +1 @@ | |
| 1 | 
            -
            0.0. | 
| 1 | 
            +
            0.0.2
         | 
    
        data/bin/rvm-tui-setup
    CHANGED
    
    | @@ -1,6 +1,7 @@ | |
| 1 1 | 
             
            #!/usr/bin/env ruby
         | 
| 2 2 |  | 
| 3 | 
            -
             | 
| 3 | 
            +
            version = File.read(File.expand_path('../../VERSION', __FILE__))
         | 
| 4 | 
            +
            puts "== rvm-tui-setup version #{version.strip} =="
         | 
| 4 5 |  | 
| 5 6 | 
             
            ruby = `which ruby`
         | 
| 6 7 | 
             
            ruby = `which jruby` if ruby.to_s.strip.empty?
         | 
| @@ -8,24 +9,30 @@ ruby = ruby.strip | |
| 8 9 | 
             
            rvm = `rvm current`.strip
         | 
| 9 10 | 
             
            command = "rvm #{rvm} do #{ruby} #{File.expand_path('../../lib/rvm-tui.rb', __FILE__)}"
         | 
| 10 11 |  | 
| 11 | 
            -
            rvm_tui_script =  | 
| 12 | 
            -
            function rvm-tui()
         | 
| 13 | 
            -
            {
         | 
| 14 | 
            -
             | 
| 15 | 
            -
             | 
| 16 | 
            -
             | 
| 17 | 
            -
             | 
| 18 | 
            -
             | 
| 19 | 
            -
             | 
| 20 | 
            -
             | 
| 21 | 
            -
             | 
| 22 | 
            -
             | 
| 23 | 
            -
             | 
| 24 | 
            -
             | 
| 25 | 
            -
             | 
| 26 | 
            -
             | 
| 27 | 
            -
             | 
| 28 | 
            -
            }
         | 
| 12 | 
            +
            rvm_tui_script = <<~SHELL_SCRIPT
         | 
| 13 | 
            +
              function rvm-tui()
         | 
| 14 | 
            +
              {
         | 
| 15 | 
            +
                # Load RVM into a shell session *as a function*
         | 
| 16 | 
            +
                if [[ -s "$HOME/.rvm/scripts/rvm" ]] ; then
         | 
| 17 | 
            +
                  # First try to load from a user install
         | 
| 18 | 
            +
                  source "$HOME/.rvm/scripts/rvm"
         | 
| 19 | 
            +
                elif [[ -s "/usr/local/rvm/scripts/rvm" ]] ; then
         | 
| 20 | 
            +
                  # Then try to load from a root install
         | 
| 21 | 
            +
                  source "/usr/local/rvm/scripts/rvm"
         | 
| 22 | 
            +
                else
         | 
| 23 | 
            +
                  printf "ERROR: An RVM installation was not found.\\n"
         | 
| 24 | 
            +
                fi
         | 
| 25 | 
            +
                
         | 
| 26 | 
            +
                IFS='@'
         | 
| 27 | 
            +
                read -a rvm_current <<< "$(rvm current)"
         | 
| 28 | 
            +
                current_ruby="${rvm_current[0]}"
         | 
| 29 | 
            +
                current_gemset="${rvm_current[1]}"
         | 
| 30 | 
            +
                #{command} $current_ruby $current_gemset
         | 
| 31 | 
            +
                if [ -f "$HOME/.rvm_command" ]; then
         | 
| 32 | 
            +
                  source $HOME/.rvm_command
         | 
| 33 | 
            +
                  rm $HOME/.rvm_command
         | 
| 34 | 
            +
                fi  
         | 
| 35 | 
            +
              }
         | 
| 29 36 | 
             
            SHELL_SCRIPT
         | 
| 30 37 |  | 
| 31 38 | 
             
            require 'fileutils'
         | 
| @@ -47,7 +54,7 @@ unless bash_profile.split("\n").detect {|line| line.include?(rvm_tui_source_stat | |
| 47 54 | 
             
              File.write(bash_profile_file, "#{bash_profile}\n#{rvm_tui_source_statement}")
         | 
| 48 55 | 
             
            end
         | 
| 49 56 | 
             
            puts <<~OUTPUT
         | 
| 50 | 
            -
             | 
| 51 | 
            -
            To use `rvm-tui`, make sure to first run:
         | 
| 52 | 
            -
            source  | 
| 57 | 
            +
              ~/#{bash_profile_file_name} has been modified to source the `rvm-tui` function from ~/.rvm_tui_source
         | 
| 58 | 
            +
              To use `rvm-tui`, make sure to first run:
         | 
| 59 | 
            +
              source ~/.rvm_tui_source 
         | 
| 53 60 | 
             
            OUTPUT
         | 
    
        data/lib/rvm-tui.rb
    CHANGED
    
    | @@ -1,27 +1,63 @@ | |
| 1 1 | 
             
            $LOAD_PATH.unshift(File.expand_path('..', __FILE__))
         | 
| 2 2 |  | 
| 3 | 
            -
            puts "rvm-tui version #{File.read(File.expand_path('../../VERSION', __FILE__))}"
         | 
| 4 | 
            -
             | 
| 5 | 
            -
             | 
| 6 | 
            -
             | 
| 7 | 
            -
             | 
| 8 | 
            -
             | 
| 9 | 
            -
             | 
| 10 | 
            -
             | 
| 11 | 
            -
             | 
| 12 | 
            -
             | 
| 13 | 
            -
             | 
| 14 | 
            -
             | 
| 15 | 
            -
             | 
| 16 | 
            -
             | 
| 17 | 
            -
             | 
| 18 | 
            -
             | 
| 19 | 
            -
             | 
| 20 | 
            -
             | 
| 21 | 
            -
             | 
| 22 | 
            -
             | 
| 23 | 
            -
             | 
| 24 | 
            -
             | 
| 25 | 
            -
             | 
| 26 | 
            -
             | 
| 27 | 
            -
             | 
| 3 | 
            +
            puts "== rvm-tui version #{File.read(File.expand_path('../../VERSION', __FILE__)).strip} =="
         | 
| 4 | 
            +
             | 
| 5 | 
            +
            require 'tty-prompt'
         | 
| 6 | 
            +
             | 
| 7 | 
            +
            CURRENT_RVM_RUBY = ARGV[0]
         | 
| 8 | 
            +
            CURRENT_RVM_GEMSET = ARGV[1] || 'default'
         | 
| 9 | 
            +
            current_rvm = CURRENT_RVM_RUBY
         | 
| 10 | 
            +
            current_rvm += "@#{CURRENT_RVM_GEMSET}" unless CURRENT_RVM_GEMSET.nil?
         | 
| 11 | 
            +
            CURRENT_RVM = current_rvm
         | 
| 12 | 
            +
            puts "Current: #{CURRENT_RVM}"
         | 
| 13 | 
            +
             | 
| 14 | 
            +
            RVM_COMMAND_PREFIX = <<~SHELL_SCRIPT
         | 
| 15 | 
            +
              # Load RVM into a shell session *as a function*
         | 
| 16 | 
            +
              if [[ -s "$HOME/.rvm/scripts/rvm" ]] ; then
         | 
| 17 | 
            +
                # First try to load from a user install
         | 
| 18 | 
            +
                source "$HOME/.rvm/scripts/rvm"
         | 
| 19 | 
            +
              elif [[ -s "/usr/local/rvm/scripts/rvm" ]] ; then
         | 
| 20 | 
            +
                # Then try to load from a root install
         | 
| 21 | 
            +
                source "/usr/local/rvm/scripts/rvm"
         | 
| 22 | 
            +
              else
         | 
| 23 | 
            +
                printf "ERROR: An RVM installation was not found.\\n"
         | 
| 24 | 
            +
              fi  
         | 
| 25 | 
            +
              rvm use #{CURRENT_RVM_RUBY}@#{CURRENT_RVM_GEMSET}
         | 
| 26 | 
            +
            SHELL_SCRIPT
         | 
| 27 | 
            +
             | 
| 28 | 
            +
            def rvm_command(command)
         | 
| 29 | 
            +
              `bash -c '#{RVM_COMMAND_PREFIX}\n#{command}'`
         | 
| 30 | 
            +
            end
         | 
| 31 | 
            +
             | 
| 32 | 
            +
            begin
         | 
| 33 | 
            +
              prompt = TTY::Prompt.new  
         | 
| 34 | 
            +
              rvm_list_lines = rvm_command('rvm list').split("\n")
         | 
| 35 | 
            +
              rvm_list_lines.shift if rvm_list_lines.first.start_with?('Using ')
         | 
| 36 | 
            +
              rubies = rvm_list_lines[0...-4] # TODO print excluded lines as an appendix
         | 
| 37 | 
            +
              rubies_help = rvm_list_lines[-4..-1].join("\n") + "\n"
         | 
| 38 | 
            +
              ruby = prompt.select("Choose a Ruby: ", rubies, cycle: true, per_page: 40, filter: true, help: "\n#{rubies_help}", show_help: :always)
         | 
| 39 | 
            +
              
         | 
| 40 | 
            +
              ruby = ruby.split.detect {|text| text.include?('ruby')}
         | 
| 41 | 
            +
              rvm_gemset_list = nil
         | 
| 42 | 
            +
              if CURRENT_RVM_RUBY == ruby
         | 
| 43 | 
            +
                rvm_gemset_list = rvm_command('rvm gemset list')
         | 
| 44 | 
            +
              else
         | 
| 45 | 
            +
                rvm_gemset_list = rvm_command("rvm #{ruby} do rvm gemset list")
         | 
| 46 | 
            +
              end
         | 
| 47 | 
            +
              rvm_gemset_list_lines = rvm_gemset_list.split("\n")
         | 
| 48 | 
            +
              rvm_gemset_list_lines.shift if rvm_gemset_list_lines.first.start_with?('Using ')
         | 
| 49 | 
            +
              gemsets = rvm_gemset_list_lines[2..-1]
         | 
| 50 | 
            +
              gemsets_help = rvm_gemset_list_lines[0..1].join("\n") + "\n"
         | 
| 51 | 
            +
              gemset = prompt.select("Choose a Gemset: ", gemsets, cycle: true, per_page: 40, filter: true, help: gemsets_help, show_help: :always)
         | 
| 52 | 
            +
              
         | 
| 53 | 
            +
              gemset = gemset.sub('=>', '').sub('(default)', 'default').strip
         | 
| 54 | 
            +
              
         | 
| 55 | 
            +
              command = "rvm --nice use #{ruby}@#{gemset}"
         | 
| 56 | 
            +
              
         | 
| 57 | 
            +
              home_dir = `echo ~`.strip
         | 
| 58 | 
            +
              File.write("#{home_dir}/.rvm_command", command)
         | 
| 59 | 
            +
            rescue TTY::Reader::InputInterrupt => e
         | 
| 60 | 
            +
              # No Op
         | 
| 61 | 
            +
              puts # a new line is needed
         | 
| 62 | 
            +
              puts "Staying at current (abort detected): #{CURRENT_RVM}"
         | 
| 63 | 
            +
            end
         | 
    
        metadata
    CHANGED
    
    | @@ -1,14 +1,14 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: rvm-tui
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version: 0.0. | 
| 4 | 
            +
              version: 0.0.2
         | 
| 5 5 | 
             
            platform: ruby
         | 
| 6 6 | 
             
            authors:
         | 
| 7 7 | 
             
            - andy_maleh
         | 
| 8 8 | 
             
            autorequire:
         | 
| 9 9 | 
             
            bindir: bin
         | 
| 10 10 | 
             
            cert_chain: []
         | 
| 11 | 
            -
            date: 2020-09- | 
| 11 | 
            +
            date: 2020-09-05 00:00:00.000000000 Z
         | 
| 12 12 | 
             
            dependencies:
         | 
| 13 13 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 14 14 | 
             
              name: tty-prompt
         | 
| @@ -114,9 +114,11 @@ executables: | |
| 114 114 | 
             
            - rvm-tui-setup
         | 
| 115 115 | 
             
            extensions: []
         | 
| 116 116 | 
             
            extra_rdoc_files:
         | 
| 117 | 
            +
            - CHANGELOG.md
         | 
| 117 118 | 
             
            - LICENSE.txt
         | 
| 118 119 | 
             
            - README.md
         | 
| 119 120 | 
             
            files:
         | 
| 121 | 
            +
            - CHANGELOG.md
         | 
| 120 122 | 
             
            - LICENSE.txt
         | 
| 121 123 | 
             
            - README.md
         | 
| 122 124 | 
             
            - VERSION
         |