sprockets-rails 1.0.0 → 2.0.0.backport1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (41) hide show
  1. checksums.yaml +7 -0
  2. data/README.md +155 -0
  3. data/lib/sprockets/rails.rb +3 -0
  4. data/lib/sprockets/rails/helper.rb +145 -0
  5. data/lib/sprockets/rails/legacy_asset_tag_helper.rb +32 -0
  6. data/lib/sprockets/rails/legacy_asset_url_helper.rb +130 -0
  7. data/lib/sprockets/rails/task.rb +82 -0
  8. data/lib/sprockets/railtie.rb +125 -0
  9. metadata +52 -81
  10. data/MIT-LICENSE +0 -20
  11. data/README.rdoc +0 -3
  12. data/Rakefile +0 -24
  13. data/lib/sprockets-rails.rb +0 -7
  14. data/lib/sprockets/rails/bootstrap.rb +0 -41
  15. data/lib/sprockets/rails/compressors.rb +0 -87
  16. data/lib/sprockets/rails/helpers.rb +0 -8
  17. data/lib/sprockets/rails/helpers/isolated_helper.rb +0 -15
  18. data/lib/sprockets/rails/helpers/rails_helper.rb +0 -169
  19. data/lib/sprockets/rails/railtie.rb +0 -64
  20. data/lib/sprockets/rails/static_compiler.rb +0 -64
  21. data/lib/sprockets/rails/version.rb +0 -5
  22. data/lib/tasks/assets.rake +0 -105
  23. data/test/abstract_unit.rb +0 -145
  24. data/test/assets_debugging_test.rb +0 -65
  25. data/test/assets_test.rb +0 -532
  26. data/test/fixtures/alternate/stylesheets/style.css +0 -1
  27. data/test/fixtures/app/fonts/dir/font.ttf +0 -0
  28. data/test/fixtures/app/fonts/font.ttf +0 -0
  29. data/test/fixtures/app/images/logo.png +0 -0
  30. data/test/fixtures/app/javascripts/application.js +0 -1
  31. data/test/fixtures/app/javascripts/dir/xmlhr.js +0 -0
  32. data/test/fixtures/app/javascripts/extra.js +0 -0
  33. data/test/fixtures/app/javascripts/xmlhr.js +0 -0
  34. data/test/fixtures/app/stylesheets/application.css +0 -1
  35. data/test/fixtures/app/stylesheets/dir/style.css +0 -0
  36. data/test/fixtures/app/stylesheets/extra.css +0 -0
  37. data/test/fixtures/app/stylesheets/style.css +0 -0
  38. data/test/sprockets_compressors_test.rb +0 -27
  39. data/test/sprockets_helper_test.rb +0 -345
  40. data/test/sprockets_helper_with_routes_test.rb +0 -60
  41. data/test/test_helper.rb +0 -84
