flexutils 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/.document ADDED
@@ -0,0 +1,5 @@
1
+ README.rdoc
2
+ lib/**/*.rb
3
+ bin/*
4
+ features/**/*.feature
5
+ LICENSE
data/.gitignore ADDED
@@ -0,0 +1,10 @@
1
+ .DS_Store
2
+ *.tmproj
3
+ dist
4
+ examples/build
5
+ examples/dist
6
+ *.sw?
7
+ .DS_Store
8
+ coverage
9
+ rdoc
10
+ pkg
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2009 Theo Hultberg
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.markdown ADDED
File without changes
data/Rakefile ADDED
@@ -0,0 +1,69 @@
1
+ require 'rake/testtask'
2
+ require 'rake/clean'
3
+ require 'rake/rdoctask'
4
+ require 'spec/rake/spectask'
5
+ require 'jeweler'
6
+
7
+
8
+ CLOBBER.include('dist')
9
+
10
+
11
+ task :default => [:spec, :dist]
12
+
13
+ desc 'Package the FlexUtils scripts as a single file'
14
+ task :dist => 'dist/flexutils.rb'
15
+
16
+ file 'dist/flexutils.rb' => ['lib/flexutils/FlexUtils.rb'] + FileList['lib/flexutils/*.rb'].exclude('lib/flexutils/FlexUtils.rb') do |t|
17
+ mkdir_p 'dist'
18
+
19
+ File.open(t.name, 'w') do |destination_file|
20
+ destination_file.puts("module FlexUtils")
21
+
22
+ t.prerequisites.each do |script|
23
+ code = File.read(script)
24
+
25
+ offset = code.index('module FlexUtils') + 16
26
+ length = code.rindex('end') - offset
27
+
28
+ code = code.slice(offset, length)
29
+
30
+ destination_file.puts(code)
31
+ end
32
+
33
+ destination_file.puts("end")
34
+ end
35
+ end
36
+
37
+ desc "Run the specifications"
38
+ Spec::Rake::SpecTask.new(:spec) do |t|
39
+ t.spec_files = FileList['spec/*_spec.rb']
40
+ t.libs = [File.dirname(__FILE__) + '/lib']
41
+ t.spec_opts = ['--require', 'lib/flexutils', '--format', 'specdoc', '--color']
42
+ t.fail_on_error = true
43
+ t.failure_message = 'Tests failed'
44
+ end
45
+
46
+ Jeweler::Tasks.new do |gem|
47
+ gem.name = 'flexutils'
48
+ gem.summary = 'Ruby wrappers for the Flex SDK tools'
49
+ gem.description = ""
50
+ gem.email = 'theo@iconara.net'
51
+ gem.homepage = 'http://github.com/iconara/flexutils'
52
+ gem.authors = ['Theo Hultberg']
53
+ gem.add_development_dependency "rspec"
54
+ end
55
+
56
+ Jeweler::GemcutterTasks.new
57
+
58
+ Rake::RDocTask.new do |rdoc|
59
+ if File.exist?('VERSION')
60
+ version = File.read('VERSION')
61
+ else
62
+ version = ""
63
+ end
64
+
65
+ rdoc.rdoc_dir = 'rdoc'
66
+ rdoc.title = "test #{version}"
67
+ rdoc.rdoc_files.include('README*')
68
+ rdoc.rdoc_files.include('lib/**/*.rb')
69
+ end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 1.0.0
data/examples/Rakefile ADDED
@@ -0,0 +1,89 @@
1
+ # add the lib directory to the load path so that you can run this without having to install FlexUtils
2
+ $: << File.dirname(__FILE__) + '/../lib'
3
+
4
+ # ---
5
+
6
+ require 'rake/clean'
7
+ require 'flexutils'
8
+
9
+ # ---
10
+
11
+ include FlexUtils
12
+
13
+ # ---
14
+
15
+ ENV['FLEX_HOME'] ||= '/Developer/Flex/flex-sdk-3.3'
16
+
17
+ # ---
18
+
19
+ SOURCE_FILES = FileList['src/**/*.mxml', 'src/**/*.as']
20
+ SOURCE_FILES.exclude('**/Test*.as')
21
+
22
+ MAIN_SWF = 'build/Main.swf'
23
+ TESTS_SWF = 'build/Tests.swf'
24
+ EXAMPLE_SWC = 'dist/example.swc'
25
+
26
+ # ---
27
+
28
+ CLEAN.include(MAIN_SWF + '.cache')
29
+
30
+ CLOBBER.include('build')
31
+ CLOBBER.include('dist')
32
+
33
+ # ---
34
+
35
+ desc "Runs the tests and compiles the SWF and the SWC"
36
+ task :default => [:init, :test, MAIN_SWF, EXAMPLE_SWC]
37
+
38
+ task :init do
39
+ mkdir_p 'build'
40
+ mkdir_p 'dist'
41
+ end
42
+
43
+ desc "Runs the tests"
44
+ task :test => TESTS_SWF do |t|
45
+ TestRunner.run(t.name) do |conf|
46
+ conf.title = 'Tests'
47
+ conf.exit_on_complete = false
48
+ conf.fail_on_error = true
49
+ end
50
+ end
51
+
52
+ file MAIN_SWF => SOURCE_FILES do |t|
53
+ Mxmlc.compile(t.name, 'src/Main.mxml') do |conf|
54
+ conf.debug = true
55
+ conf.incremental = true
56
+ conf.theme_files = FileList['theme/*.css']
57
+ conf.locale = ['en_US']
58
+ conf.source_path = ['src', 'locale/{locale}', 'theme']
59
+ conf.library_path = ['lib']
60
+ conf.warnings = {'show-unused-type-selector-warnings' => false}
61
+ conf.target_player = '10'
62
+ conf.fail_on_warning = true
63
+ end
64
+ end
65
+
66
+ file TESTS_SWF => SOURCE_FILES + FileList['**/Test*.as'] do |t|
67
+ Mxmlc.compile(t.name, 'src/Tests.mxml') do |conf|
68
+ conf.debug = true
69
+ conf.incremental = true
70
+ conf.locale = ['en_US']
71
+ conf.source_path = ['src', 'locale/{locale}', 'theme']
72
+ conf.library_path = ['lib']
73
+ conf.warnings = {'show-unused-type-selector-warnings' => false}
74
+ conf.target_player = '10'
75
+ conf.fail_on_warning = true
76
+ end
77
+ end
78
+
79
+ file EXAMPLE_SWC => FileList['src/SomeClass.as'] do |t|
80
+ classes = t.prerequisites.map do |path|
81
+ # remove source path and the file extention and turn directory structure into package structure
82
+ path.gsub('src/', '').gsub(/\.\w+$/, '').gsub('/', '.')
83
+ end
84
+
85
+ Compc.compile(t.name) do |conf|
86
+ conf.source_path = ['src']
87
+ conf.include_classes = classes
88
+ end
89
+ end
File without changes
File without changes
@@ -0,0 +1,7 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+
3
+ <Application xmlns="http://www.adobe.com/2006/mxml">
4
+
5
+ <Label text="Hello World"/>
6
+
7
+ </Application>
@@ -0,0 +1,7 @@
1
+ package {
2
+
3
+ public class SomeClass {
4
+
5
+ }
6
+
7
+ }
@@ -0,0 +1,7 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+
3
+ <Application xmlns="http://www.adobe.com/2006/mxml">
4
+
5
+ <Label text="Tests"/>
6
+
7
+ </Application>
File without changes
data/lib/flexutils.rb ADDED
@@ -0,0 +1,7 @@
1
+ require 'flexutils/flex_utils'
2
+ require 'flexutils/adl'
3
+ require 'flexutils/adt'
4
+ require 'flexutils/asc'
5
+ require 'flexutils/compc'
6
+ require 'flexutils/mxmlc'
7
+ require 'flexutils/test_runner'
@@ -0,0 +1,99 @@
1
+ module FlexUtils
2
+
3
+ class Adl < AbstractTool
4
+
5
+ attr_writer :swf,
6
+ :title,
7
+ :visible,
8
+ :transparent,
9
+ :width,
10
+ :height,
11
+ :x,
12
+ :y,
13
+ :system_chrome,
14
+ :arguments,
15
+ :descriptor
16
+
17
+ def initialize( swf )
18
+ @swf = swf
19
+ @title = "Temporary AIR application"
20
+ @visible = true
21
+ @transparent = false
22
+ @width = 1024
23
+ @height = 768
24
+ @x = 100
25
+ @y = 100
26
+ @system_chrome = "standard"
27
+ @arguments = []
28
+ end
29
+
30
+ def generate_descriptor
31
+ return <<-stop
32
+ <?xml version="1.0"?>
33
+
34
+ <application xmlns="http://ns.adobe.com/air/application/1.5">
35
+ <id>net.iconara.tmp</id>
36
+ <version>1.0</version>
37
+ <filename>#{@title}</filename>
38
+ <initialWindow>
39
+ <title>#{@title}</title>
40
+ <content>#{File.basename(@swf)}</content>
41
+ <systemChrome>#{@system_chrome}</systemChrome>
42
+ <transparent>#{@transparent}</transparent>
43
+ <visible>#{@visible}</visible>
44
+ <width>#{@width}</width>
45
+ <height>#{@height}</height>
46
+ <x>#{@x}</x>
47
+ <y>#{@y}</y>
48
+ </initialWindow>
49
+ </application>
50
+ stop
51
+ end
52
+
53
+ def self.run( *args )
54
+ c = self.new(*args)
55
+
56
+ yield c
57
+
58
+ c.run!
59
+ end
60
+
61
+ def command_string
62
+ @extra_args ||= [ ]
63
+
64
+ args = (@arguments + @extra_args).join(" ")
65
+
66
+ "#{command_path 'adl'} #{@descriptor} -- #{args}"
67
+ end
68
+
69
+ def run!( extra_args=[], &block )
70
+ @extra_args = extra_args
71
+
72
+ current_dir = Dir.pwd
73
+
74
+ dir = File.dirname(@swf)
75
+
76
+ Dir.chdir(dir)
77
+
78
+ temporary_descriptor = @descriptor == nil
79
+
80
+ if temporary_descriptor
81
+ @descriptor = "temporary-application.xml"
82
+
83
+ descriptor = File.new(@descriptor, "w")
84
+ descriptor.puts(generate_descriptor)
85
+ descriptor.close
86
+ end
87
+
88
+ execute_command
89
+
90
+ yield($?) if block_given?
91
+
92
+ File.delete(@descriptor) if temporary_descriptor
93
+
94
+ Dir.chdir(current_dir)
95
+ end
96
+
97
+ end
98
+
99
+ end
@@ -0,0 +1,61 @@
1
+ module FlexUtils
2
+
3
+ class Adt < AbstractTool
4
+
5
+ attr_writer :descriptor,
6
+ :keyfile,
7
+ :keypass,
8
+ :name,
9
+ :files
10
+
11
+ def initialize
12
+ @files = []
13
+ end
14
+
15
+ def self.app_version( descriptor_path )
16
+ require 'rexml/document'
17
+
18
+ doc = REXML::Document.new(File.new(descriptor_path))
19
+
20
+ version_xpath = '/application/version/text()'
21
+
22
+ REXML::XPath.first(doc, version_xpath).to_s
23
+ end
24
+
25
+ def self.package
26
+ c = self.new
27
+
28
+ yield c
29
+
30
+ c.package!
31
+ end
32
+
33
+ def command_string
34
+ unless @keyfile && @keypass && @name && @descriptor && @files
35
+ raise ArgumentError, 'Missing arguments'
36
+ end
37
+
38
+ command = command_path 'adt'
39
+ keyfile = @keyfile.gsub(File.dirname(@descriptor) + '/', '')
40
+ descriptor = File.basename(@descriptor)
41
+ name = File.basename(@name).gsub(/\.air$/, '')
42
+ files = (@files || []).map { |f| f.gsub(dir + '/', '') }.join(' ')
43
+
44
+ "#{command} -package -storetype pkcs12 -keystore #{keyfile} -storepass #{@keypass} #{name} #{descriptor} #{files}"
45
+ end
46
+
47
+ def package!
48
+ current_dir = Dir.pwd
49
+
50
+ dir = File.dirname(@descriptor)
51
+
52
+ Dir.chdir(dir)
53
+
54
+ puts execute_command
55
+
56
+ Dir.chdir(current_dir)
57
+ end
58
+
59
+ end
60
+
61
+ end
@@ -0,0 +1,140 @@
1
+ module FlexUtils
2
+
3
+ class Asc < AbstractTool
4
+
5
+ attr_writer :output, # output file path
6
+ :source_path, # list
7
+ :library_path, # list
8
+ :external_library_path, # list
9
+ :locale, # list of locales
10
+ :debug, # boolean, default false
11
+ :optimize, # boolean, default true
12
+ :strict, # boolean, default true
13
+ :verbose_stacktraces, # boolean, default true
14
+ :use_network, # boolean, default true
15
+ :incremental, # boolean, default false
16
+ :target_player, # string, default "9.0.0"
17
+ :defines, # hash name => value
18
+ :keep_as3_metadata, # list of metadata names
19
+ :warnings, # hash warning_name => boolean (warning_name example "show-actionscript-warnings")
20
+ :fail_on_error, # boolean, default true
21
+ :fail_on_warning # boolean, default false
22
+
23
+ def initialize( output )
24
+ @output = output
25
+
26
+ @debug = false
27
+ @optimize = true
28
+ @strict = true
29
+ @verbose_stacktraces = true
30
+ @incremental = false
31
+
32
+ @target_player = "9.0.0"
33
+
34
+ @source_path = []
35
+ @library_path = []
36
+ @external_library_path = []
37
+ @locale = []
38
+ @keep_as3_metadata = []
39
+
40
+ @defines = Hash.new
41
+ @warnings = Hash.new
42
+
43
+ @fail_on_error = true
44
+ @fail_on_warning = false
45
+
46
+ self.compiler = "flex"
47
+ end
48
+
49
+ def compiler_base_name
50
+ ""
51
+ end
52
+
53
+ def self.compile( *args )
54
+ c = self.new(*args)
55
+
56
+ yield c
57
+
58
+ c.compile!
59
+ end
60
+
61
+ def compiler=( name )
62
+ if name.to_s == "air"
63
+ @configname = "air"
64
+ @compiler = "a" + compiler_base_name
65
+ else
66
+ @configname = "flex"
67
+ @compiler = compiler_base_name
68
+ end
69
+
70
+ @compiler = command_path @compiler
71
+ end
72
+
73
+ def defines_str
74
+ defines = @defines.keys.map do |item|
75
+ value = if @defines[item] =~ /\s/
76
+ "'#{@defines[item]}'"
77
+ else
78
+ @defines[item]
79
+ end
80
+
81
+ "-define+=#{item},#{value}"
82
+ end
83
+
84
+ defines.join(' ')
85
+ end
86
+
87
+ def compiler_flags
88
+ all_flags = []
89
+
90
+ all_flags << ("+configname=" + @configname)
91
+
92
+ all_flags << "-source-path+=#{@source_path.join(",")}" unless @source_path.empty?
93
+ all_flags << "-library-path+=#{@library_path.join(",")}" unless @library_path.empty?
94
+ all_flags << "-external-library-path+=#{@external_library_path.join(",")}" unless @external_library_path.empty?
95
+ all_flags << "-locale=#{@locale.join(",")}" unless @locale.empty?
96
+ all_flags << "-keep-as3-metadata=#{@keep_as3_metadata.join(",")}" unless @keep_as3_metadata.empty?
97
+
98
+ all_flags << "-debug" if @debug
99
+ all_flags << "-strict" if @strict
100
+ all_flags << "-optimize" if @optimize
101
+ all_flags << "-verbose-stacktraces" if @verbose_stacktraces
102
+ all_flags << "-use-network" if @use_network
103
+ all_flags << "-incremental" if @incremental
104
+
105
+ all_flags << "-target-player #{@target_player}"
106
+
107
+ all_flags << (@warnings.keys.map { |item| "-#{item}=#{@warnings[item]}" }.join(" "))
108
+
109
+ all_flags << defines_str
110
+
111
+ all_flags
112
+ end
113
+
114
+ def command_string
115
+ all_flags = compiler_flags.delete_if { |item| (item.nil? || item =~ /^\s*$/) }.join(" ")
116
+
117
+ "#{@compiler} #{all_flags}"
118
+ end
119
+
120
+ def compile!
121
+ output = execute_command
122
+
123
+ if block_given?
124
+ yield($?, output)
125
+ else
126
+ puts output
127
+ end
128
+
129
+ if @fail_on_error and ($?.exitstatus != 0 or output.include? "Error:")
130
+ fail "Compilation failed because of an error, see output above"
131
+ end
132
+
133
+ if @fail_on_warning and output.include? "Warning:"
134
+ fail "Compilation failed because of a warning, see output above"
135
+ end
136
+ end
137
+
138
+ end
139
+
140
+ end
@@ -0,0 +1,45 @@
1
+ module FlexUtils
2
+
3
+ class Compc < Asc
4
+
5
+ attr_writer :manifest, # hash manifest_file => namespace_uri
6
+ :include_classes, # list
7
+ :include_sources, # list
8
+ :include_files # hash file_name => file_path
9
+
10
+ def initialize( output )
11
+ super(output)
12
+
13
+ @include_classes = []
14
+ @include_sources = []
15
+
16
+ @manifest = Hash.new
17
+ @include_files = Hash.new
18
+ end
19
+
20
+ def compiler_base_name
21
+ "compc"
22
+ end
23
+
24
+ def Compc.to_class_list( files, source_root )
25
+ classes = files.map do |file|
26
+ file.gsub(source_root, "").gsub(/\..+?$/, "").gsub(/\//, ".")
27
+ end
28
+ end
29
+
30
+ def compiler_flags
31
+ all_flags = super()
32
+
33
+ all_flags << "-include-classes #{@include_classes.join(" ")}" unless @include_classes.empty?
34
+ all_flags << "-include-sources #{@include_sources.join(" ")}" unless @include_sources.empty?
35
+
36
+ all_flags << "-output #{@output}"
37
+
38
+ all_flags << "-theme #{@theme}" unless @theme.nil?
39
+
40
+ all_flags
41
+ end
42
+
43
+ end
44
+
45
+ end
@@ -0,0 +1,40 @@
1
+ module FlexUtils
2
+
3
+ class AbstractTool
4
+
5
+ def command_path( command_name )
6
+ if ENV['FLEX_HOME']
7
+ "'" + File.join(ENV['FLEX_HOME'], 'bin', command_name + command_extension) + "'"
8
+ else
9
+ command_name + command_extension
10
+ end
11
+ end
12
+
13
+ def command_extension
14
+ case RUBY_PLATFORM
15
+ when /mswin/: '.exe'
16
+ else ''
17
+ end
18
+ end
19
+
20
+ def command_string
21
+
22
+ end
23
+
24
+ def execute_command( options = { } )
25
+ operative_options = standard_options.merge(options)
26
+
27
+ cmd_str = command_string
28
+
29
+ puts cmd_str if operative_options[:verbose]
30
+
31
+ %x(#{cmd_str} 2>&1)
32
+ end
33
+
34
+ def standard_options
35
+ {:verbose => true}
36
+ end
37
+
38
+ end
39
+
40
+ end
@@ -0,0 +1,43 @@
1
+ module FlexUtils
2
+
3
+ class Mxmlc < Asc
4
+
5
+ attr_writer :theme_files, # list of paths to theme SWC or CSS files
6
+ :allow_source_path_overlap, # boolean
7
+ :keep_generated_actionscript # boolean
8
+
9
+ def initialize( output, main_class )
10
+ super(output)
11
+
12
+ @main_class = main_class
13
+
14
+ @keep_generated_actionscript = false
15
+ @allow_source_path_overlap = false
16
+
17
+ @theme_files = []
18
+ end
19
+
20
+ def compiler_base_name
21
+ "mxmlc"
22
+ end
23
+
24
+ def compiler_flags
25
+ all_flags = super()
26
+
27
+ all_flags << "-allow-source-path-overlap" if @allow_source_path_overlap
28
+ all_flags << "-keep-generated-actionscript" if @keep_generated_actionscript
29
+
30
+ all_flags << "-output #{@output}"
31
+
32
+ all_flags << "-theme #{@theme_files.join(' ')}" unless @theme_files.empty?
33
+
34
+ all_flags << "--"
35
+
36
+ all_flags << @main_class
37
+
38
+ all_flags
39
+ end
40
+
41
+ end
42
+
43
+ end
@@ -0,0 +1,42 @@
1
+ module FlexUtils
2
+
3
+ class TestRunner < Adl
4
+
5
+ attr_writer :fail_on_error,
6
+ :exit_on_complete
7
+
8
+ def initialize( swf )
9
+ super(swf)
10
+
11
+ @fail_on_error = true
12
+ @exit_on_complete = false
13
+ end
14
+
15
+ def run!( extra_args=[], &block )
16
+ log_file = "tests.log"
17
+
18
+ super([log_file, "-exit-on-complete", @exit_on_complete]) do |res|
19
+ if File.exist? log_file
20
+ #File.read("data.txt")?
21
+ output = File.open(log_file) { |f| f.read }
22
+
23
+ puts output
24
+
25
+ rm log_file
26
+ end
27
+
28
+ if @fail_on_error
29
+ if output.nil?
30
+ fail "No output from tests."
31
+ elsif output =~ /tests failed/i
32
+ fail "Tests failed!"
33
+ elsif res.nil? or res.exitstatus != 0
34
+ fail "Test runner failed!"
35
+ end
36
+ end
37
+ end
38
+ end
39
+
40
+ end
41
+
42
+ end
data/spec/adl_spec.rb ADDED
@@ -0,0 +1,13 @@
1
+ describe FlexUtils::Adl do
2
+
3
+ before(:each) do
4
+ @swf = 'build/Main.swf'
5
+
6
+ @tool = FlexUtils::Adl.new @swf
7
+ end
8
+
9
+ it "should run adl" do
10
+ @tool.command_string.should include("adl")
11
+ end
12
+
13
+ end
data/spec/adt_spec.rb ADDED
@@ -0,0 +1,22 @@
1
+ describe FlexUtils::Adt do
2
+
3
+ before(:each) do
4
+ @descriptor = "src/Main-app.xml"
5
+ @keyfile = "src/Main-cert.p12"
6
+ @keypass = "secret"
7
+ @name = "Main"
8
+ @files = []
9
+
10
+ @tool = FlexUtils::Adt.new
11
+ @tool.descriptor = @descriptor
12
+ @tool.keyfile = @keyfile
13
+ @tool.keypass = @keypass
14
+ @tool.name = @name
15
+ @tool.files = @files
16
+ end
17
+
18
+ it "should run adt" do
19
+ @tool.command_string.should include("adt")
20
+ end
21
+
22
+ end
data/spec/asc_spec.rb ADDED
@@ -0,0 +1,153 @@
1
+ shared_examples_for "any Asc-derived tool" do
2
+
3
+ it "should set the config name (default)" do
4
+ @compiler.command_string.should include("+configname=flex")
5
+ end
6
+
7
+ it "should set tge config name (AIR)" do
8
+ @compiler.compiler = :air
9
+
10
+ @compiler.command_string.should include("+configname=air")
11
+ end
12
+
13
+ it "should set -source-path" do
14
+ @compiler.source_path = ['src', 'theme', 'locale/{locale}']
15
+
16
+ @compiler.command_string.should include('-source-path+=src,theme,locale/{locale}')
17
+ end
18
+
19
+ it "should set -library-path" do
20
+ @compiler.library_path = ['lib', 'some/other/path']
21
+
22
+ @compiler.command_string.should include('-library-path+=lib,some/other/path')
23
+ end
24
+
25
+ it "should set -external-library-path" do
26
+ @compiler.external_library_path = ['/path/to/flex']
27
+
28
+ @compiler.command_string.should include('-external-library-path+=/path/to/flex')
29
+ end
30
+
31
+ it "should set -locale" do
32
+ @compiler.locale = ['en_US', 'sv_SE']
33
+
34
+ @compiler.command_string.should include('-locale=en_US,sv_SE')
35
+ end
36
+
37
+ it "should not set -locale (when there's no locales specified)" do
38
+ @compiler.command_string.should_not include('-locale')
39
+ end
40
+
41
+ it "should set -debug" do
42
+ @compiler.debug = true
43
+
44
+ @compiler.command_string.should include('-debug')
45
+ end
46
+
47
+ it "should not set -debug (when it's false)" do
48
+ @compiler.debug = false
49
+
50
+ @compiler.command_string.should_not include('-debug')
51
+ end
52
+
53
+ it "should set -optimize" do
54
+ @compiler.optimize = true
55
+
56
+ @compiler.command_string.should include('-optimize')
57
+ end
58
+
59
+ it "should not set -optimize (when it's false)" do
60
+ @compiler.optimize = false
61
+
62
+ @compiler.command_string.should_not include('-optimize')
63
+ end
64
+
65
+ it "should set -strict" do
66
+ @compiler.strict = true
67
+
68
+ @compiler.command_string.should include('-strict')
69
+ end
70
+
71
+ it "should not set -strict (when it's false)" do
72
+ @compiler.strict = false
73
+
74
+ @compiler.command_string.should_not include('-strict')
75
+ end
76
+
77
+ it "should set -verbose-stacktraces" do
78
+ @compiler.verbose_stacktraces = true
79
+
80
+ @compiler.command_string.should include('-verbose-stacktraces')
81
+ end
82
+
83
+ it "should not set -verbose-stacktraces (when it's false)" do
84
+ @compiler.verbose_stacktraces = false
85
+
86
+ @compiler.command_string.should_not include('-verbose-stacktraces')
87
+ end
88
+
89
+ it "should set -use-network" do
90
+ @compiler.use_network = true
91
+
92
+ @compiler.command_string.should include('-use-network')
93
+ end
94
+
95
+ it "should not set -use-network (when it's false)" do
96
+ @compiler.use_network = false
97
+
98
+ @compiler.command_string.should_not include('-use-network')
99
+ end
100
+
101
+ it "should set -incremental" do
102
+ @compiler.incremental = true
103
+
104
+ @compiler.command_string.should include('-incremental')
105
+ end
106
+
107
+ it "should not set -incremental (when it's false)" do
108
+ @compiler.incremental = false
109
+
110
+ @compiler.command_string.should_not include('-incremental')
111
+ end
112
+
113
+ it "should set -target-player to the right string" do
114
+ @compiler.target_player = 'X.Y.Z'
115
+
116
+ @compiler.command_string.should include('-target-player X.Y.Z')
117
+ end
118
+
119
+ it "should default to 9.0.0 for -target-player" do
120
+ @compiler.target_player = '9.0.0'
121
+
122
+ @compiler.command_string.should include("-target-player 9.0.0")
123
+ end
124
+
125
+ it "should set -keep-as3-metadata" do
126
+ @compiler.keep_as3_metadata = ['one', 'two']
127
+
128
+ @compiler.command_string.should include("-keep-as3-metadata=one,two")
129
+ end
130
+
131
+ it "should not set -keep-as3-metadata (when there's none specified)" do
132
+ @compiler.command_string.should_not include("-keep-as3-metadata")
133
+ end
134
+
135
+ it "should set warning flags" do
136
+ @compiler.warnings = {'show-actionscript-warnings' => true, 'some-other-warning' => false}
137
+
138
+ @compiler.command_string.should include("-show-actionscript-warnings=true")
139
+ @compiler.command_string.should include("-some-other-warning=false")
140
+ end
141
+
142
+ it "should set defines" do
143
+ @compiler.defines = {'MY_NS' => false, 'SOME_OTHER_STRING' => 'some value'}
144
+
145
+ @compiler.command_string.should include('-define+=MY_NS,false')
146
+ @compiler.command_string.should include('-define+=SOME_OTHER_STRING,\'some value\'')
147
+ end
148
+
149
+ it "should not set any defined by default" do
150
+ @compiler.command_string.should_not include("-define=")
151
+ end
152
+
153
+ end
@@ -0,0 +1,15 @@
1
+ describe FlexUtils::Compc do
2
+
3
+ before(:each) do
4
+ @output = 'build/Main.swf'
5
+
6
+ @compiler = FlexUtils::Compc.new(@output)
7
+ # :manifest, # hash manifest_file => namespace_uri
8
+ # :include_classes, # list
9
+ # :include_sources, # list
10
+ # :include_files # hash file_name => file_path
11
+ end
12
+
13
+ it_should_behave_like "any Asc-derived tool"
14
+
15
+ end
@@ -0,0 +1,43 @@
1
+ describe FlexUtils::Mxmlc do
2
+
3
+ before(:each) do
4
+ @input = 'src/Main.mxml'
5
+ @output = 'build/Main.swf'
6
+
7
+ @compiler = FlexUtils::Mxmlc.new(@output, @input)
8
+ @compiler.theme_files = ['theme/common.css', 'theme/some/longer/path/to/a.swc']
9
+ @compiler.allow_source_path_overlap = true
10
+ @compiler.keep_generated_actionscript = true
11
+ end
12
+
13
+ it_should_behave_like "any Asc-derived tool"
14
+
15
+ it "should add the input file" do
16
+ @compiler.command_string.should include(@input)
17
+ end
18
+
19
+ it "should set the output file and prefix it with -output" do
20
+ @compiler.command_string.should include("-output #{@output}")
21
+ end
22
+
23
+ it "should set -allow-source-path-overlap" do
24
+ @compiler.command_string.should include("-allow-source-path-overlap")
25
+ end
26
+
27
+ it "should not set -allow-source-path-overlap (when it is false)" do
28
+ @compiler.allow_source_path_overlap = false;
29
+
30
+ @compiler.command_string.should_not include("-allow-source-path-overlap")
31
+ end
32
+
33
+ it "should set -keep-generated-actionscript" do
34
+ @compiler.command_string.should include("-keep-generated-actionscript")
35
+ end
36
+
37
+ it "should not set -keep-generated-actionscript (when it's false)" do
38
+ @compiler.keep_generated_actionscript = false
39
+
40
+ @compiler.command_string.should_not include("-keep-generated-actionscript")
41
+ end
42
+
43
+ end
@@ -0,0 +1,13 @@
1
+ describe FlexUtils::TestRunner do
2
+
3
+ before(:each) do
4
+ @swf = 'build/Test.swf'
5
+
6
+ @tool = FlexUtils::TestRunner.new @swf
7
+ end
8
+
9
+ it "should run adl" do
10
+ @tool.command_string.should include("adl")
11
+ end
12
+
13
+ end
metadata ADDED
@@ -0,0 +1,96 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: flexutils
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Theo Hultberg
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2009-10-26 00:00:00 +01:00
13
+ default_executable:
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: rspec
17
+ type: :development
18
+ version_requirement:
19
+ version_requirements: !ruby/object:Gem::Requirement
20
+ requirements:
21
+ - - ">="
22
+ - !ruby/object:Gem::Version
23
+ version: "0"
24
+ version:
25
+ description: ""
26
+ email: theo@iconara.net
27
+ executables: []
28
+
29
+ extensions: []
30
+
31
+ extra_rdoc_files:
32
+ - LICENSE
33
+ - README.markdown
34
+ files:
35
+ - .document
36
+ - .gitignore
37
+ - LICENSE
38
+ - README.markdown
39
+ - Rakefile
40
+ - VERSION
41
+ - examples/Rakefile
42
+ - examples/lib/.gitignore
43
+ - examples/locale/en_US/.gitignore
44
+ - examples/src/Main.mxml
45
+ - examples/src/SomeClass.as
46
+ - examples/src/Tests.mxml
47
+ - examples/theme/main.css
48
+ - lib/flexutils.rb
49
+ - lib/flexutils/adl.rb
50
+ - lib/flexutils/adt.rb
51
+ - lib/flexutils/asc.rb
52
+ - lib/flexutils/compc.rb
53
+ - lib/flexutils/flex_utils.rb
54
+ - lib/flexutils/mxmlc.rb
55
+ - lib/flexutils/test_runner.rb
56
+ - spec/adl_spec.rb
57
+ - spec/adt_spec.rb
58
+ - spec/asc_spec.rb
59
+ - spec/compc_spec.rb
60
+ - spec/mxmlc_spec.rb
61
+ - spec/testrunner_spec.rb
62
+ has_rdoc: true
63
+ homepage: http://github.com/iconara/flexutils
64
+ licenses: []
65
+
66
+ post_install_message:
67
+ rdoc_options:
68
+ - --charset=UTF-8
69
+ require_paths:
70
+ - lib
71
+ required_ruby_version: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: "0"
76
+ version:
77
+ required_rubygems_version: !ruby/object:Gem::Requirement
78
+ requirements:
79
+ - - ">="
80
+ - !ruby/object:Gem::Version
81
+ version: "0"
82
+ version:
83
+ requirements: []
84
+
85
+ rubyforge_project:
86
+ rubygems_version: 1.3.3
87
+ signing_key:
88
+ specification_version: 3
89
+ summary: Ruby wrappers for the Flex SDK tools
90
+ test_files:
91
+ - spec/adl_spec.rb
92
+ - spec/adt_spec.rb
93
+ - spec/asc_spec.rb
94
+ - spec/compc_spec.rb
95
+ - spec/mxmlc_spec.rb
96
+ - spec/testrunner_spec.rb