asrake 0.9.0 → 0.10.0

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -25,8 +25,8 @@ Arguments match those passed to the compiler (mxmlc, compc, adt, etc) with hyphe
25
25
  Convenience methods are provided for `include_libraries`, `external_library_path`, and `library_path`; you can instead use `statically_link`, `dynamically_link`, and `statically_link_only_referenced_classes` respectively.
26
26
 
27
27
 
28
- How to Use
29
- ----------
28
+ How to Tasks
29
+ ------------
30
30
 
31
31
  ### Build a SWF or SWC
32
32
 
@@ -47,11 +47,11 @@ ASRake::CompcTask.new :build do |build|
47
47
  # You can store the compiler arguments for later
48
48
  # For example, maybe we need to know the output_dir later on
49
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"
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
55
  end
56
56
  ```
57
57
 
@@ -76,8 +76,8 @@ args.source_path << "bin/src"
76
76
 
77
77
  desc "Build swc"
78
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"
79
+ compc.debug = true
80
+ compc.statically_link_only_referenced_classes << "lib/lib_used_in_project.swc"
81
81
  end
82
82
  ```
83
83
 
@@ -136,9 +136,9 @@ There is a task `version:sync` that is run every time the version changes. This
136
136
  ```ruby
137
137
  # replace :version with whatever you provided to ASRake::VersionTask.new
138
138
  namespace :version do
139
- task :sync do
140
- #update application.xml
141
- end
139
+ task :sync do
140
+ #update application.xml
141
+ end
142
142
  end
143
143
  ```
144
144
 
@@ -160,6 +160,9 @@ end
160
160
  ASRake::CleanTask.new swf
161
161
  ```
162
162
 
163
+ Additional Functionality
164
+ ------------------------
165
+
163
166
  ### New copy method
164
167
 
165
168
  ASRake introduces a new copy method `cp_u` on FileUtils and in the global namespace.
@@ -178,4 +181,27 @@ cp_u %w{application.xml my_app.swf config.json}, "/dest"
178
181
 
179
182
  # use FileList, Dir.glob(), or othr methods to copy groups of files
180
183
  cp_u FileList["lib/**/*.swc"], "bin/lib"
184
+ ```
185
+
186
+ ### Build without a task
187
+
188
+ 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.
189
+
190
+ > Note that this will not do any dependency checks, so the build will run even if it is unnecessary
191
+
192
+ ```ruby
193
+ args = ASRake::CompcArguments.new
194
+ args.target_player = 11.0
195
+ args.output = "bin/bin/my_project.swc"
196
+ args.source_path << "bin/src"
197
+ args.statically_link_only_referenced_classes << "lib/lib_used_in_project.swc"
198
+ args.build()
199
+
200
+ ASRake::MxmlcArguments.new do |mxmlc|
201
+ mxmlc.target_player = 11.0
202
+ mxmlc.output = "bin/bin/my_project.swf"
203
+ mxmlc.debug = true
204
+ mxmlc.source_path << "bin/src"
205
+ mxmlc.build()
206
+ end
181
207
  ```
