sprout 0.5.23 → 0.5.25

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of sprout might be problematic. Click here for more details.

Files changed (3) hide show
  1. data/lib/sprout/version.rb +1 -1
  2. data/lib/user.rb +56 -36
  3. metadata +1 -1
@@ -2,7 +2,7 @@ module Sprout #:nodoc:
2
2
  module VERSION #:nodoc:
3
3
  MAJOR = 0
4
4
  MINOR = 5
5
- TINY = 24
5
+ TINY = 26
6
6
 
7
7
  STRING = [MAJOR, MINOR, TINY].join('.')
8
8
  end
@@ -1,13 +1,13 @@
1
1
 
2
2
  module PatternPark
3
3
 
4
- class ExecutionError < StandardError; end
4
+ class ExecutionError < StandardError; end
5
5
 
6
6
  #############################
7
- # User class
7
+ # User class
8
8
  class User
9
9
  @@user = nil
10
-
10
+
11
11
  def User.new(os=nil, impl=nil)
12
12
  if(os.nil? && impl.nil? && @@user)
13
13
  return @@user
@@ -32,15 +32,15 @@ module PatternPark
32
32
  @@user = UnixUser.new
33
33
  end
34
34
  end
35
-
35
+
36
36
  def User.user=(user)
37
37
  @@user = user
38
38
  end
39
-
39
+
40
40
  def User.home=(path)
41
41
  User.new().home = path
42
42
  end
43
-
43
+
44
44
  def User.in_path?(executable)
45
45
  User.new().in_path?(executable)
46
46
  end
@@ -48,19 +48,19 @@ module PatternPark
48
48
  def User.home
49
49
  User.new().home
50
50
  end
51
-
51
+
52
52
  def User.application_home(name)
53
53
  return User.new().application_home(name)
54
54
  end
55
-
55
+
56
56
  def User.library
57
57
  return User.new().library
58
58
  end
59
-
59
+
60
60
  def User.execute(tool, options='')
61
61
  return User.new().execute(tool, options)
62
62
  end
63
-
63
+
64
64
  def User.execute_thread(tool, options='')
65
65
  if(Log.debug)
66
66
  return ThreadMock.new
@@ -68,44 +68,44 @@ module PatternPark
68
68
  return User.new().execute_thread(tool, options)
69
69
  end
70
70
  end
71
-
71
+
72
72
  def User.clean_path(path)
73
73
  return User.new().clean_path(path)
74
74
  end
75
-
75
+
76
76
  # Called from Sprout.init_values...
77
77
  def User.init_values
78
78
  @@user = nil
79
79
  @@home = nil
80
80
  end
81
81
  end
82
-
82
+
83
83
  #############################
84
- # UnixUser class
84
+ # UnixUser class
85
85
  class UnixUser
86
-
86
+
87
87
  def initialize
88
88
  require 'open3'
89
89
  @home = nil
90
90
  end
91
-
91
+
92
92
  def home=(path)
93
93
  @home = path
94
94
  end
95
-
95
+
96
96
  def home
97
97
  if(@home)
98
98
  return @home
99
99
  end
100
-
100
+
101
101
  ["HOME", "USERPROFILE"].each do |homekey|
102
102
  return @home = ENV[homekey] if ENV[homekey]
103
103
  end
104
-
104
+
105
105
  if ENV["HOMEDRIVE"] && ENV["HOMEPATH"]
106
106
  return @home = "#{ENV["HOMEDRIVE"]}:#{ENV["HOMEPATH"]}"
107
107
  end
108
-
108
+
109
109
  begin
110
110
  return @home = File.expand_path("~")
111
111
  rescue StandardError => ex
@@ -148,11 +148,11 @@ module PatternPark
148
148
  return Platform::IMPL
149
149
  end
150
150
  end
151
-
151
+
152
152
  def get_process_runner(command)
153
153
  return ProcessRunner.new(command)
154
154
  end
155
-
155
+
156
156
  def execute(tool, options='')
157
157
  tool = Sprout.load(tool)
158
158
  if(tool.executable)
