flashsdk 1.0.1.pre
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +9 -0
- data/README.textile +0 -0
- data/VERSION +1 -0
- data/bin/sprout-as3 +9 -0
- data/flashsdk.gemspec +23 -0
- data/lib/flashplayer/clix_flash_player.rb +91 -0
- data/lib/flashplayer/clix_wrapper.rb +22 -0
- data/lib/flashplayer/errors.rb +12 -0
- data/lib/flashplayer/log_file.rb +95 -0
- data/lib/flashplayer/mm_config.rb +96 -0
- data/lib/flashplayer/module.rb +50 -0
- data/lib/flashplayer/specification.rb +32 -0
- data/lib/flashplayer/task.legacy.rb +293 -0
- data/lib/flashplayer/task.rb +137 -0
- data/lib/flashplayer/trust.rb +45 -0
- data/lib/flashplayer.rb +8 -0
- data/lib/flashsdk/generators/class_generator.rb +43 -0
- data/lib/flashsdk/generators/flash_helper.rb +48 -0
- data/lib/flashsdk/generators/project_generator.rb +53 -0
- data/lib/flashsdk/generators/templates/ActionScript3Class.as +9 -0
- data/lib/flashsdk/generators/templates/ActionScript3MainClass.as +11 -0
- data/lib/flashsdk/generators/templates/DefaultProjectImage.png +0 -0
- data/lib/flashsdk/generators/templates/Gemfile +6 -0
- data/lib/flashsdk/generators/templates/rakefile.rb +17 -0
- data/lib/flashsdk/module.rb +9 -0
- data/lib/flashsdk/tasks/mxmlc.rb +687 -0
- data/lib/flashsdk/tasks/mxmlc_legacy.rb +135 -0
- data/lib/flashsdk.rb +12 -0
- data/lib/flex3.rb +53 -0
- data/lib/flex4.rb +58 -0
- data/rakefile.rb +20 -0
- data/test/fixtures/mxmlc/simple/SomeFile.as +11 -0
- data/test/unit/class_generator_test.rb +50 -0
- data/test/unit/flash_helper_test.rb +27 -0
- data/test/unit/flashplayer_test.rb +56 -0
- data/test/unit/log_file_test.rb +47 -0
- data/test/unit/mm_config_test.rb +74 -0
- data/test/unit/mxmlc_test.rb +45 -0
- data/test/unit/project_generator_test.rb +53 -0
- data/test/unit/task_test.rb +93 -0
- data/test/unit/test_helper.rb +16 -0
- data/test/unit/trust_test.rb +30 -0
- metadata +145 -0
@@ -0,0 +1,293 @@
|
|
1
|
+
|
2
|
+
=begin
|
3
|
+
|
4
|
+
class FlashPlayerTask < Rake::Task
|
5
|
+
# This is the opening prelude to a collection of test results. When the
|
6
|
+
# task encounters this string in the trace output log file, it will begin
|
7
|
+
# collecting trace statements with the expectation that the following
|
8
|
+
# strings will be well-formatted XML data matching what JUnit emits for
|
9
|
+
# Cruise Control.
|
10
|
+
#
|
11
|
+
# See the lib/asunit3/asunit.framework.XMLResultPrinter for more information.
|
12
|
+
@@test_result_pre_delimiter = '<XMLResultPrinter>'
|
13
|
+
|
14
|
+
# This is the closing string that will indicate the end of test result XML data
|
15
|
+
@@test_result_post_delimiter = '</XMLResultPrinter>'
|
16
|
+
|
17
|
+
@@home = nil
|
18
|
+
@@trust = nil
|
19
|
+
|
20
|
+
def initialize(task_name, app)
|
21
|
+
super(task_name, app)
|
22
|
+
@default_gem_name = 'sprout-flashplayer-tool'
|
23
|
+
@default_gem_version = '10.22.0'
|
24
|
+
@default_result_file = 'AsUnitResults.xml'
|
25
|
+
@inside_test_result = false
|
26
|
+
end
|
27
|
+
|
28
|
+
def self.define_task(args, &block)
|
29
|
+
t = super
|
30
|
+
yield t if block_given?
|
31
|
+
t.define
|
32
|
+
end
|
33
|
+
|
34
|
+
# Local system path to the Flash Player Trust file
|
35
|
+
def FlashPlayerTask.trust
|
36
|
+
if(@@trust)
|
37
|
+
return @@trust
|
38
|
+
end
|
39
|
+
@@trust = File.join(FlashPlayerTask.home, '#Security', 'FlashPlayerTrust', 'sprout.cfg')
|
40
|
+
return @@trust
|
41
|
+
end
|
42
|
+
|
43
|
+
# Local system path to where the Flash Player stores trace output logs and trust files
|
44
|
+
def FlashPlayerTask.home
|
45
|
+
if(@@home)
|
46
|
+
return @@home
|
47
|
+
end
|
48
|
+
|
49
|
+
FlashPlayerTask.home_paths.each do |path|
|
50
|
+
if(File.exists?(path))
|
51
|
+
return @@home = path
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
if(@@home.nil?)
|
56
|
+
raise FlashPlayerError.new('FlashPlayer unable to find home folder for your platform')
|
57
|
+
end
|
58
|
+
return @@home
|
59
|
+
end
|
60
|
+
|
61
|
+
# Collection of the potential locations of the Flash Player Home
|
62
|
+
# For each supported Platform, the first existing location
|
63
|
+
# will be used.
|
64
|
+
def FlashPlayerTask.home_paths
|
65
|
+
return [File.join(User.library, 'Preferences', 'Macromedia', 'Flash Player'),
|
66
|
+
File.join(User.library, 'Application Support', 'Macromedia'),
|
67
|
+
File.join(User.home, 'Application Data', 'Macromedia', 'Flash Player'),
|
68
|
+
File.join(User.home, 'AppData', 'Roaming', 'Macromedia', 'Flash Player'),
|
69
|
+
File.join(User.home, '.macromedia', 'Flash_Player')]
|
70
|
+
end
|
71
|
+
|
72
|
+
# The swf parameter can be set explicitly in the block sent to this task as in:
|
73
|
+
#
|
74
|
+
# flashplayer :run do |t|
|
75
|
+
# t.swf = 'bin/SomeProject.swf'
|
76
|
+
# end
|
77
|
+
#
|
78
|
+
# Or it can be set implicitly as a rake prerequisite as follows:
|
79
|
+
#
|
80
|
+
# flashplayer :run => 'bin/SomeProject' do |t|
|
81
|
+
# end
|
82
|
+
#
|
83
|
+
def swf=(swf)
|
84
|
+
@swf = swf
|
85
|
+
end
|
86
|
+
|
87
|
+
def swf
|
88
|
+
@swf ||= nil
|
89
|
+
if(@swf.nil?)
|
90
|
+
prerequisites.each do |req|
|
91
|
+
if(req.index('.swf'))
|
92
|
+
@swf = req.to_s
|
93
|
+
break
|
94
|
+
end
|
95
|
+
end
|
96
|
+
end
|
97
|
+
return @swf
|
98
|
+
end
|
99
|
+
|
100
|
+
def gem_version=(version)
|
101
|
+
@gem_version = version
|
102
|
+
end
|
103
|
+
|
104
|
+
def gem_version
|
105
|
+
return @gem_version ||= nil
|
106
|
+
end
|
107
|
+
|
108
|
+
# Full name of the sprout tool gem that this tool task will use.
|
109
|
+
# This defaults to sprout-flashplayer-tool
|
110
|
+
def gem_name=(name)
|
111
|
+
@gem_name = name
|
112
|
+
end
|
113
|
+
|
114
|
+
def gem_name
|
115
|
+
return @gem_name ||= @default_gem_name
|
116
|
+
end
|
117
|
+
|
118
|
+
# The File where JUnit test results should be written. This value
|
119
|
+
# defaults to 'AsUnitResults.xml'
|
120
|
+
#
|
121
|
+
def test_result_file=(file)
|
122
|
+
@test_result_file = file
|
123
|
+
end
|
124
|
+
|
125
|
+
def test_result_file
|
126
|
+
@test_result_file ||= @default_result_file
|
127
|
+
end
|
128
|
+
|
129
|
+
def test_result
|
130
|
+
@test_result ||= ''
|
131
|
+
end
|
132
|
+
|
133
|
+
def define # :nodoc:
|
134
|
+
CLEAN.add(test_result_file)
|
135
|
+
end
|
136
|
+
|
137
|
+
def execute(*args)
|
138
|
+
super
|
139
|
+
raise FlashPlayerError.new("FlashPlayer task #{name} required field swf is nil") unless swf
|
140
|
+
|
141
|
+
log_file = nil
|
142
|
+
|
143
|
+
# Don't let trust or log file failures break other features...
|
144
|
+
begin
|
145
|
+
config = FlashPlayerConfig.new
|
146
|
+
log_file = config.log_file
|
147
|
+
FlashPlayerTrust.new(File.expand_path(File.dirname(swf)))
|
148
|
+
|
149
|
+
if(File.exists?(log_file))
|
150
|
+
File.open(log_file, 'w') do |f|
|
151
|
+
f.write('')
|
152
|
+
end
|
153
|
+
else
|
154
|
+
FileUtils.makedirs(File.dirname(log_file))
|
155
|
+
FileUtils.touch(log_file)
|
156
|
+
end
|
157
|
+
rescue StandardError => e
|
158
|
+
logger.puts '[WARNING] FlashPlayer encountered an error working with the mm.cfg log and/or editing the Trust file'
|
159
|
+
end
|
160
|
+
|
161
|
+
@running_process = nil
|
162
|
+
@thread = run(gem_name, gem_version, swf)
|
163
|
+
read_log(@thread, log_file) unless log_file.nil?
|
164
|
+
@thread.join
|
165
|
+
end
|
166
|
+
|
167
|
+
def run(tool, gem_version, swf)
|
168
|
+
path_to_exe = Sprout.get_executable(tool, nil, gem_version)
|
169
|
+
target = User.clean_path(path_to_exe)
|
170
|
+
@player_pid = nil
|
171
|
+
|
172
|
+
thread_out = $stdout
|
173
|
+
command = "#{target} #{User.clean_path(swf)}"
|
174
|
+
|
175
|
+
usr = User.new()
|
176
|
+
if(usr.is_a?(WinUser) && !usr.is_a?(CygwinUser))
|
177
|
+
return Thread.new {
|
178
|
+
system command
|
179
|
+
}
|
180
|
+
elsif usr.is_a?(OSXUser)
|
181
|
+
require 'clix_flash_player'
|
182
|
+
@clix_player = CLIXFlashPlayer.new
|
183
|
+
@clix_player.execute(target, swf)
|
184
|
+
return @clix_player
|
185
|
+
else
|
186
|
+
return Thread.new {
|
187
|
+
require 'open4'
|
188
|
+
@player_pid, stdin, stdout, stderr = Open4.popen4(command)
|
189
|
+
stdout.read
|
190
|
+
}
|
191
|
+
end
|
192
|
+
end
|
193
|
+
|
194
|
+
def close
|
195
|
+
usr = User.new
|
196
|
+
if(usr.is_a?(WinUser))
|
197
|
+
Thread.kill(@thread)
|
198
|
+
elsif(usr.is_a?(OSXUser))
|
199
|
+
@clix_player.kill unless @clix_player.nil?
|
200
|
+
else
|
201
|
+
Process.kill("SIGALRM", @player_pid)
|
202
|
+
end
|
203
|
+
end
|
204
|
+
|
205
|
+
def read_log(thread, log_file)
|
206
|
+
lines_put = 0
|
207
|
+
|
208
|
+
if(log_file.nil?)
|
209
|
+
raise FlashPlayerError.new('[ERROR] Unable to find the trace output log file because the expected location was nil')
|
210
|
+
end
|
211
|
+
|
212
|
+
if(!File.exists?(log_file))
|
213
|
+
raise FlashPlayerError.new('[ERROR] Unable to find the trace output log file in the expected location: ' + log_file)
|
214
|
+
end
|
215
|
+
|
216
|
+
while(thread.alive?)
|
217
|
+
sleep(0.2)
|
218
|
+
lines_read = 0
|
219
|
+
|
220
|
+
File.open(log_file, 'r') do |file|
|
221
|
+
file.readlines.each do |line|
|
222
|
+
lines_read = lines_read + 1
|
223
|
+
if(lines_read > lines_put)
|
224
|
+
if(!parse_test_result(line, thread))
|
225
|
+
logger.puts "[trace] #{line}"
|
226
|
+
end
|
227
|
+
$stdout.flush
|
228
|
+
lines_put = lines_put + 1
|
229
|
+
end
|
230
|
+
end
|
231
|
+
end
|
232
|
+
end
|
233
|
+
end
|
234
|
+
|
235
|
+
# Returns true if inside of a test result
|
236
|
+
def parse_test_result(line, thread)
|
237
|
+
if(@inside_test_result)
|
238
|
+
if(line.index(@@test_result_post_delimiter))
|
239
|
+
@inside_test_result = false
|
240
|
+
write_test_result(test_result)
|
241
|
+
close
|
242
|
+
examine_test_result test_result
|
243
|
+
return true
|
244
|
+
else
|
245
|
+
test_result << line
|
246
|
+
end
|
247
|
+
end
|
248
|
+
|
249
|
+
if(line.index(@@test_result_pre_delimiter))
|
250
|
+
@inside_test_result = true
|
251
|
+
end
|
252
|
+
|
253
|
+
return @inside_test_result
|
254
|
+
end
|
255
|
+
|
256
|
+
def write_test_result(result)
|
257
|
+
FileUtils.makedirs(File.dirname(test_result_file))
|
258
|
+
File.open(test_result_file, File::CREAT|File::TRUNC|File::RDWR) do |f|
|
259
|
+
f.puts(result)
|
260
|
+
end
|
261
|
+
end
|
262
|
+
|
263
|
+
def examine_test_result(result)
|
264
|
+
require 'rexml/document'
|
265
|
+
doc = nil
|
266
|
+
begin
|
267
|
+
doc = REXML::Document.new(result)
|
268
|
+
rescue REXML::ParseException => e
|
269
|
+
puts "[WARNING] Invalid test results encountered"
|
270
|
+
return
|
271
|
+
end
|
272
|
+
|
273
|
+
# Handle JUnit Failures
|
274
|
+
failures = []
|
275
|
+
|
276
|
+
doc.elements.each('/testsuites/testsuite/testsuite/testcase/error') do |element|
|
277
|
+
failures << element.text
|
278
|
+
end
|
279
|
+
|
280
|
+
doc.elements.each("/testsuites/testsuite/testsuite/testcase/failure") do |element|
|
281
|
+
failures << element.text
|
282
|
+
end
|
283
|
+
|
284
|
+
if(failures.size > 0)
|
285
|
+
raise AssertionFailure.new("[ERROR] Test Failures Encountered \n#{failures.join("\n")}")
|
286
|
+
end
|
287
|
+
end
|
288
|
+
|
289
|
+
end
|
290
|
+
|
291
|
+
=end
|
292
|
+
|
293
|
+
|
@@ -0,0 +1,137 @@
|
|
1
|
+
|
2
|
+
module FlashPlayer
|
3
|
+
|
4
|
+
class Task < Rake::Task
|
5
|
+
|
6
|
+
attr_accessor :input
|
7
|
+
attr_accessor :pkg_name
|
8
|
+
attr_accessor :pkg_version
|
9
|
+
|
10
|
+
##
|
11
|
+
# This is the Rake::Task constructor
|
12
|
+
# signature...
|
13
|
+
def initialize task_name, rake_application
|
14
|
+
super
|
15
|
+
@logger = $stdout
|
16
|
+
@mm_config = MMConfig.new
|
17
|
+
@reader = LogFile.new
|
18
|
+
@trust_config = Trust.new
|
19
|
+
@process = nil
|
20
|
+
@input = task_name
|
21
|
+
|
22
|
+
@pkg_name = FlashPlayer::NAME
|
23
|
+
@pkg_version = FlashSDK::VERSION
|
24
|
+
end
|
25
|
+
|
26
|
+
def execute *args
|
27
|
+
super
|
28
|
+
#puts ">> invoke with: #{args} and input: #{input}"
|
29
|
+
update_input_if_necessary
|
30
|
+
execute_safely do
|
31
|
+
update_mm_config
|
32
|
+
update_trust_config_with input
|
33
|
+
end
|
34
|
+
player_thread = launch_player_with input
|
35
|
+
tail_flashlog player_thread
|
36
|
+
end
|
37
|
+
|
38
|
+
def logger=(logger)
|
39
|
+
@logger = logger
|
40
|
+
@mm_config.logger = logger
|
41
|
+
@reader.logger = logger
|
42
|
+
@trust_config.logger = logger
|
43
|
+
end
|
44
|
+
|
45
|
+
def logger
|
46
|
+
@logger
|
47
|
+
end
|
48
|
+
|
49
|
+
private
|
50
|
+
|
51
|
+
def execute_safely
|
52
|
+
begin
|
53
|
+
yield if block_given?
|
54
|
+
rescue FlashPlayer::PathError => e
|
55
|
+
logger.puts ">> [WARNING] It seems this was the first time FlashPlayer was launched on this system and as a result, the expected folders were not found. Please close the Player and run again - this message should only ever be displayed once."
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
def update_input_if_necessary
|
60
|
+
return if input.match(/\.swf$/)
|
61
|
+
prerequisites.each do |prereq|
|
62
|
+
if(prereq.match(/\.swf$/))
|
63
|
+
self.input = prereq
|
64
|
+
return
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
def update_mm_config
|
70
|
+
@mm_config.create
|
71
|
+
end
|
72
|
+
|
73
|
+
def update_trust_config_with swf
|
74
|
+
@trust_config.add File.dirname(swf)
|
75
|
+
end
|
76
|
+
|
77
|
+
def clean_path path
|
78
|
+
current_system.clean_path path
|
79
|
+
end
|
80
|
+
|
81
|
+
def current_system
|
82
|
+
@current_system ||= Sprout.current_system
|
83
|
+
end
|
84
|
+
|
85
|
+
def launch_player_with swf
|
86
|
+
player = Sprout::Executable.load(:flashplayer, pkg_name, pkg_version).path
|
87
|
+
swf = clean_path swf
|
88
|
+
current_system.open_flashplayer_with player, swf
|
89
|
+
end
|
90
|
+
|
91
|
+
def tail_flashlog player_thread
|
92
|
+
@reader.tail player_thread
|
93
|
+
end
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
97
|
+
##
|
98
|
+
# Update the native System instances
|
99
|
+
# to handle FlashPlayer launching in
|
100
|
+
# order to overcome non-cli limitations.
|
101
|
+
#
|
102
|
+
module Sprout
|
103
|
+
module System
|
104
|
+
|
105
|
+
class WinSystem
|
106
|
+
def open_flashplayer_with exe, swf
|
107
|
+
return Thread.new {
|
108
|
+
system command
|
109
|
+
}
|
110
|
+
end
|
111
|
+
end
|
112
|
+
|
113
|
+
class OSXSystem
|
114
|
+
def open_flashplayer_with exe, swf
|
115
|
+
require 'flashplayer/clix_flash_player'
|
116
|
+
@clix_player = CLIXFlashPlayer.new
|
117
|
+
@clix_player.execute(exe, swf)
|
118
|
+
return @clix_player
|
119
|
+
end
|
120
|
+
end
|
121
|
+
|
122
|
+
class UnixSystem
|
123
|
+
def open_flashplayer_with exe, swf
|
124
|
+
return Thread.new {
|
125
|
+
require 'open4'
|
126
|
+
@player_pid, stdin, stdout, stderr = Open4.popen4(command)
|
127
|
+
stdout.read
|
128
|
+
}
|
129
|
+
end
|
130
|
+
end
|
131
|
+
end
|
132
|
+
end
|
133
|
+
|
134
|
+
def flashplayer *args, &block
|
135
|
+
FlashPlayer::Task.define_task *args, &block
|
136
|
+
end
|
137
|
+
|
@@ -0,0 +1,45 @@
|
|
1
|
+
|
2
|
+
module FlashPlayer
|
3
|
+
|
4
|
+
class Trust
|
5
|
+
|
6
|
+
attr_accessor :logger
|
7
|
+
|
8
|
+
def initialize
|
9
|
+
@logger = $stdout
|
10
|
+
end
|
11
|
+
|
12
|
+
def add path
|
13
|
+
file = trust_file
|
14
|
+
create(file) unless File.exists?(file)
|
15
|
+
update_if_necessary file, path
|
16
|
+
end
|
17
|
+
|
18
|
+
private
|
19
|
+
|
20
|
+
def create file
|
21
|
+
dir = File.dirname file
|
22
|
+
FileUtils.makedirs(dir) unless File.exists?(dir)
|
23
|
+
FileUtils.touch file
|
24
|
+
end
|
25
|
+
|
26
|
+
def update_if_necessary file, path
|
27
|
+
path = File.expand_path path
|
28
|
+
if(!has_path?(file, path))
|
29
|
+
File.open(file, 'a') do |f|
|
30
|
+
f.puts path
|
31
|
+
end
|
32
|
+
logger.puts ">> Added #{path} to Flash Player Trust file at: #{file}"
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
def has_path? file, path
|
37
|
+
!File.read(file).index(path).nil?
|
38
|
+
end
|
39
|
+
|
40
|
+
def trust_file
|
41
|
+
FlashPlayer.trust
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
data/lib/flashplayer.rb
ADDED
@@ -0,0 +1,43 @@
|
|
1
|
+
module FlashSDK
|
2
|
+
class ClassGenerator < Sprout::Generator::Base
|
3
|
+
include FlashHelper
|
4
|
+
|
5
|
+
##
|
6
|
+
# The path where source files should be created.
|
7
|
+
add_param :src, String, { :default => 'src' }
|
8
|
+
|
9
|
+
def manifest
|
10
|
+
directory class_directory do
|
11
|
+
template "#{class_name}.as", 'ActionScript3Class.as'
|
12
|
+
end
|
13
|
+
|
14
|
+
generator :test_class, :input => "#{fully_qualified_class_name}Test"
|
15
|
+
generator :suite_class
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
21
|
+
|
22
|
+
##
|
23
|
+
# This is a null Generator, if you add a test library
|
24
|
+
# to your Gemfile, it should have it's own TestClassGenerator
|
25
|
+
# that supercedes this one.
|
26
|
+
module FlashSDK
|
27
|
+
class TestClassGenerator < Sprout::Generator::Base
|
28
|
+
def manifest
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
##
|
34
|
+
# This is a null Generator, if you add a test library
|
35
|
+
# to your Gemfile, it should have it's own TestClassGenerator
|
36
|
+
# that supercedes this one.
|
37
|
+
module FlashSDK
|
38
|
+
class SuiteClassGenerator < Sprout::Generator::Base
|
39
|
+
def manifest
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
@@ -0,0 +1,48 @@
|
|
1
|
+
|
2
|
+
module FlashSDK
|
3
|
+
|
4
|
+
module FlashHelper
|
5
|
+
|
6
|
+
def class_directory
|
7
|
+
parts = input_in_parts
|
8
|
+
if parts.size > 1
|
9
|
+
parts.pop
|
10
|
+
return File.join src, *parts
|
11
|
+
end
|
12
|
+
return src
|
13
|
+
end
|
14
|
+
|
15
|
+
def package_name
|
16
|
+
parts = input_in_parts
|
17
|
+
if parts.size > 1
|
18
|
+
parts.pop
|
19
|
+
return "#{parts.join('.')} "
|
20
|
+
end
|
21
|
+
return ""
|
22
|
+
end
|
23
|
+
|
24
|
+
def class_name
|
25
|
+
parts = input_in_parts
|
26
|
+
parts.pop.camel_case
|
27
|
+
end
|
28
|
+
|
29
|
+
def input_in_parts
|
30
|
+
provided_input = input
|
31
|
+
if provided_input.include?('/')
|
32
|
+
provided_input.gsub! /^#{src}\//, ''
|
33
|
+
provided_input = provided_input.split('/').join('.')
|
34
|
+
end
|
35
|
+
|
36
|
+
provided_input.gsub!(/\.as$/, '')
|
37
|
+
provided_input.gsub!(/\.mxml$/, '')
|
38
|
+
provided_input.gsub!(/\.xml$/, '')
|
39
|
+
|
40
|
+
provided_input.split('.')
|
41
|
+
end
|
42
|
+
|
43
|
+
def fully_qualified_class_name
|
44
|
+
input
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
@@ -0,0 +1,53 @@
|
|
1
|
+
module FlashSDK
|
2
|
+
class ProjectGenerator < ClassGenerator
|
3
|
+
|
4
|
+
##
|
5
|
+
# The path where assets will be created.
|
6
|
+
add_param :assets, String, { :default => 'assets' }
|
7
|
+
|
8
|
+
##
|
9
|
+
# The path where skins will be created.
|
10
|
+
add_param :skins, String, { :default => 'skins' }
|
11
|
+
|
12
|
+
##
|
13
|
+
# The path where test cases should be created.
|
14
|
+
add_param :test, String, { :default => 'test' }
|
15
|
+
|
16
|
+
##
|
17
|
+
# The path where libraries should be added.
|
18
|
+
add_param :lib, String, { :default => 'lib' }
|
19
|
+
|
20
|
+
##
|
21
|
+
# The path where binaries should be created.
|
22
|
+
add_param :bin, String, { :default => 'bin' }
|
23
|
+
|
24
|
+
def manifest
|
25
|
+
directory input do
|
26
|
+
template 'rakefile.rb'
|
27
|
+
template 'Gemfile'
|
28
|
+
|
29
|
+
directory src do
|
30
|
+
template "#{input}.as", 'ActionScript3MainClass.as'
|
31
|
+
end
|
32
|
+
|
33
|
+
directory assets do
|
34
|
+
directory skins do
|
35
|
+
file 'DefaultProjectImage.png'
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
# Create empty directories:
|
40
|
+
directory lib
|
41
|
+
directory bin
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
protected
|
46
|
+
|
47
|
+
def debug_swf_name
|
48
|
+
"#{class_name}-debug.swf"
|
49
|
+
end
|
50
|
+
|
51
|
+
end
|
52
|
+
|
53
|
+
end
|
Binary file
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'bundler'
|
3
|
+
Bundler.require
|
4
|
+
|
5
|
+
library :asunit4
|
6
|
+
|
7
|
+
desc "Compile the debug swf"
|
8
|
+
mxmlc "<%= bin %>/<%= debug_swf_name %>" => :asunit4 do |t|
|
9
|
+
t.input = "<%= src %>/<%= class_name %>.as"
|
10
|
+
t.debug = true
|
11
|
+
end
|
12
|
+
|
13
|
+
desc "Compile and run the debug swf"
|
14
|
+
flashplayer :debug => "<%= bin %>/<%= debug_swf_name %>"
|
15
|
+
|
16
|
+
task :default => :debug
|
17
|
+
|
@@ -0,0 +1,9 @@
|
|
1
|
+
|
2
|
+
module FlashSDK
|
3
|
+
# Do this craptastic, otherwise we get a carriage return
|
4
|
+
# after our version, and that poops on our archive folder
|
5
|
+
# after downloading...
|
6
|
+
version_file = File.join(File.dirname(__FILE__), '..', '..', 'VERSION')
|
7
|
+
VERSION = File.read(version_file).gsub("\n", '')
|
8
|
+
end
|
9
|
+
|