asrake 0.11.0 → 0.12.3

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/README.md CHANGED
@@ -12,7 +12,7 @@ Overview
12
12
  Add the path(s) to your Flex SDK for all systems that will need to run the Rake tasks.
13
13
  ```ruby
14
14
  FlexSDK::SDK_PATHS << 'C:\develop\sdk\flex_sdk_4.6.0.23201'
15
- FlexSDK::SDK_PATHS << "C:/develop/sdk/flex_sdk_4.5.1"
15
+ FlexSDK::SDK_PATHS << "C:/develop/sdk/flex_sdk 4.5.1"
16
16
  FlexSDK::SDK_PATHS << "/opt/lib/adobe/flex_4.6"
17
17
  ```
18
18
 
@@ -31,66 +31,45 @@ How to Tasks
31
31
  ### Build a SWF or SWC
32
32
 
33
33
  ```
34
- ASRake::MxmlcTask(task_name = :build, compiler_args = nil) |self|
34
+ ASRake::Mxmlc(file) |self|
35
35
  ```
36
36
  ```
37
- ASRake::CompcTask(task_name = :build, compiler_args = nil) |self|
37
+ ASRake::Compc(file) |self|
38
38
  ```
39
39
 
40
- You can define the compile arguments elsewhere and pass it to the task, or set them inside the task block, or a combination of both. It is purely preference.
41
-
42
- The following snippets produce identical tasks.
43
-
44
- ```ruby
45
- desc "Build swc"
46
- ASRake::CompcTask.new :build do |build|
47
- # You can store the compiler arguments for later
48
- # For example, maybe we need to know the output_dir later on
49
- #compc = ASRake::CompcTask.new :build do |build|
50
- build.target_player = 11.0
51
- build.output = "bin/bin/my_project.swc"
52
- build.debug = true
53
- build.source_path << "bin/src"
54
- build.statically_link_only_referenced_classes << "lib/lib_used_in_project.swc"
55
- end
56
- ```
40
+ Assign arguments for your build and optionally run it with a friendlier-named task:
57
41
 
58
42
  ```ruby
59
- args = ASRake::CompcArguments.new
43
+ args = ASRake::Compc.new "bin/bin/my_project.swc"
60
44
  args.target_player = 11.0
61
- args.output = "bin/bin/my_project.swc"
62
45
  args.debug = true
63
46
  args.source_path << "bin/src"
64
47
  args.statically_link_only_referenced_classes << "lib/lib_used_in_project.swc"
65
48
 
66
49
  desc "Build swc"
67
- ASRake::CompcTask.new :build, args
50
+ task :build => args
68
51
  ```
69
52
 
70
- ```ruby
71
- args = ASRake::CompcArguments.new
72
- args.target_player = 11.0
73
- args.output = "bin/bin/my_project.swc"
74
- args.debug = false
75
- args.source_path << "bin/src"
53
+ You can also define arguments in a block on creation:
76
54
 
55
+ ```ruby
77
56
  desc "Build swc"
78
- ASRake::CompcTask.new :build, args do |compc|
79
- compc.debug = true
80
- compc.statically_link_only_referenced_classes << "lib/lib_used_in_project.swc"
57
+ ASRake::Compc.new "bin/bin/my_project.swc" do |build|
58
+ build.target_player = 11.0
59
+ build.debug = true
60
+ build.source_path << "bin/src"
61
+ build.statically_link_only_referenced_classes << "lib/lib_used_in_project.swc"
81
62
  end
82
63
  ```
83
64
 
84
65
  ### Include ASDoc in a SWC
85
66
 
86
- If you are compiling with `CompcArgs` or a `CompcTask`, you can set the field `include_asdoc` to have documentation added to your swc
67
+ If you are compiling with `Compc`, you can set the field `include_asdoc` to have documentation added to your swc
87
68
 
88
69
  ```ruby
89
70
  desc "Build swc"
90
- ASRake::CompcTask.new :build do |build|
71
+ ASRake::Compc.new "bin/bin/my_project.swc" do |build|
91
72
  build.target_player = 11.0
92
- build.output = "bin/bin/my_project.swc"
93
- build.debug = true
94
73
  build.source_path << "bin/src"
95
74
  build.statically_link_only_referenced_classes << "lib/lib_used_in_project.swc"
96
75
  build.include_asdoc = true
@@ -103,9 +82,8 @@ Compile your SWF file as normal, but set the `isAIR` property to true
103
82
 
104
83
  ```ruby
105
84
  desc "Build app"
106
- ASRake::MxmlcTask.new :build do |build|
85
+ ASRake::Mxmlc.new "bin/my_app.swf" do |build|
107
86
  build.load_config << "mxmlc_config.xml"
108
- build.output = "bin/my_app.swf"
109
87
  build.isAIR = true
110
88
  end
111
89
  ```
@@ -183,23 +161,20 @@ cp_u FileList["lib/**/*.swc"], "bin/lib"
183
161
 
