sprout 0.5.29 → 0.7.153

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of sprout might be problematic. Click here for more details.

Files changed (48) hide show
  1. data/{MIT-LICENSE.txt → MIT-LICENSE} +0 -0
  2. data/TODO +12 -0
  3. data/bin/sprout +83 -140
  4. data/doc/Bundle +14 -0
  5. data/doc/Generator +35 -0
  6. data/doc/Library +63 -0
  7. data/doc/Task +21 -0
  8. data/doc/Tool +20 -0
  9. data/lib/platform.rb +2 -3
  10. data/lib/progress_bar.rb +39 -23
  11. data/lib/sprout/builder.rb +35 -0
  12. data/lib/sprout/commands/generate.rb +14 -0
  13. data/lib/sprout/general_tasks.rb +5 -0
  14. data/lib/sprout/generator/base_mixins.rb +132 -0
  15. data/lib/sprout/generator/named_base.rb +216 -0
  16. data/lib/sprout/generator.rb +6 -0
  17. data/lib/{log.rb → sprout/log.rb} +2 -2
  18. data/lib/sprout/process_runner.rb +46 -0
  19. data/lib/sprout/project_model.rb +114 -0
  20. data/lib/{remote_file_loader.rb → sprout/remote_file_loader.rb} +63 -36
  21. data/lib/sprout/remote_file_target.rb +96 -0
  22. data/lib/sprout/simple_resolver.rb +88 -0
  23. data/lib/sprout/tasks/gem_wrap_task.rb +192 -0
  24. data/lib/sprout/tasks/library_task.rb +103 -0
  25. data/lib/sprout/tasks/sftp_task.rb +245 -0
  26. data/lib/sprout/tasks/tool_task.rb +541 -0
  27. data/lib/sprout/tasks/zip_task.rb +158 -0
  28. data/lib/{template_resolver.rb → sprout/template_resolver.rb} +10 -7
  29. data/lib/{user.rb → sprout/user.rb} +84 -37
  30. data/lib/sprout/version.rb +4 -3
  31. data/lib/sprout/zip_util.rb +61 -0
  32. data/lib/sprout.rb +377 -285
  33. data/rakefile.rb +93 -119
  34. data/samples/gem_wrap/rakefile.rb +17 -0
  35. metadata +131 -96
  36. data/Manifest.txt +0 -9
  37. data/lib/command.rb +0 -29
  38. data/lib/file_target.rb +0 -8
  39. data/lib/generate.rb +0 -37
  40. data/lib/library.rb +0 -18
  41. data/lib/process_runner.rb +0 -27
  42. data/lib/project.rb +0 -10
  43. data/lib/project_model.rb +0 -59
  44. data/lib/remote_file_target.rb +0 -62
  45. data/lib/task.rb +0 -20
  46. data/lib/template.rb +0 -37
  47. data/lib/tool.rb +0 -18
  48. data/setup.rb +0 -1585
