js2 0.3.7 → 0.3.8
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +5 -0
- data/lib/js2/browser.js +1 -1
- data/lib/js2/js2.js +28 -23
- data/lib/js2/rack.rb +4 -4
- metadata +17 -7
data/CHANGELOG
CHANGED
data/lib/js2/browser.js
CHANGED
data/lib/js2/js2.js
CHANGED
@@ -14,7 +14,7 @@ function mainFunction (arg) {
|
|
14
14
|
|
15
15
|
var JS2 = root.JS2 = mainFunction;
|
16
16
|
var js2 = root.js2 = JS2;
|
17
|
-
js2.VERSION = "0.3.
|
17
|
+
js2.VERSION = "0.3.8";
|
18
18
|
|
19
19
|
JS2.ROOT = JS2;
|
20
20
|
|
@@ -433,9 +433,9 @@ function mainFunction (arg) {
|
|
433
433
|
var mode = 0;
|
434
434
|
for (var i=0; i<str.length; i++) {
|
435
435
|
if (str.charAt(i) == '*') {
|
436
|
-
mode
|
436
|
+
mode = 1;
|
437
437
|
} else if (str.charAt(i) == '/' && mode == 1) {
|
438
|
-
mode
|
438
|
+
mode = 2;
|
439
439
|
} else {
|
440
440
|
mode = 0;
|
441
441
|
}
|
@@ -1262,7 +1262,7 @@ JS2.Class.extend('Config', function(KLASS, OO){
|
|
1262
1262
|
this.recursive = true;
|
1263
1263
|
this.interval = 2;
|
1264
1264
|
this.sourceDir = './app/js2';
|
1265
|
-
this.
|
1265
|
+
this.targetDir = './public/javascripts';
|
1266
1266
|
this.args = [];
|
1267
1267
|
|
1268
1268
|
this.fs = fs;
|
@@ -1294,10 +1294,15 @@ JS2.Class.extend('Config', function(KLASS, OO){
|
|
1294
1294
|
try {
|
1295
1295
|
var config = JSON.parse(this.fs.read(file).replace(/\n\r?/g, ''));
|
1296
1296
|
|
1297
|
+
if (config['out-dir']) {
|
1298
|
+
config['target-dir'] = config['target-dir'] || config['out-dir'];
|
1299
|
+
console.log("Please use target-dir instead of out-dir");
|
1300
|
+
}
|
1301
|
+
|
1297
1302
|
this.format = config.format || this.format;
|
1298
1303
|
this.interval = config['interval'] ? config['interval'] : this.interval;
|
1299
1304
|
this.sourceDir = config['source-dir'] || this.sourceDir;
|
1300
|
-
this.
|
1305
|
+
this.targetDir = config['target-dir'] || this.targetDir;
|
1301
1306
|
this.verbose = ('verbose' in config) ? config['verbose'] : false;
|
1302
1307
|
|
1303
1308
|
this['non-recursive'] = config['non-recursive'];
|
@@ -1318,20 +1323,20 @@ JS2.Class.extend('Commander', function(KLASS, OO){
|
|
1318
1323
|
OO.addMember("BANNER","js2 <command> [options] <arguments>\n" +
|
1319
1324
|
"VERSION: " + JS2.VERSION + "\n" +
|
1320
1325
|
"Commands:\n" +
|
1321
|
-
" * run <file>
|
1322
|
-
" * render <file>
|
1323
|
-
" * compile <
|
1324
|
-
" Options:\n" +
|
1325
|
-
" -n -- Do NOT traverse directories recursively\n" +
|
1326
|
-
" -v -- Verbose \n" +
|
1327
|
-
" -f=<format> -- Compile for different formats: node, ringo, or browser\n" +
|
1328
|
-
" * compile <file> -- Compiles a single js2 file into js\n" +
|
1329
|
-
" * watch <inDir> <outDir> -- Similar to compile, but update will keep looping while watching for modifications\n" +
|
1326
|
+
" * run <file> -- Executes file\n" +
|
1327
|
+
" * render <file> -- Shows JS2 compiled output\n" +
|
1328
|
+
" * compile <source dir> [target dir] -- Compiles a directory and puts js files into target dir. If target dir is not specified, source dir will be used\n" +
|
1330
1329
|
" Options:\n" +
|
1331
|
-
" -n
|
1332
|
-
" -
|
1333
|
-
" -
|
1334
|
-
"
|
1330
|
+
" -n -- Do NOT traverse directories recursively\n" +
|
1331
|
+
" -v -- Verbose \n" +
|
1332
|
+
" -f=<format> -- Compile for different formats: node, ringo, or browser\n" +
|
1333
|
+
" * compile <file> -- Compiles a single js2 file into js\n" +
|
1334
|
+
" * watch <source dir> <target dir> -- Similar to compile, but update will keep looping while watching for modifications\n" +
|
1335
|
+
" Options:\n" +
|
1336
|
+
" -n -- Do NOT traverse directories recursively\n" +
|
1337
|
+
" -f=<format> -- Compile for different formats: node, ringo, or browser\n" +
|
1338
|
+
" -v -- Verbose \n" +
|
1339
|
+
" -i=<seconds> -- Interval time in seconds between loops\n");
|
1335
1340
|
|
1336
1341
|
OO.addMember("initialize",function (argv) {
|
1337
1342
|
this.fs = JS2.fs;
|
@@ -1358,7 +1363,7 @@ JS2.Class.extend('Commander', function(KLASS, OO){
|
|
1358
1363
|
});
|
1359
1364
|
|
1360
1365
|
OO.addMember("render",function () {
|
1361
|
-
|
1366
|
+
console.log(js2.render(this.fs.read(this.config.args[0])));
|
1362
1367
|
});
|
1363
1368
|
|
1364
1369
|
OO.addMember("run",function () {
|
@@ -1376,16 +1381,16 @@ JS2.Class.extend('Commander', function(KLASS, OO){
|
|
1376
1381
|
});
|
1377
1382
|
|
1378
1383
|
OO.addMember("getUpdater",function () {
|
1379
|
-
var inDir
|
1380
|
-
var
|
1381
|
-
return new JS2.Updater(this.fs, inDir,
|
1384
|
+
var inDir = this.config.args[0] || this.config.sourceDir || '.';
|
1385
|
+
var targetDir = this.config.args[1] || this.config.outDir || inDir;
|
1386
|
+
return new JS2.Updater(this.fs, inDir, targetDir, this.config.recursive);
|
1382
1387
|
});
|
1383
1388
|
|
1384
1389
|
OO.addMember("watch",function () {
|
1385
1390
|
var updater = this.getUpdater();
|
1386
1391
|
var self = this;
|
1387
1392
|
var interval = this.config.interval || 2;
|
1388
|
-
JS2.LOGGER.info('
|
1393
|
+
JS2.LOGGER.info('Source Directory:' + updater.inDir + ' -> Target Directory:' + updater.targetDir);
|
1389
1394
|
if (updater.recursive) JS2.LOGGER.info('RECURSIVE');
|
1390
1395
|
|
1391
1396
|
// HACK to get this integrated with ruby
|
data/lib/js2/rack.rb
CHANGED
@@ -7,7 +7,7 @@ module JS2
|
|
7
7
|
|
8
8
|
DEFAULT_CONFIG = {
|
9
9
|
'source_dir' => "#{ROOT}/app/js2",
|
10
|
-
'
|
10
|
+
'target_dir' => "#{ROOT}/public/javascripts",
|
11
11
|
'bin' => (`which js2`.chomp rescue nil),
|
12
12
|
'copy_js2' => true
|
13
13
|
}
|
@@ -18,11 +18,11 @@ module JS2
|
|
18
18
|
config = YAML.load_file(ROOT + '/config/js2.yml') rescue DEFAULT_CONFIG
|
19
19
|
|
20
20
|
@source_dir = config['source_dir'] || './app/js2'
|
21
|
-
@
|
21
|
+
@target_dir = config['target_dir'] || './public/javascripts'
|
22
22
|
@bin = config['bin'] || 'js2'
|
23
23
|
@copy_js2 = config.has_key?('copy_js2') ? config['copy_js2'] : true
|
24
24
|
|
25
|
-
@valid = @source_dir && @
|
25
|
+
@valid = @source_dir && @target_dir && !@bin.blank?
|
26
26
|
|
27
27
|
unless @valid
|
28
28
|
puts "JS2 is not configured properly"
|
@@ -38,7 +38,7 @@ module JS2
|
|
38
38
|
end
|
39
39
|
end
|
40
40
|
|
41
|
-
`#{@bin} compile -f=browser -m #{@source_dir} #{@
|
41
|
+
`#{@bin} compile -f=browser -m #{@source_dir} #{@target_dir}` if @valid
|
42
42
|
@app.call(env)
|
43
43
|
end
|
44
44
|
end
|
metadata
CHANGED
@@ -1,8 +1,12 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: js2
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
prerelease:
|
5
|
-
|
4
|
+
prerelease: false
|
5
|
+
segments:
|
6
|
+
- 0
|
7
|
+
- 3
|
8
|
+
- 8
|
9
|
+
version: 0.3.8
|
6
10
|
platform: ruby
|
7
11
|
authors:
|
8
12
|
- Jeff Su
|
@@ -10,7 +14,7 @@ autorequire:
|
|
10
14
|
bindir: bin
|
11
15
|
cert_chain: []
|
12
16
|
|
13
|
-
date: 2011-03-
|
17
|
+
date: 2011-03-27 00:00:00 -07:00
|
14
18
|
default_executable:
|
15
19
|
dependencies:
|
16
20
|
- !ruby/object:Gem::Dependency
|
@@ -21,6 +25,8 @@ dependencies:
|
|
21
25
|
requirements:
|
22
26
|
- - ">="
|
23
27
|
- !ruby/object:Gem::Version
|
28
|
+
segments:
|
29
|
+
- 0
|
24
30
|
version: "0"
|
25
31
|
type: :runtime
|
26
32
|
version_requirements: *id001
|
@@ -36,11 +42,11 @@ extra_rdoc_files: []
|
|
36
42
|
files:
|
37
43
|
- bin/js2
|
38
44
|
- bin/js2-ruby
|
39
|
-
- lib/js2.rb
|
40
|
-
- lib/js2/context.rb
|
41
|
-
- lib/js2/rack.rb
|
42
45
|
- lib/js2/command.rb
|
46
|
+
- lib/js2/context.rb
|
43
47
|
- lib/js2/fs.rb
|
48
|
+
- lib/js2/rack.rb
|
49
|
+
- lib/js2.rb
|
44
50
|
- lib/js2/browser.js
|
45
51
|
- lib/js2/js2.js
|
46
52
|
- CHANGELOG
|
@@ -58,17 +64,21 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
58
64
|
requirements:
|
59
65
|
- - ">="
|
60
66
|
- !ruby/object:Gem::Version
|
67
|
+
segments:
|
68
|
+
- 0
|
61
69
|
version: "0"
|
62
70
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
63
71
|
none: false
|
64
72
|
requirements:
|
65
73
|
- - ">="
|
66
74
|
- !ruby/object:Gem::Version
|
75
|
+
segments:
|
76
|
+
- 0
|
67
77
|
version: "0"
|
68
78
|
requirements: []
|
69
79
|
|
70
80
|
rubyforge_project:
|
71
|
-
rubygems_version: 1.
|
81
|
+
rubygems_version: 1.3.7
|
72
82
|
signing_key:
|
73
83
|
specification_version: 3
|
74
84
|
summary: Javascript Syntactic Sugar
|