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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9662868a467492b5eef4a0e08bb869de8180cd98
4
- data.tar.gz: ade68c20abf5be41e9c36f6decb3f0ab1d5cff87
3
+ metadata.gz: fda664a0aedf72f1bdfcf7cca6794fae70f1a94a
4
+ data.tar.gz: 2a207f65ac70b4c808e574606bd8f01a27805a82
5
5
  SHA512:
6
- metadata.gz: 655c12c2405fe68955f7871b7ea5e7e18d8b5f0383114610062df569803415dd587874d09cf7709cdbf9200d10dcd2d9a6bda4842801452da2f6b93c1b5c1626
7
- data.tar.gz: 436c1416aecf1627747e1e1dcc494f617c500d4b0fba1891677e02e9f6cbf7a3268b265a2e7a6d277b21d9150eb94f788f1def0f7317d3ae50a4a42d04771ca9
6
+ metadata.gz: a73b711edfecbeebcb7811ad76cd01cb0657b40a490589d9038d88c53bbe7ac37b4c1c5be92bec85678b1c43fed3dc61d08a0307bdbe84180432b25969b7942f
7
+ data.tar.gz: b674a19e18e8b1e431c2d98e94a7e19787b4c3fd8214f40cb3884cf2318160790797824075d417c7267badda1eb185d945bef670c258ab6e7fc2ebc9fa2f12b4
@@ -0,0 +1,4 @@
1
+ rvm:
2
+ - 1.9.3-p327
3
+ - jruby-19mode
4
+ - 2.0.0
@@ -0,0 +1,7 @@
1
+ appraise "Sprockets 2.2" do
2
+ gem "sprockets", "2.2.2"
3
+ end
4
+
5
+ appraise "Sprockets 2.10" do
6
+ gem "sprockets", "2.10"
7
+ end
data/Gemfile CHANGED
@@ -2,5 +2,8 @@ source 'https://rubygems.org'
2
2
  gemspec
3
3
 
4
4
  gem 'pry'
5
+ gem 'pry-stack_explorer', platform: 'ruby'
5
6
  gem 'rake'
6
7
  gem 'rspec'
8
+ gem 'appraisal'
9
+ gem 'execjs', '< 2'
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 => :spec
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
- <%= javascript_path('sprockets/preload/assets').to_json %>,
119
- <%= Sprockets::Preload['sprockets/preload/assets'].digest.to_json %>,
120
- <%= Sprockets::Preload['sprockets/preload/assets'].length.to_json %>
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(<%= javascript_path('sprockets/preload/assets').to_json %>)
124
+ SprocketsPreload.loadSimple(<%= JSON.generate asset_path('sprockets/preload/assets'), quirks_mode: true %>)
@@ -0,0 +1,13 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "pry"
6
+ gem "pry-stack_explorer"
7
+ gem "rake"
8
+ gem "rspec"
9
+ gem "appraisal"
10
+ gem "execjs", "< 2"
11
+ gem "sprockets", "2.10"
12
+
13
+ gemspec :path=>"../"
@@ -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,13 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "pry"
6
+ gem "pry-stack_explorer"
7
+ gem "rake"
8
+ gem "rspec"
9
+ gem "appraisal"
10
+ gem "execjs", "< 2"
11
+ gem "sprockets", "2.2.2"
12
+
13
+ gemspec :path=>"../"
@@ -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!
@@ -1,4 +1,4 @@
1
- require 'active_support/all'
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
@@ -1,5 +1,5 @@
1
1
  module Sprockets
2
2
  module Preload
3
- VERSION = "0.0.5"
3
+ VERSION = "0.1.0"
4
4
  end
5
5
  end
@@ -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
 
@@ -23,6 +23,5 @@ Gem::Specification.new do |spec|
23
23
  spec.require_paths = ["lib"]
24
24
 
25
25
  spec.add_dependency "sprockets"
26
- spec.add_dependency "activesupport"
27
26
  spec.add_dependency "coffee-script"
28
27
  end
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.5
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-12 00:00:00.000000000 Z
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