fluby 0.5.2

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 ADDED
@@ -0,0 +1,4 @@
1
+ fluby
2
+ =====
3
+
4
+ A simple command to create an empty project for MTASC + SWFMILL + Rake
data/Rakefile ADDED
@@ -0,0 +1,54 @@
1
+ ##### Requirements
2
+
3
+ require 'rake'
4
+
5
+ require 'rake/clean'
6
+ require 'rake/gempackagetask'
7
+ require 'rake/testtask'
8
+
9
+ require File.dirname(__FILE__) + '/lib/fluby.rb'
10
+
11
+ ##### Cleaning
12
+ CLEAN.include [ 'tmp', 'test/fixtures/*/output/*', 'test/fixtures/*/tmp' ]
13
+ CLOBBER.include [ 'pkg' ]
14
+
15
+ ##### Packaging
16
+ spec = Gem::Specification.new do |s|
17
+ s.name = Fluby::NAME
18
+ s.version = Fluby::VERSION
19
+ s.platform = Gem::Platform::RUBY
20
+ s.summary = 'A simple command to create an empty project for MTASC + SWFMILL + Rake'
21
+ s.description = s.summary
22
+ s.homepage = 'http://fluby.googlecode.com/'
23
+ s.author = 'Ale Muñoz'
24
+ s.email = 'ale@bomberstudios.com'
25
+
26
+ s.rubyforge_project = 'fluby'
27
+
28
+ s.required_ruby_version = '>= 1.8.5'
29
+
30
+ s.has_rdoc = false
31
+ s.files = FileList.new("README","Rakefile","bin/**/*","lib/**/*").to_a
32
+ s.executables = [ 'fluby' ]
33
+ s.require_path = 'lib'
34
+ s.bindir = 'bin'
35
+ end
36
+
37
+ Rake::GemPackageTask.new(spec) { |task| }
38
+
39
+ task :install do
40
+ sh %{rake package}
41
+ sh %{sudo gem install pkg/#{Fluby::NAME}-#{Fluby::VERSION}}
42
+ end
43
+
44
+ task :uninstall do
45
+ sh %{sudo gem uninstall #{Fluby::NAME}}
46
+ end
47
+
48
+ ### Testing
49
+
50
+ Rake::TestTask.new(:test) do |test|
51
+ test.test_files = Dir['test/test_*.rb']
52
+ end
53
+
54
+ task :default => [ :test ]
data/bin/fluby ADDED
@@ -0,0 +1,15 @@
1
+ #!/usr/bin/env ruby
2
+ # Fluby Generator <http://fluby.googlecode.com>
3
+ # Handcrafted with love by bomberstudios & mamuso
4
+ # 2008-03-16
5
+
6
+ require File.dirname(__FILE__) + '/../lib/fluby.rb'
7
+
8
+ # Display help
9
+ if ARGV[0].nil?
10
+ puts "Fluby v#{Fluby::VERSION}"
11
+ puts "Usage: fluby project_name"
12
+ exit
13
+ end
14
+
15
+ Fluby.create_project(ARGV[0])
data/lib/fluby.rb ADDED
@@ -0,0 +1,50 @@
1
+ module Fluby
2
+ NAME = 'fluby'
3
+ VERSION = '0.5.2'
4
+
5
+ def self.create_project(name)
6
+ require "fileutils"
7
+ require "erb"
8
+
9
+ @project_name = name
10
+ @project_folder = FileUtils.pwd + "/" + @project_name
11
+
12
+ # Make folders
13
+ if File.exist? @project_folder
14
+ puts "Folder #{@project_name} already exists,"
15
+ puts "please choose a different name for your project"
16
+ exit
17
+ end
18
+ FileUtils.mkdir [@project_folder,"#{@project_folder}/deploy","#{@project_folder}/assets"]
19
+
20
+ # Make files
21
+ ["Rakefile","README"].each do |file|
22
+ render_template file
23
+ end
24
+
25
+ # Static Templates
26
+ copy_template "index.rhtml"
27
+ copy_template "project.rxml", "#{@project_name}.rxml"
28
+ copy_template "swfobject.js", "deploy/swfobject.js"
29
+
30
+ # Main Class
31
+ render_template "ASClass.as", "#{@project_name}.as"
32
+
33
+ end
34
+
35
+ def self.copy_template source, destination=nil
36
+ if destination.nil?
37
+ destination = source
38
+ end
39
+ FileUtils.cp "#{File.dirname(__FILE__)}/templates/#{source}", "#{@project_folder}/#{destination}"
40
+ end
41
+
42
+ def self.render_template source, destination=nil
43
+ if destination.nil?
44
+ destination = source
45
+ end
46
+ open("#{@project_folder}/#{destination}","w") do |f|
47
+ f << ERB.new(IO.read("#{File.dirname(__FILE__)}/templates/#{source}")).result(binding)
48
+ end
49
+ end
50
+ end
@@ -0,0 +1,9 @@
1
+ class <%= @project_name %> {
2
+ var _timeline:MovieClip;
3
+ function <%= @project_name %>(timeline){
4
+ _timeline = timeline;
5
+ }
6
+ static function main(tl:MovieClip){
7
+ var app:<%= @project_name %> = new <%= @project_name %>(tl);
8
+ }
9
+ }
@@ -0,0 +1,19 @@
1
+
2
+ <%= @project_name %>
3
+ <%= "="*@project_name.length %>
4
+
5
+ This is the README for the <%= @project_name %> project.
6
+
7
+ Compilation
8
+ -----------
9
+ <%= @project_name %> has been created using fluby, so compilation is pretty straightforward:
10
+
11
+ $ cd <%= @project_name %>
12
+ $ rake
13
+
14
+ There are some additional rake tasks available:
15
+
16
+ <%= %x(rake -f "#{@project_folder}/Rakefile" -T -s) %>
17
+
18
+ ---
19
+ Created: <%= Time.now %>
@@ -0,0 +1,70 @@
1
+ WIDTH = 725
2
+ HEIGHT = 480
3
+ FPS = 31
4
+ PLAYER = 8
5
+ BGCOLOR = "#ffffff"
6
+ APP = "<%= @project_name %>"
7
+
8
+ require "erb"
9
+
10
+ def render_template(file)
11
+ filename = File.basename(file).split(".")[0]
12
+ case File.basename(file).split(".")[1]
13
+ when "rhtml"
14
+ extension = "html"
15
+ when "rxml"
16
+ extension = "xml"
17
+ end
18
+ to_file = filename + "." + extension
19
+ puts "Rendering #{file}"
20
+ open(to_file,"w") do |f|
21
+ f << ERB.new(IO.read(file)).result
22
+ end
23
+ end
24
+
25
+ task :compile do
26
+ if @nodebug
27
+ puts "Trace disabled"
28
+ trace = " -trace no"
29
+ else
30
+ trace = ""
31
+ end
32
+ @start = Time.now
33
+ ["*.rhtml","*.rxml"].each do |list|
34
+ Dir[list].each do |tpl|
35
+ render_template(tpl)
36
+ end
37
+ end
38
+ puts %x(swfmill simple #{APP}.xml #{APP}.swf)
39
+ rm "#{APP}.xml"
40
+ puts %x(mtasc -swf #{APP}.swf -header #{WIDTH}:#{HEIGHT}:#{FPS} -main -mx -version #{PLAYER} #{trace} #{APP}.as)
41
+ @end = Time.now
42
+
43
+ ["*.html","*.swf"].each do |list|
44
+ Dir[list].each do |file|
45
+ mv file, "deploy/#{file}"
46
+ end
47
+ end
48
+ end
49
+
50
+ task :notify do
51
+ msg = "Finished compiling in #{@end - @start}s."
52
+ if @nodebug
53
+ msg += "\ntrace() disabled"
54
+ end
55
+ %x(growlnotify --name Rake -m '#{msg}' 'Rake')
56
+ end
57
+
58
+ task :nodebug do
59
+ @nodebug = true
60
+ end
61
+
62
+ desc "Test the SWF file in your default browser"
63
+ task :test => [:compile] do
64
+ %x(open deploy/index.html)
65
+ end
66
+
67
+ desc "Build a release version of <%= @project_name %> (with trace() disabled)"
68
+ task :release => [:nodebug,:compile,:notify]
69
+
70
+ task :default => [:compile,:notify,:test]
@@ -0,0 +1,16 @@
1
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
2
+ <head>
3
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
4
+ <title><%= APP %></title>
5
+ <script type="text/javascript" src="swfobject.js"></script>
6
+ </head>
7
+ <body>
8
+ <div id="flashcontent">
9
+ This text is replaced by the Flash movie.
10
+ </div>
11
+ <script type="text/javascript">
12
+ var so = new SWFObject("<%= APP %>.swf", "mymovie", "<%= WIDTH %>", "<%= HEIGHT %>", "<%= PLAYER %>", "<%= BGCOLOR %>");
13
+ so.write("flashcontent");
14
+ </script>
15
+ </body>
16
+ </html>
@@ -0,0 +1,14 @@
1
+ <?xml version="1.0" encoding="UTF-8" ?>
2
+ <movie width="<%= WIDTH %>" height="<%= HEIGHT %>" framerate="<%= FPS %>" version="<%= PLAYER %>">
3
+ <background color="<%= BGCOLOR %>"/>
4
+ <frame>
5
+ <library>
6
+ <% Dir["assets/*.png"].each do |file| %>
7
+ <clip id="<%= File.basename(file,'.png') %>" import="<%= file %>"/>
8
+ <% end %>
9
+ <% Dir["assets/*.ttf"].each do |file| %>
10
+ <font id="<%= File.basename(file,'.ttf') %>" import="<%= file %>" glyphs="abcdefghijklmnñopqrstuvwxyzABCDEFGHIJKLMNÑOPQRSTUVWXYZ01234567890,.-_¡!áéíóúÁÉÍÓÚüÜ/• :;()¿?" />
11
+ <% end %>
12
+ </library>
13
+ </frame>
14
+ </movie>
@@ -0,0 +1,230 @@
1
+ /**
2
+ * SWFObject v1.5.1: Flash Player detection and embed - http://blog.deconcept.com/swfobject/
3
+ *
4
+ * SWFObject is (c) 2007 Geoff Stearns and is released under the MIT License:
5
+ * http://www.opensource.org/licenses/mit-license.php
6
+ *
7
+ */
8
+ if(typeof deconcept == "undefined") var deconcept = {};
9
+ if(typeof deconcept.util == "undefined") deconcept.util = {};
10
+ if(typeof deconcept.SWFObjectUtil == "undefined") deconcept.SWFObjectUtil = {};
11
+ deconcept.SWFObject = function(swf, id, w, h, ver, c, quality, xiRedirectUrl, redirectUrl, detectKey) {
12
+ if (!document.getElementById) { return; }
13
+ this.DETECT_KEY = detectKey ? detectKey : 'detectflash';
14
+ this.skipDetect = deconcept.util.getRequestParameter(this.DETECT_KEY);
15
+ this.params = {};
16
+ this.variables = {};
17
+ this.attributes = [];
18
+ if(swf) { this.setAttribute('swf', swf); }
19
+ if(id) { this.setAttribute('id', id); }
20
+ if(w) { this.setAttribute('width', w); }
21
+ if(h) { this.setAttribute('height', h); }
22
+ if(ver) { this.setAttribute('version', new deconcept.PlayerVersion(ver.toString().split("."))); }
23
+ this.installedVer = deconcept.SWFObjectUtil.getPlayerVersion();
24
+ if (!window.opera && document.all && this.installedVer.major > 7) {
25
+ // only add the onunload cleanup if the Flash Player version supports External Interface and we are in IE
26
+ // fixes bug in some fp9 versions see http://blog.deconcept.com/2006/07/28/swfobject-143-released/
27
+ if (!deconcept.unloadSet) {
28
+ deconcept.SWFObjectUtil.prepUnload = function() {
29
+ __flash_unloadHandler = function(){};
30
+ __flash_savedUnloadHandler = function(){};
31
+ window.attachEvent("onunload", deconcept.SWFObjectUtil.cleanupSWFs);
32
+ }
33
+ window.attachEvent("onbeforeunload", deconcept.SWFObjectUtil.prepUnload);
34
+ deconcept.unloadSet = true;
35
+ }
36
+ }
37
+ if(c) { this.addParam('bgcolor', c); }
38
+ var q = quality ? quality : 'high';
39
+ this.addParam('quality', q);
40
+ this.setAttribute('useExpressInstall', false);
41
+ this.setAttribute('doExpressInstall', false);
42
+ var xir = (xiRedirectUrl) ? xiRedirectUrl : window.location;
43
+ this.setAttribute('xiRedirectUrl', xir);
44
+ this.setAttribute('redirectUrl', '');
45
+ if(redirectUrl) { this.setAttribute('redirectUrl', redirectUrl); }
46
+ }
47
+ deconcept.SWFObject.prototype = {
48
+ useExpressInstall: function(path) {
49
+ this.xiSWFPath = !path ? "expressinstall.swf" : path;
50
+ this.setAttribute('useExpressInstall', true);
51
+ },
52
+ setAttribute: function(name, value){
53
+ this.attributes[name] = value;
54
+ },
55
+ getAttribute: function(name){
56
+ return this.attributes[name] || "";
57
+ },
58
+ addParam: function(name, value){
59
+ this.params[name] = value;
60
+ },
61
+ getParams: function(){
62
+ return this.params;
63
+ },
64
+ addVariable: function(name, value){
65
+ this.variables[name] = value;
66
+ },
67
+ getVariable: function(name){
68
+ return this.variables[name] || "";
69
+ },
70
+ getVariables: function(){
71
+ return this.variables;
72
+ },
73
+ getVariablePairs: function(){
74
+ var variablePairs = [];
75
+ var key;
76
+ var variables = this.getVariables();
77
+ for(key in variables){
78
+ variablePairs[variablePairs.length] = key +"="+ variables[key];
79
+ }
80
+ return variablePairs;
81
+ },
82
+ getSWFHTML: function() {
83
+ var swfNode = "";
84
+ if (navigator.plugins && navigator.mimeTypes && navigator.mimeTypes.length) { // netscape plugin architecture
85
+ if (this.getAttribute("doExpressInstall")) {
86
+ this.addVariable("MMplayerType", "PlugIn");
87
+ this.setAttribute('swf', this.xiSWFPath);
88
+ }
89
+ swfNode = '<embed type="application/x-shockwave-flash" src="'+ this.getAttribute('swf') +'" width="'+ this.getAttribute('width') +'" height="'+ this.getAttribute('height') +'" style="'+ (this.getAttribute('style') || "") +'"';
90
+ swfNode += ' id="'+ this.getAttribute('id') +'" name="'+ this.getAttribute('id') +'" ';
91
+ var params = this.getParams();
92
+ for(var key in params){ swfNode += [key] +'="'+ params[key] +'" '; }
93
+ var pairs = this.getVariablePairs().join("&");
94
+ if (pairs.length > 0){ swfNode += 'flashvars="'+ pairs +'"'; }
95
+ swfNode += '/>';
96
+ } else { // PC IE
97
+ if (this.getAttribute("doExpressInstall")) {
98
+ this.addVariable("MMplayerType", "ActiveX");
99
+ this.setAttribute('swf', this.xiSWFPath);
100
+ }
101
+ swfNode = '<object id="'+ this.getAttribute('id') +'" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="'+ this.getAttribute('width') +'" height="'+ this.getAttribute('height') +'" style="'+ (this.getAttribute('style') || "") +'">';
102
+ swfNode += '<param name="movie" value="'+ this.getAttribute('swf') +'" />';
103
+ var params = this.getParams();
104
+ for(var key in params) {
105
+ swfNode += '<param name="'+ key +'" value="'+ params[key] +'" />';
106
+ }
107
+ var pairs = this.getVariablePairs().join("&");
108
+ if(pairs.length > 0) {swfNode += '<param name="flashvars" value="'+ pairs +'" />';}
109
+ swfNode += "</object>";
110
+ }
111
+ return swfNode;
112
+ },
113
+ write: function(elementId){
114
+ if(this.getAttribute('useExpressInstall')) {
115
+ // check to see if we need to do an express install
116
+ var expressInstallReqVer = new deconcept.PlayerVersion([6,0,65]);
117
+ if (this.installedVer.versionIsValid(expressInstallReqVer) && !this.installedVer.versionIsValid(this.getAttribute('version'))) {
118
+ this.setAttribute('doExpressInstall', true);
119
+ this.addVariable("MMredirectURL", escape(this.getAttribute('xiRedirectUrl')));
120
+ document.title = document.title.slice(0, 47) + " - Flash Player Installation";
121
+ this.addVariable("MMdoctitle", document.title);
122
+ }
123
+ }
124
+ if(this.skipDetect || this.getAttribute('doExpressInstall') || this.installedVer.versionIsValid(this.getAttribute('version'))){
125
+ var n = (typeof elementId == 'string') ? document.getElementById(elementId) : elementId;
126
+ n.innerHTML = this.getSWFHTML();
127
+ return true;
128
+ }else{
129
+ if(this.getAttribute('redirectUrl') != "") {
130
+ document.location.replace(this.getAttribute('redirectUrl'));
131
+ }
132
+ }
133
+ return false;
134
+ }
135
+ }
136
+
137
+ /* ---- detection functions ---- */
138
+ deconcept.SWFObjectUtil.getPlayerVersion = function(){
139
+ var PlayerVersion = new deconcept.PlayerVersion([0,0,0]);
140
+ if(navigator.plugins && navigator.mimeTypes.length){
141
+ var x = navigator.plugins["Shockwave Flash"];
142
+ if(x && x.description) {
143
+ PlayerVersion = new deconcept.PlayerVersion(x.description.replace(/([a-zA-Z]|\s)+/, "").replace(/(\s+r|\s+b[0-9]+)/, ".").split("."));
144
+ }
145
+ }else if (navigator.userAgent && navigator.userAgent.indexOf("Windows CE") >= 0){ // if Windows CE
146
+ var axo = 1;
147
+ var counter = 3;
148
+ while(axo) {
149
+ try {
150
+ counter++;
151
+ axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash."+ counter);
152
+ // document.write("player v: "+ counter);
153
+ PlayerVersion = new deconcept.PlayerVersion([counter,0,0]);
154
+ } catch (e) {
155
+ axo = null;
156
+ }
157
+ }
158
+ } else { // Win IE (non mobile)
159
+ // do minor version lookup in IE, but avoid fp6 crashing issues
160
+ // see http://blog.deconcept.com/2006/01/11/getvariable-setvariable-crash-internet-explorer-flash-6/
161
+ try{
162
+ var axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7");
163
+ }catch(e){
164
+ try {
165
+ var axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6");
166
+ PlayerVersion = new deconcept.PlayerVersion([6,0,21]);
167
+ axo.AllowScriptAccess = "always"; // error if player version < 6.0.47 (thanks to Michael Williams @ Adobe for this code)
168
+ } catch(e) {
169
+ if (PlayerVersion.major == 6) {
170
+ return PlayerVersion;
171
+ }
172
+ }
173
+ try {
174
+ axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash");
175
+ } catch(e) {}
176
+ }
177
+ if (axo != null) {
178
+ PlayerVersion = new deconcept.PlayerVersion(axo.GetVariable("").split(" ")[1].split(","));
179
+ }
180
+ }
181
+ return PlayerVersion;
182
+ }
183
+ deconcept.PlayerVersion = function(arrVersion){
184
+ this.major = arrVersion[0] != null ? parseInt(arrVersion[0]) : 0;
185
+ this.minor = arrVersion[1] != null ? parseInt(arrVersion[1]) : 0;
186
+ this.rev = arrVersion[2] != null ? parseInt(arrVersion[2]) : 0;
187
+ }
188
+ deconcept.PlayerVersion.prototype.versionIsValid = function(fv){
189
+ if(this.major < fv.major) return false;
190
+ if(this.major > fv.major) return true;
191
+ if(this.minor < fv.minor) return false;
192
+ if(this.minor > fv.minor) return true;
193
+ if(this.rev < fv.rev) return false;
194
+ return true;
195
+ }
196
+ /* ---- get value of query string param ---- */
197
+ deconcept.util = {
198
+ getRequestParameter: function(param) {
199
+ var q = document.location.search || document.location.hash;
200
+ if (param == null) { return q; }
201
+ if(q) {
202
+ var pairs = q.substring(1).split("&");
203
+ for (var i=0; i < pairs.length; i++) {
204
+ if (pairs[i].substring(0, pairs[i].indexOf("=")) == param) {
205
+ return pairs[i].substring((pairs[i].indexOf("=")+1));
206
+ }
207
+ }
208
+ }
209
+ return "";
210
+ }
211
+ }
212
+ /* fix for video streaming bug */
213
+ deconcept.SWFObjectUtil.cleanupSWFs = function() {
214
+ var objects = document.getElementsByTagName("OBJECT");
215
+ for (var i = objects.length - 1; i >= 0; i--) {
216
+ objects[i].style.display = 'none';
217
+ for (var x in objects[i]) {
218
+ if (typeof objects[i][x] == 'function') {
219
+ objects[i][x] = function(){};
220
+ }
221
+ }
222
+ }
223
+ }
224
+ /* add document.getElementById if needed (mobile IE < 5) */
225
+ if (!document.getElementById && document.all) { document.getElementById = function(id) { return document.all[id]; }}
226
+
227
+ /* add some aliases for ease of use/backwards compatibility */
228
+ var getQueryParamValue = deconcept.util.getRequestParameter;
229
+ var FlashObject = deconcept.SWFObject; // for legacy support
230
+ var SWFObject = deconcept.SWFObject;
metadata ADDED
@@ -0,0 +1,63 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: fluby
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.5.2
5
+ platform: ruby
6
+ authors:
7
+ - "Ale Mu\xC3\xB1oz"
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2008-03-17 00:00:00 +01:00
13
+ default_executable:
14
+ dependencies: []
15
+
16
+ description: A simple command to create an empty project for MTASC + SWFMILL + Rake
17
+ email: ale@bomberstudios.com
18
+ executables:
19
+ - fluby
20
+ extensions: []
21
+
22
+ extra_rdoc_files: []
23
+
24
+ files:
25
+ - README
26
+ - Rakefile
27
+ - bin/fluby
28
+ - lib/fluby.rb
29
+ - lib/templates
30
+ - lib/templates/ASClass.as
31
+ - lib/templates/index.rhtml
32
+ - lib/templates/project.rxml
33
+ - lib/templates/Rakefile
34
+ - lib/templates/README
35
+ - lib/templates/swfobject.js
36
+ has_rdoc: false
37
+ homepage: http://fluby.googlecode.com/
38
+ post_install_message:
39
+ rdoc_options: []
40
+
41
+ require_paths:
42
+ - lib
43
+ required_ruby_version: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: 1.8.5
48
+ version:
49
+ required_rubygems_version: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - ">="
52
+ - !ruby/object:Gem::Version
53
+ version: "0"
54
+ version:
55
+ requirements: []
56
+
57
+ rubyforge_project: fluby
58
+ rubygems_version: 1.0.1
59
+ signing_key:
60
+ specification_version: 2
61
+ summary: A simple command to create an empty project for MTASC + SWFMILL + Rake
62
+ test_files: []
63
+