airake 0.3.2 → 0.4.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/History.txt CHANGED
@@ -1,3 +1,7 @@
1
+ === 0.4.0 2008-01-28
2
+
3
+ * Using a config file (airake.yml), breaking backwards compatibility, sorry!
4
+
1
5
  == 0.3.2 2008-01-19
2
6
 
3
7
  * Refactoring amxmlc command into mxmlc command to work for regular flash projects
@@ -43,6 +43,7 @@ class AirakeGenerator < RubiGen::Base
43
43
  m.template "Rakefile", "Rakefile"
44
44
  m.template "descriptor_M6.xml", "src/#{app_name}-app.xml"
45
45
  m.template "application.mxml", "src/#{app_name}.mxml"
46
+ m.template "airake.yml", "airake.yml"
46
47
 
47
48
  # Icons
48
49
  m.directory "src/assets/app_icons"
@@ -45,7 +45,8 @@ class BrowsairGenerator < RubiGen::Base
45
45
  # Source
46
46
  m.directory "src"
47
47
  m.template "descriptor_M6.xml", "src/#{app_name}-app.xml"
48
- m.template "application.mxml", "src/#{app_name}.mxml"
48
+ m.template "application.mxml", "src/#{app_name}.mxml"
49
+ m.template "airake.yml", "airake.yml"
49
50
 
50
51
  # Icons
51
52
  if icon_src_path.blank?
@@ -1,18 +1,8 @@
1
1
  require 'rubygems'
2
2
  require 'airake'
3
3
 
4
- # Specify certificate path
5
- ENV["CERTIFICATE"] ||= "cert.pfx"
6
-
7
- # dirname $0
8
- ENV["BASE_DIR"] ||= File.expand_path(File.dirname(__FILE__))
9
-
10
- # MXML options
11
- ENV["MXML"] ||= "src/<%= app_name %>.mxml"
12
- ENV["MXML_TEST"] ||= "test/Test.mxml"
13
-
14
- # Assets to package, can be multiple items, e.g. "src/assets/app_icons src/assets/tray_icons"
15
- ENV["ASSETS"] ||= "src/assets"
4
+ ENV["AIRAKE_ROOT"] = File.dirname(__FILE__)
5
+ ENV["AIRAKE_ENV"] = "development"
16
6
 
17
7
  # Aliases
18
8
  task :test => [ "air:test" ] do; end
@@ -1,67 +1,77 @@
1
- module Airake #:nodoc
1
+ module Airake
2
2
 
3
3
  #
4
4
  # Project for AIR application
5
5
  #
6
6
  class Project
7
7
 
8
- attr_reader :base_dir, :bin_dir, :src_dir, :lib_dir, :test_dir
8
+ attr_reader :base_dir, :src_dirs, :lib_dir
9
9
  attr_reader :mxml_path, :appxml_path, :air_path, :swf_path
10
10
  attr_reader :debug, :assets, :certificate
11
- attr_reader :build_env
12
11
 
13
- # Options to override defaults
14
- Options = [ :bin_dir, :src_dir, :lib_dir, :test_dir,
15
- :appxml_path, :air_path, :swf_path, :debug, :certificate, :assets,
16
- :amxmlc_path, :adl_path, :adt_path, :asdoc_path, :amxmlc_extra_opts, :adl_extra_opts, :adt_extra_opts, :asdoc_extra_opts ]
17
-
18
12
  # Build project:
19
13
  #
20
- # base_dir: Base (project) directory
21
- # mxml_path: Path to the ProjectName.mxml (relative)
22
- # options:
23
- # bin_dir: Path to generated output, defaults to 'bin'
24
- # src_dir: Path to source, defaults to 'src'
25
- # lib_dir: Path to lib directory, defaults to 'lib'
26
- # test_dir: Path to test directory, defaults to 'test'
27
- # appxml_path: Path to application descriptor, defaults to '<mxml_dir>/<ProjectName>-app.xml'. Default assumes the app xml is in same directory as the root mxml.
28
- # air_path: Path to AIR file, defaults to '<bin_dir>/<ProjectName>.air'
29
- # swf_path: Path to SWF file, defaults to '<bin_dir>/<ProjectName.swf'
14
+ # env: development, test
15
+ # base_dir: Base (project) directory, if nil, AirakeRoot is used
16
+ # options: If nil, loaded from airake.yml in root. (All paths relative to base directory)
17
+ # mxml_path: Path to the ProjectName.mxml
18
+ # appxml_path: Path to application descriptor
19
+ # src_dirs: Paths to source
20
+ # lib_dir: Path to lib directory
21
+ # air_path: Path to AIR file
22
+ # swf_path: Path to SWF file
30
23
  # debug: "true" or "false"
