requirejs-rails 0.9.4 → 0.9.5
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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +35 -26
- data/Gemfile.lock +1 -1
- data/app/helpers/requirejs_helper.rb +40 -37
- data/bin/r.js +22 -21
- data/lib/requirejs/rails/engine.rb +14 -8
- data/lib/requirejs/rails/rjs_driver.js.erb +3 -5
- data/lib/requirejs/rails/version.rb +2 -2
- data/test/requirejs-rails_test.rb +56 -38
- data/vendor/assets/javascripts/almond.js +10 -2
- data/vendor/assets/javascripts/require.js +2 -2
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 5e6e1a6b4dcfccf6349e7b4f3f45a21725f3f0b9
|
|
4
|
+
data.tar.gz: 759a8ae32987c747490a3644fdb1f5ff0dd4032d
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: de28293e70d15e53b87a18c46dc3272f874e583edae8e8da4cbece14fd63fd942ccacc80a65311e14d5690bfaf436cabd7a00b88d9e1fcee44a3fc0a4db1bc77
|
|
7
|
+
data.tar.gz: a160056a3264a6a3630a73d6f0fa4b57f963e622135b7b1464b77fe1310217d9166e5bca56097030e964628fd5d653ab9b5457ece2dea9c432b58140f928fbd8
|
data/CHANGELOG.md
CHANGED
|
@@ -1,53 +1,63 @@
|
|
|
1
|
-
<!--
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
<!-- Marked Style: GitHub -->
|
|
2
|
+
|
|
3
|
+
## requirejs-rails changelog
|
|
4
|
+
|
|
5
|
+
### v0.9.5
|
|
6
|
+
|
|
7
|
+
- Update `require.js` and `r.js` to `2.1.15`, and `almond.js` to `0.3.0`.
|
|
8
|
+
- Remove `data-main` attribute generation from `requirejs_include_tag` and replicate its functionality with an explicit
|
|
9
|
+
`require` call. This paves the way for proper almond support.
|
|
10
|
+
- Instead of disabling JS compression everywhere, only do so when staging `r.js` input files. This enables `require.js`
|
|
11
|
+
itself to be compiled (or not) by the asset pipeline, like any other asset.
|
|
12
|
+
- Add support for `bower.json` modules.
|
|
13
|
+
|
|
14
|
+
### v0.9.4
|
|
5
15
|
|
|
6
16
|
- Restore compression of non-module JS assets if specified, including `require.js` itself.
|
|
7
17
|
- Update `require.js` to `2.1.14`.
|
|
8
18
|
|
|
9
|
-
|
|
19
|
+
### v0.9.3
|
|
10
20
|
|
|
11
21
|
- Add detection and proper handling of Bower-based modules.
|
|
12
22
|
- Update `require.js` to `2.1.11` and `almond.js` to `0.2.9`.
|
|
13
23
|
|
|
14
|
-
|
|
24
|
+
### v0.9.2
|
|
15
25
|
|
|
16
26
|
- Update `require.js` to `2.1.10` and `almond.js` to `0.2.5`.
|
|
17
27
|
- Rails 4 support.
|
|
18
28
|
|
|
19
|
-
|
|
29
|
+
### v0.9.1
|
|
20
30
|
|
|
21
31
|
- Updated to to require.js \ r.js 2.1.2, and almond 0.2.3
|
|
22
32
|
|
|
23
|
-
|
|
33
|
+
### v0.9.0
|
|
24
34
|
|
|
25
35
|
- **BREAKING CHANGE**: Upgrade RequireJS and r.js to v2.0.0
|
|
26
36
|
- order.js was removed. See the new [RequireJS 2.0 shim config](https://github.com/jrburke/requirejs/wiki/Upgrading-to-RequireJS-2.0#wiki-shim).
|
|
27
37
|
- Build support for `empty:` is now handled by r.js 2.0 natively.
|
|
28
38
|
|
|
29
|
-
|
|
39
|
+
### v0.8.2
|
|
30
40
|
|
|
31
41
|
- Fix for `requirejs_include_tag` error when `config/requirejs.yml` has no
|
|
32
42
|
`paths` key. Thanks to @JustinLove for the issue and failing test!
|
|
33
43
|
|
|
34
|
-
|
|
44
|
+
### v0.8.0
|
|
35
45
|
|
|
36
46
|
- Build will now substitute `empty:` for the right-hand side of
|
|
37
47
|
`config/requirejs.yml` paths entries that are URLs.
|
|
38
48
|
- Documented how to configure assets hosted on a CDN.
|
|
39
49
|
|
|
40
|
-
|
|
50
|
+
### v0.7.3
|
|
41
51
|
|
|
42
52
|
- Upgrade RequireJS and r.js to v1.0.8
|
|
43
53
|
|
|
44
|
-
|
|
54
|
+
### v0.7.2
|
|
45
55
|
|
|
46
56
|
- Add require.js to config.assets.precompile in all environments. Closes #45.
|
|
47
57
|
This change allows builds to work in Rails environments other than
|
|
48
58
|
'production', e.g. 'staging'. Thanks to @hollow for the fix.
|
|
49
59
|
|
|
50
|
-
|
|
60
|
+
### v0.7.1
|
|
51
61
|
|
|
52
62
|
- Liberalize asset path filtering. `0.7.0` added filtering on the logical
|
|
53
63
|
asset path which was too aggressive in that only `.js` files were allowed in
|
|
@@ -55,7 +65,7 @@ Marked Style: GitHub
|
|
|
55
65
|
added, which allows `.js`, `.html`, `.txt` files by default and is user
|
|
56
66
|
configurable.
|
|
57
67
|
|
|
58
|
-
|
|
68
|
+
### v0.7.0
|
|
59
69
|
|
|
60
70
|
- Support for [almond](https://github.com/jrburke/almond) via
|
|
61
71
|
`config.requirejs.loader = :almond` in application.rb.
|
|
@@ -66,11 +76,11 @@ Marked Style: GitHub
|
|
|
66
76
|
leverage the asset pipeline for their needs. Thanks to @hollow for the
|
|
67
77
|
patch.
|
|
68
78
|
|
|
69
|
-
|
|
79
|
+
### v0.6.1
|
|
70
80
|
|
|
71
81
|
- Fix regression in production env when `paths` specified in requirejs.yml.
|
|
72
82
|
|
|
73
|
-
|
|
83
|
+
### v0.6.0
|
|
74
84
|
|
|
75
85
|
**NOTE:** Upgrade to 0.6.1! This was yanked due to a regression.
|
|
76
86
|
|
|
@@ -80,30 +90,30 @@ Marked Style: GitHub
|
|
|
80
90
|
tag via `requirejs_include_tag`. See [README](README.md) for details. Closes
|
|
81
91
|
pull request #32; thanks to @hollow for the submission!
|
|
82
92
|
|
|
83
|
-
|
|
93
|
+
### v0.5.6
|
|
84
94
|
|
|
85
95
|
- Upgrade to RequireJS and r.js 1.0.7
|
|
86
96
|
|
|
87
|
-
|
|
97
|
+
### v0.5.5
|
|
88
98
|
|
|
89
99
|
- Support for Rails 3.2.x. Rails 3.1.x is also supported by this release.
|
|
90
100
|
|
|
91
|
-
|
|
101
|
+
### v0.5.4
|
|
92
102
|
|
|
93
103
|
- Upgrade to RequireJS and r.js 1.0.5
|
|
94
104
|
- Pull request #31, closes #30. Thanks @karelim!
|
|
95
105
|
|
|
96
|
-
|
|
106
|
+
### v0.5.3
|
|
97
107
|
|
|
98
108
|
- Upgrade to RequireJS and r.js 1.0.4
|
|
99
109
|
- Pulled #22, fix for asset compliation failure with no config/requirejs.yml.
|
|
100
110
|
Thanks @arehberg!
|
|
101
111
|
|
|
102
|
-
|
|
112
|
+
### v0.5.2
|
|
103
113
|
|
|
104
114
|
- Upgrade to RequireJS and r.js 1.0.3
|
|
105
115
|
|
|
106
|
-
|
|
116
|
+
### v0.5.1
|
|
107
117
|
|
|
108
118
|
- This is a quick turn to fix an issue that could trigger an Anonymous mismatched define() error from require.js and/or r.js.
|
|
109
119
|
|
|
@@ -121,21 +131,20 @@ Marked Style: GitHub
|
|
|
121
131
|
|
|
122
132
|
Thanks to Andrew de Andrade for the catch.
|
|
123
133
|
|
|
124
|
-
|
|
134
|
+
### v0.5.0
|
|
125
135
|
|
|
126
136
|
- Precompilation via `rake assets:precompile` is now implemented.
|
|
127
137
|
- gem configuration via application.js is deprecated.
|
|
128
138
|
- Application-specific require.js configuration lives in `config/requirejs.yml`.
|
|
129
139
|
- See [README](README.md) for updated usage details.
|
|
130
140
|
|
|
131
|
-
|
|
141
|
+
### v0.0.2
|
|
132
142
|
|
|
133
143
|
- Fixed stupid problems with Rails::Engine instantiation.
|
|
134
144
|
- Test improvements
|
|
135
145
|
- Upgrade to RequireJS 1.0.2
|
|
136
146
|
|
|
137
|
-
|
|
147
|
+
### v0.0.1
|
|
138
148
|
|
|
139
149
|
- Birthday!
|
|
140
150
|
- This gem makes `require.js` and the `order.js` plugin available to the Rails 3 Asset Pipeline.
|
|
141
|
-
|
data/Gemfile.lock
CHANGED
|
@@ -7,36 +7,27 @@ module RequirejsHelper
|
|
|
7
7
|
mattr_accessor :_priority
|
|
8
8
|
@@_priority = []
|
|
9
9
|
|
|
10
|
-
def _requirejs_data(name, &block)
|
|
11
|
-
{}.tap do |data|
|
|
12
|
-
if name
|
|
13
|
-
name += ".js" unless name =~ /\.js$/
|
|
14
|
-
data['main'] = _javascript_path(name) \
|
|
15
|
-
.sub(/\.js$/, '') \
|
|
16
|
-
.sub(base_url(name), '') \
|
|
17
|
-
.sub(/\A\//, '')
|
|
18
|
-
end
|
|
19
|
-
|
|
20
|
-
data.merge!(yield controller) if block_given?
|
|
21
|
-
end.map do |k, v|
|
|
22
|
-
%Q{data-#{k}="#{v}"}
|
|
23
|
-
end.join(" ")
|
|
24
|
-
end
|
|
25
|
-
|
|
26
10
|
def requirejs_include_tag(name=nil, &block)
|
|
27
11
|
requirejs = Rails.application.config.requirejs
|
|
28
12
|
|
|
29
13
|
if requirejs.loader == :almond
|
|
30
14
|
name = requirejs.module_name_for(requirejs.build_config['modules'][0])
|
|
31
|
-
return
|
|
15
|
+
return almond_include_tag(name, &block)
|
|
32
16
|
end
|
|
33
17
|
|
|
34
18
|
html = ""
|
|
35
19
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
20
|
+
once_guard do
|
|
21
|
+
rjs_attributes = {
|
|
22
|
+
src: javascript_path("require")
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
rjs_attributes = rjs_attributes.merge(Hash[block.call(controller).map do |key, value|
|
|
26
|
+
["data-#{key}", value]
|
|
27
|
+
end]) \
|
|
28
|
+
if block
|
|
29
|
+
|
|
30
|
+
html.concat(content_tag(:script, "", rjs_attributes))
|
|
40
31
|
|
|
41
32
|
unless requirejs.run_config.empty?
|
|
42
33
|
run_config = requirejs.run_config.dup
|
|
@@ -52,11 +43,13 @@ module RequirejsHelper
|
|
|
52
43
|
|
|
53
44
|
# Generate digestified paths from the modules spec
|
|
54
45
|
paths = {}
|
|
55
|
-
modules.each { |m| paths[m] =
|
|
46
|
+
modules.each { |m| paths[m] = javascript_path(m).sub /\.js$/, '' }
|
|
56
47
|
|
|
57
48
|
if run_config.has_key? 'paths'
|
|
58
49
|
# Add paths for assets specified by full URL (on a CDN)
|
|
59
|
-
run_config['paths'].each
|
|
50
|
+
run_config['paths'].each do |k, v|
|
|
51
|
+
paths[k] = v if v.is_a?(Array) || v =~ /^https?:/
|
|
52
|
+
end
|
|
60
53
|
end
|
|
61
54
|
|
|
62
55
|
# Override user paths, whose mappings are only relevant in dev mode
|
|
@@ -65,16 +58,34 @@ module RequirejsHelper
|
|
|
65
58
|
end
|
|
66
59
|
|
|
67
60
|
run_config['baseUrl'] = base_url(name)
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
61
|
+
|
|
62
|
+
html.concat(content_tag(:script) do
|
|
63
|
+
script = "require.config(#{run_config.to_json});"
|
|
64
|
+
|
|
65
|
+
# Pass an array to `require`, since it's a top-level module about to be loaded asynchronously (see
|
|
66
|
+
# `http://requirejs.org/docs/errors.html#notloaded`).
|
|
67
|
+
script.concat(" require([#{name.dump}]);") \
|
|
68
|
+
if name
|
|
69
|
+
|
|
70
|
+
script.html_safe
|
|
71
|
+
end)
|
|
71
72
|
end
|
|
72
73
|
|
|
73
74
|
html.html_safe
|
|
74
75
|
end
|
|
75
76
|
end
|
|
76
77
|
|
|
77
|
-
def
|
|
78
|
+
def javascript_path(name)
|
|
79
|
+
if defined?(super)
|
|
80
|
+
super
|
|
81
|
+
else
|
|
82
|
+
"/assets/#{name}"
|
|
83
|
+
end
|
|
84
|
+
end
|
|
85
|
+
|
|
86
|
+
private
|
|
87
|
+
|
|
88
|
+
def once_guard
|
|
78
89
|
if defined?(controller) && controller.requirejs_included
|
|
79
90
|
raise Requirejs::MultipleIncludeError, "Only one requirejs_include_tag allowed per page."
|
|
80
91
|
end
|
|
@@ -85,16 +96,8 @@ module RequirejsHelper
|
|
|
85
96
|
retval
|
|
86
97
|
end
|
|
87
98
|
|
|
88
|
-
def
|
|
89
|
-
|
|
90
|
-
end
|
|
91
|
-
|
|
92
|
-
def _javascript_path(name)
|
|
93
|
-
if defined?(javascript_path)
|
|
94
|
-
javascript_path(name)
|
|
95
|
-
else
|
|
96
|
-
"/assets/#{name}"
|
|
97
|
-
end
|
|
99
|
+
def almond_include_tag(name, &block)
|
|
100
|
+
content_tag(:script, "", src: javascript_path(name))
|
|
98
101
|
end
|
|
99
102
|
|
|
100
103
|
def base_url(js_asset)
|
data/bin/r.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @license r.js 2.1.
|
|
2
|
+
* @license r.js 2.1.15 Copyright (c) 2010-2014, 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, xpcUtil;
|
|
|
20
20
|
(function (console, args, readFileFunc) {
|
|
21
21
|
var fileName, env, fs, vm, path, exec, rhinoContext, dir, nodeRequire,
|
|
22
22
|
nodeDefine, exists, reqMain, loadedOptimizedLib, existsForNode, Cc, Ci,
|
|
23
|
-
version = '2.1.
|
|
23
|
+
version = '2.1.15',
|
|
24
24
|
jsSuffixRegExp = /\.js$/,
|
|
25
25
|
commandOption = '',
|
|
26
26
|
useLibLoaded = {},
|
|
@@ -238,7 +238,7 @@ var requirejs, require, define, xpcUtil;
|
|
|
238
238
|
}
|
|
239
239
|
|
|
240
240
|
/** vim: et:ts=4:sw=4:sts=4
|
|
241
|
-
* @license RequireJS 2.1.
|
|
241
|
+
* @license RequireJS 2.1.15 Copyright (c) 2010-2014, The Dojo Foundation All Rights Reserved.
|
|
242
242
|
* Available via the MIT or new BSD license.
|
|
243
243
|
* see: http://github.com/jrburke/requirejs for details
|
|
244
244
|
*/
|
|
@@ -251,7 +251,7 @@ var requirejs, require, define, xpcUtil;
|
|
|
251
251
|
(function (global) {
|
|
252
252
|
var req, s, head, baseElement, dataMain, src,
|
|
253
253
|
interactiveScript, currentlyAddingScript, mainScript, subPath,
|
|
254
|
-
version = '2.1.
|
|
254
|
+
version = '2.1.15',
|
|
255
255
|
commentRegExp = /(\/\*([\s\S]*?)\*\/|([^:]|^)\/\/(.*)$)/mg,
|
|
256
256
|
cjsRequireRegExp = /[^.]\s*require\s*\(\s*["']([^'"\s]+)["']\s*\)/g,
|
|
257
257
|
jsSuffixRegExp = /\.js$/,
|
|
@@ -22949,7 +22949,7 @@ define('parse', ['./esprimaAdapter', 'lang'], function (esprima, lang) {
|
|
|
22949
22949
|
//Like traverse, but skips if branches that would not be processed
|
|
22950
22950
|
//after has application that results in tests of true or false boolean
|
|
22951
22951
|
//literal values.
|
|
22952
|
-
var key, child, result, i, params, param,
|
|
22952
|
+
var key, child, result, i, params, param, tempObject,
|
|
22953
22953
|
hasHas = options && options.has;
|
|
22954
22954
|
|
|
22955
22955
|
fnExpScope = fnExpScope || emptyScope;
|
|
@@ -22979,23 +22979,23 @@ define('parse', ['./esprimaAdapter', 'lang'], function (esprima, lang) {
|
|
|
22979
22979
|
|
|
22980
22980
|
//Build up a "scope" object that informs nested recurse calls if
|
|
22981
22981
|
//the define call references an identifier that is likely a UMD
|
|
22982
|
-
//wrapped function
|
|
22982
|
+
//wrapped function expression argument.
|
|
22983
22983
|
if (object.type === 'ExpressionStatement' && object.expression &&
|
|
22984
22984
|
object.expression.type === 'CallExpression' && object.expression.callee &&
|
|
22985
22985
|
object.expression.callee.type === 'FunctionExpression') {
|
|
22986
|
-
|
|
22987
|
-
|
|
22988
|
-
|
|
22989
|
-
|
|
22990
|
-
|
|
22991
|
-
|
|
22992
|
-
|
|
22993
|
-
|
|
22994
|
-
|
|
22995
|
-
}
|
|
22986
|
+
tempObject = object.expression.callee;
|
|
22987
|
+
|
|
22988
|
+
if (tempObject.params && tempObject.params.length) {
|
|
22989
|
+
params = tempObject.params;
|
|
22990
|
+
fnExpScope = mixin({}, fnExpScope, true);
|
|
22991
|
+
for (i = 0; i < params.length; i++) {
|
|
22992
|
+
param = params[i];
|
|
22993
|
+
if (param.type === 'Identifier') {
|
|
22994
|
+
fnExpScope[param.name] = true;
|
|
22996
22995
|
}
|
|
22997
22996
|
}
|
|
22998
22997
|
}
|
|
22998
|
+
}
|
|
22999
22999
|
|
|
23000
23000
|
for (key in object) {
|
|
23001
23001
|
if (object.hasOwnProperty(key)) {
|
|
@@ -23014,12 +23014,12 @@ define('parse', ['./esprimaAdapter', 'lang'], function (esprima, lang) {
|
|
|
23014
23014
|
//wrapping.
|
|
23015
23015
|
if (typeof result === 'string') {
|
|
23016
23016
|
if (hasProp(fnExpScope, result)) {
|
|
23017
|
-
//
|
|
23018
|
-
//
|
|
23019
|
-
return;
|
|
23017
|
+
//result still in scope, keep jumping out indicating the
|
|
23018
|
+
//identifier still in use.
|
|
23019
|
+
return result;
|
|
23020
23020
|
}
|
|
23021
23021
|
|
|
23022
|
-
return
|
|
23022
|
+
return;
|
|
23023
23023
|
}
|
|
23024
23024
|
}
|
|
23025
23025
|
};
|
|
@@ -26539,7 +26539,8 @@ define('build', function (require) {
|
|
|
26539
26539
|
"excludeShallow": true,
|
|
26540
26540
|
"insertRequire": true,
|
|
26541
26541
|
"stubModules": true,
|
|
26542
|
-
"deps": true
|
|
26542
|
+
"deps": true,
|
|
26543
|
+
"mainConfigFile": true
|
|
26543
26544
|
};
|
|
26544
26545
|
|
|
26545
26546
|
for (i = 0; i < ary.length; i++) {
|
|
@@ -21,14 +21,20 @@ module Requirejs
|
|
|
21
21
|
config.assets.precompile += config.requirejs.precompile
|
|
22
22
|
|
|
23
23
|
# Check for the `requirejs:precompile:all` top-level Rake task and run the following initialization code.
|
|
24
|
-
Rake.application.top_level_tasks
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
24
|
+
if defined?(Rake.application) && Rake.application.top_level_tasks == ["requirejs:precompile:all"]
|
|
25
|
+
# Prevent Sprockets from freezing the assets environment, which allows JS compression to be toggled on a per-
|
|
26
|
+
# file basis. This trick *will* fail if any of the lines linked to below change.
|
|
27
|
+
|
|
28
|
+
if ::Rails::VERSION::MAJOR >= 4
|
|
29
|
+
# For Rails 4 (see
|
|
30
|
+
# `https://github.com/rails/sprockets-rails/blob/v2.1.2/lib/sprockets/railtie.rb#L119-121`).
|
|
31
|
+
config.cache_classes = false
|
|
32
|
+
else
|
|
33
|
+
# For Rails 3 (see
|
|
34
|
+
# `https://github.com/rails/rails/blob/v3.2.19/actionpack/lib/sprockets/bootstrap.rb#L32-34`).
|
|
35
|
+
config.assets.digest = false
|
|
30
36
|
end
|
|
31
|
-
end
|
|
37
|
+
end
|
|
32
38
|
|
|
33
39
|
manifest_directory = config.assets.manifest || File.join(::Rails.public_path, config.assets.prefix)
|
|
34
40
|
manifest_path = File.join(manifest_directory, "rjs_manifest.yml")
|
|
@@ -44,7 +50,7 @@ module Requirejs
|
|
|
44
50
|
end
|
|
45
51
|
end
|
|
46
52
|
|
|
47
|
-
if ::Rails::VERSION::
|
|
53
|
+
if ::Rails::VERSION::MAJOR >= 4
|
|
48
54
|
config.after_initialize do |app|
|
|
49
55
|
config = app.config
|
|
50
56
|
rails_manifest_path = File.join(app.root, 'public', config.assets.prefix)
|
|
@@ -5,11 +5,9 @@ cdn_pattern = Regexp.new("\\Ahttps?://")
|
|
|
5
5
|
modifiedHash = build_config.select { |k, _| k != "modules" }
|
|
6
6
|
pathsHash = modifiedHash["paths"]
|
|
7
7
|
modifiedHash["dir"] = build_dir.to_s
|
|
8
|
-
modifiedHash["paths"] = Hash[
|
|
9
|
-
.
|
|
10
|
-
|
|
11
|
-
end.map do |k, v|
|
|
12
|
-
[k, if !cdn_pattern.match(v) then v else "empty:" end]
|
|
8
|
+
modifiedHash["paths"] = Hash[
|
|
9
|
+
pathsHash.map do |k, v|
|
|
10
|
+
[k, v.is_a?(Array) || cdn_pattern.match(v) ? "empty:" : v]
|
|
13
11
|
end
|
|
14
12
|
] if !pathsHash.nil?
|
|
15
13
|
|
|
@@ -9,7 +9,7 @@ class RequirejsRailsTest < ActiveSupport::TestCase
|
|
|
9
9
|
assert_kind_of Module, Requirejs::Rails
|
|
10
10
|
assert_kind_of Class, Requirejs::Rails::Engine
|
|
11
11
|
end
|
|
12
|
-
|
|
12
|
+
|
|
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)
|
|
@@ -51,13 +51,13 @@ class RequirejsRailsConfigTest < ActiveSupport::TestCase
|
|
|
51
51
|
|
|
52
52
|
test "user_config should reject baseUrl" do
|
|
53
53
|
exc = assert_raises Requirejs::ConfigError do
|
|
54
|
-
@cfg.user_config = {
|
|
54
|
+
@cfg.user_config = {'baseUrl' => '/frobnitz'}
|
|
55
55
|
end
|
|
56
56
|
assert_match /baseUrl is not needed/, exc.message
|
|
57
57
|
end
|
|
58
58
|
|
|
59
59
|
test "run_config should inherit user_config settings" do
|
|
60
|
-
@cfg.user_config = {
|
|
60
|
+
@cfg.user_config = {'paths' => {'jquery' => 'lib/jquery-1.7.2.min'}}
|
|
61
61
|
refute_nil @cfg.run_config['paths']
|
|
62
62
|
assert_kind_of Hash, @cfg.run_config['paths']
|
|
63
63
|
assert_equal 'lib/jquery-1.7.2.min', @cfg.run_config['paths']['jquery']
|
|
@@ -69,32 +69,32 @@ class RequirejsRailsConfigTest < ActiveSupport::TestCase
|
|
|
69
69
|
end
|
|
70
70
|
|
|
71
71
|
test "build_config should inherit user_config settings" do
|
|
72
|
-
@cfg.user_config = {
|
|
72
|
+
@cfg.user_config = {'paths' => {'jquery' => 'lib/jquery-1.7.2.min'}}
|
|
73
73
|
refute_nil @cfg.build_config['paths']
|
|
74
74
|
assert_kind_of Hash, @cfg.build_config['paths']
|
|
75
75
|
assert_equal 'lib/jquery-1.7.2.min', @cfg.build_config['paths']['jquery']
|
|
76
76
|
end
|
|
77
77
|
|
|
78
78
|
test "run_config should reject irrelevant settings" do
|
|
79
|
-
@cfg.user_config = {
|
|
80
|
-
assert_nil @cfg.run_config['optimize']
|
|
79
|
+
@cfg.user_config = {'optimize' => 'none'}
|
|
80
|
+
assert_nil @cfg.run_config['optimize']
|
|
81
81
|
end
|
|
82
82
|
|
|
83
83
|
test "build_config should reject irrelevant settings" do
|
|
84
|
-
@cfg.user_config = {
|
|
85
|
-
assert_nil @cfg.build_config['priority']
|
|
84
|
+
@cfg.user_config = {'priority' => %w{ foo bar baz }}
|
|
85
|
+
assert_nil @cfg.build_config['priority']
|
|
86
86
|
end
|
|
87
87
|
|
|
88
88
|
## Almond tests
|
|
89
89
|
test "build_config with almond should accept one module" do
|
|
90
90
|
@cfg.loader = :almond
|
|
91
|
-
@cfg.user_config = {
|
|
91
|
+
@cfg.user_config = {'modules' => [{'name' => 'foo'}]}
|
|
92
92
|
assert_match 'almond', @cfg.build_config['modules'][0]['name']
|
|
93
93
|
end
|
|
94
94
|
|
|
95
95
|
test "build_config with almond must reject more than one module" do
|
|
96
96
|
@cfg.loader = :almond
|
|
97
|
-
@cfg.user_config = {
|
|
97
|
+
@cfg.user_config = {'modules' => [{'name' => 'foo'}, {'name' => 'bar'}]}
|
|
98
98
|
exc = assert_raises Requirejs::ConfigError do
|
|
99
99
|
@cfg.build_config
|
|
100
100
|
end
|
|
@@ -103,7 +103,6 @@ class RequirejsRailsConfigTest < ActiveSupport::TestCase
|
|
|
103
103
|
end
|
|
104
104
|
|
|
105
105
|
class RequirejsHelperTest < ActionView::TestCase
|
|
106
|
-
|
|
107
106
|
def setup
|
|
108
107
|
controller.requirejs_included = false
|
|
109
108
|
Rails.application.config.requirejs.user_config = {}
|
|
@@ -112,49 +111,61 @@ class RequirejsHelperTest < ActionView::TestCase
|
|
|
112
111
|
end
|
|
113
112
|
|
|
114
113
|
def with_cdn
|
|
115
|
-
Rails.application.config.requirejs.user_config = {
|
|
116
|
-
|
|
114
|
+
Rails.application.config.requirejs.user_config = {
|
|
115
|
+
"paths" => {
|
|
116
|
+
"jquery" => "http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"
|
|
117
|
+
}
|
|
117
118
|
}
|
|
118
119
|
end
|
|
119
|
-
|
|
120
|
+
|
|
120
121
|
def wrap(tag)
|
|
121
122
|
"<html><head>#{tag}</head></html>"
|
|
122
123
|
end
|
|
123
|
-
|
|
124
|
+
|
|
124
125
|
test "requirejs_include_tag" do
|
|
125
|
-
render :
|
|
126
|
-
|
|
127
|
-
assert_select "script:
|
|
126
|
+
render text: wrap(requirejs_include_tag)
|
|
127
|
+
|
|
128
|
+
assert_select "script:first-of-type[src=\"/javascripts/require.js\"]", count: 1
|
|
129
|
+
assert_select "script:last-of-type", text: "require.config({\"baseUrl\":\"/assets\"});"
|
|
128
130
|
end
|
|
129
|
-
|
|
131
|
+
|
|
130
132
|
test "requirejs_include_tag_with_param" do
|
|
131
|
-
render :
|
|
132
|
-
|
|
133
|
+
render text: wrap(requirejs_include_tag("application"))
|
|
134
|
+
|
|
135
|
+
assert_select "script:first-of-type[src=\"/javascripts/require.js\"]", count: 1
|
|
133
136
|
end
|
|
134
|
-
|
|
137
|
+
|
|
135
138
|
test "requirejs_include_tag_with_block" do
|
|
136
|
-
|
|
137
|
-
{
|
|
138
|
-
end
|
|
139
|
+
render text: wrap(requirejs_include_tag("application") do
|
|
140
|
+
{"class" => controller.class.name.demodulize}
|
|
141
|
+
end)
|
|
139
142
|
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
assert_select "script:last-of-type[src^=/javascripts/require.js][data-class^=TestController]", :count => 1
|
|
143
|
+
assert_select "script:first-of-type[src=\"/javascripts/require.js\"]" \
|
|
144
|
+
"[data-class=\"TestController\"]", count: 1
|
|
143
145
|
end
|
|
144
146
|
|
|
145
147
|
test "requirejs_include_tag can appear only once" do
|
|
146
148
|
assert_raises Requirejs::MultipleIncludeError do
|
|
147
|
-
|
|
149
|
+
requirejs_include_tag
|
|
150
|
+
requirejs_include_tag
|
|
148
151
|
end
|
|
149
152
|
end
|
|
150
153
|
|
|
151
|
-
test "requirejs_include_tag with
|
|
154
|
+
test "requirejs_include_tag with digestified asset paths" do
|
|
152
155
|
begin
|
|
156
|
+
Rails.application.config.requirejs.user_config = {
|
|
157
|
+
"modules" => [
|
|
158
|
+
{"name" => "foo"}
|
|
159
|
+
]
|
|
160
|
+
}
|
|
161
|
+
|
|
153
162
|
saved_digest = Rails.application.config.assets.digest
|
|
154
163
|
Rails.application.config.assets.digest = true
|
|
155
|
-
|
|
156
|
-
render :
|
|
157
|
-
|
|
164
|
+
|
|
165
|
+
render text: wrap(requirejs_include_tag)
|
|
166
|
+
|
|
167
|
+
assert_select "script:last-of-type",
|
|
168
|
+
text: Regexp.new("\\Arequire\\.config\\({.*\"paths\":{.*\"foo\":\"/javascripts/foo\".*}.*}\\);\\z")
|
|
158
169
|
ensure
|
|
159
170
|
Rails.application.config.assets.digest = saved_digest
|
|
160
171
|
end
|
|
@@ -162,17 +173,24 @@ class RequirejsHelperTest < ActionView::TestCase
|
|
|
162
173
|
|
|
163
174
|
test "requirejs_include_tag with CDN asset in paths" do
|
|
164
175
|
with_cdn
|
|
165
|
-
|
|
166
|
-
|
|
176
|
+
|
|
177
|
+
render text: wrap(requirejs_include_tag)
|
|
178
|
+
|
|
179
|
+
assert_select "script:last-of-type",
|
|
180
|
+
text: Regexp.new("\\Arequire\\.config\\({.*\"paths\":{.*\"http://ajax\\..*\".*}.*}\\);\\z")
|
|
167
181
|
end
|
|
168
182
|
|
|
169
|
-
test "requirejs_include_tag with CDN asset and
|
|
183
|
+
test "requirejs_include_tag with CDN asset and digestified asset paths" do
|
|
170
184
|
begin
|
|
171
185
|
with_cdn
|
|
186
|
+
|
|
172
187
|
saved_digest = Rails.application.config.assets.digest
|
|
173
188
|
Rails.application.config.assets.digest = true
|
|
174
|
-
|
|
175
|
-
|
|
189
|
+
|
|
190
|
+
render text: wrap(requirejs_include_tag)
|
|
191
|
+
|
|
192
|
+
assert_select "script:last-of-type",
|
|
193
|
+
text: Regexp.new("\\Arequire\\.config\\({.*\"paths\":{.*\"http://ajax\\..*\".*}.*}\\);\\z")
|
|
176
194
|
ensure
|
|
177
195
|
Rails.application.config.assets.digest = saved_digest
|
|
178
196
|
end
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @license almond 0.
|
|
2
|
+
* @license almond 0.3.0 Copyright (c) 2011-2014, The Dojo Foundation All Rights Reserved.
|
|
3
3
|
* Available via the MIT or new BSD license.
|
|
4
4
|
* see: http://github.com/jrburke/almond for details
|
|
5
5
|
*/
|
|
@@ -150,7 +150,15 @@ var requirejs, require, define;
|
|
|
150
150
|
//A version of a require function that passes a moduleName
|
|
151
151
|
//value for items that may need to
|
|
152
152
|
//look up paths relative to the moduleName
|
|
153
|
-
|
|
153
|
+
var args = aps.call(arguments, 0);
|
|
154
|
+
|
|
155
|
+
//If first arg is not require('string'), and there is only
|
|
156
|
+
//one arg, it is the array form without a callback. Insert
|
|
157
|
+
//a null so that the following concat is correct.
|
|
158
|
+
if (typeof args[0] !== 'string' && args.length === 1) {
|
|
159
|
+
args.push(null);
|
|
160
|
+
}
|
|
161
|
+
return req.apply(undef, args.concat([relName, forceSync]));
|
|
154
162
|
};
|
|
155
163
|
}
|
|
156
164
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/** vim: et:ts=4:sw=4:sts=4
|
|
2
|
-
* @license RequireJS 2.1.
|
|
2
|
+
* @license RequireJS 2.1.15 Copyright (c) 2010-2014, 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
|
*/
|
|
@@ -12,7 +12,7 @@ var requirejs, require, define;
|
|
|
12
12
|
(function (global) {
|
|
13
13
|
var req, s, head, baseElement, dataMain, src,
|
|
14
14
|
interactiveScript, currentlyAddingScript, mainScript, subPath,
|
|
15
|
-
version = '2.1.
|
|
15
|
+
version = '2.1.15',
|
|
16
16
|
commentRegExp = /(\/\*([\s\S]*?)\*\/|([^:]|^)\/\/(.*)$)/mg,
|
|
17
17
|
cjsRequireRegExp = /[^.]\s*require\s*\(\s*["']([^'"\s]+)["']\s*\)/g,
|
|
18
18
|
jsSuffixRegExp = /\.js$/,
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: requirejs-rails
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.9.
|
|
4
|
+
version: 0.9.5
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- John Whitley
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2014-
|
|
11
|
+
date: 2014-09-18 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: railties
|