sprout 0.7.191-mswin32

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.

@@ -0,0 +1,96 @@
1
+
2
+ module Sprout
3
+ class RemoteFileTargetError < StandardError #:nodoc:
4
+ end
5
+
6
+ class RemoteFileTarget # :nodoc:
7
+
8
+ attr_writer :archive_path
9
+
10
+ # The user path where this gem will download and install files
11
+ # This value is set by the Sprout::Builder that creates this RemoteFileTarget
12
+ attr_accessor :install_path
13
+
14
+ # Optional md5 hash, usually set in the sprout.spec for each RemoteFileTarget
15
+ # If this value is set, the downloaded archive will be hashed, the hashes will
16
+ # be compared and if they differ, the installation process will break.
17
+ attr_accessor :md5
18
+
19
+ # Used for dmg archives. Absolute path to the mounted dmg (essentially it's name)
20
+ attr_accessor :mount_path
21
+
22
+ # Which platform will this RemoteFileTarget support.
23
+ # Supported options are:
24
+ # * universal
25
+ # * macosx
26
+ # * win32
27
+ # * linux
28
+ attr_accessor :platform
29
+
30
+ # URL where Sprouts can go to download the RemoteFileTarget archive
31
+ attr_accessor :url
32
+
33
+ # Relative path within the archive to the executable or binary of interest
34
+ def archive_path
35
+ @archive_path ||= ''
36
+ end
37
+
38
+ # Resolve this RemoteFileTarget now. This method is called by the Sprout::Builder
39
+ # and will download, install and unpack the described archive
40
+ def resolve(update=false)
41
+ if(url)
42
+ @loader = RemoteFileLoader.new
43
+ if(url && (update || !File.exists?(downloaded_path)))
44
+ download(url, downloaded_path, update)
45
+ end
46
+
47
+ if(!File.exists?(installed_path) || !File.exists?(File.join(installed_path, archive_path) ))
48
+ archive_root = File.join(install_path, 'archive')
49
+ install(downloaded_path, archive_root)
50
+ end
51
+ end
52
+ end
53
+
54
+ # Return the basename of the executable that this RemoteFileTarget refers to
55
+ def executable
56
+ return File.basename(archive_path)
57
+ end
58
+
59
+ # The root path to the unpacked archive files. This is the base path that will be added to any
60
+ # +archive_path+ relative paths
61
+ def installed_path
62
+ @installed_path ||= File.join(install_path, 'archive')
63
+ return @installed_path
64
+ end
65
+
66
+ # Parent directory where archives are downloaded
67
+ # can be something like: ~/Library/Sprouts/cache/0.7/sprout-somesprout-tool.x.x.x/
68
+ def downloaded_path
69
+ @downloaded_path ||= File.join(install_path, file_name)
70
+ return @downloaded_path
71
+ end
72
+
73
+ # Base file name represented by the provided +url+
74
+ # Will strip off any ? arguments and trailing slashes. May not play nice with Rails URLS,
75
+ # We expect archive file name suffixes like, zip, gzip, tar.gz, dmg, etc.
76
+ def file_name
77
+ if(url.split('').last == '/')
78
+ return name
79
+ end
80
+ file = url.split('/').pop
81
+ file = file.split('?').shift
82
+ return file
83
+ end
84
+
85
+ private
86
+ def download(url, path, update=false)
87
+ @loader = RemoteFileLoader.new
88
+ @loader.get_remote_file(url, path, update, md5)
89
+ end
90
+
91
+ def install(from, to)
92
+ @loader.unpack_downloaded_file(from, to)
93
+ end
94
+
95
+ end
96
+ end
@@ -0,0 +1,88 @@
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
@@ -0,0 +1,192 @@
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
+
67
+ def self.define_task(args, &block)
68
+ t = super
69
+ yield t if block_given?
70
+ t.define
71
+ end
72
+
73
+ def define # :nodoc:
74
+ define_gem_name
75
+ define_extensions(extensions)
76
+ end
77
+
78
+ def initialize(task_name, app) # :nodoc:
79
+ super
80
+ @sprout_type = "library"
81
+ @package = "pkg"
82
+ @summary = "#{task_name}"
83
+ @email = "projectsprouts@googlegroups.com"
84
+ @homepage = "http://www.projectsprouts.org"
85
+ end
86
+
87
+ def execute(*args) # :nodoc:
88
+ super
89
+ raise GemWrapError.new("A version must be provided to produce a Gem!") unless @version
90
+ @summary = "#{name} #{@sprout_type} generated by Sprout::GemWrapTask" unless @summary
91
+
92
+ FileUtils.mkdir_p(gem_package)
93
+ render_sprout_spec(gem_package, @sprout_spec) if @sprout_spec
94
+ # render_extensions(gem_package, extensions) if extensions.size
95
+
96
+ Dir.chdir(gem_package) do
97
+
98
+ spec = Gem::Specification.new do |s|
99
+ files = []
100
+ s.platform = Gem::Platform::RUBY
101
+ s.version = @version
102
+ s.author = @author if @author
103
+ s.summary = @summary
104
+ s.name = @gem_name
105
+ s.email = @email
106
+ s.homepage = @homepage
107
+ s.rubyforge_project = 'sprout'
108
+ s.requirements << {'sprout', '>= 0.7.1'}
109
+ gem_dependencies.each do |dep|
110
+ s.requirements << dep
111
+ end
112
+ if(File.exists?('sprout.spec'))
113
+ files << 'sprout.spec'
114
+ end
115
+ if(extensions.size > 0)
116
+ files << 'ext'
117
+ end
118
+ zipped_extensions.each do |ext|
119
+ files << File.join('ext', File.basename(ext))
120
+ end
121
+ s.files = files
122
+ end
123
+ Gem::Builder.new(spec).build
124
+ end
125
+
126
+ FileUtils.mv("#{gem_package}/#{@gem_name}-#{@version}.gem", @package)
127
+ FileUtils.rm_rf(gem_package)
128
+ end
129
+
130
+ # Add a gem dependency either with only the gem name
131
+ # or with a full name and version hash like:
132
+ #
133
+ # t.add_dependency('sprout-flashplayer-tool')
134
+ # or
135
+ # t.add_dependency('sprout-flashplayer-tool' => '9.115.0')
136
+ #
137
+ def add_dependency(args)
138
+ gem_dependencies << args
139
+ end
140
+
141
+ def gem_dependencies
142
+ return @gem_dependencies ||= []
143
+ end
144
+
145
+ # Add files to include in the gem/ext folder
146
+ def extensions
147
+ return @extensions ||= []
148
+ end
149
+
150
+ private
151
+
152
+ def gem_package
153
+ @gem_package ||= File.join(@package, @gem_name)
154
+ end
155
+
156
+ def zipped_extensions
157
+ return @zipped_extensions ||= []
158
+ end
159
+
160
+ def define_gem_name
161
+ @gem_name = "sprout-#{name}-#{@sprout_type}" if !@gem_name
162
+ end
163
+
164
+ def define_extensions(exts)
165
+ exts.each do |ext|
166
+ if(File.directory?(ext))
167
+ full = File.expand_path(ext)
168
+ t = nil
169
+
170
+ zip full do |t|
171
+ t.input = full
172
+ t.output = File.join(gem_name, 'ext', File.basename(full) + '.zip')
173
+ end
174
+ puts "pwd: #{Dir.pwd} out #{t.output}"
175
+ zipped_extensions << File.expand_path(t.output)
176
+ prerequisites << t.output
177
+ end
178
+ end
179
+ end
180
+
181
+ def render_sprout_spec(target, spec)
182
+ File.open(File.join(target, 'sprout.spec'), 'w') do |f|
183
+ f.write(spec)
184
+ end
185
+ end
186
+
187
+ end
188
+ end
189
+
190
+ def gem_wrap(args, &block)
191
+ Sprout::GemWrapTask.define_task(args, &block)
192
+ end
@@ -0,0 +1,113 @@
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
+
24
+ module Sprout
25
+ class LibraryError < StandardError #:nodoc:
26
+ end
27
+
28
+ # :include: ../../../doc/Library
29
+ class LibraryTask < Rake::Task
30
+
31
+ # The RubyGems gem version string for this library (e.g., +version = '0.0.1'+)
32
+ attr_accessor :version
33
+
34
+ attr_writer :gem_name # :nodoc:
35
+ attr_writer :project_lib # :nodoc:
36
+
37
+ def self.define_task(args, &block) # :nodoc:
38
+ t = super
39
+ yield t if block_given?
40
+ t.define
41
+ end
42
+
43
+ # The full gem name like 'sprout-asunit3-library'
44
+ def gem_name
45
+ @gem_name ||= "sprout-#{clean_name}-library"
46
+ end
47
+
48
+ # Ensure that namespaced rake tasks only use
49
+ # the final part for name-based features
50
+ def clean_name
51
+ return name.split(':').pop
52
+ end
53
+
54
+ # The path to the library source or swc that will be copied into your project.
55
+ # This can actually be any full or relative path on your system, but should almost
56
+ # always be left alone for automatic resolution.
57
+ def library_path
58
+ @library_path ||= nil
59
+ end
60
+
61
+ # Override the the project folder where the library will be installed.
62
+ #
63
+ # By default, libraries are installed into Sprout::ProjectModel +lib_dir+.
64
+ def project_lib
65
+ if(library_path.index('.swc'))
66
+ @project_lib ||= ProjectModel.instance.swc_dir
67
+ else
68
+ @project_lib ||= ProjectModel.instance.lib_dir
69
+ end
70
+ end
71
+
72
+ # Unlike other rake tasks, Library tasks are actually
73
+ # resolved at 'define' time. This allows the tool tasks
74
+ # to build their own dependencies (like file deps)
75
+ # (I'm sure there's a better way to do this, if you know how to fix this,
76
+ # and would like to contribute to sprouts, this might be a good spot for it)
77
+ def define
78
+ @file_target = sprout(gem_name, version)
79
+ @library_path = File.join(@file_target.installed_path, @file_target.archive_path)
80
+ define_file_task(library_path, project_path)
81
+ end
82
+
83
+ def execute(*args) # :nodoc:
84
+ super
85
+ end
86
+
87
+ # The path within the project where this library is installed
88
+ def project_path
89
+ if(File.directory?(@library_path))
90
+ # library is source dir
91
+ File.join(project_lib, clean_name)
92
+ else
93
+ # library is a binary (like swc, jar, etc)
94
+ File.join(project_lib, File.basename(@file_target.archive_path))
95
+ end
96
+ end
97
+
98
+ private
99
+
100
+ def define_file_task(source, destination)
101
+ file destination do |t|
102
+ FileUtils.cp_r(library_path, destination)
103
+ end
104
+ prerequisites << destination
105
+ end
106
+
107
+ end
108
+ end
109
+
110
+ # Helper method for definining and accessing LibraryTask instances in a rakefile
111
+ def library(args, &block)
112
+ Sprout::LibraryTask.define_task(args, &block)
113
+ end