184
162
  ### Build without a task
185
163
 
186
- You don't need to create a rake task to build a swf or swc. Just call `build()` on an instance of CompcArguments or MxmlcArguments.
164
+ You don't need to create a rake task to build a swf or swc. Just call `execute()` on an instance of Compc or Mxmlc.
187
165
 
188
166
  > Note that this will not do any dependency checks, so the build will run even if it is unnecessary
189
167
 
190
168
  ```ruby
191
- args = ASRake::CompcArguments.new
169
+ args = ASRake::Compc.new "bin/bin/my_project.swc"
192
170
  args.target_player = 11.0
193
- args.output = "bin/bin/my_project.swc"
194
171
  args.source_path << "bin/src"
195
172
  args.statically_link_only_referenced_classes << "lib/lib_used_in_project.swc"
196
- args.build()
173
+ args.execute()
197
174
 
198
- ASRake::MxmlcArguments.new do |mxmlc|
175
+ (ASRake::Mxmlc.new "bin/bin/my_project.swf" do |mxmlc|
199
176
  mxmlc.target_player = 11.0
200
- mxmlc.output = "bin/bin/my_project.swf"
201
177
  mxmlc.debug = true
202
178
  mxmlc.source_path << "bin/src"
203
- mxmlc.build()
204
- end
179
+ end).execute()
205
180
  ```
@@ -1,9 +1,13 @@
1
+ require 'asrake/util'
1
2
  require 'rake/tasklib'
2
3
  require 'nokogiri'
3
4
 
4
5
  module ASRake
5
6
  class AdtTask < Rake::TaskLib
6
7
 
8
+ include ASRake::PathUtils
9
+ include Rake::DSL
10
+
7
11
  attr_accessor :output
8
12
  # http://help.adobe.com/en_US/air/build/WS5b3ccc516d4fbf351e63e3d118666ade46-7ff1.html
9
13
  attr_accessor :application_descriptor
data/lib/asrake/asdoc.rb CHANGED
@@ -1,11 +1,14 @@
1
+ require 'asrake/util'
1
2
  require 'rake/tasklib'
2
3
  require 'nokogiri'
3
4
 
4
5
  # http://help.adobe.com/en_US/flex/using/WSd0ded3821e0d52fe1e63e3d11c2f44bc36-7ffa.html
5
6
 
6
- module ASRake
7
- class Asdoc
7
+ class ASRake::Asdoc
8
8
 
9
+ include ASRake::PathUtils
10
+ include Rake::DSL
11
+
9
12
  attr_accessor :additional_args
10
13
 
11
14
  # we have some special handling of this
@@ -112,7 +115,10 @@ class Asdoc
112
115
  attr_accessor name
113
116
  end
114
117
 
115
- def initialize
118
+ def initialize(output=nil)
119
+
120
+ raise "Output directory must be provided to ASDoc.new" if output == nil
121
+
116
122
  # set all defaults
117
123
  @@compiler_args.each do |name, type|
118
124
  instance_variable_set("@#{name}", []) if type == :array || type == :dirs
@@ -120,6 +126,8 @@ class Asdoc
120
126
 
121
127
  @doc_sources = []
122
128
 
129
+ @output = output
130
+
123
131
  yield self if block_given?
124
132
  end
125
133
 
@@ -128,7 +136,7 @@ class Asdoc
128
136
  self.library_path << args.library_path
129
137
  self.library_path << args.include_libraries
130
138
  self.library_path << args.external_library_path
131
- args.source_path.each { |p| self.doc_classes << ASRake::get_classes(p) } if args.kind_of? ASRake::CompcArguments_Module
139
+ args.source_path.each { |p| self.doc_classes << ASRake::get_classes(p) } if args.kind_of? ASRake::Compc
132
140
  end
133
141
 
134
142
  def execute(&block)
@@ -172,5 +180,4 @@ class Asdoc
172
180
  run(command, true, &block)
173
181
  end
174
182
 
175
- end
176
183
  end
@@ -1,17 +1,18 @@
1
+ require 'asrake/base_task'
1
2
  require 'asrake/flexsdk'
2
3
  require 'nokogiri'
3
4
 
4
5
  module ASRake
6
+ class BaseCompiler < BaseTask
5
7
 
6
- module BaseCompilerArguments_Module
7
-
8
+ include ASRake::PathUtils
9
+ include Rake::DSL
10
+
8
11
  #
9
12
  # compiler arguments
10
13
  #
11
14
 
12
15
  @@args = [
13
- :output,
14
-
15
16
  :source_path,
16
17
  :library_path,
17
18
  :external_library_path,
@@ -23,20 +24,15 @@ module BaseCompilerArguments_Module
23
24
 
24
25
  :debug,
25
26
 
26
- :dump_config
27
+ :dump_config,
28
+
29
+ :additional_args
27
30
  ]
28
31
  attr_accessor *@@args
