compass-rails 1.1.7 → 2.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 CHANGED
@@ -1,15 +1,7 @@
1
1
  ---
2
- !binary "U0hBMQ==":
3
- metadata.gz: !binary |-
4
- OGJhZGJjYmQ4NzYxODExMDQ5MTllYzM2ZmM1MGQ0YWZlODAzZmZmMw==
5
- data.tar.gz: !binary |-
6
- YTRiYTc0M2VhZjkyOGJkNzVmNWYxMDJmOTE0OTA2ZGY3MzBiZjEzMA==
2
+ SHA1:
3
+ metadata.gz: 32048be7b100642ba51ac64ba90f5d8772db0089
4
+ data.tar.gz: 72b5056ea2292f497bc0bcbf2b3bdb94f9aae889
7
5
  SHA512:
8
- metadata.gz: !binary |-
9
- YTJiYWRmMGMzNzJiNWUyZmVkNDVhOTMzN2E1ZDBkYzBkMTU2OWU2NzBkNWEw
10
- NjdhMTkxZjYyMmI0ZjViODhhMWIyMmRiMjVjZDlhMjEyNzUyNTVjY2I5Njc5
11
- MTk1YjQ5YWVhMmNmN2NmMzVmNDQxMWFhM2Y0MDU2OGNiNWI3ZmI=
12
- data.tar.gz: !binary |-
13
- N2Q2ZmE3OTYxNzM5MDJiMzFiMTQ0YzQ5ZWU0YzFjZDNiZDFlODFmMzMxZmM3
14
- NjFiMTRhZDk0ZmY0ODdhOTcwYjM1NGI4MzM0ZDk0NTVmNGU1OWI0ZTMxNjVj
15
- ZmNlMjI4NTk5Y2EyZjFiOWJhMTY1YTU0YThmZWZlM2VkN2JmZjk=
6
+ metadata.gz: 52f299102a23a6cc39be6bb5b38fcaa9e7fa68f5988eb1f055420508729e626497f91d4540ea364e70eb4141de3f5cf1e84c135fd48438dc8d8010e87ad63453
7
+ data.tar.gz: cdb26631fb53897b9a4ecdb3d304fd514956f23bebfd766f4825c90711a2cbfcad708fcbaa81a24dc28c493c2e98cc72a4f575c9b05d828d5739babba8bba847
data/Appraisals CHANGED
@@ -1,7 +1,3 @@
1
- appraise "rails3" do
2
- gem "rails", "3.0.11"
3
- end
4
-
5
1
  appraise "rails31" do
6
2
  gem "rails", "3.1.3"
7
3
  gem "sass-rails"
data/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  **We Take Pull Requests!**
4
4
 
