bomberstudios-fluby 0.6 → 0.6.1
Sign up to get free protection for your applications and to get access to all the features.
- data/README.mdown +102 -2
- data/lib/fluby.rb +2 -2
- data/lib/templates/generate +1 -2
- data/lib/templates/generators/class +2 -2
- data/lib/templates/generators/delegate +22 -0
- metadata +2 -1
data/README.mdown
CHANGED
@@ -11,10 +11,15 @@ Fluby requires the 'mtasc' and 'swfmill' executables somewhere on your path.
|
|
11
11
|
|
12
12
|
## Usage
|
13
13
|
|
14
|
+
### New project
|
15
|
+
|
14
16
|
To create a new project:
|
15
17
|
|
16
18
|
fluby ProjectName
|
17
19
|
|
20
|
+
|
21
|
+
### Compilation
|
22
|
+
|
18
23
|
To compile your brand new project:
|
19
24
|
|
20
25
|
cd ProjectName
|
@@ -24,11 +29,106 @@ That should generate a 'ProjectName.swf' file on the 'deploy' folder. The SWF fi
|
|
24
29
|
|
25
30
|
rake release
|
26
31
|
|
32
|
+
|
33
|
+
### More Rake tasks
|
34
|
+
|
27
35
|
There are other rake tasks available:
|
28
36
|
|
29
37
|
rake package # Creates a ZIP file containing your SWF file on the 'pkg' folder
|
30
38
|
rake test # Opens a HTML file with your SWF for testing on your default browser (available on Mac only)
|
31
39
|
|
32
|
-
## Notes
|
33
40
|
|
34
|
-
|
41
|
+
### script/generate
|
42
|
+
|
43
|
+
Starting from version 0.6, fluby installs a 'generate' script in the 'scripts' folder that you can use to speed up the creation of new classes.
|
44
|
+
|
45
|
+
Right now there are 3 template types:
|
46
|
+
|
47
|
+
#### **class**
|
48
|
+
|
49
|
+
Use it to create a generic class by running:
|
50
|
+
|
51
|
+
script/generate class your.class.path.ClassName attribute:Type attribute:Type (...)
|
52
|
+
|
53
|
+
For example: if you want to create a "Car" class with attributes "make" and "model" of type String and an attribute "year" of type Number, you'd run:
|
54
|
+
|
55
|
+
script/generate class com.yourdomain.Car make:String model:String year:Number
|
56
|
+
|
57
|
+
This will create a file in com/yourdomain/Car.as with this content:
|
58
|
+
|
59
|
+
class com.yourdomain.Car {
|
60
|
+
var make:String;
|
61
|
+
var model:String;
|
62
|
+
var year:Number;
|
63
|
+
function Car(){
|
64
|
+
// Init class
|
65
|
+
}
|
66
|
+
}
|
67
|
+
|
68
|
+
|
69
|
+
#### **xml_loader**
|
70
|
+
|
71
|
+
Use to create a simple XML loader class by running:
|
72
|
+
|
73
|
+
script/generate xml_loader your.class.path.ClassName
|
74
|
+
|
75
|
+
Example: if you run
|
76
|
+
|
77
|
+
script/generate xml_loader com.bomberstudios.xml.Loader
|
78
|
+
|
79
|
+
you'll get a com/bomberstudios/xml/Loader.as file containing:
|
80
|
+
|
81
|
+
class com.bomberstudios.xml.Loader {
|
82
|
+
var _path:String;
|
83
|
+
var raw_data:XML;
|
84
|
+
function Loader(path:String,callback:Function){
|
85
|
+
_path = path;
|
86
|
+
raw_data = new XML();
|
87
|
+
raw_data.ignoreWhite = true;
|
88
|
+
raw_data.onLoad = callback;
|
89
|
+
}
|
90
|
+
function give_me(node_name){
|
91
|
+
if (raw_data.firstChild.nodeName == node_name) {
|
92
|
+
return raw_data.firstChild;
|
93
|
+
}
|
94
|
+
for(var i=raw_data.firstChild.childNodes.length; i>=0; i--){
|
95
|
+
if(raw_data.firstChild.childNodes[i].nodeName == node_name){
|
96
|
+
return raw_data.firstChild.childNodes[i];
|
97
|
+
}
|
98
|
+
}
|
99
|
+
}
|
100
|
+
public function load(){
|
101
|
+
raw_data.load(_path);
|
102
|
+
}
|
103
|
+
}
|
104
|
+
|
105
|
+
|
106
|
+
#### **delegate**
|
107
|
+
|
108
|
+
To generate a MTASC-compatible Delegate class, run
|
109
|
+
|
110
|
+
script/generate delegate your.class.path.Delegate
|
111
|
+
|
112
|
+
This will produce a your/class/path/Delegate.as file containing:
|
113
|
+
|
114
|
+
/**
|
115
|
+
*
|
116
|
+
* Delegate Class, MTASC compatible
|
117
|
+
*
|
118
|
+
**/
|
119
|
+
class your.class.path.Delegate {
|
120
|
+
public static function create(scope:Object,method:Function):Function{
|
121
|
+
var params:Array = arguments.splice(2,arguments.length-2);
|
122
|
+
var proxyFunc:Function = function():Void{
|
123
|
+
method.apply(scope,arguments.concat(params));
|
124
|
+
}
|
125
|
+
return proxyFunc;
|
126
|
+
}
|
127
|
+
public static function createR(scope:Object,method:Function):Function{
|
128
|
+
var params:Array = arguments.splice(2,arguments.length-2);
|
129
|
+
var proxyFunc:Function = function():Void{
|
130
|
+
method.apply(scope,params.concat(arguments));
|
131
|
+
}
|
132
|
+
return proxyFunc;
|
133
|
+
}
|
134
|
+
}
|
data/lib/fluby.rb
CHANGED
@@ -3,7 +3,7 @@ require "fileutils"
|
|
3
3
|
|
4
4
|
module Fluby
|
5
5
|
NAME = 'fluby'
|
6
|
-
VERSION = '0.6'
|
6
|
+
VERSION = '0.6.1'
|
7
7
|
|
8
8
|
COLORS = {
|
9
9
|
:black => "\033[0;30m",
|
@@ -114,7 +114,7 @@ module Fluby
|
|
114
114
|
FileUtils.mkdir_p target_path unless File.exist? target_path
|
115
115
|
@classpath = target_path.split("/").join(".")
|
116
116
|
@classname = name.split(".").last
|
117
|
-
options = options.
|
117
|
+
options = options.map { |i| i = i.split(":") } unless options == {}
|
118
118
|
@opts = options
|
119
119
|
File.open(target_file,"w") do |file|
|
120
120
|
file << ERB.new(File.read("#{template_path}/generators/#{type}")).result(binding)
|
data/lib/templates/generate
CHANGED
@@ -0,0 +1,22 @@
|
|
1
|
+
/**
|
2
|
+
*
|
3
|
+
* Delegate Class, MTASC compatible
|
4
|
+
*
|
5
|
+
**/
|
6
|
+
|
7
|
+
class <%= @classpath %>.<%= @classname %> {
|
8
|
+
public static function create(scope:Object,method:Function):Function{
|
9
|
+
var params:Array = arguments.splice(2,arguments.length-2);
|
10
|
+
var proxyFunc:Function = function():Void{
|
11
|
+
method.apply(scope,arguments.concat(params));
|
12
|
+
}
|
13
|
+
return proxyFunc;
|
14
|
+
}
|
15
|
+
public static function createR(scope:Object,method:Function):Function{
|
16
|
+
var params:Array = arguments.splice(2,arguments.length-2);
|
17
|
+
var proxyFunc:Function = function():Void{
|
18
|
+
method.apply(scope,params.concat(arguments));
|
19
|
+
}
|
20
|
+
return proxyFunc;
|
21
|
+
}
|
22
|
+
}
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bomberstudios-fluby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 0.6.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- "Ale Mu\xC3\xB1oz"
|
@@ -34,6 +34,7 @@ files:
|
|
34
34
|
- lib/templates/swfobject.js
|
35
35
|
- lib/templates/generate
|
36
36
|
- lib/templates/generators/class
|
37
|
+
- lib/templates/generators/delegate
|
37
38
|
- lib/templates/generators/xml_loader
|
38
39
|
has_rdoc: false
|
39
40
|
homepage: http://github.com/bomberstudios/fluby/
|