=begin Copyright (c) 2007 Pattern Park Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. TODO: Update mxmlc task * Update mxmlc to include all advanced options * Clean up default values * Investigate jruby support, especially: http://livedocs.adobe.com/flex/201/html/wwhelp/wwhimpl/common/html/wwhelp.htm?context=LiveDocs_Book_Parts&file=compilers_123_09.html =end module Sprout class GemWrapError < StandardError #:nodoc: end # Creates a ruby gem from a slightly simpler rake task than what gems provides. # Adds support for adding a sprout.spec file to your new gem which is usually useful # for tool or library sprout gems. class GemWrapTask < Rake::Task # The full name of the gem to create like: # t.gem_name = 'sprout-as3-bundle' attr_writer :gem_name # The type of sprout to create, defaults to 'library' # Other possible values are, 'bundle' and 'tool' attr_writer :sprout_type # Full string rubygem version for this sprout, usually in three parts like: # t.version = '0.0.1' attr_writer :version # Folder that the newly-created gem should be placed in attr_writer :package # Summary or short description for the gem attr_writer :summary # The author that created the gem attr_writer :author # Email address for interested users to send questions to attr_writer :email # Homepage where users can learn more about this gem attr_writer :homepage # A string remote file specification usually something like: # # t.sprout_spec =<= 0.7.1'} gem_dependencies.each do |dep| s.requirements << dep end if(File.exists?('sprout.spec')) files << 'sprout.spec' end if(extensions.size > 0) files << 'ext' end zipped_extensions.each do |ext| files << File.join('ext', File.basename(ext)) end s.files = files end Gem::Builder.new(spec).build end FileUtils.mv("#{gem_package}/#{@gem_name}-#{@version}.gem", @package) FileUtils.rm_rf(gem_package) end # Add a gem dependency either with only the gem name # or with a full name and version hash like: # # t.add_dependency('sprout-flashplayer-tool') # or # t.add_dependency('sprout-flashplayer-tool' => '9.115.0') # def add_dependency(args) gem_dependencies << args end def gem_dependencies return @gem_dependencies ||= [] end # Add files to include in the gem/ext folder def extensions return @extensions ||= [] end private def gem_package @gem_package ||= File.join(@package, @gem_name) end def zipped_extensions return @zipped_extensions ||= [] end def define_gem_name @gem_name = "sprout-#{name}-#{@sprout_type}" if !@gem_name end def define_extensions(exts) exts.each do |ext| if(File.directory?(ext)) full = File.expand_path(ext) t = nil zip full do |t| t.input = full t.output = File.join(gem_name, 'ext', File.basename(full) + '.zip') end puts "pwd: #{Dir.pwd} out #{t.output}" zipped_extensions << File.expand_path(t.output) prerequisites << t.output end end end def render_sprout_spec(target, spec) File.open(File.join(target, 'sprout.spec'), 'w') do |f| f.write(spec) end end end end def gem_wrap(args, &block) Sprout::GemWrapTask.define_task(args, &block) end