5
- [![Build Status](https://travis-ci.org/Compass/compass-rails.png?branch=stable)](https://travis-ci.org/Compass/compass-rails)
5
+ [![Build Status](https://travis-ci.org/Compass/compass-rails.png?branch=master)](https://travis-ci.org/Compass/compass-rails)
6
6
  [![Code Climate](https://codeclimate.com/github/Compass/compass-rails.png)](https://codeclimate.com/github/Compass/compass-rails)
7
7
 
8
8
  Compass rails is an adapter for the [Compass Stylesheet Authoring
@@ -10,17 +10,15 @@ Framework](http://compass-style.org) for [Ruby on Rails](http://rubyonrails.org/
10
10
 
11
11
  Since Compass v0.12.0, this is the only way to use compass with your rails application.
12
12
 
13
- Supports Rails 3.x, 4.x releases.
13
+ Supports Rails 3.2, 4.x releases.
14
14
 
15
15
  ## Installation
16
16
 
17
- Add the `compass-rails` gem line to a group called `:assets` in your application's Gemfile (Rails 3.1+ users should already have the `:assets` group):
17
+ Add the `compass-rails` gem line to your application's Gemfile
18
18
 
19
19
  ```ruby
20
- group :assets do
21
- gem 'sass-rails' # if running rails 3.1 or greater
22
- gem 'compass-rails'
23
- end
20
+ gem 'sass-rails'
21
+ gem 'compass-rails'
24
22
  ```
25
23
 
26
24
  If you are using any Compass extensions, add them to this group in your
@@ -32,12 +30,13 @@ And then execute:
32
30
 
33
31
  ## Usage
34
32
 
35
- Change your `application.css` to `application.css.scss` or `application.css.sass` and use `@import` to your hearts content. Ex:
33
+ Change your `application.css` to `application.css.scss` or `application.css.sass` and then `@import compass` and your own stylesheets to your hearts content. E.g.:
36
34
 
37
35
  ```scss
38
- @import "project/mixins";
39
- @import "project/base";
36
+ @import "compass";
40
37
 
38
+ @import "your_project/mixins";
39
+ @import "your_project/base";
41
40
  ```
42
41
 
43
42
  *or*
@@ -63,7 +62,7 @@ configuration object exposed to rails within any configuration block.
63
62
 
64
63
  ### Installing Compass extensions
65
64
 
66
- Step 1: Add it to your Gemfile in the `:assets` group and run the `bundle` command to install it.
65
+ Step 1: Add it to your Gemfile and run the `bundle` command to install it.
67
66
 
68
67
  Step 2: Install the extension's assets: `bundle exec compass install
69
68
  <extension/template>`
@@ -72,17 +71,15 @@ For example, if you want to use susy.
72
71
 
73
72
  ```ruby
74
73
  # Gemfile
75
- group :assets do
76
- gem 'compass-rails'
77
- gem 'compass-susy-plugin'
78
- end
74
+ gem 'compass-rails'
75
+ gem 'compass-susy-plugin'
79
76
  ```
80
77
 
81
78
  then run:
82
79
 
83
80
  $ bundle
84
81
  $ bundle exec compass install susy
85
-
82
+
86
83
  if you are using the rails configuration files you should add:
87
84
 
88
85
  ```ruby
@@ -17,6 +17,5 @@ Gem::Specification.new do |gem|
17
17
  gem.license = "MIT"
18
18
 
19
19
  gem.add_dependency 'compass', '>= 0.12.2'
20
- gem.add_dependency 'sprockets', '<= 2.11.0'
21
20
 
22
21
  end
@@ -4,10 +4,9 @@ require "compass-rails/configuration"
4
4
 
5
5
  module CompassRails
6
6
 
7
- RAILS_4 = %r{^4.[0|1]}
7
+ RAILS_4 = %r{^4.[0|1|2]}
8
8
  RAILS_32 = %r{^3.2}
9
9
  RAILS_31 = %r{^3.1}
10
- RAILS_3 = %r{^3.0}
11
10
 
12
11
  extend self
13
12
 
@@ -22,12 +21,10 @@ module CompassRails
22
21
  end
23
22
  #load the rails config
24
23
  require "#{rails_config_path}/config/application.rb"
25
- if rails31? || rails32? || rails4?
26
- require 'sass-rails'
27
- require 'sprockets/railtie'
28
- require 'rails/engine'
29
- @app ||= ::Rails.application.initialize!
30
- end
24
+ require 'sass-rails'
25
+ require 'sprockets/railtie'
26
+ require 'rails/engine'
27
+ @app ||= ::Rails.application.initialize!
31
28
  end
32
29
 
33
30
 
@@ -84,11 +81,6 @@ module CompassRails
84
81
  rails_spec.version.to_s
85
82
  end
86
83
 
87
- def rails3?
88
- return false unless defined?(::Rails)
89
- version_match RAILS_3
90
- end
91
-
92
84
  def rails31?
93
85
  return false unless defined?(::Rails)
94
86
  version_match RAILS_31
@@ -123,18 +115,10 @@ module CompassRails
123
115
  def configuration
124
116
  load_rails
125
117
  config = Compass::Configuration::Data.new('rails')
126
- config.extend(Configuration::Default)
127
- if asset_pipeline_enabled?
128
- require "compass-rails/configuration/asset_pipeline"
129
- config.extend(Configuration::AssetPipeline)
130
- end
118
+ config.extend(CompassRails::Configuration)
131
119
  config
132
120
  end
133
121
 
134
- def env
135
- env_production? ? :production : :development
136
- end
137
-
138
122
  def prefix
139
123
  ::Rails.application.config.assets.prefix
140
124
  end
@@ -206,13 +190,18 @@ module CompassRails
206
190
  end
207
191
 
208
192
  def boot_config
209
- config = if (config_file = Compass.detect_configuration_file) && (config_data = Compass.configuration_for(config_file))
210
- config_data
211
- else
212
- Compass::Configuration::Data.new("compass_rails_boot")
193
+ config = begin
194
+ if (config_file = Compass.detect_configuration_file) &&
195
+ (config_data = Compass.configuration_for(config_file))
196
+ config_data
197
+ else
198
+ Compass::Configuration::Data.new("compass_rails_boot")
199
+ end
200
+ end
201
+
202
+ config.tap do |c|
203
+ c.top_level.project_type = :rails
213
204
  end
214
- config.top_level.project_type = :rails
215
- config
216
205
  end
217
206
 
218
207
  def asset_pipeline_enabled?
@@ -1 +1,77 @@
1
- require "compass-rails/configuration/default"
1
+ module CompassRails
2
+ module Configuration
3
+ def default_images_dir
4
+ File.join("app", "assets", "images")
5
+ end
6
+
7
+ def default_fonts_dir
8
+ File.join("app", "assets", "fonts")
9
+ end
10
+
11
+ def default_javascripts_dir
12
+ File.join("app", "assets", "javascripts")
13
+ end
14
+
15
+ def default_css_dir
16
+ File.join('public', CompassRails.prefix)
17
+ end
18
+
19
+ def default_http_path
20
+ File.join(CompassRails.prefix)
21
+ end
22
+
23
+ def default_http_images_path
24
+ "#{top_level.http_path}"
25
+ end
26
+
27
+ def default_http_javascripts_path
28
+ "#{top_level.http_path}"
29
+ end
30
+
31
+ def default_http_fonts_path
32
+ "#{top_level.http_path}"
33
+ end
34
+
35
+ def default_http_stylesheets_path
36
+ "#{top_level.http_path}"
37
+ end
38
+
39
+ def default_preferred_syntax
40
+ ::Rails.application.config.sass.preferred_syntax rescue nil
41
+ end
42
+
43
+ def default_sprite_load_path
44
+ CompassRails.sprockets.paths
45
+ end
46
+
47
+ def project_type_without_default
48
+ :rails
49
+ end
50
+
51
+ def default_sass_dir
52
+ File.join("app", "assets", "stylesheets")
53
+ end
54
+
55
+ def default_http_generated_images_path
56
+ # Relies on the fact that this will be loaded after the "normal"
57
+ # defaults, so that method_missing finds http_root_relative
58
+ http_root_relative "images"
59
+ end
60
+
61
+ def default_extensions_dir
62
+ File.join("vendor", "plugins", "compass_extensions")
63
+ end
64
+
65
+ def default_cache_dir
66
+ File.join("tmp", "sass-cache")
67
+ end
68
+
69
+ def default_project_path
70
+ Rails.root
71
+ end
72
+
73
+ def default_environment
74
+ Rails.env
75
+ end
76
+ end
77
+ end
@@ -4,14 +4,34 @@ require 'compass-rails/patches/sprite_importer'
4
4
 
5
5
  module Sass::Script::Functions
6
6
  def generated_image_url(path, only_path = nil)
7
- cachebust_generated_images
7
+ pathobject = Pathname.new(path.to_s)
8
+ subdirectory = pathobject.dirname.to_s
9
+
10
+ cachebust_generated_images(path, subdirectory)
8
11
  asset_url(path)
9
12
  end
10
13
 
11
- def cachebust_generated_images
14
+ def cachebust_generated_images(image_path, subdirectory = nil)
12
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
18
+ else
19
+ bust_cache_path = generated_images_path + "/" + subdirectory
20
+ end
21
+ bust_image_stat_path = generated_images_path + "/" + image_path.to_s
22
+
13
23
  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
24
+
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)
28
+
29
+ # 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
+
32
+ # 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)
34
+ end
15
35
  end
16
36
  end
17
37
 
@@ -1,31 +1,36 @@
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
1
+ klass = if defined?(Sass::Rails::SassTemplate)
2
+ Sass::Rails::SassTemplate
3
+ else
4
+ Sprockets::SassTemplate
5
+ end
6
+
7
+ klass.class_eval do
8
+ def evaluate(context, locals, &block)
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
9
14
 
10
15
 
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
- })
16
+ options = CompassRails.sass_config.merge( {
17
+ :filename => eval_file,
18
+ :line => line,
19
+ :syntax => syntax,
20
+ :cache_store => cache_store,
21
+ :importer => self.class.parent::SassImporter.new(context, context.pathname),
22
+ :load_paths => paths,
23
+ :sprockets => {
24
+ :context => context,
25
+ :environment => context.environment
26
+ }
27
+ })
23
28
 
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
29
+ ::Sass::Engine.new(data, options).render
30
+ rescue ::Sass::SyntaxError => e
31
+ # Annotates exception message with parse line number
32
+ context.__LINE__ = e.sass_backtrace.first[:line]
33
+ raise e
30
34
  end
31
- end
35
+ end
36
+
@@ -1,8 +1,6 @@
1
1
  if defined?(::Rails)
2
2
  if CompassRails.rails31? || CompassRails.rails32?
3
3
  require "compass-rails/railties/3_1"
4
- elsif CompassRails.rails3?
5
- require "compass-rails/railties/3_0"
6
4
  elsif CompassRails.rails4?
7
5
  require "compass-rails/railties/4_0"
8
6
  else
@@ -1,93 +1,8 @@
1
- #3.1.3
2
- require 'compass'
3
- require 'rails/railtie'
4
-
5
- class Rails::Railtie::Configuration
6
- # Adds compass configuration accessor to the application configuration.
7
- #
8
- # If a configuration file for compass exists, it will be read in and
9
- # the project's configuration values will already be set on the config
10
- # object.
11
- #
12
- # For example:
13
- #
14
- # module MyApp
15
- # class Application < Rails::Application
16
- # config.compass.line_comments = !Rails.env.production?
17
- # config.compass.fonts_dir = "app/assets/fonts"
18
- # end
19
- # end
20
- #
21
- # It is suggested that you create a compass configuration file if you
22
- # want a quicker boot time when using the compass command line tool.
23
- #
24
- # For more information on available configuration options see:
25
- # http://compass-style.org/help/tutorials/configuration-reference/
26
- def compass
27
- @compass ||= begin
28
- data = if (config_file = Compass.detect_configuration_file) && (config_data = Compass.configuration_for(config_file))
29
- config_data
30
- else
31
- Compass::Configuration::Data.new("rails_config")
32
- end
33
- data.project_type = :rails # Forcing this makes sure all the rails defaults will be loaded.
34
- Compass.add_configuration(:rails)
35
- Compass.add_configuration(data)
36
- Compass.configuration.on_sprite_saved do |filename|
37
- # This is a huge hack based on reading through the sprockets internals.
38
- # Sprockets needs an API for adding assets during precompilation.
39
- # At a minimum sprockets should provide this API:
40
- #
41
- # #filename is a path in the asset source directory
42
- # Rails.application.assets.new_asset!(filename)
43
- #
44
- # # logical_path is how devs refer to it, data is the contents of it.
45
- # Rails.application.assets.new_asset!(logical_path, data)
46
- #
47
- # I would also like to select one of the above calls based on whether
48
- # the user is precompiling or not:
49
- #
50
- # Rails.application.assets.precompiling? #=> true or false
51
- #
52
- # But even the above is not an ideal API. The issue is that compass sprites need to
53
- # avoid generation if the sprite file is already generated (which can be quite time
54
- # consuming). To do this, compass has it's own uniqueness hash based on the user's
55
- # inputs instead of being based on the file contents. So if we could provide our own
56
- # hash or some metadata that is opaque to sprockets that could be read from the
57
- # asset's attributes, we could avoid cluttering the assets directory with generated
58
- # sprites and always just use the logical_path + data version of the api.
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
-
67
- pathname = Pathname.new(filename)
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
78
-
79
- end
80
- end
81
- data
82
- end
83
- @compass
84
- end
85
- end
86
-
87
1
  module CompassRails
88
2
  class Railtie < Rails::Railtie
89
3
 
90
4
  initializer "compass.initialize_rails", :group => :all do |app|
5
+ require 'compass'
91
6
  if CompassRails.asset_pipeline_enabled?
92
7
  require 'compass-rails/patches/3_1'
93
8
  # Configure compass for use within rails, and provide the project configuration
@@ -99,5 +14,42 @@ module CompassRails
99
14
  CompassRails.initialize!(app.config.compass)
100
15
  end
101
16
  end
17
+
18
+ config.compass = begin
19
+ @compass ||= begin
20
+ data = if (config_file = Compass.detect_configuration_file) && (config_data = Compass.configuration_for(config_file))
21
+ config_data
22
+ else
23
+ Compass::Configuration::Data.new("rails_config")
24
+ end
25
+ data.project_type = :rails # Forcing this makes sure all the rails defaults will be loaded.
26
+ Compass.add_configuration(:rails)
27
+ Compass.add_configuration(data)
28
+ Compass.configuration.on_sprite_saved do |filename|
29
+ if Rails.application.config.assets.digest && # if digesting is enabled
30
+ caller.grep(/static_compiler/).any? && #OMG HAX - check if we're being precompiled
31
+ 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
32
+
33
+ # Clear entries in Hike::Index for this sprite's directory.
34
+ # 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))
36
+
37
+ pathname = Pathname.new(filename)
38
+ logical_path = pathname.relative_path_from(Pathname.new(Compass.configuration.images_path))
39
+ asset = Rails.application.assets.find_asset(logical_path)
40
+ target = File.join(Rails.public_path, Rails.application.config.assets.prefix, asset.digest_path)
41
+
42
+ # Adds the asset to the manifest file.
43
+ Sprockets::StaticCompiler.generated_sprites[logical_path.to_s] = asset.digest_path
44
+
45
+ # Adds the fingerprinted asset to the public directory
46
+ FileUtils.mkdir_p File.dirname(target)
47
+ asset.write_to target
48
+
49
+ end
50
+ end
51
+ data
52
+ end
53
+ end
102
54
  end
103
55
  end
@@ -1,96 +1,8 @@
1
- #3.1.3
2
- require 'compass'
3
- require 'rails/railtie'
4
-
5
- class Rails::Railtie::Configuration
6
- # Adds compass configuration accessor to the application configuration.
7
- #
8
- # If a configuration file for compass exists, it will be read in and
9
- # the project's configuration values will already be set on the config
10
- # object.
11
- #
12
- # For example:
13
- #
14
- # module MyApp
15
- # class Application < Rails::Application
16
- # config.compass.line_comments = !Rails.env.production?
17
- # config.compass.fonts_dir = "app/assets/fonts"
18
- # end
19
- # end
20
- #
21
- # It is suggested that you create a compass configuration file if you
22
- # want a quicker boot time when using the compass command line tool.
23
- #
24
- # For more information on available configuration options see:
25
- # http://compass-style.org/help/tutorials/configuration-reference/
26
- def compass
27
- @compass ||= begin
28
- data = if (config_file = Compass.detect_configuration_file) && (config_data = Compass.configuration_for(config_file))
29
- config_data
30
- else
31
- Compass::Configuration::Data.new("rails_config")
32
- end
33
- data.project_type = :rails # Forcing this makes sure all the rails defaults will be loaded.
34
- Compass.add_configuration(:rails)
35
- Compass.add_configuration(data)
36
- Compass.configuration.on_sprite_saved do |filename|
37
- # This is a huge hack based on reading through the sprockets internals.
38
- # Sprockets needs an API for adding assets during precompilation.
39
- # At a minimum sprockets should provide this API:
40
- #
41
- # #filename is a path in the asset source directory
42
- # Rails.application.assets.new_asset!(filename)
43
- #
44
- # # logical_path is how devs refer to it, data is the contents of it.
45
- # Rails.application.assets.new_asset!(logical_path, data)
46
- #
47
- # I would also like to select one of the above calls based on whether
48
- # the user is precompiling or not:
49
- #
50
- # Rails.application.assets.precompiling? #=> true or false
51
- #
52
- # But even the above is not an ideal API. The issue is that compass sprites need to
53
- # avoid generation if the sprite file is already generated (which can be quite time
54
- # consuming). To do this, compass has it's own uniqueness hash based on the user's
55
- # inputs instead of being based on the file contents. So if we could provide our own
56
- # hash or some metadata that is opaque to sprockets that could be read from the
57
- # asset's attributes, we could avoid cluttering the assets directory with generated
58
- # sprites and always just use the logical_path + data version of the api.
59
- if Rails.application.config.assets.digest && # if digesting is enabled
60
- caller.grep(%r{/sprockets/rails/task.rb}).any? && #OMG HAX - check if we're being precompiled
61
- Compass.configuration.generated_images_path[Compass.configuration.images_path.to_s] # 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
-
67
- pathname = Pathname.new(filename)
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
-
74
- manifest = ActionView::Base.assets_manifest
75
- manifest.assets[logical_path.to_s] = asset.digest_path
76
-
77
-
78
- # Adds the fingerprinted asset to the public directory
79
- FileUtils.mkdir_p File.dirname(target)
80
- asset.write_to target
81
-
82
- end
83
- end
84
- data
85
- end
86
- @compass
87
- end
88
- end
89
-
90
1
  module CompassRails
91
2
  class Railtie < Rails::Railtie
92
3
 
93
4
  initializer "compass.initialize_rails", :group => :all do |app|
5
+ require 'compass'
94
6
  require 'compass-rails/patches/4_0'
95
7
  # Configure compass for use within rails, and provide the project configuration
96
8
  # that came via the rails boot process.
@@ -98,5 +10,47 @@ module CompassRails
98
10
  Compass.discover_extensions!
99
11
  CompassRails.configure_rails!(app)
100
12
  end
13
+
14
+ config.compass = begin
15
+ @compass ||= begin
16
+ data = if (config_file = Compass.detect_configuration_file) && (config_data = Compass.configuration_for(config_file))
17
+ config_data
18
+ else
19
+ Compass::Configuration::Data.new("rails_config")
20
+ end
21
+ data.project_type = :rails # Forcing this makes sure all the rails defaults will be loaded.
22
+ Compass.add_configuration(:rails)
23
+ Compass.add_configuration(data)
24
+ Compass.configuration.on_sprite_saved do |filename|
25
+ if Rails.application.config.assets.digest && # if digesting is enabled
26
+ caller.grep(%r{/sprockets/rails/task.rb}).any? && #OMG HAX - check if we're being precompiled
27
+ Compass.configuration.generated_images_path[Compass.configuration.images_path.to_s] # if the generated images path is not in the assets images directory, we don't have to do these backflips
28
+
29
+ # Clear entries in Hike::Index for this sprite's directory.
30
+ # 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)
34
+
35
+ 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
+ target = File.join(Rails.public_path, Rails.application.config.assets.prefix, asset.digest_path)
39
+
40
+ # Adds the asset to the manifest file.
41
+
42
+ manifest = ActionView::Base.assets_manifest
43
+ manifest.assets[logical_path.to_s] = asset.digest_path
44
+
45
+
46
+ # Adds the fingerprinted asset to the public directory
47
+ FileUtils.mkdir_p File.dirname(target)
48
+ asset.write_to target
49
+
50
+ end
51
+ end
52
+ data
53
+ end
54
+ end
101
55
  end
102
56
  end
@@ -1,5 +1,5 @@
1
1
  module CompassRails
2
2
  unless defined?(::CompassRails::VERSION)
3
- VERSION = "1.1.7"
3
+ VERSION = "2.0.0"
4
4
  end
5
5
  end
@@ -8,29 +8,25 @@ module CompassRails
8
8
  RAILS_4_0 = "4.0"
9
9
  RAILS_3_2 = "3.2"
10
10
  RAILS_3_1 = "3.1"
11
- RAILS_3 = "3.0"
12
11
 
13
12
  WORKING_DIR = File.join(ROOT_PATH, 'rails-temp')
14
13
 
15
14
  GEMFILES = {
16
15
  RAILS_4_0 => GEMFILES_DIR.join("rails40.gemfile").to_s,
17
16
  RAILS_3_2 => GEMFILES_DIR.join("rails32.gemfile").to_s,
18
- RAILS_3_1 => GEMFILES_DIR.join("rails31.gemfile").to_s,
19
- RAILS_3 => GEMFILES_DIR.join("rails3.gemfile").to_s
17
+ RAILS_3_1 => GEMFILES_DIR.join("rails31.gemfile").to_s
20
18
  }
21
19
 
22
20
  GENERATOR_OPTIONS = {
23
21
  RAILS_4_0 => ['-q', '-G', '-O', '--skip-bundle'],
24
22
  RAILS_3_2 => ['-q', '-G', '-O', '--skip-bundle'],
25
- RAILS_3_1 => ['-q', '-G', '-O', '--skip-bundle'],
26
- RAILS_3 => ['-q', '-G', '-O', '--skip-bundle']
23
+ RAILS_3_1 => ['-q', '-G', '-O', '--skip-bundle']
27
24
  }
28
25
 
29
26
  GENERATOR_COMMAND = {
30
27
  RAILS_4_0 => 'new',
31
28
  RAILS_3_2 => 'new',
32
- RAILS_3_1 => 'new',
33
- RAILS_3 => 'new'
29
+ RAILS_3_1 => 'new'
34
30
  }
35
31
 
36
32
  def rails_command(options, version)
@@ -1,4 +1,5 @@
1
1
  require 'test_helper'
2
+
2
3
  class Rails31Test < Test::Unit::TestCase
3
4
  include CompassRails::Test::RailsHelpers
4
5
 
@@ -35,13 +36,11 @@ class Rails31Test < Test::Unit::TestCase
35
36
  end
36
37
  end
37
38
 
38
-
39
39
  def test_compass_preferred_syntax
40
40
  within_rails_app('test_railtie', RAILS_VERSION) do |project|
41
41
  project.set_rails('sass.preferred_syntax', :sass)
42
42
  project.run_compass('init')
43
43
  assert project.directory.join('app/assets/stylesheets/screen.css.sass').exist?
44
- end
44
+ end
45
45
  end
46
-
47
- end
46
+ end
@@ -1,6 +1,8 @@
1
1
  require 'test_helper'
2
+
2
3
  class Rails32Test < Test::Unit::TestCase
3
4
  include CompassRails::Test::RailsHelpers
5
+
4
6
  RAILS_VERSION = RAILS_3_2
5
7
 
6
8
  def test_rails_app_created
@@ -9,7 +11,6 @@ class Rails32Test < Test::Unit::TestCase
9
11
  end
10
12
  end
11
13
 
12
-
13
14
  def test_installs_compass
14
15
  within_rails_app('test_railtie', RAILS_VERSION) do |project|
15
16
  project.run_compass('init')
@@ -40,7 +41,6 @@ class Rails32Test < Test::Unit::TestCase
40
41
  project.set_rails('sass.preferred_syntax', :sass)
41
42
  project.run_compass('init')
42
43
  assert project.directory.join('app/assets/stylesheets/screen.css.sass').exist?
43
- end
44
+ end
44
45
  end
45
-
46
- end
46
+ end
@@ -1,6 +1,8 @@
1
1
  require 'test_helper'
2
+
2
3
  class Rails40Test < Test::Unit::TestCase
3
4
  include CompassRails::Test::RailsHelpers
5
+
4
6
  RAILS_VERSION = RAILS_4_0
5
7
 
6
8
  def test_rails_app_created
@@ -9,7 +11,6 @@ class Rails40Test < Test::Unit::TestCase
9
11
  end
10
12
  end
11
13
 
12
-
13
14
  def test_installs_compass
14
15
  within_rails_app('test_railtie', RAILS_VERSION) do |project|
15
16
  project.run_compass('init')
@@ -42,5 +43,4 @@ class Rails40Test < Test::Unit::TestCase
42
43
  assert project.directory.join('app/assets/stylesheets/screen.css.sass').exist?
43
44
  end
44
45
  end
45
-
46
46
  end
@@ -1,10 +1,10 @@
1
1
  require 'test/unit'
2
2
  require 'compass-rails'
3
3
  require 'rainbow'
4
+
4
5
  module CompassRails
5
6
  module Test
6
7
  ROOT_PATH = File.expand_path('../../', __FILE__)
7
- TESTING_VERSION = '0.12.alpha'
8
8
  end
9
9
  end
10
10
 
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.1.7
4
+ version: 2.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Scott Davis
@@ -10,36 +10,22 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2014-03-18 00:00:00.000000000 Z
13
+ date: 2014-07-10 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
- requirement: !ruby/object:Gem::Requirement
17
- requirements:
18
- - - ! '>='
19
- - !ruby/object:Gem::Version
20
- version: 0.12.2
21
- prerelease: false
22
16
  name: compass
23
- version_requirements: !ruby/object:Gem::Requirement
17
+ requirement: !ruby/object:Gem::Requirement
24
18
  requirements:
25
- - - ! '>='
19
+ - - ">="
26
20
  - !ruby/object:Gem::Version
27
21
  version: 0.12.2
28
22
  type: :runtime
29
- - !ruby/object:Gem::Dependency
30
- requirement: !ruby/object:Gem::Requirement
31
- requirements:
32
- - - <=
33
- - !ruby/object:Gem::Version
34
- version: 2.11.0
35
23
  prerelease: false
36
- name: sprockets
37
24
  version_requirements: !ruby/object:Gem::Requirement
38
25
  requirements:
39
- - - <=
26
+ - - ">="
40
27
  - !ruby/object:Gem::Version
41
- version: 2.11.0
42
- type: :runtime
28
+ version: 0.12.2
43
29
  description: Integrate Compass into Rails 3.0 and up.
44
30
  email:
45
31
  - jetviper21@gmail.com
@@ -49,8 +35,8 @@ executables: []
49
35
  extensions: []
50
36
  extra_rdoc_files: []
51
37
  files:
52
- - .gitignore
53
- - .travis.yml
38
+ - ".gitignore"
39
+ - ".travis.yml"
54
40
  - Appraisals
55
41
  - Gemfile
56
42
  - Guardfile
@@ -59,14 +45,11 @@ files:
59
45
  - Rakefile
60
46
  - changelog.markdown
61
47
  - compass-rails.gemspec
62
- - gemfiles/rails3.gemfile
63
48
  - gemfiles/rails31.gemfile
64
49
  - gemfiles/rails32.gemfile
65
50
  - gemfiles/rails40.gemfile
66
51
  - lib/compass-rails.rb
67
52
  - lib/compass-rails/configuration.rb
68
- - lib/compass-rails/configuration/asset_pipeline.rb
69
- - lib/compass-rails/configuration/default.rb
70
53
  - lib/compass-rails/installer.rb
71
54
  - lib/compass-rails/patches.rb
72
55
  - lib/compass-rails/patches/3_1.rb
@@ -77,7 +60,6 @@ files:
77
60
  - lib/compass-rails/patches/sprite_importer.rb
78
61
  - lib/compass-rails/patches/static_compiler.rb
79
62
  - lib/compass-rails/railties.rb
80
- - lib/compass-rails/railties/3_0.rb
81
63
  - lib/compass-rails/railties/3_1.rb
82
64
  - lib/compass-rails/railties/4_0.rb
83
65
  - lib/compass-rails/version.rb
@@ -89,10 +71,8 @@ files:
89
71
  - test/helpers/rails_helper.rb
90
72
  - test/helpers/rails_project.rb
91
73
  - test/integrations/.gitkeep
92
- - test/integrations/rails3_test.rb
93
74
  - test/integrations/rails_31_test.rb
94
75
  - test/integrations/rails_32_test.rb
95
- - test/integrations/rails_32_without_pipeline_test.rb
96
76
  - test/integrations/rails_40_test.rb
97
77
  - test/test_helper.rb
98
78
  - test/units/.gitkeep
@@ -106,17 +86,17 @@ require_paths:
106
86
  - lib
107
87
  required_ruby_version: !ruby/object:Gem::Requirement
108
88
  requirements:
109
- - - ! '>='
89
+ - - ">="
110
90
  - !ruby/object:Gem::Version
111
91
  version: '0'
112
92
  required_rubygems_version: !ruby/object:Gem::Requirement
113
93
  requirements:
114
- - - ! '>='
94
+ - - ">="
115
95
  - !ruby/object:Gem::Version
116
96
  version: '0'
117
97
  requirements: []
118
98
  rubyforge_project:
119
- rubygems_version: 2.1.11
99
+ rubygems_version: 2.2.2
120
100
  signing_key:
121
101
  specification_version: 4
122
102
  summary: Integrate Compass into Rails 3.0 and up.
@@ -128,10 +108,9 @@ test_files:
128
108
  - test/helpers/rails_helper.rb
129
109
  - test/helpers/rails_project.rb
130
110
  - test/integrations/.gitkeep
131
- - test/integrations/rails3_test.rb
132
111
  - test/integrations/rails_31_test.rb
133
112
  - test/integrations/rails_32_test.rb
134
- - test/integrations/rails_32_without_pipeline_test.rb
135
113
  - test/integrations/rails_40_test.rb
136
114
  - test/test_helper.rb
137
115
  - test/units/.gitkeep
116
+ has_rdoc:
@@ -1,22 +0,0 @@
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", "3.0.11"
10
-
11
- group :assets do
12
- gem "compass", "~> 0.13.alpha.0"
13
- gem "compass-rails", :path=>".."
14
- gem "compass-blueprint"
15
- end
16
- group :test do
17
- gem "mocha"
18
- gem "appraisal", :git=>"https://github.com/scottdavis/appraisal.git"
19
- gem "rainbow"
20
- end
21
-
22
- gemspec :path=>"../"
@@ -1,51 +0,0 @@
1
- module CompassRails
2
- module Configuration
3
- module AssetPipeline
4
-
5
- def default_images_dir
6
- File.join("app", "assets", "images")
7
- end
8
-
9
- def default_fonts_dir
10
- File.join("app", "assets", "fonts")
11
- end
12
-
13
- def default_javascripts_dir
14
- File.join("app", "assets", "javascripts")
15
- end
16
-
17
- def default_css_dir
18
- File.join('public', CompassRails.prefix)
19
- end
20
-
21
- def default_http_path
22
- File.join(CompassRails.prefix)
23
- end
24
-
25
- def default_http_images_path
26
- "#{top_level.http_path}"
27
- end
28
-
29
- def default_http_javascripts_path
30
- "#{top_level.http_path}"
31
- end
32
-
33
- def default_http_fonts_path
34
- "#{top_level.http_path}"
35
- end
36
-
37
- def default_http_stylesheets_path
38
- "#{top_level.http_path}"
39
- end
40
-
41
- def default_preferred_syntax
42
- ::Rails.application.config.sass.preferred_syntax rescue nil
43
- end
44
-
45
- def default_sprite_load_path
46
- CompassRails.sprockets.paths
47
- end
48
-
49
- end
50
- end
51
- end
@@ -1,75 +0,0 @@
1
- module CompassRails
2
- module Configuration
3
- module Default
4
-
5
- def project_type_without_default
6
- :rails
7
- end
8
-
9
- def default_sass_dir
10
- File.join("app", "assets", "stylesheets")
11
- end
12
-
13
- def default_css_dir
14
- File.join("public", "stylesheets")
15
- end
16
-
17
- def default_images_dir
18
- File.join("public", "images")
19
- end
20
-
21
- def default_fonts_dir
22
- File.join("public", "fonts")
23
- end
24
-
25
- def default_javascripts_dir
26
- File.join("public", "javascripts")
27
- end
28
-
29
- def default_http_images_path
30
- # Relies on the fact that this will be loaded after the "normal"
31
- # defaults, so that method_missing finds http_root_relative
32
- http_root_relative "images"
33
- end
34
-
35
- def default_http_generated_images_path
36
- # Relies on the fact that this will be loaded after the "normal"
37
- # defaults, so that method_missing finds http_root_relative
38
- http_root_relative "images"
39
- end
40
-
41
- def default_http_javascripts_path
42
- http_root_relative "javascripts"
43
- end
44
-
45
- def default_http_fonts_path
46
- http_root_relative "fonts"
47
- end
48
-
49
- def default_http_stylesheets_path
50
- http_root_relative "stylesheets"
51
- end
52
-
53
- def default_extensions_dir
54
- File.join("vendor", "plugins", "compass_extensions")
55
- end
56
-
57
- def default_cache_dir
58
- File.join("tmp", "sass-cache")
59
- end
60
-
61
- def default_project_path
62
- project_path = CompassRails.root
63
- end
64
-
65
- def default_http_path
66
- "/" # XXX Where is/was this stored in the Rails config?
67
- end
68
-
69
- def default_environment
70
- CompassRails.env
71
- end
72
-
73
- end
74
- end
75
- end
@@ -1,48 +0,0 @@
1
- #3.0.11
2
- require 'compass'
3
- require 'rails'
4
-
5
- class Rails::Railtie::Configuration
6
- # Adds compass configuration accessor to the application configuration.
7
- #
8
- # If a configuration file for compass exists, it will be read in and
9
- # the project's configuration values will already be set on the config
10
- # object.
11
- #
12
- # For example:
13
- #
14
- # module MyApp
15
- # class Application < Rails::Application
16
- # config.compass.line_comments = !Rails.env.production?
17
- # config.compass.fonts_dir = "app/assets/fonts"
18
- # end
19
- # end
20
- #
21
- # It is suggested that you create a compass configuration file if you
22
- # want a quicker boot time when using the compass command line tool.
23
- #
24
- # For more information on available configuration options see:
25
- # http://compass-style.org/help/tutorials/configuration-reference/
26
- def compass
27
- @compass ||= begin
28
- data = if (config_file = Compass.detect_configuration_file) && (config_data = Compass.configuration_for(config_file))
29
- config_data
30
- else
31
- Compass::Configuration::Data.new("project")
32
- end
33
- data.project_type = :rails # Forcing this makes sure all the rails defaults will be loaded.
34
- data
35
- end
36
- end
37
- end
38
-
39
- module CompassRails
40
- class Railtie < Rails::Railtie
41
-
42
- initializer "compass.initialize_rails" do |app|
43
- # Configure compass for use within rails, and provide the project configuration
44
- # that came via the rails boot process.
45
- CompassRails.initialize!(app.config.compass)
46
- end
47
- end
48
- end
@@ -1,37 +0,0 @@
1
- require 'test_helper'
2
- class Rails3Test < Test::Unit::TestCase
3
- include CompassRails::Test::RailsHelpers
4
- RAILS_VERSION = RAILS_3
5
-
6
- def test_rails_app_created
7
- within_rails_app('test_railtie', RAILS_VERSION, false) do |project|
8
- assert project.boots?
9
- end
10
- end
11
-
12
- def test_installs_compass
13
- within_rails_app('test_railtie', RAILS_VERSION, false) do |project|
14
- project.run_compass('init')
15
- assert project.has_config?
16
- assert project.has_screen_file?
17
- assert project.has_compass_import?
18
- end
19
- end
20
-
21
- def test_compass_compile
22
- within_rails_app('test_railtie', RAILS_VERSION, false) do |project|
23
- project.run_compass('init')
24
- project.run_compass('compile')
25
- assert project.directory.join('public/stylesheets/screen.css').exist?
26
- end
27
- end
28
-
29
- def test_install_blueprint
30
- within_rails_app('test_railtie', RAILS_VERSION, false) do |project|
31
- project.run_compass('init')
32
- project.run_compass('install blueprint --force')
33
- assert project.directory.join('app/assets/stylesheets/partials').directory?
34
- end
35
- end
36
-
37
- end
@@ -1,37 +0,0 @@
1
- require 'test_helper'
2
- class Rails32WithoutPipelineTest < Test::Unit::TestCase
3
- include CompassRails::Test::RailsHelpers
4
- RAILS_VERSION = RAILS_3_2
5
-
6
- def test_rails_app_created
7
- within_rails_app('test_railtie', RAILS_VERSION, false) do |project|
8
- assert project.boots?
9
- end
10
- end
11
-
12
- def test_installs_compass
13
- within_rails_app('test_railtie', RAILS_VERSION, false) do |project|
14
- project.run_compass('init')
15
- assert project.has_config?
16
- assert project.has_screen_file?
17
- assert project.has_compass_import?
18
- end
19
- end
20
-
21
- def test_compass_compile
22
- within_rails_app('test_railtie', RAILS_VERSION, false) do |project|
23
- project.run_compass('init')
24
- project.run_compass('compile')
25
- assert project.directory.join('public/stylesheets/screen.css').exist?
26
- end
27
- end
28
-
29
- def test_install_blueprint
30
- within_rails_app('test_railtie', RAILS_VERSION, false) do |project|
31
- project.run_compass('init')
32
- project.run_compass('install blueprint --force')
33
- assert project.directory.join('app/assets/stylesheets/partials').directory?
34
- end
35
- end
36
-
37
- end