sprout 0.5.0 → 0.5.9

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.

@@ -0,0 +1,28 @@
1
+
2
+ module PatternPark
3
+
4
+ class ProcessRunner
5
+ attr_reader :path,
6
+ :r,
7
+ :w,
8
+ :e
9
+
10
+ def initialize(*command)
11
+ require 'open3'
12
+ @command = command
13
+ @w, @r, @e = Open3.popen3(*@command)
14
+ end
15
+
16
+ def puts(msg)
17
+ @w.puts(msg)
18
+ end
19
+
20
+ def read
21
+ return r.read
22
+ end
23
+
24
+ def read_err
25
+ return e.read
26
+ end
27
+ end
28
+ end
@@ -90,11 +90,27 @@ module PatternPark
90
90
  begin
91
91
  retries += 1
92
92
  Zip::ZipFile::open(zip_file) do |zf|
93
- zf.each do |e|
94
- fpath = File.join(dir, e.name)
95
- FileUtils.mkdir_p(File.dirname(fpath))
96
- zf.extract(e, fpath)
93
+ zf.each do |e|
94
+ fpath = File.join(dir, e.name)
95
+ FileUtils.mkdir_p(File.dirname(fpath))
96
+ # Disgusting, Gross Hack to fix Windows/Ruby Bug
97
+ # That makes the zip library throw a ZipDestinationFileExistsError
98
+ # When the zip archive includes two files whose names
99
+ # differ only by extension.
100
+ # This bug actually appears in the File.exists? implementation
101
+ # throwing false positives!
102
+ # If you're going to use this code, be sure you extract
103
+ # into a new, empty directory as existing files will be
104
+ # clobbered...
105
+ if(File.exists?(fpath) && !File.directory?(fpath))
106
+ hackpath = fpath + 'hack'
107
+ zf.extract(e, hackpath)
108
+ File.copy(hackpath, fpath)
109
+ File.delete(hackpath)
110
+ else
111
+ zf.extract(e, fpath)
97
112
  end
113
+ end
98
114
  end
99
115
  rescue StandardError => e
100
116
  if(retries < 3)
@@ -9,7 +9,7 @@ module PatternPark
9
9
  :archive_path,
10
10
  :install_path,
11
11
  :project_path,
12
- :post_install
12
+ :post_install,
13
13
  :mount_path
14
14
  attr_reader :downloaded_path,
15
15
  :file_name,
@@ -25,8 +25,11 @@ module PatternPark
25
25
  end
26
26
  @file_name = url.split('/').pop
27
27
  @downloaded_path = File.join(Sprout.cache, type, install_path, file_name)
28
- a_type = (archive_type == 'txt') ? nil : archive_type
29
- @install_path = File.join(Sprout.cache, type, install_path, a_type)
28
+ if(archive_type == 'txt' || archive_type == 'exe')
29
+ @install_path = File.join(Sprout.cache, type, install_path)
30
+ else
31
+ @install_path = File.join(Sprout.cache, type, install_path, archive_type)
32
+ end
30
33
  @copy_path = File.join(install_path, archive_path)
31
34
  loader = RemoteFileLoader.new
32
35
 
data/lib/sprout.rb CHANGED
@@ -279,6 +279,7 @@ module PatternPark
279
279
  if(targets)
280
280
  universal_target = nil
281
281
  platform = usr.platform.to_s
282
+ # puts "platform: #{platform}"
282
283
  targets.each do |t|
283
284
  if(t.platform == platform)
284
285
  @target = t
@@ -319,6 +320,7 @@ module PatternPark
319
320
 
320
321
  require 'singleton'
321
322
  require 'progress_bar'
323
+ require 'process_runner'
322
324
  require 'template_resolver'
323
325
  require 'platform'
324
326
  require 'user'
@@ -2,7 +2,7 @@ module Sprout #:nodoc:
2
2
  module VERSION #:nodoc:
3
3
  MAJOR = 0
4
4
  MINOR = 5
5
- TINY = 1
5
+ TINY = 10
6
6
 
7
7
  STRING = [MAJOR, MINOR, TINY].join('.')
8
8
  end
data/lib/user.rb CHANGED
@@ -20,10 +20,10 @@ module PatternPark
20
20
  end
21
21
  if(os == :win32 && impl == :vista)
22
22
  @@user = VistaUser.new
23
+ elsif(os == :win32 && impl == :cygwin)
24
+ @@user = CygwinUser.new
23
25
  elsif(os == :win32)
24
26
  @@user = WinUser.new
25
- elsif(os == :unix && impl == :cygwin)
26
- @@user = CygwinUser.new
27
27
  elsif(os == :unix && impl == :macosx)
28
28
  @@user = OSXUser.new
29
29
  elsif(os == :unix && impl == :linux)
@@ -126,14 +126,17 @@ module PatternPark
126
126
  end
127
127
  end
128
128
 
129
+ def get_process_runner(command)
130
+ return ProcessRunner.new(command)
131
+ end
132
+
129
133
  def execute(tool, options='')
130
134
  tool = Sprout.load(tool)
131
135
  target = tool.archive_path
132
136
  Log.puts(">> Execute: #{File.basename(target)} #{options}")
133
- runner = CommandRunner.new("#{clean_path(target)} #{options}")
134
- runner.run
137
+ runner = get_process_runner("#{clean_path(target)} #{options}")
135
138
  result = runner.read
136
- error = runner.readError.to_s
139
+ error = runner.read_err
137
140
  if(result.size > 0)
138
141
  Log.puts result
139
142
  end
@@ -220,6 +223,12 @@ module PatternPark
220
223
  end
221
224
 
222
225
  class CygwinUser < WinUser
226
+ def clean_path(path)
227
+ if(path.index(' '))
228
+ return %{'#{path}'}
229
+ end
230
+ return path
231
+ end
223
232
  end
224
233
 
225
234
  class VistaUser < WinUser
metadata CHANGED
@@ -3,8 +3,8 @@ 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.0
7
- date: 2007-06-10 00:00:00 -07:00
6
+ version: 0.5.9
7
+ date: 2007-06-12 00:00:00 -07:00
8
8
  summary: "Sprouts is an open-source, cross-platform project generation and configuration
9
9
  tool."
10
10
  require_paths:
@@ -50,6 +50,7 @@ files:
50
50
  - lib/library.rb
51
51
  - lib/log.rb
52
52
  - lib/platform.rb
53
+ - lib/process_runner.rb
53
54
  - lib/progress_bar.rb
54
55
  - lib/project.rb
55
56
  - lib/project_model.rb