asproject 0.1.41 → 0.1.42
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/asproject.rb +3 -1
- data/lib/asproject/version.rb +1 -1
- data/lib/eclipse_project.rb +7 -3
- data/lib/path_finder.rb +6 -1
- data/lib/tasks/flash_player.rb +3 -2
- data/lib/tasks/hamtasc.rb +63 -63
- data/lib/tasks/mtasc.rb +4 -4
- data/lib/tasks/remote_file_task.rb +42 -4
- data/lib/tasks/swfmill.rb +4 -4
- data/lib/template_resolver.rb +150 -150
- data/rakefile.rb +1 -0
- data/templates/asproject/as2/project/rakefile.rb +4 -4
- metadata +10 -1
data/lib/asproject.rb
CHANGED
@@ -4,6 +4,8 @@ require 'rubygems'
|
|
4
4
|
require 'rake/clean'
|
5
5
|
require 'rake/tasklib'
|
6
6
|
require 'zip/zipfilesystem'
|
7
|
+
require 'zlib'
|
8
|
+
require 'archive/tar/minitar'
|
7
9
|
require 'net/http'
|
8
10
|
require 'yaml'
|
9
11
|
require 'optparse'
|
@@ -232,7 +234,7 @@ EOF
|
|
232
234
|
|
233
235
|
#######################################
|
234
236
|
# ignore_file?
|
235
|
-
@@COPY_IGNORE_FILES = ['.', '..', '.svn', '.DS_Store', 'CVS', '.cvs' 'Thumbs.db', '.crap_file']
|
237
|
+
@@COPY_IGNORE_FILES = ['.', '..', '.svn', '.DS_Store', 'CVS', '.cvs' 'Thumbs.db', '.crap_file', '.Trashes', 'Desktop DB', 'Desktop DF']
|
236
238
|
# Do not copy files found in the ignore_files list
|
237
239
|
def AsProject.ignore_file? file
|
238
240
|
@@COPY_IGNORE_FILES.each do |name|
|
data/lib/asproject/version.rb
CHANGED
data/lib/eclipse_project.rb
CHANGED
@@ -15,9 +15,13 @@ module AsProject
|
|
15
15
|
|
16
16
|
def file_path=(path)
|
17
17
|
@file_path = path
|
18
|
-
|
19
|
-
|
20
|
-
|
18
|
+
begin
|
19
|
+
File.open(path, 'r') do |f|
|
20
|
+
parse(f.read)
|
21
|
+
end
|
22
|
+
rescue
|
23
|
+
@project_name = File.dirname(Dir.pwd)
|
24
|
+
end
|
21
25
|
end
|
22
26
|
|
23
27
|
def parse(str)
|
data/lib/path_finder.rb
CHANGED
@@ -181,13 +181,17 @@ module AsProject
|
|
181
181
|
# Over multiple lines?
|
182
182
|
private
|
183
183
|
def is_project?(dir)
|
184
|
-
return (has_config_yaml?(dir) || has_eclipse_project?(dir) || has_src_eclipse_project?(dir) || has_src_and_test?(dir))
|
184
|
+
return (has_config_rb?(dir) || has_config_yaml?(dir) || has_eclipse_project?(dir) || has_src_eclipse_project?(dir) || has_src_and_test?(dir))
|
185
185
|
end
|
186
186
|
|
187
187
|
def has_config_yaml?(dir)
|
188
188
|
return File.exists?(File.join(dir, 'config', 'asproject.yaml'))
|
189
189
|
end
|
190
190
|
|
191
|
+
def has_config_rb?(dir)
|
192
|
+
return File.exists?(File.join(dir, 'config', '*.rb'))
|
193
|
+
end
|
194
|
+
|
191
195
|
def has_eclipse_project?(dir)
|
192
196
|
return File.exists?(File.join(dir, '.project'))
|
193
197
|
end
|
@@ -367,6 +371,7 @@ EOF
|
|
367
371
|
raise UsageError.new("There was a problem finding a target for #{task.name}, it doesn't appear as if this task was expected to run on your system...")
|
368
372
|
end
|
369
373
|
t.url = task.osx_url
|
374
|
+
t.mounted_path = task.osx_mounted_path
|
370
375
|
t.extracted_file = task.osx_extracted_file
|
371
376
|
end
|
372
377
|
end
|
data/lib/tasks/flash_player.rb
CHANGED
@@ -37,8 +37,9 @@ module AsProject
|
|
37
37
|
elsif(version == 8)
|
38
38
|
@win_url = "http://download.macromedia.com/pub/flashplayer/updaters/8/flash_player_update3_flash8_win.zip"
|
39
39
|
@win_extracted_file = "/Players/Debug/SAFlashPlayer.exe"
|
40
|
-
@osx_url =
|
41
|
-
@
|
40
|
+
@osx_url = "http://download.macromedia.com/pub/flashplayer/updaters/8/sa_flashplayer_8_all_debug.dmg"
|
41
|
+
@osx_mounted_path = "/Volumes/Adobe Flash Standalone Players"
|
42
|
+
@osx_extracted_file = "/en/SAFlashPlayer"
|
42
43
|
@unix_url = nil
|
43
44
|
@unix_extracted_file = nil
|
44
45
|
elsif(version == 9)
|
data/lib/tasks/hamtasc.rb
CHANGED
@@ -1,64 +1,64 @@
|
|
1
|
-
|
2
|
-
module AsProject
|
3
|
-
class HAMTASCError < StandardError; end
|
4
|
-
|
5
|
-
class HAMTASC < MTASC
|
6
|
-
|
7
|
-
attr_accessor :pack_path,
|
8
|
-
:rb_entry,
|
9
|
-
:rb_exclude_swf,
|
10
|
-
:rb_exclude_path
|
11
|
-
|
12
|
-
def initialize(name=:compile, do_not_define=false)
|
13
|
-
@pack_path = []
|
14
|
-
@exclude_packages = []
|
15
|
-
@rb_exclude_path = []
|
16
|
-
super(name, true) do |s|
|
17
|
-
s.compiler_version = '1.12.rb.20'
|
18
|
-
s.win_url = "http://asproject.googlecode.com/files/hamtasc-#{compiler_version}.zip"
|
19
|
-
s.win_extracted_file = "/hamtasc-#{compiler_version}/hamtasc.exe"
|
20
|
-
s.osx_url = nil
|
21
|
-
s.osx_extracted_file = nil
|
22
|
-
s.unix_url = nil
|
23
|
-
s.unix_extracted_file = nil
|
24
|
-
end
|
25
|
-
yield self if block_given?
|
26
|
-
define unless do_not_define
|
27
|
-
end
|
28
|
-
|
29
|
-
def define
|
30
|
-
if(rb_exclude_path.size > 0)
|
31
|
-
@exclude_packages = rb_exclude_path
|
32
|
-
# rb_exclude_path.each do |path|
|
33
|
-
# @exclude_packages << recurse_exclude_path(path)
|
34
|
-
# end
|
35
|
-
end
|
36
|
-
|
37
|
-
@cleaned_pack_path = []
|
38
|
-
pack_path.each do |path|
|
39
|
-
add_path(path, @cleaned_pack_path)
|
40
|
-
end
|
41
|
-
|
42
|
-
super
|
43
|
-
end
|
44
|
-
|
45
|
-
def remote_task_name
|
46
|
-
return "hamtasc-#{compiler_version}"
|
47
|
-
end
|
48
|
-
|
49
|
-
def compile_task_desc
|
50
|
-
return "Compile #{name} using HAMTASC"
|
51
|
-
end
|
52
|
-
|
53
|
-
def option_list
|
54
|
-
result = super
|
55
|
-
input = result.pop if(input)
|
56
|
-
result << "-rb_entry" << rb_entry if rb_entry
|
57
|
-
result << "-rb_exclude_swf" << clean_path(rb_exclude_swf) if rb_exclude_swf
|
58
|
-
result << "-rb_exclude_package " << @exclude_packages.join(" -rb_exclude_package ") if @exclude_packages.size > 0
|
59
|
-
result << "-pack " + @cleaned_pack_path.join(" -pack ") if pack_path.size > 0
|
60
|
-
result << input if input
|
61
|
-
return result
|
62
|
-
end
|
63
|
-
end
|
1
|
+
|
2
|
+
module AsProject
|
3
|
+
class HAMTASCError < StandardError; end
|
4
|
+
|
5
|
+
class HAMTASC < MTASC
|
6
|
+
|
7
|
+
attr_accessor :pack_path,
|
8
|
+
:rb_entry,
|
9
|
+
:rb_exclude_swf,
|
10
|
+
:rb_exclude_path
|
11
|
+
|
12
|
+
def initialize(name=:compile, do_not_define=false)
|
13
|
+
@pack_path = []
|
14
|
+
@exclude_packages = []
|
15
|
+
@rb_exclude_path = []
|
16
|
+
super(name, true) do |s|
|
17
|
+
s.compiler_version = '1.12.rb.20'
|
18
|
+
s.win_url = "http://asproject.googlecode.com/files/hamtasc-#{compiler_version}.zip"
|
19
|
+
s.win_extracted_file = "/hamtasc-#{compiler_version}/hamtasc.exe"
|
20
|
+
s.osx_url = nil
|
21
|
+
s.osx_extracted_file = nil
|
22
|
+
s.unix_url = nil
|
23
|
+
s.unix_extracted_file = nil
|
24
|
+
end
|
25
|
+
yield self if block_given?
|
26
|
+
define unless do_not_define
|
27
|
+
end
|
28
|
+
|
29
|
+
def define
|
30
|
+
if(rb_exclude_path.size > 0)
|
31
|
+
@exclude_packages = rb_exclude_path
|
32
|
+
# rb_exclude_path.each do |path|
|
33
|
+
# @exclude_packages << recurse_exclude_path(path)
|
34
|
+
# end
|
35
|
+
end
|
36
|
+
|
37
|
+
@cleaned_pack_path = []
|
38
|
+
pack_path.each do |path|
|
39
|
+
add_path(path, @cleaned_pack_path)
|
40
|
+
end
|
41
|
+
|
42
|
+
super
|
43
|
+
end
|
44
|
+
|
45
|
+
def remote_task_name
|
46
|
+
return "hamtasc-#{compiler_version}"
|
47
|
+
end
|
48
|
+
|
49
|
+
def compile_task_desc
|
50
|
+
return "Compile #{name} using HAMTASC"
|
51
|
+
end
|
52
|
+
|
53
|
+
def option_list
|
54
|
+
result = super
|
55
|
+
input = result.pop if(input)
|
56
|
+
result << "-rb_entry" << rb_entry if rb_entry
|
57
|
+
result << "-rb_exclude_swf" << clean_path(rb_exclude_swf) if rb_exclude_swf
|
58
|
+
result << "-rb_exclude_package " << @exclude_packages.join(" -rb_exclude_package ") if @exclude_packages.size > 0
|
59
|
+
result << "-pack " + @cleaned_pack_path.join(" -pack ") if pack_path.size > 0
|
60
|
+
result << input if input
|
61
|
+
return result
|
62
|
+
end
|
63
|
+
end
|
64
64
|
end
|
data/lib/tasks/mtasc.rb
CHANGED
@@ -24,10 +24,10 @@ module AsProject
|
|
24
24
|
@user_task = nil
|
25
25
|
@win_url = "http://www.mtasc.org/zip/mtasc-#{compiler_version}.zip"
|
26
26
|
@win_extracted_file = "/mtasc-#{compiler_version}/mtasc.exe"
|
27
|
-
@osx_url = "http://
|
28
|
-
@osx_extracted_file = "/mtasc
|
29
|
-
@unix_url =
|
30
|
-
@unix_extracted_file =
|
27
|
+
@osx_url = "http://mtasc.org/zip/mtasc-1.12-osx.zip"
|
28
|
+
@osx_extracted_file = "/mtasc-1.12-osx/mtasc"
|
29
|
+
@unix_url = nil
|
30
|
+
@unix_extracted_file = nil
|
31
31
|
super(name, true)
|
32
32
|
define unless do_not_define
|
33
33
|
end
|
@@ -12,6 +12,7 @@ module AsProject
|
|
12
12
|
# each platform will seamlessly download and
|
13
13
|
# target these tools.
|
14
14
|
class RemoteFileTask < Rake::TaskLib
|
15
|
+
|
15
16
|
attr_accessor :name,
|
16
17
|
:user_task,
|
17
18
|
:remote_task_name,
|
@@ -20,7 +21,8 @@ module AsProject
|
|
20
21
|
:unix_url,
|
21
22
|
:win_extracted_file,
|
22
23
|
:osx_extracted_file,
|
23
|
-
:unix_extracted_file
|
24
|
+
:unix_extracted_file,
|
25
|
+
:osx_mounted_path
|
24
26
|
|
25
27
|
def initialize(name=:remote_file_task, do_not_define=false)
|
26
28
|
@name = name
|
@@ -65,8 +67,11 @@ module AsProject
|
|
65
67
|
# Concrete instances returned from
|
66
68
|
# User objects
|
67
69
|
class AbstractRemoteFileTask
|
70
|
+
include Archive::Tar
|
71
|
+
|
68
72
|
attr_accessor :name,
|
69
73
|
:url,
|
74
|
+
:mounted_path,
|
70
75
|
:extracted_file
|
71
76
|
|
72
77
|
def initialize(name, user)
|
@@ -110,9 +115,14 @@ module AsProject
|
|
110
115
|
end
|
111
116
|
|
112
117
|
def unpack_downloaded_file(file_name, expected_file)
|
118
|
+
dir = File.dirname(file_name)
|
113
119
|
if(!File.exists?(expected_file))
|
114
120
|
if(is_zip?(file_name))
|
115
|
-
unpack_zip(file_name,
|
121
|
+
unpack_zip(file_name, dir)
|
122
|
+
elsif(is_targz?(file_name))
|
123
|
+
unpack_targz(file_name, dir)
|
124
|
+
elsif(is_dmg?(file_name))
|
125
|
+
unpack_dmg(file_name, dir)
|
116
126
|
elsif(!is_exe?(file_name))
|
117
127
|
raise UsageError.new("RemoteFileTask does not know how to unpack files of type: #{file_name}")
|
118
128
|
end
|
@@ -129,6 +139,33 @@ module AsProject
|
|
129
139
|
end
|
130
140
|
end
|
131
141
|
|
142
|
+
def unpack_targz(tgz_file, dir)
|
143
|
+
tar = Zlib::GzipReader.new(File.open(tgz_file, 'rb'))
|
144
|
+
Minitar.unpack(tar, dir)
|
145
|
+
end
|
146
|
+
|
147
|
+
# This probably NOT the correct way to do this,
|
148
|
+
# But I don't know much about macs, osx or dmgs
|
149
|
+
# and it seems to work...
|
150
|
+
# IF you know a better way - PLEASE let me know
|
151
|
+
def unpack_dmg(dmg_file, dir)
|
152
|
+
# 1) Mount the dmg in place
|
153
|
+
# 2) Recursively Copy it's contents to asproject_home
|
154
|
+
# 3) Unmount the dmg
|
155
|
+
if(mounted_path.nil?)
|
156
|
+
raise StandardError.new('DMG file downloaded, but the RemoteFileTask needs a mounted_path in order to mount it')
|
157
|
+
end
|
158
|
+
|
159
|
+
puts "Creating mounted path task: #{File.exists?(mounted_path)}"
|
160
|
+
if(!File.exists?(mounted_path))
|
161
|
+
system(%{hdiutil mount #{dmg_file}})
|
162
|
+
end
|
163
|
+
resolver = TemplateResolver.new
|
164
|
+
resolver.copy_files(mounted_path, dir, false)
|
165
|
+
File.chmod(0755, extracted_file)
|
166
|
+
system(%{hdiutil unmount #{mounted_path}})
|
167
|
+
end
|
168
|
+
|
132
169
|
def is_exe?(file)
|
133
170
|
return (file.split('.').pop == 'exe')
|
134
171
|
end
|
@@ -137,8 +174,9 @@ module AsProject
|
|
137
174
|
return (file.split('.').pop == 'zip')
|
138
175
|
end
|
139
176
|
|
140
|
-
def
|
141
|
-
|
177
|
+
def is_targz?(file)
|
178
|
+
parts = file.split('.')
|
179
|
+
return (parts.pop == 'gz' && parts.pop == 'tar')
|
142
180
|
end
|
143
181
|
|
144
182
|
def is_gzip?(file)
|
data/lib/tasks/swfmill.rb
CHANGED
@@ -21,10 +21,10 @@ module AsProject
|
|
21
21
|
@version = '0.2.12'
|
22
22
|
@win_url = "http://www.swfmill.org/releases/swfmill-#{version}-win32.zip"
|
23
23
|
@win_extracted_file = "/swfmill-#{version}-win32/swfmill.exe"
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
24
|
+
@osx_url = "http://swfmill.org/releases/swfmill-#{version}-macosx.tar.gz"
|
25
|
+
@osx_extracted_file = "swfmill-#{version}-macosx/swfmill"
|
26
|
+
@unix_url = nil
|
27
|
+
@unix_extracted_file = nil
|
28
28
|
super(name, true)
|
29
29
|
define unless do_not_define
|
30
30
|
end
|
data/lib/template_resolver.rb
CHANGED
@@ -1,151 +1,151 @@
|
|
1
|
-
|
2
|
-
module AsProject
|
3
|
-
#######################################
|
4
|
-
# TemplateResolver
|
5
|
-
class TemplateResolver < Hash
|
6
|
-
attr_accessor :replace_all, :ignore_all
|
7
|
-
@@ASPROJECT_FILE_NAME = 'AsProject'
|
8
|
-
@@RENDER_IGNORE_FILES = ['asclass_config.rb', 'SWFMillTemplate.erb']
|
9
|
-
@@BINARY_EXTENSIONS = ['.jpg', '.png', '.gif', '.doc', '.xls', '.exe']
|
10
|
-
|
11
|
-
def initialize
|
12
|
-
@replace_all = false
|
13
|
-
@ignore_all = false
|
14
|
-
end
|
15
|
-
|
16
|
-
def copy_files(from, to, render=false)
|
17
|
-
created_files = Array.new
|
18
|
-
if(!File.exists? from)
|
19
|
-
raise ProjectError.new('TemplateResolver attempted to copy files from (' + from + ') but it does not exist...')
|
20
|
-
end
|
21
|
-
if(File.directory? from)
|
22
|
-
Dir.open(from).each do |filename|
|
23
|
-
if(!AsProject.ignore_file? filename)
|
24
|
-
fullname = File.join(from, filename)
|
25
|
-
new_fullname = File.join(to, filename)
|
26
|
-
cleaned_filename = clean_file_name(filename)
|
27
|
-
cleaned_fullname = File.join(to, cleaned_filename)
|
28
|
-
if(File.directory? fullname)
|
29
|
-
Dir.mkdir(new_fullname) unless File.exists? new_fullname
|
30
|
-
copy_files(fullname, new_fullname, render).each do |file|
|
31
|
-
created_files << file
|
32
|
-
end
|
33
|
-
else
|
34
|
-
file = copy_file(fullname, cleaned_fullname, render)
|
35
|
-
if(file)
|
36
|
-
created_files << file
|
37
|
-
end
|
38
|
-
end
|
39
|
-
end
|
40
|
-
end
|
41
|
-
else
|
42
|
-
raise ProjectError.new("copy_files called with a file (" + from + ") instead of a directory!")
|
43
|
-
end
|
44
|
-
return created_files
|
45
|
-
end
|
46
|
-
|
47
|
-
def copy_file(from, to, render=false)
|
48
|
-
if(write_file?(to))
|
49
|
-
content = File.open(from, 'r').read
|
50
|
-
parts = to.split(File::SEPARATOR)
|
51
|
-
parts.pop
|
52
|
-
File.makedirs(parts.join(File::SEPARATOR))
|
53
|
-
target = File.open(to, 'w')
|
54
|
-
if(render && should_render?(from))
|
55
|
-
begin
|
56
|
-
content = ERB.new(content, nil, '>').result(binding)
|
57
|
-
rescue NameError => e
|
58
|
-
puts '>> Template ' + from + ' references a value that is not defined'
|
59
|
-
raise e
|
60
|
-
end
|
61
|
-
end
|
62
|
-
target.write(content)
|
63
|
-
target.close
|
64
|
-
return to
|
65
|
-
end
|
66
|
-
return nil
|
67
|
-
end
|
68
|
-
|
69
|
-
def should_render?(file)
|
70
|
-
if(is_binary?(file) || @@RENDER_IGNORE_FILES.index(File.basename(file)))
|
71
|
-
return false
|
72
|
-
end
|
73
|
-
return true
|
74
|
-
end
|
75
|
-
|
76
|
-
def write_file?(file)
|
77
|
-
if(!File.exists?(file))
|
78
|
-
return true
|
79
|
-
elsif(@replace_all)
|
80
|
-
File.delete(file)
|
81
|
-
return true
|
82
|
-
elsif(@ignore_all)
|
83
|
-
return false
|
84
|
-
end
|
85
|
-
|
86
|
-
relative = file.gsub(Dir.pwd, '')
|
87
|
-
msg = <<EOF
|
88
|
-
|
89
|
-
AsProject Encountered an existing file at [#{relative}], what would you like to do?
|
90
|
-
(r)eplace, (i)gnore, (R)eplace all or (I)gnore all?
|
91
|
-
|
92
|
-
EOF
|
93
|
-
puts msg
|
94
|
-
answer = gets.chomp!
|
95
|
-
if(answer == 'r')
|
96
|
-
return true
|
97
|
-
elsif(answer == 'i')
|
98
|
-
return false
|
99
|
-
elsif(answer == 'R')
|
100
|
-
msg = <<EOF
|
101
|
-
|
102
|
-
Are you sure you want to replace ALL duplicate files?
|
103
|
-
(y)es or (n)o
|
104
|
-
|
105
|
-
EOF
|
106
|
-
puts msg
|
107
|
-
answer = gets.chomp!
|
108
|
-
if(answer == 'y')
|
109
|
-
@replace_all = true
|
110
|
-
else
|
111
|
-
write_file?(file)
|
112
|
-
end
|
113
|
-
elsif(answer == 'I')
|
114
|
-
@ignore_all = true
|
115
|
-
return false
|
116
|
-
else
|
117
|
-
puts "I didn't understand that response... Please choose from the following choices:\n\n"
|
118
|
-
write_file?(file)
|
119
|
-
end
|
120
|
-
end
|
121
|
-
|
122
|
-
def render_file filename
|
123
|
-
file = File.open(filename, 'r')
|
124
|
-
resolved = ERB.new(file.read, nil, '>').result(binding)
|
125
|
-
file.close
|
126
|
-
file = File.open(filename, 'w')
|
127
|
-
file.write(resolved)
|
128
|
-
file.close
|
129
|
-
end
|
130
|
-
|
131
|
-
def clean_file_name name
|
132
|
-
return name.gsub(@@ASPROJECT_FILE_NAME, project_name)
|
133
|
-
end
|
134
|
-
|
135
|
-
# Override in subclasses!
|
136
|
-
def project_name
|
137
|
-
return @@ASPROJECT_FILE_NAME
|
138
|
-
end
|
139
|
-
|
140
|
-
#TODO: Figure out if the file is plain text or not... Possible?
|
141
|
-
def is_binary? file
|
142
|
-
file_extension = File.extname(file).downcase
|
143
|
-
@@BINARY_EXTENSIONS.each do |ext|
|
144
|
-
if(file_extension == ext)
|
145
|
-
return true
|
146
|
-
end
|
147
|
-
end
|
148
|
-
return false
|
149
|
-
end
|
150
|
-
end
|
1
|
+
|
2
|
+
module AsProject
|
3
|
+
#######################################
|
4
|
+
# TemplateResolver
|
5
|
+
class TemplateResolver < Hash
|
6
|
+
attr_accessor :replace_all, :ignore_all
|
7
|
+
@@ASPROJECT_FILE_NAME = 'AsProject'
|
8
|
+
@@RENDER_IGNORE_FILES = ['asclass_config.rb', 'SWFMillTemplate.erb']
|
9
|
+
@@BINARY_EXTENSIONS = ['.jpg', '.png', '.gif', '.doc', '.xls', '.exe']
|
10
|
+
|
11
|
+
def initialize
|
12
|
+
@replace_all = false
|
13
|
+
@ignore_all = false
|
14
|
+
end
|
15
|
+
|
16
|
+
def copy_files(from, to, render=false)
|
17
|
+
created_files = Array.new
|
18
|
+
if(!File.exists? from)
|
19
|
+
raise ProjectError.new('TemplateResolver attempted to copy files from (' + from + ') but it does not exist...')
|
20
|
+
end
|
21
|
+
if(File.directory? from)
|
22
|
+
Dir.open(from).each do |filename|
|
23
|
+
if(!AsProject.ignore_file? filename)
|
24
|
+
fullname = File.join(from, filename)
|
25
|
+
new_fullname = File.join(to, filename)
|
26
|
+
cleaned_filename = clean_file_name(filename)
|
27
|
+
cleaned_fullname = File.join(to, cleaned_filename)
|
28
|
+
if(File.directory? fullname)
|
29
|
+
Dir.mkdir(new_fullname) unless File.exists? new_fullname
|
30
|
+
copy_files(fullname, new_fullname, render).each do |file|
|
31
|
+
created_files << file
|
32
|
+
end
|
33
|
+
else
|
34
|
+
file = copy_file(fullname, cleaned_fullname, render)
|
35
|
+
if(file)
|
36
|
+
created_files << file
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
else
|
42
|
+
raise ProjectError.new("copy_files called with a file (" + from + ") instead of a directory!")
|
43
|
+
end
|
44
|
+
return created_files
|
45
|
+
end
|
46
|
+
|
47
|
+
def copy_file(from, to, render=false)
|
48
|
+
if(write_file?(to))
|
49
|
+
content = File.open(from, 'r').read
|
50
|
+
parts = to.split(File::SEPARATOR)
|
51
|
+
parts.pop
|
52
|
+
File.makedirs(parts.join(File::SEPARATOR))
|
53
|
+
target = File.open(to, 'w')
|
54
|
+
if(render && should_render?(from))
|
55
|
+
begin
|
56
|
+
content = ERB.new(content, nil, '>').result(binding)
|
57
|
+
rescue NameError => e
|
58
|
+
puts '>> Template ' + from + ' references a value that is not defined'
|
59
|
+
raise e
|
60
|
+
end
|
61
|
+
end
|
62
|
+
target.write(content)
|
63
|
+
target.close
|
64
|
+
return to
|
65
|
+
end
|
66
|
+
return nil
|
67
|
+
end
|
68
|
+
|
69
|
+
def should_render?(file)
|
70
|
+
if(is_binary?(file) || @@RENDER_IGNORE_FILES.index(File.basename(file)))
|
71
|
+
return false
|
72
|
+
end
|
73
|
+
return true
|
74
|
+
end
|
75
|
+
|
76
|
+
def write_file?(file)
|
77
|
+
if(!File.exists?(file))
|
78
|
+
return true
|
79
|
+
elsif(@replace_all)
|
80
|
+
File.delete(file)
|
81
|
+
return true
|
82
|
+
elsif(@ignore_all)
|
83
|
+
return false
|
84
|
+
end
|
85
|
+
|
86
|
+
relative = file.gsub(Dir.pwd, '')
|
87
|
+
msg = <<EOF
|
88
|
+
|
89
|
+
AsProject Encountered an existing file at [#{relative}], what would you like to do?
|
90
|
+
(r)eplace, (i)gnore, (R)eplace all or (I)gnore all?
|
91
|
+
|
92
|
+
EOF
|
93
|
+
puts msg
|
94
|
+
answer = gets.chomp!
|
95
|
+
if(answer == 'r')
|
96
|
+
return true
|
97
|
+
elsif(answer == 'i')
|
98
|
+
return false
|
99
|
+
elsif(answer == 'R')
|
100
|
+
msg = <<EOF
|
101
|
+
|
102
|
+
Are you sure you want to replace ALL duplicate files?
|
103
|
+
(y)es or (n)o
|
104
|
+
|
105
|
+
EOF
|
106
|
+
puts msg
|
107
|
+
answer = gets.chomp!
|
108
|
+
if(answer == 'y')
|
109
|
+
@replace_all = true
|
110
|
+
else
|
111
|
+
write_file?(file)
|
112
|
+
end
|
113
|
+
elsif(answer == 'I')
|
114
|
+
@ignore_all = true
|
115
|
+
return false
|
116
|
+
else
|
117
|
+
puts "I didn't understand that response... Please choose from the following choices:\n\n"
|
118
|
+
write_file?(file)
|
119
|
+
end
|
120
|
+
end
|
121
|
+
|
122
|
+
def render_file filename
|
123
|
+
file = File.open(filename, 'r')
|
124
|
+
resolved = ERB.new(file.read, nil, '>').result(binding)
|
125
|
+
file.close
|
126
|
+
file = File.open(filename, 'w')
|
127
|
+
file.write(resolved)
|
128
|
+
file.close
|
129
|
+
end
|
130
|
+
|
131
|
+
def clean_file_name name
|
132
|
+
return name.gsub(@@ASPROJECT_FILE_NAME, project_name)
|
133
|
+
end
|
134
|
+
|
135
|
+
# Override in subclasses!
|
136
|
+
def project_name
|
137
|
+
return @@ASPROJECT_FILE_NAME
|
138
|
+
end
|
139
|
+
|
140
|
+
#TODO: Figure out if the file is plain text or not... Possible?
|
141
|
+
def is_binary? file
|
142
|
+
file_extension = File.extname(file).downcase
|
143
|
+
@@BINARY_EXTENSIONS.each do |ext|
|
144
|
+
if(file_extension == ext)
|
145
|
+
return true
|
146
|
+
end
|
147
|
+
end
|
148
|
+
return false
|
149
|
+
end
|
150
|
+
end
|
151
151
|
end
|
data/rakefile.rb
CHANGED
@@ -38,9 +38,9 @@ end
|
|
38
38
|
|
39
39
|
task :compile_main => [:compile_skin]
|
40
40
|
|
41
|
-
AsProject::
|
41
|
+
AsProject::MTASC.new(:compile_main) do |t|
|
42
42
|
t.input = '<%= project_name %>'
|
43
|
-
t.
|
43
|
+
t.main = true
|
44
44
|
t.version = 8
|
45
45
|
t.frame = 2
|
46
46
|
t.input_swf = 'bin/<%= project_name %>Skin.swf'
|
@@ -51,11 +51,11 @@ end
|
|
51
51
|
############################################
|
52
52
|
# Compile your Application using HAMTASC
|
53
53
|
|
54
|
-
AsProject::
|
54
|
+
AsProject::MTASC.new(:compile_tests) do |t|
|
55
55
|
t.input = '<%= project_name %>Runner'
|
56
56
|
t.version = 8
|
57
57
|
t.frame = 2
|
58
|
-
t.
|
58
|
+
t.main = true
|
59
59
|
t.input_swf = 'bin/<%= project_name %>Skin.swf'
|
60
60
|
t.output = 'bin/<%= project_name %>Runner.swf'
|
61
61
|
t.class_path << 'src'
|
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.
|
6
|
+
version: 0.1.42
|
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:
|
@@ -304,3 +304,12 @@ dependencies:
|
|
304
304
|
- !ruby/object:Gem::Version
|
305
305
|
version: 0.9.1
|
306
306
|
version:
|
307
|
+
- !ruby/object:Gem::Dependency
|
308
|
+
name: archive-tar-minitar
|
309
|
+
version_requirement:
|
310
|
+
version_requirements: !ruby/object:Gem::Version::Requirement
|
311
|
+
requirements:
|
312
|
+
- - ">="
|
313
|
+
- !ruby/object:Gem::Version
|
314
|
+
version: 0.5.1
|
315
|
+
version:
|