2020-10-25 08:32:14 -07:00
|
|
|
package main
|
|
|
|
|
|
|
|
type ruby struct {
|
2021-02-03 10:33:05 -08:00
|
|
|
language *language
|
2020-10-25 08:32:14 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
func (r *ruby) string() string {
|
2021-02-03 10:33:05 -08:00
|
|
|
version := r.language.string()
|
|
|
|
// asdf default non-set version
|
|
|
|
if version == "______" {
|
|
|
|
return ""
|
2020-10-25 08:32:14 -07:00
|
|
|
}
|
2021-02-03 10:33:05 -08:00
|
|
|
return version
|
2020-10-25 08:32:14 -07:00
|
|
|
}
|
|
|
|
|
2021-11-26 01:37:33 -08:00
|
|
|
func (r *ruby) init(props properties, env environmentInfo) {
|
2021-02-03 10:33:05 -08:00
|
|
|
r.language = &language{
|
|
|
|
env: env,
|
|
|
|
props: props,
|
|
|
|
extensions: []string{"*.rb", "Rakefile", "Gemfile"},
|
|
|
|
commands: []*cmd{
|
|
|
|
{
|
|
|
|
executable: "rbenv",
|
|
|
|
args: []string{"version-name"},
|
|
|
|
regex: `(?P<version>.+)`,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
executable: "rvm-prompt",
|
|
|
|
args: []string{"i", "v", "g"},
|
|
|
|
regex: `(?P<version>.+)`,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
executable: "chruby",
|
|
|
|
args: []string(nil),
|
|
|
|
regex: `\* (?P<version>.+)\n`,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
executable: "asdf",
|
|
|
|
args: []string{"current", "ruby"},
|
|
|
|
regex: `ruby\s+(?P<version>[^\s]+)\s+`,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
executable: "ruby",
|
|
|
|
args: []string{"--version"},
|
|
|
|
regex: `ruby\s+(?P<version>[^\s]+)\s+`,
|
|
|
|
},
|
|
|
|
},
|
2020-10-25 08:32:14 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-02-03 10:33:05 -08:00
|
|
|
func (r *ruby) enabled() bool {
|
|
|
|
return r.language.enabled()
|
2020-10-25 08:32:14 -07:00
|
|
|
}
|