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
@@ -1,88 +0,0 @@
|
|
1
|
-
=begin
|
2
|
-
Copyright (c) 2007 Pattern Park
|
3
|
-
|
4
|
-
Permission is hereby granted, free of charge, to any person obtaining
|
5
|
-
a copy of this software and associated documentation files (the
|
6
|
-
"Software"), to deal in the Software without restriction, including
|
7
|
-
without limitation the rights to use, copy, modify, merge, publish,
|
8
|
-
distribute, sublicense, and/or sell copies of the Software, and to
|
9
|
-
permit persons to whom the Software is furnished to do so, subject to
|
10
|
-
the following conditions:
|
11
|
-
|
12
|
-
The above copyright notice and this permission notice shall be
|
13
|
-
included in all copies or substantial portions of the Software.
|
14
|
-
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
16
|
-
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
17
|
-
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
18
|
-
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
19
|
-
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
20
|
-
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
21
|
-
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
22
|
-
=end
|
23
|
-
require 'erb'
|
24
|
-
|
25
|
-
module Sprout
|
26
|
-
|
27
|
-
class SimpleResolver #:nodoc:
|
28
|
-
|
29
|
-
def initialize(template, output, files, base_dir=nil)
|
30
|
-
@template = template
|
31
|
-
@output = output
|
32
|
-
@files = files
|
33
|
-
@base_dir = base_dir
|
34
|
-
@ignored_files = []
|
35
|
-
execute
|
36
|
-
finish
|
37
|
-
end
|
38
|
-
|
39
|
-
def execute
|
40
|
-
template_file = File.open(@template, 'r')
|
41
|
-
content = template_file.read
|
42
|
-
result = ERB.new(content, nil, '>').result(binding)
|
43
|
-
|
44
|
-
output_file = File.open(@output, 'w')
|
45
|
-
output_file.write(result)
|
46
|
-
|
47
|
-
template_file.close
|
48
|
-
output_file.close
|
49
|
-
end
|
50
|
-
|
51
|
-
def files
|
52
|
-
return @files
|
53
|
-
end
|
54
|
-
|
55
|
-
def finish
|
56
|
-
if(@ignored_files.size > 0)
|
57
|
-
Logger.puts '>> SimpleResolver ignored the following files because their names were invalid:'
|
58
|
-
@ignored_files.each do |file|
|
59
|
-
puts file
|
60
|
-
end
|
61
|
-
end
|
62
|
-
end
|
63
|
-
|
64
|
-
def xml_edit_warning
|
65
|
-
return <<EOF
|
66
|
-
<!--
|
67
|
-
DO NOT EDIT THIS FILE!
|
68
|
-
This file was auto-generated from
|
69
|
-
an ERB template which can be
|
70
|
-
found at:
|
71
|
-
#{@template}
|
72
|
-
-->
|
73
|
-
EOF
|
74
|
-
end
|
75
|
-
|
76
|
-
def edit_warning
|
77
|
-
return <<EOF
|
78
|
-
/*************************************
|
79
|
-
* DO NOT EDIT THIS FILE!
|
80
|
-
* This file was auto-generated from
|
81
|
-
* an ERB template which can be
|
82
|
-
* found at:
|
83
|
-
* #{@template}
|
84
|
-
*************************************/
|
85
|
-
EOF
|
86
|
-
end
|
87
|
-
end
|
88
|
-
end
|
@@ -1,118 +0,0 @@
|
|
1
|
-
require 'erb'
|
2
|
-
|
3
|
-
# Rake task that makes it stupid-easy to render ERB templates
|
4
|
-
# to disk. Just add parameters to the yielded object, and
|
5
|
-
# they will be available to your Template.
|
6
|
-
#
|
7
|
-
# erb_resolver 'config/SomeFile.xml' do |t|
|
8
|
-
# t.param1 = 'value'
|
9
|
-
# t.other_param = 'other value'
|
10
|
-
# t.another_param = ['a', 'b', 'c']
|
11
|
-
# end
|
12
|
-
#
|
13
|
-
# Your erb template must be found at:
|
14
|
-
#
|
15
|
-
# [task_name].erb
|
16
|
-
#
|
17
|
-
# For the above example, this file would be:
|
18
|
-
#
|
19
|
-
# config/SomeFile.xml.erb
|
20
|
-
#
|
21
|
-
module Sprout
|
22
|
-
|
23
|
-
class ERBResolver < Rake::FileTask
|
24
|
-
|
25
|
-
# Path to the input ERB template. This
|
26
|
-
# value will default to the value of
|
27
|
-
# "#{ERBResolver.output}.erb"
|
28
|
-
attr_accessor :template
|
29
|
-
|
30
|
-
def initialize(name, app) # :nodoc:
|
31
|
-
super
|
32
|
-
@context = ERBContext.new
|
33
|
-
end
|
34
|
-
|
35
|
-
def define(args)
|
36
|
-
end
|
37
|
-
|
38
|
-
def prepare
|
39
|
-
prepare_prerequisites
|
40
|
-
end
|
41
|
-
|
42
|
-
# Modified from Rake::Task.execute
|
43
|
-
def execute(args=nil)
|
44
|
-
args ||= EMPTY_TASK_ARGS
|
45
|
-
if application.options.dryrun
|
46
|
-
puts "** Execute (dry run) #{name}"
|
47
|
-
return
|
48
|
-
end
|
49
|
-
if application.options.trace
|
50
|
-
puts "** Execute #{name}"
|
51
|
-
end
|
52
|
-
application.enhance_with_matching_rule(name) if @actions.empty?
|
53
|
-
@actions.each do |action|
|
54
|
-
execute_erb_task(action, args)
|
55
|
-
end
|
56
|
-
end
|
57
|
-
|
58
|
-
def execute_erb_task(action, args=nil)
|
59
|
-
case action.arity
|
60
|
-
when 1
|
61
|
-
action.call(@context)
|
62
|
-
else
|
63
|
-
action.call(@context, args)
|
64
|
-
end
|
65
|
-
|
66
|
-
@context.execute(template, output, args)
|
67
|
-
end
|
68
|
-
|
69
|
-
def self.define_task(*args, &block)
|
70
|
-
t = super
|
71
|
-
if(t.is_a?(ERBResolver))
|
72
|
-
t.define(args)
|
73
|
-
t.prepare
|
74
|
-
end
|
75
|
-
return t
|
76
|
-
end
|
77
|
-
|
78
|
-
def template
|
79
|
-
@template ||= "#{output}.erb"
|
80
|
-
end
|
81
|
-
|
82
|
-
def output
|
83
|
-
self.name
|
84
|
-
end
|
85
|
-
|
86
|
-
protected
|
87
|
-
|
88
|
-
def prepare_prerequisites
|
89
|
-
prerequisites << file(template)
|
90
|
-
CLEAN.add(output)
|
91
|
-
end
|
92
|
-
|
93
|
-
end
|
94
|
-
|
95
|
-
# An empty, dynamic object that will be yielded
|
96
|
-
# to the provided block and later supplied to the
|
97
|
-
# ERB template.
|
98
|
-
#
|
99
|
-
# Returning this empty object gives us the ability
|
100
|
-
# to use parameter names in our templates even if
|
101
|
-
# they are already used by Rake tasks (i.e. name).
|
102
|
-
class ERBContext
|
103
|
-
include DynamicAccessors
|
104
|
-
|
105
|
-
def execute(template, output, args=nil)
|
106
|
-
content = nil
|
107
|
-
File.open(template, 'r') { |f| content = f.read }
|
108
|
-
result = ERB.new(content, nil, '>').result(binding)
|
109
|
-
File.open(output, 'w') { |f| f.write(result) }
|
110
|
-
Log.puts ">> Created ERB output at: #{output} from: #{template}"
|
111
|
-
end
|
112
|
-
end
|
113
|
-
|
114
|
-
end
|
115
|
-
|
116
|
-
def erb_resolver(*args, &block)
|
117
|
-
Sprout::ERBResolver.define_task(args, &block)
|
118
|
-
end
|
@@ -1,214 +0,0 @@
|
|
1
|
-
=begin
|
2
|
-
Copyright (c) 2007 Pattern Park
|
3
|
-
|
4
|
-
Permission is hereby granted, free of charge, to any person obtaining
|
5
|
-
a copy of this software and associated documentation files (the
|
6
|
-
"Software"), to deal in the Software without restriction, including
|
7
|
-
without limitation the rights to use, copy, modify, merge, publish,
|
8
|
-
distribute, sublicense, and/or sell copies of the Software, and to
|
9
|
-
permit persons to whom the Software is furnished to do so, subject to
|
10
|
-
the following conditions:
|
11
|
-
|
12
|
-
The above copyright notice and this permission notice shall be
|
13
|
-
included in all copies or substantial portions of the Software.
|
14
|
-
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
16
|
-
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
17
|
-
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
18
|
-
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
19
|
-
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
20
|
-
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
21
|
-
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
22
|
-
|
23
|
-
TODO: Update mxmlc task
|
24
|
-
* Update mxmlc to include all advanced options
|
25
|
-
* Clean up default values
|
26
|
-
* Investigate jruby support, especially:
|
27
|
-
http://livedocs.adobe.com/flex/201/html/wwhelp/wwhimpl/common/html/wwhelp.htm?context=LiveDocs_Book_Parts&file=compilers_123_09.html
|
28
|
-
=end
|
29
|
-
|
30
|
-
module Sprout
|
31
|
-
class GemWrapError < StandardError #:nodoc:
|
32
|
-
end
|
33
|
-
|
34
|
-
# Creates a ruby gem from a slightly simpler rake task than what gems provides.
|
35
|
-
# Adds support for adding a sprout.spec file to your new gem which is usually useful
|
36
|
-
# for tool or library sprout gems.
|
37
|
-
class GemWrapTask < Rake::Task
|
38
|
-
# The full name of the gem to create like:
|
39
|
-
# t.gem_name = 'sprout-as3-bundle'
|
40
|
-
attr_writer :gem_name
|
41
|
-
# The type of sprout to create, defaults to 'library'
|
42
|
-
# Other possible values are, 'bundle' and 'tool'
|
43
|
-
attr_writer :sprout_type
|
44
|
-
# Full string rubygem version for this sprout, usually in three parts like:
|
45
|
-
# t.version = '0.0.1'
|
46
|
-
attr_writer :version
|
47
|
-
# Folder that the newly-created gem should be placed in
|
48
|
-
attr_writer :package
|
49
|
-
# Summary or short description for the gem
|
50
|
-
attr_writer :summary
|
51
|
-
# The author that created the gem
|
52
|
-
attr_writer :author
|
53
|
-
# Email address for interested users to send questions to
|
54
|
-
attr_writer :email
|
55
|
-
# Homepage where users can learn more about this gem
|
56
|
-
attr_writer :homepage
|
57
|
-
# A string remote file specification usually something like:
|
58
|
-
#
|
59
|
-
# t.sprout_spec =<<EOF
|
60
|
-
# - !ruby/object:Sprout::RemoteFileTarget
|
61
|
-
# platform: universal
|
62
|
-
# url: http://as3flickrlib.googlecode.com/files/flickr-.87.zip
|
63
|
-
# archive_path: flickr-.87/src
|
64
|
-
# EOF
|
65
|
-
attr_writer :sprout_spec
|
66
|
-
# An array of library names this sprout depends on.
|
67
|
-
# Each will be expanded to sprout-[library-name]-library
|
68
|
-
# and resolved at compile stage
|
69
|
-
attr_writer :libraries
|
70
|
-
|
71
|
-
def self.define_task(args, &block)
|
72
|
-
t = super
|
73
|
-
yield t if block_given?
|
74
|
-
t.define
|
75
|
-
end
|
76
|
-
|
77
|
-
def define # :nodoc:
|
78
|
-
define_gem_name
|
79
|
-
define_extensions(extensions)
|
80
|
-
end
|
81
|
-
|
82
|
-
def initialize(task_name, app) # :nodoc:
|
83
|
-
super
|
84
|
-
@sprout_type = "library"
|
85
|
-
@package = "pkg"
|
86
|
-
@summary = "#{task_name}"
|
87
|
-
@email = "projectsprouts@googlegroups.com"
|
88
|
-
@homepage = "http://www.projectsprouts.org"
|
89
|
-
end
|
90
|
-
|
91
|
-
def execute(*args) # :nodoc:
|
92
|
-
super
|
93
|
-
raise GemWrapError.new("A version must be provided to produce a Gem!") unless @version
|
94
|
-
@summary = "#{name} #{@sprout_type} generated by Sprout::GemWrapTask" unless @summary
|
95
|
-
|
96
|
-
FileUtils.mkdir_p(gem_package)
|
97
|
-
render_sprout_spec(gem_package, @sprout_spec) if @sprout_spec
|
98
|
-
# render_extensions(gem_package, extensions) if extensions.size
|
99
|
-
|
100
|
-
Dir.chdir(gem_package) do
|
101
|
-
|
102
|
-
spec = Gem::Specification.new do |s|
|
103
|
-
files = []
|
104
|
-
s.platform = Gem::Platform::RUBY
|
105
|
-
s.version = @version
|
106
|
-
s.author = @author if @author
|
107
|
-
s.summary = @summary
|
108
|
-
s.name = @gem_name
|
109
|
-
s.email = @email
|
110
|
-
s.homepage = @homepage
|
111
|
-
# added in order to avoid the lib not found error
|
112
|
-
s.require_path = "sprout.spec"
|
113
|
-
s.rubyforge_project = 'sprout'
|
114
|
-
gem_dependencies.each do |dep|
|
115
|
-
s.requirements << dep
|
116
|
-
end
|
117
|
-
libraries.each do |l|
|
118
|
-
puts "Adding #{l} to gem dependencies"
|
119
|
-
s.add_dependency("sprout-#{l}-library", ">= 0.0.0")
|
120
|
-
end
|
121
|
-
|
122
|
-
sprout_requirement = s.requirements.collect do |req|
|
123
|
-
(req[0] == 'sprout')
|
124
|
-
end
|
125
|
-
|
126
|
-
if(!sprout_requirement)
|
127
|
-
s.add_dependency('sprout', '>= 0.7.209')
|
128
|
-
end
|
129
|
-
|
130
|
-
if(File.exists?('sprout.spec'))
|
131
|
-
files << 'sprout.spec'
|
132
|
-
end
|
133
|
-
if(extensions.size > 0)
|
134
|
-
files << 'ext'
|
135
|
-
end
|
136
|
-
zipped_extensions.each do |ext|
|
137
|
-
files << File.join('ext', File.basename(ext))
|
138
|
-
end
|
139
|
-
s.files = files
|
140
|
-
end
|
141
|
-
Gem::Builder.new(spec).build
|
142
|
-
end
|
143
|
-
|
144
|
-
FileUtils.mv("#{gem_package}/#{@gem_name}-#{@version}.gem", @package)
|
145
|
-
FileUtils.rm_rf(gem_package)
|
146
|
-
end
|
147
|
-
|
148
|
-
# Add a gem dependency either with only the gem name
|
149
|
-
# or with a full name and version hash like:
|
150
|
-
#
|
151
|
-
# t.add_dependency('sprout-flashplayer-tool')
|
152
|
-
# or
|
153
|
-
# t.add_dependency('sprout-flashplayer-tool' => '9.115.0')
|
154
|
-
#
|
155
|
-
def add_dependency(args)
|
156
|
-
gem_dependencies << args
|
157
|
-
end
|
158
|
-
|
159
|
-
def gem_dependencies
|
160
|
-
return @gem_dependencies ||= []
|
161
|
-
end
|
162
|
-
|
163
|
-
# Add files to include in the gem/ext folder
|
164
|
-
def extensions
|
165
|
-
return @extensions ||= []
|
166
|
-
end
|
167
|
-
|
168
|
-
def libraries
|
169
|
-
@libraries ||= []
|
170
|
-
end
|
171
|
-
|
172
|
-
private
|
173
|
-
|
174
|
-
def gem_package
|
175
|
-
@gem_package ||= File.join(@package, @gem_name)
|
176
|
-
end
|
177
|
-
|
178
|
-
def zipped_extensions
|
179
|
-
return @zipped_extensions ||= []
|
180
|
-
end
|
181
|
-
|
182
|
-
def define_gem_name
|
183
|
-
@gem_name = "sprout-#{name}-#{@sprout_type}" if !@gem_name
|
184
|
-
end
|
185
|
-
|
186
|
-
def define_extensions(exts)
|
187
|
-
exts.each do |ext|
|
188
|
-
if(File.directory?(ext))
|
189
|
-
full = File.expand_path(ext)
|
190
|
-
t = nil
|
191
|
-
|
192
|
-
zip full do |z|
|
193
|
-
z.input = full
|
194
|
-
z.output = File.join(gem_name, 'ext', File.basename(full) + '.zip')
|
195
|
-
end
|
196
|
-
puts "pwd: #{Dir.pwd} out #{t.output}"
|
197
|
-
zipped_extensions << File.expand_path(t.output)
|
198
|
-
prerequisites << t.output
|
199
|
-
end
|
200
|
-
end
|
201
|
-
end
|
202
|
-
|
203
|
-
def render_sprout_spec(target, spec)
|
204
|
-
File.open(File.join(target, 'sprout.spec'), 'w') do |f|
|
205
|
-
f.write(spec)
|
206
|
-
end
|
207
|
-
end
|
208
|
-
|
209
|
-
end
|
210
|
-
end
|
211
|
-
|
212
|
-
def gem_wrap(args, &block)
|
213
|
-
Sprout::GemWrapTask.define_task(args, &block)
|
214
|
-
end
|
@@ -1,134 +0,0 @@
|
|
1
|
-
require 'sprout/version_file'
|
2
|
-
|
3
|
-
module Sprout
|
4
|
-
|
5
|
-
class GitTaskError < StandardError; end
|
6
|
-
|
7
|
-
# A Rake task for continous integration and automated deployment.
|
8
|
-
# This task will automatically load a +version_file+, increment
|
9
|
-
# the last digit (revision), create a new tag in Git with the full
|
10
|
-
# version number, and push tags to the remote Git repository.
|
11
|
-
#
|
12
|
-
# To use this task, simply add the following to your rakefile:
|
13
|
-
#
|
14
|
-
# desc 'Increment revision, tag and push with git'
|
15
|
-
# git :tag do |t|
|
16
|
-
# t.version_file = 'version.txt'
|
17
|
-
# end
|
18
|
-
#
|
19
|
-
|
20
|
-
class GitTask < Rake::Task
|
21
|
-
# Path to a plain text file that contains a three-part version number.
|
22
|
-
# @see VersionFile
|
23
|
-
attr_accessor :version_file
|
24
|
-
# The remote branch to use, defaults to 'origin'.
|
25
|
-
attr_accessor :remote
|
26
|
-
# The local branch to send, defaults to 'master'.
|
27
|
-
attr_accessor :branch
|
28
|
-
# Message to use when committing after incrementing revision number.
|
29
|
-
# Defaults to 'Incremented revision number'.
|
30
|
-
attr_accessor :commit_message
|
31
|
-
|
32
|
-
def initialize(name, app)
|
33
|
-
super
|
34
|
-
@remote = 'origin'
|
35
|
-
@branch = 'master'
|
36
|
-
@commit_message = 'Incremented revision number'
|
37
|
-
end
|
38
|
-
|
39
|
-
def version
|
40
|
-
@version.to_s
|
41
|
-
end
|
42
|
-
|
43
|
-
def define
|
44
|
-
validate
|
45
|
-
@version = VersionFile.new(version_file)
|
46
|
-
end
|
47
|
-
|
48
|
-
def execute(*args)
|
49
|
-
super
|
50
|
-
# Fix numeric comparison....
|
51
|
-
while(get_tags.index(@version.to_tag)) do
|
52
|
-
@version.increment_revision
|
53
|
-
end
|
54
|
-
create_tag(@version.to_tag)
|
55
|
-
commit
|
56
|
-
push
|
57
|
-
end
|
58
|
-
|
59
|
-
def self.define_task(args, &block)
|
60
|
-
begin
|
61
|
-
require 'git'
|
62
|
-
rescue LoadError => e
|
63
|
-
puts "You need to install the 'git' gem. Try running: sudo gem install git"
|
64
|
-
raise e
|
65
|
-
end
|
66
|
-
t = super
|
67
|
-
yield t if block_given?
|
68
|
-
t.define
|
69
|
-
return t
|
70
|
-
end
|
71
|
-
|
72
|
-
# Accessor for mocking the git gem.
|
73
|
-
def scm=(scm)
|
74
|
-
@scm = scm
|
75
|
-
end
|
76
|
-
|
77
|
-
# Will open on path if no SCM exists yet.
|
78
|
-
def scm
|
79
|
-
if(@scm.nil?)
|
80
|
-
path = path_to_git
|
81
|
-
raise GitTaskError.new("We don't appear to be inside of a git repository") if path.nil?
|
82
|
-
@scm = Git.open(path)
|
83
|
-
end
|
84
|
-
|
85
|
-
@scm
|
86
|
-
end
|
87
|
-
|
88
|
-
private
|
89
|
-
|
90
|
-
def push
|
91
|
-
`git push #{remote} #{branch} --tags`
|
92
|
-
end
|
93
|
-
|
94
|
-
def commit
|
95
|
-
`git commit -a -m "#{commit_message}"`
|
96
|
-
end
|
97
|
-
|
98
|
-
def path_to_git
|
99
|
-
git = '.git'
|
100
|
-
parts = Dir.pwd.split(File::SEPARATOR)
|
101
|
-
|
102
|
-
while(parts.size > 0) do
|
103
|
-
path = parts.join(File::SEPARATOR)
|
104
|
-
if(File.exists?(File.join(path, git)))
|
105
|
-
return path
|
106
|
-
end
|
107
|
-
parts.pop
|
108
|
-
end
|
109
|
-
|
110
|
-
return nil
|
111
|
-
end
|
112
|
-
|
113
|
-
def get_tags
|
114
|
-
return scm.tags.collect do |t|
|
115
|
-
t.name
|
116
|
-
end
|
117
|
-
end
|
118
|
-
|
119
|
-
def create_tag(name)
|
120
|
-
scm.add_tag name
|
121
|
-
end
|
122
|
-
|
123
|
-
def validate
|
124
|
-
raise GitTaskError.new("task.version_file is a required configuration for GitTask") if version_file.nil?
|
125
|
-
end
|
126
|
-
|
127
|
-
end
|
128
|
-
|
129
|
-
end
|
130
|
-
|
131
|
-
# Helper method for definining the git task in a rakefile
|
132
|
-
def git(args, &block)
|
133
|
-
Sprout::GitTask.define_task(args, &block)
|
134
|
-
end
|