@@ -0,0 +1,106 @@
1
+ require 'rake/tasklib'
2
+ require 'nokogiri'
3
+
4
+ # http://help.adobe.com/en_US/flex/using/WSd0ded3821e0d52fe1e63e3d11c2f44bc36-7ffa.html
5
+
6
+ module ASRake
7
+ class Asdoc
8
+
9
+ attr_accessor :output
10
+
11
+ attr_accessor :doc_sources
12
+ attr_accessor :doc_classes
13
+ attr_accessor :doc_namespaces
14
+ attr_accessor :source_path
15
+ attr_accessor :library_path
16
+
17
+ attr_accessor :load_config
18
+ #
19
+ # The path to the ASDoc template directory. The default is the asdoc/templates directory in the ASDoc
20
+ # installation directory. This directory contains all the HTML, CSS, XSL, and image files used for
21
+ # generating the output.
22
+ #
23
+ attr_accessor :templates_path
24
+
25
+ attr_accessor :additional_args
26
+
27
+ @@compiler_args = [
28
+ [:output, :dir],
29
+ #
30
+ # When true, retain the intermediate XML files created by the ASDoc tool. The default value is false.
31
+ #
32
+ [:keep_xml, :bool],
33
+ #
34
+ # When true, configures the ASDoc tool to generate the intermediate XML files only, and not perform
35
+ # the final conversion to HTML. The default value is false.
36
+ #
37
+ [:skip_xsl, :bool],
38
+ #
39
+ # Whether all dependencies found by the compiler are documented. If true, the dependencies of
40
+ # the input classes are not documented. The default value is false.
41
+ #
42
+ [:exclude_dependencies, :bool],
43
+ #
44
+ # Ignore XHTML errors (such as a missing </p> tag) and produce the ASDoc output.
45
+ # All errors are written to the validation_errors.log file.
46
+ #
47
+ [:lenient, :bool],
48
+ [:source_path, :array],
49
+ [:load_config, :array],
50
+ [:library_path, :array],
51
+ [:doc_classes, :array],
52
+ [:doc_namespaces, :array],
53
+ ]
54
+
55
+ @@compiler_args.each do |name, type|
56
+ attr_accessor name
57
+ end
58
+
59
+ def initialize
60
+
61
+ # set all defaults
62
+ @@compiler_args.each do |name, type|
63
+ instance_variable_set("@#{name}", []) if type == :array
64
+ end
65
+
66
+ @doc_sources = []
67
+
68
+ yield self if block_given?
69
+
70
+ end
71
+
72
+ def execute
73
+ command = "#{FlexSDK::asdoc}"
74
+
75
+ @@compiler_args.each do |name, type|
76
+ arg = name.to_s.gsub('_','-')
77
+ value = instance_variable_get("@#{name}")
78
+ case type
79
+ when :bool
80
+ command << " -#{arg}=#{value}" if value
81
+ when :array
82
+ value.flatten!
83
+ value = value.map{|s| s.index(' ') != nil ? "'#{s}'" : s} if value.length > 1
84
+ command << " -#{arg} #{cf value.join(' ')}" if !value.empty?
85
+ when :dir
86
+ command << " -#{arg}=#{cf value}" if value != nil
87
+ else
88
+ fail "unknown type #{type}"
89
+ end
90
+ end
91
+
92
+ # Use doc-sources argument if it has been assigned (duh) or if neither doc-classes or doc-namespaces have
93
+ # been assigned and source-path has
94
+ if !self.doc_sources.empty?
95
+ command << " -doc-sources #{cf doc_sources.join(' ')}"
96
+ elsif !self.source_path.empty? && self.doc_classes.empty? && self.doc_namespaces.empty?
97
+ command << " -doc-sources #{cf source_path.join(' ')}" if !self.source_path.empty?
98
+ end
99
+
100
+ command << " #{additional_args}" if self.additional_args != nil
101
+
102
+ run command
103
+ end
104
+
105
+ end
106
+ end
@@ -256,6 +256,7 @@ end
256
256
  #end
257
257
 
258
258
  #http://fpdownload.macromedia.com/get/flashplayer/updaters/11/playerglobal11_2.swc
259
+ #https://github.com/nexussays/playerglobal/raw/master/player/11.2/playerglobal.swc
259
260
  #frameworks\libs\player
260
261
 
261
262
  #-dump-config compiler_config.xml
@@ -6,6 +6,8 @@ module ASRake
6
6
  module CompcArguments_Module
7
7
  include BaseCompilerArguments_Module
8
8
 
9
+ attr_accessor :include_asdoc
10
+
9
11
  def compiler
10
12
  FlexSDK::compc
11
13
  end
@@ -15,24 +17,12 @@ module CompcArguments_Module
15
17
 
16
18
  #compc << " -include-sources=#{cf source_path.join(',')}" if !source_path.empty?