29
32
 
30
- attr_accessor :additional_args
31
-
32
- #
33
- # non-compiler arguments
34
- #
35
-
36
- attr_reader :output_file
37
- attr_reader :output_dir
33
+ def initialize(file, exe_path)
34
+ @exe = exe_path
38
35
 
39
- def initialize(args=nil)
40
36
  @isAIR = false
41
37
  @library_path = []
42
38
  @external_library_path = []
@@ -46,35 +42,12 @@ module BaseCompilerArguments_Module
46
42
  #include default flex-config
47
43
  @load_config = [ FlexSDK::flex_config ]
48
44
 
49
- self.merge_in args if args != nil
50
-
51
- yield self if block_given?
52
- end
53
-
54
- # compiler needs to be defined in subclass
55
- def compiler
56
- fail "'compiler' must be defined in subclass"
57
- end
58
-
59
- def output
60
- @output
61
- end
45
+ super(file)
62
46
 
63
- def output= value
64
- @output = value
65
- # if the output path ends in a path separator, it is a directory
66
- if @output =~ /[\/\\]$/
67
- @output_dir = @output
68
- else
69
- # forward-slashes required for File methods
70
- @output = cf @output
71
- @output_dir = File.dirname(@output)
72
- @output_file = File.basename(@output)
73
- end
74
- end
47
+ # allow setting source_path with '=' instead of '<<'
48
+ # actually, no, this is really bad and confusing we should probably throw when they try to assign
49
+ #self.source_path = [self.source_path] if self.source_path.is_a? String
75
50
 
76
- def output_is_dir?
77
- output_file == nil
78
51
  end
79
52
 
80
53
  # provide a more understandable alias
@@ -107,49 +80,34 @@ module BaseCompilerArguments_Module
107
80
  alias_method :isAir, :isAIR
108
81
  alias_method :isAir=, :isAIR=
109
82
 
110
- def merge_in(args)
111
- @@args.each do |arg|
112
- # TODO: This needs to concat arrays not overwite them
113
- self.send("#{arg}=", args.send(arg))
114
- end
115
- end
116
-
117
- def to_s
118
- @output
119
- end
120
-
121
83
  #
122
84
  # Verify properties and then return build arguments
123
85
  #
124
86
  def generate_args
125
87
 
126
- #
127
- # allow all the array arguments to be set as single strings
128
- #
129
-
130
- # TODO: have this be part of the attribute accessor
131
- self.source_path = [self.source_path] if self.source_path.is_a? String
132
- self.load_config = [self.load_config] if self.load_config.is_a? String
133
- self.library_path = [self.library_path] if self.library_path.is_a? String
134
- self.external_library_path = [self.external_library_path] if self.external_library_path.is_a? String
135
- self.include_libraries = [self.include_libraries] if self.include_libraries.is_a? String
88
+ # TODO: have this be checked when assigned and throw on string so the user understands the proper syntax
89
+ #self.source_path = [self.source_path] if self.source_path.is_a? String
90
+ #self.load_config = [self.load_config] if self.load_config.is_a? String
91
+ #self.library_path = [self.library_path] if self.library_path.is_a? String
92
+ #self.external_library_path = [self.external_library_path] if self.external_library_path.is_a? String
93
+ #self.include_libraries = [self.include_libraries] if self.include_libraries.is_a? String
136
94
 
137
95
  # set to true if the version is defined in one of the referenced configs
138
- isTargetDefined = false
96
+ is_target_defined = false
139
97
  if self.target_player == nil
140
98
  # try to find necessary args in any loaded config files
141
- unless self.load_config.length == 1 && isDefaultConfig?(self.load_config[0])
99
+ unless self.load_config.length == 1 && is_default_config?(self.load_config[0])
142
100
  # load config in reverse so last added has priority
143
101
  self.load_config.reverse.each do |config|
144
102
  flex_config = Nokogiri::XML(File.read(config))
145
103
 
146
- isTargetDefined = true if flex_config.at_css('target-player')
104
+ is_target_defined = true if flex_config.at_css('target-player')
147
105
  #configSource? = true if
148
106
  end
149
107
  end
150
108
  end
151
109
 
152
- fail "You must define 'target_player' for #{self}" if self.target_player == nil && !isTargetDefined
110
+ fail "You must define 'target_player' for #{self}" if self.target_player == nil && !is_target_defined
153
111
 
154
112
  # TODO: iterate over all non-default config files provided and look for source-path entries
155
113
  #fail "You must add at least one path to 'source_path' for #{self}" if source_path.empty? && !configSource?
@@ -175,11 +133,11 @@ module BaseCompilerArguments_Module
175
133
  args << " -source-path=#{cf source_path.join(',')}" if !self.source_path.empty?
176
134
 
177
135
  # add the -load-config option if it is anything other than the default
