requirejs-rails 0.5.5 → 0.5.6
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/.rvmrc +28 -31
- data/CHANGELOG.md +4 -0
- data/Gemfile.lock +1 -1
- data/bin/r.js +324 -59
- data/lib/requirejs/rails/rjs_driver.js.erb +1 -1
- data/lib/requirejs/rails/version.rb +1 -1
- data/test/requirejs-rails_test.rb +1 -1
- data/vendor/assets/javascripts/require.js +3 -2
- metadata +11 -11
data/.rvmrc
CHANGED
@@ -3,53 +3,50 @@
|
|
3
3
|
# This is an RVM Project .rvmrc file, used to automatically load the ruby
|
4
4
|
# development environment upon cd'ing into the directory
|
5
5
|
|
6
|
-
# First we specify our desired <ruby>[@<gemset>], the @gemset name is optional
|
7
|
-
|
6
|
+
# First we specify our desired <ruby>[@<gemset>], the @gemset name is optional,
|
7
|
+
# Only full ruby name is supported here, for short names use:
|
8
|
+
# echo "rvm use 1.9.3" > .rvmrc
|
9
|
+
environment_id="ruby-1.9.3-p125@requirejs-rails"
|
10
|
+
|
11
|
+
# Uncomment the following lines if you want to verify rvm version per project
|
12
|
+
# rvmrc_rvm_version="1.10.2" # 1.10.1 seams as a safe start
|
13
|
+
# eval "$(echo ${rvm_version}.${rvmrc_rvm_version} | awk -F. '{print "[[ "$1*65536+$2*256+$3" -ge "$4*65536+$5*256+$6" ]]"}' )" || {
|
14
|
+
# echo "This .rvmrc file requires at least RVM ${rvmrc_rvm_version}, aborting loading."
|
15
|
+
# return 1
|
16
|
+
# }
|
8
17
|
|
9
|
-
#
|
10
|
-
# Uncomment following line if you want options to be set only for given project.
|
11
|
-
#
|
12
|
-
# PROJECT_JRUBY_OPTS=( --1.9 )
|
13
|
-
|
14
|
-
#
|
15
18
|
# First we attempt to load the desired environment directly from the environment
|
16
19
|
# file. This is very fast and efficient compared to running through the entire
|
17
20
|
# CLI and selector. If you want feedback on which environment was used then
|
18
21
|
# insert the word 'use' after --create as this triggers verbose mode.
|
19
|
-
|
20
|
-
if [[ -d "${rvm_path:-$HOME/.rvm}/environments" \
|
22
|
+
if [[ -d "${rvm_path:-$HOME/.rvm}/environments"
|
21
23
|
&& -s "${rvm_path:-$HOME/.rvm}/environments/$environment_id" ]]
|
22
24
|
then
|
23
25
|
\. "${rvm_path:-$HOME/.rvm}/environments/$environment_id"
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
26
|
+
[[ -s "${rvm_path:-$HOME/.rvm}/hooks/after_use" ]] &&
|
27
|
+
\. "${rvm_path:-$HOME/.rvm}/hooks/after_use" || true
|
28
|
+
if [[ $- == *i* ]] # check for interactive shells
|
29
|
+
then echo "Using: $(tput setaf 2)$GEM_HOME$(tput sgr0)" # show the user the ruby and gemset they are using in green
|
30
|
+
else echo "Using: $GEM_HOME" # don't use colors in non-interactive shells
|
28
31
|
fi
|
29
32
|
else
|
30
33
|
# If the environment file has not yet been created, use the RVM CLI to select.
|
31
|
-
|
32
|
-
then
|
34
|
+
rvm --create use "$environment_id" || {
|
33
35
|
echo "Failed to create RVM environment '${environment_id}'."
|
34
36
|
return 1
|
35
|
-
|
37
|
+
}
|
36
38
|
fi
|
37
39
|
|
38
|
-
#
|
39
|
-
#
|
40
|
-
#
|
41
|
-
#
|
42
|
-
#
|
43
|
-
# filename=".gems"
|
44
|
-
# if [[ -s "$filename" ]]
|
40
|
+
# If you use bundler, this might be useful to you:
|
41
|
+
# if [[ -s Gemfile ]] && {
|
42
|
+
# ! builtin command -v bundle >/dev/null ||
|
43
|
+
# builtin command -v bundle | grep $rvm_path/bin/bundle >/dev/null
|
44
|
+
# }
|
45
45
|
# then
|
46
|
-
#
|
46
|
+
# printf "%b" "The rubygem 'bundler' is not installed. Installing it now.\n"
|
47
|
+
# gem install bundler
|
47
48
|
# fi
|
48
|
-
|
49
|
-
# If you use bundler, this might be useful to you:
|
50
|
-
# if command -v bundle && [[ -s Gemfile ]]
|
49
|
+
# if [[ -s Gemfile ]] && builtin command -v bundle >/dev/null
|
51
50
|
# then
|
52
|
-
# bundle install
|
51
|
+
# bundle install | grep -vE '^Using|Your bundle is complete'
|
53
52
|
# fi
|
54
|
-
|
55
|
-
|
data/CHANGELOG.md
CHANGED
data/Gemfile.lock
CHANGED
data/bin/r.js
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
/**
|
2
|
-
* @license r.js 1.0.
|
2
|
+
* @license r.js 1.0.7 Copyright (c) 2010-2012, The Dojo Foundation All Rights Reserved.
|
3
3
|
* Available via the MIT or new BSD license.
|
4
4
|
* see: http://github.com/jrburke/requirejs for details
|
5
5
|
*/
|
@@ -20,7 +20,7 @@ var requirejs, require, define;
|
|
20
20
|
|
21
21
|
var fileName, env, fs, vm, path, exec, rhinoContext, dir, nodeRequire,
|
22
22
|
nodeDefine, exists, reqMain, loadedOptimizedLib,
|
23
|
-
version = '1.0.
|
23
|
+
version = '1.0.7',
|
24
24
|
jsSuffixRegExp = /\.js$/,
|
25
25
|
commandOption = '',
|
26
26
|
useLibLoaded = {},
|
@@ -102,7 +102,7 @@ var requirejs, require, define;
|
|
102
102
|
}
|
103
103
|
|
104
104
|
/** vim: et:ts=4:sw=4:sts=4
|
105
|
-
* @license RequireJS 1.0.
|
105
|
+
* @license RequireJS 1.0.7 Copyright (c) 2010-2012, The Dojo Foundation All Rights Reserved.
|
106
106
|
* Available via the MIT or new BSD license.
|
107
107
|
* see: http://github.com/jrburke/requirejs for details
|
108
108
|
*/
|
@@ -112,7 +112,7 @@ var requirejs, require, define;
|
|
112
112
|
|
113
113
|
(function () {
|
114
114
|
//Change this version number for each release.
|
115
|
-
var version = "1.0.
|
115
|
+
var version = "1.0.7",
|
116
116
|
commentRegExp = /(\/\*([\s\S]*?)\*\/|([^:]|^)\/\/(.*)$)/mg,
|
117
117
|
cjsRequireRegExp = /require\(\s*["']([^'"\s]+)["']\s*\)/g,
|
118
118
|
currDirRegExp = /^\.\//,
|
@@ -1156,6 +1156,7 @@ var requirejs, require, define;
|
|
1156
1156
|
err = makeError("timeout", "Load timeout for modules: " + noLoads);
|
1157
1157
|
err.requireType = "timeout";
|
1158
1158
|
err.requireModules = noLoads;
|
1159
|
+
err.contextName = context.contextName;
|
1159
1160
|
return req.onError(err);
|
1160
1161
|
}
|
1161
1162
|
|
@@ -2976,15 +2977,17 @@ define('rhino/file', function () {
|
|
2976
2977
|
* see: http://github.com/jrburke/requirejs for details
|
2977
2978
|
*/
|
2978
2979
|
|
2979
|
-
/*jslint plusplus:
|
2980
|
-
/*global define
|
2980
|
+
/*jslint plusplus: true */
|
2981
|
+
/*global define */
|
2981
2982
|
|
2982
2983
|
define('lang', function () {
|
2984
|
+
'use strict';
|
2985
|
+
|
2983
2986
|
var lang = {
|
2984
2987
|
backSlashRegExp: /\\/g,
|
2985
2988
|
ostring: Object.prototype.toString,
|
2986
2989
|
|
2987
|
-
isArray: Array.isArray
|
2990
|
+
isArray: Array.isArray || function (it) {
|
2988
2991
|
return lang.ostring.call(it) === "[object Array]";
|
2989
2992
|
},
|
2990
2993
|
|
@@ -2996,19 +2999,36 @@ define('lang', function () {
|
|
2996
2999
|
return it && it instanceof RegExp;
|
2997
3000
|
},
|
2998
3001
|
|
3002
|
+
_mixin: function(dest, source, override){
|
3003
|
+
var name;
|
3004
|
+
for (name in source) {
|
3005
|
+
if(source.hasOwnProperty(name)
|
3006
|
+
&& (override || !dest.hasOwnProperty(name))) {
|
3007
|
+
dest[name] = source[name];
|
3008
|
+
}
|
3009
|
+
}
|
3010
|
+
|
3011
|
+
return dest; // Object
|
3012
|
+
},
|
3013
|
+
|
2999
3014
|
/**
|
3000
|
-
*
|
3001
|
-
*
|
3015
|
+
* mixin({}, obj1, obj2) is allowed. If the last argument is a boolean,
|
3016
|
+
* then the source objects properties are force copied over to dest.
|
3002
3017
|
*/
|
3003
|
-
mixin: function
|
3004
|
-
|
3005
|
-
|
3006
|
-
|
3007
|
-
|
3008
|
-
|
3009
|
-
|
3010
|
-
|
3018
|
+
mixin: function(dest){
|
3019
|
+
var parameters = Array.prototype.slice.call(arguments),
|
3020
|
+
override, i, l;
|
3021
|
+
|
3022
|
+
if (!dest) { dest = {}; }
|
3023
|
+
|
3024
|
+
if (parameters.length > 2 && typeof arguments[parameters.length-1] === 'boolean') {
|
3025
|
+
override = parameters.pop();
|
3011
3026
|
}
|
3027
|
+
|
3028
|
+
for (i = 1, l = parameters.length; i < l; i++) {
|
3029
|
+
lang._mixin(dest, parameters[i], override);
|
3030
|
+
}
|
3031
|
+
return dest; // Object
|
3012
3032
|
},
|
3013
3033
|
|
3014
3034
|
delegate: (function () {
|
@@ -6577,7 +6597,7 @@ module.exports = uglify
|
|
6577
6597
|
/*jslint plusplus: false, strict: false */
|
6578
6598
|
/*global define: false */
|
6579
6599
|
|
6580
|
-
define('parse', ['uglifyjs/index'], function (uglify) {
|
6600
|
+
define('parse', ['./uglifyjs/index'], function (uglify) {
|
6581
6601
|
var parser = uglify.parser,
|
6582
6602
|
processor = uglify.uglify,
|
6583
6603
|
ostring = Object.prototype.toString,
|
@@ -7002,7 +7022,7 @@ define('parse', ['uglifyjs/index'], function (uglify) {
|
|
7002
7022
|
* @returns {Array} an array of dependency strings. The dependencies
|
7003
7023
|
* have not been normalized, they may be relative IDs.
|
7004
7024
|
*/
|
7005
|
-
parse.findDependencies = function (fileName, fileContents) {
|
7025
|
+
parse.findDependencies = function (fileName, fileContents, options) {
|
7006
7026
|
//This is a litle bit inefficient, it ends up with two uglifyjs parser
|
7007
7027
|
//calls. Can revisit later, but trying to build out larger functional
|
7008
7028
|
//pieces first.
|
@@ -7019,11 +7039,134 @@ define('parse', ['uglifyjs/index'], function (uglify) {
|
|
7019
7039
|
if ((deps = getValidDeps(deps))) {
|
7020
7040
|
dependencies = dependencies.concat(deps);
|
7021
7041
|
}
|
7042
|
+
}, options);
|
7043
|
+
|
7044
|
+
return dependencies;
|
7045
|
+
};
|
7046
|
+
|
7047
|
+
/**
|
7048
|
+
* Finds only CJS dependencies, ones that are the form require('stringLiteral')
|
7049
|
+
*/
|
7050
|
+
parse.findCjsDependencies = function (fileName, fileContents, options) {
|
7051
|
+
//This is a litle bit inefficient, it ends up with two uglifyjs parser
|
7052
|
+
//calls. Can revisit later, but trying to build out larger functional
|
7053
|
+
//pieces first.
|
7054
|
+
var dependencies = [],
|
7055
|
+
astRoot = parser.parse(fileContents);
|
7056
|
+
|
7057
|
+
parse.recurse(astRoot, function (dep) {
|
7058
|
+
dependencies.push(dep);
|
7059
|
+
}, options, function (node, onMatch) {
|
7060
|
+
|
7061
|
+
var call, args;
|
7062
|
+
|
7063
|
+
if (!isArray(node)) {
|
7064
|
+
return false;
|
7065
|
+
}
|
7066
|
+
|
7067
|
+
if (node[0] === 'call') {
|
7068
|
+
call = node[1];
|
7069
|
+
args = node[2];
|
7070
|
+
|
7071
|
+
if (call) {
|
7072
|
+
//A require('') use.
|
7073
|
+
if (call[0] === 'name' && call[1] === 'require' &&
|
7074
|
+
args[0][0] === 'string') {
|
7075
|
+
return onMatch(args[0][1]);
|
7076
|
+
}
|
7077
|
+
}
|
7078
|
+
}
|
7079
|
+
|
7080
|
+
return false;
|
7081
|
+
|
7022
7082
|
});
|
7023
7083
|
|
7024
7084
|
return dependencies;
|
7025
7085
|
};
|
7026
7086
|
|
7087
|
+
/**
|
7088
|
+
* Determines if define(), require({}|[]) or requirejs was called in the
|
7089
|
+
* file. Also finds out if define() is declared and if define.amd is called.
|
7090
|
+
*/
|
7091
|
+
parse.usesAmdOrRequireJs = function (fileName, fileContents, options) {
|
7092
|
+
var astRoot = parser.parse(fileContents),
|
7093
|
+
uses;
|
7094
|
+
|
7095
|
+
parse.recurse(astRoot, function (prop) {
|
7096
|
+
if (!uses) {
|
7097
|
+
uses = {};
|
7098
|
+
}
|
7099
|
+
uses[prop] = true;
|
7100
|
+
}, options, parse.findAmdOrRequireJsNode);
|
7101
|
+
|
7102
|
+
return uses;
|
7103
|
+
};
|
7104
|
+
|
7105
|
+
/**
|
7106
|
+
* Determines if require(''), exports.x =, module.exports =,
|
7107
|
+
* __dirname, __filename are used. So, not strictly traditional CommonJS,
|
7108
|
+
* also checks for Node variants.
|
7109
|
+
*/
|
7110
|
+
parse.usesCommonJs = function (fileName, fileContents, options) {
|
7111
|
+
var uses = null,
|
7112
|
+
assignsExports = false,
|
7113
|
+
astRoot = parser.parse(fileContents);
|
7114
|
+
|
7115
|
+
parse.recurse(astRoot, function (prop) {
|
7116
|
+
if (prop === 'varExports') {
|
7117
|
+
assignsExports = true;
|
7118
|
+
} else if (prop !== 'exports' || !assignsExports) {
|
7119
|
+
if (!uses) {
|
7120
|
+
uses = {};
|
7121
|
+
}
|
7122
|
+
uses[prop] = true;
|
7123
|
+
}
|
7124
|
+
}, options, function (node, onMatch) {
|
7125
|
+
|
7126
|
+
var call, args;
|
7127
|
+
|
7128
|
+
if (!isArray(node)) {
|
7129
|
+
return false;
|
7130
|
+
}
|
7131
|
+
|
7132
|
+
if (node[0] === 'name' && (node[1] === '__dirname' || node[1] === '__filename')) {
|
7133
|
+
return onMatch(node[1].substring(2));
|
7134
|
+
} else if (node[0] === 'var' && node[1] && node[1][0] && node[1][0][0] === 'exports') {
|
7135
|
+
//Hmm, a variable assignment for exports, so does not use cjs exports.
|
7136
|
+
return onMatch('varExports');
|
7137
|
+
} else if (node[0] === 'assign' && node[2] && node[2][0] === 'dot') {
|
7138
|
+
args = node[2][1];
|
7139
|
+
|
7140
|
+
if (args) {
|
7141
|
+
//An exports or module.exports assignment.
|
7142
|
+
if (args[0] === 'name' && args[1] === 'module' &&
|
7143
|
+
node[2][2] === 'exports') {
|
7144
|
+
return onMatch('moduleExports');
|
7145
|
+
} else if (args[0] === 'name' && args[1] === 'exports') {
|
7146
|
+
return onMatch('exports');
|
7147
|
+
}
|
7148
|
+
}
|
7149
|
+
} else if (node[0] === 'call') {
|
7150
|
+
call = node[1];
|
7151
|
+
args = node[2];
|
7152
|
+
|
7153
|
+
if (call) {
|
7154
|
+
//A require('') use.
|
7155
|
+
if (call[0] === 'name' && call[1] === 'require' &&
|
7156
|
+
args[0][0] === 'string') {
|
7157
|
+
return onMatch('require');
|
7158
|
+
}
|
7159
|
+
}
|
7160
|
+
}
|
7161
|
+
|
7162
|
+
return false;
|
7163
|
+
|
7164
|
+
});
|
7165
|
+
|
7166
|
+
return uses;
|
7167
|
+
};
|
7168
|
+
|
7169
|
+
|
7027
7170
|
parse.findRequireDepNames = function (node, deps) {
|
7028
7171
|
var moduleName, i, n, call, args;
|
7029
7172
|
|
@@ -7181,6 +7324,54 @@ define('parse', ['uglifyjs/index'], function (uglify) {
|
|
7181
7324
|
return false;
|
7182
7325
|
};
|
7183
7326
|
|
7327
|
+
/**
|
7328
|
+
* Looks for define(), require({} || []), requirejs({} || []) calls.
|
7329
|
+
*/
|
7330
|
+
parse.findAmdOrRequireJsNode = function (node, onMatch) {
|
7331
|
+
var call, args, configNode, type;
|
7332
|
+
|
7333
|
+
if (!isArray(node)) {
|
7334
|
+
return false;
|
7335
|
+
}
|
7336
|
+
|
7337
|
+
if (node[0] === 'defun' && node[1] === 'define') {
|
7338
|
+
type = 'declaresDefine';
|
7339
|
+
} else if (node[0] === 'assign' && node[2] && node[2][2] === 'amd' &&
|
7340
|
+
node[2][1] && node[2][1][0] === 'name' &&
|
7341
|
+
node[2][1][1] === 'define') {
|
7342
|
+
type = 'defineAmd';
|
7343
|
+
} else if (node[0] === 'call') {
|
7344
|
+
call = node[1];
|
7345
|
+
args = node[2];
|
7346
|
+
|
7347
|
+
if (call) {
|
7348
|
+
if ((call[0] === 'dot' &&
|
7349
|
+
(call[1] && call[1][0] === 'name' &&
|
7350
|
+
(call[1][1] === 'require' || call[1][1] === 'requirejs')) &&
|
7351
|
+
call[2] === 'config')) {
|
7352
|
+
//A require.config() or requirejs.config() call.
|
7353
|
+
type = call[1][1] + 'Config';
|
7354
|
+
} else if (call[0] === 'name' &&
|
7355
|
+
(call[1] === 'require' || call[1] === 'requirejs')) {
|
7356
|
+
//A require() or requirejs() config call.
|
7357
|
+
//Only want ones that start with an object or an array.
|
7358
|
+
configNode = args[0];
|
7359
|
+
if (configNode[0] === 'object' || configNode[0] === 'array') {
|
7360
|
+
type = call[1];
|
7361
|
+
}
|
7362
|
+
} else if (call[0] === 'name' && call[1] === 'define') {
|
7363
|
+
//A define call.
|
7364
|
+
type = 'define';
|
7365
|
+
}
|
7366
|
+
}
|
7367
|
+
}
|
7368
|
+
|
7369
|
+
if (type) {
|
7370
|
+
return onMatch(type);
|
7371
|
+
}
|
7372
|
+
|
7373
|
+
return false;
|
7374
|
+
};
|
7184
7375
|
|
7185
7376
|
/**
|
7186
7377
|
* Determines if a specific node is a valid require/requirejs config
|
@@ -7616,7 +7807,7 @@ define('rhino/optimize', ['logger'], function (logger) {
|
|
7616
7807
|
* see: http://github.com/jrburke/requirejs for details
|
7617
7808
|
*/
|
7618
7809
|
|
7619
|
-
/*jslint plusplus: false, nomen: false, regexp: false
|
7810
|
+
/*jslint plusplus: false, nomen: false, regexp: false */
|
7620
7811
|
/*global define: false */
|
7621
7812
|
|
7622
7813
|
define('optimize', [ 'lang', 'logger', 'env!env/optimize', 'env!env/file', 'parse',
|
@@ -7700,6 +7891,9 @@ function (lang, logger, envOptimize, file, parse,
|
|
7700
7891
|
//If no slash, so must be just a file name. Use empty string then.
|
7701
7892
|
importPath = (importEndIndex !== -1) ? importFileName.substring(0, importEndIndex + 1) : "";
|
7702
7893
|
|
7894
|
+
//fix url() on relative import (#5)
|
7895
|
+
importPath = importPath.replace(/^\.\//, '');
|
7896
|
+
|
7703
7897
|
//Modify URL paths to match the path represented by this file.
|
7704
7898
|
importContents = importContents.replace(cssUrlRegExp, function (fullMatch, urlMatch) {
|
7705
7899
|
fixedUrlMatch = cleanCssUrlQuotes(urlMatch);
|
@@ -7760,11 +7954,37 @@ function (lang, logger, envOptimize, file, parse,
|
|
7760
7954
|
var parts = (config.optimize + "").split('.'),
|
7761
7955
|
optimizerName = parts[0],
|
7762
7956
|
keepLines = parts[1] === 'keepLines',
|
7763
|
-
|
7764
|
-
fileContents, optFunc, match, comment;
|
7957
|
+
fileContents;
|
7765
7958
|
|
7766
7959
|
fileContents = file.readFile(fileName);
|
7767
7960
|
|
7961
|
+
fileContents = optimize.js(fileName, fileContents, optimizerName,
|
7962
|
+
keepLines, config, pluginCollector);
|
7963
|
+
|
7964
|
+
file.saveUtf8File(outFileName, fileContents);
|
7965
|
+
},
|
7966
|
+
|
7967
|
+
/**
|
7968
|
+
* Optimizes a file that contains JavaScript content. Optionally collects
|
7969
|
+
* plugin resources mentioned in a file, and then passes the content
|
7970
|
+
* through an minifier if one is specified via config.optimize.
|
7971
|
+
*
|
7972
|
+
* @param {String} fileName the name of the file that matches the
|
7973
|
+
* fileContents.
|
7974
|
+
* @param {String} fileContents the string of JS to optimize.
|
7975
|
+
* @param {String} [optimizerName] optional name of the optimizer to
|
7976
|
+
* use. 'uglify' is default.
|
7977
|
+
* @param {Boolean} [keepLines] whether to keep line returns in the optimization.
|
7978
|
+
* @param {Object} [config] the build config object.
|
7979
|
+
* @param {Array} [pluginCollector] storage for any plugin resources
|
7980
|
+
* found.
|
7981
|
+
*/
|
7982
|
+
js: function (fileName, fileContents, optimizerName, keepLines, config, pluginCollector) {
|
7983
|
+
var licenseContents = '',
|
7984
|
+
optFunc, match, comment;
|
7985
|
+
|
7986
|
+
config = config || {};
|
7987
|
+
|
7768
7988
|
//Apply pragmas/namespace renaming
|
7769
7989
|
fileContents = pragma.process(fileName, fileContents, config, 'OnSave', pluginCollector);
|
7770
7990
|
|
@@ -7794,7 +8014,7 @@ function (lang, logger, envOptimize, file, parse,
|
|
7794
8014
|
config[optimizerName]);
|
7795
8015
|
}
|
7796
8016
|
|
7797
|
-
|
8017
|
+
return fileContents;
|
7798
8018
|
},
|
7799
8019
|
|
7800
8020
|
/**
|
@@ -7887,7 +8107,8 @@ function (lang, logger, envOptimize, file, parse,
|
|
7887
8107
|
};
|
7888
8108
|
|
7889
8109
|
return optimize;
|
7890
|
-
})
|
8110
|
+
});
|
8111
|
+
/**
|
7891
8112
|
* @license RequireJS Copyright (c) 2010-2011, The Dojo Foundation All Rights Reserved.
|
7892
8113
|
* Available via the MIT or new BSD license.
|
7893
8114
|
* see: http://github.com/jrburke/requirejs for details
|
@@ -7978,13 +8199,13 @@ function (file, pragma, parse) {
|
|
7978
8199
|
* @returns {Boolean}
|
7979
8200
|
*/
|
7980
8201
|
require._isSupportedBuildUrl = function (url) {
|
7981
|
-
//Ignore URLs with protocols or question marks, means either network
|
8202
|
+
//Ignore URLs with protocols, hosts or question marks, means either network
|
7982
8203
|
//access is needed to fetch it or it is too dynamic. Note that
|
7983
8204
|
//on Windows, full paths are used for some urls, which include
|
7984
8205
|
//the drive, like c:/something, so need to test for something other
|
7985
8206
|
//than just a colon.
|
7986
8207
|
return url.indexOf("://") === -1 && url.indexOf("?") === -1 &&
|
7987
|
-
url.indexOf('empty:') !== 0;
|
8208
|
+
url.indexOf('empty:') !== 0 && url.indexOf('//') !== 0;
|
7988
8209
|
};
|
7989
8210
|
|
7990
8211
|
//Override define() to catch modules that just define an object, so that
|
@@ -8023,15 +8244,15 @@ function (file, pragma, parse) {
|
|
8023
8244
|
/*jslint evil: true */
|
8024
8245
|
var contents, pluginBuilderMatch, builderName;
|
8025
8246
|
|
8026
|
-
//Adjust the URL if it was not transformed to use baseUrl.
|
8027
|
-
url = normalizeUrlWithBase(context, moduleName, url);
|
8028
|
-
|
8029
8247
|
context.scriptCount += 1;
|
8030
8248
|
|
8031
8249
|
//Only handle urls that can be inlined, so that means avoiding some
|
8032
8250
|
//URLs like ones that require network access or may be too dynamic,
|
8033
8251
|
//like JSONP
|
8034
8252
|
if (require._isSupportedBuildUrl(url)) {
|
8253
|
+
//Adjust the URL if it was not transformed to use baseUrl.
|
8254
|
+
url = normalizeUrlWithBase(context, moduleName, url);
|
8255
|
+
|
8035
8256
|
//Save the module name to path and path to module name mappings.
|
8036
8257
|
layer.buildPathMap[moduleName] = url;
|
8037
8258
|
layer.buildFileToModule[url] = moduleName;
|
@@ -8049,6 +8270,12 @@ function (file, pragma, parse) {
|
|
8049
8270
|
//Load the file contents, process for conditionals, then
|
8050
8271
|
//evaluate it.
|
8051
8272
|
contents = file.readFile(url);
|
8273
|
+
|
8274
|
+
//If there is a read filter, run it now.
|
8275
|
+
if (context.config.onBuildRead) {
|
8276
|
+
contents = context.config.onBuildRead(moduleName, url, contents);
|
8277
|
+
}
|
8278
|
+
|
8052
8279
|
contents = pragma.process(url, contents, context.config, 'OnExecute');
|
8053
8280
|
|
8054
8281
|
//Find out if the file contains a require() definition. Need to know
|
@@ -8341,14 +8568,16 @@ define('commonJs', ['env!env/file', 'uglifyjs/index'], function (file, uglify) {
|
|
8341
8568
|
* see: http://github.com/jrburke/requirejs for details
|
8342
8569
|
*/
|
8343
8570
|
|
8344
|
-
/*jslint
|
8345
|
-
/*global define
|
8571
|
+
/*jslint plusplus: true, nomen: true */
|
8572
|
+
/*global define, require */
|
8346
8573
|
|
8347
8574
|
|
8348
8575
|
define('build', [ 'lang', 'logger', 'env!env/file', 'parse', 'optimize', 'pragma',
|
8349
8576
|
'env!env/load', 'requirePatch'],
|
8350
8577
|
function (lang, logger, file, parse, optimize, pragma,
|
8351
8578
|
load, requirePatch) {
|
8579
|
+
'use strict';
|
8580
|
+
|
8352
8581
|
var build, buildBaseConfig,
|
8353
8582
|
endsWithSemiColonRegExp = /;\s*$/;
|
8354
8583
|
|
@@ -8388,7 +8617,7 @@ function (lang, logger, file, parse, optimize, pragma,
|
|
8388
8617
|
* sure to allow absolute paths on Windows, like C:\directory.
|
8389
8618
|
*/
|
8390
8619
|
function disallowUrls(path) {
|
8391
|
-
if (path.indexOf('://') !== -1 && path !== 'empty:') {
|
8620
|
+
if ((path.indexOf('://') !== -1 || path.indexOf('//') === 0) && path !== 'empty:') {
|
8392
8621
|
throw new Error('Path is not supported: ' + path +
|
8393
8622
|
'\nOptimizer can only handle' +
|
8394
8623
|
' local paths. Download the locally if necessary' +
|
@@ -8498,8 +8727,13 @@ function (lang, logger, file, parse, optimize, pragma,
|
|
8498
8727
|
//Adjust baseUrl if config.appDir is in play, and set up build output paths.
|
8499
8728
|
buildPaths = {};
|
8500
8729
|
if (config.appDir) {
|
8501
|
-
//All the paths should be inside the appDir
|
8502
|
-
|
8730
|
+
//All the paths should be inside the appDir, so just adjust
|
8731
|
+
//the paths to use the dirBaseUrl
|
8732
|
+
for (prop in paths) {
|
8733
|
+
if (paths.hasOwnProperty(prop)) {
|
8734
|
+
buildPaths[prop] = paths[prop].replace(config.baseUrl, config.dirBaseUrl);
|
8735
|
+
}
|
8736
|
+
}
|
8503
8737
|
} else {
|
8504
8738
|
//If no appDir, then make sure to copy the other paths to this directory.
|
8505
8739
|
for (prop in paths) {
|
@@ -8869,7 +9103,7 @@ function (lang, logger, file, parse, optimize, pragma,
|
|
8869
9103
|
* to the absFilePath passed in.
|
8870
9104
|
*/
|
8871
9105
|
build.makeAbsConfig = function (config, absFilePath) {
|
8872
|
-
var props, prop, i
|
9106
|
+
var props, prop, i;
|
8873
9107
|
|
8874
9108
|
props = ["appDir", "dir", "baseUrl"];
|
8875
9109
|
for (i = 0; (prop = props[i]); i++) {
|
@@ -8877,24 +9111,17 @@ function (lang, logger, file, parse, optimize, pragma,
|
|
8877
9111
|
//Add abspath if necessary, make sure these paths end in
|
8878
9112
|
//slashes
|
8879
9113
|
if (prop === "baseUrl") {
|
8880
|
-
originalBaseUrl = config.baseUrl;
|
9114
|
+
config.originalBaseUrl = config.baseUrl;
|
8881
9115
|
if (config.appDir) {
|
8882
9116
|
//If baseUrl with an appDir, the baseUrl is relative to
|
8883
9117
|
//the appDir, *not* the absFilePath. appDir and dir are
|
8884
9118
|
//made absolute before baseUrl, so this will work.
|
8885
|
-
config.baseUrl = build.makeAbsPath(originalBaseUrl, config.appDir);
|
8886
|
-
//Set up dir output baseUrl.
|
8887
|
-
config.dirBaseUrl = build.makeAbsPath(originalBaseUrl, config.dir);
|
9119
|
+
config.baseUrl = build.makeAbsPath(config.originalBaseUrl, config.appDir);
|
8888
9120
|
} else {
|
8889
9121
|
//The dir output baseUrl is same as regular baseUrl, both
|
8890
9122
|
//relative to the absFilePath.
|
8891
9123
|
config.baseUrl = build.makeAbsPath(config[prop], absFilePath);
|
8892
|
-
config.dirBaseUrl = config.dir || config.baseUrl;
|
8893
9124
|
}
|
8894
|
-
|
8895
|
-
//Make sure dirBaseUrl ends in a slash, since it is
|
8896
|
-
//concatenated with other strings.
|
8897
|
-
config.dirBaseUrl = endsWithSlash(config.dirBaseUrl);
|
8898
9125
|
} else {
|
8899
9126
|
config[prop] = build.makeAbsPath(config[prop], absFilePath);
|
8900
9127
|
}
|
@@ -8940,12 +9167,9 @@ function (lang, logger, file, parse, optimize, pragma,
|
|
8940
9167
|
if (typeof value === 'object' && value &&
|
8941
9168
|
!lang.isArray(value) && !lang.isFunction(value) &&
|
8942
9169
|
!lang.isRegExp(value)) {
|
8943
|
-
|
8944
|
-
target[prop] = {};
|
8945
|
-
}
|
8946
|
-
lang.mixin(target[prop], source[prop], true);
|
9170
|
+
target[prop] = lang.mixin({}, target[prop], value, true);
|
8947
9171
|
} else {
|
8948
|
-
target[prop] =
|
9172
|
+
target[prop] = value;
|
8949
9173
|
}
|
8950
9174
|
}
|
8951
9175
|
}
|
@@ -8967,12 +9191,13 @@ function (lang, logger, file, parse, optimize, pragma,
|
|
8967
9191
|
var config = {}, buildFileContents, buildFileConfig, mainConfig,
|
8968
9192
|
mainConfigFile, prop, buildFile, absFilePath;
|
8969
9193
|
|
8970
|
-
lang.mixin(config, buildBaseConfig);
|
8971
|
-
lang.mixin(config, cfg, true);
|
8972
|
-
|
8973
9194
|
//Make sure all paths are relative to current directory.
|
8974
9195
|
absFilePath = file.absPath('.');
|
8975
|
-
build.makeAbsConfig(
|
9196
|
+
build.makeAbsConfig(cfg, absFilePath);
|
9197
|
+
build.makeAbsConfig(buildBaseConfig, absFilePath);
|
9198
|
+
|
9199
|
+
lang.mixin(config, buildBaseConfig);
|
9200
|
+
lang.mixin(config, cfg, true);
|
8976
9201
|
|
8977
9202
|
if (config.buildFile) {
|
8978
9203
|
//A build file exists, load it to get more config.
|
@@ -9034,6 +9259,19 @@ function (lang, logger, file, parse, optimize, pragma,
|
|
9034
9259
|
//args should take precedence over build file values.
|
9035
9260
|
mixConfig(config, cfg);
|
9036
9261
|
|
9262
|
+
|
9263
|
+
//Set final output dir
|
9264
|
+
if (config.hasOwnProperty("baseUrl")) {
|
9265
|
+
if (config.appDir) {
|
9266
|
+
config.dirBaseUrl = build.makeAbsPath(config.originalBaseUrl, config.dir);
|
9267
|
+
} else {
|
9268
|
+
config.dirBaseUrl = config.dir || config.baseUrl;
|
9269
|
+
}
|
9270
|
+
//Make sure dirBaseUrl ends in a slash, since it is
|
9271
|
+
//concatenated with other strings.
|
9272
|
+
config.dirBaseUrl = endsWithSlash(config.dirBaseUrl);
|
9273
|
+
}
|
9274
|
+
|
9037
9275
|
//Check for errors in config
|
9038
9276
|
if (config.cssIn && !config.out) {
|
9039
9277
|
throw new Error("ERROR: 'out' option missing.");
|
@@ -9042,7 +9280,15 @@ function (lang, logger, file, parse, optimize, pragma,
|
|
9042
9280
|
throw new Error("ERROR: 'baseUrl' option missing.");
|
9043
9281
|
}
|
9044
9282
|
if (!config.out && !config.dir) {
|
9045
|
-
throw new Error('Missing either an "out" or "dir" config value.'
|
9283
|
+
throw new Error('Missing either an "out" or "dir" config value. ' +
|
9284
|
+
'If using "appDir" for a full project optimization, ' +
|
9285
|
+
'use "dir". If you want to optimize to one file, ' +
|
9286
|
+
'use "out".');
|
9287
|
+
}
|
9288
|
+
if (config.appDir && config.out) {
|
9289
|
+
throw new Error('"appDir" is not compatible with "out". Use "dir" ' +
|
9290
|
+
'instead. appDir is used to copy whole projects, ' +
|
9291
|
+
'where "out" is used to just optimize to one file.');
|
9046
9292
|
}
|
9047
9293
|
if (config.out && config.dir) {
|
9048
9294
|
throw new Error('The "out" and "dir" options are incompatible.' +
|
@@ -9051,10 +9297,11 @@ function (lang, logger, file, parse, optimize, pragma,
|
|
9051
9297
|
' or baseUrl directories optimized.');
|
9052
9298
|
}
|
9053
9299
|
|
9054
|
-
if (config.
|
9055
|
-
//Just one file
|
9056
|
-
|
9057
|
-
//
|
9300
|
+
if ((config.name || config.include) && !config.modules) {
|
9301
|
+
//Just need to build one file, but may be part of a whole appDir/
|
9302
|
+
//baseUrl copy, but specified on the command line, so cannot do
|
9303
|
+
//the modules array setup. So create a modules section in that
|
9304
|
+
//case.
|
9058
9305
|
config.modules = [
|
9059
9306
|
{
|
9060
9307
|
name: config.name,
|
@@ -9064,6 +9311,10 @@ function (lang, logger, file, parse, optimize, pragma,
|
|
9064
9311
|
excludeShallow: config.excludeShallow
|
9065
9312
|
}
|
9066
9313
|
];
|
9314
|
+
}
|
9315
|
+
|
9316
|
+
if (config.out && !config.cssIn) {
|
9317
|
+
//Just one file to optimize.
|
9067
9318
|
|
9068
9319
|
//Does not have a build file, so set up some defaults.
|
9069
9320
|
//Optimizing CSS should not be allowed, unless explicitly
|
@@ -9281,23 +9532,37 @@ function (lang, logger, file, parse, optimize, pragma,
|
|
9281
9532
|
if (builder.write) {
|
9282
9533
|
writeApi = function (input) {
|
9283
9534
|
fileContents += "\n" + addSemiColon(input);
|
9535
|
+
if (config.onBuildWrite) {
|
9536
|
+
fileContents = config.onBuildWrite(moduleName, path, fileContents);
|
9537
|
+
}
|
9284
9538
|
};
|
9285
9539
|
writeApi.asModule = function (moduleName, input) {
|
9286
9540
|
fileContents += "\n" +
|
9287
9541
|
addSemiColon(
|
9288
9542
|
build.toTransport(anonDefRegExp, namespace, moduleName, path, input, layer));
|
9543
|
+
if (config.onBuildWrite) {
|
9544
|
+
fileContents = config.onBuildWrite(moduleName, path, fileContents);
|
9545
|
+
}
|
9289
9546
|
};
|
9290
9547
|
builder.write(parts.prefix, parts.name, writeApi);
|
9291
9548
|
}
|
9292
9549
|
} else {
|
9293
9550
|
currContents = file.readFile(path);
|
9294
9551
|
|
9552
|
+
if (config.onBuildRead) {
|
9553
|
+
currContents = config.onBuildRead(moduleName, path, currContents);
|
9554
|
+
}
|
9555
|
+
|
9295
9556
|
if (config.namespace) {
|
9296
9557
|
currContents = pragma.namespace(currContents, config.namespace);
|
9297
9558
|
}
|
9298
9559
|
|
9299
9560
|
currContents = build.toTransport(anonDefRegExp, namespace, moduleName, path, currContents, layer);
|
9300
9561
|
|
9562
|
+
if (config.onBuildWrite) {
|
9563
|
+
currContents = config.onBuildWrite(moduleName, path, currContents);
|
9564
|
+
}
|
9565
|
+
|
9301
9566
|
//Semicolon is for files that are not well formed when
|
9302
9567
|
//concatenated with other content.
|
9303
9568
|
fileContents += "\n" + addSemiColon(currContents);
|
@@ -9345,7 +9610,7 @@ function (lang, logger, file, parse, optimize, pragma,
|
|
9345
9610
|
//define(\n//begin v1.x content
|
9346
9611
|
//for a comment.
|
9347
9612
|
return new RegExp('(^|[^\\.])(' + (namespace || '').replace(/\./g, '\\.') +
|
9348
|
-
'define|define)\\s*\\(\\s*(\\/\\/[^\\n\\r]*[\\r\\n])?(\\[|function|[\\w\\d_
|
9613
|
+
'define|define)\\s*\\(\\s*(\\/\\/[^\\n\\r]*[\\r\\n])?(\\[|function|[\\w\\d_\\-\\$]+\\s*\\)|\\{|["\']([^"\']+)["\'])(\\s*,\\s*f)?');
|
9349
9614
|
};
|
9350
9615
|
|
9351
9616
|
build.leadingCommaRegExp = /^\s*,/;
|
@@ -2,7 +2,7 @@
|
|
2
2
|
var requirejs = require('<%= rjs_path %>'),
|
3
3
|
//Set up basic config, include config that is
|
4
4
|
//common to all the optimize() calls.
|
5
|
-
basConfig = <%= JSON.pretty_generate(build_config) %>;
|
5
|
+
basConfig = <%= JSON.pretty_generate(build_config.reject {|k,v| k == 'modules'}) %>;
|
6
6
|
|
7
7
|
// Function used to mix in baseConfig to a new config target
|
8
8
|
function mix(target) {
|
@@ -13,7 +13,7 @@ class RequirejsRailsTest < ActiveSupport::TestCase
|
|
13
13
|
test "require.js version" do
|
14
14
|
require_js = Pathname.new(__FILE__+'/../../vendor/assets/javascripts/require.js').cleanpath.read
|
15
15
|
context = ExecJS.compile(require_js)
|
16
|
-
assert_equal "1.0.
|
16
|
+
assert_equal "1.0.7", context.eval("require.version")
|
17
17
|
end
|
18
18
|
end
|
19
19
|
|
@@ -1,5 +1,5 @@
|
|
1
1
|
/** vim: et:ts=4:sw=4:sts=4
|
2
|
-
* @license RequireJS 1.0.
|
2
|
+
* @license RequireJS 1.0.7 Copyright (c) 2010-2012, The Dojo Foundation All Rights Reserved.
|
3
3
|
* Available via the MIT or new BSD license.
|
4
4
|
* see: http://github.com/jrburke/requirejs for details
|
5
5
|
*/
|
@@ -9,7 +9,7 @@
|
|
9
9
|
var requirejs, require, define;
|
10
10
|
(function () {
|
11
11
|
//Change this version number for each release.
|
12
|
-
var version = "1.0.
|
12
|
+
var version = "1.0.7",
|
13
13
|
commentRegExp = /(\/\*([\s\S]*?)\*\/|([^:]|^)\/\/(.*)$)/mg,
|
14
14
|
cjsRequireRegExp = /require\(\s*["']([^'"\s]+)["']\s*\)/g,
|
15
15
|
currDirRegExp = /^\.\//,
|
@@ -1053,6 +1053,7 @@ var requirejs, require, define;
|
|
1053
1053
|
err = makeError("timeout", "Load timeout for modules: " + noLoads);
|
1054
1054
|
err.requireType = "timeout";
|
1055
1055
|
err.requireModules = noLoads;
|
1056
|
+
err.contextName = context.contextName;
|
1056
1057
|
return req.onError(err);
|
1057
1058
|
}
|
1058
1059
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: requirejs-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.6
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-02-
|
12
|
+
date: 2012-02-23 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: railties
|
16
|
-
requirement: &
|
16
|
+
requirement: &70316642847980 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -24,10 +24,10 @@ dependencies:
|
|
24
24
|
version: '3.3'
|
25
25
|
type: :runtime
|
26
26
|
prerelease: false
|
27
|
-
version_requirements: *
|
27
|
+
version_requirements: *70316642847980
|
28
28
|
- !ruby/object:Gem::Dependency
|
29
29
|
name: rails
|
30
|
-
requirement: &
|
30
|
+
requirement: &70316642846680 !ruby/object:Gem::Requirement
|
31
31
|
none: false
|
32
32
|
requirements:
|
33
33
|
- - ! '>='
|
@@ -38,10 +38,10 @@ dependencies:
|
|
38
38
|
version: '3.3'
|
39
39
|
type: :development
|
40
40
|
prerelease: false
|
41
|
-
version_requirements: *
|
41
|
+
version_requirements: *70316642846680
|
42
42
|
- !ruby/object:Gem::Dependency
|
43
43
|
name: sqlite3
|
44
|
-
requirement: &
|
44
|
+
requirement: &70316642844860 !ruby/object:Gem::Requirement
|
45
45
|
none: false
|
46
46
|
requirements:
|
47
47
|
- - ! '>='
|
@@ -49,7 +49,7 @@ dependencies:
|
|
49
49
|
version: '0'
|
50
50
|
type: :development
|
51
51
|
prerelease: false
|
52
|
-
version_requirements: *
|
52
|
+
version_requirements: *70316642844860
|
53
53
|
description: This gem provides RequireJS support for your Rails 3 application.
|
54
54
|
email:
|
55
55
|
- whitley@bangpath.org
|
@@ -128,7 +128,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
128
128
|
version: '0'
|
129
129
|
segments:
|
130
130
|
- 0
|
131
|
-
hash:
|
131
|
+
hash: -4183822375632730942
|
132
132
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
133
133
|
none: false
|
134
134
|
requirements:
|
@@ -137,12 +137,12 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
137
137
|
version: '0'
|
138
138
|
segments:
|
139
139
|
- 0
|
140
|
-
hash:
|
140
|
+
hash: -4183822375632730942
|
141
141
|
requirements:
|
142
142
|
- node.js is required for 'rake assets:precompile', used to run the r.js build
|
143
143
|
- If needed, jQuery should be v1.7 or greater (jquery-rails >= 1.0.17).
|
144
144
|
rubyforge_project:
|
145
|
-
rubygems_version: 1.8.
|
145
|
+
rubygems_version: 1.8.16
|
146
146
|
signing_key:
|
147
147
|
specification_version: 3
|
148
148
|
summary: Use RequireJS with the Rails 3 Asset Pipeline
|