flashsdk 1.0.1.pre

Sign up to get free protection for your applications and to get access to all the features.
Files changed (43) hide show
  1. data/Gemfile +9 -0
  2. data/README.textile +0 -0
  3. data/VERSION +1 -0
  4. data/bin/sprout-as3 +9 -0
  5. data/flashsdk.gemspec +23 -0
  6. data/lib/flashplayer/clix_flash_player.rb +91 -0
  7. data/lib/flashplayer/clix_wrapper.rb +22 -0
  8. data/lib/flashplayer/errors.rb +12 -0
  9. data/lib/flashplayer/log_file.rb +95 -0
  10. data/lib/flashplayer/mm_config.rb +96 -0
  11. data/lib/flashplayer/module.rb +50 -0
  12. data/lib/flashplayer/specification.rb +32 -0
  13. data/lib/flashplayer/task.legacy.rb +293 -0
  14. data/lib/flashplayer/task.rb +137 -0
  15. data/lib/flashplayer/trust.rb +45 -0
  16. data/lib/flashplayer.rb +8 -0
  17. data/lib/flashsdk/generators/class_generator.rb +43 -0
  18. data/lib/flashsdk/generators/flash_helper.rb +48 -0
  19. data/lib/flashsdk/generators/project_generator.rb +53 -0
  20. data/lib/flashsdk/generators/templates/ActionScript3Class.as +9 -0
  21. data/lib/flashsdk/generators/templates/ActionScript3MainClass.as +11 -0
  22. data/lib/flashsdk/generators/templates/DefaultProjectImage.png +0 -0
  23. data/lib/flashsdk/generators/templates/Gemfile +6 -0
  24. data/lib/flashsdk/generators/templates/rakefile.rb +17 -0
  25. data/lib/flashsdk/module.rb +9 -0
  26. data/lib/flashsdk/tasks/mxmlc.rb +687 -0
  27. data/lib/flashsdk/tasks/mxmlc_legacy.rb +135 -0
  28. data/lib/flashsdk.rb +12 -0
  29. data/lib/flex3.rb +53 -0
  30. data/lib/flex4.rb +58 -0
  31. data/rakefile.rb +20 -0
  32. data/test/fixtures/mxmlc/simple/SomeFile.as +11 -0
  33. data/test/unit/class_generator_test.rb +50 -0
  34. data/test/unit/flash_helper_test.rb +27 -0
  35. data/test/unit/flashplayer_test.rb +56 -0
  36. data/test/unit/log_file_test.rb +47 -0
  37. data/test/unit/mm_config_test.rb +74 -0
  38. data/test/unit/mxmlc_test.rb +45 -0
  39. data/test/unit/project_generator_test.rb +53 -0
  40. data/test/unit/task_test.rb +93 -0
  41. data/test/unit/test_helper.rb +16 -0
  42. data/test/unit/trust_test.rb +30 -0
  43. metadata +145 -0