@@ -0,0 +1,132 @@
1
+
2
+ module Rails # :nodoc:[all]
3
+ module Generator # :nodoc:[all]
4
+
5
+ class Base # :nodoc:[all]
6
+
7
+ def initialize(runtime_args, runtime_options = {})
8
+ @args = runtime_args
9
+ parse!(@args, runtime_options)
10
+
11
+ # Derive source and destination paths.
12
+ @source_root = options[:source] || File.join(spec.path, 'templates')
13
+
14
+ if options[:destination]
15
+ @destination_root = options[:destination]
16
+ # The following two lines were changed:
17
+ #elsif defined? ::RAILS_ROOT
18
+ # @destination_root = ::RAILS_ROOT
19
+ elsif defined? Sprout::Sprout.project_path
20
+ @destination_root = Sprout::Sprout.project_path
21
+ else
22
+ @destination_root = Dir.pwd
23
+ end
24
+
25
+ # Silence the logger if requested.
26
+ logger.quiet = options[:quiet]
27
+
28
+ # Raise usage error if help is requested.
29
+ usage if options[:help]
30
+ end
31
+
32
+ end
33
+
34
+ # GemGeneratorSource hits the mines to quarry for generators. The latest versions
35
+ # of gems named sprout-#{sprout_name}-bundle are selected.
36
+ class GemGeneratorSource < AbstractGemSource # :nodoc:[all]
37
+
38
+ def initialize(name=nil)
39
+ super()
40
+ @sprout_name = name
41
+ end
42
+
43
+ # Yield latest versions of generator gems.
44
+ def each
45
+ Gem::cache.search(/sprout-*#{@sprout_name}-bundle$/).inject({}) { |latest, gem|
46
+ hem = latest[gem.name]
47
+ latest[gem.name] = gem if hem.nil? or gem.version > hem.version
48
+ latest
49
+ }.values.each { |gem|
50
+ yield Spec.new(gem.name.sub(/sprout-*#{@sprout_name}-bundle$/, ''), gem.full_gem_path, label)
51
+ }
52
+ end
53
+
54
+ def each_sprout
55
+ Gem::cache.search(/^sprout-.*/).inject({}) { |latest, gem|
56
+ hem = latest[gem.name]
57
+ latest[gem.name] = gem if hem.nil? or gem.version > hem.version
58
+ latest
59
+ }.values.each { |gem|
60
+ yield Spec.new(gem.name, gem.full_gem_path, label)
61
+ }
62
+ end
63
+ end
64
+
65
+ # GemPathSource looks for generators within any RubyGem's
66
+ # /sprout/generators/<generator_name>/<generator_name>_generator.rb file.
67
+ # It will only include generators from sprouts whose name includes
68
+ # #{sprout_name}-bundle
69
+ class GemPathSource < AbstractGemSource # :nodoc:[all]
70
+
71
+ def initialize(name=nil)
72
+ super()
73
+ @sprout_name = name
74
+ end
75
+
76
+ # Yield each generator within rails_generator subdirectories.
77
+ def each
78
+ generator_full_paths.each do |generator|
79
+ yield Spec.new(File.basename(generator).sub(/_generator.rb$/, ''), File.dirname(generator), label)
80
+ end
81
+ end
82
+
83
+ private
84
+ def generator_full_paths
85
+ @generator_full_paths ||=
86
+ Gem::cache.inject({}) do |latest, name_gem|
87
+ name, gem = name_gem
88
+ hem = latest[gem.name]
89
+ latest[gem.name] = gem if hem.nil? or gem.version > hem.version
90
+ latest
91
+ end.values.inject([]) do |mem, gem|
92
+ Dir[gem.full_gem_path + '/lib/sprout/**/generators/**/*_generator.rb'].each do |generator|
93
+ if(@sprout_name && gem.name.match(/sprout-#{@sprout_name}-bundle/))
94
+ mem << generator
95
+ end
96
+ end
97
+ mem
98
+ end
99
+ end
100
+ end
101
+
102
+ module Lookup # :nodoc:[all]
103
+ module ClassMethods # :nodoc:[all]
104
+
105
+ def use_sprout_sources!(sprout_name, project_path=nil)
106
+ reset_sources
107
+
108
+ # Project-specific generator paths
109
+ if project_path
110
+ sources << PathSource.new(:project, "#{project_path}/generators")
111
+ sources << PathSource.new(:script, "#{project_path}/script/generators")
112
+ sources << PathSource.new(:vendor, "#{project_path}/vendor/generators")
113
+ end
114
+
115
+ # System-wide generator paths
116
+ system_path = "#{Sprout::Sprout.sprout_cache}/generators/#{sprout_name}"
117
+ if(File.exists?(system_path))
118
+ sources << PathSource.new(:system, system_path)
119
+ end
120
+
121
+ # Gem generators will collect all
122
+ # rubygems that end with -bundle or -generators
123
+ if(Object.const_defined?(:Gem))
124
+ sources << GemGeneratorSource.new(sprout_name)
125
+ sources << GemPathSource.new(sprout_name)
126
+ end
127
+ end
128
+ end
129
+ end
130
+
131
+ end
132
+ end
@@ -0,0 +1,216 @@
1
+
2
+ module Sprout
3
+ module Generator #:nodoc:
4
+
5
+ class NamedBaseError < StandardError #:nodoc:
6
+ end
7
+
8
+ # The NamedBase is a good default base class for ActionScript class Generators.
9
+ # This class will accept the first command line argument and create
10
+ # many helpful properties for concrete generators to use.
11
+ #
12
+ # Can accept class names in following formats:
13
+ # * src/package/package/ClassName.as
14
+ # * test/package/package/ClassName.as
15
+ # * package/package/ClassName
16
+ # * package.package.ClassName
17
+ #
18
+ # Regardless of which format the name was sent in, the helper
19
+ # methods should provide valid results
20
+ #
21
+ class NamedBase < Rails::Generator::Base
22
+
23
+ # Fully qualified class named including package name like 'flash.display.Sprite'
24
+ attr_reader :full_class_name
25
+ # Path to the class file relative to your src_dir like 'flash/display/Sprite.as'
26
+ attr_reader :class_file
27
+ # The directory that contains the file, relative to your src_dir like 'flash/diplay'
28
+ attr_reader :class_dir
29
+ # The unqualified name of the class like 'Sprite'
30
+ attr_reader :class_name
31
+ # The package name of the class like 'flash.display'
32
+ attr_reader :package_name
33
+
34
+ def initialize(runtime_args, runtime_options = {})
35
+ super
36
+
37
+ rakefile = Sprout.project_rakefile
38
+ if(rakefile && File.exists?(rakefile))
39
+ load rakefile
40
+ end
41
+ @model = ProjectModel.instance
42
+
43
+ # Had to stop throwing on no args because the suite generator does
44
+ # not require the user to send in a class name....
45
+ #usage("Final argument must be a name parameter") if runtime_args.empty?
46
+ @args = runtime_args.dup
47
+ assign_names! @args.shift
48
+ end
49
+
50
+ # Quick access to the source directory identified by your project model
51
+ def src_dir
52
+ return model.src_dir
53
+ end
54
+
55
+ # Quick access to the test directory identified by your project model
56
+ def test_dir
57
+ return model.test_dir
58
+ end
59
+
60
+ # Quick access to the library directory identified by your project model
61
+ def lib_dir
62
+ return model.lib_dir
63
+ end
64
+
65
+ # The path to your project. This will either be the directory from which
66
+ # the sprout gem was executed, or the nearest ancestor directory that
67
+ # contains a properly named rakefile.
68
+ def project_path
69
+ return model.project_path
70
+ end
71
+
72
+ # The project_name that was either sent to the sprout gem or
73
+ # defined in your rakefile project model
74
+ def project_name
75
+ @project_name ||= (Sprout.project_name || model.project_name)
76
+ end
77
+
78
+ # The technology language that is stored in your project model usually (as2 or as3)
79
+ def language
80
+ return model.language
81
+ end
82
+
83
+ # Name of possible test case for this class_name
84
+ def test_case_name
85
+ @test_case_name ||= class_name + 'Test'
86
+ end
87
+
88
+ # Full name of the possible test case for this class_name
89
+ def full_test_case_name
90
+ full_class_name + 'Test'
91
+ end
92
+
93
+ # Full path to the parent directory that contains the class
94
+ # like 'src/flash/display' for flash.display.Sprite class.
95
+ def full_class_dir
96
+ @full_class_dir ||= File.join(src_dir, class_dir)
97
+ # pull trailing slash for classes in the root package
98
+ @full_class_dir.gsub!(/\/$/, '')
99
+ @full_class_dir
100
+ end
101
+
102
+ # Full path to the class file from your project_path like 'src/flash/display/Sprite.as'
103
+ def full_class_path
104
+ @full_class_path ||= File.join(src_dir, class_file)
105
+ end
106
+
107
+ # Filesystem path to the folder that contains the TestCase file
108
+ def full_test_dir
109
+ @full_test_dir ||= full_class_dir.gsub(src_dir, test_dir)
110
+ end
111
+
112
+ # Filesystem path to the TestCase file
113
+ def full_test_case_path
114
+ @full_test_case_path ||= File.join(full_test_dir, test_case_name + '.as')
115
+ end
116
+
117
+ def instance_name
118
+ name = class_name.dup;
119
+ char = name[0, 1]
120
+ name[0, 1] = char.downcase
121
+ if(name.size > 10)
122
+ name = 'instance'
123
+ end
124
+ return name
125
+ end
126
+
127
+ # Will return whether the user originally requested a class name
128
+ # that looks like a test case (e.g., name.match(/Test$/) )
129
+ def user_requested_test
130
+ @user_requested_test ||= false
131
+ end
132
+
133
+ # Glob that is used to search for test cases and build
134
+ # up the test suites
135
+ def test_glob
136
+ return @test_glob ||= '**/**/*Test.as'
137
+ end
138
+
139
+ def test_glob=(glob)
140
+ @test_glob = glob
141
+ end
142
+
143
+ # Collection of all test case files either assigned or found
144
+ # using the test_glob as provided.
145
+ def test_cases
146
+ @test_cases ||= Dir.glob(test_dir + test_glob)
147
+ end
148
+
149
+ def test_cases=(collection)
150
+ @test_cases = collection
151
+ end
152
+
153
+ # Get the list of test_cases (which are files) as a
154
+ # list of fully qualified class names
155
+ def test_case_classes
156
+ @test_case_classes = self.test_cases.dup
157
+ @test_case_classes.collect! do |file|
158
+ actionscript_file_to_class_name(file)
159
+ end
160
+ @test_case_classes
161
+ end
162
+
163
+ # Transform a file name in the source or test path
164
+ # to a fully-qualified class name
165
+ def actionscript_file_to_class_name(file)
166
+ name = file.dup
167
+ name.gsub!(/^#{Dir.pwd}\//, '')
168
+ name.gsub!(/^#{test_dir}\//, '')
169
+ name.gsub!(/^#{src_dir}\//, '')
170
+ name.gsub!(/.as$/, '')
171
+ name.gsub!(/#{File::SEPARATOR}/, '.')
172
+ return name
173
+ end
174
+
175
+ protected
176
+
177
+ def banner
178
+ "Usage: #{$0} [options] packagename.ClassName"
179
+ end
180
+
181
+ def model
182
+ @model ||= ProjectModel.instance
183
+ end
184
+
185
+ def assign_names!(name)
186
+ # trim file name suffix in case it was submitted
187
+ name.gsub!(/\//, '.')
188
+ name.gsub!(/\.as$/, '')
189
+ name.gsub!(/\.mxml$/, '')
190
+ if(model)
191
+ # Pull leading src_dir from class name if submitted
192
+ name.gsub!(/^#{src_dir}\./, '')
193
+ name.gsub!(/^#{test_dir}\./, '')
194
+ end
195
+
196
+ if(name.match(/Test$/))
197
+ @user_requested_test = true
198
+ name = name.gsub(/Test$/, '')
199
+ end
200
+ if(name.match(/^I/) || name.match(/able$/))
201
+ @user_requested_interface = true
202
+ end
203
+
204
+ @full_class_name = name
205
+ parts = name.split('.')
206
+ @class_name = parts.pop
207
+ @package_name = parts.join('.')
208
+ @class_file = @full_class_name.split('.').join(File::SEPARATOR) + '.as'
209
+ @class_dir = File.dirname(@class_file)
210
+ if(@class_dir == '.')
211
+ @class_dir = ''
212
+ end
213
+ end
214
+ end
215
+ end
216
+ end
@@ -0,0 +1,6 @@
1
+ gem 'activesupport', '>= 2.0.2'
2
+ require 'rails_generator'
3
+ require 'sprout/generator/base_mixins'
4
+ require 'sprout/generator/named_base'
5
+
6
+ # This is the entry point for sprout generator features
@@ -1,7 +1,7 @@
1
1
 
2
- module PatternPark
2
+ module Sprout #:nodoc:
3
3
 
4
- class Log
4
+ class Log #:nodoc:
5
5
  @@debug = false
6
6
  @@output = ''
7
7
  @@printout = ''
@@ -0,0 +1,46 @@
1
+
2
+ module Sprout #:nodoc:
3
+ class ProcessRunnerError < StandardError # :nodoc:
4
+ end
5
+
6
+ class ProcessRunner #:nodoc:
7
+ attr_reader :pid,
8
+ :r,
9
+ :w,
10
+ :e
11
+
12
+ def initialize(*command)
13
+ @command = command
14
+ begin
15
+ usr = User.new()
16
+ if(usr.is_a?(WinUser) && !usr.is_a?(CygwinUser))
17
+ require 'win32/open3'
18
+ Open3.popen3(*@command) do |w, r, e, pid|
19
+ @w = w
20
+ @r = r
21
+ @e = e
22
+ @pid = pid
23
+ end
24
+ else
25
+ require 'open4'
26
+ @pid, @w, @r, @e = open4.popen4(*@command)
27
+ end
28
+ rescue Errno::ENOENT => e
29
+ part = command[0].split(' ').shift
30
+ raise ProcessRunnerError.new("The expected executable was not found for command [#{part}], please check your system path and/or sprout definition")
31
+ end
32
+ end
33
+
34
+ def puts(msg)
35
+ @w.puts(msg)
36
+ end
37
+
38
+ def read
39
+ return r.read
40
+ end
41
+
42
+ def read_err
43
+ return e.read
44
+ end
45
+ end
46
+ end
@@ -0,0 +1,114 @@
1
+
2
+ module Sprout
3
+
4
+ # The ProjectModel gives you a place to describe your project so that you
5
+ # don't need to repeat yourself throughout a rakefile.
6
+ #
7
+ # The default set of properties are also used from code generators, library tasks and sometimes tools.
8
+ #
9
+ # This class should have some reasonable default values, but can be modified from any rakefile.
10
+ # If you don't find some properties that you'd like on the ProjectModel, you can simply add
11
+ # new properties and use them however you wish!
12
+ class ProjectModel < Hash
13
+
14
+ # The real name of the project, usually capitalized like a class name 'SomeProject'
15
+ attr_accessor :project_name
16
+ # The relative path to your main source directory. Defaults to 'src'
17
+ attr_accessor :src_dir
18
+ # The relative path to your library directory. Defaults to 'lib'
19
+ #
20
+ # Any remote .SWC and source libraries that are referenced in your rakefile will be installed
21
+ # into this directory. Source libraries will be placed in a folder that matches the library name,
22
+ # while SWCs will be simply placed directly into the lib_dir.
23
+ attr_accessor :lib_dir
24
+ # The folder where binary files will be created. Usually this is where any build artifacts like SWF files get placed.
25
+ attr_accessor :bin_dir
26
+ # Relative path to the folder that contains your test cases
27
+ attr_accessor :test_dir
28
+ # Relative path to the folder where compile time assets will be stored
29
+ attr_accessor :asset_dir
30
+ # The folder where compile time skins can be loaded from
31
+ attr_accessor :skin_dir
32
+ # The technology language that is being used, right now this is either 'as2' or 'as3'.
33
+ # Code generators take advantage of this setting to determine which templates to use.
34
+ attr_accessor :language
35
+
36
+ # TODO: Add clean hash interface so that users
37
+ # can simply add to this object's properties like:
38
+ # model.foo = 'bar'
39
+ # model.junk = true
40
+ # and then just as easily reference those vars from
41
+ # external generators...
42
+ def self.instance
43
+ @@instance ||= ProjectModel.new
44
+ end
45
+
46
+ def self.destroy # :nodoc:
47
+ @@instance = nil
48
+ end
49
+
50
+ def initialize
51
+ super
52
+ @project_name = ''
53
+ @src_dir = 'src'
54
+ @lib_dir = 'lib'
55
+ @bin_dir = 'bin'
56
+ @test_dir = 'test'
57
+ @asset_dir = 'assets'
58
+ @skin_dir = File.join(@asset_dir, 'skins')
59
+
60
+ @language = 'as3'
61
+
62
+ @model_dir = nil
63
+ @view_dir = nil
64
+ @controller_dir = nil
65
+ end
66
+
67
+ # Path to the project directory from which all other paths are created
68
+ def project_path
69
+ return Sprout.project_path
70
+ end
71
+
72
+ def model_dir=(dir)
73
+ @model_dir = dir
74
+ end
75
+
76
+ # Simple MVC helper for project-wide models if your project is called 'SomeProject'
77
+ # this will default to:
78
+ # SomeProject/src/someproject/models
79
+ def model_dir
80
+ if(@model_dir.nil?)
81
+ @model_dir = File.join(src_dir, project_name.downcase, 'models')
82
+ end
83
+ return @model_dir
84
+ end
85
+
86
+ def view_dir=(dir)
87
+ @view_dir = dir
88
+ end
89
+
90
+ # Simple MVC helper for project-wide views if your project is called 'SomeProject'
91
+ # this will default to:
92
+ # SomeProject/src/someproject/views
93
+ def view_dir
94
+ if(@view_dir.nil?)
95
+ @view_dir = File.join(src_dir, project_name.downcase, 'views')
96
+ end
97
+ return @view_dir
98
+ end
99
+
100
+ def controller_dir=(dir)
101
+ @controller_dir = dir
102
+ end
103
+
104
+ # Simple MVC helper for project-wide views if your project is called 'SomeProject'
105
+ # this will default to:
106
+ # SomeProject/src/someproject/controllers
107
+ def controller_dir
108
+ if(@controller_dir.nil?)
109
+ @controller_dir = File.join(src_dir, project_name.downcase, 'controllers')
110
+ end
111
+ return @controller_dir
112
+ end
113
+ end
114
+ end
@@ -1,45 +1,52 @@
1
- require 'open-uri'
2
1
 
3
- module PatternPark
4
- class RemoteFileLoader
2
+ module Sprout
3
+ class RemoteFileLoaderError < StandardError #:nodoc:
4
+ end
5
+
6
+ class RemoteFileLoader #:nodoc:
5
7
  include Archive::Tar
6
8
 
7
- def get_remote_file(uri, target)
8
- if(Sprout.update || !File.exists?(target))
9
- begin
10
- response = fetch(uri.to_s)
11
- rescue SocketError => e
12
- puts "[ERROR] Unable to connect to #{uri}"
13
- return
14
- end
15
- FileUtils.makedirs(File.dirname(target))
16
-
17
- if(Sprout.update && File.exists?(target))
18
- File.delete(target)
19
- end
20
-
21
- File.open(target, 'wb') do |f|
22
- f.write(response)
9
+ def get_remote_file(uri, target, force=false, md5=nil)
10
+ if(force || !File.exists?(target))
11
+ response = fetch(uri.to_s)
12
+ if(response_is_valid?(response, md5))
13
+ write(response, target, force)
23
14
  end
24
15
  end
25
16
  end
26
17
 
27
- def fetch(location)
28
- uri = URI.parse(location)
29
-
18
+ def response_is_valid?(response, expected_md5sum=nil)
19
+ if(expected_md5sum)
20
+ md5 = Digest::MD5.new
21
+ md5 << response
22
+ raise BadCheckSum if (expected_md5sum != md5.hexdigest)
23
+ end
24
+ return true
25
+ end
26
+
27
+ def write(response, target, force=false)
28
+ FileUtils.makedirs(File.dirname(target))
29
+ if(force && File.exists?(target))
30
+ File.delete(target)
31
+ end
32
+ File.open(target, 'wb') do |f|
33
+ f.write(response)
34
+ end
35
+ end
36
+
37
+ def fetch(uri)
38
+ uri = URI.parse(uri)
30
39
  # Download the file now to the downloads dir
31
40
  # If the file is an archive (zip, gz, tar, tar.gz, dmg), extract to
32
- # AsProject/remote_files/@name/@location
41
+ # Sprouts/cache/@type/@name
33
42
  # Check the location again...
34
43
  progress = nil
35
44
  response = nil
36
- head = nil
37
45
  name = uri.path.split("/").pop
38
-
39
- raise UsageError.new("The RemoteFileTask failed for #{name}. WE can only handle HTTP requests at this time, it seems you were trying: #{location}") if uri.scheme != 'http'
40
46
 
41
-
42
- open(uri.to_s, :content_length_proc => lambda {|t|
47
+ raise RemoteFileLoaderError.new("The RemoteFileTask failed for #{name}. We can only handle HTTP requests at this time, it seems you were trying: '#{uri.scheme}'") if uri.scheme != 'http'
48
+ begin
49
+ open(uri.to_s, :content_length_proc => lambda {|t|
43
50
  if t && t > 0
44
51
  progress = ProgressBar.new(name, t)
45
52
  progress.file_transfer_mode
@@ -56,8 +63,15 @@ module PatternPark
56
63
  response = f.read
57
64
  progress.finish
58
65
  }
59
-
60
- return response
66
+ rescue SocketError => e
67
+ raise RemoteFileLoaderError.new("[ERROR] #{e.to_s}")
68
+ rescue OpenURI::HTTPError => e
69
+ raise RemoteFileLoaderError.new("[ERROR] Failed to load file from: '#{uri.to_s}'\n[REMOTE ERROR] #{e.io.read.strip}")
70
+ rescue Errno::ECONNREFUSED => e
71
+ raise Errno::ECONNREFUSED.new("[ERROR] Connection refused at: '#{uri.to_s}'")
72
+ end
73
+
74
+ return response
61
75
  end
62
76
 
63
77
  def unpack_downloaded_file(file_name, dir)
@@ -72,7 +86,10 @@ module PatternPark
72
86
  # just copy the swc...
73
87
  elsif(is_rb?(file_name))
74
88
  return
75
- elsif(!is_exe?(file_name))
89
+ elsif(is_exe?(file_name))
90
+ FileUtils.mkdir_p(dir)
91
+ File.mv(file_name, dir)
92
+ else
76
93
  raise UsageError.new("RemoteFileTask does not know how to unpack files of type: #{file_name}")
77
94
  end
78
95
  end
@@ -84,7 +101,11 @@ module PatternPark
84
101
  if(RUBY_PLATFORM =~ /darwin/)
85
102
  # Unzipping on OS X
86
103
  FileUtils.makedirs(dir)
87
- %x(cd #{dir};unzip #{zip_file})
104
+ zip_dir = File.expand_path(File.dirname(zip_file))
105
+ zip_name = File.basename(zip_file)
106
+ output = File.expand_path(dir)
107
+ #puts ">> zip_dir: #{zip_dir} zip_name: #{zip_name} output: #{output}"
108
+ %x(cd #{zip_dir};unzip #{zip_name} -d #{output})
88
109
  else
89
110
  retries = 0
90
111
  begin
@@ -93,7 +114,7 @@ module PatternPark
93
114
  zf.each do |e|
94
115
  fpath = File.join(dir, e.name)
95
116
  FileUtils.mkdir_p(File.dirname(fpath))
96
- # Disgusting, Gross Hack to fix Windows/Ruby Bug
117
+ # Disgusting, Gross Hack to fix DOS/Ruby Bug
97
118
  # That makes the zip library throw a ZipDestinationFileExistsError
98
119
  # When the zip archive includes two files whose names
99
120
  # differ only by extension.
@@ -130,6 +151,15 @@ module PatternPark
130
151
  end
131
152
  tar = Zlib::GzipReader.new(File.open(tgz_file, 'rb'))
132
153
  Minitar.unpack(tar, dir)
154
+
155
+ # Recurse and unpack gzipped children (Adobe did this double
156
+ # gzip with the Linux FlashPlayer for some reason)
157
+ Dir.glob("#{dir}/**/*.tar.gz").each do |child|
158
+ if(child != tgz_file)
159
+ unpack_targz(child, File.dirname(child))
160
+ end
161
+ end
162
+
133
163
  end
134
164
 
135
165
  # This is actually not unpacking the FlashPlayer
@@ -155,12 +185,9 @@ module PatternPark
155
185
  # Copy the DMG contents using system copy rather than ruby utils
156
186
  # Because OS X does something special with .app files that the
157
187
  # Ruby FileUtils and File classes break...
158
- Log.puts '=================='
159
188
  from = mounted_target
160
189
  # from = File.join(full_mounted_path, extracted_file)
161
190
  to = File.join(@user.downloads, @name.to_s, extracted_file)
162
- Log.puts 'from: ' + from
163
- Log.puts 'to: ' + to
164
191
  FileUtils.makedirs(File.dirname(to))
165
192
 
166
193
  if(File.exists?(from))