sprockets_rails3_backport 0.0.1 → 0.0.2

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.
data/README.markdown CHANGED
@@ -27,15 +27,9 @@ Here are the various `config.assets` options and their defaults:
27
27
  config.assets.compile = true
28
28
  config.assets.digest = false
29
29
  config.assets.manifest = nil
30
- config.assets.cache_store = false
30
+ config.assets.cache_store = [ :file_store, "#{root}/tmp/cache/assets/" ]
31
31
  config.assets.js_compressor = nil
32
32
  config.assets.css_compressor = nil
33
33
  config.assets.initialize_on_precompile = true
34
34
 
35
-
36
- ## Differences from Rails 3.1.3
37
-
38
- * no `config.assets.enabled`
39
- * `config.assets.cache_store` defaults to false, so you probably want to set it yourself
40
-
41
-
35
+ `config.assets.enabled` is not used.
@@ -1,5 +1,46 @@
1
1
  module Rails
2
2
  class Application < Engine
3
+ class Configuration < ::Rails::Engine::Configuration
4
+ # we need to do this over again for Rails::Application::Configuration because
5
+ # the Rails 3.0 implementation squashes the paths.vendor that we made in
6
+ # application_ext.rb.
7
+
8
+ def paths_with_vendor_assets
9
+ @paths ||= begin
10
+ paths = paths_without_vendor_assets
11
+ paths.vendor "vendor", :load_path => true
12
+ paths.vendor.assets "vendor/assets", :glob => "*"
13
+ paths.vendor.plugins "vendor/plugins"
14
+ paths
15
+ end
16
+ end
17
+
18
+ alias_method_chain :paths, :vendor_assets
19
+
20
+ def initialize_with_assets(*args)
21
+ initialize_without_assets(*args)
22
+ @assets = ActiveSupport::OrderedOptions.new
23
+ # @assets.enabled = false
24
+ @assets.paths = []
25
+ @assets.precompile = [ Proc.new{ |path| !['.js', '.css'].include?(File.extname(path)) },
26
+ /(?:\/|\\|\A)application\.(css|js)$/ ]
27
+ @assets.prefix = "/assets"
28
+ @assets.version = ''
29
+ @assets.debug = false
30
+ @assets.compile = true
31
+ @assets.digest = false
32
+ @assets.manifest = nil
33
+ @assets.cache_store = [ :file_store, "#{root}/tmp/cache/assets/" ]
34
+ @assets.js_compressor = nil
35
+ @assets.css_compressor = nil
36
+ @assets.initialize_on_precompile = true
37
+ end
38
+
39
+ alias_method_chain :initialize, :assets
40
+
41
+ attr_accessor :assets
42
+ end
43
+
3
44
  attr_accessor :assets
4
45
  end
5
- end
46
+ end
@@ -0,0 +1,24 @@
1
+ module Rails
2
+ class Engine < Railtie
3
+ class Configuration < ::Rails::Railtie::Configuration
4
+ def paths_with_assets
5
+ @paths ||= begin
6
+ paths = paths_without_assets
7
+ paths.app.assets "app/assets", :glob => "*"
8
+ paths.lib.assets "lib/assets", :glob => "*"
9
+ paths.vendor "vendor", :load_path => true
10
+ paths.vendor.assets "vendor/assets", :glob => "*"
11
+ paths
12
+ end
13
+ end
14
+
15
+ alias_method_chain :paths, :assets
16
+ end
17
+
18
+ initializer :append_assets_path, :group => :all do |app|
19
+ app.config.assets.paths.unshift(*paths.vendor.assets.paths)
20
+ app.config.assets.paths.unshift(*paths.lib.assets.paths)
21
+ app.config.assets.paths.unshift(*paths.app.assets.paths)
22
+ end
23
+ end
24
+ end
@@ -35,14 +35,20 @@ namespace :assets do
35
35
  # Ensure that action view is loaded and the appropriate
36
36
  # sprockets hooks get executed
37
37
  _ = ActionView::Base
38
-
39
38
  config = Rails.application.config
40
39
  config.assets.compile = true
41
- config.assets.digest = digest unless digest.nil?
40
+ config.assets.compress = true
41
+ if digest.nil?
42
+ if ENV['ASSETS_DIGEST'].present?
43
+ config.assets.digest = (ENV['ASSETS_DIGEST'].to_s == 'true')
44
+ end
45
+ else
46
+ config.assets.digest = digest
47
+ end
42
48
  config.assets.digests = {}
43
49
 
44
50
  env = Rails.application.assets
