muto 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
data/README.textile CHANGED
@@ -19,24 +19,28 @@ h2. Example Usage
19
19
  #From the command line
20
20
 
21
21
  muto
22
- =>Expected format: muto [ruby_version]
23
- =>
24
- =>Available Versions are:
25
- => 186 ruby 1.8.6 (2007-09-24 patchlevel 111) [i386-mswin32]
26
- => 192 ruby 1.9.2p180 (2011-02-18) [i386-mingw32]
27
- =>
28
- =>Currently using:
29
- =>ruby 1.8.6 (2007-09-24 patchlevel 111) [i386-mswin32]
22
+ =>Expected format: muto [ruby_version]
23
+ =>
24
+ =>Available Versions are:
25
+ => 186 ruby 1.8.6 (2007-09-24 patchlevel 111) [i386-mswin32]
26
+ => 192 ruby 1.9.2p180 (2011-02-18) [i386-mingw32]
27
+ =>
28
+ =>Currently using:
29
+ =>ruby 1.8.6 (2007-09-24 patchlevel 111) [i386-mswin32]
30
30
 
31
31
  ruby -v
32
- =>ruby 1.8.6 (2007-09-24 patchlevel 111) [i386-mswin32]
32
+ =>ruby 1.8.6 (2007-09-24 patchlevel 111) [i386-mswin32]
33
+ echo %JAVA_HOME%
34
+ =>C:\Program Files\Java\jre5
33
35
 
34
36
  muto 192
35
- =>System updated. Now using:
36
- =>ruby 1.9.2p180 (2011-02-18) [i386-mingw32]
37
+ =>System updated. Now using:
38
+ =>ruby 1.9.2p180 (2011-02-18) [i386-mingw32]
37
39
 
38
40
  ruby -v
39
- =>ruby 1.9.2p180 (2011-02-18) [i386-mingw32]
41
+ =>ruby 1.9.2p180 (2011-02-18) [i386-mingw32]
42
+ echo %JAVA_HOME%
43
+ =>C:\Program Files\Java\jre7
40
44
  </pre>
41
45
 
42
46
  h2. How Muto works..
@@ -67,7 +71,6 @@ extract_muto
67
71
  #=>Then add C:\Muto to your Windows PATH environment variable and you're good to go
68
72
  </pre>
69
73
 
70
-
71
74
  h3. ruby_versions.yml
72
75
 
73
76
  As well as being able to switch to other versions of Ruby in your Windows environment, you can also define other User Environment Variables to change at
@@ -84,20 +87,11 @@ ruby_versions:
84
87
  ruby_186:
85
88
  shortcut: 186
86
89
  bin_folder: C:\ruby\bin
90
+ user_env_variables:
91
+ java_home: C:\Program Files\Java\jre5
87
92
  ruby_192:
88
93
  shortcut: 192
89
94
  bin_folder: C:\ruby192\bin
90
-
91
- jruby_164_jre6:
92
- shortcut: jr_j6
93
- bin_folder: C:\jruby-1.6.4\bin
94
- exe_name: jruby.exe
95
- user_env_variables:
96
- java_home: C:\Program Files\Java\jre6
97
- jruby_164_jre7:
98
- shortcut: jr_j7
99
- bin_folder: C:\jruby-1.6.4\bin
100
- exe_name: jruby.exe
101
95
  user_env_variables:
102
96
  java_home: C:\Program Files\Java\jre7
103
97
 
data/bin/extract_muto CHANGED
@@ -24,14 +24,20 @@ class Muto
24
24
 
25
25
  Dir[templates].each do |source|
26
26
 
27
- next if source.match(/muto.bat\z/) #ignore muto.bat here, going to write it next
27
+ next if source.match(/muto.bat\z/) #ignore muto.bat here, going to write it manually next
28
28
 
29
29
  destination = File.join(muto_root_dir, source.gsub(/^.*\/deploy_scripts/, ''))
30
- if File.exist?(destination) || (File.directory? destination)
31
- puts "Skipping #{destination.to_s.gsub(/\//, '\\')} because it already exists"
30
+ if File.exist?(destination) && destination.match(/ruby_versions\.yml/)
31
+ puts "Leaving #{destination.to_s.gsub(/\//, '\\')} because a copy already exists"
32
32
  else
33
- puts "Generating #{destination.to_s.gsub(/\//, '\\')}"
34
- File.directory?(source) ? FileUtils.mkdir(destination) : FileUtils.cp(source, destination)
33
+ if File.exist?(destination)
34
+ puts "Replacing #{destination.to_s.gsub(/\//, '\\')}"
35
+ FileUtils.rm_rf(destination)
36
+ FileUtils.cp(source, destination)
37
+ else
38
+ puts "Generating #{destination.to_s.gsub(/\//, '\\')}"
39
+ File.directory?(source) ? FileUtils.mkdir(destination) : FileUtils.cp(source, destination)
40
+ end
35
41
  end
36
42
  end
37
43
 
@@ -57,7 +63,7 @@ class Muto
57
63
  end
58
64
 
59
65
  puts "\nAdd Ruby versions to your #{muto_root_dir.to_s.gsub(/\//, '\\')}\\ruby_versions.yml"
60
- puts "Then add #{muto_root_dir.to_s.gsub(/\//, '\\')} to your Windows PATH environment variable and you're good to go"
66
+ puts "Then add #{muto_root_dir.to_s.gsub(/\//, '\\')} to your User PATH environment variable and you're good to go"
61
67
 
62
68
  rescue
63
69
  puts $!, $!.backtrace
@@ -108,7 +108,13 @@ class Muto
108
108
  end
109
109
 
110
110
  def update_user_path_variable(versions_yml_key)
111
- reg_key, path_env_var = Win32::Registry::HKEY_CURRENT_USER.open('Environment').read('PATH')
111
+
112
+ begin
113
+ reg_key, path_env_var = Win32::Registry::HKEY_CURRENT_USER.open('Environment').read('PATH')
114
+ rescue
115
+ user_path_env_not_set_properly_msg
116
+ exit!
117
+ end
112
118
 
113
119
  #TODO - Fix regex to support all variants of path names
114
120
  @all_bin_paths.each do |bin_path|
@@ -128,7 +134,17 @@ class Muto
128
134
  end
129
135
 
130
136
  broadcast_WM_SETTINGCHANGE_signal
137
+ end
138
+
139
+ private
131
140
 
141
+ def user_path_env_not_set_properly_msg
142
+ puts "\nThere are no User environment variables named PATH defined, most likely your
143
+ \nruby version is defined on your System PATH environment variable. Muto can
144
+ \nonly modify User environment variables, not system environment variables.
145
+ \nSwitch your path to ruby over to a User environment variable and you
146
+ \nshould be good to go :)"
147
+ puts "\nSystem did not update! Still using:"
132
148
  end
133
149
  end
134
150
 
data/lib/muto/version.rb CHANGED
@@ -1,3 +1,4 @@
1
1
  module Muto
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
+
3
4
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: muto
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-09-24 00:00:00.000000000Z
12
+ date: 2011-11-13 00:00:00.000000000Z
13
13
  dependencies: []
14
14
  description: Set up different Windows Ruby environments and switch between them on
15
15
  the command line
@@ -74,7 +74,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
74
74
  version: '0'
75
75
  requirements: []
76
76
  rubyforge_project:
77
- rubygems_version: 1.8.5
77
+ rubygems_version: 1.8.11
78
78
  signing_key:
79
79
  specification_version: 3
80
80
  summary: I got sick of manually having to change windows environment variables and