@@ -0,0 +1,82 @@
1
+ require 'rake'
2
+ require 'rake/sprocketstask'
3
+ require 'sprockets'
4
+
5
+ module Sprockets
6
+ module Rails
7
+ class Task < Rake::SprocketsTask
8
+ attr_accessor :app
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
47
+
48
+ def define
49
+ 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
+ desc "Compile all the assets named in config.assets.precompile"
58
+ task :precompile => :environment do
59
+ with_logger do
60
+ manifest.compile(assets)
61
+ end
62
+ end
63
+
64
+ desc "Remove old compiled assets"
65
+ task :clean => :environment do
66
+ with_logger do
67
+ manifest.clean(keep)
68
+ end
69
+ end
70
+
71
+ desc "Remove compiled assets"
72
+ task :clobber => :environment do
73
+ with_logger do
74
+ manifest.clobber
75
+ rm_rf cache_path if cache_path
76
+ end
77
+ end
78
+ end
79
+ end
80
+ end
81
+ end
82
+ end
@@ -0,0 +1,125 @@
1
+ require 'rails'
2
+ require 'rails/railtie'
3
+ require 'action_controller/railtie'
4
+ require 'active_support/core_ext/module/remove_method'
5
+ require 'sprockets'
6
+ require 'sprockets/rails/helper'
7
+
8
+ module Rails
9
+ class Application
10
+ # Hack: We need to remove Rails' built in config.assets so we can
11
+ # do our own thing.
12
+ class Configuration
13
+ remove_possible_method :assets
14
+ end
15
+
16
+ # Undefine Rails' assets method before redefining it, to avoid warnings.
17
+ remove_possible_method :assets
18
+ remove_possible_method :assets=
19
+
20
+ # Returns Sprockets::Environment for app config.
21
+ def assets
22
+ @assets ||= Sprockets::Environment.new(root.to_s) do |env|
23
+ env.version = ::Rails.env
24
+
25
+ path = "#{config.root}/tmp/cache/assets/#{::Rails.env}"
26
+ env.cache = Sprockets::Cache::FileStore.new(path)
27
+
28
+ env.context_class.class_eval do
29
+ include ::Sprockets::Rails::Helper
30
+ end
31
+ end
32
+ end
33
+ attr_writer :assets
34
+ end
35
+ end
36
+
37
+ module Sprockets
38
+ class Railtie < ::Rails::Railtie
39
+ LOOSE_APP_ASSETS = lambda do |path, filename|
40
+ filename =~ /app\/assets/ && !%w(.js .css).include?(File.extname(path))
41
+ end
42
+
43
+ class OrderedOptions < ActiveSupport::OrderedOptions
44
+ def configure(&block)
45
+ self._blocks << block
46
+ end
47
+ end
48
+
49
+ config.assets = OrderedOptions.new
50
+ config.assets._blocks = []
51
+ config.assets.paths = []
52
+ config.assets.prefix = "/assets"
53
+ config.assets.precompile = [LOOSE_APP_ASSETS, /(?:\/|\\|\A)application\.(css|js)$/]
54
+ config.assets.version = ""
55
+ config.assets.debug = false
56
+ config.assets.compile = true
57
+ config.assets.digest = false
58
+
59
+ rake_tasks do |app|
60
+ require 'sprockets/rails/task'
61
+ Sprockets::Rails::Task.new(app)
62
+ end
63
+
64
+ config.after_initialize do |app|
65
+ config = app.config
66
+
67
+ manifest_path = File.join(app.root, 'public', config.assets.prefix)
68
+
69
+ unless config.assets.version.blank?
70
+ app.assets.version += "-#{config.assets.version}"
71
+ end
72
+
73
+ # Copy config.assets.paths to Sprockets
74
+ config.assets.paths.each do |path|
75
+ app.assets.append_path path
76
+ end
77
+
78
+ ActionView::Base.instance_eval do
79
+ include Sprockets::Rails::Helper
80
+
81
+ # Copy relevant config to AV context
82
+ self.debug_assets = config.assets.debug
83
+ self.digest_assets = config.assets.digest
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
91
+
92
+ if config.assets.compile
93
+ self.assets_environment = app.assets
94
+ self.assets_manifest = Sprockets::Manifest.new(app.assets, manifest_path)
95
+ else
96
+ self.assets_manifest = Sprockets::Manifest.new(manifest_path)
97
+ end
98
+ end
99
+
100
+ app.assets.js_compressor = config.assets.js_compressor
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
117
+ if app.routes.respond_to?(:prepend)
118
+ app.routes.prepend do
119
+ mount app.assets => config.assets.prefix
120
+ end
121
+ end
122
+ end
123
+ end
124
+ end
125
+ end
metadata CHANGED
@@ -1,134 +1,105 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sprockets-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
5
- prerelease:
4
+ version: 2.0.0.backport1
6
5
  platform: ruby
7
6
  authors:
8
- - David Heinemeier Hansson
7
+ - Joshua Peek
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2012-03-26 00:00:00.000000000 Z
11
+ date: 2013-09-25 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: sprockets
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
17
  - - ~>
20
18
  - !ruby/object:Gem::Version
21
- version: 2.3.1
19
+ version: 2.2.2.backport2
22
20
  type: :runtime
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
24
  - - ~>
28
25
  - !ruby/object:Gem::Version
29
- version: 2.3.1
26
+ version: 2.2.2.backport2
30
27
  - !ruby/object:Gem::Dependency
31
- name: railties
28
+ name: actionpack
32
29
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
30
  requirements:
35
- - - ! '>='
31
+ - - '>='
36
32
  - !ruby/object:Gem::Version
37
- version: 4.0.0.beta
38
- - - <
33
+ version: '3.0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '3.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: activesupport
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - '>='
39
46
  - !ruby/object:Gem::Version
40
- version: '5.0'
47
+ version: '3.0'
41
48
  type: :runtime
42
49
  prerelease: false
43
50
  version_requirements: !ruby/object:Gem::Requirement
44
- none: false
45
51
  requirements:
46
- - - ! '>='
52
+ - - '>='
47
53
  - !ruby/object:Gem::Version
48
- version: 4.0.0.beta
49
- - - <
54
+ version: '3.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rake
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - '>='
50
67
  - !ruby/object:Gem::Version
51
- version: '5.0'
52
- description: Sprockets Rails integration
53
- email:
54
- - david@loudthinking.com
68
+ version: '0'
69
+ description:
70
+ email: josh@joshpeek.com
55
71
  executables: []
56
72
  extensions: []
57
73
  extra_rdoc_files: []
58
74
  files:
