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.
Files changed (48) hide show
  1. checksums.yaml +5 -5
  2. data/.gitignore +1 -0
  3. data/.travis.yml +23 -4
  4. data/Appraisals +18 -9
  5. data/CHANGELOG.md +18 -0
  6. data/Gemfile +4 -7
  7. data/README.md +12 -11
  8. data/Rakefile +4 -23
  9. data/compass-rails.gemspec +3 -2
  10. data/gemfiles/rails52.gemfile +20 -0
  11. data/gemfiles/rails60.gemfile +21 -0
  12. data/gemfiles/rails_edge.gemfile +21 -0
  13. data/lib/compass-rails/patches/3_1.rb +2 -2
  14. data/lib/compass-rails/patches/4_0.rb +20 -17
  15. data/lib/compass-rails/patches/compass.rb +2 -2
  16. data/lib/compass-rails/patches/importer.rb +10 -12
  17. data/lib/compass-rails/patches/sass_importer.rb +67 -7
  18. data/lib/compass-rails/patches/sprite_importer.rb +4 -4
  19. data/lib/compass-rails/patches.rb +0 -3
  20. data/lib/compass-rails/railties/3_1.rb +5 -12
  21. data/lib/compass-rails/railties/4_0.rb +11 -9
  22. data/lib/compass-rails/railties.rb +1 -3
  23. data/lib/compass-rails/version.rb +1 -3
  24. data/lib/compass-rails.rb +12 -125
  25. data/test/compass_rails_spec.rb +58 -0
  26. data/test/fixtures/assets/images/letters/a.png +0 -0
  27. data/test/fixtures/assets/images/letters/b.png +0 -0
  28. data/test/fixtures/assets/images/numbers/sprite-1.png +0 -0
  29. data/test/fixtures/assets/images/numbers/sprite-2.png +0 -0
  30. data/test/fixtures/assets/stylesheets/application.css.scss +23 -0
  31. data/test/fixtures/assets/stylesheets/partials/_partial_1.scss +3 -0
  32. data/test/fixtures/assets/stylesheets/partials/_partial_2.scss +3 -0
  33. data/test/helpers/command_helper.rb +2 -15
  34. data/test/helpers/debug_helper.rb +1 -1
  35. data/test/helpers/file_helper.rb +2 -17
  36. data/test/helpers/rails_helper.rb +37 -38
  37. data/test/helpers/rails_project.rb +30 -70
  38. data/test/test_helper.rb +8 -3
  39. metadata +50 -18
  40. data/gemfiles/rails31.gemfile +0 -22
  41. data/gemfiles/rails32.gemfile +0 -22
  42. data/gemfiles/rails40.gemfile +0 -22
  43. data/lib/compass-rails/installer.rb +0 -30
  44. data/test/integrations/.gitkeep +0 -0
  45. data/test/integrations/rails_31_test.rb +0 -46
  46. data/test/integrations/rails_32_test.rb +0 -46
  47. data/test/integrations/rails_40_test.rb +0 -46
  48. data/test/units/.gitkeep +0 -0
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 8b3db69cd3f6e7ae24f00b4c4a62dc0de7812ce9
4
- data.tar.gz: 99d55fb02db28aaff700d3503d28b98e02fdb921
2
+ SHA256:
3
+ metadata.gz: 051e3425d85a8db3f1b3d76430f4523a905b19d51b3d29476188f18441fe315b
4
+ data.tar.gz: 30d80439765d7c6288c1f460ee1ad45d710bb690f3e8fda29bbd7c13039d7199
5
5
  SHA512:
6
- metadata.gz: 2b9a899fb6aa8a8f05720ddacd9f0e18df6e300ea8da15ff6b742a7d21b5cd46da36efc9d535b6c7ff06f07c6c91b2270d6fd95988bcec29e00d3edd7a06f9ec
7
- data.tar.gz: 53baf588260989ae998fe741dcad4221e595314016f328a9dc74afdfaee7547ca679910829a4c47cc13599a618362a6c39694427f95132a0fc71dd5a7104a49b
6
+ metadata.gz: 4be5c5939deedbe57b6c64e801cb69ef14947722de615a279e51e051f6b8efc063197fe72b26a97eb6036b31012d123762ad20f8409a78e30ebd113f62895ea1
7
+ data.tar.gz: 4b95ded34fbfeae63c2df0645b63e8452040046ec38e11e5601624764a70c9353829a88d210f4569110c04987530237829f6563347b141f5fd21ee116b49f1b9
data/.gitignore CHANGED
@@ -1,6 +1,7 @@
1
1
  *.gem
2
2
  *.rbc
3
3
  .bundle
4
+ .idea
4
5
  .config
5
6
  .yardoc
6
7
  gemfiles/*.gemfile.lock
data/.travis.yml CHANGED
@@ -1,5 +1,24 @@
1
+ language: ruby
2
+ sudo: false
1
3
  rvm:
2
- - 1.9.3
3
- - 2.0.0
4
- - 2.1.0
5
- script: "bundle exec rake appraisal:install test"
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 "rails31" do
2
- gem "rails", "3.1.3"
3
- gem "sass-rails"
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 "rails32" do
7
- gem "rails", "~> 3.2"
8
- gem "sass-rails"
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 "rails40" do
12
- gem "rails", "~> 4.0.0"
13
- gem "sass-rails"
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 "appraisal"
14
- gem 'rainbow'
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
- [![Build Status](https://travis-ci.org/Compass/compass-rails.png?branch=master)](https://travis-ci.org/Compass/compass-rails)
6
- [![Code Climate](https://codeclimate.com/github/Compass/compass-rails.png)](https://codeclimate.com/github/Compass/compass-rails)
7
+ [![Build Status](https://travis-ci.org/Compass/compass-rails.svg?branch=master)](https://travis-ci.org/Compass/compass-rails)
8
+ [![Code Climate](https://codeclimate.com/github/Compass/compass-rails.svg)](https://codeclimate.com/github/Compass/compass-rails)
7
9
  [![Gem Version](https://badge.fury.io/rb/compass-rails.svg)](http://badge.fury.io/rb/compass-rails)
10
+ [![Coverage Status](https://coveralls.io/repos/Compass/compass-rails/badge.svg)](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 3.2, 4.x releases.
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
- If you have a compass configuration file (recommended) then you can
57
- use the [Compass configuration
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. If you choose to configure compass from your rails configuration
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 'compass-susy-plugin'
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 'rubygems'
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/**/*_test.rb']
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
- Rake::TestTask.new :units do |t|
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]
@@ -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', '~> 1.0.0'
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, only_path = nil)
6
- asset_url(path, Sass::Script::String.new("image"))
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, only_path = nil)
7
- pathobject = Pathname.new(path.to_s)
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(image_path, subdirectory = nil)
15
- generated_images_path = Rails.root.join(Compass.configuration.generated_images_dir).to_s
16
- if subdirectory.nil?
17
- bust_cache_path = generated_images_path
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
- bust_cache_path = generated_images_path + "/" + subdirectory
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 = options[:sprockets][:environment].send(:trail).instance_variable_get(:@entries)
23
+ sprockets_entries = sprockets_trail.instance_variable_get(:@entries) || {}
24
+ sprockets_stats = sprockets_trail.instance_variable_get(:@stats) || {}
24
25
 
25
- # sprockets_entries.delete(generated_images_path) if sprockets_entries.has_key? generated_images_path
26
- if sprockets_entries.has_key? generated_images_path
27
- # sprockets_entries.delete(generated_images_path)
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
- options[:sprockets][:environment].send(:trail).instance_variable_get(:@entries).delete(bust_cache_path)
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
- options[:sprockets][:environment].send(:trail).instance_variable_get(:@stats).delete(bust_image_stat_path)
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 = ::Rails.application.assets.find_asset(image_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
- if CompassRails.asset_pipeline_enabled?
8
- @sass_options[:custom] ||= {}
9
- @sass_options[:custom] = {:resolver => ::Sass::Rails::Resolver.new(CompassRails.context)}
10
- @sass_options[:load_paths] ||= []
11
- unless @sass_options[:load_paths].any? {|k| k.is_a?(::Sass::Rails::Importer) }
12
- ::Rails.application.assets.paths.each do |path|
13
- next unless path.to_s =~ STYLESHEET
14
- Dir["#{path}/**/*"].each do |pathname|
15
- # args are: sprockets environment, the logical_path ex. 'stylesheets', and the full path name for the render
16
- context = ::CompassRails.context.new(::Rails.application.assets, File.basename(path), Pathname.new(pathname))
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 = Sprockets::SassCacheStore.new(context.environment)
11
- paths = context.environment.paths.map { |path| CompassRails::SpriteImporter.new(context, path) }
12
- paths += context.environment.paths.map { |path| self.class.parent::SassImporter.new(context, path) }
13
- paths += ::Rails.application.config.sass.load_paths
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 => self.class.parent::SassImporter.new(context, context.pathname),
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).render
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 :context, :root
6
+ attr_reader :root
7
7
 
8
- def initialize(context, root)
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
 
@@ -1,6 +1,3 @@
1
1
  if CompassRails.rails31? || CompassRails.rails32?
2
- CompassRails.load_rails
3
2
  require 'compass-rails/patches/importer'
4
- elsif CompassRails.rails4?
5
- CompassRails.load_rails
6
3
  end
@@ -3,16 +3,9 @@ module CompassRails
3
3
 
4
4
  initializer "compass.initialize_rails", :group => :all do |app|
5
5
  require 'compass'
6
- if CompassRails.asset_pipeline_enabled?
7
- require 'compass-rails/patches/3_1'
8
- # Configure compass for use within rails, and provide the project configuration
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
- Rails.application.assets.send(:trail).instance_variable_get(:@entries).delete(File.dirname(filename))
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 = Rails.application.assets.find_asset(logical_path)
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
- trail = Rails.application.assets.send(:trail)
32
- trail.instance_variable_get(:@entries).delete(File.dirname(filename))
33
- trail.instance_variable_get(:@stats).delete(filename)
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 = Rails.application.assets.find_asset(logical_path)
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.to_s] = asset.digest_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
- $stderr.puts "Unsupported rails environment for compass"
5
+ require "compass-rails/railties/4_0"
8
6
  end
9
7
  end
@@ -1,5 +1,3 @@
1
1
  module CompassRails
2
- unless defined?(::CompassRails::VERSION)
3
- VERSION = "2.0.1"
4
- end
2
+ VERSION = '4.0.0' unless defined?(::CompassRails::VERSION)
5
3
  end