31
24
  # assets: Path to assets
32
25
  # certificate: Path to certificate
33
- #
26
+ #
34
27
  # Other options:
35
- # :mxmlc_path, :adt_path, :adl_path, :asdoc_path, :mxmlc_extra_opts, :adt_extra_opts, :adl_extra_opts, :asdoc_extra_opts
28
+ # mxmlc_path, adt_path, adl_path, asdoc_path, mxmlc_extra_opts, adt_extra_opts, adl_extra_opts, asdoc_extra_opts
36
29
  #
37
- def initialize(base_dir, mxml_path, options = {}, build_env = :normal)
38
- raise ArgumentError, "Invalid MXML path: #{mxml_path}" if mxml_path.blank?
30
+ def initialize(env = nil, base_dir = nil, options = nil)
31
+
32
+ env = ENV["AIRAKE_ENV"] if env.nil?
33
+ base_dir = ENV["AIRAKE_ROOT"] if base_dir.nil?
34
+ raise "Need to specify an AIRAKE_ROOT (project root)" if base_dir.blank?
39
35
 
40
- mxml_dir = File.expand_path(File.dirname(mxml_path))
41
- project_name = File.basename(mxml_path, ".mxml")
36
+ if options.nil?
37
+ conf_path = File.join(base_dir, "airake.yml")
38
+ unless File.exist?(conf_path)
39
+ raise <<-EOS
40
+
41
+ You are missing your #{conf_path} configuration file.
42
+
43
+ For existing projects, please regenerate an airake project and look at Rakefile and airake.yml for an example.
44
+
45
+ EOS
46
+ end
47
+
48
+ options = YAML.load_file(File.join(base_dir, "airake.yml"))
49
+ env_options = options[env]
50
+ options = options.merge(env_options) if env_options
51
+ options.symbolize_keys!
52
+ end
42
53
 
43
54
  @base_dir = base_dir
44
- @mxml_path = File.join(mxml_dir, "#{project_name}.mxml")
45
- @build_env = build_env
46
55
 
47
- @bin_dir = options[:bin_dir] || File.join(base_dir, "bin")
48
- @src_dir = options[:src_dir] || File.join(base_dir, "src")
49
- @lib_dir = options[:lib_dir] || File.join(base_dir, "lib")
50
- @test_dir = options[:test_dir] || File.join(base_dir, "test")
56
+ @mxml_path = File.join(base_dir, options[:mxml_path])
57
+ @appxml_path = File.join(base_dir, options[:appxml_path])
51
58
 
52
- @appxml_path = options[:appxml_path] || File.join(mxml_dir, "#{project_name}-app.xml")
59
+ @src_dirs = options[:src_dirs].collect { |src_dir| File.join(base_dir, src_dir) }
60
+ @lib_dir = File.join(base_dir, options[:lib_dir]) if options[:lib_dir]
53
61
 
54
62
  # Dest package files
55
- @air_path = options[:air_path] || File.join(@bin_dir, "#{project_name}.air")
56
- @swf_path = options[:swf_path] || File.join(@bin_dir, "#{project_name}.swf")
63
+ @air_path = File.join(base_dir, options[:air_path])
64
+ @swf_path = File.join(base_dir, options[:swf_path])
57
65
 
58
66
  # Debug options
59
- @debug = options[:debug].is_a?(TrueClass) || options[:debug] == "true"
67
+ @debug = options[:debug]
60
68
 
61
69
  with_keyed_options([ :assets, :certificate, :mxmlc_path, :adt_path, :adl_path, :asdoc_path,
62
70
  :mxmlc_extra_opts, :adt_extra_opts, :adl_extra_opts, :asdoc_extra_opts ], options)
71
+
72
+ ensure_exists([ @mxml_path, @appxml_path, *@src_dirs ])
63
73
  end
64
-
74
+
65
75
  # Flex compiler command (under AIR) for this project
66
76
  def amxmlc
67
77
  mxmlc({ :config_name => "air" })
@@ -69,16 +79,10 @@ module Airake #:nodoc
69
79
 
70
80
  # Flex compiler command for this project
71
81
  def mxmlc(options = {})