178
- unless self.load_config.length == 1 && isDefaultConfig?(self.load_config[0])
136
+ unless self.load_config.length == 1 && is_default_config?(self.load_config[0])
179
137
  # if the default flex config is still in the load_config array, then append all config files, otherwise have the first one replace
180
- op = hasDefaultConfigFile? ? "+=" : "="
138
+ op = has_default_config_file? ? "+=" : "="
181
139
  self.load_config.each do |config|
182
- args << " -load-config#{op}#{cf config}" unless isDefaultConfig?(config)
140
+ args << " -load-config#{op}#{cf config}" unless is_default_config?(config)
183
141
  op = "+="
184
142
  end
185
143
  end
@@ -196,30 +154,24 @@ module BaseCompilerArguments_Module
196
154
  return args
197
155
  end
198
156
 
199
- def build(tips=true)
200
- fail "Compiler not defined in #{self}" if compiler == nil
201
- puts
202
- if tips
203
- puts "> #{compiler}#{generate_args}"
204
- run "#{compiler}#{generate_args}" do |line|
205
- puts "> #{line}"
206
- generate_error_message_tips(line)
207
- end
208
- else
209
- run "#{compiler}#{generate_args}"
157
+ def execute
158
+ puts "> #{@exe}#{generate_args}"
159
+ run "#{@exe}#{generate_args}" do |line|
160
+ puts "> #{line}"
161
+ generate_error_message_tips(line)
210
162
  end
211
163
  end
212
164
 
213
165
  private
214
166
 
215
- def hasDefaultConfigFile?
167
+ def has_default_config_file?
216
168
  self.load_config.each do |path|
217
- return true if isDefaultConfig? path
169
+ return true if is_default_config? path
218
170
  end
219
171
  return false
220
172
  end
221
173
 
222
- def isDefaultConfig?(path)
174
+ def is_default_config?(path)
223
175
  return (path == FlexSDK::flex_config || path == FlexSDK::air_config)
224
176
  end
225
177
 
@@ -231,7 +183,7 @@ module BaseCompilerArguments_Module
231
183
  advice << "to have access to the native JSON parser. It is currently set to #{target_player}"
232
184
  elsif line.include?("Error: The definition of base class Object was not found")
233
185
  advice << "If you have removed the default flex-config by setting 'load_config' to"
234
- advice << "an empty or alternate value (i.e., not appended to it) you must be sure to"
186
+ advice << "an empty or alternate value using = instead of << you must be sure to"
235
187
  advice << "still reference the necessary core Flash files, especially playerglobal.swc"
236
188
  end
237
189
 
@@ -258,10 +210,6 @@ end
258
210
  # }
259
211
  #end
260
212
 
261
- #http://fpdownload.macromedia.com/get/flashplayer/updaters/11/playerglobal11_2.swc
262
- #https://github.com/nexussays/playerglobal/raw/master/player/11.2/playerglobal.swc
263
- #frameworks\libs\player
264
-
265
213
  #-dump-config compiler_config.xml
266
214
  #-link-report compiler_linkreport.xml
267
215
  #-size-report compiler_sizereport.xml
