asproject 0.1.37 → 0.1.38

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/lib/asclass.rb CHANGED
@@ -1,8 +1,6 @@
1
1
  $:.push(File.dirname(__FILE__))
2
2
 
3
3
  require 'asproject'
4
- require 'asclass_arguments'
5
- require 'test_suite_generator'
6
4
 
7
5
  module AsProject
8
6
  class AsClass < AsProjectBase
data/lib/asproject.rb CHANGED
@@ -1,11 +1,16 @@
1
1
  $:.push(File.dirname(__FILE__))
2
2
 
3
3
  require 'rubygems'
4
+ require 'rake/clean'
5
+ require 'rake/tasklib'
6
+ require 'zip/zipfilesystem'
7
+ require 'net/http'
4
8
  require 'yaml'
5
9
  require 'optparse'
6
10
  require 'fileutils'
7
11
  require 'erb'
8
12
  require 'ftools'
13
+ require 'uri'
9
14
 
10
15
  require 'asproject/version'
11
16
  require 'asproject_base'
@@ -17,7 +22,18 @@ require 'project'
17
22
  require 'eclipse_project'
18
23
  require 'asproject_arguments'
19
24
  require 'asclass'
25
+ require 'asclass_arguments'
26
+ require 'test_suite_generator'
27
+
28
+ require 'tasks/simple_resolver'
20
29
  require 'tasks/remote_file_task'
30
+ require 'tasks/flash_log'
31
+ require 'tasks/mtasc'
32
+ require 'tasks/hamtasc'
33
+ require 'tasks/flash_player'
34
+ require 'tasks/swfmill_input_resolver'
35
+ require 'tasks/swfmill_input'
36
+ require 'tasks/swfmill'
21
37
 
22
38
  module AsProject
23
39
  class AsProject < AsProjectBase
@@ -2,7 +2,7 @@ module AsProject
2
2
  module VERSION
3
3
  MAJOR = 0
4
4
  MINOR = 1
5
- TINY = 37
5
+ TINY = 38
6
6
 
7
7
  STRING = [MAJOR, MINOR, TINY].join('.')
8
8
  end
data/lib/path_finder.rb CHANGED
@@ -1,7 +1,4 @@
1
1
 
2
- require 'player_fetcher'
3
- require 'ftools'
4
-
5
2
  module AsProject
6
3
  class PathFinder < TemplateResolver
7
4
  attr_accessor :execution_dir
@@ -33,10 +30,6 @@ module AsProject
33
30
  return @user.flash_player_config_content
34
31
  end
35
32
 
36
- def flash_player_debug(version)
37
- return @user.flash_player_debug(version)
38
- end
39
-
40
33
  def flash_player_trust
41
34
  return @user.flash_player_trust
42
35
  end
@@ -284,27 +277,6 @@ EOF
284
277
  return File.join(asproject_home, 'players', 'FlashPlayer' + version.to_s)
285
278
  end
286
279
 
287
- def flash_player_debug(version)
288
- path = flash_player_path(version)
289
- if(File.exists?(path))
290
- return path
291
- else
292
- url = get_player_url(version)
293
- if(url.nil?)
294
- raise UsageError.new("Unable to find appropriate player version #{version} for your system...")
295
- end
296
- fetch_player(url, path)
297
- end
298
- end
299
-
300
- def fetch_player(url, path)
301
- dir = path.split(File::SEPARATOR)
302
- dir.pop
303
- File.makedirs(dir.join(File::SEPARATOR))
304
- PlayerFetcher.new(url, path, @zip_target)
305
- return path
306
- end
307
-
308
280
  def flash_player_log
309
281
  dir = File.join(flash_player_home, 'Logs')
310
282
  File.makedirs(dir)
@@ -1,6 +1,4 @@
1
1
 
2
- require 'asproject'
3
-
4
2
  module AsProject
5
3
  class FlashLog
6
4
  attr_accessor :version
@@ -1,11 +1,4 @@
1
1
 
2
- require File.dirname(__FILE__) + '/../asproject'
3
- require File.dirname(__FILE__) + '/remote_file_task'
4
- require File.dirname(__FILE__) + '/flash_log'
5
- #require 'config/asclass_config'
6
- #require 'tasks/flash_log'
7
- #require 'asproject'
8
-
9
2
  # Pull in the project-local config file