@@ -0,0 +1,135 @@
1
+
2
+ =begin
3
+ def define # :nodoc:
4
+ super
5
+
6
+ if(!output)
7
+ if(name.match(/.swf/) || name.match(/swc/))
8
+ self.output = name
9
+ end
10
+ end
11
+
12
+ if(input && !input.match(/.css/) && File.exists?(input))
13
+ source_path << File.dirname(input)
14
+ end
15
+
16
+ if(include_path)
17
+ include_path.each do |path|
18
+ process_include_path(path) if(File.directory?(path))
19
+ end
20
+ end
21
+
22
+ self.include_path = []
23
+
24
+ if(link_report)
25
+ CLEAN.add(link_report)
26
+ end
27
+
28
+ source_path.uniq!
29
+ param_hash['source_path'].value = clean_nested_source_paths(source_path)
30
+
31
+ CLEAN.add(output)
32
+ if(incremental)
33
+ CLEAN.add(FileList['**/**/*.cache'])
34
+ end
35
+
36
+ self
37
+ end
38
+
39
+ protected
40
+
41
+ def process_include_path(path)
42
+ symbols = []
43
+ FileList["#{path}/**/*[.as|.mxml]"].each do |file|
44
+ next if File.directory?(file)
45
+ file.gsub!(path, '')
46
+ file.gsub!(/^\//, '')
47
+ file.gsub!('/', '.')
48
+ file.gsub!(/.as$/, '')
49
+ file.gsub!(/.mxml$/, '')
50
+ file.gsub!(/.css$/, '')
51
+ symbols << file
52
+ end
53
+
54
+ symbols.each do |symbol|
55
+ self.includes << symbol
56
+ end
57
+ end
58
+
59
+ def clean_nested_source_paths(paths)
60
+ results = []
61
+ paths.each do |path|
62
+ # TODO: This should only happen if: allow_source_path_overlap != true
63
+ if(check_nested_source_path(results, path))
64
+ results << path
65
+ end
66
+ end
67
+ return results
68
+ end
69
+
70
+ def check_nested_source_path(array, path)
71
+ array.each_index do |index|
72
+ item = array[index]
73
+ if(item =~ /^#{path}/)
74
+ array.slice!(index, 1)
75
+ elsif(path =~ /^#{item}/)
76
+ return false
77
+ end
78
+ end
79
+ return true
80
+ end
81
+
82
+ # Use the swc path if possible
83
+ # Otherwise add to source
84
+ def resolve_library(library_task)
85
+ #TODO: Add support for libraries that don't get
86
+ # copied into the project
87
+ path = library_task.project_path
88
+ if(path.match(/.swc$/))
89
+ library_path << library_task.project_path
90
+ else
91
+ source_path << library_task.project_path
92
+ end
93
+ end
94
+
95
+ def execute_with_fcsh(command)
96
+ begin
97
+ display_preprocess_message
98
+ puts FCSHSocket.execute("mxmlc #{command}")
99
+ rescue FCSHError => fcsh_error
100
+ raise fcsh_error
101
+ rescue StandardError => std_error
102
+ # TODO: Capture a more concrete error here...
103
+ raise MXMLCError.new("[ERROR] There was a problem connecting to the Flex Compiler SHell, run 'rake fcsh:start' in another terminal.")
104
+ end
105
+ end
106
+
107
+ def execute(*args)
108
+ begin
109
+ start = Time.now.to_i
110
+ if(@use_fcsh)
111
+ execute_with_fcsh(to_shell)
112
+ else
113
+ super
114
+ end
115
+ Log.puts "mxmlc finished compiling #{name} in #{Time.now.to_i - start} seconds"
116
+ rescue ExecutionError => e
117
+ if(e.message.index('Warning:'))
118
+ # MXMLC sends warnings to stderr....
119
+ Log.puts(e.message.gsub('[ERROR]', '[WARNING]'))
120
+ else
121
+ raise e
122
+ end
123
+ end
124
+ end
125
+
126
+ end
127
+ end
128
+
129
+ # Helper method for definining and accessing MXMLC instances in a rakefile
130
+ def mxmlc(args, &block)
131
+ AS3::MXMLC.define_task(args, &block)
132
+ end
133
+
134
+ =end
135
+
data/lib/flashsdk.rb ADDED
@@ -0,0 +1,12 @@
1
+ require 'sprout'
2
+
3
+ lib = File.expand_path File.dirname(__FILE__)
4
+ $:.unshift lib unless $:.include?(lib)
5
+
6
+ require 'flashsdk/module'
7
+ require 'flashsdk/generators/flash_helper'
8
+ require 'flashsdk/generators/class_generator'
9
+ require 'flashsdk/generators/project_generator'
10
+ require 'flashsdk/tasks/mxmlc'
11
+ require 'flashplayer'
12
+
data/lib/flex3.rb ADDED
@@ -0,0 +1,53 @@
1
+
2
+ Sprout::Specification.new do |s|
3
+ s.name = 'flex3'
4
+ s.version = FlashSDK::VERSION
5
+
6
+ # Create an independent remote_file_target for each
7
+ # platform that must be supported independently.
8
+ #
9
+ # If the archive includes support for all platforms (:windows, :osx, :unix)
10
+ # then set platform = :universal
11
+ #
12
+ s.add_remote_file_target do |t|
13
+ # Apply the windows-specific configuration:
14
+ t.platform = :universal
15
+ # Apply the shared platform configuration:
16
+ # Remote Archive:
17
+ t.archive_type = :zip
18
+ t.url = "http://fpdownload.adobe.com/pub/flex/sdk/builds/flex3/flex_sdk_3.4.0.9271_mpl.zip"
19
+ t.md5 = "ba0df5a5b7a9c901540bedaf8a4fec9e"
20
+
21
+ # Executables: (add .exe suffix if it was passed in)
22
+ t.add_executable :aasdoc, "bin/aasdoc"
23
+ t.add_executable :acompc, "bin/acompc"
24
+ t.add_executable :adl, "bin/adl"
25
+ t.add_executable :adt, "bin/adt"
26
+ t.add_executable :amxmlc, "bin/amxmlc"
27
+ t.add_executable :asdoc, "bin/asdoc"
28
+ t.add_executable :compc, "bin/compc"
29
+ t.add_executable :copylocale, "bin/compc"
30
+ t.add_executable :digest, "bin/digest"
31
+ t.add_executable :fcsh, "bin/fcsh"
32
+ t.add_executable :fdb, "bin/fdb"
33
+ t.add_executable :mxmlc, "bin/mxmlc"
34
+ t.add_executable :optimizer, "bin/optimizer"
35
+
36
+ # Flex framework SWCs:
37
+ t.add_library :flex, "frameworks/libs/flex.swc"
38
+ t.add_library :framework, "frameworks/libs/framework.swc"
39
+ t.add_library :rpc, "frameworks/libs/rpc.swc"
40
+ t.add_library :utilities, "frameworks/libs/utilities.swc"
41
+ t.add_library :playerglobal_9, "frameworks/libs/player/9/playerglobal.swc"
42
+ t.add_library :playerglobal_10, "frameworks/libs/player/10/playerglobal.swc"
43
+
44
+ # AsDoc templates:
45
+ t.add_library :asdoc_templates, "asdoc/templates"
46
+
47
+ # Locale-Specific Flex SWCs:
48
+ t.add_library :airframework_en_US, "frameworks/locale/en_US/airframework_rb.swc"
49
+ t.add_library :framework_en_US, "frameworks/locale/en_US/framework_rb.swc"
50
+ t.add_library :rpc_en_US, "frameworks/locale/en_US/rpc_rb.swc"
51
+ end
52
+ end
53
+
data/lib/flex4.rb ADDED
@@ -0,0 +1,58 @@
1
+
2
+ Sprout::Specification.new do |s|
3
+ s.name = 'flex4'
4
+ s.version = FlashSDK::VERSION
5
+
6
+ s.add_remote_file_target do |t|
7
+ # Apply the windows-specific configuration:
8
+ t.platform = :universal
9
+ # Apply the shared platform configuration:
10
+ # Remote Archive:
11
+ t.archive_type = :zip
12
+ t.url = "http://download.macromedia.com/pub/labs/flex/4/flex4sdk_b2_100509.zip"
13
+ t.md5 = "6a0838c5cb33145fe88933778ddb966d"
14
+
15
+ # Executables: (add .exe suffix if it was passed in)
16
+ t.add_executable :aasdoc, "bin/aasdoc"
17
+ t.add_executable :acompc, "bin/acompc"
18
+ t.add_executable :adl, "bin/adl"
19
+ t.add_executable :adt, "bin/adt"
20
+ t.add_executable :amxmlc, "bin/amxmlc"
21
+ t.add_executable :asdoc, "bin/asdoc"
22
+ t.add_executable :compc, "bin/compc"
23
+ t.add_executable :copylocale, "bin/compc"
24
+ t.add_executable :digest, "bin/digest"
25
+ t.add_executable :fcsh, "bin/fcsh"
26
+ t.add_executable :fdb, "bin/fdb"
27
+ t.add_executable :mxmlc, "bin/mxmlc"
28
+ t.add_executable :optimizer, "bin/optimizer"
29
+
30
+ # Flex framework SWCs:
31
+ t.add_library :flex, "frameworks/libs/flex.swc"
32
+ t.add_library :flex4, "frameworks/libs/flex4.swc"
33
+ t.add_library :f_textlayout, "frameworks/libs/framework_textLayout.swc"
34
+ t.add_library :framework, "frameworks/libs/framework.swc"
35
+ t.add_library :rpc, "frameworks/libs/rpc.swc"
36
+ t.add_library :sparkskins, "frameworks/libs/sparkskins.swc"
37
+ t.add_library :textlayout, "frameworks/libs/textLayout.swc"
38
+ t.add_library :utilities, "frameworks/libs/utilities.swc"
39
+ t.add_library :playerglobal_9, "frameworks/libs/player/9/playerglobal.swc"
40
+ t.add_library :playerglobal_10, "frameworks/libs/player/10/playerglobal.swc"
41
+
42
+ # AsDoc templates:
43
+ t.add_library :asdoc_templates, "asdoc/templates"
44
+
45
+ # Locale-Specific Flex SWCs:
46
+ [
47
+ 'da_DK', 'de_DE', 'en_US', 'es_ES', 'fi_FL', 'fr_FR', 'it_IT', 'ja_JP',
48
+ 'ko_KR', 'nb_NO', 'nl_NL', 'pt_BR', 'ru_RU', 'sv_SE', 'zh_CN', 'zh_TW'
49
+ ].each do |locale|
50
+ t.add_library "flex_4_#{locale}".to_sym, "frameworks/locale/#{locale}/flex4_rb.swc"
51
+ t.add_library "airframework_#{locale}".to_sym, "frameworks/locale/#{locale}/airframework_rb.swc"
52
+ t.add_library "framework_#{locale}".to_sym, "frameworks/locale/#{locale}/framework_rb.swc"
53
+ t.add_library "rpc_#{locale}".to_sym, "frameworks/locale/#{locale}/rpc_rb.swc"
54
+ end
55
+ end
56
+ end
57
+
58
+
data/rakefile.rb ADDED
@@ -0,0 +1,20 @@
1
+ require 'rubygems'
2
+ require 'bundler'
3
+
4
+ Bundler.setup
5
+
6
+ require 'rake'
7
+ require 'rake/clean'
8
+ require 'rake/testtask'
9
+
10
+ namespace :test do
11
+
12
+ Rake::TestTask.new(:units) do |t|
13
+ t.libs << "test/unit"
14
+ t.test_files = FileList["test/unit/*_test.rb"]
15
+ t.verbose = true
16
+ end
17
+
18
+ end
19
+
20
+ task :test => 'test:units'
@@ -0,0 +1,11 @@
1
+ package {
2
+ import flash.display.Sprite;
3
+
4
+ public class SomeFile extends Sprite {
5
+
6
+ public function SomeFile() {
7
+ trace(">> SomeFile instantiated");
8
+ }
9
+ }
10
+ }
11
+
@@ -0,0 +1,50 @@
1
+ require File.join(File.dirname(__FILE__), "test_helper")
2
+
3
+ class ClassGeneratorTest < Test::Unit::TestCase
4
+ include SproutTestCase
5
+
6
+ context "a new class generator" do
7
+
8
+ setup do
9
+ @temp = File.join(fixtures, 'generators', 'tmp')
10
+ FileUtils.mkdir_p @temp
11
+ @generator = FlashSDK::ClassGenerator.new
12
+ @generator.path = @temp
13
+ @generator.logger = StringIO.new
14
+
15
+ Sprout::Generator.register FlashSDK::ClassGenerator
16
+ Sprout::Generator.register FlashSDK::TestClassGenerator
17
+ Sprout::Generator.register FlashSDK::SuiteClassGenerator
18
+ end
19
+
20
+ teardown do
21
+ remove_file @temp
22
+ end
23
+
24
+ should "work with a simple class" do
25
+ @generator.input = 'utils.MathUtil'
26
+ @generator.execute
27
+ assert_file File.join(@temp, 'src', 'utils', 'MathUtil.as')
28
+ end
29
+
30
+ should "work with no package" do
31
+ @generator.input = 'MathUtil'
32
+ @generator.execute
33
+ assert_file File.join(@temp, 'src', 'MathUtil.as')
34
+ end
35
+
36
+ should "work with directory instead of dots" do
37
+ @generator.input = 'src/utils/MathUtil.as'
38
+ @generator.execute
39
+ assert_file File.join(@temp, 'src', 'utils', 'MathUtil.as')
40
+ end
41
+
42
+ should "work with directory but no source" do
43
+ @generator.input = 'utils/MathUtil.as'
44
+ @generator.execute
45
+ assert_file File.join(@temp, 'src', 'utils', 'MathUtil.as')
46
+ end
47
+ end
48
+
49
+ end
50
+
@@ -0,0 +1,27 @@
1
+ require File.join(File.dirname(__FILE__), 'test_helper')
2
+
3
+ class FlashHelperTest < Test::Unit::TestCase
4
+ include SproutTestCase
5
+
6
+ context "A FlashHelper" do
7
+
8
+ [
9
+ { :input => 'com.foo.Bar', :expected => 'com.foo.Bar' }
10
+ #{ :input => 'com/foo/Bar.as', :expected => 'com.foo.Bar' },
11
+ #{ :input => 'com.out.HTML', :expected => 'com.out.HTML' },
12
+ #{ :input => 'bar', :expected => 'Bar' }
13
+ ].each do |input|
14
+
15
+ should "return fully qualified classname for #{input[:input]}" do
16
+ instance = FakeGenerator.new
17
+ instance.input = input[:input]
18
+ assert_equal input[:expected], instance.fully_qualified_class_name
19
+ end
20
+ end
21
+ end
22
+ end
23
+
24
+ class FakeGenerator < Sprout::Generator::Base
25
+ include FlashSDK::FlashHelper
26
+ end
27
+
@@ -0,0 +1,56 @@
1
+ require File.join(File.dirname(__FILE__), 'test_helper')
2
+
3
+ class FlashPlayerTest < Test::Unit::TestCase
4
+ include SproutTestCase
5
+
6
+ context "The FlashPlayer module" do
7
+
8
+ context "should find home" do
9
+
10
+ setup do
11
+ @fixture = File.join(fixtures, 'home')
12
+
13
+ @osx_home1 = File.join(@fixture, 'Preferences', 'Macromedia', 'Flash Player')
14
+ @osx_home2 = File.join(@fixture, 'Application Support', 'Macromedia')
15
+ @win_home1 = File.join(@fixture, 'Application Data', 'Macromedia', 'Flash Player')
16
+ @win_home2 = File.join(@fixture, 'AppData', 'Roaming', 'Macromedia', 'Flash Player')
17
+ @nix_home1 = File.join(@fixture, '.macromedia', 'Flash_Player')
18
+
19
+ # Ensure the looks in our Fixtures folder instead of system:
20
+ FlashPlayer.stubs(:system_library).returns @fixture
21
+ FlashPlayer.stubs(:system_home).returns @fixture
22
+ end
23
+
24
+ teardown do
25
+ remove_file File.join(@fixture)
26
+ end
27
+
28
+ should "find home on osx" do
29
+ FileUtils.mkdir_p @osx_home1
30
+ assert_equal @osx_home1, FlashPlayer.home
31
+ end
32
+
33
+ should "find home on osx 2" do
34
+ FileUtils.mkdir_p @osx_home2
35
+ assert_equal @osx_home2, FlashPlayer.home
36
+ end
37
+
38
+ should "find home on win 1" do
39
+ FileUtils.mkdir_p @win_home1
40
+ assert_equal @win_home1, FlashPlayer.home
41
+ end
42
+
43
+ should "find home on win 2" do
44
+ FileUtils.mkdir_p @win_home2
45
+ assert_equal @win_home2, FlashPlayer.home
46
+ end
47
+
48
+ should "find home on nix 1" do
49
+ FileUtils.mkdir_p @nix_home1
50
+ assert_equal @nix_home1, FlashPlayer.home
51
+ end
52
+ end
53
+
54
+ end
55
+ end
56
+
@@ -0,0 +1,47 @@
1
+ require File.join(File.dirname(__FILE__), 'test_helper')
2
+
3
+ class LogFileTest < Test::Unit::TestCase
4
+ include SproutTestCase
5
+
6
+ context "A LogFile" do
7
+
8
+ setup do
9
+ @logger = StringIO.new
10
+ @flashlog = File.join(fixtures, 'flashlog.txt')
11
+ @reader = FlashPlayer::LogFile.new
12
+ @reader.logger = @logger
13
+ @reader.stubs(:flashlog_path).returns @flashlog
14
+
15
+ FileUtils.touch @flashlog
16
+ end
17
+
18
+ teardown do
19
+ remove_file @flashlog
20
+ end
21
+
22
+ should "read until killed" do
23
+ blocked = true
24
+ t = Thread.new {
25
+ @reader.tail
26
+ blocked = false
27
+ }
28
+
29
+ assert blocked
30
+ t.kill
31
+ end
32
+
33
+
34
+ # This method only works when run alone -
35
+ # Under normal circumstances, the SproutTestCase
36
+ # clears out any Rake tasks that have been defined
37
+ # and we don't have an easy way to redefine the
38
+ # task...
39
+ #should "read from rake task" do
40
+ #FlashPlayer::LogFile.any_instance.stubs(:logger).returns StringIO.new
41
+ #FlashPlayer::LogFile.any_instance.expects(:read_flashlog_at)
42
+ #Rake.application[:flashlog].invoke
43
+ #end
44
+
45
+ end
46
+ end
47
+
@@ -0,0 +1,74 @@
1
+ require File.join(File.dirname(__FILE__), 'test_helper')
2
+
3
+ class MMConfigTest < Test::Unit::TestCase
4
+ include SproutTestCase
5
+
6
+ context "An MMConfig" do
7
+
8
+ setup do
9
+ @home = File.join(fixtures, 'home')
10
+ @osx_fp = File.join(@home, 'Application Support', 'Macromedia')
11
+ @linux_fp = File.join(@home, '.macromedia', 'Flash_Player')
12
+
13
+ FileUtils.mkdir_p @home
14
+
15
+ @mm_config = FlashPlayer::MMConfig.new
16
+ @mm_config.stubs(:user_confirmation?).returns true
17
+ @mm_config.logger = StringIO.new
18
+ end
19
+
20
+ teardown do
21
+ remove_file @home
22
+ end
23
+
24
+ should "ignore failure if flashplayer has never run" do
25
+ # No creation of expected FlashPlayer folders...
26
+
27
+ as_a_mac_system do
28
+ @mm_config.stubs(:system_library).returns @home
29
+ @mm_config.stubs(:flashplayer_home).returns @osx_fp
30
+ @mm_config.create
31
+ end
32
+ end
33
+
34
+ should "create a config file on OS X with FP 9" do
35
+ FileUtils.mkdir_p @osx_fp
36
+ flashlog = File.expand_path(File.join(@osx_fp, 'Logs', 'flashlog.txt'))
37
+
38
+ as_a_mac_system do
39
+ @mm_config.stubs(:system_library).returns @home
40
+ @mm_config.stubs(:flashplayer_home).returns @osx_fp
41
+ @mm_config.stubs(:flashlog_path).returns flashlog
42
+ @mm_config.create
43
+ mm_cfg = File.join(@osx_fp, mm_config_file)
44
+ assert_file mm_cfg do |content|
45
+ assert_matches /#{@flashlog}/, content
46
+ end
47
+ end
48
+ end
49
+
50
+ should "create a config file on linux" do
51
+ FileUtils.mkdir_p @linux_fp
52
+ flashlog = File.expand_path(File.join(@linux_fp, 'Logs', 'flashlog.txt'))
53
+
54
+ as_a_unix_system do
55
+ @mm_config.stubs(:system_library).returns @home
56
+ @mm_config.stubs(:system_home).returns @home
57
+ @mm_config.stubs(:flashlog_path).returns flashlog
58
+ @mm_config.stubs(:flashplayer_home).returns @linux_fp
59
+ @mm_config.create
60
+ mm_cfg = File.join(@home, mm_config_file)
61
+ assert_file mm_cfg do |content|
62
+ assert_matches /#{flashlog}/, content
63
+ end
64
+ end
65
+ end
66
+ end
67
+
68
+ private
69
+
70
+ def mm_config_file
71
+ FlashPlayer::MMConfig::FILE_NAME
72
+ end
73
+ end
74
+
@@ -0,0 +1,45 @@
1
+ require File.join(File.dirname(__FILE__), 'test_helper')
2
+
3
+ class MXMLCTest < Test::Unit::TestCase
4
+ include SproutTestCase
5
+
6
+ context "An MXMLC tool" do
7
+
8
+ setup do
9
+ @fixture = File.join 'test', 'fixtures', 'mxmlc', 'simple'
10
+ @input = File.join @fixture, 'SomeFile.as'
11
+ @expected_output = File.join @fixture, 'SomeFile.swf'
12
+ #Sprout::Log.debug = false
13
+ end
14
+
15
+ teardown do
16
+ remove_file @expected_output
17
+ end
18
+
19
+ should "accept input" do
20
+ as_a_unix_system do
21
+ mxmlc = FlashSDK::MXMLC.new
22
+ mxmlc.input = @input
23
+ mxmlc.source_path << @fixture
24
+ assert_equal '--source-path+=test/fixtures/mxmlc/simple test/fixtures/mxmlc/simple/SomeFile.as', mxmlc.to_shell
25
+ end
26
+ end
27
+
28
+ should "compile a swf" do
29
+ mxmlc = FlashSDK::MXMLC.new
30
+ mxmlc.input = @input
31
+ # Turn on to trigger an actual compilation:
32
+ # (This is too damn slow to leave in the every-time test run)
33
+ mxmlc.execute
34
+ assert_file @expected_output
35
+ end
36
+
37
+ should "assign simple output" do
38
+ t = mxmlc 'bin/SomeProject.swf' do |t|
39
+ t.input = @input
40
+ end
41
+ assert_equal 'bin/SomeProject.swf', t.output
42
+ end
43
+ end
44
+ end
45
+
@@ -0,0 +1,53 @@
1
+ require File.join(File.dirname(__FILE__), "test_helper")
2
+
3
+ class ProjectGeneratorTest < Test::Unit::TestCase
4
+ include SproutTestCase
5
+
6
+ context "A new project generator" do
7
+
8
+ setup do
9
+ @temp = File.join(fixtures, 'generators', 'tmp')
10
+ FileUtils.mkdir_p @temp
11
+ @generator = FlashSDK::ProjectGenerator.new
12
+ @generator.path = @temp
13
+ @generator.logger = StringIO.new
14
+ end
15
+
16
+ teardown do
17
+ remove_file @temp
18
+ end
19
+
20
+ should "generate a new application" do
21
+ @generator.input = 'SomeProject'
22
+ @generator.execute
23
+ project = File.join(@temp, 'SomeProject')
24
+ assert_directory project
25
+ assert_file File.join(project, 'Gemfile') do |content|
26
+ assert_matches /asunit4/, content
27
+ end
28
+ assert_file File.join(project, 'rakefile.rb') do |content|
29
+ assert_matches /bin\/SomeProject-debug.swf\"/, content
30
+ assert_matches /src\/SomeProject.as/, content
31
+ end
32
+ assert_file File.join(project, 'src', 'SomeProject.as') do |content|
33
+ assert_matches /flash.display.Sprite;/, content
34
+ end
35
+ assert_directory File.join(project, 'lib')
36
+ assert_directory File.join(project, 'bin')
37
+ end
38
+
39
+ should "accept alternate bin dir" do
40
+ @generator.bin = 'other'
41
+ @generator.input = 'OtherProject'
42
+ @generator.execute
43
+ project = File.join(@temp, 'OtherProject')
44
+ assert_directory project
45
+ assert_directory File.join(project, 'other')
46
+ assert_file File.join(project, 'rakefile.rb') do |content|
47
+ assert_matches /other\/OtherProject-debug.swf/, content
48
+ end
49
+ end
50
+
51
+ end
52
+ end
53
+