45
- target = File.join(Rails.public_path, config.assets.prefix)
51
+ target = ENV['ASSETS_TARGET'] || File.join(Rails.public_path, config.assets.prefix)
46
52
  compiler = Sprockets::StaticCompiler.new(env,
47
53
  target,
48
54
  config.assets.precompile,
@@ -79,7 +85,7 @@ namespace :assets do
79
85
  namespace :clean do
80
86
  task :all => ["assets:environment", "tmp:cache:clear"] do
81
87
  config = Rails.application.config
82
- public_asset_path = File.join(Rails.public_path, config.assets.prefix)
88
+ public_asset_path = ENV['ASSETS_TARGET'] || File.join(Rails.public_path, config.assets.prefix)
83
89
  rm_rf public_asset_path, :secure => true
84
90
  end
85
91
  end
@@ -88,7 +94,7 @@ namespace :assets do
88
94
  if Rails.application.config.assets.initialize_on_precompile
89
95
  Rake::Task["environment"].invoke
90
96
  else
91
- Rails.application.initialize!(:assets)
97
+ Rails.application.initialize!
92
98
  Sprockets::Bootstrap.new(Rails.application).run
93
99
  end
94
100
  end
@@ -57,10 +57,10 @@ module Sprockets
57
57
  options[:body] ? "#{path}?body=1" : path
58
58
  end
59
59
 
60
- def image_path(source)
61
- asset_path(source)
62
- end
63
- alias_method :path_to_image, :image_path # aliased to avoid conflicts with an image_path named route
60
+ # def image_path(source)
61
+ # asset_path(source)
62
+ # end
63
+ # alias_method :path_to_image, :image_path # aliased to avoid conflicts with an image_path named route
64
64
 
65
65
  def javascript_path(source)
66
66
  asset_path(source)
@@ -1,5 +1,4 @@
1
1
  # require "action_controller/railtie"
2
- require "extensions/application_ext"
3
2
 
4
3
  module Sprockets
5
4
  autoload :Bootstrap, "sprockets/bootstrap"
@@ -10,23 +9,6 @@ module Sprockets
10
9
 
11
10
  # TODO: Get rid of config.assets.enabled
12
11
  class Railtie < ::Rails::Railtie
13
- # config.action_controller.default_asset_host_protocol = :relative
14
- config.assets = ActiveSupport::OrderedOptions.new
15
- # config.assets.enabled = false
16
- config.assets.paths = []
17
- config.assets.precompile = [ Proc.new{ |path| !['.js', '.css'].include?(File.extname(path)) },
18
- /(?:\/|\\|\A)application\.(css|js)$/ ]
19
- config.assets.prefix = "/assets"
20
- config.assets.version = ''
21
- config.assets.debug = false
22
- config.assets.compile = true
23
- config.assets.digest = false
24
- config.assets.manifest = nil
25
- config.assets.cache_store = false
26
- config.assets.js_compressor = nil
27
- config.assets.css_compressor = nil
28
- config.assets.initialize_on_precompile = true
29
-
30
12
  rake_tasks do
31
13
  load "sprockets/assets.rake"
32
14
  end
@@ -36,7 +36,7 @@ module Sprockets
36
36
  filename = File.join(target, path)
37
37
  FileUtils.mkdir_p File.dirname(filename)
38
38
  asset.write_to(filename)
39
- asset.write_to("#{filename}.gz") if filename.to_s =~ /\.(css|js)$/
39
+ # asset.write_to("#{filename}.gz") if filename.to_s =~ /\.(css|js)$/
40
40
  end
41
41
  end
42
42
 
@@ -1 +1,4 @@
1
+ require "extensions/engine_ext"
2
+ require "extensions/application_ext"
3
+
1
4
  require "sprockets/railtie"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sprockets_rails3_backport
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,12 +9,12 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-12-01 00:00:00.000000000 -05:00
12
+ date: 2011-12-13 00:00:00.000000000 -05:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rails
17
- requirement: &2156849120 !ruby/object:Gem::Requirement
17
+ requirement: &2168815640 !ruby/object:Gem::Requirement
18
18
  none: false
19
19
  requirements:
20
20
  - - ~>
@@ -22,10 +22,10 @@ dependencies:
22
22
  version: 3.0.0
23
23
  type: :runtime
24
24
  prerelease: false
25
- version_requirements: *2156849120
25
+ version_requirements: *2168815640
26
26
  - !ruby/object:Gem::Dependency
27
27
  name: sprockets
28
- requirement: &2156848660 !ruby/object:Gem::Requirement
28
+ requirement: &2168815160 !ruby/object:Gem::Requirement
29
29
  none: false
30
30
  requirements:
31
31
  - - =
@@ -33,7 +33,7 @@ dependencies:
33
33
  version: 2.1.2
34
34
  type: :runtime
35
35
  prerelease: false
36
- version_requirements: *2156848660
36
+ version_requirements: *2168815160
37
37
  description:
38
38
  email:
39
39
  - james@shopify.com
@@ -43,6 +43,7 @@ extra_rdoc_files: []
43
43
  files:
44
44
  - lib/action_view/asset_paths.rb
45
45
  - lib/extensions/application_ext.rb
46
+ - lib/extensions/engine_ext.rb
46
47
  - lib/sprockets/assets.rake
47
48
  - lib/sprockets/bootstrap.rb
48
49
  - lib/sprockets/compressors.rb