sprout 0.7.246 → 1.0.0.pre
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/CHANGELOG.md +10 -0
- data/Gemfile +28 -0
- data/MIT-LICENSE +3 -2
- data/POSTINSTALL.rdoc +28 -0
- data/README.textile +152 -0
- data/bin/sprout +1 -131
- data/bin/sprout-generator +10 -0
- data/bin/sprout-library +11 -0
- data/bin/sprout-tool +10 -0
- data/lib/sprout.rb +4 -500
- data/lib/sprout/archive_unpacker.rb +122 -206
- data/lib/sprout/base.rb +90 -0
- data/lib/sprout/concern.rb +30 -0
- data/lib/sprout/dir.rb +23 -0
- data/lib/sprout/errors.rb +94 -0
- data/lib/sprout/executable.rb +496 -0
- data/lib/sprout/executable/boolean.rb +35 -0
- data/lib/sprout/executable/collection_param.rb +53 -0
- data/lib/sprout/executable/file_param.rb +53 -0
- data/lib/sprout/executable/files.rb +26 -0
- data/lib/sprout/executable/number.rb +10 -0
- data/lib/sprout/executable/param.rb +222 -0
- data/lib/sprout/executable/parameter_factory.rb +28 -0
- data/lib/sprout/executable/path.rb +21 -0
- data/lib/sprout/executable/paths.rb +21 -0
- data/lib/sprout/executable/string_param.rb +15 -0
- data/lib/sprout/executable/strings.rb +11 -0
- data/lib/sprout/executable/url.rb +10 -0
- data/lib/sprout/executable/urls.rb +10 -0
- data/lib/sprout/file_target.rb +76 -0
- data/lib/sprout/generator/base.rb +233 -0
- data/lib/sprout/generator/command.rb +67 -0
- data/lib/sprout/generator/directory_manifest.rb +49 -0
- data/lib/sprout/generator/file_manifest.rb +55 -0
- data/lib/sprout/generator/manifest.rb +13 -0
- data/lib/sprout/generator/template_manifest.rb +13 -0
- data/lib/sprout/generators/generator/generator_generator.rb +48 -0
- data/lib/sprout/generators/generator/templates/generator_class.rb +17 -0
- data/lib/sprout/generators/generator/templates/generator_executable +9 -0
- data/lib/sprout/generators/generator/templates/generator_template +1 -0
- data/lib/sprout/generators/generator/templates/generator_test.rb +37 -0
- data/lib/sprout/generators/generator/templates/generator_test_helper.rb +16 -0
- data/lib/sprout/generators/library/library_generator.rb +20 -0
- data/lib/sprout/generators/library/templates/library.gemspec +19 -0
- data/lib/sprout/generators/library/templates/library.rb +15 -0
- data/lib/sprout/generators/ruby/ruby_generator.rb +59 -0
- data/lib/sprout/generators/ruby/templates/ruby_base.rb +10 -0
- data/lib/sprout/generators/ruby/templates/ruby_executable +6 -0
- data/lib/sprout/generators/ruby/templates/ruby_gemfile +4 -0
- data/lib/sprout/generators/ruby/templates/ruby_input.rb +7 -0
- data/lib/sprout/generators/tool/templates/Gemfile +4 -0
- data/lib/sprout/generators/tool/templates/tool.gemspec +22 -0
- data/lib/sprout/generators/tool/templates/tool.rb +38 -0
- data/lib/sprout/generators/tool/tool_generator.rb +36 -0
- data/lib/sprout/library.rb +111 -0
- data/lib/sprout/log.rb +1 -0
- data/lib/sprout/platform.rb +71 -0
- data/lib/sprout/process_runner.rb +80 -40
- data/lib/sprout/progress_bar.rb +341 -0
- data/lib/sprout/rdoc_parser.rb +91 -0
- data/lib/sprout/remote_file_loader.rb +72 -50
- data/lib/sprout/remote_file_target.rb +44 -152
- data/lib/sprout/ruby_feature.rb +167 -0
- data/lib/sprout/specification.rb +197 -0
- data/lib/sprout/string.rb +19 -0
- data/lib/sprout/system.rb +35 -0
- data/lib/sprout/system/base_system.rb +225 -0
- data/lib/sprout/system/java_system.rb +9 -0
- data/lib/sprout/system/osx_system.rb +26 -0
- data/lib/sprout/system/unix_system.rb +72 -0
- data/lib/sprout/system/vista_system.rb +16 -0
- data/lib/sprout/system/win_nix_system.rb +41 -0
- data/lib/sprout/system/win_system.rb +76 -0
- data/lib/sprout/test/sprout_test_case.rb +211 -0
- data/lib/sprout/version.rb +9 -4
- data/rakefile.rb +85 -144
- data/script/console +10 -0
- data/script/destroy +14 -0
- data/script/generate +14 -0
- data/sprout.gemspec +26 -0
- data/test/fixtures/archive_unpacker/copyable/some_file.exe +0 -0
- data/test/fixtures/archive_unpacker/copyable/some_file.rb +0 -0
- data/test/fixtures/archive_unpacker/copyable/some_file.swc +0 -0
- data/test/fixtures/archive_unpacker/tgz/some folder.tgz +0 -0
- data/test/fixtures/archive_unpacker/tgz/some_file.tgz +0 -0
- data/test/fixtures/archive_unpacker/zip/some folder.zip +0 -0
- data/test/fixtures/archive_unpacker/zip/some_file.zip +0 -0
- data/test/fixtures/examples/app_generator.rb +127 -0
- data/test/fixtures/examples/echo_inputs.rb +151 -0
- data/test/fixtures/executable/echochamber_gem/bin/echochamber +3 -0
- data/test/fixtures/executable/echochamber_gem/echo_chamber.rb +10 -0
- data/test/fixtures/executable/flex3sdk_gem/flex3sdk.rb +11 -0
- data/test/fixtures/executable/flex3sdk_gem/mxmlc +3 -0
- data/test/fixtures/executable/flex3sdk_gem/mxmlc.bat +3 -0
- data/test/fixtures/executable/mxmlc.rb +805 -0
- data/test/fixtures/executable/params/input.as +0 -0
- data/test/fixtures/executable/params/input2.as +0 -0
- data/test/fixtures/executable/params/input3.as +0 -0
- data/test/fixtures/executable/params/mxmlc +5 -0
- data/test/fixtures/executable/path with spaces/input.as b/data/test/fixtures/executable/path with → spaces/input.as +0 -0
- data/test/fixtures/executable/path with spaces/input2.as b/data/test/fixtures/executable/path with → spaces/input2.as +0 -0
- data/test/fixtures/executable/path with spaces/input3.as b/data/test/fixtures/executable/path with → spaces/input3.as +0 -0
- data/test/fixtures/executable/paths/folder1/file1 +0 -0
- data/test/fixtures/executable/paths/folder1/file2 +0 -0
- data/test/fixtures/executable/paths/folder1/file3 +0 -0
- data/test/fixtures/executable/paths/folder2/file4 +0 -0
- data/test/fixtures/executable/paths/folder2/file5 +0 -0
- data/test/fixtures/executable/paths/folder3/file6 +0 -0
- data/test/fixtures/executable/src/Main.as +0 -0
- data/test/fixtures/executable/windows_line_endings +47 -0
- data/test/fixtures/generators/song_generator.rb +11 -0
- data/test/fixtures/generators/song_subclass/least_favorite.rb +10 -0
- data/test/fixtures/generators/song_subclass/templates/Song.txt +3 -0
- data/test/fixtures/generators/temp_generator.rb +24 -0
- data/test/fixtures/generators/templates/Main.as +9 -0
- data/test/fixtures/generators/templates/OtherFileTemplate +1 -0
- data/test/fixtures/generators/templates/SomeFile +1 -0
- data/test/fixtures/generators/templates/SomeSubclassFile +2 -0
- data/test/fixtures/generators/templates/Song.txt +3 -0
- data/test/fixtures/generators/templates/destroy +0 -0
- data/test/fixtures/generators/templates/generate +0 -0
- data/test/fixtures/library/archive/Archive.swc +0 -0
- data/test/fixtures/library/sources/lib/a/A.as +0 -0
- data/test/fixtures/library/sources/lib/b/B.as +0 -0
- data/test/fixtures/library/sources/src/Source.as +0 -0
- data/test/fixtures/process_runner/chmod_script.sh +3 -0
- data/test/fixtures/process_runner/dir with spaces/chmod_script.sh +3 -0
- data/test/fixtures/process_runner/failure +5 -0
- data/test/fixtures/process_runner/success +4 -0
- data/test/fixtures/remote_file_loader/md5/echochamber-test.zip +0 -0
- data/test/fixtures/remote_file_loader/md5/file_with_known_md5 +0 -0
- data/test/fixtures/remote_file_target/bin/echochamber +3 -0
- data/test/fixtures/remote_file_target/bin/echochamber.bat +3 -0
- data/test/fixtures/remote_file_target/echochamber-test.zip +0 -0
- data/test/fixtures/specification/asunit4.rb +25 -0
- data/test/fixtures/specification/ext/AsUnit-4.1.pre.swc +0 -0
- data/test/fixtures/specification/flashplayer.rb +30 -0
- data/test/fixtures/specification/flex4sdk.rb +72 -0
- data/test/fixtures/specification/flexunit4.sproutspec +17 -0
- data/test/fixtures/specification/lib/as3reflection/Reflection.as +0 -0
- data/test/fixtures/specification/src/AsUnit.as +0 -0
- data/test/fixtures/user/mxmlc_crlf +3 -0
- data/test/unit/archive_unpacker_test.rb +108 -0
- data/test/unit/boolean_param_test.rb +38 -0
- data/test/unit/executable_option_parser_test.rb +142 -0
- data/test/unit/executable_param_test.rb +76 -0
- data/test/unit/executable_test.rb +237 -0
- data/test/unit/fake_executable_task.rb +22 -0
- data/test/unit/fake_other_executable.rb +20 -0
- data/test/unit/fake_process_runner.rb +29 -0
- data/test/unit/file_param_test.rb +61 -0
- data/test/unit/file_target_test.rb +42 -0
- data/test/unit/files_param_test.rb +72 -0
- data/test/unit/generator_generator_test.rb +85 -0
- data/test/unit/generator_test.rb +333 -0
- data/test/unit/library_generator_test.rb +41 -0
- data/test/unit/library_test.rb +88 -0
- data/test/unit/osx_system_test.rb +20 -0
- data/test/unit/path_param_test.rb +43 -0
- data/test/unit/paths_param_test.rb +53 -0
- data/test/unit/platform_test.rb +76 -0
- data/test/unit/process_runner_test.rb +104 -0
- data/test/unit/rdoc_parser_test.rb +15 -0
- data/test/unit/remote_file_loader_test.rb +34 -0
- data/test/unit/remote_file_target_test.rb +105 -0
- data/test/unit/ruby_feature_test.rb +108 -0
- data/test/unit/ruby_generator_test.rb +70 -0
- data/test/unit/specification_test.rb +73 -0
- data/test/unit/sprout_test.rb +170 -0
- data/test/unit/sprout_test_helper.rb +18 -0
- data/test/unit/string_param_test.rb +19 -0
- data/test/unit/string_test.rb +20 -0
- data/test/unit/strings_param_test.rb +27 -0
- data/test/unit/test_helper.rb +1 -0
- data/test/unit/tool_generator_test.rb +43 -0
- data/test/unit/unix_system_test.rb +52 -0
- data/test/unit/user_test.rb +147 -0
- data/test/unit/vista_system_test.rb +40 -0
- data/test/unit/win_nix_system_test.rb +26 -0
- data/test/unit/win_system_test.rb +61 -0
- metadata +318 -113
- data/doc/Bundle +0 -14
- data/doc/Generator +0 -35
- data/doc/Library +0 -63
- data/doc/Task +0 -21
- data/doc/Tool +0 -20
- data/lib/platform.rb +0 -113
- data/lib/progress_bar.rb +0 -354
- data/lib/sprout/builder.rb +0 -51
- data/lib/sprout/bundle_resolver.rb +0 -349
- data/lib/sprout/commands/generate.rb +0 -9
- data/lib/sprout/dynamic_accessors.rb +0 -40
- data/lib/sprout/general_tasks.rb +0 -6
- data/lib/sprout/generator.rb +0 -7
- data/lib/sprout/generator/base_mixins.rb +0 -186
- data/lib/sprout/generator/named_base.rb +0 -227
- data/lib/sprout/project_model.rb +0 -278
- data/lib/sprout/simple_resolver.rb +0 -88
- data/lib/sprout/tasks/erb_resolver.rb +0 -118
- data/lib/sprout/tasks/gem_wrap_task.rb +0 -214
- data/lib/sprout/tasks/git_task.rb +0 -134
- data/lib/sprout/tasks/library_task.rb +0 -118
- data/lib/sprout/tasks/sftp_task.rb +0 -248
- data/lib/sprout/tasks/ssh_task.rb +0 -153
- data/lib/sprout/tasks/tool_task.rb +0 -836
- data/lib/sprout/tasks/zip_task.rb +0 -158
- data/lib/sprout/tool_task_model.rb +0 -19
- data/lib/sprout/user.rb +0 -415
- data/lib/sprout/version_file.rb +0 -89
- data/lib/sprout/zip_util.rb +0 -61
- data/samples/gem_wrap/rakefile.rb +0 -17
data/CHANGELOG.md
ADDED
data/Gemfile
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
source "http://rubygems.org"
|
2
|
+
|
3
|
+
gem "bundler", ">= 0.9.19"
|
4
|
+
gem "rake", ">= 0.8.7"
|
5
|
+
gem "rdoc", ">= 2.5.8"
|
6
|
+
gem "rubyzip", "0.9.4"
|
7
|
+
gem "archive-tar-minitar", "0.5.2"
|
8
|
+
|
9
|
+
if RUBY_PLATFORM =~ /mswin/i
|
10
|
+
gem "win32-open3", "0.2.5" # Win32 only
|
11
|
+
else
|
12
|
+
gem "open4", ">= 0.9.6" # All others
|
13
|
+
end
|
14
|
+
|
15
|
+
group :development do
|
16
|
+
gem "shoulda"
|
17
|
+
gem "mocha"
|
18
|
+
gem "flay"
|
19
|
+
gem "flog"
|
20
|
+
gem "heckle"
|
21
|
+
|
22
|
+
# rcov doesn't appear to install on
|
23
|
+
# debian/ubuntu. Boo. Ideas?
|
24
|
+
if RUBY_PLATFORM =~ /darwin/i
|
25
|
+
gem "rcov"
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
data/MIT-LICENSE
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
Copyright (c) 2007 Pattern Park
|
1
|
+
Copyright (c) 2007-2010 Pattern Park
|
2
2
|
|
3
3
|
Permission is hereby granted, free of charge, to any person obtaining
|
4
4
|
a copy of this software and associated documentation files (the
|
@@ -17,4 +17,5 @@ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
17
17
|
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
18
|
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
19
|
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
-
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
21
|
+
|
data/POSTINSTALL.rdoc
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
+++++++++++++++++++++++++++++++++++
|
2
|
+
Welcome to Project Sprouts!
|
3
|
+
|
4
|
+
If you want to experiment with Sprouts, try the following steps:
|
5
|
+
|
6
|
+
1) Create a new ActionScript 3 Project:
|
7
|
+
sprout -n as3 SomeProject
|
8
|
+
|
9
|
+
2) cd to the new directory:
|
10
|
+
cd SomeProject
|
11
|
+
|
12
|
+
3) Install all prerequisites:
|
13
|
+
bundle install
|
14
|
+
|
15
|
+
4) Compile and run the new project:
|
16
|
+
rake
|
17
|
+
|
18
|
+
5) Generate a class, test and suite:
|
19
|
+
script/generate utils.MathUtil
|
20
|
+
|
21
|
+
6) Compile and run the test harness:
|
22
|
+
rake test
|
23
|
+
|
24
|
+
If you have any questions or issues, please email us at:
|
25
|
+
|
26
|
+
projectsprouts@googlegroups.com
|
27
|
+
|
28
|
+
+++++++++++++++++++++++++++++++++++
|
data/README.textile
ADDED
@@ -0,0 +1,152 @@
|
|
1
|
+
h1. IMPORTANT NOTE
|
2
|
+
|
3
|
+
The mainline of this repository represents the next major release of Sprouts which involves a nearly complete rewrite.
|
4
|
+
|
5
|
+
To see, or edit the source code for the currently-released code, please check out the "0.7.241-release branch":http://github.com/lukebayes/project-sprouts/tree/0.7.241-release.
|
6
|
+
|
7
|
+
h1. Project Sprouts
|
8
|
+
|
9
|
+
Project Sprouts is an open-source, cross-platform project generation and configuration tool for ActionScript 2, ActionScript 3, and Flex projects.
|
10
|
+
|
11
|
+
Project Sprouts provides everything you need to get up and running with SWF development instantly. The only prerequisites are Ruby and RubyGems.
|
12
|
+
|
13
|
+
Sprouts includes support for project and code templates, automated build scripts, remote managed libraries, and automatic installation of dependencies like the Flash VM and a variety of compilers and tools.
|
14
|
+
|
15
|
+
Sprouts works on OS X, Windows XP, Windows Vista and many flavors of *nix (including Solaris thanks to lots of patience from Armaghan Chaudhary).
|
16
|
+
|
17
|
+
h3. Installation
|
18
|
+
|
19
|
+
# "Install Ruby":http://www.ruby-lang.org/en/downloads/ _(>= v 1.8.7)_
|
20
|
+
# "Install RubyGems":http://rubyforge.org/frs/?group_id=126 _(>= v 1.3.6)_
|
21
|
+
# Install the Sprout gem:
|
22
|
+
|
23
|
+
<pre><code>gem install sprout</code></pre>
|
24
|
+
_(If prompted, select the appropriate gem for your platform.)_
|
25
|
+
|
26
|
+
h3. Getting Started
|
27
|
+
|
28
|
+
Open a terminal and enter the following commands:
|
29
|
+
|
30
|
+
Create a new ActionScript 3 project and move into it:
|
31
|
+
|
32
|
+
<pre><code>sprout -n as3 SomeProject
|
33
|
+
cd SomeProject</code></pre>
|
34
|
+
|
35
|
+
Resolve all dependencies, compile and launch the SWF:
|
36
|
+
|
37
|
+
<pre><code>rake</code></pre>
|
38
|
+
|
39
|
+
Generate a new class, test case and test suite:
|
40
|
+
|
41
|
+
<pre><code>script/generate utils.MathUtil</code></pre>
|
42
|
+
|
43
|
+
Compile and launch the test harness:
|
44
|
+
|
45
|
+
<pre><code>rake test</code></pre>
|
46
|
+
|
47
|
+
Compile a SWC file:
|
48
|
+
|
49
|
+
<pre><code>rake swc</code></pre>
|
50
|
+
|
51
|
+
Generate documentation using "AsDoc":http://labs.adobe.com/wiki/index.php/ASDoc:
|
52
|
+
|
53
|
+
<pre><code>rake doc</code></pre>
|
54
|
+
|
55
|
+
Execute the test harness, emit a JUnit-compatible test results document, and close the Flash Player when complete or after encountering an uncaught exception:
|
56
|
+
|
57
|
+
<pre><code>rake cruise</code></pre>
|
58
|
+
|
59
|
+
Display all available Rake tasks:
|
60
|
+
|
61
|
+
<pre><code>rake -T</code></pre>
|
62
|
+
|
63
|
+
h3. Some Simple, Sample Rake Tasks
|
64
|
+
|
65
|
+
Sprouts brings the power of the "Rake":http://martinfowler.com/articles/rake.html build language to SWF development. Rake is similar to Make and Ant, but harnesses the full power and flexibility of Ruby to help us describe the structure and automate the behavior of any build, from the simplest to the most complex.
|
66
|
+
|
67
|
+
Following are some simple examples of the Rake tasks that Sprouts provides:
|
68
|
+
|
69
|
+
_"The Default Rakefile - Expanded":http://gist.github.com/221569_
|
70
|
+
|
71
|
+
_"An example of the erb_resolver Rake task":http://gist.github.com/306334_
|
72
|
+
|
73
|
+
_ActionScript 3 and MXML Projects:_
|
74
|
+
|
75
|
+
<pre><code>mxmlc :debug do |t|
|
76
|
+
t.input = 'src/SomeProject.as'
|
77
|
+
t.output = 'bin/SomeProject.swf'
|
78
|
+
end
|
79
|
+
|
80
|
+
compc :deploy do |t|
|
81
|
+
t.input = 'src/SomeProject.as'
|
82
|
+
t.output = 'bin/SomeProject.swc'
|
83
|
+
end
|
84
|
+
|
85
|
+
asdoc :doc do |t|
|
86
|
+
t.doc_classes = 'SomeProject'
|
87
|
+
t.source_path = 'src'
|
88
|
+
end
|
89
|
+
|
90
|
+
flashplayer :run do |t|
|
91
|
+
t.swf = 'bin/SomeProject.swf'
|
92
|
+
end
|
93
|
+
</code></pre>
|
94
|
+
|
95
|
+
_ActionScript 2 Projects:_
|
96
|
+
|
97
|
+
<pre><code>swfmill :skin do |t|
|
98
|
+
t.input = 'assets/skins/SomeProjectSkin'
|
99
|
+
t.output = 'assets/skins/SomeProjectSkin.swf'
|
100
|
+
end
|
101
|
+
|
102
|
+
mtasc :debug => :skin do |t|
|
103
|
+
t.main = true
|
104
|
+
t.header = '800:600:24'
|
105
|
+
t.input = 'src/SomeProject.as'
|
106
|
+
t.output = 'bin/SomeProject.swf'
|
107
|
+
end
|
108
|
+
|
109
|
+
flashplayer :run do |t|
|
110
|
+
t.swf = 'bin/SomeProject.swf'
|
111
|
+
end
|
112
|
+
</code></pre>
|
113
|
+
|
114
|
+
h3. Some Links
|
115
|
+
|
116
|
+
* "Web Site":http://projectsprouts.org
|
117
|
+
* "File a Bug":http://github.com/lukebayes/project-sprouts/issues
|
118
|
+
* "See the Documentation":http://projectsprouts.org/rdoc
|
119
|
+
* "Meet the Community":http://groups.google.com/group/projectsprouts
|
120
|
+
|
121
|
+
h1. Contributing
|
122
|
+
|
123
|
+
* Fork this git repository
|
124
|
+
* Clone your forked version with write-access
|
125
|
+
* cd to your local copy
|
126
|
+
* Run "bundle install"
|
127
|
+
* Run "rake test"
|
128
|
+
|
129
|
+
h3. MIT License
|
130
|
+
|
131
|
+
<pre>
|
132
|
+
Copyright (c) 2007, 2008, 2009 Pattern Park
|
133
|
+
|
134
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
135
|
+
a copy of this software and associated documentation files (the
|
136
|
+
"Software"), to deal in the Software without restriction, including
|
137
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
138
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
139
|
+
permit persons to whom the Software is furnished to do so, subject to
|
140
|
+
the following conditions:
|
141
|
+
|
142
|
+
The above copyright notice and this permission notice shall be
|
143
|
+
included in all copies or substantial portions of the Software.
|
144
|
+
|
145
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
146
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
147
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
148
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
149
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
150
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
151
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
152
|
+
</pre>
|
data/bin/sprout
CHANGED
@@ -1,133 +1,3 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
-
#
|
3
|
-
# Created by Luke Bayes on 2007-4-29.
|
4
|
-
# Copyright (c) 2007. All rights reserved.
|
5
2
|
|
6
|
-
|
7
|
-
require 'rubygems'
|
8
|
-
rescue LoadError
|
9
|
-
# no rubygems to load, so we fail silently
|
10
|
-
end
|
11
|
-
|
12
|
-
$:.push(File.dirname(__FILE__) + '/../lib')
|
13
|
-
require 'sprout'
|
14
|
-
require 'sprout/generator'
|
15
|
-
require 'optparse'
|
16
|
-
|
17
|
-
OPTIONS = {
|
18
|
-
:sources => [],
|
19
|
-
:project_name => nil,
|
20
|
-
:sprout_name => nil,
|
21
|
-
:requirements => nil,
|
22
|
-
:remove_all => false
|
23
|
-
}
|
24
|
-
|
25
|
-
def fail_with(opts, message)
|
26
|
-
puts "[ERROR] #{message}"
|
27
|
-
puts ""
|
28
|
-
puts opts
|
29
|
-
exit
|
30
|
-
end
|
31
|
-
|
32
|
-
parser = OptionParser.new do |opts|
|
33
|
-
opts.banner = <<BANNER
|
34
|
-
Sprout is an open-source, cross-platform project generation and configuration tool
|
35
|
-
|
36
|
-
Usage: #{File.basename($0)} [options] [ProjectName]
|
37
|
-
|
38
|
-
Examples:
|
39
|
-
|
40
|
-
Create a new ActionScript 3.0 project named 'SomeProject':
|
41
|
-
#{File.basename($0)} -n as3 SomeProject
|
42
|
-
|
43
|
-
Create a new ActionScript 2.0 project named 'OtherProject':
|
44
|
-
#{File.basename($0)} -n as2 OtherProject
|
45
|
-
|
46
|
-
Create a new MXML project named 'SomeProject':
|
47
|
-
#{File.basename($0)} -n mxml SomeProject
|
48
|
-
|
49
|
-
Remove all Sprout gems and cached files:
|
50
|
-
#{File.basename($0)} -R
|
51
|
-
|
52
|
-
Options are:
|
53
|
-
BANNER
|
54
|
-
opts.separator ""
|
55
|
-
|
56
|
-
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|
|
57
|
-
OPTIONS[:sprout_name] = name
|
58
|
-
end
|
59
|
-
|
60
|
-
opts.on('--source [URL]', String, "Use URL as the remote source for gems") do |source|
|
61
|
-
OPTIONS[:sources] << source
|
62
|
-
end
|
63
|
-
|
64
|
-
opts.on('-r', '--requirements REQUIREMENTS', String, "The specific gem version requirements for the named bundle (e.g., 0.3.2)") do |requirements|
|
65
|
-
OPTIONS[:requirements] = requirements
|
66
|
-
end
|
67
|
-
|
68
|
-
opts.on("-R", "--remove-all", "Remove all sprout gems and cached files") do
|
69
|
-
OPTIONS[:remove_all] = true
|
70
|
-
Sprout::Sprout.remove_all
|
71
|
-
end
|
72
|
-
|
73
|
-
opts.on("-v", "--version", "Display the installed version of the sprout gem") do |version|
|
74
|
-
puts "sprout #{Sprout::VERSION::STRING}"
|
75
|
-
exit
|
76
|
-
end
|
77
|
-
|
78
|
-
opts.on("-h", "--help", "Show this help message.") do
|
79
|
-
puts opts
|
80
|
-
exit
|
81
|
-
end
|
82
|
-
|
83
|
-
opts.parse!(ARGV)
|
84
|
-
|
85
|
-
if(OPTIONS[:sources].size > 0)
|
86
|
-
set_sources OPTIONS[:sources]
|
87
|
-
end
|
88
|
-
|
89
|
-
if(ARGV.size > 0)
|
90
|
-
if(OPTIONS[:sprout_name])
|
91
|
-
OPTIONS[:project_name] = ARGV.pop
|
92
|
-
if(OPTIONS[:project_name] == "=")
|
93
|
-
fail_with(opts, "Invalid project name #{OPTIONS[:project_name]}")
|
94
|
-
elsif(OPTIONS[:project_name] =~ /Test$/)
|
95
|
-
fail_with(opts, "Your project name should not match /Test$/ as this will quickly cause problems when generating test cases and test suites")
|
96
|
-
end
|
97
|
-
else
|
98
|
-
fail_with(opts, "You must provide a sprout name argument such as, '-n as2' or '-n as3'")
|
99
|
-
end
|
100
|
-
elsif(OPTIONS[:remove_all])
|
101
|
-
exit
|
102
|
-
else
|
103
|
-
fail_with(opts, "Expected a sprout bundle name and project name like: 'sprout -n as2 SomeProject'")
|
104
|
-
end
|
105
|
-
|
106
|
-
end
|
107
|
-
|
108
|
-
#############################################
|
109
|
-
|
110
|
-
sprout_name = OPTIONS[:sprout_name]
|
111
|
-
sprout_requirements = OPTIONS[:requirements]
|
112
|
-
project_name = OPTIONS[:project_name]
|
113
|
-
|
114
|
-
#############################################
|
115
|
-
|
116
|
-
puts ">> Creating new project '#{project_name}' with #{sprout_name}"
|
117
|
-
Sprout::Sprout.project_name = project_name
|
118
|
-
|
119
|
-
begin
|
120
|
-
# Fallback if a version was specified
|
121
|
-
if(sprout_requirements)
|
122
|
-
sprout(sprout_name, sprout_requirements)
|
123
|
-
end
|
124
|
-
# Try to run the generator against user home and existing gems first
|
125
|
-
Sprout::Sprout.generate(sprout_name, 'project', [project_name])
|
126
|
-
rescue RubiGen::GeneratorError
|
127
|
-
# Failing that, try to download a sprout gem by name
|
128
|
-
sprout(sprout_name, sprout_requirements)
|
129
|
-
# Then try again....
|
130
|
-
Sprout::Sprout.generate(sprout_name, 'project', [project_name])
|
131
|
-
end
|
132
|
-
|
133
|
-
Sprout::Log.flush
|
3
|
+
puts 'Type sprout- and then hit the tab key to see the new sprout binaries.'
|
data/bin/sprout-library
ADDED
data/bin/sprout-tool
ADDED
data/lib/sprout.rb
CHANGED
@@ -1,505 +1,9 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
require 'rake'
|
4
|
-
require 'rake/clean'
|
1
|
+
lib = File.expand_path File.dirname(__FILE__)
|
2
|
+
$:.unshift lib unless $:.include?(lib)
|
5
3
|
|
6
|
-
|
7
|
-
# http://code.google.com/p/projectsprouts/issues/detail?id=106
|
8
|
-
# Which is created because the new version (1.0.1) of RubyGems
|
9
|
-
# includes open-uri, while older versions do not.
|
10
|
-
# When open-uri is included twice, we get a bunch of nasty
|
11
|
-
# warnings because constants are being overwritten.
|
12
|
-
gem_version = Gem::Version.new(Gem::RubyGemsVersion)
|
13
|
-
if(gem_version != Gem::Version.new('1.0.1'))
|
14
|
-
require 'open-uri'
|
15
|
-
end
|
16
|
-
|
17
|
-
if(gem_version < Gem::Version.new('1.3.5'))
|
18
|
-
puts "[WARNING] You need to update your version of RubyGems: sudo gem update --system"
|
19
|
-
end
|
20
|
-
|
21
|
-
$:.unshift(File.dirname(__FILE__))
|
22
|
-
require 'sprout/dynamic_accessors'
|
23
|
-
require 'progress_bar'
|
24
|
-
require 'sprout/log'
|
25
|
-
require 'sprout/user'
|
26
|
-
require 'sprout/zip_util'
|
27
|
-
require 'sprout/remote_file_loader'
|
28
|
-
require 'sprout/archive_unpacker'
|
29
|
-
require 'sprout/remote_file_target'
|
30
|
-
require 'sprout/simple_resolver'
|
31
|
-
# require 'sprout/template_resolver'
|
32
|
-
require 'sprout/bundle_resolver'
|
33
|
-
|
34
|
-
require 'rubygems/installer'
|
35
|
-
require 'rubygems/source_info_cache'
|
36
|
-
require 'rubygems/version'
|
37
|
-
require 'digest/md5'
|
38
|
-
|
39
|
-
require 'sprout/tool_task_model'
|
40
|
-
require 'sprout/project_model'
|
41
|
-
require 'sprout/builder'
|
42
|
-
require 'sprout/version'
|
43
|
-
require 'sprout/tasks/tool_task'
|
44
|
-
require 'sprout/tasks/erb_resolver'
|
45
|
-
require 'sprout/general_tasks'
|
46
|
-
require 'sprout/generator'
|
4
|
+
require 'sprout/base'
|
47
5
|
|
48
6
|
module Sprout
|
49
|
-
|
50
|
-
SUDO_INSTALL_GEMS = 'false' == ENV['SUDO_INSTALL_GEMS'] ? false : true
|
51
|
-
end
|
52
|
-
|
53
|
-
class UsageError < StandardError #:nodoc
|
54
|
-
end
|
55
|
-
|
56
|
-
class SproutError < StandardError #:nodoc:
|
57
|
-
end
|
58
|
-
|
59
|
-
# Sprouts is an open-source, cross-platform project generation and configuration tool
|
60
|
-
# for ActionScript 2, ActionScript 3, Adobe AIR and Flex projects. It is built on top
|
61
|
-
# of Ruby Gems, Rubigen Generators and is intended to work on any platform that Ruby runs
|
62
|
-
# on including specifically, Windows XP, Windows Vista, Cygwin, OS X and Linux.
|
63
|
-
#
|
64
|
-
# Sprouts can be separated into some core concepts as follows:
|
65
|
-
#
|
66
|
-
# ----
|
67
|
-
# == Tools
|
68
|
-
# :include: ../doc/Tool
|
69
|
-
#
|
70
|
-
# ----
|
71
|
-
# == Libraries
|
72
|
-
# :include: ../doc/Library
|
73
|
-
#
|
74
|
-
# ----
|
75
|
-
# == Bundles
|
76
|
-
# :include: ../doc/Bundle
|
77
|
-
#
|
78
|
-
# ----
|
79
|
-
# == Generators
|
80
|
-
# :include: ../doc/Generator
|
81
|
-
#
|
82
|
-
# ----
|
83
|
-
# == Tasks
|
84
|
-
# :include: ../doc/Task
|
85
|
-
#
|
86
|
-
# ----
|
87
|
-
# == Sprout
|
88
|
-
#
|
89
|
-
# Tools, Libraries and Bundles are distributed as RubyGems and given a specific gem name suffix. For some examples:
|
90
|
-
# sprout-flex3sdk-tool
|
91
|
-
# sprout-asunit-library
|
92
|
-
# sprout-as3-bundle
|
93
|
-
#
|
94
|
-
# The Sprout application provides shared functionality for each of the different types of Sprouts.
|
95
|
-
#
|
96
|
-
# The Sprout command line tool primarily provides access to project generators from any sprout bundle that is available
|
97
|
-
# to your system, either locally or from the network.
|
98
|
-
#
|
99
|
-
# When executed from the system path, this class will download and install a named bundle, and execute a +project+
|
100
|
-
# generator within that bundle. Following is an example:
|
101
|
-
#
|
102
|
-
# sprout -n as3 SomeProject
|
103
|
-
#
|
104
|
-
# The previous command will download and install the latest version of the sprout-as3-bundle gem and initiate the
|
105
|
-
# project_generator with a single argument of 'SomeProject'. If the string passed to the -n parameter begins with
|
106
|
-
# 'sprout-' it will be unmodified for the lookup. For example:
|
107
|
-
#
|
108
|
-
# spout -n sprout-as3-bundle SomeProject
|
109
|
-
#
|
110
|
-
# will not have duplicate strings prepended or suffixed.
|
111
|
-
#
|
112
|
-
# ----
|
113
|
-
# Some additional resources or references:
|
114
|
-
#
|
115
|
-
# Rake:
|
116
|
-
# http://rake.rubyforge.org
|
117
|
-
# http://martinfowler.com/articles/rake.html
|
118
|
-
#
|
119
|
-
# RubyGems:
|
120
|
-
# * http://www.rubygems.org
|
121
|
-
# * http://www.linuxjournal.com/article/8967
|
122
|
-
#
|
123
|
-
# Ruby Raven (Mostly Inspiration)
|
124
|
-
# * http://raven.rubyforge.org
|
125
|
-
#
|
126
|
-
class Sprout
|
127
|
-
@@default_rakefiles = ['rakefile', 'Rakefile', 'rakefile.rb', 'Rakefile.rb'].freeze
|
128
|
-
|
129
|
-
@@name = 'Sprouts'
|
130
|
-
@@cache = 'cache'
|
131
|
-
@@lib = 'lib'
|
132
|
-
@@spec = 'sprout.spec'
|
133
|
-
@@home = File.expand_path(File.dirname(File.dirname(__FILE__)))
|
134
|
-
|
135
|
-
# Execute a generator that is available locally or from the network.
|
136
|
-
# * +sprout_name+ A full gem name (ex., sprout-as3-bundle) that contains a generator that matches +generator_name+
|
137
|
-
# * +generator_name+ A string like 'project' or 'class' that maps to a generator
|
138
|
-
# * +params+ Arbitrary parameters to pass to the generator
|
139
|
-
# * +project_path+ Optional parameter. Will default to the nearest folder that contains a valid Rakefile.
|
140
|
-
# This Rakefile will usually be loaded by the referenced Generator, and it should have a configured ProjectModel
|
141
|
-
# defined in it.
|
142
|
-
|
143
|
-
# TODO: This command should accept an array of sprout names to fall back on...
|
144
|
-
# for example: generate(['flex4', 'as3'], ...)
|
145
|
-
def self.generate(sprout_name, generator_name, params, project_path=nil)
|
146
|
-
# params.each_index do |index|
|
147
|
-
# params[index] = clean_project_name(params[index])
|
148
|
-
# end
|
149
|
-
RubiGen::Base.use_sprout_sources!(sprout_name, project_path)
|
150
|
-
generator = RubiGen::Base.instance(generator_name, params)
|
151
|
-
generator.command(:create).invoke!
|
152
|
-
end
|
153
|
-
|
154
|
-
# Remove all installed RubyGems that begin with the string 'sprout' and clear the local sprout cache
|
155
|
-
def self.remove_all
|
156
|
-
# Set up sudo prefix if not on win machine
|
157
|
-
# Only show confirmation if there is at least one installed sprout gem
|
158
|
-
confirmation = false
|
159
|
-
count = 0
|
160
|
-
# For each sprout found, remove it!
|
161
|
-
RubiGen::GemGeneratorSource.new().each_sprout do |sprout|
|
162
|
-
count += 1
|
163
|
-
command = "#{get_gem_preamble} uninstall -x -a -q #{sprout.name}"
|
164
|
-
|
165
|
-
if(!confirmation)
|
166
|
-
confirmation = remove_gems_confirmation
|
167
|
-
break unless confirmation
|
168
|
-
end
|
169
|
-
puts "executing #{command}"
|
170
|
-
raise ">> Exited with errors: #{$?}" unless system(command)
|
171
|
-
end
|
172
|
-
|
173
|
-
if(confirmation)
|
174
|
-
puts "All Sprout gems have been successfully uninstalled"
|
175
|
-
elsif(count > 0)
|
176
|
-
puts "Some Sprout gems have been left on the system"
|
177
|
-
else
|
178
|
-
puts "No Sprout gems were found on this system"
|
179
|
-
end
|
180
|
-
|
181
|
-
# Now clear out the cache
|
182
|
-
cache = File.dirname(File.dirname(Sprout.sprout_cache))
|
183
|
-
|
184
|
-
if(File.exists?(cache))
|
185
|
-
puts "\n[WARNING]\n\nAbout to irrevocably destroy the sprout cache at:\n\n#{cache}\n\n"
|
186
|
-
puts "Are you absolutely sure? [Yn]"
|
187
|
-
response = $stdin.gets.chomp!
|
188
|
-
if(response.downcase.index('y'))
|
189
|
-
FileUtils.rm_rf(cache)
|
190
|
-
else
|
191
|
-
puts "Leaving the Sprout file cache in tact...."
|
192
|
-
end
|
193
|
-
else
|
194
|
-
puts "No cached files found on this system"
|
195
|
-
end
|
196
|
-
|
197
|
-
puts "To completely remove sprouts now, run:"
|
198
|
-
puts " #{get_gem_preamble} uninstall sprout"
|
199
|
-
end
|
200
|
-
|
201
|
-
# Build up the platform-specific preamble required
|
202
|
-
# to call the gem binary from Kernel.execute
|
203
|
-
def self.get_gem_preamble
|
204
|
-
usr = User.new()
|
205
|
-
if(!usr.is_a?(WinUser))
|
206
|
-
# Everyone but Win and Cygwin users get 'sudo '
|
207
|
-
return "#{SUDO_INSTALL_GEMS ? 'sudo ' : ''}gem"
|
208
|
-
elsif(!usr.is_a?(CygwinUser))
|
209
|
-
# We're in the DOS Shell
|
210
|
-
return "ruby #{get_executable_from_path('gem')}"
|
211
|
-
end
|
212
|
-
# We're either a CygwinUser or some other non-sudo supporter
|
213
|
-
return 'gem'
|
214
|
-
end
|
215
|
-
|
216
|
-
# Retrieve the full path to an executable that is
|
217
|
-
# available in the system path
|
218
|
-
def self.get_executable_from_path(exe)
|
219
|
-
path = ENV['PATH']
|
220
|
-
file_path = nil
|
221
|
-
path.split(get_path_delimiter).each do |p|
|
222
|
-
file_path = File.join(p, exe)
|
223
|
-
# file_path = file_path.split("/").join("\\")
|
224
|
-
# file_path = file_path.split("\\").join("/")
|
225
|
-
if(File.exists?(file_path))
|
226
|
-
return User.clean_path(file_path)
|
227
|
-
end
|
228
|
-
end
|
229
|
-
return nil
|
230
|
-
end
|
231
|
-
|
232
|
-
def self.get_path_delimiter
|
233
|
-
usr = User.new
|
234
|
-
if(usr.is_a?(WinUser) && !usr.is_a?(CygwinUser))
|
235
|
-
return ';'
|
236
|
-
else
|
237
|
-
return ':'
|
238
|
-
end
|
239
|
-
end
|
240
|
-
|
241
|
-
def self.remove_gems_confirmation
|
242
|
-
msg =<<EOF
|
243
|
-
About to uninstall all RubyGems that match 'sprout-'....
|
244
|
-
Are you sure you want to do this? [Yn]
|
245
|
-
EOF
|
246
|
-
puts msg
|
247
|
-
response = $stdin.gets.chomp!
|
248
|
-
if(response.downcase.index('y'))
|
249
|
-
return true
|
250
|
-
end
|
251
|
-
return false
|
252
|
-
end
|
253
|
-
|
254
|
-
# Retrieve the file target to an executable by sprout name. Usually, these are tool sprouts.
|
255
|
-
# * +name+ Full sprout gem name that contains an executable file
|
256
|
-
# * +archive_path+ Optional parameter for tools that contain more than one executable, or for
|
257
|
-
# when you don't want to use the default executable presented by the tool. For example, the Flex SDK
|
258
|
-
# has many executables, when this method is called for them, one might use something like:
|
259
|
-
# Sprout::Sprout.get_executable('sprout-flex3sdk-tool', 'bin/mxmlc')
|
260
|
-
# * +version+ Optional parameter to specify a particular gem version for this executable
|
261
|
-
def self.get_executable(name, archive_path=nil, version=nil)
|
262
|
-
target = self.sprout(name, version)
|
263
|
-
if(archive_path)
|
264
|
-
# If caller sent in a relative path to an executable (e.g., bin/mxmlc), use it
|
265
|
-
exe = File.join(target.installed_path, archive_path)
|
266
|
-
if(User.new.is_a?(WinUser) && !archive_path.match(/.exe$/))
|
267
|
-
# If we're on Win (even Cygwin), add .exe to support custom binaries (see sprout-flex3sdk-tool)
|
268
|
-
if(File.exists?(exe + '.exe'))
|
269
|
-
exe << '.exe'
|
270
|
-
end
|
271
|
-
end
|
272
|
-
elsif(target.url)
|
273
|
-
# Otherwise, use the default path to an executable if the RemoteFileTarget has a url prop
|
274
|
-
exe = File.join(target.installed_path, target.archive_path)
|
275
|
-
else
|
276
|
-
# Otherwise attempt to run the feature from the system path
|
277
|
-
exe = target.archive_path
|
278
|
-
end
|
279
|
-
|
280
|
-
if(!File.exists?(exe))
|
281
|
-
raise UsageError.new("Could not retrieve requested executable from path: #{exe}")
|
282
|
-
end
|
283
|
-
|
284
|
-
if(File.exists?(exe) && !File.directory?(exe) && !File.stat(exe).executable?)
|
285
|
-
File.chmod 0755, exe
|
286
|
-
end
|
287
|
-
|
288
|
-
return exe
|
289
|
-
end
|
290
|
-
|
291
|
-
# Allows us to easily download and install RubyGem sprouts by name and
|
292
|
-
# version.
|
293
|
-
# Returns a RubyGem Gem Spec[http://rubygems.org/read/chapter/20]
|
294
|
-
# when installation is complete. If the installed gem has a Ruby file
|
295
|
-
# configured to 'autorequire', that file will also be required by this
|
296
|
-
# method so that any provided Ruby functionality will be immediately
|
297
|
-
# available to client scripts. If the installed gem contains a
|
298
|
-
# 'sprout.spec' file, any RemoteFileTargets will be resolved synchronously
|
299
|
-
# and those files will be available in the Sprout::Sprout.cache.
|
300
|
-
#
|
301
|
-
def self.sprout(name, version=nil)
|
302
|
-
name = sprout_to_gem_name(name)
|
303
|
-
gem_spec = self.find_gem_spec(name, version)
|
304
|
-
sprout_spec_path = File.join(gem_spec.full_gem_path, @@spec)
|
305
|
-
|
306
|
-
if(gem_spec.autorequire)
|
307
|
-
$:.push(File.join(gem_spec.full_gem_path, 'lib'))
|
308
|
-
require gem_spec.autorequire
|
309
|
-
end
|
310
|
-
if(File.exists?(sprout_spec_path))
|
311
|
-
# Ensure the requisite files get downloaded and unpacked
|
312
|
-
Builder.build(sprout_spec_path, gem_spec.name, gem_spec.version)
|
313
|
-
else
|
314
|
-
return gem_spec
|
315
|
-
end
|
316
|
-
end
|
317
|
-
|
318
|
-
# Return sprout-#{name}-bundle for any name that does not begin with 'sprout-'. This was used early on in development
|
319
|
-
# but should possibly be removed as we move forward and try to support arbitrary RubyGems.
|
320
|
-
def self.sprout_to_gem_name(name)
|
321
|
-
if(!name.match(/^sprout-/))
|
322
|
-
name = "sprout-#{name}-bundle"
|
323
|
-
end
|
324
|
-
return name
|
325
|
-
end
|
326
|
-
|
327
|
-
# Return the home directory for this Sprout installation
|
328
|
-
def self.home
|
329
|
-
return @@home
|
330
|
-
end
|
331
|
-
|
332
|
-
# Return the location on disk where this installation of Sprouts stores it's cached files.
|
333
|
-
# If the currently installed version of Sprouts were 0.7 and your system username were 'foo'
|
334
|
-
# this would return the following locations:
|
335
|
-
# * +OSX+ /Users/foo/Library/Sprouts/cache/0.7
|
336
|
-
# * +Windows+ C:/Documents And Settings/foo/Local Settings/Application Data/Sprouts/cache/0.7
|
337
|
-
# * +Linux+ ~/.sprouts/cache/0.7
|
338
|
-
def self.sprout_cache
|
339
|
-
@@sprout_cache ||= self.inferred_sprout_cache
|
340
|
-
end
|
341
|
-
|
342
|
-
def self.sprout_cache=(cache)
|
343
|
-
@@sprout_cache = cache
|
344
|
-
end
|
345
|
-
|
346
|
-
def self.inferred_sprout_cache
|
347
|
-
home = User.application_home(@@name)
|
348
|
-
return File.join(home, @@cache, "#{VERSION::MAJOR}.#{VERSION::MINOR}")
|
349
|
-
end
|
350
|
-
|
351
|
-
# Return the +sprout_cache+ combined with the passed in +name+ and +version+ so that you will get
|
352
|
-
# a cache location for a specific gem.
|
353
|
-
def self.gem_file_cache(name, version)
|
354
|
-
return File.join(sprout_cache, "#{name}-#{version}")
|
355
|
-
end
|
356
|
-
|
357
|
-
# Retrieve the RubyGems gem spec for a particular gem +name+ that meets the provided +requirements+.
|
358
|
-
# +requirements+ are provided as a string value like:
|
359
|
-
# '>= 0.0.1'
|
360
|
-
# or
|
361
|
-
# '0.0.1'
|
362
|
-
# This method will actually download and install the provided gem by +name+ and +requirements+ if
|
363
|
-
# it is not found locally on the system.
|
364
|
-
def self.find_gem_spec(name, requirements=nil, recursed=false)
|
365
|
-
specs = Gem::cache.sprout_search(/.*#{name}$/).reverse # Found specs are returned in order from oldest to newest!?
|
366
|
-
requirement = nil
|
367
|
-
if(requirements)
|
368
|
-
requirement = Gem::Requirement.new(requirements)
|
369
|
-
end
|
370
|
-
specs.each do |spec|
|
371
|
-
if(requirements)
|
372
|
-
if(requirement.satisfied_by?(spec.version))
|
373
|
-
return spec
|
374
|
-
end
|
375
|
-
else
|
376
|
-
return spec
|
377
|
-
end
|
378
|
-
end
|
379
|
-
|
380
|
-
if(recursed)
|
381
|
-
raise SproutError.new("Gem Spec not found for #{name} #{requirements}")
|
382
|
-
else
|
383
|
-
msg = ">> Loading gem [#{name}]"
|
384
|
-
msg << " #{requirements}" if requirements
|
385
|
-
msg << " from #{gem_sources.join(', ')} with its dependencies"
|
386
|
-
Log.puts msg
|
387
|
-
parts = [ 'ins', '-r', name ]
|
388
|
-
# This url should be removed once released, released gems should be hosted from the rubyforge
|
389
|
-
# project, and development gems will be hosted on our domain.
|
390
|
-
parts << "--source #{gem_sources.join(' --source ')}" if(Log.debug || name.index('sprout-'))
|
391
|
-
parts << "-v #{requirements}" unless requirements.nil?
|
392
|
-
|
393
|
-
self.load_gem(parts.join(" "))
|
394
|
-
Gem::cache.refresh!
|
395
|
-
return find_gem_spec(name, requirements, true)
|
396
|
-
end
|
397
|
-
end
|
398
|
-
|
399
|
-
def self.load_gem(args)
|
400
|
-
# This must use a 'system' call because RubyGems
|
401
|
-
# sends an 'exit'?
|
402
|
-
system("#{get_gem_preamble} #{args}")
|
403
|
-
end
|
404
|
-
|
405
|
-
##
|
406
|
-
# List of files to ignore when copying project templates
|
407
|
-
# These files will not be copied
|
408
|
-
@@COPY_IGNORE_FILES = ['.', '..', '.svn', '.DS_Store', 'CVS', '.cvs' 'Thumbs.db', '__MACOSX', '.Trashes', 'Desktop DB', 'Desktop DF']
|
409
|
-
# Do not copy files found in the ignore_files list
|
410
|
-
def self.ignore_file? file
|
411
|
-
@@COPY_IGNORE_FILES.each do |name|
|
412
|
-
if(name == file)
|
413
|
-
return true
|
414
|
-
end
|
415
|
-
end
|
416
|
-
return false
|
417
|
-
end
|
418
|
-
|
419
|
-
def self.gem_sources=(sources) # :nodoc:
|
420
|
-
if(sources.is_a?(String))
|
421
|
-
# TODO: Clean up the string that is sent in,
|
422
|
-
# maybe even split space or comma-delimited?
|
423
|
-
sources = [sources]
|
424
|
-
end
|
425
|
-
@@gem_sources = sources
|
426
|
-
end
|
427
|
-
|
428
|
-
# TODO: Should be updated after release so that all gems are
|
429
|
-
# loaded form rubyforge instead of projectsprouts, only development
|
430
|
-
# gems will continue to be hosted at this default domain.
|
431
|
-
def self.gem_sources # :nodoc:
|
432
|
-
@@gem_sources ||= ['http://gems.rubyforge.org']
|
433
|
-
end
|
434
|
-
|
435
|
-
def self.project_name=(name) # :nodoc:
|
436
|
-
@@project_name = name
|
437
|
-
end
|
438
|
-
|
439
|
-
# Return the current project_name assuming someone has already set it, otherwise return an empty string
|
440
|
-
def self.project_name
|
441
|
-
@@project_name ||= ''
|
442
|
-
end
|
443
|
-
|
444
|
-
def self.project_path=(path) # :nodoc:
|
445
|
-
@@project_rakefile = child_rakefile(path)
|
446
|
-
@@project_path = path
|
447
|
-
end
|
448
|
-
|
449
|
-
# project_path should step backward in the file system
|
450
|
-
# until it encounters a rakefile. The parent directory
|
451
|
-
# of that rakefile should be returned.
|
452
|
-
# If no rakefile is found, it should return Dir.pwd
|
453
|
-
def self.project_path
|
454
|
-
@@project_path ||= self.project_path = get_implicit_project_path(Dir.pwd)
|
455
|
-
end
|
456
|
-
|
457
|
-
# Return the rakefile in the current +project_path+
|
458
|
-
def self.project_rakefile
|
459
|
-
if(!defined?(@@project_rakefile))
|
460
|
-
path = project_path
|
461
|
-
end
|
462
|
-
return @@project_rakefile ||= nil
|
463
|
-
end
|
464
|
-
|
465
|
-
# Look in the provided +dir+ for files that meet the criteria to be a valid Rakefile.
|
466
|
-
def self.child_rakefile(dir)
|
467
|
-
@@default_rakefiles.each do |file|
|
468
|
-
rake_path = File.join(dir, file)
|
469
|
-
if(File.exists?(rake_path))
|
470
|
-
return rake_path
|
471
|
-
end
|
472
|
-
end
|
473
|
-
return nil
|
474
|
-
end
|
475
|
-
|
476
|
-
def self.get_implicit_project_path(path)
|
477
|
-
# We have recursed to the root of the filesystem, return nil
|
478
|
-
if(path.nil? || File.dirname(path) == path || path == '/' || path.match(/^\w\:\/$/))
|
479
|
-
return Dir.pwd
|
480
|
-
end
|
481
|
-
# Look for a rakefile as a child of the current path
|
482
|
-
if(child_rakefile(path))
|
483
|
-
return path
|
484
|
-
end
|
485
|
-
|
486
|
-
# No rakefile and no root found, check in parent dir
|
487
|
-
return Sprout.get_implicit_project_path(File.dirname(path))
|
488
|
-
end
|
489
|
-
|
490
|
-
end
|
7
|
+
include Base
|
491
8
|
end
|
492
9
|
|
493
|
-
# Set an array of URLs to use as gem repositories when loading Sprout gems.
|
494
|
-
# Any rakefile that requires the sprout gem can use this method as follows:
|
495
|
-
#
|
496
|
-
# set_sources ['http://gems.yourdomain.com']
|
497
|
-
#
|
498
|
-
def set_sources(sources)
|
499
|
-
Sprout::Sprout.gem_sources = sources
|
500
|
-
end
|
501
|
-
|
502
|
-
# Helper method that will download and install remote sprouts by name and version
|
503
|
-
def sprout(name, version=nil)
|
504
|
-
Sprout::Sprout.sprout(name, version)
|
505
|
-
end
|