59
- - lib/sprockets/rails/bootstrap.rb
60
- - lib/sprockets/rails/compressors.rb
61
- - lib/sprockets/rails/helpers/isolated_helper.rb
62
- - lib/sprockets/rails/helpers/rails_helper.rb
63
- - lib/sprockets/rails/helpers.rb
64
- - lib/sprockets/rails/railtie.rb
65
- - lib/sprockets/rails/static_compiler.rb
66
- - lib/sprockets/rails/version.rb
67
- - lib/sprockets-rails.rb
68
- - lib/tasks/assets.rake
69
- - MIT-LICENSE
70
- - Rakefile
71
- - README.rdoc
72
- - test/abstract_unit.rb
73
- - test/assets_debugging_test.rb
74
- - test/assets_test.rb
75
- - test/fixtures/alternate/stylesheets/style.css
76
- - test/fixtures/app/fonts/dir/font.ttf
77
- - test/fixtures/app/fonts/font.ttf
78
- - test/fixtures/app/images/logo.png
79
- - test/fixtures/app/javascripts/application.js
80
- - test/fixtures/app/javascripts/dir/xmlhr.js
81
- - test/fixtures/app/javascripts/extra.js
82
- - test/fixtures/app/javascripts/xmlhr.js
83
- - test/fixtures/app/stylesheets/application.css
84
- - test/fixtures/app/stylesheets/dir/style.css
85
- - test/fixtures/app/stylesheets/extra.css
86
- - test/fixtures/app/stylesheets/style.css
87
- - test/sprockets_compressors_test.rb
88
- - test/sprockets_helper_test.rb
89
- - test/sprockets_helper_with_routes_test.rb
90
- - test/test_helper.rb
75
+ - README.md
76
+ - lib/sprockets/rails/helper.rb
77
+ - lib/sprockets/rails/legacy_asset_tag_helper.rb
78
+ - lib/sprockets/rails/legacy_asset_url_helper.rb
79
+ - lib/sprockets/rails/task.rb
80
+ - lib/sprockets/rails.rb
81
+ - lib/sprockets/railtie.rb
91
82
  homepage: https://github.com/rails/sprockets-rails
92
83
  licenses: []
84
+ metadata: {}
93
85
  post_install_message:
94
86
  rdoc_options: []
95
87
  require_paths:
96
88
  - lib
97
89
  required_ruby_version: !ruby/object:Gem::Requirement
98
- none: false
99
90
  requirements:
100
- - - ! '>='
91
+ - - '>='
101
92
  - !ruby/object:Gem::Version
102
93
  version: '0'
103
94
  required_rubygems_version: !ruby/object:Gem::Requirement
104
- none: false
105
95
  requirements:
106
- - - ! '>='
96
+ - - '>'
107
97
  - !ruby/object:Gem::Version
108
- version: '0'
98
+ version: 1.3.1
109
99
  requirements: []
110
100
  rubyforge_project:
111
- rubygems_version: 1.8.21
101
+ rubygems_version: 2.0.3
112
102
  signing_key:
113
- specification_version: 3
103
+ specification_version: 4
114
104
  summary: Sprockets Rails integration
115
- test_files:
116
- - test/abstract_unit.rb
117
- - test/assets_debugging_test.rb
118
- - test/assets_test.rb
119
- - test/fixtures/alternate/stylesheets/style.css
120
- - test/fixtures/app/fonts/dir/font.ttf
121
- - test/fixtures/app/fonts/font.ttf
122
- - test/fixtures/app/images/logo.png
123
- - test/fixtures/app/javascripts/application.js
124
- - test/fixtures/app/javascripts/dir/xmlhr.js
125
- - test/fixtures/app/javascripts/extra.js
126
- - test/fixtures/app/javascripts/xmlhr.js
127
- - test/fixtures/app/stylesheets/application.css
128
- - test/fixtures/app/stylesheets/dir/style.css
129
- - test/fixtures/app/stylesheets/extra.css
130
- - test/fixtures/app/stylesheets/style.css
131
- - test/sprockets_compressors_test.rb
132
- - test/sprockets_helper_test.rb
133
- - test/sprockets_helper_with_routes_test.rb
134
- - test/test_helper.rb
105
+ test_files: []
data/MIT-LICENSE DELETED
@@ -1,20 +0,0 @@
1
- Copyright (c) 2012 David Heinemeier Hansson
2
-
3
- Permission is hereby granted, free of charge, to any person obtaining
4
- a copy of this software and associated documentation files (the
5
- "Software"), to deal in the Software without restriction, including
6
- without limitation the rights to use, copy, modify, merge, publish,
7
- distribute, sublicense, and/or sell copies of the Software, and to
8
- permit persons to whom the Software is furnished to do so, subject to
9
- the following conditions:
10
-
11
- The above copyright notice and this permission notice shall be
12
- included in all copies or substantial portions of the Software.
13
-
14
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
- LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
- OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
- WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.rdoc DELETED
@@ -1,3 +0,0 @@
1
- = sprockets-rails
2
-
3
- This project rocks and uses MIT-LICENSE.
data/Rakefile DELETED
@@ -1,24 +0,0 @@
1
- #!/usr/bin/env rake
2
- require 'rake/testtask'
3
-
4
- namespace :test do
5
- task :isolated do
6
- Dir["test/assets*_test.rb"].each do |file|
7
- dash_i = [
8
- 'test',
9
- 'lib',
10
- ]
11
- ruby "-I#{dash_i.join ':'}", file
12
- end
13
- end
14
- end
15
-
16
- Rake::TestTask.new("test:regular") do |t|
17
- t.libs << 'lib'
18
- t.libs << 'test'
19
- t.pattern = 'test/**/sprockets*_test.rb'
20
- t.verbose = true
21
- end
22
-
23
- task :test => ['test:isolated', 'test:regular']
24
- task :default => :test