@@ -171,24 +171,24 @@ module PatternPark
171
171
  raise ExecutionError.new("[ERROR] #{error}")
172
172
  end
173
173
  end
174
-
174
+
175
175
  def execute_thread(tool, options='')
176
176
  return Thread.new {
177
177
  execute(tool, options)
178
178
  }
179
179
  end
180
-
180
+
181
181
  def clean_path(path)
182
182
  if(path.index(' '))
183
183
  return %{'#{path}'}
184
184
  end
185
185
  return path
186
186
  end
187
-
187
+
188
188
  def application_home(name)
189
189
  return File.join(library, format_application_name(name.to_s));
190
190
  end
191
-
191
+
192
192
  def format_application_name(name)
193
193
  if(name.index('.') != 0)
194
194
  name = '.' + name
@@ -196,10 +196,10 @@ module PatternPark
196
196
  return name.split(" ").join("_").downcase
197
197
  end
198
198
  end
199
-
199
+
200
200
  class OSXUser < UnixUser
201
201
  @@LIBRARY = 'Library'
202
-
202
+
203
203
  def library
204
204
  lib = File.join(home, @@LIBRARY)
205
205
  if(File.exists?(lib))
@@ -208,21 +208,21 @@ module PatternPark
208
208
  return super
209
209
  end
210
210
  end
211
-
211
+
212
212
  def format_application_name(name)
213
213
  return name.capitalize
214
214
  end
215
215
  end
216
-
216
+
217
217
  class WinUser < UnixUser
218
218
  @@LOCAL_SETTINGS = "Local\ Settings"
219
219
  @@APPLICATION_DATA = "Application\ Data"
220
-
220
+
221
221
  def initialize
222
222
  require 'win32/open3'
223
223
  @home = nil
224
224
  end
225
-
225
+
226
226
  def home
227
227
  usr = super
228
228
  if(usr.index "My Documents")
@@ -234,7 +234,7 @@ module PatternPark
234
234
  def get_paths
235
235
  return ENV['PATH'].split(';')
236
236
  end
237
-
237
+
238
238
  def library
239
239
  # For some reason, my homepath returns inside 'My Documents'...
240
240
  application_data = File.join(home, @@LOCAL_SETTINGS, @@APPLICATION_DATA)
@@ -252,7 +252,7 @@ module PatternPark
252
252
  end
253
253
  return path
254
254
  end
255
-
255
+
256
256
  def format_application_name(name)
257
257
  return name.capitalize
258
258
  end
@@ -263,8 +263,10 @@ module PatternPark
263
263
  def initialize
264
264
  require 'open3'
265
265
  @home = nil
266
+ @win_home = nil
267
+ @win_home_cyg_path = nil
266
268
  end
267
-
269
+
268
270
  def clean_path(path)
269
271
  if(path.index(' '))
270
272
  return %{'#{path}'}
@@ -272,8 +274,26 @@ module PatternPark
272
274
  return path
273
275
  end
274
276
 
277
+ def win_home
278
+ if(@win_home.nil?)
279
+ @win_home = ENV['HOMEDRIVE'] + ENV['HOMEPATH']
280
+ end
281
+ return @win_home
282
+ end
283
+
284
+ def home
285
+ if(@home.nil?)
286
+ path = win_home.split('\\').join("/")
287
+ path = path.split(":").join("")
288
+ parts = path.split("/")
289
+ path = parts.shift().downcase + "/" + parts.join("/")
290
+ @home = "/cygdrive/" + path
291
+ end
292
+ return @home
293
+ end
294
+
275
295
  end
276
-
296
+
277
297
  class VistaUser < WinUser
278
298
  def home
279
299
  profile = ENV['USERPROFILE']
metadata CHANGED
@@ -3,7 +3,7 @@ rubygems_version: 0.9.2
3
3
  specification_version: 1
4
4
  name: sprout
5
5
  version: !ruby/object:Gem::Version
6
- version: 0.5.23
6
+ version: 0.5.25
7
7
  date: 2007-07-07 00:00:00 -07:00
8
8
  summary: "Sprouts is an open-source, cross-platform project generation and configuration
9
9
  tool."