10
3
  # if it exists...
11
4
  if(File.exists?('script/asclass_config.rb'))
@@ -76,7 +69,6 @@ module AsProject
76
69
  end
77
70
 
78
71
  player_thread = Thread.new {
79
- puts 'PLAYER THREAD with: ' + @swf
80
72
  execute("./#{@swf}")
81
73
  }
82
74
 
data/lib/tasks/hamtasc.rb CHANGED
@@ -1,6 +1,4 @@
1
1
 
2
- require File.dirname(__FILE__) + '/remote_file_task'
3
-
4
2
  module AsProject
5
3
  class HAMTASCError < StandardError; end
6
4
 
data/lib/tasks/mtasc.rb CHANGED
@@ -1,6 +1,4 @@
1
1
 
2
- require File.dirname(__FILE__) + '/remote_file_task'
3
-
4
2
  module AsProject
5
3
  class MTASCError < StandardError; end
6
4
 
@@ -1,10 +1,6 @@
1
- require 'rake/tasklib'
2
- require 'rake/clean'
3
- require 'uri'
4
- require 'ftools'
5
1
 
6
2
  # Tell Rake NOT to remove directory(ies) named 'core'
7
- CLEAN.exclude("core")
3
+ CLEAN.exclude("core")
8
4
 
9
5
  module AsProject
10
6
  # The RemoteFileTask was created to resolve
@@ -240,7 +236,7 @@ module AsProject
240
236
  end
241
237
 
242
238
  def execute(params)
