sprout 1.0.26.pre → 1.0.29.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/lib/sprout/base.rb +6 -2
- data/lib/sprout/executable.rb +10 -9
- data/lib/sprout/file_target.rb +2 -2
- data/lib/sprout/library.rb +119 -54
- data/lib/sprout/remote_file_loader.rb +8 -36
- data/lib/sprout/remote_file_target.rb +44 -5
- data/lib/sprout/ruby_feature.rb +4 -2
- data/lib/sprout/system/unix_system.rb +3 -0
- data/lib/sprout/version.rb +1 -1
- data/rakefile.rb +5 -0
- data/test/fixtures/executable/mxmlc.rb +4 -5
- data/test/unit/archive_unpacker_test.rb +1 -1
- data/test/unit/boolean_param_test.rb +1 -1
- data/test/unit/executable_option_parser_test.rb +2 -2
- data/test/unit/executable_param_test.rb +1 -1
- data/test/unit/executable_test.rb +14 -10
- data/test/unit/file_param_test.rb +1 -1
- data/test/unit/file_target_test.rb +6 -1
- data/test/unit/files_param_test.rb +2 -2
- data/test/unit/generator_generator_test.rb +1 -1
- data/test/unit/generator_test.rb +3 -3
- data/test/unit/library_generator_test.rb +1 -2
- data/test/unit/library_test.rb +13 -17
- data/test/unit/osx_system_test.rb +1 -1
- data/test/unit/path_param_test.rb +1 -1
- data/test/unit/paths_param_test.rb +1 -1
- data/test/unit/platform_test.rb +1 -1
- data/test/unit/process_runner_test.rb +1 -1
- data/test/unit/rdoc_parser_test.rb +2 -2
- data/test/unit/remote_file_loader_test.rb +1 -11
- data/test/unit/remote_file_target_test.rb +28 -19
- data/test/unit/ruby_feature_test.rb +1 -1
- data/test/unit/ruby_generator_test.rb +1 -1
- data/test/unit/specification_test.rb +1 -1
- data/test/unit/sprout_test.rb +1 -1
- data/test/unit/string_param_test.rb +1 -1
- data/test/unit/string_test.rb +1 -1
- data/test/unit/strings_param_test.rb +1 -1
- data/test/unit/tool_generator_test.rb +1 -1
- data/test/unit/unix_system_test.rb +1 -1
- data/test/unit/user_test.rb +1 -1
- data/test/unit/vista_system_test.rb +1 -1
- data/test/unit/win_nix_system_test.rb +1 -1
- data/test/unit/win_system_test.rb +2 -2
- metadata +3 -18
data/lib/sprout/base.rb
CHANGED
@@ -70,9 +70,13 @@ module Sprout
|
|
70
70
|
Sprout::System.create
|
71
71
|
end
|
72
72
|
|
73
|
+
##
|
74
|
+
# Get the file name from the 'caller' property of
|
75
|
+
# a Ruby exception.
|
76
|
+
#
|
77
|
+
# Note: It's a bummer that this string is colon delimited -
|
78
|
+
# The value on Windows can include a colon...
|
73
79
|
def file_from_caller caller_string
|
74
|
-
# NOTE: It's a bummer that this string is colon delimited -
|
75
|
-
# The value on Windows sometimes includes a colon...
|
76
80
|
parts = caller_string.split(':')
|
77
81
|
str = parts.shift
|
78
82
|
while(parts.size > 0 && !File.exists?(str))
|
data/lib/sprout/executable.rb
CHANGED
@@ -15,7 +15,7 @@ require 'sprout/executable/parameter_factory'
|
|
15
15
|
module Sprout
|
16
16
|
|
17
17
|
##
|
18
|
-
# The Sprout::Executable module
|
18
|
+
# The Sprout::Executable module exposes a Domain Specific Language
|
19
19
|
# for describing Command Line Interface (CLI) applications.
|
20
20
|
#
|
21
21
|
# This module can be included by any class, and depending on how that class
|
@@ -408,19 +408,20 @@ module Sprout
|
|
408
408
|
# This method will generally be overridden
|
409
409
|
# by subclasses and they can do whatever customization
|
410
410
|
# is necessary for a particular library type.
|
411
|
-
|
411
|
+
#
|
412
|
+
# It's important to note that this value can be
|
413
|
+
# a String path to a file (or folder), or it can
|
414
|
+
# be an Array of paths to files (or folders).
|
415
|
+
def library_added path_or_paths
|
412
416
|
end
|
413
417
|
|
414
418
|
private
|
415
419
|
|
416
420
|
def handle_library_prerequisites items
|
417
|
-
items.each do |
|
418
|
-
t = Rake.application[
|
419
|
-
if(t.
|
420
|
-
|
421
|
-
lib.project_paths.each do |path|
|
422
|
-
library_added path
|
423
|
-
end unless lib.project_paths.nil?
|
421
|
+
items.each do |task_name|
|
422
|
+
t = Rake.application[task_name]
|
423
|
+
if(!t.sprout_entity.nil?)
|
424
|
+
library_added t.sprout_entity.installed_project_path
|
424
425
|
end
|
425
426
|
end
|
426
427
|
end
|
data/lib/sprout/file_target.rb
CHANGED
@@ -43,7 +43,7 @@ module Sprout
|
|
43
43
|
else
|
44
44
|
path = expand_executable_path path
|
45
45
|
end
|
46
|
-
libraries <<
|
46
|
+
libraries << Sprout::Library.new( :name => name, :path => path, :file_target => self )
|
47
47
|
end
|
48
48
|
|
49
49
|
##
|
@@ -59,7 +59,7 @@ module Sprout
|
|
59
59
|
end
|
60
60
|
|
61
61
|
def to_s
|
62
|
-
"[FileTarget
|
62
|
+
"[FileTarget pkg_name=#{pkg_name} pkg_version=#{pkg_version} platform=#{platform}]"
|
63
63
|
end
|
64
64
|
|
65
65
|
def validate
|
data/lib/sprout/library.rb
CHANGED
@@ -1,15 +1,27 @@
|
|
1
1
|
|
2
2
|
module Sprout
|
3
|
-
|
3
|
+
class Library
|
4
|
+
include RubyFeature
|
5
|
+
|
4
6
|
TASK_NAME = :resolve_sprout_libraries
|
5
7
|
|
6
|
-
|
8
|
+
attr_accessor :file_target
|
9
|
+
attr_accessor :installed_project_path
|
10
|
+
attr_accessor :name
|
11
|
+
attr_accessor :path
|
12
|
+
attr_accessor :pkg_name
|
13
|
+
attr_accessor :pkg_version
|
7
14
|
|
8
15
|
class << self
|
9
|
-
|
10
16
|
##
|
11
17
|
# Set the path within a project
|
12
18
|
# where libraries should be loaded.
|
19
|
+
#
|
20
|
+
# From top of your Rakefile, you can
|
21
|
+
# set this value with:
|
22
|
+
#
|
23
|
+
# Sprout::Library.project_path = 'libs'
|
24
|
+
#
|
13
25
|
def project_path=(path)
|
14
26
|
@project_path = path
|
15
27
|
end
|
@@ -19,82 +31,122 @@ module Sprout
|
|
19
31
|
# libraries should be added.
|
20
32
|
#
|
21
33
|
# Defaults to 'lib'
|
34
|
+
#
|
35
|
+
# From anywhere in your Rakefile, you can output
|
36
|
+
# this value with:
|
37
|
+
#
|
38
|
+
# puts ">> Library Project Path: #{Sprout::Library.project_path}"
|
39
|
+
#
|
22
40
|
def project_path
|
23
41
|
@project_path ||= 'lib'
|
24
42
|
end
|
25
43
|
|
26
44
|
##
|
27
45
|
# Create Rake tasks that will load and install
|
28
|
-
# a particular library.
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
# rather than simply clobbering...
|
39
|
-
path_or_paths.collect { |p| define_path_task pkg_name, library, p }
|
40
|
-
else
|
41
|
-
define_path_task pkg_name, library, path_or_paths
|
42
|
-
end
|
43
|
-
library
|
46
|
+
# a particular library into the current project.
|
47
|
+
#
|
48
|
+
# This method is usually accessed from the global
|
49
|
+
# library helper.
|
50
|
+
#
|
51
|
+
# library :asunit4
|
52
|
+
#
|
53
|
+
def define_task name=nil, pkg_name=nil, pkg_version=nil
|
54
|
+
library = Sprout::Library.load name, pkg_name, pkg_version
|
55
|
+
library.create_installation_tasks
|
44
56
|
end
|
57
|
+
end
|
45
58
|
|
46
|
-
|
59
|
+
def initialize params=nil
|
60
|
+
params.each {|key,value| self.send("#{key}=", value)} unless params.nil?
|
61
|
+
super()
|
62
|
+
end
|
63
|
+
|
64
|
+
##
|
65
|
+
# Returns the outer Rake::Task which is invokable.
|
66
|
+
def create_installation_tasks
|
67
|
+
define_lib_dir_task_if_necessary project_path
|
68
|
+
create_project_tasks
|
69
|
+
create_outer_task
|
70
|
+
end
|
47
71
|
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
72
|
+
def create_outer_task
|
73
|
+
t = task pkg_name
|
74
|
+
# This helps executable rake tasks decide if they
|
75
|
+
# want to do something special for library tasks.
|
76
|
+
t.sprout_entity = self
|
77
|
+
class << t
|
78
|
+
def sprout_library?
|
79
|
+
!sprout_entity.nil? &&
|
80
|
+
sprout_entity.is_a?(Sprout::Library)
|
54
81
|
end
|
55
82
|
end
|
83
|
+
t
|
84
|
+
end
|
56
85
|
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
86
|
+
private
|
87
|
+
|
88
|
+
def project_path
|
89
|
+
Sprout::Library.project_path
|
90
|
+
end
|
91
|
+
|
92
|
+
def create_project_tasks
|
93
|
+
if path.is_a?(Array)
|
94
|
+
# TODO: Need to add support for merging these directories
|
95
|
+
# rather than simply clobbering...
|
96
|
+
@instaled_project_path = path.collect { |single_path| define_project_path_task pkg_name, single_path }
|
97
|
+
else
|
98
|
+
@installed_project_path = define_project_path_task pkg_name, path
|
64
99
|
end
|
100
|
+
end
|
65
101
|
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
102
|
+
def define_lib_dir_task_if_necessary dir
|
103
|
+
if !File.exists?(dir)
|
104
|
+
define_file_task dir do
|
105
|
+
FileUtils.mkdir_p dir
|
106
|
+
Sprout::Log.puts ">> Created directory at: #{dir}"
|
70
107
|
end
|
71
|
-
installation_path
|
72
108
|
end
|
109
|
+
end
|
73
110
|
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
end
|
81
|
-
task_name
|
111
|
+
def define_project_path_task pkg_name, path
|
112
|
+
install_path = "#{project_path}/#{pkg_name}"
|
113
|
+
if File.directory?(path)
|
114
|
+
define_directory_copy_task path, install_path
|
115
|
+
else
|
116
|
+
define_file_copy_task path, install_path
|
82
117
|
end
|
118
|
+
end
|
83
119
|
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
task Sprout::Library::TASK_NAME => name
|
120
|
+
def define_directory_copy_task path, install_path
|
121
|
+
define_file_task install_path do
|
122
|
+
FileUtils.cp_r path, install_path
|
123
|
+
Sprout::Log.puts ">> Copied files from: (#{path}) to: (#{install_path})"
|
89
124
|
end
|
125
|
+
install_path
|
126
|
+
end
|
90
127
|
|
128
|
+
def define_file_copy_task path, install_path
|
129
|
+
task_name = "#{install_path}/#{File.basename(path)}"
|
130
|
+
define_file_task task_name do
|
131
|
+
FileUtils.mkdir_p install_path
|
132
|
+
FileUtils.cp path, "#{install_path}/"
|
133
|
+
Sprout::Log.puts ">> Copied file from: (#{path}) to: (#{task_name})"
|
134
|
+
end
|
135
|
+
task_name
|
91
136
|
end
|
92
137
|
|
138
|
+
def define_file_task name
|
139
|
+
file name do |t|
|
140
|
+
yield if block_given?
|
141
|
+
end
|
142
|
+
task Sprout::Library::TASK_NAME => name
|
143
|
+
end
|
93
144
|
end
|
145
|
+
|
94
146
|
end
|
95
147
|
|
96
148
|
# From within a Rakefile, you can load libraries
|
97
|
-
# by calling this
|
149
|
+
# by calling this method:
|
98
150
|
#
|
99
151
|
# library :asunit4
|
100
152
|
#
|
@@ -107,7 +159,20 @@ end
|
|
107
159
|
#
|
108
160
|
# library :asunit4, :swc, '>= 4.2.pre'
|
109
161
|
#
|
110
|
-
|
111
|
-
|
162
|
+
# It's important to note that libraries must also
|
163
|
+
# be defined in your Gemfile like:
|
164
|
+
#
|
165
|
+
# gem "asunit4", ">= 4.2.pre"
|
166
|
+
#
|
167
|
+
# Libraries are generally then added to compiler tasks
|
168
|
+
# as Rake dependencies like:
|
169
|
+
#
|
170
|
+
# mxmlc 'bin/SomeRunner.swf' => [:asunit4] do |t|
|
171
|
+
# t.input = 'src/SomeRunner.as'
|
172
|
+
# t.source_path << 'test'
|
173
|
+
# end
|
174
|
+
#
|
175
|
+
def library pkg_name, name=nil, version=nil
|
176
|
+
Sprout::Library.define_task name, pkg_name, version
|
112
177
|
end
|
113
178
|
|
@@ -1,4 +1,3 @@
|
|
1
|
-
require 'digest/md5'
|
2
1
|
|
3
2
|
module Sprout
|
4
3
|
|
@@ -8,31 +7,15 @@ module Sprout
|
|
8
7
|
|
9
8
|
class << self
|
10
9
|
|
11
|
-
def load uri, md5=nil,
|
12
|
-
|
13
|
-
if(force || response_is_valid?(response, md5))
|
14
|
-
return response
|
15
|
-
end
|
16
|
-
nil
|
10
|
+
def load uri, md5=nil, display_name=nil
|
11
|
+
fetch uri.to_s, display_name
|
17
12
|
end
|
18
13
|
|
19
14
|
private
|
20
15
|
|
21
|
-
def
|
22
|
-
if(expected_md5sum)
|
23
|
-
md5 = Digest::MD5.new
|
24
|
-
md5 << response
|
25
|
-
|
26
|
-
if(expected_md5sum != md5.hexdigest)
|
27
|
-
return prompt_for_md5_failure md5, expected_md5sum
|
28
|
-
end
|
29
|
-
end
|
30
|
-
return true
|
31
|
-
end
|
32
|
-
|
33
|
-
def fetch uri, name=nil
|
16
|
+
def fetch uri, display_name=nil
|
34
17
|
begin
|
35
|
-
return open_uri uri,
|
18
|
+
return open_uri uri, display_name
|
36
19
|
rescue SocketError => sock_err
|
37
20
|
raise Sprout::Errors::RemoteFileLoaderError.new("[ERROR] #{sock_err.to_s}")
|
38
21
|
rescue OpenURI::HTTPError => http_err
|
@@ -44,16 +27,16 @@ module Sprout
|
|
44
27
|
|
45
28
|
private
|
46
29
|
|
47
|
-
def open_uri uri,
|
30
|
+
def open_uri uri, display_name=nil
|
48
31
|
uri = URI.parse(uri)
|
49
32
|
progress = nil
|
50
33
|
response = nil
|
51
|
-
|
34
|
+
display_name ||= uri.path.split("/").pop
|
52
35
|
|
53
36
|
# Why was this here? Shouldn't the 'open' command work for other
|
54
37
|
# protocols like https?
|
55
38
|
#
|
56
|
-
#message = "The RemoteFileTask failed for #{
|
39
|
+
#message = "The RemoteFileTask failed for #{display_name}. We can only handle HTTP requests at this time, it seems you were trying: '#{uri.scheme}'"
|
57
40
|
#raise Sprout::Errors::RemoteFileLoaderError.new(message) if uri.scheme != 'http' || uri.scheme != 'https'
|
58
41
|
|
59
42
|
# This is the strangest implementation I've seen in Ruby yet.
|
@@ -61,7 +44,7 @@ module Sprout
|
|
61
44
|
open(uri.to_s,
|
62
45
|
:content_length_proc => lambda {|length|
|
63
46
|
length ||= 0
|
64
|
-
progress = Sprout::ProgressBar.new(
|
47
|
+
progress = Sprout::ProgressBar.new(display_name, length)
|
65
48
|
progress.file_transfer_mode
|
66
49
|
progress.set(0)
|
67
50
|
},
|
@@ -75,17 +58,6 @@ module Sprout
|
|
75
58
|
response
|
76
59
|
end
|
77
60
|
|
78
|
-
def prompt_for_md5_failure md5, expected_md5sum
|
79
|
-
puts "The MD5 Sum of the downloaded file (#{md5.hexdigest}) does not match what was expected (#{expected_md5sum})."
|
80
|
-
puts "Would you like to install anyway? [Yn]"
|
81
|
-
response = $stdin.gets.chomp!
|
82
|
-
if(response.downcase == 'y')
|
83
|
-
return true
|
84
|
-
else
|
85
|
-
raise Sprout::Errors::RemoteFileLoaderError.new('MD5 Checksum failed')
|
86
|
-
end
|
87
|
-
end
|
88
|
-
|
89
61
|
end
|
90
62
|
end
|
91
63
|
end
|
@@ -1,3 +1,4 @@
|
|
1
|
+
require 'digest/md5'
|
1
2
|
|
2
3
|
module Sprout
|
3
4
|
|
@@ -31,8 +32,14 @@ module Sprout
|
|
31
32
|
|
32
33
|
private
|
33
34
|
|
35
|
+
##
|
36
|
+
# Do not cache this value...
|
37
|
+
#
|
38
|
+
# This response can change over time IF:
|
39
|
+
# - The downloaded bytes do not match the expected MD5
|
40
|
+
# - AND the user confirms the prompt that they are OK with this
|
34
41
|
def downloaded_file
|
35
|
-
|
42
|
+
File.join(Sprout.cache, pkg_name, "#{md5}.#{archive_type}")
|
36
43
|
end
|
37
44
|
|
38
45
|
def unpacked_file
|
@@ -42,9 +49,19 @@ module Sprout
|
|
42
49
|
def load_unpack_or_ignore_archive
|
43
50
|
if(!unpacked_files_exist?)
|
44
51
|
if(!File.exists?(downloaded_file))
|
45
|
-
|
52
|
+
bytes = download_archive
|
53
|
+
write_archive bytes
|
54
|
+
end
|
55
|
+
|
56
|
+
# If we *just* downloaded the file,
|
57
|
+
# use the bytes directly, otherwise
|
58
|
+
# read them off disk from a previous
|
59
|
+
# download attempt:
|
60
|
+
bytes ||= File.open(downloaded_file, 'rb').read
|
61
|
+
|
62
|
+
if should_unpack?(bytes, md5)
|
63
|
+
unpack_archive
|
46
64
|
end
|
47
|
-
unpack_archive
|
48
65
|
end
|
49
66
|
end
|
50
67
|
|
@@ -53,7 +70,7 @@ module Sprout
|
|
53
70
|
end
|
54
71
|
|
55
72
|
def download_archive
|
56
|
-
Sprout::RemoteFileLoader.load
|
73
|
+
Sprout::RemoteFileLoader.load url, pkg_name
|
57
74
|
end
|
58
75
|
|
59
76
|
def write_archive bytes
|
@@ -63,6 +80,29 @@ module Sprout
|
|
63
80
|
end
|
64
81
|
end
|
65
82
|
|
83
|
+
def should_unpack? bytes, expected_md5sum
|
84
|
+
if expected_md5sum
|
85
|
+
downloaded_md5 = Digest::MD5.new
|
86
|
+
downloaded_md5 << bytes
|
87
|
+
|
88
|
+
if(expected_md5sum != downloaded_md5.hexdigest)
|
89
|
+
return prompt_for_md5_failure downloaded_md5, expected_md5sum
|
90
|
+
end
|
91
|
+
end
|
92
|
+
return true
|
93
|
+
end
|
94
|
+
|
95
|
+
def prompt_for_md5_failure downloaded_md5, expected_md5sum
|
96
|
+
puts "The MD5 Sum of the downloaded file (#{downloaded_md5.hexdigest}) does not match what was expected (#{expected_md5sum})."
|
97
|
+
puts "Would you like to install anyway? [Yn]"
|
98
|
+
user_response = $stdin.gets.chomp!
|
99
|
+
if(user_response.downcase == 'y')
|
100
|
+
return true
|
101
|
+
else
|
102
|
+
raise Sprout::Errors::RemoteFileLoaderError.new('MD5 Checksum failed')
|
103
|
+
end
|
104
|
+
end
|
105
|
+
|
66
106
|
def unpack_archive
|
67
107
|
FileUtils.mkdir_p unpacked_file
|
68
108
|
unpacker = Sprout::ArchiveUnpacker.new
|
@@ -71,4 +111,3 @@ module Sprout
|
|
71
111
|
|
72
112
|
end
|
73
113
|
end
|
74
|
-
|
data/lib/sprout/ruby_feature.rb
CHANGED
@@ -98,8 +98,10 @@ module Sprout
|
|
98
98
|
end
|
99
99
|
|
100
100
|
def entity_for name_or_names, pkg_name, version_requirement
|
101
|
+
# These commented blocks help immensely when debugging
|
102
|
+
# loading and registration issues, please leave them here:
|
101
103
|
#puts "+++++++++++++++++++++++++++"
|
102
|
-
#puts ">> entity_for #{
|
104
|
+
#puts ">> entity_for #{name_or_names} pkg_name: #{pkg_name} version: #{version_requirement}"
|
103
105
|
#registered_entities.each do |entity|
|
104
106
|
#puts ">> entity: #{entity.name} pkg_name: #{entity.pkg_name} version: #{entity.pkg_version}"
|
105
107
|
#end
|
@@ -172,5 +174,5 @@ end
|
|
172
174
|
# can interoperate with some
|
173
175
|
# knowledge of each other.
|
174
176
|
class Rake::Task
|
175
|
-
attr_accessor :
|
177
|
+
attr_accessor :sprout_entity
|
176
178
|
end
|
@@ -63,6 +63,9 @@ module Sprout::System
|
|
63
63
|
# for the file at the provided +path+ String.
|
64
64
|
#
|
65
65
|
# Will this corrupt binaries? Yes... Yes. it. will.
|
66
|
+
#
|
67
|
+
# This also fails on UTF-8 files since Ruby's regex
|
68
|
+
# appears to choke on UTF-8??
|
66
69
|
def should_repair_executable path
|
67
70
|
return (File.exists?(path) && !File.directory?(path) && File.read(path).match(/^\#\!\/bin\/sh/))
|
68
71
|
end
|
data/lib/sprout/version.rb
CHANGED
data/rakefile.rb
CHANGED
@@ -644,12 +644,11 @@ module Sprout
|
|
644
644
|
#
|
645
645
|
add_param :warnings, Boolean
|
646
646
|
|
647
|
-
def library_added
|
648
|
-
|
649
|
-
|
650
|
-
self.library_path << path
|
647
|
+
def library_added path_or_paths
|
648
|
+
if(path_or_paths =~ /\.swc$/)
|
649
|
+
self.library_path << path_or_paths
|
651
650
|
else
|
652
|
-
self.source_path <<
|
651
|
+
self.source_path << path_or_paths
|
653
652
|
end
|
654
653
|
end
|
655
654
|
|
@@ -1,8 +1,8 @@
|
|
1
|
-
require
|
2
|
-
require '
|
3
|
-
require '
|
4
|
-
require '
|
5
|
-
require '
|
1
|
+
require 'test_helper'
|
2
|
+
require 'fixtures/executable/mxmlc'
|
3
|
+
require 'unit/fake_other_executable'
|
4
|
+
require 'fixtures/executable/subclass/executable_superclass'
|
5
|
+
require 'fixtures/executable/subclass/executable_subclass'
|
6
6
|
|
7
7
|
class ExecutableTest < Test::Unit::TestCase
|
8
8
|
include SproutTestCase
|
@@ -220,20 +220,20 @@ class ExecutableTest < Test::Unit::TestCase
|
|
220
220
|
should "add libraries as provided" do
|
221
221
|
as_a_unix_system do
|
222
222
|
|
223
|
-
Sprout::Library.stubs(:define_path_task)
|
224
223
|
task 'abcd'
|
225
224
|
task 'bin/OtherFileTask.swf'
|
226
225
|
|
227
|
-
asunit_lib =
|
226
|
+
asunit_lib = Sprout::Library.new :name => :swc, :pkg_name => :asunit4, :path => 'lib/AsUnit-4.4.2.swc'
|
228
227
|
Sprout::Library.register asunit_lib
|
229
228
|
|
230
|
-
library :asunit4
|
229
|
+
t = library :asunit4
|
231
230
|
|
232
231
|
@tool = mxmlc 'bin/SomeFile.swf' => [:asunit4, 'abcd', 'bin/OtherFileTask.swf'] do |t|
|
233
232
|
t.source_path << 'test/fixtures/executable/src'
|
234
233
|
t.input = 'test/fixtures/executable/src/Main.as'
|
235
234
|
end
|
236
|
-
|
235
|
+
|
236
|
+
assert_equal "-library-path+=lib/asunit4/AsUnit-4.4.2.swc -output=bin/SomeFile.swf -source-path+=test/fixtures/executable/src test/fixtures/executable/src/Main.as", @tool.to_shell
|
237
237
|
end
|
238
238
|
end
|
239
239
|
|
@@ -259,6 +259,10 @@ class ExecutableTest < Test::Unit::TestCase
|
|
259
259
|
end
|
260
260
|
|
261
261
|
should "execute the registered executable" do
|
262
|
+
# This test should never pass on Windows, even
|
263
|
+
# though it did prior to Ruby 1.9.2...
|
264
|
+
return if Sprout::Platform.new.windows?
|
265
|
+
|
262
266
|
# Configure stub executable:
|
263
267
|
@tool.input = 'test/fixtures/executable/src/Main.as'
|
264
268
|
@tool.source_path << 'test/fixtures/executable/src'
|
@@ -274,7 +278,7 @@ class ExecutableTest < Test::Unit::TestCase
|
|
274
278
|
@tool.execute
|
275
279
|
|
276
280
|
# Ensure the file mode was updated:
|
277
|
-
assert "non-executable file mode should be updated by execute"
|
281
|
+
assert first != File.stat(@mxmlc_executable).mode, "non-executable file mode should be updated by execute"
|
278
282
|
end
|
279
283
|
|
280
284
|
should "include prerequisites" do
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require
|
1
|
+
require 'test_helper'
|
2
2
|
|
3
3
|
class FileTargetTest < Test::Unit::TestCase
|
4
4
|
include SproutTestCase
|
@@ -11,6 +11,8 @@ class FileTargetTest < Test::Unit::TestCase
|
|
11
11
|
context "that is created with a constructor block" do
|
12
12
|
should "have the provided values" do
|
13
13
|
target = Sprout::FileTarget.new do |t|
|
14
|
+
t.pkg_name = 'asunit4'
|
15
|
+
t.pkg_version = '4.2.2.pre'
|
14
16
|
t.add_library :swc, @asunit_swc
|
15
17
|
end
|
16
18
|
assert_provided_values target
|
@@ -20,6 +22,8 @@ class FileTargetTest < Test::Unit::TestCase
|
|
20
22
|
context "that is created with no constructor block" do
|
21
23
|
should "have the provided values" do
|
22
24
|
target = Sprout::FileTarget.new
|
25
|
+
target.pkg_name = 'asunit4'
|
26
|
+
target.pkg_version = '4.2.2.pre'
|
23
27
|
target.add_library :swc, @asunit_swc
|
24
28
|
assert_provided_values target
|
25
29
|
end
|
@@ -36,6 +40,7 @@ class FileTargetTest < Test::Unit::TestCase
|
|
36
40
|
library = t.libraries.first
|
37
41
|
assert_equal :swc, library.name
|
38
42
|
assert_equal File.join('.', @asunit_swc), library.path
|
43
|
+
assert_equal '[FileTarget pkg_name=asunit4 pkg_version=4.2.2.pre platform=universal]', t.to_s
|
39
44
|
end
|
40
45
|
|
41
46
|
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require
|
1
|
+
require 'test_helper'
|
2
2
|
|
3
3
|
class FilesParamTest < Test::Unit::TestCase
|
4
4
|
include SproutTestCase
|
@@ -63,7 +63,7 @@ class FilesParamTest < Test::Unit::TestCase
|
|
63
63
|
|
64
64
|
@param.value << 'abcd'
|
65
65
|
|
66
|
-
assert "Should be visible"
|
66
|
+
assert @param.visible?, "Should be visible"
|
67
67
|
assert_equal 'proc:inputs:abcd', @param.to_shell
|
68
68
|
end
|
69
69
|
|
data/test/unit/generator_test.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
require
|
1
|
+
require 'test_helper'
|
2
2
|
|
3
3
|
class GeneratorTest < Test::Unit::TestCase
|
4
4
|
include SproutTestCase
|
@@ -289,8 +289,8 @@ class GeneratorTest < Test::Unit::TestCase
|
|
289
289
|
|
290
290
|
context "a generator that is a subclass of another" do
|
291
291
|
# Require the source files for this context
|
292
|
-
require '
|
293
|
-
require '
|
292
|
+
require 'fixtures/generators/song_generator'
|
293
|
+
require 'fixtures/generators/song_subclass/least_favorite'
|
294
294
|
|
295
295
|
setup do
|
296
296
|
@path = File.join(fixtures, 'generators', 'tmp')
|
data/test/unit/library_test.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
require
|
1
|
+
require 'test_helper'
|
2
2
|
|
3
3
|
class LibraryTest < Test::Unit::TestCase
|
4
4
|
include SproutTestCase
|
@@ -7,11 +7,11 @@ class LibraryTest < Test::Unit::TestCase
|
|
7
7
|
setup do
|
8
8
|
@path = File.join fixtures, 'library', 'archive'
|
9
9
|
@archive = File.join @path, 'Archive.swc'
|
10
|
-
create_and_register_library :fake_archive_lib, @archive
|
10
|
+
create_and_register_library :fake_archive_lib, :swc, @archive
|
11
11
|
end
|
12
12
|
|
13
13
|
should "be able to load registered libraries" do
|
14
|
-
lib = Sprout::Library.load :fake_archive_lib
|
14
|
+
lib = Sprout::Library.load :swc, :fake_archive_lib
|
15
15
|
assert_not_nil lib
|
16
16
|
end
|
17
17
|
end
|
@@ -22,12 +22,13 @@ class LibraryTest < Test::Unit::TestCase
|
|
22
22
|
@lib_dir = File.join fixture, 'project_lib'
|
23
23
|
sources = File.join fixture, 'sources'
|
24
24
|
@src = File.join sources, 'src', 'Source.as'
|
25
|
-
|
26
|
-
|
25
|
+
|
26
|
+
Sprout::Library.any_instance.stubs(:project_path).returns @lib_dir
|
27
|
+
create_and_register_library :fake_swc_lib, :swc, @src
|
27
28
|
end
|
28
29
|
|
29
30
|
should "create rake file tasks for single files" do
|
30
|
-
Sprout::Library.define_task :fake_swc_lib
|
31
|
+
Sprout::Library.define_task :swc, :fake_swc_lib
|
31
32
|
end
|
32
33
|
end
|
33
34
|
|
@@ -39,17 +40,16 @@ class LibraryTest < Test::Unit::TestCase
|
|
39
40
|
@lib_a = File.join sources, 'lib', 'a'
|
40
41
|
@lib_b = File.join sources, 'lib', 'b'
|
41
42
|
@src = File.join sources, 'src'
|
42
|
-
Sprout::Library.project_path
|
43
|
-
create_and_register_library :fake_source_lib, [@src, @lib_a, @lib_b]
|
43
|
+
Sprout::Library.any_instance.stubs(:project_path).returns @lib_dir
|
44
|
+
create_and_register_library :fake_source_lib, :src, [@src, @lib_a, @lib_b]
|
44
45
|
end
|
45
46
|
|
46
47
|
teardown do
|
47
|
-
Sprout::Library.project_path = nil
|
48
48
|
remove_file @lib_dir
|
49
49
|
end
|
50
50
|
|
51
51
|
should "be able to load registered libraries" do
|
52
|
-
lib = Sprout::Library.load :fake_source_lib
|
52
|
+
lib = Sprout::Library.load :src, :fake_source_lib
|
53
53
|
assert_not_nil lib
|
54
54
|
paths = lib.path.dup
|
55
55
|
assert_equal @src, paths.shift
|
@@ -58,7 +58,7 @@ class LibraryTest < Test::Unit::TestCase
|
|
58
58
|
end
|
59
59
|
|
60
60
|
should "create rake file tasks for directories" do
|
61
|
-
Sprout::Library.define_task :fake_source_lib
|
61
|
+
Sprout::Library.define_task :src, :fake_source_lib
|
62
62
|
Rake::application[:resolve_sprout_libraries].invoke
|
63
63
|
|
64
64
|
library_dir = File.join(@lib_dir, 'fake_source_lib')
|
@@ -68,20 +68,16 @@ class LibraryTest < Test::Unit::TestCase
|
|
68
68
|
assert_file File.join(library_dir, 'b')
|
69
69
|
end
|
70
70
|
|
71
|
-
should "load the library from the load_path" do
|
72
|
-
end
|
73
|
-
|
74
71
|
end
|
75
72
|
|
76
73
|
private
|
77
74
|
|
78
|
-
def create_and_register_library name, path,
|
79
|
-
lib =
|
75
|
+
def create_and_register_library pkg_name, name, path, pkg_version=nil
|
76
|
+
lib = Sprout::Library.new
|
80
77
|
lib.name = name
|
81
78
|
lib.path = path
|
82
79
|
lib.pkg_name = pkg_name unless pkg_name.nil?
|
83
80
|
lib.pkg_version = pkg_version unless pkg_version.nil?
|
84
|
-
|
85
81
|
Sprout::Library.register lib
|
86
82
|
end
|
87
83
|
end
|
data/test/unit/platform_test.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
require
|
1
|
+
require 'test_helper'
|
2
2
|
|
3
3
|
class RemoteFileLoaderTest < Test::Unit::TestCase
|
4
4
|
include SproutTestCase
|
@@ -19,16 +19,6 @@ class RemoteFileLoaderTest < Test::Unit::TestCase
|
|
19
19
|
assert_equal 310, bytes.size
|
20
20
|
end
|
21
21
|
|
22
|
-
should "fail if md5 doesn't match" do
|
23
|
-
Sprout::RemoteFileLoader.expects(:prompt_for_md5_failure)
|
24
|
-
Sprout::RemoteFileLoader.load @uri, 'abcd'
|
25
|
-
end
|
26
|
-
|
27
|
-
should "pass if md5 isn't provided" do
|
28
|
-
Sprout::RemoteFileLoader.expects(:prompt_for_md5_failure).never
|
29
|
-
Sprout::RemoteFileLoader.load @uri
|
30
|
-
end
|
31
22
|
end
|
32
|
-
|
33
23
|
end
|
34
24
|
|
@@ -1,14 +1,10 @@
|
|
1
|
-
require
|
1
|
+
require 'test_helper'
|
2
2
|
|
3
3
|
class RemoteFileTargetTest < Test::Unit::TestCase
|
4
4
|
include SproutTestCase
|
5
5
|
|
6
6
|
context "an improperly configured remote file target" do
|
7
|
-
|
8
|
-
setup do
|
9
|
-
Sprout::RemoteFileTarget.any_instance.stubs(:load_archive).returns true
|
10
|
-
end
|
11
|
-
|
7
|
+
|
12
8
|
should "throw validation error on archive_type" do
|
13
9
|
assert_raises Sprout::Errors::ValidationError do
|
14
10
|
t = Sprout::RemoteFileTarget.new
|
@@ -54,7 +50,7 @@ class RemoteFileTargetTest < Test::Unit::TestCase
|
|
54
50
|
setup do
|
55
51
|
@target = Sprout::RemoteFileTarget.new do |t|
|
56
52
|
t.archive_type = :zip
|
57
|
-
t.md5 = '
|
53
|
+
t.md5 = 'd41d8cd98f00b204e9800998ecf8427e'
|
58
54
|
t.url = 'http://github.com/downloads/lukebayes/project-sprouts/echochamber-test.zip'
|
59
55
|
t.pkg_name = 'echochamber'
|
60
56
|
t.pkg_version = '1.0.pre'
|
@@ -66,10 +62,17 @@ class RemoteFileTargetTest < Test::Unit::TestCase
|
|
66
62
|
|
67
63
|
@downloaded_file = File.join(temp_cache, 'downloaded.zip')
|
68
64
|
@target.stubs(:downloaded_file).returns @downloaded_file
|
65
|
+
|
66
|
+
downloaded_bytes = File.join(fixtures, 'remote_file_target', 'echochamber-test.zip')
|
67
|
+
@archive_bytes = File.open(downloaded_bytes, 'rb').read
|
69
68
|
|
70
|
-
@
|
71
|
-
|
69
|
+
@target.stubs(:download_archive).returns @archive_bytes
|
70
|
+
end
|
72
71
|
|
72
|
+
teardown do
|
73
|
+
remove_file File.join(fixtures, 'sprout')
|
74
|
+
end
|
75
|
+
|
73
76
|
context "that has already been UNPACKED" do
|
74
77
|
should "not be DOWNLOADED or unpacked" do
|
75
78
|
create_file File.join(@unpacked_file, 'unpacked')
|
@@ -79,36 +82,42 @@ class RemoteFileTargetTest < Test::Unit::TestCase
|
|
79
82
|
end
|
80
83
|
end
|
81
84
|
|
82
|
-
context "that had an
|
85
|
+
context "that had an unpack failure" do
|
83
86
|
should "still unpack the file" do
|
87
|
+
# Create the expected unpacked_file:
|
84
88
|
FileUtils.mkdir_p @unpacked_file
|
85
|
-
@target.
|
89
|
+
@target.stubs('should_unpack?').returns true
|
86
90
|
@target.expects(:unpack_archive)
|
87
91
|
@target.resolve
|
88
92
|
end
|
89
93
|
end
|
90
94
|
|
91
95
|
context "that has been DOWNLOADED, but not UNPACKED" do
|
96
|
+
|
97
|
+
should "not unpack if md5 doesn't match, and user responds in negative" do
|
98
|
+
@target.stubs('should_unpack?').returns false
|
99
|
+
@target.expects(:unpack_archive).never
|
100
|
+
@target.resolve
|
101
|
+
end
|
102
|
+
|
92
103
|
should "unpack but not download" do
|
93
|
-
|
94
|
-
@target.expects(:download_archive).never
|
95
|
-
@target.expects(:unpack_archive)
|
104
|
+
@target.stubs('should_unpack?').returns true
|
96
105
|
@target.resolve
|
106
|
+
assert_not_empty @unpacked_file
|
97
107
|
end
|
98
108
|
end
|
99
109
|
|
100
110
|
context "that has not yet been DOWNLOADED, or UNPACKED" do
|
101
111
|
should "download and unpack the remote archive" do
|
102
|
-
|
112
|
+
@target.stubs('should_unpack?').returns true
|
113
|
+
#@target.expects(:download_archive)
|
103
114
|
#@target.expects(:unpack_archive)
|
104
|
-
|
105
115
|
@target.resolve
|
116
|
+
|
106
117
|
assert_file @downloaded_file
|
107
|
-
|
108
|
-
#assert_not_empty @unpacked_file
|
118
|
+
assert_not_empty @unpacked_file
|
109
119
|
end
|
110
120
|
end
|
111
121
|
|
112
122
|
end
|
113
123
|
end
|
114
|
-
|
data/test/unit/sprout_test.rb
CHANGED
data/test/unit/string_test.rb
CHANGED
data/test/unit/user_test.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
require
|
1
|
+
require 'test_helper'
|
2
2
|
|
3
3
|
class WinSystemTest < Test::Unit::TestCase
|
4
4
|
include SproutTestCase
|
@@ -44,7 +44,7 @@ class WinSystemTest < Test::Unit::TestCase
|
|
44
44
|
|
45
45
|
should "find library outside home" do
|
46
46
|
File.stubs(:exists?).returns false
|
47
|
-
assert "Shouldn't use app data if it doesn't exist"
|
47
|
+
assert (@user.library =~ /Application Data/).nil?, "Shouldn't use app data if it doesn't exist"
|
48
48
|
end
|
49
49
|
|
50
50
|
should "wrap paths that have spaces with escaped quotes" do
|
metadata
CHANGED
@@ -1,14 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sprout
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash: 1407429492
|
5
4
|
prerelease: true
|
6
5
|
segments:
|
7
6
|
- 1
|
8
7
|
- 0
|
9
|
-
-
|
8
|
+
- 29
|
10
9
|
- pre
|
11
|
-
version: 1.0.
|
10
|
+
version: 1.0.29.pre
|
12
11
|
platform: ruby
|
13
12
|
authors:
|
14
13
|
- Luke Bayes
|
@@ -16,7 +15,7 @@ autorequire:
|
|
16
15
|
bindir: bin
|
17
16
|
cert_chain: []
|
18
17
|
|
19
|
-
date: 2010-
|
18
|
+
date: 2010-10-10 00:00:00 -07:00
|
20
19
|
default_executable:
|
21
20
|
dependencies:
|
22
21
|
- !ruby/object:Gem::Dependency
|
@@ -26,7 +25,6 @@ dependencies:
|
|
26
25
|
requirements:
|
27
26
|
- - ">="
|
28
27
|
- !ruby/object:Gem::Version
|
29
|
-
hash: 29
|
30
28
|
segments:
|
31
29
|
- 0
|
32
30
|
- 9
|
@@ -42,7 +40,6 @@ dependencies:
|
|
42
40
|
requirements:
|
43
41
|
- - ">="
|
44
42
|
- !ruby/object:Gem::Version
|
45
|
-
hash: 49
|
46
43
|
segments:
|
47
44
|
- 0
|
48
45
|
- 8
|
@@ -58,7 +55,6 @@ dependencies:
|
|
58
55
|
requirements:
|
59
56
|
- - ">="
|
60
57
|
- !ruby/object:Gem::Version
|
61
|
-
hash: 11
|
62
58
|
segments:
|
63
59
|
- 2
|
64
60
|
- 5
|
@@ -74,7 +70,6 @@ dependencies:
|
|
74
70
|
requirements:
|
75
71
|
- - "="
|
76
72
|
- !ruby/object:Gem::Version
|
77
|
-
hash: 51
|
78
73
|
segments:
|
79
74
|
- 0
|
80
75
|
- 9
|
@@ -90,7 +85,6 @@ dependencies:
|
|
90
85
|
requirements:
|
91
86
|
- - "="
|
92
87
|
- !ruby/object:Gem::Version
|
93
|
-
hash: 15
|
94
88
|
segments:
|
95
89
|
- 0
|
96
90
|
- 5
|
@@ -106,7 +100,6 @@ dependencies:
|
|
106
100
|
requirements:
|
107
101
|
- - ">="
|
108
102
|
- !ruby/object:Gem::Version
|
109
|
-
hash: 55
|
110
103
|
segments:
|
111
104
|
- 0
|
112
105
|
- 9
|
@@ -122,7 +115,6 @@ dependencies:
|
|
122
115
|
requirements:
|
123
116
|
- - ">="
|
124
117
|
- !ruby/object:Gem::Version
|
125
|
-
hash: 3
|
126
118
|
segments:
|
127
119
|
- 0
|
128
120
|
version: "0"
|
@@ -136,7 +128,6 @@ dependencies:
|
|
136
128
|
requirements:
|
137
129
|
- - ">="
|
138
130
|
- !ruby/object:Gem::Version
|
139
|
-
hash: 3
|
140
131
|
segments:
|
141
132
|
- 0
|
142
133
|
version: "0"
|
@@ -150,7 +141,6 @@ dependencies:
|
|
150
141
|
requirements:
|
151
142
|
- - ">="
|
152
143
|
- !ruby/object:Gem::Version
|
153
|
-
hash: 3
|
154
144
|
segments:
|
155
145
|
- 0
|
156
146
|
version: "0"
|
@@ -164,7 +154,6 @@ dependencies:
|
|
164
154
|
requirements:
|
165
155
|
- - ">="
|
166
156
|
- !ruby/object:Gem::Version
|
167
|
-
hash: 3
|
168
157
|
segments:
|
169
158
|
- 0
|
170
159
|
version: "0"
|
@@ -178,7 +167,6 @@ dependencies:
|
|
178
167
|
requirements:
|
179
168
|
- - ">="
|
180
169
|
- !ruby/object:Gem::Version
|
181
|
-
hash: 3
|
182
170
|
segments:
|
183
171
|
- 0
|
184
172
|
version: "0"
|
@@ -192,7 +180,6 @@ dependencies:
|
|
192
180
|
requirements:
|
193
181
|
- - ">="
|
194
182
|
- !ruby/object:Gem::Version
|
195
|
-
hash: 3
|
196
183
|
segments:
|
197
184
|
- 0
|
198
185
|
version: "0"
|
@@ -416,7 +403,6 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
416
403
|
requirements:
|
417
404
|
- - ">="
|
418
405
|
- !ruby/object:Gem::Version
|
419
|
-
hash: 3
|
420
406
|
segments:
|
421
407
|
- 0
|
422
408
|
version: "0"
|
@@ -425,7 +411,6 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
425
411
|
requirements:
|
426
412
|
- - ">="
|
427
413
|
- !ruby/object:Gem::Version
|
428
|
-
hash: 23
|
429
414
|
segments:
|
430
415
|
- 1
|
431
416
|
- 3
|