sprockets-preload 0.0.5 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +4 -0
- data/Appraisals +7 -0
- data/Gemfile +3 -0
- data/README.md +1 -0
- data/Rakefile +7 -1
- data/assets/sprockets/preload/load.coffee.erb +5 -5
- data/gemfiles/Sprockets_2.10.gemfile +13 -0
- data/gemfiles/Sprockets_2.10.gemfile.lock +64 -0
- data/gemfiles/Sprockets_2.2.gemfile +13 -0
- data/gemfiles/Sprockets_2.2.gemfile.lock +64 -0
- data/lib/sprockets/preload.rb +17 -11
- data/lib/sprockets/preload/engine.rb +5 -0
- data/lib/sprockets/preload/version.rb +1 -1
- data/spec/helpers/boot.rb +2 -2
- data/sprockets-preload.gemspec +0 -1
- metadata +8 -16
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fda664a0aedf72f1bdfcf7cca6794fae70f1a94a
|
4
|
+
data.tar.gz: 2a207f65ac70b4c808e574606bd8f01a27805a82
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a73b711edfecbeebcb7811ad76cd01cb0657b40a490589d9038d88c53bbe7ac37b4c1c5be92bec85678b1c43fed3dc61d08a0307bdbe84180432b25969b7942f
|
7
|
+
data.tar.gz: b674a19e18e8b1e431c2d98e94a7e19787b4c3fd8214f40cb3884cf2318160790797824075d417c7267badda1eb185d945bef670c258ab6e7fc2ebc9fa2f12b4
|
data/.travis.yml
ADDED
data/Appraisals
ADDED
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -2,6 +2,7 @@
|
|
2
2
|
|
3
3
|
[![Gem Version](https://badge.fury.io/rb/sprockets-preload.png)](http://badge.fury.io/rb/sprockets-preload)
|
4
4
|
[![Build Status](https://travis-ci.org/inossidabile/sprockets-preload.png?branch=master)](https://travis-ci.org/inossidabile/sprockets-preload)
|
5
|
+
[![Code Climate](https://codeclimate.com/github/inossidabile/sprockets-preload.png)](https://codeclimate.com/github/inossidabile/sprockets-preload)
|
5
6
|
|
6
7
|
Ever had heavy Javascript assets that were taking a while to download? **Sprockets::Preload** allows you to preload it using only the directives of **Sprockets**.
|
7
8
|
|
data/Rakefile
CHANGED
@@ -1,6 +1,12 @@
|
|
1
1
|
require 'bundler/gem_tasks'
|
2
2
|
require 'rspec/core/rake_task'
|
3
|
+
require 'appraisal'
|
3
4
|
|
4
5
|
RSpec::Core::RakeTask.new(:spec)
|
5
6
|
|
6
|
-
task :default => :
|
7
|
+
task :default => :all
|
8
|
+
|
9
|
+
desc 'Test the plugin under all supported Rails versions.'
|
10
|
+
task :all => ["appraisal:install"] do |t|
|
11
|
+
exec('rake appraisal spec')
|
12
|
+
end
|
@@ -55,7 +55,7 @@
|
|
55
55
|
try
|
56
56
|
attempt = localStorage['sprockets-preload']
|
57
57
|
attempt = JSON.parse(attempt) if attempt
|
58
|
-
catch
|
58
|
+
catch e
|
59
59
|
delete localStorage['sprockets-preload']
|
60
60
|
|
61
61
|
if attempt?.version == version
|
@@ -115,10 +115,10 @@
|
|
115
115
|
SprocketsPreload.triggerSuccess()
|
116
116
|
else if SprocketsPreload.localStorage && window.localStorage
|
117
117
|
SprocketsPreload.loadCached(
|
118
|
-
<%=
|
119
|
-
<%= Sprockets::Preload['sprockets/preload/assets'].digest
|
120
|
-
<%= Sprockets::Preload['sprockets/preload/assets'].length
|
118
|
+
<%= JSON.generate asset_path('sprockets/preload/assets'), quirks_mode: true %>,
|
119
|
+
<%= JSON.generate Sprockets::Preload['sprockets/preload/assets'].digest, quirks_mode: true %>,
|
120
|
+
<%= Sprockets::Preload['sprockets/preload/assets'].length %>
|
121
121
|
)
|
122
122
|
else
|
123
123
|
delete localStorage['sprockets-preload'] if window.localStorage?
|
124
|
-
SprocketsPreload.loadSimple(<%=
|
124
|
+
SprocketsPreload.loadSimple(<%= JSON.generate asset_path('sprockets/preload/assets'), quirks_mode: true %>)
|
@@ -0,0 +1,64 @@
|
|
1
|
+
PATH
|
2
|
+
remote: /Users/inossidabile/Repos/sprockets-preload
|
3
|
+
specs:
|
4
|
+
sprockets-preload (0.0.5)
|
5
|
+
coffee-script
|
6
|
+
sprockets
|
7
|
+
|
8
|
+
GEM
|
9
|
+
remote: https://rubygems.org/
|
10
|
+
specs:
|
11
|
+
appraisal (0.5.2)
|
12
|
+
bundler
|
13
|
+
rake
|
14
|
+
binding_of_caller (0.7.2)
|
15
|
+
debug_inspector (>= 0.0.1)
|
16
|
+
coderay (1.0.9)
|
17
|
+
coffee-script (2.2.0)
|
18
|
+
coffee-script-source
|
19
|
+
execjs
|
20
|
+
coffee-script-source (1.6.3)
|
21
|
+
debug_inspector (0.0.2)
|
22
|
+
diff-lcs (1.2.4)
|
23
|
+
execjs (1.4.0)
|
24
|
+
multi_json (~> 1.0)
|
25
|
+
hike (1.2.3)
|
26
|
+
method_source (0.8.2)
|
27
|
+
multi_json (1.7.9)
|
28
|
+
pry (0.9.12.2)
|
29
|
+
coderay (~> 1.0.5)
|
30
|
+
method_source (~> 0.8)
|
31
|
+
slop (~> 3.4)
|
32
|
+
pry-stack_explorer (0.4.9.1)
|
33
|
+
binding_of_caller (>= 0.7)
|
34
|
+
pry (>= 0.9.11)
|
35
|
+
rack (1.5.2)
|
36
|
+
rake (10.1.0)
|
37
|
+
rspec (2.14.1)
|
38
|
+
rspec-core (~> 2.14.0)
|
39
|
+
rspec-expectations (~> 2.14.0)
|
40
|
+
rspec-mocks (~> 2.14.0)
|
41
|
+
rspec-core (2.14.5)
|
42
|
+
rspec-expectations (2.14.2)
|
43
|
+
diff-lcs (>= 1.1.3, < 2.0)
|
44
|
+
rspec-mocks (2.14.3)
|
45
|
+
slop (3.4.6)
|
46
|
+
sprockets (2.10.0)
|
47
|
+
hike (~> 1.2)
|
48
|
+
multi_json (~> 1.0)
|
49
|
+
rack (~> 1.0)
|
50
|
+
tilt (~> 1.1, != 1.3.0)
|
51
|
+
tilt (1.4.1)
|
52
|
+
|
53
|
+
PLATFORMS
|
54
|
+
ruby
|
55
|
+
|
56
|
+
DEPENDENCIES
|
57
|
+
appraisal
|
58
|
+
execjs (< 2)
|
59
|
+
pry
|
60
|
+
pry-stack_explorer
|
61
|
+
rake
|
62
|
+
rspec
|
63
|
+
sprockets (= 2.10)
|
64
|
+
sprockets-preload!
|
@@ -0,0 +1,64 @@
|
|
1
|
+
PATH
|
2
|
+
remote: /Users/inossidabile/Repos/sprockets-preload
|
3
|
+
specs:
|
4
|
+
sprockets-preload (0.0.5)
|
5
|
+
coffee-script
|
6
|
+
sprockets
|
7
|
+
|
8
|
+
GEM
|
9
|
+
remote: https://rubygems.org/
|
10
|
+
specs:
|
11
|
+
appraisal (0.5.2)
|
12
|
+
bundler
|
13
|
+
rake
|
14
|
+
binding_of_caller (0.7.2)
|
15
|
+
debug_inspector (>= 0.0.1)
|
16
|
+
coderay (1.0.9)
|
17
|
+
coffee-script (2.2.0)
|
18
|
+
coffee-script-source
|
19
|
+
execjs
|
20
|
+
coffee-script-source (1.6.3)
|
21
|
+
debug_inspector (0.0.2)
|
22
|
+
diff-lcs (1.2.4)
|
23
|
+
execjs (1.4.0)
|
24
|
+
multi_json (~> 1.0)
|
25
|
+
hike (1.2.3)
|
26
|
+
method_source (0.8.2)
|
27
|
+
multi_json (1.7.9)
|
28
|
+
pry (0.9.12.2)
|
29
|
+
coderay (~> 1.0.5)
|
30
|
+
method_source (~> 0.8)
|
31
|
+
slop (~> 3.4)
|
32
|
+
pry-stack_explorer (0.4.9.1)
|
33
|
+
binding_of_caller (>= 0.7)
|
34
|
+
pry (>= 0.9.11)
|
35
|
+
rack (1.4.5)
|
36
|
+
rake (10.1.0)
|
37
|
+
rspec (2.14.1)
|
38
|
+
rspec-core (~> 2.14.0)
|
39
|
+
rspec-expectations (~> 2.14.0)
|
40
|
+
rspec-mocks (~> 2.14.0)
|
41
|
+
rspec-core (2.14.5)
|
42
|
+
rspec-expectations (2.14.2)
|
43
|
+
diff-lcs (>= 1.1.3, < 2.0)
|
44
|
+
rspec-mocks (2.14.3)
|
45
|
+
slop (3.4.6)
|
46
|
+
sprockets (2.2.2)
|
47
|
+
hike (~> 1.2)
|
48
|
+
multi_json (~> 1.0)
|
49
|
+
rack (~> 1.0)
|
50
|
+
tilt (~> 1.1, != 1.3.0)
|
51
|
+
tilt (1.4.1)
|
52
|
+
|
53
|
+
PLATFORMS
|
54
|
+
ruby
|
55
|
+
|
56
|
+
DEPENDENCIES
|
57
|
+
appraisal
|
58
|
+
execjs (< 2)
|
59
|
+
pry
|
60
|
+
pry-stack_explorer
|
61
|
+
rake
|
62
|
+
rspec
|
63
|
+
sprockets (= 2.2.2)
|
64
|
+
sprockets-preload!
|
data/lib/sprockets/preload.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
require '
|
1
|
+
require 'json'
|
2
2
|
require 'sprockets'
|
3
3
|
require 'sprockets/preload/directive_processor'
|
4
4
|
require 'sprockets/preload/context'
|
@@ -9,16 +9,7 @@ require 'sprockets/preload/engine' if defined?(Rails)
|
|
9
9
|
Sprockets::DirectiveProcessor.send :include, Sprockets::Preload::DirectiveProcessor
|
10
10
|
Sprockets::Context.send :include, Sprockets::Preload::Context
|
11
11
|
|
12
|
-
Sprockets.append_path File.expand_path('../../../assets', __FILE__)
|
13
12
|
|
14
|
-
# Pass in current environment condition to mark if loading should be stubbed
|
15
|
-
Sprockets.register_postprocessor 'application/javascript', :preload do |context, data|
|
16
|
-
if context._assets_to_preload
|
17
|
-
data << "SprocketsPreload.inline = true;" unless context.preload?
|
18
|
-
end
|
19
|
-
|
20
|
-
data
|
21
|
-
end
|
22
13
|
|
23
14
|
module Sprockets
|
24
15
|
module Preload
|
@@ -28,6 +19,19 @@ module Sprockets
|
|
28
19
|
attr_accessor :precompiles
|
29
20
|
end
|
30
21
|
|
22
|
+
def self.setup_sprockets(receiver)
|
23
|
+
receiver.append_path File.expand_path('../../../assets', __FILE__)
|
24
|
+
|
25
|
+
# Pass in current environment condition to mark if loading should be stubbed
|
26
|
+
receiver.register_postprocessor 'application/javascript', :preload do |context, data|
|
27
|
+
if context._assets_to_preload
|
28
|
+
data << "SprocketsPreload.inline = true;" unless context.preload?
|
29
|
+
end
|
30
|
+
|
31
|
+
data
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
31
35
|
#
|
32
36
|
# Forks circular calls protection to allow cross-tree assets interactions
|
33
37
|
#
|
@@ -88,4 +92,6 @@ module Sprockets
|
|
88
92
|
to_preload
|
89
93
|
end
|
90
94
|
end
|
91
|
-
end
|
95
|
+
end
|
96
|
+
|
97
|
+
Sprockets::Preload.setup_sprockets(Sprockets) if Sprockets.respond_to? :append_path
|
@@ -9,6 +9,11 @@ module Sprockets
|
|
9
9
|
Sprockets::Preload.environment = app.assets
|
10
10
|
Sprockets::Preload.precompiles = app.config.assets.precompile
|
11
11
|
|
12
|
+
# Workaround for older sprockets
|
13
|
+
unless Sprockets.respond_to? :append_path
|
14
|
+
Sprockets::Preload.setup_sprockets(Sprockets::Preload.environment)
|
15
|
+
end
|
16
|
+
|
12
17
|
app.config.assets.precompile += ['sprockets/preload/assets.js']
|
13
18
|
end
|
14
19
|
end
|
data/spec/helpers/boot.rb
CHANGED
@@ -9,16 +9,16 @@ Sprockets::Context.class_eval do
|
|
9
9
|
end
|
10
10
|
|
11
11
|
Sprockets::Preload.precompiles = []
|
12
|
-
Sprockets.append_path File.expand_path('../assets', __FILE__)
|
13
12
|
|
14
13
|
RSpec.configure do |config|
|
15
14
|
config.treat_symbols_as_metadata_keys_with_true_values = true
|
16
15
|
config.run_all_when_everything_filtered = true
|
17
16
|
config.filter_run :focus
|
18
|
-
config.order = 'random:59695'
|
19
17
|
|
20
18
|
config.before(:each) do
|
21
19
|
Sprockets::Preload.environment = Sprockets::Environment.new
|
20
|
+
Sprockets::Preload.setup_sprockets Sprockets::Preload.environment unless Sprockets.respond_to? :append_path
|
21
|
+
Sprockets::Preload.environment.append_path File.expand_path('../assets', __FILE__)
|
22
22
|
end
|
23
23
|
end
|
24
24
|
|
data/sprockets-preload.gemspec
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sprockets-preload
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Boris Staal
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-08-
|
11
|
+
date: 2013-08-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: sprockets
|
@@ -24,20 +24,6 @@ dependencies:
|
|
24
24
|
- - '>='
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '0'
|
27
|
-
- !ruby/object:Gem::Dependency
|
28
|
-
name: activesupport
|
29
|
-
requirement: !ruby/object:Gem::Requirement
|
30
|
-
requirements:
|
31
|
-
- - '>='
|
32
|
-
- !ruby/object:Gem::Version
|
33
|
-
version: '0'
|
34
|
-
type: :runtime
|
35
|
-
prerelease: false
|
36
|
-
version_requirements: !ruby/object:Gem::Requirement
|
37
|
-
requirements:
|
38
|
-
- - '>='
|
39
|
-
- !ruby/object:Gem::Version
|
40
|
-
version: '0'
|
41
27
|
- !ruby/object:Gem::Dependency
|
42
28
|
name: coffee-script
|
43
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -60,12 +46,18 @@ extensions: []
|
|
60
46
|
extra_rdoc_files: []
|
61
47
|
files:
|
62
48
|
- .gitignore
|
49
|
+
- .travis.yml
|
50
|
+
- Appraisals
|
63
51
|
- Gemfile
|
64
52
|
- LICENSE.txt
|
65
53
|
- README.md
|
66
54
|
- Rakefile
|
67
55
|
- assets/sprockets/preload/assets.js.erb
|
68
56
|
- assets/sprockets/preload/load.coffee.erb
|
57
|
+
- gemfiles/Sprockets_2.10.gemfile
|
58
|
+
- gemfiles/Sprockets_2.10.gemfile.lock
|
59
|
+
- gemfiles/Sprockets_2.2.gemfile
|
60
|
+
- gemfiles/Sprockets_2.2.gemfile.lock
|
69
61
|
- lib/sprockets/preload.rb
|
70
62
|
- lib/sprockets/preload/context.rb
|
71
63
|
- lib/sprockets/preload/directive_processor.rb
|