@@ -0,0 +1,70 @@
1
+ require 'asrake/util'
2
+
3
+ module ASRake
4
+ class BaseTask
5
+
6
+ include ASRake::PathUtils
7
+ include Rake::DSL
8
+
9
+ #
10
+ # non-compiler arguments
11
+ #
12
+
13
+ attr_reader :output
14
+ attr_reader :output_file
15
+ attr_reader :output_dir
16
+
17
+ def initialize(file=nil)
18
+
19
+ raise "Output file/directory must be provided" if file == nil
20
+
21
+ @output = file.to_s
22
+ # if the output path ends in a path separator, it is a directory
23
+ if @output =~ /[\/\\]$/
24
+ @output_dir = @output
25
+ else
26
+ # forward-slashes required for File methods
27
+ @output = cf @output
28
+ @output_dir = File.dirname(@output)
29
+ @output_file = File.basename(@output)
30
+ end
31
+
32
+ yield self if block_given?
33
+
34
+ # create file task for output
35
+ file self.output do
36
+ self.execute
37
+ # TODO: Want to output this even if the dependencies are met and the task isn't run
38
+ result = c self.output
39
+ result << " (#{File.size(output)} bytes)" unless self.output_is_dir?
40
+ puts result
41
+ end
42
+
43
+ # create directory task for output
44
+ if !output_is_dir?
45
+ directory self.output_dir
46
+ file self.output => self.output_dir
47
+ end
48
+ end
49
+
50
+ def output_is_dir?
51
+ output_file == nil
52
+ end
53
+
54
+ def merge_in(args)
55
+ @@args.each do |arg|
56
+ # TODO: This needs to concat arrays not overwite them
57
+ self.send("#{arg}=", args.send(arg))
58
+ end
59
+ end
60
+
61
+ def to_s
62
+ @output
63
+ end
64
+
65
+ def execute
66
+ raise "Must define execute in subclass"
67
+ end
68
+
69
+ end
70
+ end
@@ -0,0 +1,77 @@
1
+ require 'asrake/util'
2
+ require 'asrake/base_compiler'
3
+ require 'asrake/asdoc'
4
+
5
+ module ASRake
6
+ class Compc < BaseCompiler
7
+
8
+ include ASRake::PathUtils
9
+ include Rake::DSL
10
+
11
+ attr_accessor :include_asdoc
12
+
13
+ #
14
+ # Create a compc task for the provided swc
15
+ #
16
+ def initialize(swc_file)
17
+ super(swc_file, FlexSDK::compc)
18
+
19
+ # set dependencies on all .as and .mxml files in the source paths
20
+ dependencies = FileList.new
21
+ self.source_path.each do |path|
22
+ dependencies.include(File.join(cf path, "**/*.as"))
23
+ dependencies.include(File.join(cf path, "**/*.mxml"))
24
+ end
25
+ file(self.output => dependencies) if !dependencies.empty?
26
+
27
+ # update build task to include asdoc
28
+ file self.output do
29
+ if self.include_asdoc
30
+ asdoc = ASRake::Asdoc.new File.join(self.output_dir, ".asrake_temp")
31
+ asdoc.add(self)
32
+ asdoc.keep_xml = true
33
+ asdoc.skip_xsl = true
34
+ asdoc.lenient = true
35
+ # capture output in a block to prevent it from going to console
36
+ asdoc.execute { |line| }
37
+
38
+ if output_is_dir?
39
+ cp_r "#{asdoc.output}/tempdita", File.join(self.output_dir, "docs")
40
+ else
41
+ Zip::ZipFile.open(self.output) do |zipfile|
42
+ # remove existing docs (eg, from -include-libraries linking a swc with pre-existing docs)
43
+ begin
44
+ zipfile.remove("docs")
45
+ rescue
46
+ #no rescue
47
+ end
48
+ FileList["#{asdoc.output}/tempdita/*"].each do |file|
49
+ zipfile.add("docs/#{File.basename(file)}", file)
50
+ end
51
+ end
52
+ end
53
+
54
+ rm_rf asdoc.output, :verbose => false
55
+ end
56
+ end
57
+
58
+ end
59
+
60
+ def generate_args
61
+ compc = super
62
+
63
+ #compc << " -include-sources=#{cf source_path.join(',')}" if !source_path.empty?
64
+ self.source_path.each do |path|
65
+ compc << " -include-classes #{ASRake::get_classes(path).join(' ')}"
66
+ end
67
+
68
+ return compc
69
+ end
70
+
71
+ def merge_in(args)
72
+ super
73
+ self.include_asdoc = args.include_asdoc
74
+ end
75
+
76
+ end
77
+ end
@@ -1,4 +1,4 @@
1
- require 'asrake/host'
1
+ require 'asrake/util'
2
2
 
3
3
  class FlexSDK
4
4
 
@@ -6,6 +6,8 @@ SDK_PATHS = []
6
6
 
7
7
  class << self
8
8
 
9
+ include ASRake::PathUtils
10
+
9
11
  @@initialized = false
10
12
 
11
13
  # dynamically create getters for the executables and config files
@@ -44,12 +46,14 @@ class << self
44
46
  @@configs.each do |name|
45
47
  config = c File.join(path, 'frameworks', "#{name}.xml")
46
48
  missing[SDK_PATHS] << config if !File.exists?(config)
49
+ config = "\"#{config}\"" if config =~ /\s/
47
50
  instance_variable_set "@#{name.gsub('-','_')}", config
48
51
  end
49
52
 
50
53
  @@executables.each do |name|
51
54
  exec = c File.join(path, 'bin', name)
52
55
  missing[SDK_PATHS] << exec if !File.exists?(exec)
56
+ exec = "\"#{exec}\"" if exec =~ /\s/
53
57
  instance_variable_set "@#{name}", exec
54
58
  end
55
59
 
@@ -69,7 +73,7 @@ class << self
69
73
  str << "\n"
70
74
  end
71
75
  str << "Append a valid SDK path in your rakefile, e.g.:\nFlexSDK::SDK_PATHS << 'C:\\develop\\sdk\\flex_sdk_4.6.0.23201'"
72
- str << "\nFor more information, see: http://adobe.com/go/flex_sdk/"
76
+ #str << "\nFor more information, see: http://adobe.com/go/flex_sdk/"
73
77
  fail str
74
78
  end
75
79
  end
