sprout 0.5.29 → 0.7.153
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.
- data/{MIT-LICENSE.txt → MIT-LICENSE} +0 -0
- data/TODO +12 -0
- data/bin/sprout +83 -140
- data/doc/Bundle +14 -0
- data/doc/Generator +35 -0
- data/doc/Library +63 -0
- data/doc/Task +21 -0
- data/doc/Tool +20 -0
- data/lib/platform.rb +2 -3
- data/lib/progress_bar.rb +39 -23
- data/lib/sprout/builder.rb +35 -0
- data/lib/sprout/commands/generate.rb +14 -0
- data/lib/sprout/general_tasks.rb +5 -0
- data/lib/sprout/generator/base_mixins.rb +132 -0
- data/lib/sprout/generator/named_base.rb +216 -0
- data/lib/sprout/generator.rb +6 -0
- data/lib/{log.rb → sprout/log.rb} +2 -2
- data/lib/sprout/process_runner.rb +46 -0
- data/lib/sprout/project_model.rb +114 -0
- data/lib/{remote_file_loader.rb → sprout/remote_file_loader.rb} +63 -36
- data/lib/sprout/remote_file_target.rb +96 -0
- data/lib/sprout/simple_resolver.rb +88 -0
- data/lib/sprout/tasks/gem_wrap_task.rb +192 -0
- data/lib/sprout/tasks/library_task.rb +103 -0
- data/lib/sprout/tasks/sftp_task.rb +245 -0
- data/lib/sprout/tasks/tool_task.rb +541 -0
- data/lib/sprout/tasks/zip_task.rb +158 -0
- data/lib/{template_resolver.rb → sprout/template_resolver.rb} +10 -7
- data/lib/{user.rb → sprout/user.rb} +84 -37
- data/lib/sprout/version.rb +4 -3
- data/lib/sprout/zip_util.rb +61 -0
- data/lib/sprout.rb +377 -285
- data/rakefile.rb +93 -119
- data/samples/gem_wrap/rakefile.rb +17 -0
- metadata +131 -96
- data/Manifest.txt +0 -9
- data/lib/command.rb +0 -29
- data/lib/file_target.rb +0 -8
- data/lib/generate.rb +0 -37
- data/lib/library.rb +0 -18
- data/lib/process_runner.rb +0 -27
- data/lib/project.rb +0 -10
- data/lib/project_model.rb +0 -59
- data/lib/remote_file_target.rb +0 -62
- data/lib/task.rb +0 -20
- data/lib/template.rb +0 -37
- data/lib/tool.rb +0 -18
- data/setup.rb +0 -1585
@@ -1,17 +1,20 @@
|
|
1
1
|
|
2
|
-
module
|
3
|
-
|
4
|
-
|
5
|
-
class TemplateResolver < Hash
|
2
|
+
module Sprout
|
3
|
+
|
4
|
+
class TemplateResolver < Hash #:nodoc:
|
6
5
|
include Singleton
|
7
6
|
|
8
|
-
attr_accessor :replace_all,
|
7
|
+
attr_accessor :replace_all,
|
8
|
+
:ignore_all
|
9
|
+
|
9
10
|
@@SPROUT_FILE_NAME = 'Sprout'
|
10
|
-
@@RENDER_IGNORE_FILES = ['asclass_config.rb', 'SWFMillTemplate.erb']
|
11
|
+
@@RENDER_IGNORE_FILES = ['asclass_config.rb', 'SWFMillTemplate.erb', 'Template.erb']
|
11
12
|
@@BINARY_EXTENSIONS = ['.jpg', '.png', '.gif', '.doc', '.xls', '.exe', '.swf', 'fla', '.psd']
|
12
13
|
@@LOG_PREFIX = ">> Created file: "
|
13
|
-
@@DELETE_PREFIX = ">>
|
14
|
+
@@DELETE_PREFIX = ">> Deleted file: "
|
15
|
+
|
14
16
|
def initialize
|
17
|
+
super
|
15
18
|
@replace_all = false
|
16
19
|
@ignore_all = false
|
17
20
|
end
|
@@ -1,13 +1,20 @@
|
|
1
|
+
require 'platform'
|
2
|
+
require 'sprout/log'
|
3
|
+
require 'sprout/process_runner'
|
1
4
|
|
2
|
-
module
|
5
|
+
module Sprout
|
3
6
|
|
4
|
-
class ExecutionError < StandardError
|
7
|
+
class ExecutionError < StandardError # :nodoc:
|
8
|
+
end
|
5
9
|
|
6
|
-
|
7
|
-
#
|
10
|
+
# The User class provides a single and consistent interface to User based paths
|
11
|
+
# and features so that Sprout implementation code doesn't need to be concerned
|
12
|
+
# with which Operating system it is running on.
|
13
|
+
#
|
8
14
|
class User
|
9
15
|
@@user = nil
|
10
16
|
|
17
|
+
# Retrieve a user instance that represents the currently logged in user on this system.
|
11
18
|
def User.new(os=nil, impl=nil)
|
12
19
|
if(os.nil? && impl.nil? && @@user)
|
13
20
|
return @@user
|
@@ -26,41 +33,75 @@ module PatternPark
|
|
26
33
|
@@user = WinUser.new
|
27
34
|
elsif(os == :unix && impl == :macosx)
|
28
35
|
@@user = OSXUser.new
|
29
|
-
elsif(os == :unix && impl == :linux)
|
30
|
-
@@user = UnixUser.new
|
36
|
+
# elsif(os == :unix && impl == :linux)
|
37
|
+
# @@user = UnixUser.new
|
31
38
|
else
|
32
39
|
@@user = UnixUser.new
|
33
40
|
end
|
34
41
|
end
|
35
42
|
|
36
|
-
def User.user=(user)
|
43
|
+
def User.user=(user) # :nodoc:
|
37
44
|
@@user = user
|
38
45
|
end
|
39
46
|
|
40
|
-
def User.home=(path)
|
47
|
+
def User.home=(path) # :nodoc:
|
41
48
|
User.new().home = path
|
42
49
|
end
|
43
50
|
|
51
|
+
# Pass an executable or binary file name and find out if that file exists in the system
|
52
|
+
# path or not
|
44
53
|
def User.in_path?(executable)
|
45
54
|
User.new().in_path?(executable)
|
46
55
|
end
|
56
|
+
|
57
|
+
# Retrieve the full path to an executable that exists in the user path
|
58
|
+
def User.get_exe_path(executable)
|
59
|
+
return User.new().get_exe_path(executable)
|
60
|
+
end
|
47
61
|
|
62
|
+
# Return the home path for the currently logged in user. If the user name is lbayes, this should be:
|
63
|
+
#
|
64
|
+
# Windows XP:: C:\Documents And Settings\lbayes
|
65
|
+
# Cygwin:: /cygdrive/c/Documents And Settings/lbayes
|
66
|
+
# OS X:: /Users/lbayes
|
67
|
+
# Linux:: ~/
|
48
68
|
def User.home
|
49
69
|
User.new().home
|
50
70
|
end
|
51
71
|
|
72
|
+
# Returns the home path for a named application based on the currently logged in user and operating system.
|
73
|
+
# If the user name is lbayes and the application name is Sprouts, this path will be:
|
74
|
+
#
|
75
|
+
# Windows XP:: C:\Documents And Settings\lbayes\Local Settings\Application Data\Sprouts
|
76
|
+
# Cygwin:: /cygdrive/c/Documents And Settings/Local Settings/Application Data/Sprouts
|
77
|
+
# OS X:: /Users/lbayes/Library/Sprouts
|
78
|
+
# Linux:: ~/.sprouts
|
52
79
|
def User.application_home(name)
|
53
80
|
return User.new().application_home(name)
|
54
81
|
end
|
55
82
|
|
83
|
+
# Returns the library path on the current system. This is the general path where all applications should
|
84
|
+
# store configuration or session data.
|
85
|
+
#
|
86
|
+
# Windows XP:: C:\Documents And Settings\lbayes\Local Settings\Application Data
|
87
|
+
# Cygwin:: /cygdrive/c/Documents And Settings/lbayes/Local Settings/Application Data
|
88
|
+
# OS X:: /Users/lbayes/Library
|
89
|
+
# Linux:: ~/
|
56
90
|
def User.library
|
57
91
|
return User.new().library
|
58
92
|
end
|
59
93
|
|
94
|
+
# Execute a named tool sprout. The full sprout name should be provided to the tool parameter, and
|
95
|
+
# a string of shell parameters that will be sent to the tool itself.
|
60
96
|
def User.execute(tool, options='')
|
61
97
|
return User.new().execute(tool, options)
|
62
98
|
end
|
99
|
+
|
100
|
+
def User.execute_silent(tool, options='')
|
101
|
+
return User.new().execute_silent(tool, options)
|
102
|
+
end
|
63
103
|
|
104
|
+
# Execute a named tool sprout as a new thread and return that thread
|
64
105
|
def User.execute_thread(tool, options='')
|
65
106
|
if(Log.debug)
|
66
107
|
return ThreadMock.new
|
@@ -69,25 +110,26 @@ module PatternPark
|
|
69
110
|
end
|
70
111
|
end
|
71
112
|
|
113
|
+
# Clean a path string in such a way that works for each platform. For example, Windows doesn't like
|
114
|
+
# it when we backslash to escape spaces in a path because that is the character they use as a delimiter.
|
115
|
+
# And OS X doesn't really like it when we wrap paths in quotes.
|
72
116
|
def User.clean_path(path)
|
73
117
|
return User.new().clean_path(path)
|
74
118
|
end
|
75
119
|
|
76
|
-
# Called from Sprout.init_values...
|
77
|
-
def User.init_values
|
78
|
-
@@user = nil
|
79
|
-
@@home = nil
|
80
|
-
end
|
81
120
|
end
|
82
121
|
|
83
122
|
#############################
|
84
123
|
# UnixUser class
|
85
|
-
class UnixUser
|
124
|
+
class UnixUser # :nodoc:
|
86
125
|
|
87
126
|
def initialize
|
88
|
-
|
127
|
+
setup_user
|
89
128
|
@home = nil
|
90
129
|
end
|
130
|
+
|
131
|
+
def setup_user
|
132
|
+
end
|
91
133
|
|
92
134
|
def home=(path)
|
93
135
|
@home = path
|
@@ -108,7 +150,7 @@ module PatternPark
|
|
108
150
|
|
109
151
|
begin
|
110
152
|
return @home = File.expand_path("~")
|
111
|
-
rescue StandardError
|
153
|
+
rescue StandardError
|
112
154
|
if File::ALT_SEPARATOR
|
113
155
|
return @home = "C:\\"
|
114
156
|
else
|
@@ -119,9 +161,11 @@ module PatternPark
|
|
119
161
|
|
120
162
|
def get_exe_path(executable)
|
121
163
|
paths = get_paths
|
164
|
+
file = nil
|
122
165
|
paths.each do |path|
|
123
|
-
|
124
|
-
|
166
|
+
file = File.join(path, executable)
|
167
|
+
if(File.exists?(file))
|
168
|
+
return file
|
125
169
|
end
|
126
170
|
end
|
127
171
|
return nil
|
@@ -149,19 +193,11 @@ module PatternPark
|
|
149
193
|
end
|
150
194
|
end
|
151
195
|
|
152
|
-
def get_process_runner(command)
|
153
|
-
return ProcessRunner.new(command)
|
154
|
-
end
|
155
|
-
|
156
196
|
def execute(tool, options='')
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
target = tool.archive_path
|
162
|
-
end
|
163
|
-
Log.puts(">> Execute: #{File.basename(target)} #{options}")
|
164
|
-
runner = get_process_runner("#{clean_path(target)} #{options}")
|
197
|
+
Log.puts(">> Execute: #{File.basename(tool)} #{options}")
|
198
|
+
tool = clean_path(tool)
|
199
|
+
runner = ProcessRunner.new("#{tool} #{options}")
|
200
|
+
|
165
201
|
result = runner.read
|
166
202
|
error = runner.read_err
|
167
203
|
if(result.size > 0)
|
@@ -172,6 +208,11 @@ module PatternPark
|
|
172
208
|
end
|
173
209
|
end
|
174
210
|
|
211
|
+
def execute_silent(tool, options='')
|
212
|
+
tool = clean_path(tool)
|
213
|
+
return ProcessRunner.new("#{tool} #{options}")
|
214
|
+
end
|
215
|
+
|
175
216
|
def execute_thread(tool, options='')
|
176
217
|
return Thread.new {
|
177
218
|
execute(tool, options)
|
@@ -197,7 +238,7 @@ module PatternPark
|
|
197
238
|
end
|
198
239
|
end
|
199
240
|
|
200
|
-
class OSXUser < UnixUser
|
241
|
+
class OSXUser < UnixUser # :nodoc:
|
201
242
|
@@LIBRARY = 'Library'
|
202
243
|
|
203
244
|
def library
|
@@ -214,14 +255,17 @@ module PatternPark
|
|
214
255
|
end
|
215
256
|
end
|
216
257
|
|
217
|
-
class WinUser < UnixUser
|
258
|
+
class WinUser < UnixUser # :nodoc:
|
218
259
|
@@LOCAL_SETTINGS = "Local\ Settings"
|
219
260
|
@@APPLICATION_DATA = "Application\ Data"
|
220
261
|
|
221
262
|
def initialize
|
222
|
-
|
263
|
+
super
|
223
264
|
@home = nil
|
224
265
|
end
|
266
|
+
|
267
|
+
def setup_user
|
268
|
+
end
|
225
269
|
|
226
270
|
def home
|
227
271
|
usr = super
|
@@ -258,14 +302,17 @@ module PatternPark
|
|
258
302
|
end
|
259
303
|
end
|
260
304
|
|
261
|
-
class CygwinUser < WinUser
|
305
|
+
class CygwinUser < WinUser # :nodoc:
|
262
306
|
|
263
307
|
def initialize
|
264
|
-
|
308
|
+
super
|
265
309
|
@home = nil
|
266
310
|
@win_home = nil
|
267
311
|
@win_home_cyg_path = nil
|
268
312
|
end
|
313
|
+
|
314
|
+
def setup_user
|
315
|
+
end
|
269
316
|
|
270
317
|
def clean_path(path)
|
271
318
|
if(path.index(' '))
|
@@ -294,7 +341,7 @@ module PatternPark
|
|
294
341
|
|
295
342
|
end
|
296
343
|
|
297
|
-
class VistaUser < WinUser
|
344
|
+
class VistaUser < WinUser # :nodoc:
|
298
345
|
def home
|
299
346
|
profile = ENV['USERPROFILE']
|
300
347
|
if(profile)
|
@@ -304,7 +351,7 @@ module PatternPark
|
|
304
351
|
end
|
305
352
|
end
|
306
353
|
|
307
|
-
class ThreadMock
|
354
|
+
class ThreadMock # :nodoc:
|
308
355
|
def alive?
|
309
356
|
return false
|
310
357
|
end
|
data/lib/sprout/version.rb
CHANGED
@@ -0,0 +1,61 @@
|
|
1
|
+
|
2
|
+
module Sprout
|
3
|
+
class ZipUtil #:nodoc:
|
4
|
+
|
5
|
+
# Pack up an archive from a directory on disk
|
6
|
+
def self.pack(input, archive, excludes)
|
7
|
+
Zip::ZipFile.open(archive, Zip::ZipFile::CREATE) do |zip|
|
8
|
+
add_file_to_zip(zip, input, excludes)
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
# Unpack an archive to a directory on disk
|
13
|
+
def self.unpack(archive, destination)
|
14
|
+
Zip::ZipFile.open(archive) do |zip|
|
15
|
+
unpack_file(zip, destination)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
def self.unpack_file(zip, destination, path='')
|
20
|
+
if(zip.file.file?(path))
|
21
|
+
File.open(File.join(destination, path), 'w') do |dest|
|
22
|
+
zip.file.open(path) do |src|
|
23
|
+
dest.write src.read
|
24
|
+
end
|
25
|
+
end
|
26
|
+
else
|
27
|
+
Dir.mkdir(File.join(destination, path))
|
28
|
+
zip.dir.foreach(path) do |dir|
|
29
|
+
unpack_file(zip, destination, File.join(path, dir))
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
def self.add_file_to_zip(zip, path, excludes)
|
35
|
+
if(File.directory?(path))
|
36
|
+
zip.dir.mkdir(path)
|
37
|
+
Dir.open(path).each do |child|
|
38
|
+
if(!excluded?(child, excludes))
|
39
|
+
add_file_to_zip(zip, File.join(path, child), excludes)
|
40
|
+
end
|
41
|
+
end
|
42
|
+
else
|
43
|
+
File.open(path) do |src|
|
44
|
+
zip.file.open(path, 'w') do |dest|
|
45
|
+
dest.write src.read
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
def self.excluded?(str, excludes)
|
52
|
+
excludes.each do |exc|
|
53
|
+
if(str == exc)
|
54
|
+
return true
|
55
|
+
end
|
56
|
+
end
|
57
|
+
return false
|
58
|
+
end
|
59
|
+
|
60
|
+
end
|
61
|
+
end
|