17
19
  self.source_path.each do |path|
18
- compc << " -include-classes #{get_classes(path).join(' ')}"
20
+ compc << " -include-classes #{ASRake::get_classes(path).join(' ')}"
19
21
  end
20
22
 
21
23
  return compc
22
24
  end
23
25
 
24
- def get_classes(path)
25
- arr = []
26
- Dir.chdir(path) do
27
- FileList["**/*.as"].pathmap('%X').each do |file|
28
- name = file.gsub(/^\.[\/\\]/, "").gsub(/[\/\\]/, ".")
29
- yield name if block_given?
30
- arr << name
31
- end
32
- end
33
- return arr
34
- end
35
-
36
26
  end
37
27
 
38
28
  class CompcArguments
@@ -3,6 +3,7 @@ require 'rake/tasklib'
3
3
  require 'asrake/host'
4
4
  require 'asrake/base_compiler_task'
5
5
  require 'asrake/compc_args'
6
+ require 'asrake/asdoc'
6
7
 
7
8
  module ASRake
8
9
  class CompcTask < BaseCompilerTask
@@ -13,10 +14,13 @@ class CompcTask < BaseCompilerTask
13
14
  super
14
15
 
15
16
  # create directory task for output
16
- directory self.output_dir
17
-
17
+ if !output_is_dir?
18
+ directory self.output_dir
19
+ file self.output => self.output_dir
20
+ end
21
+
18
22
  # create file task for output
19
- file self.output => self.output_dir do
23
+ file self.output do
20
24
  self.build
21
25
  end
22
26
 
@@ -41,6 +45,36 @@ class CompcTask < BaseCompilerTask
41
45
  puts result
42
46
  end
43
47
 
48
+ if @include_asdoc
49
+ file self.output do
50
+ asdoc = ASRake::Asdoc.new
51
+ asdoc.output = "#{self.output_dir}/.asrake/"
52
+ asdoc.source_path = self.source_path
53
+ asdoc.library_path = self.library_path
54
+ asdoc.load_config = self.load_config
55
+ self.source_path.each do |path|
56
+ asdoc.doc_classes << ASRake::get_classes(path)
57
+ end
58
+ asdoc.keep_xml = true
59
+ asdoc.skip_xsl = true
60
+ asdoc.lenient = true
61
+ asdoc.exclude_dependencies = true
62
+ asdoc.execute
63
+
64
+ if output_is_dir?
65
+ cp_r File.join(asdoc.output, 'tempdita'), File.join(self.output_dir, 'docs')
66
+ else
67
+ Zip::ZipFile.open(self.output) do |zipfile|
68
+ FileList[File.join(asdoc.output, 'tempdita', '*')].each do |file|
69
+ zipfile.add(File.join('docs', File.basename(file)), file)
70
+ end
71
+ end
72
+ end
73
+
74
+ rm_rf asdoc.output
75
+ end
76
+ end
77
+
44
78
  end
45
79
 
46
80
  end
data/lib/asrake.rb CHANGED
@@ -24,4 +24,22 @@ THE SOFTWARE.
24
24
  Dir.glob(File.join(File.expand_path(File.dirname(__FILE__)), "asrake/*_task.rb")).each {|f| require f }
25
25
  Dir.glob(File.join(File.expand_path(File.dirname(__FILE__)), "asrake/*_args.rb")).each {|f| require f }
26
26
 
27
- require 'asrake/file_utils'
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
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.9.0
4
+ version: 0.10.0
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-08-05 00:00:00.000000000 Z
12
+ date: 2012-09-18 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: nokogiri
@@ -70,6 +70,7 @@ extensions: []
70
70
  extra_rdoc_files: []
71
71
  files:
72
72
  - lib/asrake/adt_task.rb
73
+ - lib/asrake/asdoc.rb
73
74
  - lib/asrake/base_compiler_args.rb
74
75
  - lib/asrake/base_compiler_task.rb
75
76
  - lib/asrake/clean_task.rb