wers 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.
- checksums.yaml +15 -0
- data/.gitignore +17 -0
- data/Gemfile +4 -0
- data/LICENSE +20 -0
- data/LICENSE.txt +22 -0
- data/README.md +47 -0
- data/Rakefile +1 -0
- data/bin/wers +49 -0
- data/bin/wers.bat +39 -0
- data/ext/wers/extconf.rb +36 -0
- data/ext/wers/wers.c +1 -0
- data/lib/wers.rb +221 -0
- data/lib/wers/version.rb +1 -0
- data/wers.gemspec +30 -0
- metadata +64 -0
checksums.yaml
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
---
|
2
|
+
!binary "U0hBMQ==":
|
3
|
+
metadata.gz: !binary |-
|
4
|
+
NGVjZWQyYzIzMzAzYWY3ZmFmZTVjYjc4YjZlZmQ0M2Q4Y2VlZWYyNQ==
|
5
|
+
data.tar.gz: !binary |-
|
6
|
+
YzZkYjNiODJhYjBjZTE5MTYwZDQxZTAxODgwMTQyOWFhYWUzNGIzNA==
|
7
|
+
!binary "U0hBNTEy":
|
8
|
+
metadata.gz: !binary |-
|
9
|
+
NjQyMzUyOTRhNWY4MDBiODBjZGRhNDE1YjhjMWNhMDE2MTI1MzgzYTNkODhj
|
10
|
+
Yzk2ODBlOTNkOGM1YzYwYWE0MGE5MjYwN2NkZTEzYWI1Zjg0NmQ4NTQ0ZTMx
|
11
|
+
ZDFkOTU1YzM1NTljZTJiMzVmOWM0Y2Q2OGQ3MmNjYjBkODg3MDE=
|
12
|
+
data.tar.gz: !binary |-
|
13
|
+
ODU5YTU3N2NiYTE1Y2ZkYmQ4NzUzNGE3ODRiOGUyYjY2Y2UxNjZmODUyZDBm
|
14
|
+
ODRmYTNlNDkyNmRhODU2MWYxNDU1NGUzOGI5ZDcwYjU2NDM2NmU5ZjI0MWQy
|
15
|
+
MzhjNjc4NThlZjgxNDY2MTBhMGQ2NjMzNmZjYjhkNDEwNzRmMDg=
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2013 urin
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
6
|
+
this software and associated documentation files (the "Software"), to deal in
|
7
|
+
the Software without restriction, including without limitation the rights to
|
8
|
+
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
9
|
+
the Software, and to permit persons to whom the Software is furnished to do so,
|
10
|
+
subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
17
|
+
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
18
|
+
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
19
|
+
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
20
|
+
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2013 urin
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,47 @@
|
|
1
|
+
# wers
|
2
|
+
|
3
|
+
Manage multiple Ruby versions for Microsoft Windows
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
```bat
|
8
|
+
gem install wers
|
9
|
+
```
|
10
|
+
|
11
|
+
## Usage:
|
12
|
+
|
13
|
+
```bat
|
14
|
+
wers command [options...]
|
15
|
+
```
|
16
|
+
|
17
|
+
## Commands:
|
18
|
+
|
19
|
+
<dl>
|
20
|
+
<dt>init</dt>
|
21
|
+
<dd>Initialize wers with current available Ruby.</dd>
|
22
|
+
<dt>list</dt>
|
23
|
+
<dd>List all Ruby versions known by wers.</dd>
|
24
|
+
<dt>add</dt>
|
25
|
+
<dd>Add specified version of Ruby to wers.</dd>
|
26
|
+
<dt>delete</dt>
|
27
|
+
<dd>Delete specified version of Ruby from wers.</dd>
|
28
|
+
<dt>global</dt>
|
29
|
+
<dd>Set or show the global Ruby version.</dd>
|
30
|
+
<dt>local</dt>
|
31
|
+
<dd>Set or show the local directory-specific Ruby version.</dd>
|
32
|
+
<dt>shell</dt>
|
33
|
+
<dd>Set or show the shell-specific Ruby version.</dd>
|
34
|
+
<dt>version</dt>
|
35
|
+
<dd>Show the current Ruby version.</dd>
|
36
|
+
<dt>help</dt>
|
37
|
+
<dd>Show this help.</dd>
|
38
|
+
</dl>
|
39
|
+
|
40
|
+
## Contributing
|
41
|
+
|
42
|
+
1. Fork it
|
43
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
44
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
45
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
46
|
+
5. Create new Pull Request
|
47
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
data/bin/wers
ADDED
@@ -0,0 +1,49 @@
|
|
1
|
+
#!/bin/bash
|
2
|
+
IFS=':' read -ra pathArray <<< "$PATH"
|
3
|
+
for (( i = 0; i < ${#pathArray[@]}; i++ ))
|
4
|
+
do
|
5
|
+
if [ -x "${pathArray[i]}/ruby.exe" ]; then
|
6
|
+
currentRubyPath=${pathArray[i]}
|
7
|
+
fi
|
8
|
+
done
|
9
|
+
if [ "$currentRubyPath" = "" ]; then
|
10
|
+
echo "Ruby does not exist in available PATH."
|
11
|
+
unset currentRubyPath
|
12
|
+
exit 0
|
13
|
+
fi
|
14
|
+
|
15
|
+
UpdateRubyPath() {
|
16
|
+
local result=$(ruby "$(dirname $mainCommand)/../lib/$(basename $mainCommand).rb" $userCommand $*)
|
17
|
+
case "$result" in
|
18
|
+
Error:*)
|
19
|
+
echo "$result"
|
20
|
+
ruby "$(dirname $mainCommand)/../lib/$(basename $mainCommand).rb" help
|
21
|
+
;;
|
22
|
+
*)
|
23
|
+
result="${result//^}"
|
24
|
+
result=$(echo "$result" | sed 's/\([A-z]\):/\/\L\1\E/g')
|
25
|
+
result="${result//\\//}"
|
26
|
+
result="${result//;/:}"
|
27
|
+
export PATH="$result"
|
28
|
+
ruby "$(dirname $mainCommand)/../lib/$(basename $mainCommand).rb" list
|
29
|
+
;;
|
30
|
+
esac
|
31
|
+
}
|
32
|
+
|
33
|
+
mainCommand=$1
|
34
|
+
shift
|
35
|
+
userCommand=$(echo $1 | tr A-Z a-z)
|
36
|
+
shift
|
37
|
+
case "$userCommand" in
|
38
|
+
"init")
|
39
|
+
ruby "$(dirname $mainCommand)/../lib/$(basename $mainCommand).rb" init $currentRubyPath ;;
|
40
|
+
"shell" | "local" | "global")
|
41
|
+
UpdateRubyPath $* ;;
|
42
|
+
*)
|
43
|
+
ruby "$(dirname $mainCommand)/../lib/$(basename $mainCommand).rb" $userCommand $* ;;
|
44
|
+
esac
|
45
|
+
|
46
|
+
unset currentRubyPath
|
47
|
+
unset mainCommand
|
48
|
+
unset userCommand
|
49
|
+
|
data/bin/wers.bat
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
@echo off
|
2
|
+
|
3
|
+
setlocal
|
4
|
+
for %%x in (ruby.exe) do (set currentRubyPath=%%~dp$PATH:x)
|
5
|
+
if "%currentRubyPath%" == "" (
|
6
|
+
echo "Ruby does not exist in available PATH."
|
7
|
+
exit /b
|
8
|
+
)
|
9
|
+
if /i "%~1" == "init" (
|
10
|
+
ruby "%~dp0..\lib\%~n0.rb" init "%currentRubyPath%"
|
11
|
+
exit /b
|
12
|
+
)
|
13
|
+
endlocal
|
14
|
+
|
15
|
+
if /i "%~1" == "shell" (
|
16
|
+
call :UpdateRubyPath %*
|
17
|
+
) else if /i "%~1" == "local" (
|
18
|
+
call :UpdateRubyPath %*
|
19
|
+
) else if /i "%~1" == "global" (
|
20
|
+
call :UpdateRubyPath %*
|
21
|
+
) else (
|
22
|
+
ruby "%~dp0..\lib\%~n0.rb" %*
|
23
|
+
)
|
24
|
+
|
25
|
+
exit /b
|
26
|
+
|
27
|
+
:UpdateRubyPath
|
28
|
+
setlocal
|
29
|
+
for /f "delims=" %%p in ('ruby "%~dp0..\lib\%~n0.rb" %*') do (set newPath=%%p)
|
30
|
+
if /i "%newPath:~0,6%" == "Error:" (
|
31
|
+
echo %newPath%
|
32
|
+
ruby "%~dp0..\lib\%~n0.rb" help
|
33
|
+
endlocal
|
34
|
+
) else (
|
35
|
+
endlocal && set PATH=%newPath%
|
36
|
+
ruby "%~dp0..\lib\%~n0.rb" list
|
37
|
+
)
|
38
|
+
exit /b
|
39
|
+
|
data/ext/wers/extconf.rb
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
require 'mkmf'
|
2
|
+
require 'fileutils'
|
3
|
+
require 'win32ole'
|
4
|
+
|
5
|
+
here = File.dirname(__FILE__)
|
6
|
+
ins_path = File.expand_path('~/.wers/')
|
7
|
+
['lib', 'bin'].each { |p|
|
8
|
+
FileUtils.copy_entry(
|
9
|
+
"#{here}/../../#{p}", FileUtils.mkdir_p("#{ins_path}/#{p}").first
|
10
|
+
)
|
11
|
+
}
|
12
|
+
bin_path_win = "#{ins_path}/bin".gsub('/', '\\').chomp('\\')
|
13
|
+
user_env_path = WIN32OLE.new("WScript.Shell").Environment("USER").Item("PATH").chomp('\\')
|
14
|
+
unless user_env_path.upcase.include?(bin_path_win.upcase)
|
15
|
+
if user_env_path.empty?
|
16
|
+
`setx PATH "#{bin_path_win}"`
|
17
|
+
else
|
18
|
+
`setx PATH "#{user_env_path + ';' + bin_path_win}"`
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
BASH_CONFIG = File.expand_path('~/.bashrc')
|
23
|
+
ALIAS_COMMAD = "alias wers='. wers ~/.wers/bin/wers'"
|
24
|
+
if File.file? BASH_CONFIG
|
25
|
+
File.write(BASH_CONFIG,
|
26
|
+
[
|
27
|
+
File.read(BASH_CONFIG).sub(/^\s*alias\s+wers\s*=.*$/, '').rstrip,
|
28
|
+
ALIAS_COMMAD
|
29
|
+
].join("\n")
|
30
|
+
)
|
31
|
+
else
|
32
|
+
File.write(BASH_CONFIG, ALIAS_COMMAD)
|
33
|
+
end
|
34
|
+
|
35
|
+
create_makefile('wers/wers')
|
36
|
+
|
data/ext/wers/wers.c
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
void Init_wers(void) {}
|
data/lib/wers.rb
ADDED
@@ -0,0 +1,221 @@
|
|
1
|
+
COMMAND_NAME = File.basename(__FILE__, '.*')
|
2
|
+
require "#{File.dirname(__FILE__)}/#{COMMAND_NAME}/version"
|
3
|
+
|
4
|
+
exit if File.expand_path($0) != File.expand_path(__FILE__)
|
5
|
+
|
6
|
+
require 'yaml'
|
7
|
+
require 'win32ole'
|
8
|
+
|
9
|
+
USER_CONFIG_FILE = File.expand_path("~/.#{COMMAND_NAME}/config.yml")
|
10
|
+
LOCAL_CONFIG_FILE = "./.ruby-version"
|
11
|
+
|
12
|
+
$args = [
|
13
|
+
[:init, 1..1, "Initialize #{COMMAND_NAME} with current available Ruby."],
|
14
|
+
[:list, 0..0, "List all Ruby versions known by #{COMMAND_NAME}."],
|
15
|
+
[:add, 1..2, "Add specified version of Ruby to #{COMMAND_NAME}."],
|
16
|
+
[:delete, 1..1, "Delete specified version of Ruby from #{COMMAND_NAME}."],
|
17
|
+
[:global, 0..1, "Set or show the global Ruby version."],
|
18
|
+
[:local, 0..1, "Set or show the local directory-specific Ruby version."],
|
19
|
+
[:shell, 1..1, "Set or show the shell-specific Ruby version."],
|
20
|
+
[:version, 0..0, "Show the current Ruby version."],
|
21
|
+
[:help, 0..0, "Show this help."]
|
22
|
+
]
|
23
|
+
|
24
|
+
#-------------------------------------------------------------------------------
|
25
|
+
# Define command method
|
26
|
+
#-------------------------------------------------------------------------------
|
27
|
+
def help(errmsg = "")
|
28
|
+
puts(errmsg.empty? ? "" : "Error: #{errmsg}")
|
29
|
+
unless [:global, :local, :shell].include?($command)
|
30
|
+
puts(
|
31
|
+
"#{errmsg.empty? ? "" : "\n"}#{COMMAND_NAME} #{Wers::VERSION} - Manage multiple Ruby versions for Microsoft Windows
|
32
|
+
|
33
|
+
Usage:
|
34
|
+
#{COMMAND_NAME} command [options...]
|
35
|
+
|
36
|
+
Commands:
|
37
|
+
#{
|
38
|
+
len = $args.transpose[0].map { |c| c.length }.max
|
39
|
+
$args.map { |a| sprintf(" %-#{len}s %s", a[0], a[2]) }.join("\n")
|
40
|
+
}"
|
41
|
+
)
|
42
|
+
end
|
43
|
+
exit
|
44
|
+
end
|
45
|
+
|
46
|
+
def list
|
47
|
+
rubies = $config[:global]["rubies"]
|
48
|
+
namelen = rubies.keys.map { |name| name.length }.max
|
49
|
+
rubies.each { |name, path|
|
50
|
+
using = ($config[:using].has_key?(name)) ? '=>' : ''
|
51
|
+
local = (name == $config[:local]) ? '<local>' : ''
|
52
|
+
global = (name == $config[:global]["default"]) ? '<global>' : ''
|
53
|
+
printf("%2s %7s %8s %-#{namelen}s : (%s)\n", using, local, global, name, path)
|
54
|
+
}
|
55
|
+
end
|
56
|
+
|
57
|
+
def init
|
58
|
+
add
|
59
|
+
end
|
60
|
+
|
61
|
+
def add
|
62
|
+
name = (
|
63
|
+
if $options.length == 2
|
64
|
+
$options.shift
|
65
|
+
else
|
66
|
+
ruby = File.expand_path($options[0]) + '/ruby.exe'
|
67
|
+
if File.executable?(ruby)
|
68
|
+
`#{ruby + ' -e "puts RUBY_VERSION"'}`.chomp
|
69
|
+
else
|
70
|
+
help("No such Ruby in #{$options[0]}.")
|
71
|
+
end
|
72
|
+
end
|
73
|
+
)
|
74
|
+
rubies = $config[:global]["rubies"]
|
75
|
+
rubies[name] = $options.shift.chomp('\\')
|
76
|
+
$config[:global]["rubies"] = Hash[rubies.sort]
|
77
|
+
if $command == :init
|
78
|
+
$config[:global]["default"] = name
|
79
|
+
$config[:using] = $config[:global]["rubies"]
|
80
|
+
end
|
81
|
+
save_config
|
82
|
+
list
|
83
|
+
end
|
84
|
+
|
85
|
+
def delete
|
86
|
+
name = $options.shift
|
87
|
+
unless $config[:global]["rubies"].delete(name)
|
88
|
+
help("No such Ruby named #{name}")
|
89
|
+
end
|
90
|
+
save_config
|
91
|
+
list
|
92
|
+
end
|
93
|
+
|
94
|
+
def shell
|
95
|
+
apply_new_path($options[0])
|
96
|
+
end
|
97
|
+
|
98
|
+
def local
|
99
|
+
name = $options.length == 1 ? $options[0] : $config[:local] || $config[:using].keys[0]
|
100
|
+
unless $config[:global]["rubies"].has_key?(name)
|
101
|
+
help("No such Ruby version #{name} in #{COMMAND_NAME}.")
|
102
|
+
end
|
103
|
+
if(File.file?(LOCAL_CONFIG_FILE) && !File.writable?(LOCAL_CONFIG_FILE) or
|
104
|
+
!File.file?(LOCAL_CONFIG_FILE) && !File.writable?(File.dirname(LOCAL_CONFIG_FILE)))
|
105
|
+
help("Can't write #{LOCAL_CONFIG_FILE}.")
|
106
|
+
end
|
107
|
+
open(LOCAL_CONFIG_FILE, 'w') { |f| f.print(name) }
|
108
|
+
apply_new_path(name)
|
109
|
+
end
|
110
|
+
|
111
|
+
def global
|
112
|
+
if $options.length == 1
|
113
|
+
unless $config[:global]["rubies"].has_key?($options[0])
|
114
|
+
help("No such Ruby version #{$options[0]} in #{COMMAND_NAME}.")
|
115
|
+
end
|
116
|
+
unless File.writable?(USER_CONFIG_FILE)
|
117
|
+
help("Can't write #{USER_CONFIG_FILE}.")
|
118
|
+
end
|
119
|
+
$config[:global]["default"] = $options.shift
|
120
|
+
save_config
|
121
|
+
else
|
122
|
+
unless $config[:global].has_key?("default")
|
123
|
+
help("Global default Ruby does not exist in #{USER_CONFIG_FILE}.")
|
124
|
+
end
|
125
|
+
end
|
126
|
+
apply_new_path($config[:global]["default"])
|
127
|
+
`setx /m PATH "#{
|
128
|
+
($env_path[:system].split(';') - $config[:global]["rubies"].values).unshift(
|
129
|
+
$config[:global]["rubies"][$config[:global]["default"]]
|
130
|
+
).join(';')
|
131
|
+
}"`
|
132
|
+
end
|
133
|
+
|
134
|
+
def version
|
135
|
+
if $config[:using].empty?
|
136
|
+
help("Current using Ruby does not exist. Do `#{COMMAND_NAME} init` first.")
|
137
|
+
end
|
138
|
+
name = $config[:using].keys[0]
|
139
|
+
local = (name == $config[:local]) ? ' <local>' : ''
|
140
|
+
global = (name == $config[:global]["default"]) ? ' <global>' : ''
|
141
|
+
path = $config[:using].values[0]
|
142
|
+
printf("=>%s%s %s : (%s)\n", local, global, name, path)
|
143
|
+
path = File.expand_path(path)
|
144
|
+
%w[ruby.exe irb rake gem ri bundle].each { |f|
|
145
|
+
fullpath = "#{path}/#{f}"
|
146
|
+
if File.file?(fullpath)
|
147
|
+
printf(" %-8s - %s\n", f.capitalize, `#{fullpath} --version`)
|
148
|
+
end
|
149
|
+
}
|
150
|
+
end
|
151
|
+
|
152
|
+
#-------------------------------------------------------------------------------
|
153
|
+
# Private
|
154
|
+
#-------------------------------------------------------------------------------
|
155
|
+
def load_config
|
156
|
+
if $command == :init
|
157
|
+
user_config = { "default" => "", "rubies" => {} }
|
158
|
+
using = {}
|
159
|
+
else
|
160
|
+
unless File.readable?(USER_CONFIG_FILE)
|
161
|
+
help("Configuration file #{USER_CONFIG_FILE} does not exist. Do `#{COMMAND_NAME} init` first.")
|
162
|
+
end
|
163
|
+
user_config = YAML.load_file(USER_CONFIG_FILE)
|
164
|
+
path = $env_path[:current].split(';')
|
165
|
+
using = Hash[user_config["rubies"].select { |name, dir|
|
166
|
+
path.index { |p| p.casecmp(dir) == 0 }
|
167
|
+
}]
|
168
|
+
end
|
169
|
+
local_config = (
|
170
|
+
File.readable?(LOCAL_CONFIG_FILE) ? open(LOCAL_CONFIG_FILE).read.chomp : ""
|
171
|
+
)
|
172
|
+
{ :global => user_config, :local => local_config, :using => using }
|
173
|
+
end
|
174
|
+
|
175
|
+
def save_config
|
176
|
+
open(USER_CONFIG_FILE, 'w') { |f| f.print($config[:global].to_yaml) }
|
177
|
+
end
|
178
|
+
|
179
|
+
def apply_new_path(name)
|
180
|
+
unless $config[:global]["rubies"].has_key?(name)
|
181
|
+
help("No such Ruby version #{name} in #{COMMAND_NAME}.")
|
182
|
+
end
|
183
|
+
new_path = $config[:global]["rubies"][name].chomp('\\')
|
184
|
+
unless File.directory?(new_path)
|
185
|
+
help("No such directory #{new_path} of #{name}.")
|
186
|
+
end
|
187
|
+
current_path = $env_path[:current].split(';')
|
188
|
+
$config[:global]["rubies"].values.each { |config|
|
189
|
+
current_path.delete_if { |path|
|
190
|
+
path.chomp('\\').casecmp(config.chomp('\\')) == 0
|
191
|
+
}
|
192
|
+
}
|
193
|
+
print(current_path.unshift(new_path).join(';').gsub('\\', '\\\\').gsub(/[()?*%<>|"'^]/, '^\0'))
|
194
|
+
end
|
195
|
+
|
196
|
+
#-------------------------------------------------------------------------------
|
197
|
+
# Main
|
198
|
+
#-------------------------------------------------------------------------------
|
199
|
+
$command = nil
|
200
|
+
if ARGV.length == 0
|
201
|
+
help
|
202
|
+
end
|
203
|
+
$command = ARGV.shift.downcase.to_sym
|
204
|
+
parameter = $args.assoc($command)
|
205
|
+
unless parameter
|
206
|
+
help("Invalid command #{$command}.")
|
207
|
+
end
|
208
|
+
unless parameter[1].include?(ARGV.length)
|
209
|
+
help("Invalid number of options for command #{$command}.")
|
210
|
+
end
|
211
|
+
|
212
|
+
wsh = WIN32OLE.new("WScript.Shell")
|
213
|
+
$env_path = {
|
214
|
+
:system => wsh.Environment("SYSTEM").Item("PATH"),
|
215
|
+
:user => wsh.Environment("USER" ).Item("PATH"),
|
216
|
+
:current => ENV["PATH"]
|
217
|
+
}
|
218
|
+
$options = ARGV.map { |arg| arg.tr('"', '') }
|
219
|
+
$config = load_config
|
220
|
+
send($command)
|
221
|
+
|
data/lib/wers/version.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
module Wers; VERSION = "0.0.1"; end
|
data/wers.gemspec
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'wers/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "wers"
|
8
|
+
spec.version = Wers::VERSION
|
9
|
+
spec.authors = ["urin"]
|
10
|
+
spec.email = ["urinkun@gmail.com"]
|
11
|
+
spec.summary = %q{Manage multiple Ruby versions for Microsoft Windows}
|
12
|
+
spec.description = %q{Usage:
|
13
|
+
wers command [options...]
|
14
|
+
|
15
|
+
Commands:
|
16
|
+
init Add current available Ruby path for global use.
|
17
|
+
list List all Ruby versions known by wers.
|
18
|
+
add Add specified version of Ruby to wers.
|
19
|
+
delete Delete specified version of Ruby from wers.
|
20
|
+
global Set or show the global Ruby version.
|
21
|
+
local Set or show the local directory-specific Ruby version.
|
22
|
+
shell Set or show the shell-specific Ruby version.
|
23
|
+
version Show the current Ruby version.
|
24
|
+
help Show this help.}
|
25
|
+
spec.homepage = ""
|
26
|
+
spec.license = "MIT"
|
27
|
+
|
28
|
+
spec.files = `git ls-files`.split($/)
|
29
|
+
spec.extensions = ["ext/wers/extconf.rb"]
|
30
|
+
end
|
metadata
ADDED
@@ -0,0 +1,64 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: wers
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- urin
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2013-08-07 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description: ! "Usage:\n wers command [options...]\n\nCommands:\n init Add current
|
14
|
+
available Ruby path for global use.\n list List all Ruby versions known by
|
15
|
+
wers.\n add Add specified version of Ruby to wers.\n delete Delete specified
|
16
|
+
version of Ruby from wers.\n global Set or show the global Ruby version.\n local
|
17
|
+
\ Set or show the local directory-specific Ruby version.\n shell Set or show
|
18
|
+
the shell-specific Ruby version.\n version Show the current Ruby version.\n help
|
19
|
+
\ Show this help."
|
20
|
+
email:
|
21
|
+
- urinkun@gmail.com
|
22
|
+
executables: []
|
23
|
+
extensions:
|
24
|
+
- ext/wers/extconf.rb
|
25
|
+
extra_rdoc_files: []
|
26
|
+
files:
|
27
|
+
- .gitignore
|
28
|
+
- Gemfile
|
29
|
+
- LICENSE
|
30
|
+
- LICENSE.txt
|
31
|
+
- README.md
|
32
|
+
- Rakefile
|
33
|
+
- bin/wers
|
34
|
+
- bin/wers.bat
|
35
|
+
- ext/wers/extconf.rb
|
36
|
+
- ext/wers/wers.c
|
37
|
+
- lib/wers.rb
|
38
|
+
- lib/wers/version.rb
|
39
|
+
- wers.gemspec
|
40
|
+
homepage: ''
|
41
|
+
licenses:
|
42
|
+
- MIT
|
43
|
+
metadata: {}
|
44
|
+
post_install_message:
|
45
|
+
rdoc_options: []
|
46
|
+
require_paths:
|
47
|
+
- lib
|
48
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
49
|
+
requirements:
|
50
|
+
- - ! '>='
|
51
|
+
- !ruby/object:Gem::Version
|
52
|
+
version: '0'
|
53
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
54
|
+
requirements:
|
55
|
+
- - ! '>='
|
56
|
+
- !ruby/object:Gem::Version
|
57
|
+
version: '0'
|
58
|
+
requirements: []
|
59
|
+
rubyforge_project:
|
60
|
+
rubygems_version: 2.0.6
|
61
|
+
signing_key:
|
62
|
+
specification_version: 4
|
63
|
+
summary: Manage multiple Ruby versions for Microsoft Windows
|
64
|
+
test_files: []
|