rvm-tui 0.0.1

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 (7) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE.txt +13 -0
  3. data/README.md +65 -0
  4. data/VERSION +1 -0
  5. data/bin/rvm-tui-setup +53 -0
  6. data/lib/rvm-tui.rb +27 -0
  7. metadata +148 -0
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 0a2efd862751fe44f51587a1f9b9b469c34d9d4be205ce43a6fbfdd86374c5f5
4
+ data.tar.gz: 193ac518992be95f86e0f701d202b9bceb0352667dd5187e74307d7b213c9c28
5
+ SHA512:
6
+ metadata.gz: 00d76e19ea4d63b0a84cf06f4948b903ca16d8e2907910b7e94a39dac5699f5b70b8d1a4c6cabc4231486f00fe21a300c9ab52ed42e90bf5cd21b7c867bd0a4e
7
+ data.tar.gz: 902a41fcc9649f5f25e117a324abf6e2496b330e26214480e6bd6ff53bb313ab8a93a46a2bf7e35440a158c98f99b325c7c9e6a2051b7926bb34015595b8d1f4
@@ -0,0 +1,13 @@
1
+ Copyright (c) 2020 Andy Maleh
2
+
3
+ Licensed under the Apache License, Version 2.0 (the "License");
4
+ you may not use this file except in compliance with the License.
5
+ You may obtain a copy of the License at
6
+
7
+ http://www.apache.org/licenses/LICENSE-2.0
8
+
9
+ Unless required by applicable law or agreed to in writing, software
10
+ distributed under the License is distributed on an "AS IS" BASIS,
11
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ See the License for the specific language governing permissions and
13
+ limitations under the License.
@@ -0,0 +1,65 @@
1
+ # Ruby enVironment Manager - Text-based User Interface
2
+
3
+ [RVM](https://rvm.io) is the original Ruby enVironment Manager that is used to:
4
+ - Effortlessly install multiple versions of [Ruby](https://www.ruby-lang.org/en/), including [JRuby](https://www.jruby.org/)
5
+ - Isolate projects from each other with gemsets to:
6
+ - Enable higher productivity by being able to work on projects completely worry-free without any concerns about side-effects on other projects
7
+ - Ability to manage a project's gems (including mass deletion) without worrying about affecting other projects
8
+ - Prevent odd bugs that happen when sharing gems with other projects due to making changes in them
9
+ - Simplify gem-related troubleshooting without a domino effect on other projects
10
+
11
+ Given how practical and often-used [RVM](https://rvm.io) is, I am providing a text-based user interface for it.
12
+
13
+ ![RVM TUI DEMO](rvm-tui-demo.gif)
14
+
15
+ ## Pre-requisites
16
+
17
+ - [RVM](https://rvm.io)
18
+ - Any version of Ruby installed via [RVM](https://rvm.io)
19
+
20
+ ## Setup Instructions
21
+
22
+ 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.
23
+
24
+ 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).
25
+
26
+ 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)
27
+
28
+ These are the commands you need to run:
29
+
30
+ ```
31
+ rvm use @default
32
+ gem install rvm-tui
33
+ rvm-tui-setup
34
+ ```
35
+
36
+ ## Usage
37
+
38
+ Simply run this command:
39
+
40
+ ```
41
+ rvm-tui
42
+ ```
43
+
44
+ ## Contributing to rvm-tui
45
+
46
+ - Make sure you have [RVM](https://rvm.io) installed
47
+ - Check out the latest master to make sure the feature hasn't been
48
+ implemented or the bug hasn't been fixed yet.
49
+ - Check out the issue tracker to make sure someone already hasn't
50
+ requested it and/or contributed it.
51
+ - Fork the project.
52
+ - Start a feature/bugfix branch.
53
+ - `bundle`
54
+ - Commit and push until you are happy with your contribution.
55
+ - `rake install` to test (or `rake build`, `rvm use @default`, and then `gem install pkg/rvm-tui-{version}.gem`)
56
+ - Please try not to mess with the Rakefile, version, or change log. If
57
+ you want to have your own version, or is otherwise necessary, that
58
+ is fine, but please isolate to its own commit so I can cherry-pick
59
+ around it.
60
+
61
+ ## License
62
+
63
+ [Apache License, Version 2.0](https://www.apache.org/licenses/LICENSE-2.0)
64
+
65
+ Copyright (c) 2020 Andy Maleh. See [LICENSE.txt](LICENSE.txt) for further details.
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.0.1
@@ -0,0 +1,53 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ puts "rvm-tui-setup version #{File.read(File.expand_path('../../VERSION', __FILE__))}"
4
+
5
+ ruby = `which ruby`
6
+ ruby = `which jruby` if ruby.to_s.strip.empty?
7
+ ruby = ruby.strip
8
+ rvm = `rvm current`.strip
9
+ command = "rvm #{rvm} do #{ruby} #{File.expand_path('../../lib/rvm-tui.rb', __FILE__)}"
10
+
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
+ }
29
+ SHELL_SCRIPT
30
+
31
+ require 'fileutils'
32
+ home_dir = `echo ~`.strip
33
+ FileUtils.mkdir_p("#{home_dir}/bin")
34
+ rvm_tui_script_file = "#{home_dir}/.rvm_tui_source"
35
+ rvm_tui_script_file_bash = "$HOME/.rvm_tui_source"
36
+ File.write(rvm_tui_script_file, rvm_tui_script)
37
+ bash_profile_file_name = '.bash_profile'
38
+ bash_profile_file = "#{home_dir}/#{bash_profile_file_name}"
39
+ if !File.exist?(bash_profile_file)
40
+ bash_profile_file_name = '.bashrc'
41
+ bash_profile_file = "#{home_dir}/#{bash_profile_file_name}"
42
+ end
43
+ FileUtils.touch(bash_profile_file)
44
+ bash_profile = File.read(bash_profile_file)
45
+ rvm_tui_source_statement = "source \"#{rvm_tui_script_file_bash}\""
46
+ unless bash_profile.split("\n").detect {|line| line.include?(rvm_tui_source_statement) }
47
+ File.write(bash_profile_file, "#{bash_profile}\n#{rvm_tui_source_statement}")
48
+ end
49
+ 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}
53
+ OUTPUT
@@ -0,0 +1,27 @@
1
+ $LOAD_PATH.unshift(File.expand_path('..', __FILE__))
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)
metadata ADDED
@@ -0,0 +1,148 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rvm-tui
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - andy_maleh
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2020-09-03 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: tty-prompt
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rspec
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: 3.5.0
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: 3.5.0
41
+ - !ruby/object:Gem::Dependency
42
+ name: rdoc
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '3.12'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '3.12'
55
+ - !ruby/object:Gem::Dependency
56
+ name: bundler
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '1.0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '1.0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: juwelier
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: 2.1.0
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: 2.1.0
83
+ - !ruby/object:Gem::Dependency
84
+ name: simplecov
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: puts_debuggerer
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ description: Ruby enVironment Manager - Text-based User Interface
112
+ email: andy.am@gmail.com
113
+ executables:
114
+ - rvm-tui-setup
115
+ extensions: []
116
+ extra_rdoc_files:
117
+ - LICENSE.txt
118
+ - README.md
119
+ files:
120
+ - LICENSE.txt
121
+ - README.md
122
+ - VERSION
123
+ - bin/rvm-tui-setup
124
+ - lib/rvm-tui.rb
125
+ homepage: http://github.com/AndyObtiva/rvm-tui
126
+ licenses:
127
+ - MIT
128
+ metadata: {}
129
+ post_install_message:
130
+ rdoc_options: []
131
+ require_paths:
132
+ - lib
133
+ required_ruby_version: !ruby/object:Gem::Requirement
134
+ requirements:
135
+ - - ">="
136
+ - !ruby/object:Gem::Version
137
+ version: '0'
138
+ required_rubygems_version: !ruby/object:Gem::Requirement
139
+ requirements:
140
+ - - ">="
141
+ - !ruby/object:Gem::Version
142
+ version: '0'
143
+ requirements: []
144
+ rubygems_version: 3.1.4
145
+ signing_key:
146
+ specification_version: 4
147
+ summary: Ruby enVironment Manager - Text-based User Interface
148
+ test_files: []