rvm-tui 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0a2efd862751fe44f51587a1f9b9b469c34d9d4be205ce43a6fbfdd86374c5f5
4
- data.tar.gz: 193ac518992be95f86e0f701d202b9bceb0352667dd5187e74307d7b213c9c28
3
+ metadata.gz: eb887902a94db7f5b472c4a2344c4d619dfbfa820a27e64c43e54ac1d22876a8
4
+ data.tar.gz: b6d25cc471a84289c45684b35387933c200cb33ad45e2e614a0f321ebd59e07e
5
5
  SHA512:
6
- metadata.gz: 00d76e19ea4d63b0a84cf06f4948b903ca16d8e2907910b7e94a39dac5699f5b70b8d1a4c6cabc4231486f00fe21a300c9ab52ed42e90bf5cd21b7c867bd0a4e
7
- data.tar.gz: 902a41fcc9649f5f25e117a324abf6e2496b330e26214480e6bd6ff53bb313ab8a93a46a2bf7e35440a158c98f99b325c7c9e6a2051b7926bb34015595b8d1f4
6
+ metadata.gz: 528ea9fa16c7dc9eedf1988cae2c2caaf9b3a83ee93f981d630aa24f4b277a276e922a94ea8b57e8ca284239c03b116471db794f2d6f89987f69fd3f47bfd500
7
+ data.tar.gz: df555dd0a0c2c12c6e4697d2709db78326d29d271170eb1bcb0612a0c8c1f12a8e59f88cce455356c0b818207d6fd9c46ec81001752733dceaad75dcaf83125e
@@ -0,0 +1,10 @@
1
+ # Change Log
2
+
3
+ ## 0.0.2
4
+
5
+ - Safe abort support (use CTRL+C without seeing error messages)
6
+ - Highlight current RVM Gemset (not just the current Ruby)
7
+
8
+ ## 0.0.1
9
+
10
+ - Initial implementation supporting selection of RVM Ruby and Gemset
data/README.md CHANGED
@@ -1,4 +1,5 @@
1
1
  # Ruby enVironment Manager - Text-based User Interface
2
+ [![Gem Version](https://badge.fury.io/rb/rvm-tui.svg)](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
1
+ 0.0.2
@@ -1,6 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- puts "rvm-tui-setup version #{File.read(File.expand_path('../../VERSION', __FILE__))}"
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 = <<-SHELL_SCRIPT
12
- function rvm-tui()
13
- {
14
- # Load RVM into a shell session *as a function*
15
- if [[ -s "$HOME/.rvm/scripts/rvm" ]] ; then
16
- # First try to load from a user install
17
- source "$HOME/.rvm/scripts/rvm"
18
- elif [[ -s "/usr/local/rvm/scripts/rvm" ]] ; then
19
- # Then try to load from a root install
20
- source "/usr/local/rvm/scripts/rvm"
21
- else
22
- printf "ERROR: An RVM installation was not found.\\n"
23
- fi
24
-
25
- #{command}
26
- source $HOME/.rvm-command
27
- rm $HOME/.rvm-command
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
- The `rvm-tui` function has been sourced from ~/#{bash_profile_file_name}
51
- To use `rvm-tui`, make sure to first run:
52
- source ~/#{bash_profile_file_name}
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
@@ -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
- puts
5
-
6
- require "tty-prompt"
7
-
8
- prompt = TTY::Prompt.new
9
-
10
- rvm_list_lines = `rvm list`.split("\n")
11
- rubies = rvm_list_lines[0...-4] # TODO print excluded lines as an appendix
12
- rubies_help = rvm_list_lines[-4..-1].join("\n") + "\n"
13
- ruby = prompt.select("Choose a Ruby version: ", rubies, cycle: true, per_page: 40, filter: true, help: "\n#{rubies_help}", show_help: :always)
14
-
15
- ruby = ruby.split.detect {|text| text.include?('ruby')}
16
- rvm_gem_list_lines = `rvm use #{ruby} do rvm gemset list`.split("\n")
17
- gemsets = rvm_gem_list_lines[2..-1]
18
- gemsets_help = rvm_gem_list_lines[0..1].join("\n") + "\n"
19
- gemset = prompt.select("Choose a gemset: ", gemsets, cycle: true, per_page: 40, filter: true, help: gemsets_help, show_help: :always)
20
-
21
- gemset = gemset.strip
22
-
23
- command = "rvm --nice use #{ruby}"
24
- command += "@#{gemset}" unless gemset.include?('(default)')
25
-
26
- home_dir = `echo ~`.strip
27
- File.write("#{home_dir}/.rvm-command", command)
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.1
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-03 00:00:00.000000000 Z
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