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
File without changes
|
data/TODO
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
|
2
|
+
---------------------------------
|
3
|
+
In the interest of being a better member of our growing community,
|
4
|
+
I have extracted the contents of this file to the googlecode site at:
|
5
|
+
|
6
|
+
http://code.google.com/p/projectsprouts/issues/list?q=label:Beta1.0&can=2
|
7
|
+
|
8
|
+
Please feel free to check over the available issues and see if any look appealing!
|
9
|
+
|
10
|
+
If you're considering a contribution, please check in on our mailing list first just to be sure.
|
11
|
+
(projectsprouts@googlegroups.com)
|
12
|
+
|
data/bin/sprout
CHANGED
@@ -9,177 +9,120 @@ rescue LoadError
|
|
9
9
|
# no rubygems to load, so we fail silently
|
10
10
|
end
|
11
11
|
|
12
|
-
|
12
|
+
$:.push(File.dirname(__FILE__) + '/../lib')
|
13
13
|
require 'sprout'
|
14
|
-
|
15
|
-
|
14
|
+
require 'sprout/generator'
|
15
|
+
require 'optparse'
|
16
16
|
|
17
17
|
OPTIONS = {
|
18
|
-
:
|
18
|
+
:sources => [],
|
19
19
|
:project_name => nil,
|
20
20
|
:sprout_name => nil,
|
21
|
-
:
|
22
|
-
:
|
23
|
-
:clean => false
|
21
|
+
:requirements => nil,
|
22
|
+
:remove_all => false
|
24
23
|
}
|
25
24
|
|
25
|
+
def fail_with(opts, message)
|
26
|
+
puts "[ERROR] #{message}"
|
27
|
+
puts ""
|
28
|
+
puts opts
|
29
|
+
exit
|
30
|
+
end
|
31
|
+
|
26
32
|
parser = OptionParser.new do |opts|
|
27
33
|
opts.banner = <<BANNER
|
28
|
-
|
29
|
-
If you would like to edit or remove installed sprout contents or definitions,
|
30
|
-
simply navigate to the following location:
|
34
|
+
Sprout is an open-source, cross-platform project generation and configuration tool
|
31
35
|
|
32
|
-
#{
|
36
|
+
Usage: #{File.basename($0)} [options] [ProjectName]
|
33
37
|
|
34
|
-
|
38
|
+
Examples:
|
35
39
|
|
36
|
-
|
37
|
-
|
38
|
-
opts.separator ""
|
39
|
-
opts.on("-s", "--sprout=NAME", String,
|
40
|
-
"[DEPRECATED] The name of the sprout to create (e.g., as2 as3, haxe, or mxml)"
|
41
|
-
) do |name|
|
42
|
-
OPTIONS[:sprout_name] = name
|
43
|
-
end
|
44
|
-
opts.on("-n", "--name=NAME", String,
|
45
|
-
"The name of the sprout to create (e.g., as2 as3, haxe, or mxml)"
|
46
|
-
) do |name|
|
47
|
-
OPTIONS[:sprout_name] = name
|
48
|
-
end
|
49
|
-
opts.on("-l", "--locations=URL[,URL2,URL3]", String,
|
50
|
-
"Insert url(s) into the http search path for sprout definitions"
|
51
|
-
) do |name|
|
52
|
-
OPTIONS[:locations] = name.split(',')
|
53
|
-
end
|
54
|
-
opts.on("-f", "--force",
|
55
|
-
"Force project creation, overwrite if necessary"
|
56
|
-
) do |force|
|
57
|
-
OPTIONS[:force] = force
|
58
|
-
end
|
59
|
-
opts.on("-u", "--update",
|
60
|
-
"Update the local versions of all referenced sprouts"
|
61
|
-
) do
|
62
|
-
OPTIONS[:update] = true
|
63
|
-
end
|
64
|
-
opts.on("-h", "--help",
|
65
|
-
"Show this help message.") { puts opts; exit }
|
66
|
-
opts.parse!(ARGV)
|
67
|
-
|
68
|
-
if(OPTIONS[:sprout_name].nil? && OPTIONS[:update])
|
69
|
-
OPTIONS[:sprout_name] = ARGV.pop
|
70
|
-
else
|
71
|
-
OPTIONS[:project_name] = ARGV.pop
|
72
|
-
end
|
73
|
-
end
|
40
|
+
Create a new ActionScript 3.0 project named 'SomeProject':
|
41
|
+
#{File.basename($0)} -n as3 SomeProject
|
74
42
|
|
75
|
-
|
43
|
+
Create a new ActionScript 2.0 project named 'OtherProject':
|
44
|
+
#{File.basename($0)} -n as2 OtherProject
|
76
45
|
|
77
|
-
|
78
|
-
|
79
|
-
locations = OPTIONS[:locations]
|
80
|
-
update = OPTIONS[:update]
|
81
|
-
clean = OPTIONS[:clean]
|
82
|
-
|
83
|
-
#############################################
|
46
|
+
Remove all Sprout gems and cached files:
|
47
|
+
#{File.basename($0)} -R
|
84
48
|
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
end
|
49
|
+
Options are:
|
50
|
+
BANNER
|
51
|
+
opts.separator ""
|
89
52
|
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
end
|
53
|
+
opts.on("-n", "--name NAME", String, "The name of the sprout bundle whose project generator will be executed (e.g., as2 or as3)") do |name|
|
54
|
+
OPTIONS[:sprout_name] = name
|
55
|
+
end
|
94
56
|
|
95
|
-
|
96
|
-
|
97
|
-
[WARNING] Are you sure you want to clobber all local sprout definitions referenced by "#{sprout_name}"? [Yn]
|
98
|
-
EOF
|
99
|
-
puts msg
|
100
|
-
response = gets.chomp!
|
101
|
-
if(response == '' || response.downcase == 'y')
|
102
|
-
Sprout.update = true
|
103
|
-
else
|
104
|
-
Log.puts("[ERROR] Sprout execution terminated, please try again.")
|
105
|
-
exit
|
57
|
+
opts.on('--source [URL]', String, "Use URL as the remote source for gems") do |source|
|
58
|
+
OPTIONS[:sources] << source
|
106
59
|
end
|
107
|
-
end
|
108
60
|
|
109
|
-
|
110
|
-
|
61
|
+
opts.on('-r', '--requirements REQUIREMENTS', String, "The specific gem version requirements for the named bundle (e.g., 0.3.2)") do |requirements|
|
62
|
+
OPTIONS[:requirements] = requirements
|
63
|
+
end
|
111
64
|
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
require rakefile
|
116
|
-
name = ProjectModel.instance.project_name
|
117
|
-
puts 'rakefile: ' + rakefile
|
118
|
-
else
|
119
|
-
raise LoadError.new('rakefile was not found')
|
120
|
-
end
|
121
|
-
rescue LoadError
|
122
|
-
name = File.basename(dir).capitalize
|
65
|
+
opts.on("-R", "--remove-all", "Remove all sprout gems and cached files") do
|
66
|
+
OPTIONS[:remove_all] = true
|
67
|
+
Sprout::Sprout.remove_all
|
123
68
|
end
|
124
69
|
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
puts "(3) End Process: OOPs, I'll start over..."
|
129
|
-
if(name != nil && name != '')
|
130
|
-
puts "(4) Use Inferred Name: '#{name}' and load '#{sprout_name}' into #{dir}"
|
70
|
+
opts.on("-v", "--version", "Display the installed version of the sprout gem") do |version|
|
71
|
+
puts "sprout #{Sprout::VERSION::STRING}"
|
72
|
+
exit
|
131
73
|
end
|
132
74
|
|
133
|
-
|
75
|
+
opts.on("-h", "--help", "Show this help message.") do
|
76
|
+
puts opts
|
77
|
+
exit
|
78
|
+
end
|
134
79
|
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
when "2" :
|
140
|
-
when "4" :
|
141
|
-
project_name = name
|
142
|
-
else
|
143
|
-
Log.puts("[ERROR] Sprout execution terminated, please try again.")
|
144
|
-
exit
|
80
|
+
opts.parse!(ARGV)
|
81
|
+
|
82
|
+
if(OPTIONS[:sources].size > 0)
|
83
|
+
set_sources OPTIONS[:sources]
|
145
84
|
end
|
146
85
|
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
if(
|
151
|
-
|
152
|
-
Sprout.project_path = path
|
153
|
-
if(File.exists?(path))
|
154
|
-
if(OPTIONS[:force])
|
155
|
-
FileUtils.rm_rf(path)
|
156
|
-
else
|
157
|
-
puts "[WARNING] Are you sure you want to destroy #{path} and all of it's contents? [Yn]"
|
158
|
-
result = gets.chomp!
|
159
|
-
if(result.downcase == 'y' || result == '')
|
160
|
-
FileUtils.rm_rf(path)
|
161
|
-
else
|
162
|
-
puts "[ERROR] Folder already exists at: #{path}, remove it or use -f to force project creation."
|
163
|
-
exit
|
86
|
+
if(ARGV.size > 0)
|
87
|
+
if(OPTIONS[:sprout_name])
|
88
|
+
OPTIONS[:project_name] = ARGV.pop
|
89
|
+
if(OPTIONS[:project_name] == "=")
|
90
|
+
fail_with(opts, "Invalid project name #{OPTIONS[:project_name]}")
|
164
91
|
end
|
92
|
+
else
|
93
|
+
fail_with(opts, "You must provide a sprout name argument such as, '-n as2' or '-n as3'")
|
165
94
|
end
|
95
|
+
elsif(OPTIONS[:remove_all])
|
96
|
+
exit
|
97
|
+
else
|
98
|
+
fail_with(opts, "Expected a sprout bundle name and project name like: 'sprout -n as2 SomeProject'")
|
166
99
|
end
|
167
|
-
|
168
|
-
str = ''
|
169
|
-
80.times do
|
170
|
-
str += '-'
|
171
|
-
end
|
172
|
-
puts str
|
173
|
-
puts ">> Creating Sprout #{sprout_name} at #{path}"
|
174
|
-
Sprout.project_name = project_name
|
175
|
-
TemplateResolver.instance.replace_all = true
|
176
|
-
sprout = Sprout.load(sprout_name)
|
177
|
-
sprout.execute
|
100
|
+
|
178
101
|
end
|
179
102
|
|
180
|
-
|
181
|
-
|
182
|
-
|
103
|
+
#############################################
|
104
|
+
|
105
|
+
sprout_name = OPTIONS[:sprout_name]
|
106
|
+
sprout_requirements = OPTIONS[:requirements]
|
107
|
+
project_name = OPTIONS[:project_name]
|
108
|
+
|
109
|
+
#############################################
|
110
|
+
|
111
|
+
puts ">> Creating new project '#{project_name}' with #{sprout_name}"
|
112
|
+
Sprout::Sprout.project_name = project_name
|
113
|
+
|
114
|
+
begin
|
115
|
+
# Fallback if a version was specified
|
116
|
+
if(sprout_requirements)
|
117
|
+
sprout(sprout_name, sprout_requirements)
|
118
|
+
end
|
119
|
+
# Try to run the generator against user home and existing gems first
|
120
|
+
Sprout::Sprout.generate(sprout_name, 'project', [project_name])
|
121
|
+
rescue Rails::Generator::GeneratorError
|
122
|
+
# Failing that, try to download a sprout gem by name
|
123
|
+
sprout(sprout_name, sprout_requirements)
|
124
|
+
# Then try again....
|
125
|
+
Sprout::Sprout.generate(sprout_name, 'project', [project_name])
|
183
126
|
end
|
184
127
|
|
185
|
-
Log.flush
|
128
|
+
Sprout::Log.flush
|
data/doc/Bundle
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
|
2
|
+
A Sprout Bundle is a collection of Ruby code that supports a particular interest or technology. At the time of this writing, we have two bundles available.
|
3
|
+
|
4
|
+
* ActionScript 2 Bundle (link[link:files/bundles/as2/README.html]) which supports ActionScript 2.0 development
|
5
|
+
* ActionScript 3 Bundle (link[link:files/bundles/as3/README.html]) which supports ActionScript 3.0, MXML and AIR development
|
6
|
+
|
7
|
+
Bundles are the named entry point that the +sprout+ shell tool uses to find project generators[link:files/doc/Generator.html].
|
8
|
+
|
9
|
+
Bundles should be packaged and published to the RubyForge gem repository with very specific names as follows:
|
10
|
+
|
11
|
+
sprout-#{bundle_name}-bundle where ${bundle_name} is what will be given to the -n parameter of the +sprout+ gem.
|
12
|
+
|
13
|
+
The as3 bundle is released as sprout-as3-bundle on RubyForge, but we can simply enter the short name when creating new as3 projects.
|
14
|
+
|
data/doc/Generator
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
A SproutGenerator is a set of specifically configured folders and files that have been placed in a particular, expected location on disk.
|
2
|
+
The Sprout generator feature is a minor modification to the standard Rails generators.
|
3
|
+
|
4
|
+
Sprouts modifies the underlying Rails Generator implementation mainly by changing where it looks for available, named generators. This was an importat change that will help prevent Sprout projects from clobbering generators that are intended for Rails support and vice versa. We also have a slightly different requirement in that we need support for multiple languages or technologies while Rails is able to simply expect that it's generating Ruby code.
|
5
|
+
|
6
|
+
Generators can exist in multiple different locations on disk, to learn how to create a new generator, see the Rails documentation[http://wiki.rubyonrails.org/rails/pages/UnderstandingGenerators].
|
7
|
+
|
8
|
+
To use a new or existing generator, simply enter it's name from within a project after calling
|
9
|
+
script/generate
|
10
|
+
|
11
|
+
When a string is passed to the generate command, sprouts will look in the following locations in the following order with 'name' being the generator name that you have requested:
|
12
|
+
* #{project_path}/generators/#{name}
|
13
|
+
* #{project_path}/script/generators/#{name}
|
14
|
+
* #{project_path}/vendor/generators/#{name}
|
15
|
+
* #{Sprout::Sprout.sprout_cache}/generators/#{Sprout::ProjectModel.language}/#{name}
|
16
|
+
* All Rubygems with a name ending with '-bundle' and with contents that match '/lib/sprout/**/generators/[name]'
|
17
|
+
|
18
|
+
This means that when you have a new project and enter:
|
19
|
+
script/generate foo
|
20
|
+
|
21
|
+
We will first look in your project for, 'generators/foo', 'script/generators/foo' and 'vendor/generators/foo'.
|
22
|
+
|
23
|
+
Assuming no viable generator is found in your project, we will then look in your Sprout::Sprout sprout_cache for a folder named 'generators/foo'.
|
24
|
+
|
25
|
+
Assuming no viable generator is found in your system wide path, we will begin looking inside of installed Ruby Gems. The expected gem will have a file at:
|
26
|
+
|
27
|
+
lib/sprout/**/generators/foo/foo_generator.rb
|
28
|
+
|
29
|
+
If no named generator is found in any of these places an exception will be encountered.
|
30
|
+
|
31
|
+
Sprouts generators can be initiated from one of two places, either from a project directory with script/generate or directly from the Sprout gem.
|
32
|
+
|
33
|
+
When executing generators directly from the Sprout gem, you must send in a bundle base name and know that only 'project' generators found in that bundle will be executed.
|
34
|
+
|
35
|
+
When executing generators from a project, the Sprout::ProjectModel language parameter is used to determine the bundle (if necessary), and then the Generator name is used to execute any found generator.
|
data/doc/Library
ADDED
@@ -0,0 +1,63 @@
|
|
1
|
+
|
2
|
+
A Library is simply shared code. Some libraries are distributed with only source, others are only pre-compiled binaries (SWC for ActionScript libraries), and still others are made available in both forms.
|
3
|
+
|
4
|
+
The Sprout::LibraryTask will download and copy a remote library sprout gem.
|
5
|
+
The remote archive can include (or reference) either source or a pre-compiled
|
6
|
+
file. For ActionScript libraries, this would be a SWC file.
|
7
|
+
|
8
|
+
This task is integrated with some of the compiler tasks in such
|
9
|
+
a way that if an Sprout::MXMLCTask has any number of library tasks in
|
10
|
+
it's prerequisites list, each of those libraries will be added
|
11
|
+
to the compiler directive appropriately.
|
12
|
+
|
13
|
+
Following is a simple example of a library task. Using only
|
14
|
+
this simple task definition, the Adobe corelib library sprout gem
|
15
|
+
will be downloaded, installed and copied to your Sprout::ProjectModel +lib_dir+.
|
16
|
+
|
17
|
+
library :corelib
|
18
|
+
|
19
|
+
By adding this named task as a prerequisite to your compilation task,
|
20
|
+
that SWC will also be added to the Sprout::MXMLCTask +library_path+ parameter.
|
21
|
+
|
22
|
+
mxmlc 'bin/SomeProject.swf' => :corelib
|
23
|
+
|
24
|
+
You can also specify a particular library gem version if the library
|
25
|
+
has changed since your project began.
|
26
|
+
|
27
|
+
library :asunit3 do |t|
|
28
|
+
t.version = '3.0.1'
|
29
|
+
end
|
30
|
+
|
31
|
+
This will ensure that only that particular library version is used for this project.
|
32
|
+
|
33
|
+
You may want to refer to a library using a particular task name, but have it
|
34
|
+
use a different library sprout gem. This can be done using the gem_name parameter
|
35
|
+
as follows:
|
36
|
+
|
37
|
+
library :asunit do |t|
|
38
|
+
t.gem_name = 'sprout-asunit3-library'
|
39
|
+
end
|
40
|
+
|
41
|
+
This may be useful because now the AsUnit[http://www.asunit.org] sources will be installed to:
|
42
|
+
lib/asunit
|
43
|
+
instead of:
|
44
|
+
lib/asunit3
|
45
|
+
and you can now depend on this library as simply +:asunit+ in your compiler tasks.
|
46
|
+
|
47
|
+
You can easily create your own library gems using the Sprout::GemWrapTask and then
|
48
|
+
refer to them by gem name.
|
49
|
+
|
50
|
+
In order to share your library tasks, you will need to
|
51
|
+
do one of the following:
|
52
|
+
|
53
|
+
* Tell interested developers to manually install your library gem
|
54
|
+
* Upload your gem to any Rubyforge[http://www.rubyforge.org] project file releases area.
|
55
|
+
If your gem name begins with 'sprout-' and ends with '-library', you (and others) can refer to it by only
|
56
|
+
the string in between that prefix and suffix. Otherwise, you (and others) will always have
|
57
|
+
to set the gem_name parameter to the full name of your custom library.
|
58
|
+
* Submit your library for inclusion from the ProjectSprouts[http://www.projectsprouts.org] project.
|
59
|
+
* Add your gem to your own custom gem_server[http://rambleon.org/2007/04/19/creating-your-own-gem-server/], and set up your rakefiles to pull from that server
|
60
|
+
|
61
|
+
You can search for all available libraries as follows:
|
62
|
+
gem search -r sprout-*library
|
63
|
+
Only results that begin with 'sprout-' are known, valid libraries.
|
data/doc/Task
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
In Sprouts, a Task is referring to a Rake[http://rake.rubyforge.org/] Task.
|
2
|
+
|
3
|
+
Rake is the automated build to written in Ruby. This tool is similar to Ant[http://ant.apache.org/] and Make[http://www.gnu.org/software/make/] if you're familiar with those technologies.
|
4
|
+
|
5
|
+
The main thing that differentiates Rake from it's competitors is the fact that Rake tasks are defined and configured in Ruby code rather than XML or C. This lets us more easily avoid repetition throughout a rakefile, and we gain the full power of the Ruby language to apply to our build scripts.
|
6
|
+
|
7
|
+
Essentially, Rake allows us to write and maintain much smaller, more digestible build scripts.
|
8
|
+
|
9
|
+
To learn more about Rake, check out Martin Fowler's seminal article[http://martinfowler.com/articles/rake.html] on the subject.
|
10
|
+
|
11
|
+
At the time of this writing, Sprouts makes the following Rake tasks available:
|
12
|
+
* Core Sprout::SFTPTask
|
13
|
+
* Core Sprout::ZipTask
|
14
|
+
* Core Sprout::LibraryTask
|
15
|
+
* As3Bundle Sprout::AsDocTask
|
16
|
+
* As3Bundle Sprout::AsUnitTask
|
17
|
+
* As3Bundle Sprout::COMPCTask
|
18
|
+
* As3Bundle Sprout::MXMLCTask
|
19
|
+
* As2Bundle Sprout::MTASCTask
|
20
|
+
* As2Bundle Sprout::SWFMillTask
|
21
|
+
|
data/doc/Tool
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
|
2
|
+
A Tool is a Ruby Gem that usually refers to an executable or binary application.
|
3
|
+
These applications are either natively cross platform, or the Ruby Gem should include a
|
4
|
+
YAML document that tells Sprouts where to go in order to get the appropriate binary for
|
5
|
+
which platform the user is currently running.
|
6
|
+
|
7
|
+
CLI Tools are usually referenced by subclasses of Sprout::ToolTask.
|
8
|
+
|
9
|
+
Once installed, many Tool Sprouts are made available from your path. For example
|
10
|
+
if you install the sprout-mtasc-tool gem, from that point forward you can execute mtasc
|
11
|
+
from the terminal as follows:
|
12
|
+
|
13
|
+
mtasc -help # Should throw an error
|
14
|
+
sudo gem install sprout-mtasc-tool
|
15
|
+
mtasc -help # Should download and execute mtasc
|
16
|
+
|
17
|
+
Using just Sprout tools by themselves, we now have have the ability to install and manage
|
18
|
+
requisite executables across platforms with zero configuration.
|
19
|
+
|
20
|
+
In reality, 'Tool Sprouts' are actually nothing more than a naming convention and expected gem configuration, but once those requirements are met, the core Sprout::Sprout can do some important work with them.
|
data/lib/platform.rb
CHANGED
@@ -1,8 +1,7 @@
|
|
1
1
|
#
|
2
2
|
# platform.rb: naive platform detection for Ruby
|
3
|
-
# author: Matt Mower
|
3
|
+
# author: Matt Mower
|
4
4
|
#
|
5
|
-
|
6
5
|
# == Platform
|
7
6
|
#
|
8
7
|
# Platform is a simple module which parses the Ruby constant
|
@@ -38,7 +37,7 @@
|
|
38
37
|
#
|
39
38
|
# ruby platform.rb
|
40
39
|
#
|
41
|
-
module Platform
|
40
|
+
module Platform #:nodoc:
|
42
41
|
os = nil
|
43
42
|
impl = nil
|
44
43
|
arch = nil
|
data/lib/progress_bar.rb
CHANGED
@@ -8,15 +8,19 @@
|
|
8
8
|
# You can redistribute it and/or modify it under the terms
|
9
9
|
# of Ruby's license.
|
10
10
|
#
|
11
|
+
# Modified by Luke Bayes to support progress display on
|
12
|
+
# multiple simultaneous connections
|
11
13
|
|
12
|
-
|
14
|
+
require 'singleton'
|
15
|
+
|
16
|
+
class ProgressBar # :nodoc:[all]
|
13
17
|
VERSION = "0.9"
|
14
18
|
def self.new(title, total)
|
15
19
|
return ProgressBarManager.instance.add(title, total)
|
16
20
|
end
|
17
21
|
end
|
18
22
|
|
19
|
-
class ProgressBarImpl
|
23
|
+
class ProgressBarImpl # :nodoc:[all]
|
20
24
|
|
21
25
|
def initialize (title, total, out = STDERR)
|
22
26
|
@title = title
|
@@ -42,7 +46,6 @@ class ProgressBarImpl
|
|
42
46
|
:title_width,
|
43
47
|
:bar_mark
|
44
48
|
|
45
|
-
private
|
46
49
|
def fmt_bar
|
47
50
|
bar_width = do_percentage * @terminal_width / 100
|
48
51
|
sprintf("|%s%s|",
|
@@ -104,15 +107,15 @@ class ProgressBarImpl
|
|
104
107
|
if @current == 0
|
105
108
|
"ETA: --:--:--"
|
106
109
|
else
|
107
|
-
|
108
|
-
|
109
|
-
sprintf("ETA: %s", format_time(
|
110
|
+
elapsed_time = Time.now - @start_time
|
111
|
+
estimated_time = elapsed_time * @total / @current - elapsed_time
|
112
|
+
sprintf("ETA: %s", format_time(estimated_time))
|
110
113
|
end
|
111
114
|
end
|
112
115
|
|
113
116
|
def elapsed
|
114
|
-
|
115
|
-
sprintf("Time: %s", format_time(
|
117
|
+
elapsed_time = Time.now - @start_time
|
118
|
+
sprintf("Time: %s", format_time(elapsed_time))
|
116
119
|
end
|
117
120
|
|
118
121
|
def eol
|
@@ -128,14 +131,18 @@ class ProgressBarImpl
|
|
128
131
|
end
|
129
132
|
|
130
133
|
def get_width
|
131
|
-
return 80
|
134
|
+
# return 80
|
132
135
|
# FIXME: I don't know how portable it is.
|
133
136
|
default_width = 80
|
134
137
|
begin
|
135
138
|
tiocgwinsz = 0x5413
|
136
139
|
data = [0, 0, 0, 0].pack("SSSS")
|
137
140
|
if @out.ioctl(tiocgwinsz, data) >= 0 then
|
138
|
-
|
141
|
+
unpacked = data.unpack("SSSS")
|
142
|
+
cols = unpacked[1]
|
143
|
+
# Commented this because Aptana was complaining about
|
144
|
+
# The unused variables
|
145
|
+
# rows, cols, xpixels, ypixels = data.unpack("SSSS")
|
139
146
|
if cols >= 0 then cols else default_width end
|
140
147
|
else
|
141
148
|
default_width
|
@@ -153,10 +160,10 @@ class ProgressBarImpl
|
|
153
160
|
line = sprintf(@format, *arguments)
|
154
161
|
|
155
162
|
width = get_width
|
156
|
-
if
|
163
|
+
if(line.length == width - 1)
|
157
164
|
@out.print(line + eol)
|
158
165
|
@out.flush
|
159
|
-
elsif
|
166
|
+
elsif(line.length >= width)
|
160
167
|
@terminal_width = [@terminal_width - (line.length - width + 1), 0].max
|
161
168
|
if @terminal_width == 0 then @out.print(line + eol) else show end
|
162
169
|
else # line.length < width - 1
|
@@ -237,13 +244,27 @@ class ProgressBarImpl
|
|
237
244
|
end
|
238
245
|
end
|
239
246
|
|
240
|
-
|
247
|
+
# Used instead of $stderr when Log.debug == true
|
248
|
+
# This helps keep us from junking up unit test
|
249
|
+
# output with download status messages
|
250
|
+
class MockOutput # :nodoc:[all]
|
251
|
+
def print(str)
|
252
|
+
end
|
253
|
+
|
254
|
+
def puts(str)
|
255
|
+
end
|
256
|
+
|
257
|
+
def flush
|
258
|
+
end
|
259
|
+
end
|
260
|
+
|
261
|
+
class ReversedProgressBar < ProgressBar # :nodoc:[all]
|
241
262
|
def do_percentage
|
242
263
|
100 - super
|
243
264
|
end
|
244
265
|
end
|
245
266
|
|
246
|
-
class ProgressBarOutputStream
|
267
|
+
class ProgressBarOutputStream # :nodoc:[all]
|
247
268
|
attr_reader :title
|
248
269
|
|
249
270
|
def initialize(mgr)
|
@@ -265,7 +286,7 @@ class ProgressBarOutputStream
|
|
265
286
|
|
266
287
|
end
|
267
288
|
|
268
|
-
class ProgressBarManager
|
289
|
+
class ProgressBarManager # :nodoc:[all]
|
269
290
|
include Singleton
|
270
291
|
|
271
292
|
def initialize
|
@@ -276,9 +297,9 @@ class ProgressBarManager
|
|
276
297
|
end
|
277
298
|
|
278
299
|
def add(title, total1)
|
279
|
-
if(@bars[title])
|
280
|
-
raise
|
281
|
-
end
|
300
|
+
# if(@bars[title])
|
301
|
+
# raise StandardError.new
|
302
|
+
# end
|
282
303
|
@outs[title] = ProgressBarOutputStream.new(self)
|
283
304
|
@bars[title] = ProgressBarImpl.new(title, total1, @outs[title])
|
284
305
|
end
|
@@ -292,21 +313,16 @@ class ProgressBarManager
|
|
292
313
|
end
|
293
314
|
|
294
315
|
def flush
|
295
|
-
str = ""
|
296
|
-
|
297
316
|
@bars.keys.each do |title|
|
298
317
|
print(title)
|
299
318
|
end
|
300
319
|
|
301
|
-
finished = true
|
302
320
|
@bars.values.each do |bar|
|
303
321
|
if(bar.finished?)
|
304
322
|
print(bar.title)
|
305
323
|
@outio.print "\n"
|
306
324
|
@outs.delete(bar.title)
|
307
325
|
@bars.delete(bar.title)
|
308
|
-
else
|
309
|
-
finished = false
|
310
326
|
end
|
311
327
|
end
|
312
328
|
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
|
2
|
+
module Sprout
|
3
|
+
|
4
|
+
# accepts a destination path and a sprout specification
|
5
|
+
# and will download and unpack the platform-specific
|
6
|
+
# archives that are identified in the spec
|
7
|
+
class Builder # :nodoc:
|
8
|
+
|
9
|
+
class BuilderError < StandardError #:nodoc:
|
10
|
+
end
|
11
|
+
|
12
|
+
def self.build(file_targets_yaml, destination)
|
13
|
+
data = nil
|
14
|
+
|
15
|
+
File.open(file_targets_yaml, 'r') do |f|
|
16
|
+
data = f.read
|
17
|
+
end
|
18
|
+
|
19
|
+
usr = User.new
|
20
|
+
platform = usr.platform.to_s
|
21
|
+
|
22
|
+
targets = YAML.load(data)
|
23
|
+
targets.each do |target|
|
24
|
+
if(target.platform == 'universal' || target.platform == platform)
|
25
|
+
target.install_path = FileUtils.mkdir_p(destination)
|
26
|
+
target.resolve
|
27
|
+
return target
|
28
|
+
end
|
29
|
+
end
|
30
|
+
raise BuilderError.new("Sprout::Builder.build failed, unsupported platform or unexpected yaml")
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
@@ -0,0 +1,14 @@
|
|
1
|
+
# Shamelessly copied from Ruby On Rails
|
2
|
+
# Which happens to share the same MIT license!
|
3
|
+
|
4
|
+
=begin
|
5
|
+
#require "#{RAILS_ROOT}/config/environment"
|
6
|
+
require 'rubygems'
|
7
|
+
gem 'activesupport', '>= 2.0.2'
|
8
|
+
require 'generator'
|
9
|
+
#require 'generator/scripts/generate'
|
10
|
+
require 'sprout'
|
11
|
+
|
12
|
+
ARGV.shift if ['--help', '-h'].include?(ARGV[0])
|
13
|
+
Rails::Generator::Scripts::Generate.new.run(ARGV)
|
14
|
+
=end
|