rvm-tui 0.0.4 → 0.0.5

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.
Files changed (6) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +16 -6
  3. data/VERSION +1 -1
  4. data/bin/rvm-tui-setup +41 -23
  5. data/lib/rvm-tui.rb +8 -8
  6. metadata +6 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 41f83c17d25917d5fda5079abc57e5ab1bf63b4764d121eb53c20c304dbeddba
4
- data.tar.gz: 588dd92c2b110152f17c217b9161dbeed3eb83f8bcec21440c4c320b1b103ded
3
+ metadata.gz: 5b603a90ad6f01469d19be7a31552be2a20e09e7f839f7c875b3a2c30e1a4f2a
4
+ data.tar.gz: cb8f8d3e5cef414f059c2a46067206f4de0e524f83beeed5f57c3ebf6aad9c83
5
5
  SHA512:
6
- metadata.gz: f552858af4da1cd3dc98c5b8bbf80f39a857cc22d8ff0baf1368a313c9fb5e6268482224a91094f59f467f3808d33d7da87d3f6b9ab56b50837679377936f7db
7
- data.tar.gz: a4640cbb5ff9cd9a0f7ce96d74c49abcf2c853a83cc31fdce343a59c2646ad9e68351177f12a6174d4ec159c1a657191c7eddbcbabff4bd03ca39941de9e6c51
6
+ metadata.gz: 9f25e594235051e4ef7ad704bf149845e6719ce6331fcb541a09d77aff13ca84e0afee54e3e649cd8c162e71d47bbab6e3ef66b7fc9d9345c11368cf27d32a45
7
+ data.tar.gz: e5cdf77790fd75877e709d39b688ca607ee301ed59f03b632140854aec6226b8e92bef84d9ca89b70cd07da05bb022893aee982e76232c0dd4cf1807da82e59d
data/README.md CHANGED
@@ -21,20 +21,21 @@ Other TUI gems you may be interested in:
21
21
  ## Pre-requisites
22
22
 