243
- sh %{"#{extracted_file_path}" #{params}}
239
+ sh(%{"#{extracted_file_path}" #{params}})
244
240
  end
245
241
  end
246
242
 
@@ -0,0 +1,62 @@
1
+
2
+ class SimpleResolver
3
+
4
+ def initialize(template, output, files, base_dir=nil)
5
+ @template = template
6
+ @output = output
7
+ @files = files
8
+ @base_dir = base_dir
9
+ @ignored_files = []
10
+ execute
11
+ finish
12
+ end
13
+
14
+ def execute
15
+ template_file = File.open(@template, 'r')
16
+ content = template_file.read
17
+ result = ERB.new(content, nil, '>').result(binding)
18
+
19
+ output_file = File.open(@output, 'w')
20
+ output_file.write(result)
21
+
22
+ template_file.close
23
+ output_file.close
24
+ end
25
+
26
+ def files
27
+ return @files
28
+ end
29
+
30
+ def finish
31
+ if(@ignored_files.size > 0)
32
+ puts '>> SimpleResolver ignored the following files because their names were invalid:'
33
+ @ignored_files.each do |file|
34
+ puts file
35
+ end
36
+ end
37
+ end
38
+
39
+ def xml_edit_warning
40
+ return <<EOF
41
+ <!--
42
+ DO NOT EDIT THIS FILE!
43
+ This file was auto-generated from
44
+ an ERB template which can be
45
+ found at:
46
+ #{@template}
47
+ -->
48
+ EOF
49
+ end
50
+
51
+ def edit_warning
52
+ return <<EOF
53
+ /*************************************
54
+ * DO NOT EDIT THIS FILE!
55
+ * This file was auto-generated from
56
+ * an ERB template which can be
57
+ * found at:
58
+ * #{@template}
59
+ *************************************/
60
+ EOF
61
+ end
62
+ end
data/lib/tasks/swfmill.rb CHANGED
@@ -1,6 +1,4 @@
1
1
 
2
- require File.dirname(__FILE__) + '/remote_file_task'
3
-
4
2
  module AsProject
5
3
  class SWFMillError < StandardError; end
6
4
 
@@ -8,12 +6,16 @@ module AsProject
8
6
  attr_accessor :name,
9
7
  :simple,
10
8
  :input,
9
+ :input_expr,
11
10
  :output,
11
+ :template,
12
12
  :version
13
13
 
14
14
  def initialize(name, do_not_define=false)
15
15
  @simple = true
16
16
  @input = nil
17
+ @template = nil
18
+ @input_expr = nil
17
19
  @output = nil
18
20
  @options = []
19
21
  @version = '0.2.12'
@@ -35,16 +37,24 @@ module AsProject
35
37
  super
36
38
 
37
39
  if(@input.nil?)
38
- raise Error.new('SWFMill task requires that input be set')
40
+ raise SWFMillError.new('SWFMill task requires that input be set')
39
41
  end
40
42
 
41
43
  if(@output.nil?)
42
- raise Error.new('SWFMill task requires that output be set')
44
+ raise SWFMillError.new('SWFMill task requires that output be set')
45
+ end
46
+
47
+ if(File.directory?(input))
48
+ @input = define_xml_task(input).xml_file
43
49
  end
50
+
44
51
  file input
45
- file output => [input] do |f|
46
- user_task.execute(option_list.join(' '))
47
- # sh %{swfmill #{option_list}}
52
+ file output => input do |f|
53
+ cleaned_options = []
54
+ option_list.each do |item|
55
+ cleaned_options << clean_path(item)
56
+ end
57
+ execute(cleaned_options.join(' '))
48
58
  end
49
59
 
50
60
  desc "#{name} using SWFMill"
@@ -55,6 +65,16 @@ module AsProject
55
65
  self
56
66
  end
57
67
 
68
+ def define_xml_task(path)
69
+ # build the input xml file automatically
70
+ # Based on a directory full of images...
71
+ if(@template.nil?)
72
+ raise SWFMillError.new('If input is a directory, you must assign a template to use for the generated xml document')
73
+ end
74
+
75
+ return SWFMillInput.new(path, template, input_expr)
76
+ end
77
+
58
78
  def option_list
59
79
  result = @options.dup
60
80
  result << "simple" if simple
@@ -0,0 +1,56 @@
1
+
2
+ module AsProject
3
+ class SWFMillInputError < StandardError; end
4
+
5
+ class SWFMillInput
6
+ attr_accessor :path,
7
+ :template,
8
+ :input_expr
9
+
10
+ def initialize(path, template, input_expr=nil)
11
+ @path = path
12
+ @template = template
13
+ if(input_expr.nil?)
14
+ @input_expr = '/**/**/*'
15
+ else
16
+ @input_expr = input_expr
17
+ end
18
+ define
19
+ end
20
+
21
+ def define
22
+ if(@path.nil?)
23
+ raise SWFMillInputError.new('SWFMillInput needs a valid input');
24
+ end
25
+
26
+ if(@template.nil?)
27
+ raise SWFMillInputError.new('CompileSkins needs a valid template to use');
28
+ end
29
+
30
+ input_files = FileList.new(path + input_expr)
31
+ file xml_file => input_files
32
+ file xml_file => path
33
+ file xml_file => template
34
+
35
+ file xml_file do |f|
36
+ write_xml(xml_file, input_files, path)
37
+ end
38
+
39
+ CLEAN.add(xml_file)
40
+ self
41
+ end
42
+
43
+ def skin_name
44
+ return File.basename(path).capitalize
45
+ end
46
+
47
+ def xml_file
48
+ return File.join(File.dirname(path), skin_name + '.xml')
49
+ end
50
+
51
+ def write_xml(file, files, base_dir)
52
+ SWFMillInputResolver.new(template, file, files, base_dir)
53
+ puts 'Created file at: ' + file
54
+ end
55
+ end
56
+ end
@@ -0,0 +1,24 @@
1
+
2
+ class SWFMillInputResolver < SimpleResolver
3
+
4
+ def ignore_file?(file)
5
+ base = File.basename(file)
6
+ if(base == '.DS_Store' || base == 'Thumbs.db' || base.match(/^\d/))
7
+ @ignored_files << file
8
+ return true
9
+ end
10
+ return false
11
+ end
12
+
13
+ def get_symbol_id(file)
14
+ trimmed = file.gsub(@base_dir, '')
15
+ parts = trimmed.split('.')
16
+ parts.pop
17
+ trimmed = parts.join('.')
18
+
19
+ result = trimmed.split(File::SEPARATOR).join('.')
20
+ result = result.gsub(/^./, '')
21
+ return result
22
+ end
23
+
24
+ end
@@ -5,7 +5,7 @@ module AsProject
5
5
  class TemplateResolver < Hash
6
6
  attr_accessor :replace_all, :ignore_all
7
7
  @@ASPROJECT_FILE_NAME = 'AsProject'
8
- @@RENDER_IGNORE_FILES = ['asclass_config.rb']
8
+ @@RENDER_IGNORE_FILES = ['asclass_config.rb', 'SWFMillTemplate.erb']
9
9
  @@BINARY_EXTENSIONS = ['.jpg', '.png', '.gif', '.doc', '.xls', '.exe']
10
10
 
11
11
  def initialize
@@ -16,7 +16,7 @@ module AsProject
16
16
  def copy_files(from, to, render=false)
17
17
  created_files = Array.new
18
18
  if(!File.exists? from)
19
- raise ProjectError.new('AsProject attempted to copy files from (' + from + ') but it does not exist...')
19
+ raise ProjectError.new('TemplateResolver attempted to copy files from (' + from + ') but it does not exist...')
20
20
  end
21
21
  if(File.directory? from)
22
22
  Dir.open(from).each do |filename|
@@ -0,0 +1,13 @@
1
+ <?xml version="1.0" encoding="iso-8859-1" ?>
2
+ <%= xml_edit_warning %>
3
+ <movie width="600" height="450" framerate="24" version="8">
4
+ <background color="#ffffff"/>
5
+ <frame>
6
+ <library><% files.each do |file| if(!ignore_file?(file) && !File.directory?(file)) %>
7
+ <clip id="<%=get_symbol_id(file)%>" import="<%=file%>" /><% end end %>
8
+ </library>
9
+ </frame>
10
+ <frame>
11
+ <stop />
12
+ </frame>
13
+ </movie>
@@ -1,8 +1,5 @@
1
1
  require 'rubygems'
2
- require 'tasks/mtasc'
3
- require 'tasks/hamtasc'
4
- require 'tasks/swfmill'
5
- require 'tasks/flash_player'
2
+ require 'asproject'
6
3
 
7
4
  ############################################
8
5
  # Launch the Application using Flash Player 8
@@ -31,7 +28,8 @@ end
31
28
  # Compile your library using SWFMill
32
29
 
33
30
  AsProject::SWFMill.new(:compile_skin) do |t|
34
- t.input = 'assets/img/skins/Default.xml'
31
+ t.input = 'assets/img/skins/default'
32
+ t.template = 'assets/img/skins/SWFMillTemplate.erb'
35
33
  t.output = 'bin/<%= project_name %>Skin.swf'
36
34
  end
37
35
 
metadata CHANGED
@@ -3,7 +3,7 @@ rubygems_version: 0.9.0
3
3
  specification_version: 1
4
4
  name: asproject
5
5
  version: !ruby/object:Gem::Version
6
- version: 0.1.37
6
+ version: 0.1.38
7
7
  date: 2007-03-04 00:00:00 -08:00
8
8
  summary: AsProject is a tool set that simplifies the process of beginning and growing a new ActionScript project.
9
9
  require_paths:
@@ -54,7 +54,6 @@ files:
54
54
  - lib/eclipse_project.rb
55
55
  - lib/path_finder.rb
56
56
  - lib/platform.rb
57
- - lib/player_fetcher.rb
58
57
  - lib/project.rb
59
58
  - lib/tasks
60
59
  - lib/template_resolver.rb
@@ -64,9 +63,11 @@ files:
64
63
  - lib/tasks/flash_player.rb
65
64
  - lib/tasks/hamtasc.rb
66
65
  - lib/tasks/mtasc.rb
67
- - lib/tasks/rake.rb
68
66
  - lib/tasks/remote_file_task.rb
67
+ - lib/tasks/simple_resolver.rb
69
68
  - lib/tasks/swfmill.rb
69
+ - lib/tasks/swfmill_input.rb
70
+ - lib/tasks/swfmill_input_resolver.rb
70
71
  - templates/asclass
71
72
  - templates/asproject
72
73
  - templates/ide
@@ -106,7 +107,7 @@ files:
106
107
  - templates/asproject/as2/project/assets/img
107
108
  - templates/asproject/as2/project/assets/img/skins
108
109
  - templates/asproject/as2/project/assets/img/skins/default
109
- - templates/asproject/as2/project/assets/img/skins/Default.xml
110
+ - templates/asproject/as2/project/assets/img/skins/SWFMillTemplate.erb
110
111
  - templates/asproject/as2/project/assets/img/skins/default/PatternPark.jpg
111
112
  - templates/asproject/as2/project/src/AsProject.as
112
113
  - templates/asproject/as2/project/test/AsProjectRunner.as
@@ -1,118 +0,0 @@
1
-
2
- require 'net/http'
3
- require 'zip/zipfilesystem'
4
-
5
- module AsProject
6
-
7
- class PlayerFetcher
8
-
9
- def initialize(url, target, zipped_file, debug=false)
10
- @debug = debug
11
- if(!debug)
12
- verify_download(target)
13
- fetch(url, target, zipped_file)
14
- end
15
- end
16
-
17
- def verify_download(target)
18
- puts <<EOF
19
-
20
- Unable to find Flash Player at:
21
- #{target}
22
-
23
- Download now? [Yn]
24
-
25
- EOF
26
- if(!$stdin.gets.chomp.downcase.index('y'))
27
- raise UsageError.new("Cannot find the Flash Player at #{target}, and automatic download was refused...")
28
- end
29
- end
30
-
31
- def fetch(url, target, zipped_file)
32
- puts "Fetching: #{url} to: #{target} now!"
33
- zip_name = url.split(File::SEPARATOR).pop
34
- parts = target.split(File::SEPARATOR)
35
- parts.pop
36
- zip_dir = parts.join(File::SEPARATOR)
37
- zip_file = File.join(zip_dir, zip_name)
38
-
39
- puts 'zip_file: ' + zip_file
40
-
41
- if(File.exists?(zip_file))
42
- result = extract(zip_file, zipped_file, target)
43
- write_file(target, result)
44
- return
45
- end
46
-
47
- response = nil
48
- host = 'download.macromedia.com'
49
-
50
- t = Thread.new {
51
- response = Net::HTTP.get_response(host, url)
52
- }
53
-
54
- while t.alive?
55
- print(".")
56
- $stdout.flush
57
- sleep(0.3)
58
- end
59
-
60
- if(response.nil?)
61
- msg1 = "Download failed for\n"
62
- msg1 << "http://#{host}#{url}\n"
63
- raise UsageError.new(msg1)
64
- end
65
-
66
- if(response.code != '200')
67
- msg = "Download failed for\n"
68
- msg << "http://#{host}#{url}\n"
69
- msg << "with HTTP Status code: #{response.code.to_s}\n"
70
- msg << response.message
71
- raise UsageError.new(msg)
72
- end
73
-
74
- puts ""
75
- puts "Downloaded: #{(response.body.size / 1024).to_s} KB"
76
- puts ""
77
-
78
-
79
- result = ''
80
-
81
- if(is_zip?(url))
82
- File.open(zip_file, 'w') do |f|
83
- f.write(response.body)
84
- end
85
- result = extract(zip_file, zipped_file, target)
86
- else
87
- result = response.body
88
- end
89
-
90
- write_file(target, result)
91
- end
92
-
93
- def write_file(file, content)
94
- File.open(file, 'w') do |f|
95
- f.write(content)
96
- end
97
-
98
- File.chmod(0755, file)
99
- end
100
-
101
- def extract(zip_file, zipped_file, unzipped_file)
102
- result = nil
103
- Zip::ZipFile.open(zip_file) do |file|
104
- entry = file.get_entry(zipped_file)
105
- result = file.get_input_stream(entry).read
106
- end
107
- return result
108
- end
109
-
110
- def is_zip?(file)
111
- return file.match(/\.zip$/)
112
- end
113
-
114
- def is_dmg?(file)
115
- return file.match(/\.dmg$/)
116
- end
117
- end
118
- end
data/lib/tasks/rake.rb DELETED
@@ -1,6 +0,0 @@
1
-
2
- require 'rake/clean'
3
- require 'rake/tasklib'
4
- require 'tasks/remote_file_task'
5
- require 'tasks/mtasc'
6
- require 'tasks/hamtasc'
@@ -1,20 +0,0 @@
1
- <?xml version="1.0" encoding="iso-8859-1" ?>
2
- <!--
3
- DO NOT EDIT THIS FILE!
4
- This file was auto-generated from
5
- an ERB template which can be
6
- found at:
7
- config/templates/wickyd/SWFMill.erb
8
- -->
9
-
10
- <movie width="600" height="450" framerate="24" version="8">
11
- <background color="#ffffff"/>
12
- <frame>
13
- <library>
14
- <clip id="PatternPark" import="assets/img/skins/default/PatternPark.jpg" />
15
- </library>
16
- </frame>
17
- <frame>
18
- <stop />
19
- </frame>
20
- </movie>