/
info_command.rb
69 lines (54 loc) · 1.67 KB
/
info_command.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
module Pik
class Info < Command
it "Displays information about the current ruby version."
aka :checkup, :cu
def execute
puts info
end
def info
ruby = Which::Ruby.exe
ruby_version = find_config_from_path(ruby.dirname)
current = config[ruby_version]
gem_home = current[:gem_home] || actual_gem_home
ruby_version = Pik::VersionParser.parse(ruby_version)
return info =<<INFO
#{pik_version}
ruby:
interpreter: "#{ruby_version.interpreter}"
version: "#{ruby_version.version}"
date: "#{ruby_version.date}"
platform: "#{ruby_version.platform}"
patchlevel: "#{ruby_version.patchlevel}"
full_version: "#{ruby_version.full_version}"
homes:
gem: "#{gem_home}"
ruby: "#{ruby.dirname.dirname}"
binaries:
ruby: "#{ruby}"
irb: "#{Which::Irb.exe}"
gem: "#{Which::Gem.exe}"
rake: "#{Which::Rake.exe}"
environment:
GEM_HOME: "#{ENV['GEM_HOME']}"
HOME: "#{ENV['HOME']}"
IRBRC: "#{ENV['IRBRC']}"
RUBYOPT: "#{ENV['RUBYOPT']}"
file associations:
.rb: #{file_associations('.rb')}
.rbw: #{file_associations('.rbw')}#{check_path}
INFO
end
def check_path
dirs = Which::Ruby.find_all
unless dirs.size == 1
dirs.unshift("\n\nwarning: There is more than one version of ruby in the system path")
dirs.join("\n")
end
end
def file_associations(extension)
@reg = Reg.new
assoc = @reg.hkcr(extension) rescue nil
ftype = @reg.hkcr("#{assoc}\\Shell\\open\\command") rescue nil
end
end
end