sprockets-rails 2.0.0.backport1 → 2.0.0.rc1
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +1 -3
- data/lib/sprockets/rails/helper.rb +3 -2
- data/lib/sprockets/rails/task.rb +1 -46
- data/lib/sprockets/railtie.rb +43 -53
- metadata +26 -16
- checksums.yaml +0 -7
data/README.md
CHANGED
@@ -31,7 +31,7 @@ Nuke `public/assets` and clear the Sprockets file system cache.
|
|
31
31
|
|
32
32
|
#### Customize
|
33
33
|
|
34
|
-
If the basic tasks don't do all that you need,
|
34
|
+
If the basic tasks don't do all that you need, its straight forward to redefined them and replace them with something more specific to your app.
|
35
35
|
|
36
36
|
You can also redefine the task with the built in task generator.
|
37
37
|
|
@@ -44,8 +44,6 @@ Sprockets::Rails::Task.new do |t|
|
|
44
44
|
end
|
45
45
|
```
|
46
46
|
|
47
|
-
Each asset task will invoke `assets:environment` first. By default this loads the Rails environment. You can override this task to add or remove dependencies for your specific compilation environment.
|
48
|
-
|
49
47
|
Also see [Sprockest::Rails::Task](https://github.com/josh/sprockets-rails/blob/master/lib/sprockets/rails/task.rb) and [Rake::SprocketsTask](https://github.com/sstephenson/sprockets/blob/master/lib/rake/sprocketstask.rb).
|
50
48
|
|
51
49
|
|
@@ -1,5 +1,6 @@
|
|
1
1
|
require 'action_view'
|
2
2
|
require 'sprockets'
|
3
|
+
|
3
4
|
require 'active_support/core_ext/class/attribute'
|
4
5
|
|
5
6
|
module Sprockets
|
@@ -94,7 +95,7 @@ module Sprockets
|
|
94
95
|
else
|
95
96
|
super(source, options)
|
96
97
|
end
|
97
|
-
}.
|
98
|
+
}.join("\n").html_safe
|
98
99
|
else
|
99
100
|
sources.push(options)
|
100
101
|
super(*sources)
|
@@ -116,7 +117,7 @@ module Sprockets
|
|
116
117
|
else
|
117
118
|
super(source, options)
|
118
119
|
end
|
119
|
-
}.
|
120
|
+
}.join("\n").html_safe
|
120
121
|
else
|
121
122
|
sources.push(options)
|
122
123
|
super(*sources)
|
data/lib/sprockets/rails/task.rb
CHANGED
@@ -5,55 +5,10 @@ require 'sprockets'
|
|
5
5
|
module Sprockets
|
6
6
|
module Rails
|
7
7
|
class Task < Rake::SprocketsTask
|
8
|
-
attr_accessor :
|
9
|
-
|
10
|
-
def initialize(app = nil)
|
11
|
-
self.app = app
|
12
|
-
super()
|
13
|
-
end
|
14
|
-
|
15
|
-
def environment
|
16
|
-
if app
|
17
|
-
app.assets
|
18
|
-
else
|
19
|
-
super
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
|
-
def output
|
24
|
-
if app
|
25
|
-
File.join(app.root, 'public', app.config.assets.prefix)
|
26
|
-
else
|
27
|
-
super
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
|
-
def assets
|
32
|
-
if app
|
33
|
-
app.config.assets.precompile
|
34
|
-
else
|
35
|
-
super
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
|
-
def cache_path
|
40
|
-
if app
|
41
|
-
"#{app.config.root}/tmp/cache/assets"
|
42
|
-
else
|
43
|
-
@cache_path
|
44
|
-
end
|
45
|
-
end
|
46
|
-
attr_writer :cache_path
|
8
|
+
attr_accessor :cache_path
|
47
9
|
|
48
10
|
def define
|
49
11
|
namespace :assets do
|
50
|
-
# Override this task change the loaded dependencies
|
51
|
-
desc "Load asset compile environment"
|
52
|
-
task :environment do
|
53
|
-
# Load full Rails environment by default
|
54
|
-
Rake::Task['environment'].invoke
|
55
|
-
end
|
56
|
-
|
57
12
|
desc "Compile all the assets named in config.assets.precompile"
|
58
13
|
task :precompile => :environment do
|
59
14
|
with_logger do
|
data/lib/sprockets/railtie.rb
CHANGED
@@ -1,7 +1,6 @@
|
|
1
1
|
require 'rails'
|
2
2
|
require 'rails/railtie'
|
3
3
|
require 'action_controller/railtie'
|
4
|
-
require 'active_support/core_ext/module/remove_method'
|
5
4
|
require 'sprockets'
|
6
5
|
require 'sprockets/rails/helper'
|
7
6
|
|
@@ -10,27 +9,46 @@ module Rails
|
|
10
9
|
# Hack: We need to remove Rails' built in config.assets so we can
|
11
10
|
# do our own thing.
|
12
11
|
class Configuration
|
13
|
-
|
12
|
+
if instance_methods.map(&:to_sym).include?(:assets)
|
13
|
+
undef_method :assets
|
14
|
+
end
|
14
15
|
end
|
15
16
|
|
16
|
-
# Undefine Rails' assets method before redefining it, to avoid warnings.
|
17
|
-
remove_possible_method :assets
|
18
|
-
remove_possible_method :assets=
|
19
|
-
|
20
17
|
# Returns Sprockets::Environment for app config.
|
21
18
|
def assets
|
22
|
-
@assets
|
23
|
-
|
19
|
+
return @assets if defined? @assets
|
20
|
+
|
21
|
+
@assets = Sprockets::Environment.new(root.to_s) do |env|
|
22
|
+
env.version = ::Rails.env + "-#{config.assets.version}"
|
24
23
|
|
25
24
|
path = "#{config.root}/tmp/cache/assets/#{::Rails.env}"
|
26
25
|
env.cache = Sprockets::Cache::FileStore.new(path)
|
27
26
|
|
27
|
+
config.assets.paths.each do |path|
|
28
|
+
env.append_path(path)
|
29
|
+
end
|
30
|
+
|
31
|
+
env.js_compressor = config.assets.js_compressor
|
32
|
+
env.css_compressor = config.assets.css_compressor
|
33
|
+
|
28
34
|
env.context_class.class_eval do
|
29
35
|
include ::Sprockets::Rails::Helper
|
30
36
|
end
|
37
|
+
env.context_class.assets_prefix = config.assets.prefix
|
38
|
+
env.context_class.digest_assets = config.assets.digest
|
39
|
+
env.context_class.config = config.action_controller
|
40
|
+
|
41
|
+
config.assets._blocks.each do |block|
|
42
|
+
block.call env
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
if config.cache_classes
|
47
|
+
@assets = @assets.index
|
31
48
|
end
|
49
|
+
|
50
|
+
@assets
|
32
51
|
end
|
33
|
-
attr_writer :assets
|
34
52
|
end
|
35
53
|
end
|
36
54
|
|
@@ -51,45 +69,33 @@ module Sprockets
|
|
51
69
|
config.assets.paths = []
|
52
70
|
config.assets.prefix = "/assets"
|
53
71
|
config.assets.precompile = [LOOSE_APP_ASSETS, /(?:\/|\\|\A)application\.(css|js)$/]
|
54
|
-
config.assets.version =
|
72
|
+
config.assets.version = ''
|
55
73
|
config.assets.debug = false
|
56
74
|
config.assets.compile = true
|
57
75
|
config.assets.digest = false
|
58
76
|
|
59
77
|
rake_tasks do |app|
|
60
78
|
require 'sprockets/rails/task'
|
61
|
-
Sprockets::Rails::Task.new(app)
|
62
|
-
end
|
63
79
|
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
unless config.assets.version.blank?
|
70
|
-
app.assets.version += "-#{config.assets.version}"
|
80
|
+
Sprockets::Rails::Task.new do |t|
|
81
|
+
t.environment = lambda { app.assets }
|
82
|
+
t.output = File.join(app.root, 'public', app.config.assets.prefix)
|
83
|
+
t.assets = app.config.assets.precompile
|
84
|
+
t.cache_path = "#{app.config.root}/tmp/cache/assets"
|
71
85
|
end
|
86
|
+
end
|
72
87
|
|
73
|
-
|
74
|
-
config.assets.
|
75
|
-
app.assets.append_path path
|
76
|
-
end
|
88
|
+
config.after_initialize do |app|
|
89
|
+
manifest_path = File.join(app.root, 'public', app.config.assets.prefix)
|
77
90
|
|
78
|
-
|
91
|
+
ActiveSupport.on_load(:action_view) do
|
79
92
|
include Sprockets::Rails::Helper
|
80
93
|
|
81
|
-
|
82
|
-
self.
|
83
|
-
self.
|
84
|
-
self.assets_prefix = config.assets.prefix
|
85
|
-
|
86
|
-
# Copy over to Sprockets as well
|
87
|
-
context = app.assets.context_class
|
88
|
-
context.assets_prefix = config.assets.prefix
|
89
|
-
context.digest_assets = config.assets.digest
|
90
|
-
context.config = config.action_controller
|
94
|
+
self.debug_assets = app.config.assets.debug
|
95
|
+
self.digest_assets = app.config.assets.digest
|
96
|
+
self.assets_prefix = app.config.assets.prefix
|
91
97
|
|
92
|
-
if config.assets.compile
|
98
|
+
if app.config.assets.compile
|
93
99
|
self.assets_environment = app.assets
|
94
100
|
self.assets_manifest = Sprockets::Manifest.new(app.assets, manifest_path)
|
95
101
|
else
|
@@ -97,26 +103,10 @@ module Sprockets
|
|
97
103
|
end
|
98
104
|
end
|
99
105
|
|
100
|
-
app.
|
101
|
-
app.assets.css_compressor = config.assets.css_compressor
|
102
|
-
|
103
|
-
# Run app.assets.configure blocks
|
104
|
-
config.assets._blocks.each do |block|
|
105
|
-
block.call app.assets
|
106
|
-
end
|
107
|
-
|
108
|
-
# No more configuration changes at this point.
|
109
|
-
# With cache classes on, Sprockets won't check the FS when files
|
110
|
-
# change. Preferable in production when the FS only changes on
|
111
|
-
# deploys when the app restarts.
|
112
|
-
if config.cache_classes
|
113
|
-
app.assets = app.assets.index
|
114
|
-
end
|
115
|
-
|
116
|
-
if config.assets.compile
|
106
|
+
if app.config.assets.compile
|
117
107
|
if app.routes.respond_to?(:prepend)
|
118
108
|
app.routes.prepend do
|
119
|
-
mount app.assets => config.assets.prefix
|
109
|
+
mount app.assets => app.config.assets.prefix
|
120
110
|
end
|
121
111
|
end
|
122
112
|
end
|
metadata
CHANGED
@@ -1,69 +1,78 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sprockets-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.0.
|
4
|
+
version: 2.0.0.rc1
|
5
|
+
prerelease: 6
|
5
6
|
platform: ruby
|
6
7
|
authors:
|
7
8
|
- Joshua Peek
|
8
9
|
autorequire:
|
9
10
|
bindir: bin
|
10
11
|
cert_chain: []
|
11
|
-
date:
|
12
|
+
date: 2012-10-19 00:00:00.000000000 Z
|
12
13
|
dependencies:
|
13
14
|
- !ruby/object:Gem::Dependency
|
14
15
|
name: sprockets
|
15
16
|
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
16
18
|
requirements:
|
17
19
|
- - ~>
|
18
20
|
- !ruby/object:Gem::Version
|
19
|
-
version: 2.
|
21
|
+
version: '2.8'
|
20
22
|
type: :runtime
|
21
23
|
prerelease: false
|
22
24
|
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
23
26
|
requirements:
|
24
27
|
- - ~>
|
25
28
|
- !ruby/object:Gem::Version
|
26
|
-
version: 2.
|
29
|
+
version: '2.8'
|
27
30
|
- !ruby/object:Gem::Dependency
|
28
31
|
name: actionpack
|
29
32
|
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
30
34
|
requirements:
|
31
|
-
- - '>='
|
35
|
+
- - ! '>='
|
32
36
|
- !ruby/object:Gem::Version
|
33
37
|
version: '3.0'
|
34
38
|
type: :runtime
|
35
39
|
prerelease: false
|
36
40
|
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
37
42
|
requirements:
|
38
|
-
- - '>='
|
43
|
+
- - ! '>='
|
39
44
|
- !ruby/object:Gem::Version
|
40
45
|
version: '3.0'
|
41
46
|
- !ruby/object:Gem::Dependency
|
42
47
|
name: activesupport
|
43
48
|
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
44
50
|
requirements:
|
45
|
-
- - '>='
|
51
|
+
- - ! '>='
|
46
52
|
- !ruby/object:Gem::Version
|
47
53
|
version: '3.0'
|
48
54
|
type: :runtime
|
49
55
|
prerelease: false
|
50
56
|
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
51
58
|
requirements:
|
52
|
-
- - '>='
|
59
|
+
- - ! '>='
|
53
60
|
- !ruby/object:Gem::Version
|
54
61
|
version: '3.0'
|
55
62
|
- !ruby/object:Gem::Dependency
|
56
63
|
name: rake
|
57
64
|
requirement: !ruby/object:Gem::Requirement
|
65
|
+
none: false
|
58
66
|
requirements:
|
59
|
-
- - '>='
|
67
|
+
- - ! '>='
|
60
68
|
- !ruby/object:Gem::Version
|
61
69
|
version: '0'
|
62
70
|
type: :development
|
63
71
|
prerelease: false
|
64
72
|
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
65
74
|
requirements:
|
66
|
-
- - '>='
|
75
|
+
- - ! '>='
|
67
76
|
- !ruby/object:Gem::Version
|
68
77
|
version: '0'
|
69
78
|
description:
|
@@ -79,27 +88,28 @@ files:
|
|
79
88
|
- lib/sprockets/rails/task.rb
|
80
89
|
- lib/sprockets/rails.rb
|
81
90
|
- lib/sprockets/railtie.rb
|
82
|
-
homepage: https://github.com/
|
91
|
+
homepage: https://github.com/josh/sprockets-rails
|
83
92
|
licenses: []
|
84
|
-
metadata: {}
|
85
93
|
post_install_message:
|
86
94
|
rdoc_options: []
|
87
95
|
require_paths:
|
88
96
|
- lib
|
89
97
|
required_ruby_version: !ruby/object:Gem::Requirement
|
98
|
+
none: false
|
90
99
|
requirements:
|
91
|
-
- - '>='
|
100
|
+
- - ! '>='
|
92
101
|
- !ruby/object:Gem::Version
|
93
102
|
version: '0'
|
94
103
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
104
|
+
none: false
|
95
105
|
requirements:
|
96
|
-
- - '>'
|
106
|
+
- - ! '>'
|
97
107
|
- !ruby/object:Gem::Version
|
98
108
|
version: 1.3.1
|
99
109
|
requirements: []
|
100
110
|
rubyforge_project:
|
101
|
-
rubygems_version:
|
111
|
+
rubygems_version: 1.8.24
|
102
112
|
signing_key:
|
103
|
-
specification_version:
|
113
|
+
specification_version: 3
|
104
114
|
summary: Sprockets Rails integration
|
105
115
|
test_files: []
|
checksums.yaml
DELETED
@@ -1,7 +0,0 @@
|
|
1
|
-
---
|
2
|
-
SHA1:
|
3
|
-
metadata.gz: b54d7de577eca6df5b44639df6929423a10b7311
|
4
|
-
data.tar.gz: 4df8d48affeec6bb7d1f1b4243a1c58c02642ef1
|
5
|
-
SHA512:
|
6
|
-
metadata.gz: e28cb27742cf4e57dfdce771577f6040391935b70565c53e8740da42587417f44d15fbdd7d36e34b7cc8dfb986cf6411b150791879bb78de374d1d1696ef6800
|
7
|
-
data.tar.gz: 2192f3965ac0b09a84255e2532965be55b47daf504f996c5695b1fa509586957ac625ab48039e39c7854faf48cf2ba8518be43db75f9799b20b87bea95e265c4
|