sprockets 3.4.0 → 3.4.1
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of sprockets might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/README.md +38 -0
- data/lib/sprockets/path_utils.rb +4 -2
- data/lib/sprockets/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cb84129a09e33080f696f5eec822299e24279dba
|
4
|
+
data.tar.gz: fc5e73588c47c119874882bacdc8d8fd8da77567
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e2166e7a2f5b2bea3e6eda0a29d0fd4816709bd9e93e6d99cfd00a85ff7df26747ef7d386c8a9812081726948465f887f0721a46a00c6cf06c832ed5f29b6ea0
|
7
|
+
data.tar.gz: 19c40eff6ab900018c2e7e0210e5ece20eb7780729daa0b2402cc2819012291adb145863c718340fdce43787acbc25e5407b88794df53558cea8e12c4cd5c545
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -20,6 +20,44 @@ Or include it in your project's `Gemfile` with Bundler:
|
|
20
20
|
gem 'sprockets', '~> 3.0'
|
21
21
|
```
|
22
22
|
|
23
|
+
## Behavior
|
24
|
+
|
25
|
+
### Index files are proxies for folders
|
26
|
+
|
27
|
+
In sprockets index files such as `index.js` or `index.css` files inside of a folder will generate a file with the folder's name. So if you have a `foo/index.js` file it will compile down to `foo.js`. This is similar to NPM's behavior of using [folders as modules](https://nodejs.org/api/modules.html#modules_folders_as_modules). It is also somewhat similar to the way that a file in `public/my_folder/index.html` can be reached by a request to `/my_folder`. This means that you cannot directly use an index file. For example this would not work:
|
28
|
+
|
29
|
+
```
|
30
|
+
<%= asset_path("foo/index.js") %>
|
31
|
+
```
|
32
|
+
|
33
|
+
Instead you would need to use:
|
34
|
+
|
35
|
+
```
|
36
|
+
<%= asset_path("foo.js") %>
|
37
|
+
```
|
38
|
+
|
39
|
+
Why would you want to use this behavior? It is common behavior where you might want to include an entire directory of files in a top level javascript. You can do this in sprockets using `require_tree .`
|
40
|
+
|
41
|
+
```
|
42
|
+
//= require_tree .
|
43
|
+
```
|
44
|
+
|
45
|
+
This has the problem that files are required alphabetically. If your directory has `jquery-ui.js` and `jquery.min.js` then sprockets will require `jquery-ui.js` before `jquery` is required which won't work (because jquery-ui depends on jquery). Previously the only way to get the correct ordering would be to rename your files, something like `0-jquery-ui.js`. Instead of doing that you can use an index file.
|
46
|
+
|
47
|
+
For example, if you have an `application.js` and want all the files in the `foo/` folder you could do this:
|
48
|
+
|
49
|
+
```
|
50
|
+
//= require foo.js
|
51
|
+
```
|
52
|
+
|
53
|
+
Then create a file `foo/index.js` that requires all the files in that folder in any order you want:
|
54
|
+
|
55
|
+
```
|
56
|
+
//= require foo.min.js
|
57
|
+
//= require foo-ui.js
|
58
|
+
```
|
59
|
+
|
60
|
+
Now in your `application.js` will correctly load the `foo.min.js` before `foo-ui.js`. If you used `require_tree` it would not work correctly.
|
23
61
|
|
24
62
|
## Understanding the Sprockets Environment
|
25
63
|
|
data/lib/sprockets/path_utils.rb
CHANGED
@@ -55,9 +55,11 @@ module Sprockets
|
|
55
55
|
# Returns an empty `Array` if the directory does not exist.
|
56
56
|
def entries(path)
|
57
57
|
if File.directory?(path)
|
58
|
-
Dir.entries(path, :encoding => Encoding.default_internal)
|
58
|
+
entries = Dir.entries(path, :encoding => Encoding.default_internal)
|
59
|
+
entries.reject! { |entry|
|
59
60
|
entry =~ /^\.|~$|^\#.*\#$/
|
60
|
-
}
|
61
|
+
}
|
62
|
+
entries.sort!
|
61
63
|
else
|
62
64
|
[]
|
63
65
|
end
|
data/lib/sprockets/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sprockets
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.4.
|
4
|
+
version: 3.4.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sam Stephenson
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2015-
|
12
|
+
date: 2015-11-25 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rack
|
@@ -317,7 +317,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
317
317
|
version: '0'
|
318
318
|
requirements: []
|
319
319
|
rubyforge_project: sprockets
|
320
|
-
rubygems_version: 2.
|
320
|
+
rubygems_version: 2.5.0
|
321
321
|
signing_key:
|
322
322
|
specification_version: 4
|
323
323
|
summary: Rack-based asset packaging system
|