23
23
  - [RVM](https://rvm.io)
24
- - Any version of Ruby installed via [RVM](https://rvm.io)
24
+ - Any version of [Ruby](https://www.ruby-lang.org/en/) installed via [RVM](https://rvm.io) (preferably [MRI Ruby](https://www.ruby-lang.org/en/) for a fast startup time)
25
+ - [Bash](https://www.gnu.org/software/bash/) or [Zsh](http://zsh.sourceforge.net/) (Z Shell) (including Sed)
25
26
 
26
27
  ## Setup Instructions
27
28
 
28
- The gem can be installed unto any [Ruby](https://rvm.io/rubies/installing)/[Gemset](https://rvm.io/gemsets/basics) in [RVM](https://rvm.io) and it will be used from there everywhere.
29
+ The gem can be installed unto any [Ruby](https://rvm.io/rubies/installing)/[Gemset](https://rvm.io/gemsets/basics) in [RVM](https://rvm.io) and it will be used from there everywhere.
29
30
 
30
- Since it is independent of any particular [Ruby](https://www.ruby-lang.org/en/) project, it is recommended you install unto the default [gemset](https://rvm.io/gemsets/basics).
31
+ Since it is independent of any particular [Ruby](https://www.ruby-lang.org/en/) project, it is recommended you install unto the default [gemset](https://rvm.io/gemsets/basics) (or optionally into its own gemset if you prefer).
31
32
 
32
33
  Afterwards, run the `rvm-tui-setup` command from the same [RVM](https://rvm.io) [Ruby](https://rvm.io/rubies/installing)/[Gemset](https://rvm.io/gemsets/basics) you installed the gem at to setup the `rvm-tui` function source in `~/.bash_profile` or `~/.bashrc` (whichever is available)
33
34
 
34
- These are the commands you need to run:
35
+ These are the commands you need to run in order to select a Ruby and gemset, install gem, and finally setup gem commands globablly in the shell environment:
35
36
 
36
37
  ```
37
- rvm use @default
38
+ rvm use @default # or a different ruby version/gemset like `rvm use ruby-2.7.2@rvm-tui --create`
38
39
  gem install rvm-tui
39
40
  rvm-tui-setup
40
41
  ```
@@ -44,9 +45,18 @@ rvm-tui-setup
44
45
  Simply run this command:
45
46
 
46
47
  ```
48
+ rvmui
49
+ ```
50
+
51
+ Or one of the aliases:
52
+
53
+ ```
54
+ rvmtui
55
+ rvm-ui
47
56
  rvm-tui
48
57
  ```
49
58
 
59
+
50
60
  ## Contributing to rvm-tui
51
61
 
52
62
  - Make sure you have [RVM](https://rvm.io) installed
@@ -76,7 +86,7 @@ rvm-tui
76
86
 
77
87
  [Apache License, Version 2.0](LICENSE.txt)
78
88
 
79
- Copyright (c) 2020 Andy Maleh
89
+ Copyright (c) 2020-2021 Andy Maleh
80
90
 
81
91
  Licensed under the Apache License, Version 2.0 (the "License");
82
92
  you may not use this file except in compliance with the License.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.4
1
+ 0.0.5
@@ -1,13 +1,13 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- # Copyright (c) 2020 Andy Maleh
4
- #
3
+ # Copyright (c) 2020-2021 Andy Maleh
4
+ #
5
5
  # Licensed under the Apache License, Version 2.0 (the "License");
6
6
  # you may not use this file except in compliance with the License.
7
7
  # You may obtain a copy of the License at
8
- #
8
+ #
9
9
  # http://www.apache.org/licenses/LICENSE-2.0
10
- #
10
+ #
11
11
  # Unless required by applicable law or agreed to in writing, software
12
12
  # distributed under the License is distributed on an "AS IS" BASIS,
13
13
  # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -37,16 +37,21 @@ rvm_tui_script = <<~SHELL_SCRIPT
37
37
  printf "ERROR: An RVM installation was not found.\\n"
38
38
  fi
39
39
 
40
- IFS='@'
41
- read -a rvm_current <<< "$(rvm current)"
42
- current_ruby="${rvm_current[0]}"
43
- current_gemset="${rvm_current[1]}"
40
+ current_rvm="$(rvm current)"
41
+ current_ruby="$(echo $current_rvm | sed -E 's/@.*$//')"
42
+ current_gemset="default"
43
+ if [[ $current_rvm == *"@"* ]] then
44
+ current_gemset="$(echo $current_rvm | sed -E 's/^[^@]+@//')"
45
+ fi
44
46
  #{command} $current_ruby $current_gemset
45
47
  if [ -f "$HOME/.rvm_command" ]; then
46
48
  source $HOME/.rvm_command
47
49
  rm $HOME/.rvm_command
48
- fi
50
+ fi
49
51
  }
52
+ alias rvm-ui=rvm-tui
53
+ alias rvmtui=rvm-tui
54
+ alias rvmui=rvm-tui
50
55
  SHELL_SCRIPT
51
56
 
52
57
  require 'fileutils'
@@ -55,20 +60,33 @@ FileUtils.mkdir_p("#{home_dir}/bin")
55
60
  rvm_tui_script_file = "#{home_dir}/.rvm_tui_source"
56
61
  rvm_tui_script_file_bash = "$HOME/.rvm_tui_source"
57
62
  File.write(rvm_tui_script_file, rvm_tui_script)
58
- bash_profile_file_name = '.bash_profile'
59
- bash_profile_file = "#{home_dir}/#{bash_profile_file_name}"
60
- if !File.exist?(bash_profile_file)
61
- bash_profile_file_name = '.bashrc'
62
- bash_profile_file = "#{home_dir}/#{bash_profile_file_name}"
63
- end
64
- FileUtils.touch(bash_profile_file)
65
- bash_profile = File.read(bash_profile_file)
66
- rvm_tui_source_statement = "source \"#{rvm_tui_script_file_bash}\""
67
- unless bash_profile.split("\n").detect {|line| line.include?(rvm_tui_source_statement) }
68
- File.write(bash_profile_file, "#{bash_profile}\n#{rvm_tui_source_statement}")
63
+
64
+ [
65
+ ['.bash_profile', '.bashrc'],
66
+ ['.zprofile', '.zshrc']
67
+ ].each do |profile_and_fallback|
68
+ shell_profile_file_name = profile_and_fallback.first
69
+ shell_profile_file_name = profile_and_fallback.last if !File.exist?("#{home_dir}/#{shell_profile_file_name}")
70
+ shell_profile_file = "#{home_dir}/#{shell_profile_file_name}"
71
+ FileUtils.touch(shell_profile_file)
72
+ bash_profile = File.read(shell_profile_file)
73
+ rvm_tui_source_statement = "source \"#{rvm_tui_script_file_bash}\""
74
+ unless bash_profile.split("\n").detect {|line| line.include?(rvm_tui_source_statement) }
75
+ File.write(shell_profile_file, "#{bash_profile}\n#{rvm_tui_source_statement}")
76
+ end
77
+ puts "~/#{shell_profile_file_name} has been modified to source the `rvm-tui` function from ~/.rvm_tui_source"
69
78
  end
79
+
70
80
  puts <<~OUTPUT
71
- ~/#{bash_profile_file_name} has been modified to source the `rvm-tui` function from ~/.rvm_tui_source
72
- To use `rvm-tui`, make sure to first run:
73
- source ~/.rvm_tui_source
81
+
82
+ Before using `rvm-tui`, start a new shell session (open a new terminal tab) or run:
83
+
84
+ source ~/.rvm_tui_source
85
+
86
+ Afterwards, you may run `rvm-tui` via one of these commands (aliases):
87
+
88
+ rvm-tui
89
+ rvm-ui
90
+ rvmtui
91
+ rvmui
74
92
  OUTPUT
@@ -1,11 +1,11 @@
1
- # Copyright (c) 2020 Andy Maleh
2
- #
1
+ # Copyright (c) 2020-2021 Andy Maleh
2
+ #
3
3
  # Licensed under the Apache License, Version 2.0 (the "License");
4
4
  # you may not use this file except in compliance with the License.
5
5
  # You may obtain a copy of the License at
6
- #
6
+ #
7
7
  # http://www.apache.org/licenses/LICENSE-2.0
8
- #
8
+ #
9
9
  # Unless required by applicable law or agreed to in writing, software
10
10
  # distributed under the License is distributed on an "AS IS" BASIS,
11
11
  # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -35,7 +35,7 @@ RVM_COMMAND_PREFIX = <<~SHELL_SCRIPT
35
35
  source "/usr/local/rvm/scripts/rvm"
36
36
  else
37
37
  printf "ERROR: An RVM installation was not found.\\n"
38
- fi
38
+ fi
39
39
  rvm use #{CURRENT_RVM_RUBY}@#{CURRENT_RVM_GEMSET}
40
40
  SHELL_SCRIPT
41
41
 
@@ -44,12 +44,12 @@ def rvm_command(command)
44
44
  end
45
45
 
46
46
  begin
47
- prompt = TTY::Prompt.new
47
+ prompt = TTY::Prompt.new
48
48
  rvm_list_lines = rvm_command('rvm list').split("\n")
49
49
  rvm_list_lines.shift if rvm_list_lines.first.start_with?('Using ')
50
50
  rubies = rvm_list_lines[0...-4] # TODO print excluded lines as an appendix
51
51
  rubies_help = rvm_list_lines[-4..-1].join("\n") + "\n"
52
- ruby = prompt.select("Choose a Ruby: ", rubies, cycle: true, per_page: 40, filter: true, help: "\n#{rubies_help}", show_help: :always)
52
+ ruby = prompt.select("Choose Ruby: ", rubies, cycle: true, per_page: 40, filter: true, help: "\n#{rubies_help}", show_help: :always)
53
53
 
54
54
  ruby = ruby.split.detect {|text| text.include?('ruby')}
55
55
  rvm_gemset_list = nil
@@ -62,7 +62,7 @@ begin
62
62
  rvm_gemset_list_lines.shift if rvm_gemset_list_lines.first.start_with?('Using ')
63
63
  gemsets = rvm_gemset_list_lines[2..-1]
64
64
  gemsets_help = rvm_gemset_list_lines[0..1].join("\n") + "\n"
65
- gemset = prompt.select("Choose a Gemset: ", gemsets, cycle: true, per_page: 40, filter: true, help: gemsets_help, show_help: :always)
65
+ gemset = prompt.select("Choose Gemset: ", gemsets, cycle: true, per_page: 40, filter: true, help: gemsets_help, show_help: :always)
66
66
 
67
67
  gemset = gemset.sub('=>', '').sub('(default)', 'default').strip
68
68
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rvm-tui
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - andy_maleh
@@ -146,7 +146,10 @@ homepage: http://github.com/AndyObtiva/rvm-tui
146
146
  licenses:
147
147
  - Apache-2.0
148
148
  metadata: {}
149
- post_install_message:
149
+ post_install_message: |2+
150
+
151
+ To finish setting up the rvm-tui Ruby gem in your shell environment, run: rvm-tui-setup
152
+
150
153
  rdoc_options: []
151
154
  require_paths:
152
155
  - lib
@@ -166,3 +169,4 @@ signing_key:
166
169
  specification_version: 4
167
170
  summary: Ruby enVironment Manager - Text-based User Interface
168
171
  test_files: []
172
+ ...