requirejs-rails 0.9.6 → 0.9.8
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 +10 -0
- data/Gemfile.lock +1 -1
- data/app/helpers/requirejs_helper.rb +2 -1
- data/lib/requirejs/rails/config.rb +0 -6
- data/lib/requirejs/rails/version.rb +1 -1
- data/lib/requirejs/rails/view_proxy.rb +7 -2
- data/lib/tasks/requirejs-rails_tasks.rake +13 -9
- data/test/requirejs-rails_test.rb +21 -6
- 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: 215e666fcb80a992bf5aab5f0204e8758caf9fd5
|
4
|
+
data.tar.gz: a0cc4708683e1133a861904043e0021778782e63
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c40c97f588521948cf3142518d752094bd94f07acab7f4945a05c932427ae2c5cf7bb9fcafa8d8222a8d72a3466ff7305b705c7a84672a8585800a7cc6677443
|
7
|
+
data.tar.gz: 9fb4030834836dfb4a31b25090f884ac904c42a79fe39c88d75af77b1350b722096db894377a0569b2d5d6f63801877b1730ae328f6daedfcab5832be51fe319
|
data/CHANGELOG.md
CHANGED
@@ -2,6 +2,16 @@
|
|
2
2
|
|
3
3
|
## requirejs-rails changelog
|
4
4
|
|
5
|
+
### v0.9.8
|
6
|
+
|
7
|
+
- Fix a bad regression and yank v0.9.7.
|
8
|
+
|
9
|
+
### v0.9.7
|
10
|
+
|
11
|
+
- Fix a corner case where modules could appear in the build config's `paths`.
|
12
|
+
- Fix regressions introduced in v0.9.6.
|
13
|
+
- Allow protocol relative urls for CDNs in the build config's `paths` (credit @remybach).
|
14
|
+
|
5
15
|
### v0.9.6
|
6
16
|
|
7
17
|
- Update `require.js` and `r.js` to `2.1.17`, and `almond.js` to `0.3.1`.
|
data/Gemfile.lock
CHANGED
@@ -49,7 +49,8 @@ module RequirejsHelper
|
|
49
49
|
if run_config.has_key? 'paths'
|
50
50
|
# Add paths for assets specified by full URL (on a CDN)
|
51
51
|
run_config['paths'].each do |k, v|
|
52
|
-
paths[k] = v if v.is_a?(Array) || v =~ /^https
|
52
|
+
paths[k] = v if v.is_a?(Array) || v =~ /^(https?:)?\/\//
|
53
|
+
|
53
54
|
end
|
54
55
|
end
|
55
56
|
|
@@ -158,12 +158,6 @@ module Requirejs
|
|
158
158
|
def get_binding
|
159
159
|
return binding()
|
160
160
|
end
|
161
|
-
|
162
|
-
def asset_allowed?(logical_path)
|
163
|
-
logical_path_patterns.reduce(false) do |accum, pattern|
|
164
|
-
accum || !!(pattern.match(logical_path))
|
165
|
-
end
|
166
|
-
end
|
167
161
|
end
|
168
162
|
end
|
169
163
|
end
|
@@ -2,8 +2,13 @@ module Requirejs
|
|
2
2
|
module Rails
|
3
3
|
class ViewProxy
|
4
4
|
include ActionView::Context
|
5
|
-
|
6
|
-
|
5
|
+
|
6
|
+
if ::Rails::VERSION::MAJOR >= 4
|
7
|
+
include ActionView::Helpers::AssetUrlHelper
|
8
|
+
include ActionView::Helpers::TagHelper
|
9
|
+
else
|
10
|
+
include ActionView::Helpers::AssetTagHelper
|
11
|
+
end
|
7
12
|
end
|
8
13
|
end
|
9
14
|
end
|
@@ -98,12 +98,7 @@ OS X Homebrew users can use 'brew install node'.
|
|
98
98
|
original_cache = requirejs.env.cache
|
99
99
|
requirejs.env.cache = nil
|
100
100
|
|
101
|
-
|
102
|
-
|
103
|
-
requirejs.env.logical_paths do |logical_path, physical_path|
|
104
|
-
next \
|
105
|
-
if !requirejs.config.asset_allowed?(logical_path)
|
106
|
-
|
101
|
+
requirejs.env.each_logical_path(requirejs.config.logical_path_patterns) do |logical_path|
|
107
102
|
m = ::Requirejs::Rails::Config::BOWER_PATH_PATTERN.match(logical_path)
|
108
103
|
|
109
104
|
if !m
|
@@ -115,7 +110,7 @@ OS X Homebrew users can use 'brew install node'.
|
|
115
110
|
asset.write_to(file)
|
116
111
|
end
|
117
112
|
else
|
118
|
-
bower_logical_path = Pathname.new(logical_path).dirname.sub_ext(
|
113
|
+
bower_logical_path = Pathname.new(logical_path).dirname.sub_ext(".js").to_s
|
119
114
|
asset = requirejs.env.find_asset(bower_logical_path)
|
120
115
|
|
121
116
|
if asset
|
@@ -150,8 +145,17 @@ OS X Homebrew users can use 'brew install node'.
|
|
150
145
|
# Copy each built asset, identified by a named module in the
|
151
146
|
# build config, to its Sprockets digestified name.
|
152
147
|
task digestify_and_compress: ["requirejs:setup"] do
|
153
|
-
requirejs.config.build_config[
|
154
|
-
|
148
|
+
requirejs.config.build_config["modules"].each do |m|
|
149
|
+
module_name = requirejs.config.module_name_for(m)
|
150
|
+
paths = requirejs.config.build_config["paths"] || {}
|
151
|
+
|
152
|
+
# Is there a `paths` entry for the module?
|
153
|
+
if !paths[module_name]
|
154
|
+
asset_name = Pathname.new(module_name).sub_ext(".js").to_s
|
155
|
+
else
|
156
|
+
asset_name = Pathname.new(paths[module_name]).sub_ext(".js").to_s
|
157
|
+
end
|
158
|
+
|
155
159
|
asset = requirejs.env.find_asset(asset_name)
|
156
160
|
|
157
161
|
built_asset_path = requirejs.config.build_dir.join(asset_name)
|
@@ -27,6 +27,12 @@ class RequirejsRailsConfigTest < ActiveSupport::TestCase
|
|
27
27
|
@cfg = Requirejs::Rails::Config.new(Rails.application)
|
28
28
|
end
|
29
29
|
|
30
|
+
def asset_allowed?(asset_path)
|
31
|
+
!!@cfg.logical_path_patterns.find do |logical_path_pattern|
|
32
|
+
logical_path_pattern.match(asset_path)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
30
36
|
test "config accepts known loaders" do
|
31
37
|
@cfg.loader = :almond
|
32
38
|
assert_equal :almond, @cfg.loader
|
@@ -39,10 +45,10 @@ class RequirejsRailsConfigTest < ActiveSupport::TestCase
|
|
39
45
|
end
|
40
46
|
|
41
47
|
test "matches configured logical assets" do
|
42
|
-
assert_equal true,
|
43
|
-
assert_equal false,
|
44
|
-
@cfg.logical_path_patterns
|
45
|
-
assert_equal true,
|
48
|
+
assert_equal true, asset_allowed?("foo.js")
|
49
|
+
assert_equal false, asset_allowed?("bar.frobnitz")
|
50
|
+
@cfg.logical_path_patterns.push(Regexp.new("\\.frobnitz\\z"))
|
51
|
+
assert_equal true, asset_allowed?("bar.frobnitz")
|
46
52
|
end
|
47
53
|
|
48
54
|
test "should have a default empty user_config" do
|
@@ -110,10 +116,10 @@ class RequirejsHelperTest < ActionView::TestCase
|
|
110
116
|
Rails.application.config.requirejs.delete(:build_config)
|
111
117
|
end
|
112
118
|
|
113
|
-
def with_cdn
|
119
|
+
def with_cdn(protocol_relative = false)
|
114
120
|
Rails.application.config.requirejs.user_config = {
|
115
121
|
"paths" => {
|
116
|
-
"jquery" => "http
|
122
|
+
"jquery" => "#{ protocol_relative ? '' : 'http:' }//ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"
|
117
123
|
}
|
118
124
|
}
|
119
125
|
end
|
@@ -199,4 +205,13 @@ class RequirejsHelperTest < ActionView::TestCase
|
|
199
205
|
Rails.application.config.assets.digest = saved_digest
|
200
206
|
end
|
201
207
|
end
|
208
|
+
|
209
|
+
test "requirejs_include_tag with protocol relative CDN asset in paths" do
|
210
|
+
with_cdn(true)
|
211
|
+
|
212
|
+
render text: wrap(requirejs_include_tag)
|
213
|
+
|
214
|
+
assert_select "script:last-of-type",
|
215
|
+
text: Regexp.new("\\Arequire\\.config\\({.*\"paths\":{.*\"//ajax\\..*\".*}.*}\\);\\z")
|
216
|
+
end
|
202
217
|
end
|
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.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- John Whitley
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-05-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: railties
|