compass-rails 1.0.0.rc.3 → 1.0.0.rc.4

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -15,6 +15,7 @@ Add the `compass-rails` gem line to a group called `:assets` in your application
15
15
 
16
16
  ```ruby
17
17
  group :assets do
18
+ gem 'sass-rails' # if running rails 3.1 or greater
18
19
  gem 'compass-rails'
19
20
  end
20
21
  ```
@@ -46,10 +47,10 @@ older versions of rails that do not use the assets pipeline.
46
47
  If you have your stylesheets already in `app/stylesheets`, you have two choices:
47
48
 
48
49
  1. Move your stylesheets to `app/assets/stylesheets`.
49
- 2. Configure your project to look in `app/assets/stylesheets` by setting
50
- `config.compass.sass_dir = "app/stylesheets"` in your rails
51
- configuration or by setting `sass_dir = "app/stylesheets"` in your
52
- compass configuration file.
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.
53
54
 
54
55
  ## Configuration
55
56
 
@@ -138,6 +139,11 @@ doing things like requiring. These **must not** be used with Sass files.
138
139
  Instead use the sass `@import` directive. In rails projects, the
139
140
  `@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 REAME](https://github.com/rails/sass-rails/blob/master/README.markdown)
140
141
 
142
+ ## Rails 3.1 Caveats
143
+
144
+ There was a bug in rails 3.1.0 -- please make sure you are running 3.1.1
145
+ at the earliest for this version of rails.
146
+
141
147
  ## Rails 3.0 Caveats
142
148
 
143
149
  If you want rails to compile your stylesheets (instead of using the
@@ -9,7 +9,7 @@ GIT
9
9
  PATH
10
10
  remote: ..
11
11
  specs:
12
- compass-rails (1.0.0.rc.1)
12
+ compass-rails (1.0.0.rc.3)
13
13
  compass (~> 0.12.rc.0)
14
14
 
15
15
  GEM
@@ -9,7 +9,7 @@ GIT
9
9
  PATH
10
10
  remote: ..
11
11
  specs:
12
- compass-rails (1.0.0.rc.1)
12
+ compass-rails (1.0.0.rc.3)
13
13
  compass (~> 0.12.rc.0)
14
14
 
15
15
  GEM
@@ -9,7 +9,7 @@ GIT
9
9
  PATH
10
10
  remote: ..
11
11
  specs:
12
- compass-rails (1.0.0.rc.1)
12
+ compass-rails (1.0.0.rc.3)
13
13
  compass (~> 0.12.rc.0)
14
14
 
15
15
  GEM
@@ -9,7 +9,7 @@ GIT
9
9
  PATH
10
10
  remote: ..
11
11
  specs:
12
- compass-rails (1.0.0.rc.1)
12
+ compass-rails (1.0.0.rc.3)
13
13
  compass (~> 0.12.rc.0)
14
14
 
15
15
  GEM
data/lib/compass-rails.rb CHANGED
@@ -177,8 +177,18 @@ module CompassRails
177
177
 
178
178
  def configure_rails!(app)
179
179
  return unless app.config.respond_to?(:sass)
180
- app.config.compass.to_sass_engine_options.each do |key, value|
181
- app.config.sass.send(:"#{key}=", value)
180
+ sass_config = app.config.sass
181
+ compass_config = app.config.compass
182
+
183
+ sass_config.load_paths.concat(compass_config.sass_load_paths)
184
+
185
+ { :output_style => :style,
186
+ :line_comments => :line_comments,
187
+ :cache => :cache,
188
+ :disable_warnings => :quiet,
189
+ :preferred_syntax => :preferred_syntax
190
+ }.each do |compass_option, sass_option|
191
+ set_maybe sass_config, compass_config, sass_option, compass_option
182
192
  end
183
193
  end
184
194
 
@@ -198,6 +208,16 @@ module CompassRails
198
208
  rails_config.respond_to?(:assets) && rails_config.assets.try(:enabled)
199
209
  end
200
210
 
211
+ private
212
+
213
+ # sets the sass config value only if the corresponding compass-based setting
214
+ # has been explicitly set by the user.
215
+ def set_maybe(sass_config, compass_config, sass_option, compass_option)
216
+ if compass_value = compass_config.send(:"#{compass_option}_without_default")
217
+ sass_config.send(:"#{sass_option}=", compass_value)
218
+ end
219
+ end
220
+
201
221
  end
202
222
 
203
223
  Compass::AppIntegration.register(:rails, "::CompassRails")
@@ -26,10 +26,6 @@ module CompassRails
26
26
  "#{top_level.http_path}"
27
27
  end
28
28
 
29
- def default_http_generated_images_path
30
- "#{top_level.http_path}"
31
- end
32
-
33
29
  def default_http_javascripts_path
34
30
  "#{top_level.http_path}"
35
31
  end
@@ -1,3 +1,5 @@
1
+ require 'compass-rails/patches/static_compiler'
2
+
1
3
  module Sass::Script::Functions
2
4
  def generated_image_url(path, only_path = nil)
3
5
  asset_url(path, Sass::Script::String.new("image"))
@@ -25,4 +27,4 @@ end
25
27
  # Wierd that this has to be re-included to pick up sub-modules. Ruby bug?
26
28
  class Sass::Script::Functions::EvaluationContext
27
29
  include Sass::Script::Functions
28
- end
30
+ end
@@ -16,7 +16,7 @@ module Compass
16
16
  end
17
17
  end
18
18
  end
19
-
19
+
20
20
  old
21
21
  end
22
22
 
@@ -35,4 +35,4 @@ module Compass
35
35
  end
36
36
 
37
37
  end
38
- end
38
+ end
@@ -0,0 +1,12 @@
1
+ require 'sprockets/static_compiler'
2
+
3
+ module Sprockets
4
+ class StaticCompiler
5
+ cattr_accessor :generated_sprites
6
+ self.generated_sprites = {}
7
+ def write_manifest_with_sprites(manifest)
8
+ write_manifest_without_sprites(manifest.merge(self.class.generated_sprites))
9
+ end
10
+ alias_method_chain :write_manifest, :sprites
11
+ end
12
+ end
@@ -31,8 +31,8 @@ class Rails::Railtie::Configuration
31
31
  Compass::Configuration::Data.new("rails_config")
32
32
  end
33
33
  data.project_type = :rails # Forcing this makes sure all the rails defaults will be loaded.
34
- data.inherit_from!(Compass.configuration) #force this
35
- Compass.add_project_configuration(data)
34
+ Compass.add_configuration(:rails)
35
+ Compass.add_configuration(data)
36
36
  Compass.configuration.on_sprite_saved do |filename|
37
37
  # This is a huge hack based on reading through the sprockets internals.
38
38
  # Sprockets needs an API for adding assets during precompilation.
@@ -56,18 +56,26 @@ class Rails::Railtie::Configuration
56
56
  # hash or some metadata that is opaque to sprockets that could be read from the
57
57
  # asset's attributes, we could avoid cluttering the assets directory with generated
58
58
  # sprites and always just use the logical_path + data version of the api.
59
- if Rails.application.config.assets.digests.try(:any?)
60
- asset = Rails.application.assets.find_asset(filename)
59
+ if Rails.application.config.assets.digest && # if digesting is enabled
60
+ caller.grep(/static_compiler/).any? && #OMG HAX - check if we're being precompiled
61
+ Compass.configuration.generated_images_path[Compass.configuration.images_path] # if the generated images path is not in the assets images directory, we don't have to do these backflips
62
+
63
+ # Clear entries in Hike::Index for this sprite's directory.
64
+ # This makes sure the asset can be found by find_assets
65
+ Rails.application.assets.send(:trail).instance_variable_get(:@entries).delete(File.dirname(filename))
66
+
61
67
  pathname = Pathname.new(filename)
62
- logical_path = filename[(Compass.configuration.generated_images_path.length+1)..-1]
63
- # Force the asset into the cache so find_asset will find it.
64
- cached_assets = Rails.application.assets.instance_variable_get("@assets")
65
- cached_assets[logical_path] = cached_assets[filename] = asset
68
+ logical_path = pathname.relative_path_from(Pathname.new(Compass.configuration.images_path))
69
+ asset = Rails.application.assets.find_asset(logical_path)
70
+ target = File.join(Rails.public_path, Rails.application.config.assets.prefix, asset.digest_path)
71
+
72
+ # Adds the asset to the manifest file.
73
+ Sprockets::StaticCompiler.generated_sprites[logical_path.to_s] = asset.digest_path
74
+
75
+ # Adds the fingerprinted asset to the public directory
76
+ FileUtils.mkdir_p File.dirname(target)
77
+ asset.write_to target
66
78
 
67
- target = Pathname.new(File.join(Rails.public_path, Rails.application.config.assets.prefix))
68
- asset = Rails.application.assets.find_asset(logical_path)
69
- filename = target.join(asset.digest_path)
70
- asset.write_to(filename)
71
79
  end
72
80
  end
73
81
  data
@@ -88,4 +96,4 @@ module CompassRails
88
96
  CompassRails.configure_rails!(app)
89
97
  end
90
98
  end
91
- end
99
+ end
@@ -1,5 +1,5 @@
1
1
  module CompassRails
2
2
  unless defined?(::CompassRails::VERSION)
3
- VERSION = "1.0.0.rc.3"
3
+ VERSION = "1.0.0.rc.4"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: compass-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0.rc.3
4
+ version: 1.0.0.rc.4
5
5
  prerelease: 6
6
6
  platform: ruby
7
7
  authors:
@@ -10,11 +10,11 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2012-02-16 00:00:00.000000000Z
13
+ date: 2012-03-12 00:00:00.000000000Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: compass
17
- requirement: &70279494124840 !ruby/object:Gem::Requirement
17
+ requirement: &70331335147980 !ruby/object:Gem::Requirement
18
18
  none: false
19
19
  requirements:
20
20
  - - ~>
@@ -22,7 +22,7 @@ dependencies:
22
22
  version: 0.12.rc.0
23
23
  type: :runtime
24
24
  prerelease: false
25
- version_requirements: *70279494124840
25
+ version_requirements: *70331335147980
26
26
  description: Integrate Compass into Rails 2.3 and up.
27
27
  email:
28
28
  - jetviper21@gmail.com
@@ -57,6 +57,7 @@ files:
57
57
  - lib/compass-rails/patches/3_1.rb
58
58
  - lib/compass-rails/patches/importer.rb
59
59
  - lib/compass-rails/patches/sprite_importer.rb
60
+ - lib/compass-rails/patches/static_compiler.rb
60
61
  - lib/compass-rails/railties.rb
61
62
  - lib/compass-rails/railties/2_3.rb
62
63
  - lib/compass-rails/railties/3_0.rb