72
- src_dirs = case build_env
73
- when :normal then [ @src_dir ]
74
- when :test then [ @src_dir, @test_dir ]
75
- else raise "Invalid build_env setting: #{build_env}"
76
- end
77
-
78
82
  options = options.merge({ :swf_path => @swf_path, :mxml_path => @mxml_path, :lib_dir => @lib_dir,
79
- :src_dirs => src_dirs, :debug => @debug, :mxmlc_extra_opts => @mxmlc_extra_opts,
83
+ :src_dirs => @src_dirs, :debug => @debug, :mxmlc_extra_opts => @mxmlc_extra_opts,
80
84
  :mxmlc_path => @mxmlc_path })
81
-
85
+
82
86
  Airake::Commands::Mxmlc.new(options)
83
87
  end
84
88
 
@@ -100,50 +104,21 @@ module Airake #:nodoc
100
104
  # AS docs
101
105
  def asdoc
102
106
  src_dirs = [ @src_dir ]
103
- options = { :lib_dir => @lib_dir, :src_dirs => src_dirs, :asdoc_extra_opts => @asdoc_extra_opts,
107
+ options = { :lib_dir => @lib_dir, :src_dirs => @src_dirs, :asdoc_extra_opts => @asdoc_extra_opts,
104
108
  :asdoc_path => @asdoc_path }
105
109
  Airake::Commands::Asdoc.new(options)
106
110
  end
107
111
 
108
- # List of files to remove on clean
109
- def to_clean
110
- case build_env
111
- when :normal then [ swf_path, air_path ]
112
- when :test then [ swf_path ]
112
+ # Remove files
113
+ def clean
114
+ paths = [ swf_path, air_path ]
115
+ paths.each do |path|
116
+ FileUtils.rm(path, :verbose => true) if File.exist?(path)
113
117
  end
114
118
  end
119
+
120
+ protected
115
121
 
116
- #
117
- # Create project using parameters from rake ENV:
118
- #
119
- # BASE_DIR: Path to project base
120
- # MXML: Path to mxml file
121
- # MXML_TEST: In test environment, path to test mxml file
122
- #
123
- # You can override any of the project options via ENV; just upcase it. <tt>:foo_bar => ENV["FOO_BAR"]</tt>
124
- #
125
- # This shouldn't really be here, but a Rakefile is a bad place to be :O
126
- #
127
- # Booleans must be "true" for true
128
- #
129
- def self.new_from_rake(env, build_env = :normal)
130
- base_dir = env["BASE_DIR"]
131
- mxml = case build_env
132
- when :test then env["MXML_TEST"]
133
- when :normal then env["MXML"]
134
- else raise "Invalid build env: #{build_env}"
135
- end
136
-
137
- # For any option check to see if its in the ENV
138
- options = {}
139
- Options.each do |option_key|
140
- env_key = option_key.to_s.upcase
141
- options[option_key] = env[env_key] if env.has_key?(env_key)
142
- end
143
- #puts "Using options: #{options.inspect}" unless options.empty?
144
- self.new(base_dir, mxml, options, build_env)
145
- end
146
-
147
122
  # Load options into instance vars
148
123
  def with_keyed_options(keys, options)
149
124
  keys.each do |key|
@@ -152,6 +127,12 @@ module Airake #:nodoc
152
127
  end
153
128
  end
154
129
 
130
+ def ensure_exists(paths)
131
+ paths.each do |path|
132
+ raise "Path not found: #{path}" unless File.exist?(path)
133
+ end
134
+ end
135
+
155
136
  end
156
137
 
157
138
  end
@@ -3,7 +3,7 @@ namespace :air do
3
3
  desc "Compile"
4
4
  task :compile => :clean do
5
5
  begin
6
- project = Airake::Project.new_from_rake(ENV)
6
+ project = Airake::Project.new
7
7
  fcsh = PatternPark::FCSH.new_from_rake(ENV)
8
8
  fcsh.execute([ project.base_dir, project.amxmlc.compile ])
9
9
  rescue PatternPark::FCSHConnectError => e
@@ -13,17 +13,25 @@ namespace :air do
13
13
  end
14
14
 
15
15
  desc "Test"
16
- task :test => :clean do
17
- ENV["DEBUG"] = "true" unless ENV.has_key?("DEBUG")
18
- test_project = Airake::Project.new_from_rake(ENV, :test)
16
+ task :test do
17
+ ENV["AIRAKE_ENV"] = "test"
18
+ Rake::Task["air:clean"].invoke
19
+
20
+ test_project = Airake::Project.new
19
21
  Airake::Runner.run(test_project.amxmlc, :compile)
20
22
  Airake::Runner.run(test_project.adl, :launch)
21
23
  end
22
24
 
23
25
  desc "Generate certificate"
24
26
  task :certificate do
27
+
25
28
  pfx_file = ENV["CERTIFICATE"]
26
29
 
30
+ unless pfx_file
31
+ project = Airake::Project.new
32
+ pfx_file = project.certificate
33
+ end
34
+
27
35
  if pfx_file.blank? || pfx_file == "path/to/certificate.pfx"
28
36
  print "Certificate file (to create; e.g. cert.pfx): "
29
37
  pfx_file = STDIN.gets.chomp!
@@ -39,7 +47,7 @@ namespace :air do
39
47
 
40
48
  puts "Will generate a certificate file at: #{pfx_file}"
41
49
 
42
- project = Airake::Project.new_from_rake(ENV)
50
+ project = Airake::Project.new
43
51
  optionals = {}
44
52
 
45
53
  print "Specify common name (e.g. SelfSign, ADigitalID) [SelfSign]: "
@@ -70,9 +78,14 @@ namespace :air do
70
78
  task :check_certificate do
71
79
  pfx_file = ENV["CERTIFICATE"]
72
80
 
81
+ unless pfx_file
82
+ project = Airake::Project.new
83
+ pfx_file = project.certificate
84
+ end
85
+
73
86
  if pfx_file.blank? || pfx_file == "path/to/certificate.pfx"
74
87
  raise <<-EOS
75
- No certificate path found (or not set). Please specify ENV[\"CERTIFICATE\"] = \"path/to/certificate.pfx\" in Rakefile.
88
+ No certificate path found (or not set). Please specify ENV[\"CERTIFICATE\"] = \"path/to/certificate.pfx\" in Rakefile. Or certificate: path/to/cert.pfx in airake.yml.
76
89
  If you don't have a certificate run rake air:certificate to generate one.
77
90
  EOS
78
91
  end
@@ -85,7 +98,7 @@ namespace :air do
85
98
 
86
99
  desc "Package only"
87
100
  task :package_only do
88
- project = Airake::Project.new_from_rake(ENV)
101
+ project = Airake::Project.new
89
102
  Airake::Runner.run(project.adt, :package)
90
103
  end
91
104
 
@@ -98,7 +111,7 @@ namespace :air do
98
111
 
99
112
  desc "Launch ADL only"
100
113
  task :adl_only do
101
- project = Airake::Project.new_from_rake(ENV)
114
+ project = Airake::Project.new
102
115
  Airake::Runner.run(project.adl, :launch)
103
116
  end
104
117
 
@@ -140,22 +153,14 @@ namespace :air do
140
153
 
141
154
  desc "Docs"
142
155
  task :docs do
143
- project = Airake::Project.new_from_rake(ENV)
156
+ project = Airake::Project.new
144
157
  Airake::Runner.run(project.asdoc, :generate)
145
158
  end
146
159
 
147
160
  desc "Clean"
148
161
  task :clean do
149
- project = Airake::Project.new_from_rake(ENV)
150
- paths = project.to_clean
151
-
152
- # Test
153
- test_project = Airake::Project.new_from_rake(ENV, :test)
154
- paths += project.to_clean
155
-
156
- paths.each do |path|
157
- FileUtils.rm(path, :verbose => true) if File.exist?(path)
158
- end
162
+ project = Airake::Project.new
163
+ project.clean
159
164
  end
160
165
 
161
166
  end
@@ -1,8 +1,8 @@
1
1
  module Airake #:nodoc:
2
2
  module VERSION #:nodoc:
3
3
  MAJOR = 0
4
- MINOR = 3
5
- TINY = 2
4
+ MINOR = 4
5
+ TINY = 0
6
6
 
7
7
  STRING = [MAJOR, MINOR, TINY].join('.')
8
8
  end
data/lib/airake.rb CHANGED
@@ -1,3 +1,7 @@
1
+ require 'rubygems'
2
+ require 'yaml'
3
+ require 'active_support'
4
+
1
5
  $:.unshift File.dirname(__FILE__)
2
6
 
3
7
  module Airake; end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: airake
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.2
4
+ version: 0.4.0
5
5
  platform: ""
6
6
  authors:
7
7
  - Gabriel Handford, Min Kim
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2008-01-20 00:00:00 -05:00
12
+ date: 2008-01-24 00:00:00 -05:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency