compass-rails 1.0.3 → 1.1.3
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 +15 -0
- data/.gitignore +1 -0
- data/.travis.yml +1 -2
- data/Appraisals +6 -5
- data/Gemfile +4 -3
- data/README.md +50 -63
- data/changelog.markdown +11 -0
- data/compass-rails.gemspec +6 -5
- data/gemfiles/rails3.gemfile +3 -2
- data/gemfiles/rails31.gemfile +3 -2
- data/gemfiles/rails32.gemfile +3 -2
- data/gemfiles/{rails2.gemfile → rails40.gemfile} +5 -3
- data/lib/compass-rails/configuration/{3_1.rb → asset_pipeline.rb} +5 -1
- data/lib/compass-rails/patches/3_1.rb +1 -14
- data/lib/compass-rails/patches/4_0.rb +25 -0
- data/lib/compass-rails/patches/compass.rb +12 -0
- data/lib/compass-rails/patches/sass_importer.rb +31 -0
- data/lib/compass-rails/patches/sprite_importer.rb +15 -23
- data/lib/compass-rails/patches/static_compiler.rb +1 -1
- data/lib/compass-rails/patches.rb +4 -4
- data/lib/compass-rails/railties/3_1.rb +10 -6
- data/lib/compass-rails/railties/4_0.rb +102 -0
- data/lib/compass-rails/railties.rb +4 -4
- data/lib/compass-rails/version.rb +1 -1
- data/lib/compass-rails.rb +27 -15
- data/test/helpers/file_helper.rb +6 -6
- data/test/helpers/rails_helper.rb +15 -16
- data/test/helpers/rails_project.rb +9 -73
- data/test/integrations/rails3_test.rb +4 -4
- data/test/integrations/rails_32_without_pipeline_test.rb +37 -0
- data/test/integrations/{rails_23_test.rb → rails_40_test.rb} +21 -3
- metadata +30 -32
- data/gemfiles/rails2.gemfile.lock +0 -81
- data/gemfiles/rails3.gemfile.lock +0 -128
- data/gemfiles/rails31.gemfile.lock +0 -145
- data/gemfiles/rails32.gemfile.lock +0 -142
- data/lib/compass-rails/railties/2_3.rb +0 -56
checksums.yaml
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
---
|
|
2
|
+
!binary "U0hBMQ==":
|
|
3
|
+
metadata.gz: !binary |-
|
|
4
|
+
MmUwYjg0NjMwMzRhNjQ3NGUzYTQ5OThkY2VhMTU4MTc3ZjY4ODdhMg==
|
|
5
|
+
data.tar.gz: !binary |-
|
|
6
|
+
ODQ0YzAyNDIyNmI3NDU2OTJlZGJlMzg4MDdlODYyMzFkNmU4M2UzZQ==
|
|
7
|
+
SHA512:
|
|
8
|
+
metadata.gz: !binary |-
|
|
9
|
+
NGQ0YjRlYTM1NTBiMWUzYzEyZGQwNmU4OThkNGJhMjc3NTRkYzgyY2JlYmI2
|
|
10
|
+
NjMyOWFiMjJmZGRiZjVhM2EyZjExNDUxMmMwZjM2ZmIwNTQxMDU0OTM2ZDg5
|
|
11
|
+
MzlmYjFhNTdiNmI1YmMwNjY0OWI3MDUyMWJkYWMxMWQyMmFkYjA=
|
|
12
|
+
data.tar.gz: !binary |-
|
|
13
|
+
YmNlMGQ2NTU2OWU3ZWYxN2FhN2M3NzNjYzAzNzEzZTkzN2Q4NmQxOTZlMTkz
|
|
14
|
+
Mjc4YWRhMGFiNzk3ODNlNTQwZmZhMzYwMjA5MDgxNWYxNmZlOWUxMDYyOGY1
|
|
15
|
+
MTUwZjQ2ZWJlMjVkNDYxMzdiN2FhZTA4YTk2ODM4MGY5ZTdhMjU=
|
data/.gitignore
CHANGED
data/.travis.yml
CHANGED
data/Appraisals
CHANGED
|
@@ -1,7 +1,3 @@
|
|
|
1
|
-
appraise "rails2" do
|
|
2
|
-
gem "rails", "2.3.14"
|
|
3
|
-
end
|
|
4
|
-
|
|
5
1
|
appraise "rails3" do
|
|
6
2
|
gem "rails", "3.0.11"
|
|
7
3
|
end
|
|
@@ -14,4 +10,9 @@ end
|
|
|
14
10
|
appraise "rails32" do
|
|
15
11
|
gem "rails", "~> 3.2"
|
|
16
12
|
gem "sass-rails"
|
|
17
|
-
end
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
appraise "rails40" do
|
|
16
|
+
gem "rails", "~> 4.0.0"
|
|
17
|
+
gem "sass-rails"
|
|
18
|
+
end
|
data/Gemfile
CHANGED
|
@@ -4,13 +4,14 @@ source 'https://rubygems.org'
|
|
|
4
4
|
gemspec
|
|
5
5
|
|
|
6
6
|
group :assets do
|
|
7
|
-
gem
|
|
8
|
-
gem
|
|
7
|
+
gem "compass", '~> 0.13.alpha.0'
|
|
8
|
+
gem "compass-rails", :path=>"."
|
|
9
|
+
gem 'compass-blueprint'
|
|
9
10
|
end
|
|
10
11
|
|
|
11
12
|
group :test do
|
|
12
13
|
gem 'mocha'
|
|
13
|
-
gem "appraisal", :git => '
|
|
14
|
+
gem "appraisal", :git => 'https://github.com/scottdavis/appraisal.git'
|
|
14
15
|
gem 'rainbow'
|
|
15
16
|
end
|
|
16
17
|
|
data/README.md
CHANGED
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
# CompassRails
|
|
2
2
|
|
|
3
|
+
[](https://travis-ci.org/Compass/compass-rails)
|
|
4
|
+
[](https://codeclimate.com/github/Compass/compass-rails)
|
|
5
|
+
|
|
3
6
|
Compass rails is an adapter for the [Compass Stylesheet Authoring
|
|
4
|
-
Framework](http://compass-style.org) for [Ruby on Rails](http://
|
|
7
|
+
Framework](http://compass-style.org) for [Ruby on Rails](http://rubyonrails.org/).
|
|
5
8
|
|
|
6
9
|
Since Compass v0.12, this adapter is the only way to install compass
|
|
7
10
|
into your rails application.
|
|
8
11
|
|
|
9
|
-
This adapter supports
|
|
10
|
-
please read the caveats below.
|
|
12
|
+
This adapter supports Rails 3.x, 4.x releases.
|
|
11
13
|
|
|
12
14
|
## Installation
|
|
13
15
|
|
|
@@ -27,6 +29,29 @@ And then execute:
|
|
|
27
29
|
|
|
28
30
|
$ bundle
|
|
29
31
|
|
|
32
|
+
## Usage
|
|
33
|
+
|
|
34
|
+
Change your `application.css` to `application.css.scss` or `application.css.sass` and use `@import` to your hearts content. Ex:
|
|
35
|
+
|
|
36
|
+
```scss
|
|
37
|
+
@import "project/mixins";
|
|
38
|
+
@import "project/base";
|
|
39
|
+
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
*or*
|
|
43
|
+
|
|
44
|
+
Use `application.css` to require files that use compass features. Ex:
|
|
45
|
+
```css
|
|
46
|
+
/*
|
|
47
|
+
*= require styleguide_full_of_compass_stuff
|
|
48
|
+
*/
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
*Don't* use `*= require something` within your SCSS or SASS files. You're gonna have a bad time.
|
|
52
|
+
|
|
53
|
+
## Optional
|
|
54
|
+
|
|
30
55
|
To set up your project with starter stylesheets and a configuration
|
|
31
56
|
file:
|
|
32
57
|
|
|
@@ -38,21 +63,7 @@ If using a compass-based framework (like [susy](http://susy.oddbird.net/) or [bl
|
|
|
38
63
|
|
|
39
64
|
Note that the `compass init` step is optional if you have a project running Rails 3.0 or greater.
|
|
40
65
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
First and foremost, follow the installation instructions above.
|
|
44
|
-
|
|
45
|
-
CompassRails uses the rails convention for stylesheet locations even in
|
|
46
|
-
older versions of rails that do not use the assets pipeline.
|
|
47
|
-
If you have your stylesheets already in `app/stylesheets`, you have two choices:
|
|
48
|
-
|
|
49
|
-
1. Move your stylesheets to `app/assets/stylesheets`.
|
|
50
|
-
2. Configure your project to look in the **legacy location** of
|
|
51
|
-
`app/stylesheets` by setting `config.compass.sass_dir =
|
|
52
|
-
"app/stylesheets"` in your rails configuration or by setting
|
|
53
|
-
`sass_dir = "app/stylesheets"` in your compass configuration file.
|
|
54
|
-
|
|
55
|
-
## Configuration
|
|
66
|
+
### Configuration
|
|
56
67
|
|
|
57
68
|
If you have a compass configuration file (recommended) then you can
|
|
58
69
|
use the [Compass configuration
|
|
@@ -62,12 +73,17 @@ files, then you should understand that the compass configuration
|
|
|
62
73
|
options explained there will be methods and properties on the `config.compass`
|
|
63
74
|
configuration object exposed to rails within any configuration block.
|
|
64
75
|
|
|
65
|
-
|
|
76
|
+
### Notes On Sprockets Directives
|
|
77
|
+
|
|
78
|
+
Sprockets, used by the rails asset pipeline, provides directives for
|
|
79
|
+
doing things like requiring. These **must not** be used with Sass files.
|
|
80
|
+
Instead use the sass `@import` directive. In rails projects, the
|
|
81
|
+
`@import` directive is configured to work with sprockets via `sass-rails`. For more information on importing in rails 3.1 or greater see the [Sass-Rails README](https://github.com/rails/sass-rails/blob/master/README.md)
|
|
66
82
|
|
|
67
83
|
### Developing with Rails-based Compilation
|
|
68
84
|
|
|
69
85
|
By default, your sass files in `app/assets/stylesheets` will be
|
|
70
|
-
automatically compiled by the
|
|
86
|
+
automatically compiled by the [`Sass::Plugin`](http://sass-lang.com/docs/yardoc/Sass/Plugin.html) or the [Rails asset
|
|
71
87
|
pipeline](http://guides.rubyonrails.org/asset_pipeline.html) depending on the version of rails that you use.
|
|
72
88
|
|
|
73
89
|
When using this approach you will need to reload your webpage in order
|
|
@@ -93,11 +109,7 @@ end
|
|
|
93
109
|
To return to using the Rails-based compilation mode, simply delete
|
|
94
110
|
the compiled stylesheets and remove any configuration changes.
|
|
95
111
|
|
|
96
|
-
### Compiling for Production
|
|
97
|
-
|
|
98
|
-
If using the Rails asset pipeline run:
|
|
99
|
-
|
|
100
|
-
$ rake assets:precompile
|
|
112
|
+
### Compiling for Production without Asset Pipeline
|
|
101
113
|
|
|
102
114
|
If not using the asset pipeline run:
|
|
103
115
|
|
|
@@ -109,10 +121,7 @@ stylesheets.
|
|
|
109
121
|
|
|
110
122
|
### Installing Compass extensions
|
|
111
123
|
|
|
112
|
-
Step 1:
|
|
113
|
-
`:assets` group and run the `bundle` command to install it.
|
|
114
|
-
If the extension is a zip file, unzip it into the
|
|
115
|
-
`vendor/plugins/compass_extensions` directory of your project.
|
|
124
|
+
Step 1: Add it to your Gemfile in the `:assets` group and run the `bundle` command to install it.
|
|
116
125
|
|
|
117
126
|
Step 2: Install the extension's assets: `bundle exec compass install
|
|
118
127
|
<extension/template>`
|
|
@@ -140,18 +149,9 @@ config.compass.require "susy"
|
|
|
140
149
|
|
|
141
150
|
to your application.rb configuration file.
|
|
142
151
|
|
|
143
|
-
|
|
144
|
-
### Notes On Sprockets Directives
|
|
145
|
-
|
|
146
|
-
Sprockets, used by the rails asset pipeline, provides directives for
|
|
147
|
-
doing things like requiring. These **must not** be used with Sass files.
|
|
148
|
-
Instead use the sass `@import` directive. In rails projects, the
|
|
149
|
-
`@import` directive is configured to work with sprockets via `sass-rails`. For more information on importing in rails 3.1 or greater see the [Sass-Rails README](https://github.com/rails/sass-rails/blob/master/README.markdown)
|
|
150
|
-
|
|
151
152
|
## Rails 3.1 Caveats
|
|
152
153
|
|
|
153
|
-
|
|
154
|
-
at the earliest for this version of rails.
|
|
154
|
+
compass-rails requires Rails 3.1.1 and greater. Also, Rails 3.1 is out of support so consider upgrading.
|
|
155
155
|
|
|
156
156
|
## Rails 3.0 Caveats
|
|
157
157
|
|
|
@@ -168,34 +168,21 @@ to this:
|
|
|
168
168
|
Bundler.require(:default, :assets, Rails.env) if defined?(Bundler)
|
|
169
169
|
```
|
|
170
170
|
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
Compass requires that your rails 2.3 project is using Bundler to manage
|
|
174
|
-
your rubygems. If you haven't yet set up your rails 2.3 project to use Bundler,
|
|
175
|
-
please do so prior to upgrading. [Bundler installation guide for rails
|
|
176
|
-
2.3](http://gembundler.com/rails23.html).
|
|
171
|
+
Also, Rails 3.0 is out of support so consider upgrading.
|
|
177
172
|
|
|
178
|
-
|
|
179
|
-
your stylesheets (instead of using the compass watcher) you need
|
|
180
|
-
edit `config/boot.rb` and change this:
|
|
173
|
+
## Upgrading Rails 3.0 and older projects to compass-rails
|
|
181
174
|
|
|
182
|
-
|
|
183
|
-
Rails::Initializer.class_eval do
|
|
184
|
-
def load_gems
|
|
185
|
-
@bundler_loaded ||= Bundler.require :default, Rails.env
|
|
186
|
-
end
|
|
187
|
-
end
|
|
188
|
-
```
|
|
175
|
+
First and foremost, follow the installation instructions above.
|
|
189
176
|
|
|
190
|
-
|
|
177
|
+
CompassRails uses the rails convention for stylesheet locations even in
|
|
178
|
+
older versions of rails that do not use the assets pipeline.
|
|
179
|
+
If you have your stylesheets already in `app/stylesheets`, you have two choices:
|
|
191
180
|
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
end
|
|
198
|
-
```
|
|
181
|
+
1. Move your stylesheets to `app/assets/stylesheets`.
|
|
182
|
+
2. Configure your project to look in the **legacy location** of
|
|
183
|
+
`app/stylesheets` by setting `config.compass.sass_dir =
|
|
184
|
+
"app/stylesheets"` in your rails configuration or by setting
|
|
185
|
+
`sass_dir = "app/stylesheets"` in your compass configuration file.
|
|
199
186
|
|
|
200
187
|
## Contributing
|
|
201
188
|
|
data/changelog.markdown
ADDED
data/compass-rails.gemspec
CHANGED
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
require File.expand_path('../lib/compass-rails/version', __FILE__)
|
|
3
3
|
|
|
4
4
|
Gem::Specification.new do |gem|
|
|
5
|
-
gem.authors = ["Scott Davis", "Chris Eppstein"]
|
|
6
|
-
gem.email = ["jetviper21@gmail.com", "chris@eppsteins.net"]
|
|
7
|
-
gem.description = %q{Integrate Compass into Rails
|
|
8
|
-
gem.summary = %q{Integrate Compass into Rails
|
|
5
|
+
gem.authors = ["Scott Davis", "Chris Eppstein", "Craig McNamara"]
|
|
6
|
+
gem.email = ["jetviper21@gmail.com", "chris@eppsteins.net", "craig.mcnamara@gmail.com"]
|
|
7
|
+
gem.description = %q{Integrate Compass into Rails 3.0 and up.}
|
|
8
|
+
gem.summary = %q{Integrate Compass into Rails 3.0 and up.}
|
|
9
9
|
gem.homepage = "https://github.com/Compass/compass-rails"
|
|
10
10
|
|
|
11
11
|
gem.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
|
@@ -14,7 +14,8 @@ Gem::Specification.new do |gem|
|
|
|
14
14
|
gem.name = "compass-rails"
|
|
15
15
|
gem.require_paths = ["lib"]
|
|
16
16
|
gem.version = CompassRails::VERSION
|
|
17
|
+
gem.license = "MIT"
|
|
17
18
|
|
|
18
|
-
gem.add_dependency 'compass', '>= 0.12.2'
|
|
19
|
+
gem.add_dependency 'compass', '>= 0.12.2'
|
|
19
20
|
|
|
20
21
|
end
|
data/gemfiles/rails3.gemfile
CHANGED
|
@@ -9,12 +9,13 @@ gem "guard-test"
|
|
|
9
9
|
gem "rails", "3.0.11"
|
|
10
10
|
|
|
11
11
|
group :assets do
|
|
12
|
-
gem "compass"
|
|
12
|
+
gem "compass", "~> 0.13.alpha.0"
|
|
13
13
|
gem "compass-rails", :path=>".."
|
|
14
|
+
gem "compass-blueprint"
|
|
14
15
|
end
|
|
15
16
|
group :test do
|
|
16
17
|
gem "mocha"
|
|
17
|
-
gem "appraisal", :git=>"
|
|
18
|
+
gem "appraisal", :git=>"https://github.com/scottdavis/appraisal.git"
|
|
18
19
|
gem "rainbow"
|
|
19
20
|
end
|
|
20
21
|
|
data/gemfiles/rails31.gemfile
CHANGED
|
@@ -10,12 +10,13 @@ gem "rails", "3.1.3"
|
|
|
10
10
|
gem "sass-rails"
|
|
11
11
|
|
|
12
12
|
group :assets do
|
|
13
|
-
gem "compass"
|
|
13
|
+
gem "compass", "~> 0.13.alpha.0"
|
|
14
14
|
gem "compass-rails", :path=>".."
|
|
15
|
+
gem "compass-blueprint"
|
|
15
16
|
end
|
|
16
17
|
group :test do
|
|
17
18
|
gem "mocha"
|
|
18
|
-
gem "appraisal", :git=>"
|
|
19
|
+
gem "appraisal", :git=>"https://github.com/scottdavis/appraisal.git"
|
|
19
20
|
gem "rainbow"
|
|
20
21
|
end
|
|
21
22
|
|
data/gemfiles/rails32.gemfile
CHANGED
|
@@ -10,12 +10,13 @@ gem "rails", "~> 3.2"
|
|
|
10
10
|
gem "sass-rails"
|
|
11
11
|
|
|
12
12
|
group :assets do
|
|
13
|
-
gem "compass"
|
|
13
|
+
gem "compass", "~> 0.13.alpha.0"
|
|
14
14
|
gem "compass-rails", :path=>".."
|
|
15
|
+
gem "compass-blueprint"
|
|
15
16
|
end
|
|
16
17
|
group :test do
|
|
17
18
|
gem "mocha"
|
|
18
|
-
gem "appraisal", :git=>"
|
|
19
|
+
gem "appraisal", :git=>"https://github.com/scottdavis/appraisal.git"
|
|
19
20
|
gem "rainbow"
|
|
20
21
|
end
|
|
21
22
|
|
|
@@ -6,15 +6,17 @@ gem "rb-fsevent", :require=>false
|
|
|
6
6
|
gem "ruby_gntp", :require=>false
|
|
7
7
|
gem "guard"
|
|
8
8
|
gem "guard-test"
|
|
9
|
-
gem "rails", "
|
|
9
|
+
gem "rails", "~> 4.0.0"
|
|
10
|
+
gem "sass-rails"
|
|
10
11
|
|
|
11
12
|
group :assets do
|
|
12
|
-
gem "compass"
|
|
13
|
+
gem "compass", "~> 0.13.alpha.0"
|
|
13
14
|
gem "compass-rails", :path=>".."
|
|
15
|
+
gem "compass-blueprint"
|
|
14
16
|
end
|
|
15
17
|
group :test do
|
|
16
18
|
gem "mocha"
|
|
17
|
-
gem "appraisal", :git=>"
|
|
19
|
+
gem "appraisal", :git=>"https://github.com/scottdavis/appraisal.git"
|
|
18
20
|
gem "rainbow"
|
|
19
21
|
end
|
|
20
22
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
module CompassRails
|
|
2
2
|
module Configuration
|
|
3
|
-
module
|
|
3
|
+
module AssetPipeline
|
|
4
4
|
|
|
5
5
|
def default_images_dir
|
|
6
6
|
File.join("app", "assets", "images")
|
|
@@ -42,6 +42,10 @@ module CompassRails
|
|
|
42
42
|
::Rails.application.config.sass.preferred_syntax rescue nil
|
|
43
43
|
end
|
|
44
44
|
|
|
45
|
+
def default_sprite_load_path
|
|
46
|
+
CompassRails.sprockets.paths
|
|
47
|
+
end
|
|
48
|
+
|
|
45
49
|
end
|
|
46
50
|
end
|
|
47
51
|
end
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
require 'compass-rails/patches/compass'
|
|
1
2
|
require 'compass-rails/patches/static_compiler'
|
|
2
3
|
|
|
3
4
|
module Sass::Script::Functions
|
|
@@ -6,20 +7,6 @@ module Sass::Script::Functions
|
|
|
6
7
|
end
|
|
7
8
|
end
|
|
8
9
|
|
|
9
|
-
|
|
10
|
-
module Compass::RailsImageFunctionPatch
|
|
11
|
-
private
|
|
12
|
-
|
|
13
|
-
def image_path_for_size(image_file)
|
|
14
|
-
begin
|
|
15
|
-
file = ::Rails.application.assets.find_asset(image_file)
|
|
16
|
-
return file
|
|
17
|
-
rescue ::Sprockets::FileOutsidePaths
|
|
18
|
-
return super(image_file)
|
|
19
|
-
end
|
|
20
|
-
end
|
|
21
|
-
end
|
|
22
|
-
|
|
23
10
|
module Sass::Script::Functions
|
|
24
11
|
include Compass::RailsImageFunctionPatch
|
|
25
12
|
end
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
require 'compass-rails/patches/compass'
|
|
2
|
+
require 'compass-rails/patches/sass_importer'
|
|
3
|
+
require 'compass-rails/patches/sprite_importer'
|
|
4
|
+
|
|
5
|
+
module Sass::Script::Functions
|
|
6
|
+
def generated_image_url(path, only_path = nil)
|
|
7
|
+
cachebust_generated_images
|
|
8
|
+
asset_url(path)
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def cachebust_generated_images
|
|
12
|
+
generated_images_path = Rails.root.join(Compass.configuration.generated_images_dir).to_s
|
|
13
|
+
sprockets_entries = options[:sprockets][:environment].send(:trail).instance_variable_get(:@entries)
|
|
14
|
+
sprockets_entries.delete(generated_images_path) if sprockets_entries.has_key? generated_images_path
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
module Sass::Script::Functions
|
|
19
|
+
include Compass::RailsImageFunctionPatch
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
# Wierd that this has to be re-included to pick up sub-modules. Ruby bug?
|
|
23
|
+
class Sass::Script::Functions::EvaluationContext
|
|
24
|
+
include Sass::Script::Functions
|
|
25
|
+
end
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
module Compass::RailsImageFunctionPatch
|
|
2
|
+
private
|
|
3
|
+
|
|
4
|
+
def image_path_for_size(image_file)
|
|
5
|
+
begin
|
|
6
|
+
file = ::Rails.application.assets.find_asset(image_file)
|
|
7
|
+
return file
|
|
8
|
+
rescue ::Sprockets::FileOutsidePaths
|
|
9
|
+
return super(image_file)
|
|
10
|
+
end
|
|
11
|
+
end
|
|
12
|
+
end
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
module Sprockets
|
|
2
|
+
class SassTemplate < Tilt::Template
|
|
3
|
+
def evaluate(context, locals, &block)
|
|
4
|
+
# Use custom importer that knows about Sprockets Caching
|
|
5
|
+
cache_store = SassCacheStore.new(context.environment)
|
|
6
|
+
paths = context.environment.paths.map { |path| CompassRails::SpriteImporter.new(context, path) }
|
|
7
|
+
paths += context.environment.paths.map { |path| SassImporter.new(context, path) }
|
|
8
|
+
paths += ::Rails.application.config.sass.load_paths
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
options = CompassRails.sass_config.merge( {
|
|
12
|
+
:filename => eval_file,
|
|
13
|
+
:line => line,
|
|
14
|
+
:syntax => syntax,
|
|
15
|
+
:cache_store => cache_store,
|
|
16
|
+
:importer => SassImporter.new(context, context.pathname),
|
|
17
|
+
:load_paths => paths,
|
|
18
|
+
:sprockets => {
|
|
19
|
+
:context => context,
|
|
20
|
+
:environment => context.environment
|
|
21
|
+
}
|
|
22
|
+
})
|
|
23
|
+
|
|
24
|
+
::Sass::Engine.new(data, options).render
|
|
25
|
+
rescue ::Sass::SyntaxError => e
|
|
26
|
+
# Annotates exception message with parse line number
|
|
27
|
+
context.__LINE__ = e.sass_backtrace.first[:line]
|
|
28
|
+
raise e
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
end
|
|
@@ -1,38 +1,30 @@
|
|
|
1
1
|
require 'sprockets'
|
|
2
2
|
require 'compass/sprite_importer'
|
|
3
3
|
|
|
4
|
-
module
|
|
5
|
-
class SpriteImporter <
|
|
4
|
+
module CompassRails
|
|
5
|
+
class SpriteImporter < Compass::SpriteImporter
|
|
6
|
+
attr_reader :context, :root
|
|
6
7
|
|
|
7
|
-
|
|
8
|
+
def initialize(context, root)
|
|
9
|
+
@context = context
|
|
10
|
+
@root = root
|
|
11
|
+
end
|
|
8
12
|
|
|
9
13
|
def find(uri, options)
|
|
10
|
-
|
|
11
|
-
if old = old_find(uri, options)
|
|
12
|
-
@_options = options
|
|
14
|
+
if old = super(uri, options)
|
|
13
15
|
self.class.files(uri).each do |file|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
+
puts file.inspect
|
|
17
|
+
relative_path = Pathname.new(file).relative_path_from(Pathname.new(root))
|
|
18
|
+
begin
|
|
19
|
+
pathname = context.resolve(relative_path)
|
|
20
|
+
context.depend_on_asset(pathname)
|
|
21
|
+
rescue Sprockets::FileNotFound
|
|
22
|
+
|
|
16
23
|
end
|
|
17
24
|
end
|
|
18
25
|
end
|
|
19
26
|
|
|
20
27
|
old
|
|
21
28
|
end
|
|
22
|
-
|
|
23
|
-
private
|
|
24
|
-
|
|
25
|
-
def resolve(uri)
|
|
26
|
-
resolver.resolve(Pathname.new(uri))
|
|
27
|
-
end
|
|
28
|
-
|
|
29
|
-
def context
|
|
30
|
-
resolver.context
|
|
31
|
-
end
|
|
32
|
-
|
|
33
|
-
def resolver
|
|
34
|
-
@_options[:custom][:resolver]
|
|
35
|
-
end
|
|
36
|
-
|
|
37
29
|
end
|
|
38
30
|
end
|
|
@@ -88,12 +88,16 @@ module CompassRails
|
|
|
88
88
|
class Railtie < Rails::Railtie
|
|
89
89
|
|
|
90
90
|
initializer "compass.initialize_rails", :group => :all do |app|
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
91
|
+
if CompassRails.asset_pipeline_enabled?
|
|
92
|
+
require 'compass-rails/patches/3_1'
|
|
93
|
+
# Configure compass for use within rails, and provide the project configuration
|
|
94
|
+
# that came via the rails boot process.
|
|
95
|
+
CompassRails.check_for_double_boot!
|
|
96
|
+
Compass.discover_extensions!
|
|
97
|
+
CompassRails.configure_rails!(app)
|
|
98
|
+
else
|
|
99
|
+
CompassRails.initialize!(app.config.compass)
|
|
100
|
+
end
|
|
97
101
|
end
|
|
98
102
|
end
|
|
99
103
|
end
|