@@ -0,0 +1,16 @@
1
+ require 'asrake/util'
2
+ require 'asrake/base_compiler'
3
+ require 'asrake/asdoc'
4
+
5
+ module ASRake
6
+ class Mxmlc < BaseCompiler
7
+
8
+ include ASRake::PathUtils
9
+ include Rake::DSL
10
+
11
+ def initialize(swf_file)
12
+ super(swf_file, FlexSDK::mxmlc)
13
+ end
14
+
15
+ end
16
+ end
@@ -0,0 +1,40 @@
1
+ require 'asrake/util'
2
+ require 'asrake/base_task'
3
+ require 'zip/zip'
4
+
5
+ module ASRake
6
+ class Package < BaseTask
7
+
8
+ include ASRake::PathUtils
9
+ include Rake::DSL
10
+
11
+ attr_accessor :files
12
+
13
+ def initialize(file=nil)
14
+ super(file)
15
+ end
16
+
17
+ def files
18
+ @files
19
+ end
20
+ def files= value
21
+ @files = value
22
+ files.each do |to, from|
23
+ file output => [cf(from)]
24
+ end
25
+ end
26
+
27
+ def to_s
28
+ @output
29
+ end
30
+
31
+ def execute
32
+ rm_r output rescue nil
33
+ Zip::ZipFile.open(output, Zip::ZipFile::CREATE) do |zipfile|
34
+ files.each do |to, from|
35
+ zipfile.add(cf(to), cf(from))
36
+ end
37
+ end
38
+ end
39
+ end
40
+ end
@@ -0,0 +1,68 @@
1
+ module ASRake
2
+ class << self
3
+
4
+ def get_classes(path)
5
+ arr = []
6
+ Dir.chdir(path) do
7
+ FileList["**/*.as"].pathmap('%X').each do |file|
8
+ name = file.gsub(/^\.[\/\\]/, "").gsub(/[\/\\]/, ".")
9
+ yield name if block_given?
10
+ arr << name
11
+ end
12
+ end
13
+ return arr
14
+ end
15
+
16
+ end
17
+ end
18
+
19
+ module ASRake::OS
20
+ class << self
21
+ def is_mac?
22
+ RUBY_PLATFORM.downcase.include?("darwin")
23
+ end
24
+
25
+ def is_windows?
26
+ require 'rbconfig'
27
+ RbConfig::CONFIG['host_os'] =~ /mswin|mingw/
28
+ end
29
+
30
+ def is_linux?
31
+ RUBY_PLATFORM.downcase.include?("linux")
32
+ end
33
+ end
34
+ end
35
+
36
+ module ASRake::PathUtils
37
+ def c(str)
38
+ ASRake::OS::is_windows? ? cb(str) : cf(str)
39
+ end
40
+
41
+ def cb(str)
42
+ str.gsub("/", "\\")
43
+ end
44
+
45
+ def cf(str)
46
+ str.gsub("\\", "/")
47
+ end
48
+ end
49
+
50
+ def run(command, abort_on_failure = true)
51
+ command.strip!
52
+
53
+ puts "> #{command}" if !block_given?
54
+ IO.popen("#{command} 2>&1") do |proc|
55
+ while !proc.closed? && (line = proc.gets)
56
+ puts "> #{line}" if !block_given?
57
+ yield line if block_given?
58
+ end
59
+ end
60
+
61
+ if $?.exitstatus != 0
62
+ msg = "Operation exited with status #{$?.exitstatus}"
63
+ fail msg if abort_on_failure
64
+ puts msg
65
+ end
66
+
67
+ return $?
68
+ end
data/lib/asrake.rb CHANGED
@@ -20,26 +20,5 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20
20
  THE SOFTWARE.
21
21
  =end
22
22
 
23
- # require all the task files so users can create them just by requiring asrake
24
- Dir.glob(File.join(File.expand_path(File.dirname(__FILE__)), "asrake/*_task.rb")).each {|f| require f }
25
- Dir.glob(File.join(File.expand_path(File.dirname(__FILE__)), "asrake/*_args.rb")).each {|f| require f }
26
-
27
- require 'asrake/file_utils'
28
-
29
- module ASRake
30
- class << self
31
-
32
- def get_classes(path)
33
- arr = []
34
- Dir.chdir(path) do
35
- FileList["**/*.as"].pathmap('%X').each do |file|
36
- name = file.gsub(/^\.[\/\\]/, "").gsub(/[\/\\]/, ".")
37
- yield name if block_given?
38
- arr << name
39
- end
40
- end
41
- return arr
42
- end
43
-
44
- end
45
- end
23
+ # require all files
24
+ Dir.glob(File.join(File.expand_path(File.dirname(__FILE__)), "asrake/*.rb")).each {|f| require f }
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: asrake
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.11.0
4
+ version: 0.12.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-09-19 00:00:00.000000000 Z
12
+ date: 2012-10-11 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: nokogiri
@@ -71,16 +71,14 @@ extra_rdoc_files: []
71
71
  files:
72
72
  - lib/asrake/adt_task.rb
73
73
  - lib/asrake/asdoc.rb
74
- - lib/asrake/base_compiler_args.rb
75
- - lib/asrake/base_compiler_task.rb
76
- - lib/asrake/compc_args.rb
77
- - lib/asrake/compc_task.rb
74
+ - lib/asrake/base_compiler.rb
75
+ - lib/asrake/base_task.rb
76
+ - lib/asrake/compc.rb
78
77
  - lib/asrake/file_utils.rb
