compass-rails 2.0.1 → 4.0.0
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.
- checksums.yaml +5 -5
- data/.gitignore +1 -0
- data/.travis.yml +23 -4
- data/Appraisals +18 -9
- data/CHANGELOG.md +18 -0
- data/Gemfile +4 -7
- data/README.md +12 -11
- data/Rakefile +4 -23
- data/compass-rails.gemspec +3 -2
- data/gemfiles/rails52.gemfile +20 -0
- data/gemfiles/rails60.gemfile +21 -0
- data/gemfiles/rails_edge.gemfile +21 -0
- data/lib/compass-rails/patches/3_1.rb +2 -2
- data/lib/compass-rails/patches/4_0.rb +20 -17
- data/lib/compass-rails/patches/compass.rb +2 -2
- data/lib/compass-rails/patches/importer.rb +10 -12
- data/lib/compass-rails/patches/sass_importer.rb +67 -7
- data/lib/compass-rails/patches/sprite_importer.rb +4 -4
- data/lib/compass-rails/patches.rb +0 -3
- data/lib/compass-rails/railties/3_1.rb +5 -12
- data/lib/compass-rails/railties/4_0.rb +11 -9
- data/lib/compass-rails/railties.rb +1 -3
- data/lib/compass-rails/version.rb +1 -3
- data/lib/compass-rails.rb +12 -125
- data/test/compass_rails_spec.rb +58 -0
- data/test/fixtures/assets/images/letters/a.png +0 -0
- data/test/fixtures/assets/images/letters/b.png +0 -0
- data/test/fixtures/assets/images/numbers/sprite-1.png +0 -0
- data/test/fixtures/assets/images/numbers/sprite-2.png +0 -0
- data/test/fixtures/assets/stylesheets/application.css.scss +23 -0
- data/test/fixtures/assets/stylesheets/partials/_partial_1.scss +3 -0
- data/test/fixtures/assets/stylesheets/partials/_partial_2.scss +3 -0
- data/test/helpers/command_helper.rb +2 -15
- data/test/helpers/debug_helper.rb +1 -1
- data/test/helpers/file_helper.rb +2 -17
- data/test/helpers/rails_helper.rb +37 -38
- data/test/helpers/rails_project.rb +30 -70
- data/test/test_helper.rb +8 -3
- metadata +50 -18
- data/gemfiles/rails31.gemfile +0 -22
- data/gemfiles/rails32.gemfile +0 -22
- data/gemfiles/rails40.gemfile +0 -22
- data/lib/compass-rails/installer.rb +0 -30
- data/test/integrations/.gitkeep +0 -0
- data/test/integrations/rails_31_test.rb +0 -46
- data/test/integrations/rails_32_test.rb +0 -46
- data/test/integrations/rails_40_test.rb +0 -46
- data/test/units/.gitkeep +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 051e3425d85a8db3f1b3d76430f4523a905b19d51b3d29476188f18441fe315b
|
4
|
+
data.tar.gz: 30d80439765d7c6288c1f460ee1ad45d710bb690f3e8fda29bbd7c13039d7199
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4be5c5939deedbe57b6c64e801cb69ef14947722de615a279e51e051f6b8efc063197fe72b26a97eb6036b31012d123762ad20f8409a78e30ebd113f62895ea1
|
7
|
+
data.tar.gz: 4b95ded34fbfeae63c2df0645b63e8452040046ec38e11e5601624764a70c9353829a88d210f4569110c04987530237829f6563347b141f5fd21ee116b49f1b9
|
data/.gitignore
CHANGED
data/.travis.yml
CHANGED
@@ -1,5 +1,24 @@
|
|
1
|
+
language: ruby
|
2
|
+
sudo: false
|
1
3
|
rvm:
|
2
|
-
-
|
3
|
-
- 2.
|
4
|
-
- 2.
|
5
|
-
|
4
|
+
- 2.4.9
|
5
|
+
- 2.5.7
|
6
|
+
- 2.6.5
|
7
|
+
- 2.7.0
|
8
|
+
- ruby-head
|
9
|
+
- jruby-head
|
10
|
+
gemfile:
|
11
|
+
- gemfiles/rails52.gemfile
|
12
|
+
- gemfiles/rails60.gemfile
|
13
|
+
- gemfiles/rails_edge.gemfile
|
14
|
+
matrix:
|
15
|
+
exclude:
|
16
|
+
- rvm: 2.4.9
|
17
|
+
gemfile: gemfiles/rails60.gemfile
|
18
|
+
- rvm: 2.4.9
|
19
|
+
gemfile: gemfiles/rails_edge.gemfile
|
20
|
+
fast_finish: true
|
21
|
+
allow_failures:
|
22
|
+
- rvm: ruby-head
|
23
|
+
- rvm: jruby-head
|
24
|
+
- gemfile: gemfiles/rails_edge.gemfile
|
data/Appraisals
CHANGED
@@ -1,14 +1,23 @@
|
|
1
|
-
appraise "
|
2
|
-
gem "rails", "
|
3
|
-
gem "
|
1
|
+
appraise "rails52" do
|
2
|
+
gem "rails", "~> 5.2.0"
|
3
|
+
gem "sprockets", "< 4.0"
|
4
|
+
gem "sass-rails", "~> 5.0"
|
5
|
+
gem "bootsnap", require: false
|
4
6
|
end
|
5
7
|
|
6
|
-
appraise "
|
7
|
-
gem "rails", "~>
|
8
|
-
gem "
|
8
|
+
appraise "rails60" do
|
9
|
+
gem "rails", "~> 6.0.0"
|
10
|
+
gem "sprockets", "< 4.0"
|
11
|
+
gem "sass-rails", "~> 5.0"
|
12
|
+
gem "webpacker", "~> 4.0"
|
13
|
+
gem "bootsnap", ">= 1.4.2", require: false
|
9
14
|
end
|
10
15
|
|
11
|
-
appraise "
|
12
|
-
gem "rails",
|
13
|
-
|
16
|
+
appraise "rails_edge" do
|
17
|
+
gem "rails", github: "rails/rails"
|
18
|
+
|
19
|
+
gem "sprockets", "< 4.0"
|
20
|
+
gem "sass-rails", "~> 5.0"
|
21
|
+
gem "webpacker", "~> 4.0"
|
22
|
+
gem "bootsnap", ">= 1.4.2", require: false
|
14
23
|
end
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,23 @@
|
|
1
1
|
# Change log
|
2
2
|
|
3
|
+
## 3.0.1 - 2016-2
|
4
|
+
### Fixed
|
5
|
+
- Fix running rake assts:precompile to be run in production mode. Issue #257.
|
6
|
+
|
7
|
+
## 3.0.0 - 2016-01-23
|
8
|
+
### Added
|
9
|
+
- Added Sprockets 3 support. Issue #232, #236, #244.
|
10
|
+
|
11
|
+
### Fixed
|
12
|
+
- Sprockets cache files are no longer saved to /tmp and now use the app-level tmp folder instead.
|
13
|
+
|
14
|
+
## 2.0.2 - 2015-01-03
|
15
|
+
### Fixed
|
16
|
+
- Fixed test suite to test against Rails 3.1, 3.2, 4.0, 4.2 on Ruby 1.9.3, 2.0.0, 2.1.0, 2.2.0 and jruby-head. Issue #206
|
17
|
+
- Support up to sass-rails 5.0.1. Issue #198
|
18
|
+
- Fix sass_importer patches having incorrect method signatures. Issue #195
|
19
|
+
- Fixed incorrect path generation for sprites in Rails 4. Issue #190
|
20
|
+
|
3
21
|
## 2.0.0 - 2014-07-10
|
4
22
|
### Added
|
5
23
|
- Support for Rails 4.2
|
data/Gemfile
CHANGED
@@ -1,17 +1,13 @@
|
|
1
1
|
source 'https://rubygems.org'
|
2
|
+
git_source(:github) { |repo| "https://github.com/#{repo}.git" }
|
2
3
|
|
3
4
|
# Specify your gem's dependencies in compass-rails.gemspec
|
4
5
|
gemspec
|
5
6
|
|
6
|
-
group :assets do
|
7
|
-
gem "compass-rails", :path=>"."
|
8
|
-
gem 'compass-blueprint'
|
9
|
-
end
|
10
|
-
|
11
7
|
group :test do
|
12
8
|
gem 'mocha'
|
13
|
-
gem
|
14
|
-
gem '
|
9
|
+
gem 'appraisal'
|
10
|
+
gem 'minitest'
|
15
11
|
end
|
16
12
|
|
17
13
|
unless ENV["CI"]
|
@@ -20,3 +16,4 @@ unless ENV["CI"]
|
|
20
16
|
gem 'guard'
|
21
17
|
gem 'guard-test'
|
22
18
|
end
|
19
|
+
|
data/README.md
CHANGED
@@ -1,17 +1,20 @@
|
|
1
1
|
# compass-rails
|
2
2
|
|
3
|
+
**Don't start new projects with compass, it is no longer supported, see the [compass statement](https://github.com/Compass/compass/pull/2094)**
|
4
|
+
|
3
5
|
**We Take Pull Requests!**
|
4
6
|
|
5
|
-
[](https://travis-ci.org/Compass/compass-rails)
|
8
|
+
[](https://codeclimate.com/github/Compass/compass-rails)
|
7
9
|
[](http://badge.fury.io/rb/compass-rails)
|
10
|
+
[](https://coveralls.io/r/Compass/compass-rails)
|
8
11
|
|
9
12
|
Compass rails is an adapter for the [Compass Stylesheet Authoring
|
10
13
|
Framework](http://compass-style.org) for [Ruby on Rails](http://rubyonrails.org/).
|
11
14
|
|
12
15
|
Since Compass v0.12.0, this is the only way to use compass with your rails application.
|
13
16
|
|
14
|
-
Supports Rails
|
17
|
+
Supports Rails 5.2 and 6.x releases.
|
15
18
|
|
16
19
|
## Installation
|
17
20
|
|
@@ -53,19 +56,17 @@ Use `application.css` to require files that use compass features. Ex:
|
|
53
56
|
|
54
57
|
### Configuration
|
55
58
|
|
56
|
-
|
57
|
-
|
59
|
+
Compass-rails is configured out of the box to work with Rails.
|
60
|
+
|
61
|
+
Advanced users can choose to add a `config/compass.rb` and take advantage of the [Compass configuration
|
58
62
|
reference](http://compass-style.org/help/documentation/configuration-reference/)
|
59
|
-
as is.
|
60
|
-
files, then you should understand that the compass configuration
|
61
|
-
options explained there will be methods and properties on the `config.compass`
|
62
|
-
configuration object exposed to rails within any configuration block.
|
63
|
+
as is.
|
63
64
|
|
64
65
|
### Installing Compass extensions
|
65
66
|
|
66
67
|
Step 1: Add it to your Gemfile and run the `bundle` command to install it.
|
67
68
|
|
68
|
-
Step 2: Install the extension's assets: `bundle exec compass install
|
69
|
+
Step 2: Install the extension's assets: `bundle exec compass install
|
69
70
|
<extension/template>`
|
70
71
|
|
71
72
|
For example, if you want to use susy.
|
@@ -73,7 +74,7 @@ For example, if you want to use susy.
|
|
73
74
|
```ruby
|
74
75
|
# Gemfile
|
75
76
|
gem 'compass-rails'
|
76
|
-
gem '
|
77
|
+
gem 'susy'
|
77
78
|
```
|
78
79
|
|
79
80
|
then run:
|
data/Rakefile
CHANGED
@@ -1,34 +1,15 @@
|
|
1
1
|
#!/usr/bin/env rake
|
2
|
-
require '
|
3
|
-
require 'bundler'
|
4
|
-
Bundler.setup
|
5
|
-
require 'rake/dsl_definition' rescue nil
|
6
|
-
|
7
|
-
require "bundler/gem_tasks"
|
8
|
-
require 'appraisal'
|
9
|
-
require 'compass'
|
10
|
-
|
11
|
-
# ----- Default: Testing ------
|
12
|
-
|
13
|
-
task :default => [:test]
|
14
|
-
|
2
|
+
require 'bundler/gem_tasks'
|
15
3
|
require 'rake/testtask'
|
16
|
-
require 'fileutils'
|
17
4
|
|
18
5
|
Rake::TestTask.new :test do |t|
|
6
|
+
require 'fileutils'
|
19
7
|
t.libs << 'lib'
|
20
8
|
t.libs << 'test'
|
21
|
-
test_files = FileList['test/**/*
|
9
|
+
test_files = FileList['test/**/*_{test,spec}.rb']
|
22
10
|
test_files.exclude('test/rails/*', 'test/haml/*')
|
23
11
|
t.test_files = test_files
|
24
12
|
t.verbose = true
|
25
13
|
end
|
26
14
|
|
27
|
-
|
28
|
-
t.libs << 'lib'
|
29
|
-
t.libs << 'test'
|
30
|
-
test_files = FileList['test/units/**/*_test.rb']
|
31
|
-
test_files.exclude('test/rails/*', 'test/haml/*')
|
32
|
-
t.test_files = test_files
|
33
|
-
t.verbose = true
|
34
|
-
end
|
15
|
+
task :default => [:test]
|
data/compass-rails.gemspec
CHANGED
@@ -16,6 +16,7 @@ Gem::Specification.new do |gem|
|
|
16
16
|
gem.version = CompassRails::VERSION
|
17
17
|
gem.license = "MIT"
|
18
18
|
|
19
|
-
gem.add_dependency 'compass',
|
20
|
-
|
19
|
+
gem.add_dependency 'compass', '~> 1.0.0'
|
20
|
+
gem.add_dependency 'sprockets', '< 4.0'
|
21
|
+
gem.add_dependency 'sass-rails', '< 5.1'
|
21
22
|
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# This file was generated by Appraisal
|
2
|
+
|
3
|
+
source "https://rubygems.org"
|
4
|
+
|
5
|
+
gem "rb-fsevent", require: false
|
6
|
+
gem "ruby_gntp", require: false
|
7
|
+
gem "guard"
|
8
|
+
gem "guard-test"
|
9
|
+
gem "rails", "~> 5.2.0"
|
10
|
+
gem "sprockets", "< 4.0"
|
11
|
+
gem "sass-rails", "~> 5.0"
|
12
|
+
gem "bootsnap", require: false
|
13
|
+
|
14
|
+
group :test do
|
15
|
+
gem "mocha"
|
16
|
+
gem "appraisal"
|
17
|
+
gem "minitest"
|
18
|
+
end
|
19
|
+
|
20
|
+
gemspec path: "../"
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# This file was generated by Appraisal
|
2
|
+
|
3
|
+
source "https://rubygems.org"
|
4
|
+
|
5
|
+
gem "rb-fsevent", require: false
|
6
|
+
gem "ruby_gntp", require: false
|
7
|
+
gem "guard"
|
8
|
+
gem "guard-test"
|
9
|
+
gem "rails", "~> 6.0.0"
|
10
|
+
gem "sprockets", "< 4.0"
|
11
|
+
gem "sass-rails", "~> 5.0"
|
12
|
+
gem "webpacker", "~> 4.0"
|
13
|
+
gem "bootsnap", ">= 1.4.2", require: false
|
14
|
+
|
15
|
+
group :test do
|
16
|
+
gem "mocha"
|
17
|
+
gem "appraisal"
|
18
|
+
gem "minitest"
|
19
|
+
end
|
20
|
+
|
21
|
+
gemspec path: "../"
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# This file was generated by Appraisal
|
2
|
+
|
3
|
+
source "https://rubygems.org"
|
4
|
+
|
5
|
+
gem "rb-fsevent", require: false
|
6
|
+
gem "ruby_gntp", require: false
|
7
|
+
gem "guard"
|
8
|
+
gem "guard-test"
|
9
|
+
gem "rails", git: "https://github.com/rails/rails.git"
|
10
|
+
gem "sprockets", "< 4.0"
|
11
|
+
gem "sass-rails", "~> 5.0"
|
12
|
+
gem "webpacker", "~> 4.0"
|
13
|
+
gem "bootsnap", ">= 1.4.2", require: false
|
14
|
+
|
15
|
+
group :test do
|
16
|
+
gem "mocha"
|
17
|
+
gem "appraisal"
|
18
|
+
gem "minitest"
|
19
|
+
end
|
20
|
+
|
21
|
+
gemspec path: "../"
|
@@ -2,7 +2,7 @@ require 'compass-rails/patches/compass'
|
|
2
2
|
require 'compass-rails/patches/static_compiler'
|
3
3
|
|
4
4
|
Compass::Core::SassExtensions::Functions::Urls::GeneratedImageUrl.module_eval do
|
5
|
-
def generated_image_url(path,
|
6
|
-
asset_url(path, Sass::Script::String.new(
|
5
|
+
def generated_image_url(path, cache_buster = Sass::Script::Bool.new(false))
|
6
|
+
asset_url(path, Sass::Script::String.new('image'))
|
7
7
|
end
|
8
8
|
end
|
@@ -3,34 +3,37 @@ require 'compass-rails/patches/sass_importer'
|
|
3
3
|
require 'compass-rails/patches/sprite_importer'
|
4
4
|
|
5
5
|
Compass::Core::SassExtensions::Functions::Urls::GeneratedImageUrl.module_eval do
|
6
|
-
def generated_image_url(path,
|
7
|
-
|
8
|
-
subdirectory = pathobject.dirname.to_s
|
9
|
-
|
10
|
-
cachebust_generated_images(path, subdirectory)
|
6
|
+
def generated_image_url(path, cache_buster = Sass::Script::Bool.new(false))
|
7
|
+
cachebust_generated_images(path)
|
11
8
|
asset_url(path)
|
12
9
|
end
|
13
10
|
|
14
|
-
def cachebust_generated_images(
|
15
|
-
|
16
|
-
|
17
|
-
|
11
|
+
def cachebust_generated_images(path)
|
12
|
+
generated_images_dir = Compass.configuration.generated_images_dir
|
13
|
+
generated_images_dir = Rails.root.join(generated_images_dir)
|
14
|
+
|
15
|
+
sprockets_env = options[:sprockets][:environment]
|
16
|
+
|
17
|
+
if sprockets_env.respond_to?(:trail, true)
|
18
|
+
sprockets_trail = sprockets_env.send(:trail)
|
18
19
|
else
|
19
|
-
|
20
|
+
sprockets_trail = sprockets_env.index
|
20
21
|
end
|
21
|
-
bust_image_stat_path = generated_images_path + "/" + image_path.to_s
|
22
22
|
|
23
|
-
sprockets_entries =
|
23
|
+
sprockets_entries = sprockets_trail.instance_variable_get(:@entries) || {}
|
24
|
+
sprockets_stats = sprockets_trail.instance_variable_get(:@stats) || {}
|
24
25
|
|
25
|
-
|
26
|
-
|
27
|
-
|
26
|
+
if sprockets_entries.key?(generated_images_dir.to_s)
|
27
|
+
path = path.value
|
28
|
+
dir = File.dirname(path)
|
28
29
|
|
29
30
|
# Delete the entries (directories) which cache the files/dirs in a directory
|
30
|
-
|
31
|
+
entry = generated_images_dir.join(dir).to_s
|
32
|
+
sprockets_entries.delete(entry)
|
31
33
|
|
32
34
|
# Delete the stats (file/dir info) which cache the what kind of file/dir each image is
|
33
|
-
|
35
|
+
stat = generated_images_dir.join(path).to_s
|
36
|
+
sprockets_stats.delete(stat)
|
34
37
|
end
|
35
38
|
end
|
36
39
|
end
|
@@ -3,8 +3,8 @@ Compass::Core::SassExtensions::Functions::ImageSize.class_eval do
|
|
3
3
|
|
4
4
|
def image_path_for_size(image_file)
|
5
5
|
begin
|
6
|
-
file = ::
|
7
|
-
return file
|
6
|
+
file = ::CompassRails.sprockets.find_asset(image_file)
|
7
|
+
return (file.respond_to?(:pathname) ? file.pathname.to_s : file)
|
8
8
|
rescue ::Sprockets::FileOutsidePaths
|
9
9
|
return super(image_file)
|
10
10
|
end
|
@@ -4,18 +4,16 @@ module Compass
|
|
4
4
|
attr_accessor :sass_options
|
5
5
|
STYLESHEET = /stylesheet/
|
6
6
|
def sass_options
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
@sass_options[:load_paths] << ::Sass::Rails::Importer.new(context)
|
18
|
-
end
|
7
|
+
@sass_options[:custom] ||= {}
|
8
|
+
@sass_options[:custom] = {:resolver => ::Sass::Rails::Resolver.new(CompassRails.context)}
|
9
|
+
@sass_options[:load_paths] ||= []
|
10
|
+
unless @sass_options[:load_paths].any? {|k| k.is_a?(::Sass::Rails::Importer) }
|
11
|
+
::CompassRails.sprockets.paths.each do |path|
|
12
|
+
next unless path.to_s =~ STYLESHEET
|
13
|
+
Dir["#{path}/**/*"].each do |pathname|
|
14
|
+
# args are: sprockets environment, the logical_path ex. 'stylesheets', and the full path name for the render
|
15
|
+
context = ::CompassRails.context.new(::CompassRails.sprockets, File.basename(path), Pathname.new(pathname))
|
16
|
+
@sass_options[:load_paths] << ::Sass::Rails::Importer.new(context)
|
19
17
|
end
|
20
18
|
end
|
21
19
|
end
|
@@ -7,18 +7,23 @@ end
|
|
7
7
|
klass.class_eval do
|
8
8
|
def evaluate(context, locals, &block)
|
9
9
|
# Use custom importer that knows about Sprockets Caching
|
10
|
-
cache_store =
|
11
|
-
|
12
|
-
|
13
|
-
|
10
|
+
cache_store =
|
11
|
+
if defined?(Sprockets::SassProcessor::CacheStore)
|
12
|
+
Sprockets::SassProcessor::CacheStore.new(sprockets_cache_store, context.environment)
|
13
|
+
else
|
14
|
+
Sprockets::SassCacheStore.new(context.environment)
|
15
|
+
end
|
14
16
|
|
17
|
+
paths = context.environment.paths.map { |path| CompassRails::SpriteImporter.new(path) }
|
18
|
+
paths += context.environment.paths.map { |path| sass_importer(context, path) }
|
19
|
+
paths += ::Rails.application.config.sass.load_paths
|
15
20
|
|
16
21
|
options = CompassRails.sass_config.merge( {
|
17
22
|
:filename => eval_file,
|
18
23
|
:line => line,
|
19
24
|
:syntax => syntax,
|
20
25
|
:cache_store => cache_store,
|
21
|
-
:importer =>
|
26
|
+
:importer => sass_importer(context, context.pathname),
|
22
27
|
:load_paths => paths,
|
23
28
|
:sprockets => {
|
24
29
|
:context => context,
|
@@ -26,11 +31,66 @@ klass.class_eval do
|
|
26
31
|
}
|
27
32
|
})
|
28
33
|
|
29
|
-
::Sass::Engine.new(data, options)
|
34
|
+
engine = ::Sass::Engine.new(data, options)
|
35
|
+
|
36
|
+
engine.dependencies.map do |dependency|
|
37
|
+
filename = dependency.options[:filename]
|
38
|
+
if filename.include?('*') # Handle sprite globs
|
39
|
+
image_path = Rails.root.join(Compass.configuration.images_dir).to_s
|
40
|
+
Dir[File.join(image_path, filename)].each do |f|
|
41
|
+
context.depend_on(f)
|
42
|
+
end
|
43
|
+
else
|
44
|
+
context.depend_on(filename) if File.exist?(filename)
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
engine.render
|
30
49
|
rescue ::Sass::SyntaxError => e
|
31
50
|
# Annotates exception message with parse line number
|
32
51
|
context.__LINE__ = e.sass_backtrace.first[:line]
|
33
52
|
raise e
|
34
53
|
end
|
35
|
-
end
|
36
54
|
|
55
|
+
private
|
56
|
+
|
57
|
+
def sass_importer_artiy
|
58
|
+
@sass_importer_artiy ||= sass_importer_class.instance_method(:initialize).arity
|
59
|
+
end
|
60
|
+
|
61
|
+
def sass_importer(context, path)
|
62
|
+
case sass_importer_artiy.abs
|
63
|
+
when 1
|
64
|
+
sass_importer_class.new(path)
|
65
|
+
else
|
66
|
+
sass_importer_class.new(context, path)
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
# if using haml-rails, self.class.parent = Haml::Filters (which doesn't have an implementation)
|
71
|
+
def sass_importer_class
|
72
|
+
@sass_importer_class ||= if defined?(self.class.parent::SassImporter)
|
73
|
+
self.class.parent::SassImporter
|
74
|
+
elsif defined?(Sass::Rails::SassTemplate)
|
75
|
+
Sass::Rails::SassImporter
|
76
|
+
else
|
77
|
+
Sprockets::SassImporter
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
def sprockets_cache_store
|
82
|
+
cache =
|
83
|
+
case Rails.application.config.assets.cache_store
|
84
|
+
when :null_store
|
85
|
+
Sprockets::Cache::NullStore.new
|
86
|
+
when :memory_store, :mem_cache_store
|
87
|
+
Sprockets::Cache::MemoryStore.new
|
88
|
+
else
|
89
|
+
path = "#{Rails.application.config.root}/tmp/cache/assets/#{Rails.env}"
|
90
|
+
|
91
|
+
Sprockets::Cache::FileStore.new(path)
|
92
|
+
end
|
93
|
+
|
94
|
+
Sprockets::Cache.new(cache, Rails.logger)
|
95
|
+
end
|
96
|
+
end
|
@@ -3,19 +3,19 @@ require 'compass/sprite_importer'
|
|
3
3
|
|
4
4
|
module CompassRails
|
5
5
|
class SpriteImporter < Compass::SpriteImporter
|
6
|
-
attr_reader :
|
6
|
+
attr_reader :root
|
7
7
|
|
8
|
-
def initialize(
|
9
|
-
@context = context
|
8
|
+
def initialize(root)
|
10
9
|
@root = root
|
11
10
|
end
|
12
11
|
|
13
12
|
def find(uri, options)
|
14
13
|
if old = super(uri, options)
|
14
|
+
context = options[:sprockets][:context]
|
15
15
|
self.class.files(uri).each do |file|
|
16
16
|
relative_path = Pathname.new(file).relative_path_from(Pathname.new(root))
|
17
17
|
begin
|
18
|
-
pathname = context.resolve(relative_path)
|
18
|
+
pathname = context.resolve(relative_path.to_s)
|
19
19
|
context.depend_on_asset(pathname)
|
20
20
|
rescue Sprockets::FileNotFound
|
21
21
|
|
@@ -3,16 +3,9 @@ module CompassRails
|
|
3
3
|
|
4
4
|
initializer "compass.initialize_rails", :group => :all do |app|
|
5
5
|
require 'compass'
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
# that came via the rails boot process.
|
10
|
-
CompassRails.check_for_double_boot!
|
11
|
-
Compass.discover_extensions!
|
12
|
-
CompassRails.configure_rails!(app)
|
13
|
-
else
|
14
|
-
CompassRails.initialize!(app.config.compass)
|
15
|
-
end
|
6
|
+
require 'compass-rails/patches/3_1'
|
7
|
+
Compass.discover_extensions!
|
8
|
+
CompassRails.configure_rails!(app)
|
16
9
|
end
|
17
10
|
|
18
11
|
config.compass = begin
|
@@ -32,11 +25,11 @@ module CompassRails
|
|
32
25
|
|
33
26
|
# Clear entries in Hike::Index for this sprite's directory.
|
34
27
|
# This makes sure the asset can be found by find_assets
|
35
|
-
|
28
|
+
CompassRails.sprockets.send(:trail).instance_variable_get(:@entries).delete(File.dirname(filename))
|
36
29
|
|
37
30
|
pathname = Pathname.new(filename)
|
38
31
|
logical_path = pathname.relative_path_from(Pathname.new(Compass.configuration.images_path))
|
39
|
-
asset =
|
32
|
+
asset = CompassRails.sprockets.find_asset(logical_path)
|
40
33
|
target = File.join(Rails.public_path, Rails.application.config.assets.prefix, asset.digest_path)
|
41
34
|
|
42
35
|
# Adds the asset to the manifest file.
|
@@ -4,9 +4,6 @@ module CompassRails
|
|
4
4
|
initializer "compass.initialize_rails", :group => :all do |app|
|
5
5
|
require 'compass'
|
6
6
|
require 'compass-rails/patches/4_0'
|
7
|
-
# Configure compass for use within rails, and provide the project configuration
|
8
|
-
# that came via the rails boot process.
|
9
|
-
CompassRails.check_for_double_boot!
|
10
7
|
Compass.discover_extensions!
|
11
8
|
CompassRails.configure_rails!(app)
|
12
9
|
end
|
@@ -28,19 +25,24 @@ module CompassRails
|
|
28
25
|
|
29
26
|
# Clear entries in Hike::Index for this sprite's directory.
|
30
27
|
# This makes sure the asset can be found by find_assets
|
31
|
-
|
32
|
-
|
33
|
-
|
28
|
+
if CompassRails.sprockets.respond_to?(:trail, true)
|
29
|
+
index = CompassRails.sprockets.send(:trail).index
|
30
|
+
else
|
31
|
+
index = CompassRails.sprockets.index
|
32
|
+
end
|
33
|
+
|
34
|
+
index.instance_variable_get(:@entries).delete(File.dirname(filename))
|
35
|
+
index.instance_variable_get(:@stats).delete(filename)
|
34
36
|
|
35
37
|
pathname = Pathname.new(filename)
|
36
|
-
logical_path = pathname.relative_path_from(Pathname.new(Compass.configuration.images_path))
|
37
|
-
asset =
|
38
|
+
logical_path = pathname.relative_path_from(Pathname.new(Compass.configuration.images_path)).to_s
|
39
|
+
asset = CompassRails.sprockets.find_asset(logical_path)
|
38
40
|
target = File.join(Rails.public_path, Rails.application.config.assets.prefix, asset.digest_path)
|
39
41
|
|
40
42
|
# Adds the asset to the manifest file.
|
41
43
|
|
42
44
|
manifest = ActionView::Base.assets_manifest
|
43
|
-
manifest.assets[logical_path
|
45
|
+
manifest.assets[logical_path] = asset.digest_path
|
44
46
|
|
45
47
|
|
46
48
|
# Adds the fingerprinted asset to the public directory
|
@@ -1,9 +1,7 @@
|
|
1
1
|
if defined?(::Rails)
|
2
2
|
if CompassRails.rails31? || CompassRails.rails32?
|
3
3
|
require "compass-rails/railties/3_1"
|
4
|
-
elsif CompassRails.rails4?
|
5
|
-
require "compass-rails/railties/4_0"
|
6
4
|
else
|
7
|
-
|
5
|
+
require "compass-rails/railties/4_0"
|
8
6
|
end
|
9
7
|
end
|