79
78
  - lib/asrake/flexsdk.rb
80
- - lib/asrake/host.rb
81
- - lib/asrake/mxmlc_args.rb
82
- - lib/asrake/mxmlc_task.rb
83
- - lib/asrake/package_task.rb
79
+ - lib/asrake/mxmlc.rb
80
+ - lib/asrake/package.rb
81
+ - lib/asrake/util.rb
84
82
  - lib/asrake/version/component.rb
85
83
  - lib/asrake/version/version.rb
86
84
  - lib/asrake/version_task.rb
@@ -111,5 +109,5 @@ rubyforge_project:
111
109
  rubygems_version: 1.8.24
112
110
  signing_key:
113
111
  specification_version: 3
114
- summary: A Rake library for Actionscript 3, Flex, and AIR projects
112
+ summary: A cross-platform Rake library for Actionscript 3, Flex, and AIR projects
115
113
  test_files: []
@@ -1,22 +0,0 @@
1
- require 'rake/tasklib'
2
- require 'asrake/base_compiler_args'
3
-
4
- module ASRake
5
- class BaseCompilerTask < Rake::TaskLib
6
- include BaseCompilerArguments_Module
7
-
8
- def initialize(name, args)
9
- super(args)
10
-
11
- @name = name
12
-
13
- # create named task first so it gets the desc if one is added
14
- Rake::Task.define_task @name
15
-
16
- # if the task name is a hash (ie, has dependencies defined) make sure we pull out the task name from it
17
- @name, _ = name.first if name.is_a? Hash
18
-
19
- end
20
-
21
- end
22
- end
@@ -1,37 +0,0 @@
1
- require 'asrake/flexsdk'
2
- require 'asrake/base_compiler_args'
3
-
4
- module ASRake
5
-
6
- module CompcArguments_Module
7
- include BaseCompilerArguments_Module
8
-
9
- attr_accessor :include_asdoc
10
-
11
- def compiler
12
- FlexSDK::compc
13
- end
14
-
15
- def generate_args
16
- compc = super
17
-
18
- #compc << " -include-sources=#{cf source_path.join(',')}" if !source_path.empty?
19
- self.source_path.each do |path|
20
- compc << " -include-classes #{ASRake::get_classes(path).join(' ')}"
21
- end
22
-
23
- return compc
24
- end
25
-
26
- def merge_in(args)
27
- super
28
- self.include_asdoc = args.include_asdoc
29
- end
30
-
31
- end
32
-
33
- class CompcArguments
34
- include CompcArguments_Module
35
- end
36
-
37
- end
@@ -1,80 +0,0 @@
1
- require 'rake/tasklib'
2
-
3
- require 'asrake/host'
4
- require 'asrake/base_compiler_task'
5
- require 'asrake/compc_args'
6
- require 'asrake/asdoc'
7
-
8
- module ASRake
9
- class CompcTask < BaseCompilerTask
10
- include CompcArguments_Module
11
-
12
- # Create a swc compilation task with the given name.
13
- def initialize(name = :build, args = nil)
14
- super
15
-
16
- # create directory task for output
17
- if !output_is_dir?
18
- directory self.output_dir
19
- file self.output => self.output_dir
20
- end
21
-
22
- # create file task for output
23
- file self.output do
24
- self.build
25
- end
26
-
27
- # allow setting source_path with '=' instead of '<<'
28
- self.source_path = [self.source_path] if self.source_path.is_a? String
29
-
30
- # set dependencies on all .as and .mxml files in the source paths
31
- dependencies = FileList.new
32
- self.source_path.each do |path|
33
- path = cf path
34
- dependencies.include(File.join(path, "*.as"))
35
- dependencies.include(File.join(path, "*.mxml"))
36
- dependencies.include(File.join(path, "**", "*.as"))
37
- dependencies.include(File.join(path, "**", "*.mxml"))
38
- end
39
- file(self.output => dependencies) if !dependencies.empty?
40
-
41
- # add output file task as a dependency to the named task created
42
- task @name => self.output do
43
- result = c self.output
44
- result << " (#{File.size(output)} bytes)" unless self.output_is_dir?
45
- puts result
46
- end
47
-
48
- if @include_asdoc
49
- file self.output do
50
- asdoc = ASRake::Asdoc.new
51
- asdoc.output = "#{self.output_dir}/.asrake_temp/"
52
- asdoc.add(self)
53
- asdoc.keep_xml = true
54
- asdoc.skip_xsl = true
55
- asdoc.lenient = true
56
- asdoc.execute { |line| }
57
-
58
- if output_is_dir?
59
- cp_r File.join(asdoc.output, 'tempdita'), File.join(self.output_dir, 'docs')
60
- else
61
- Zip::ZipFile.open(self.output) do |zipfile|
62
- # remove any existing docs (eg, from -include-libraries linking a swc with asdoc)
63
- begin
64
- zipfile.remove('docs')
65
- rescue
66
- end
67
- FileList[File.join(asdoc.output, 'tempdita', '*')].each do |file|
68
- zipfile.add(File.join('docs', File.basename(file)), file)
69
- end
70
- end
71
- end
72
-
73
- rm_rf asdoc.output, :verbose => false
74
- end
75
- end
76
-
77
- end
78
-
79
- end
80
- end
data/lib/asrake/host.rb DELETED
@@ -1,46 +0,0 @@
1
- module OS
2
- def OS.is_mac?
3
- RUBY_PLATFORM.downcase.include?("darwin")
4
- end
5
-
6
- def OS.is_windows?
7
- require 'rbconfig'
8
- RbConfig::CONFIG['host_os'] =~ /mswin|mingw/
9
- end
10
-
11
- def OS.is_linux?
12
- RUBY_PLATFORM.downcase.include?("linux")
13
- end
14
- end
15
-
16
- def run(command, abort_on_failure = true)
17
- command.strip!
18
-
19
- puts "> #{command}" if !block_given?
20
- IO.popen("#{command} 2>&1") do |proc|
21
- while !proc.closed? && (line = proc.gets)
22
- puts "> #{line}" if !block_given?
23
- yield line if block_given?
24
- end
25
- end
26
-
27
- if $?.exitstatus != 0
28
- msg = "Operation exited with status #{$?.exitstatus}"
29
- fail msg if abort_on_failure
30
- puts msg
31
- end
32
-
33
- return $?
34
- end
35
-
36
- def c(str)
37
- OS::is_windows? ? cb(str) : cf(str)
38
- end
39
-
40
- def cb(str)
41
- str.gsub("/", "\\")
42
- end
43
-
44
- def cf(str)
45
- str.gsub("\\", "/")
46
- end
@@ -1,18 +0,0 @@
1
- require 'asrake/flexsdk'
2
- require 'asrake/base_compiler_args'
3
-
4
- module ASRake
5
-
6
- module MxmlcArguments_Module
7
- include BaseCompilerArguments_Module
8
-
9
- def compiler
10
- FlexSDK::mxmlc
11
- end
12
- end
13
-
14
- class MxmlcArguments
15
- include MxmlcArguments_Module
16
- end
17
-
18
- end
@@ -1,29 +0,0 @@
1
- require 'rake/tasklib'
2
-
3
- require 'asrake/host'
4
- require 'asrake/base_compiler_task'
5
- require 'asrake/mxmlc_args'
6
-
7
- module ASRake
8
- class MxmlcTask < BaseCompilerTask
9
- include MxmlcArguments_Module
10
-
11
- # Create a swc compilation task with the given name.
12
- def initialize(name = :build, args = nil)
13
- super
14
-
15
- # create directory task for output
16
- directory self.output_dir
17
-
18
- # always build until we can properly grab dependencies
19
- task @name => self.output_dir do
20
- self.build
21
- result = c self.output
22
- result << " (#{File.size(output)} bytes)" unless self.output_is_dir?
23
- puts result
24
- end
25
-
26
- end
27
-
28
- end
29
- end
@@ -1,55 +0,0 @@
1
- require 'rake/tasklib'
2
- require 'zip/zip'
3
-
4
- module ASRake
5
- class PackageTask < Rake::TaskLib
6
-
7
- attr_accessor :output
8
- attr_accessor :files
9
-
10
- attr_reader :output_file
11
- attr_reader :output_dir
12
-
13
- def initialize(name = :package)
14
-
15
- yield self if block_given?
16
-
17
- fail "You must define 'output' for #{self}" if output == nil
18
- fail "You must define 'files' to include for #{self}" if files == nil
19
-
20
- #define named task first so if desc was called it will be attached to it instead of the file task
21
- Rake::Task.define_task name do
22
- puts "#{c output} (#{File.size(output)} bytes)"
23
- end
24
-
25
- #if the task name is a hash (ie, has dependencies defined) make sure we pull out the task name from it
26
- name, _ = name.first if name.is_a? Hash
27
-
28
- @output_dir = File.dirname(output)
29
- @output_file = File.basename(output)
30
-
31
- directory output_dir
32
-
33
- # setup file dependencies
34
- file output => output_dir
35
- files.each do |to, from|
36
- file output => [cf(from)]
37
- end
38
-
39
- #add output file task as a dependency to the named task created
40
- task name => output
41
-
42
- #create the zip task
43
- file output do
44
- rm_r output rescue nil
45
- Zip::ZipFile.open(output, Zip::ZipFile::CREATE) do |zipfile|
46
- files.each do |to, from|
47
- zipfile.add(cf(to), cf(from))
48
- end
49
- end
50
- end
51
-
52
- end
53
-
54
- end
55
- end