compass-rails 1.0.3 → 1.1.0.pre

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.
data/.gitignore CHANGED
@@ -3,6 +3,7 @@
3
3
  .bundle
4
4
  .config
5
5
  .yardoc
6
+ gemfiles/*.gemfile.lock
6
7
  Gemfile.lock
7
8
  InstalledFiles
8
9
  _yardoc
data/.travis.yml CHANGED
@@ -1,5 +1,4 @@
1
1
  rvm:
2
- - 1.8.7
3
- - 1.9.2
4
2
  - 1.9.3
3
+ - 2.0.0
5
4
  script: "bundle exec rake appraisal:install test"
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 'compass'
8
- gem 'compass-rails', :path => '.'
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 => 'git://github.com/scottdavis/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,12 +1,14 @@
1
1
  # CompassRails
2
2
 
3
+ [![Build Status](https://travis-ci.org/Compass/compass-rails.png?branch=stable)](https://travis-ci.org/Compass/compass-rails)
4
+
3
5
  Compass rails is an adapter for the [Compass Stylesheet Authoring
4
- Framework](http://compass-style.org) for [Ruby on Rails](http://http://rubyonrails.org/).
6
+ Framework](http://compass-style.org) for [Ruby on Rails](http://rubyonrails.org/).
5
7
 
6
8
  Since Compass v0.12, this adapter is the only way to install compass
7
9
  into your rails application.
8
10
 
9
- This adapter supports rails versions 2.3 and greater. Rails 2.3 and 3.0 users
11
+ This adapter supports rails versions 3.0 and greater. Rails 3.0 users
10
12
  please read the caveats below.
11
13
 
12
14
  ## Installation
@@ -168,35 +170,6 @@ to this:
168
170
  Bundler.require(:default, :assets, Rails.env) if defined?(Bundler)
169
171
  ```
170
172
 
171
- ## Rails 2.3 Caveats
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).
177
-
178
- After following the instructions there, if you want rails to compile
179
- your stylesheets (instead of using the compass watcher) you need
180
- edit `config/boot.rb` and change this:
181
-
182
- ```ruby
183
- Rails::Initializer.class_eval do
184
- def load_gems
185
- @bundler_loaded ||= Bundler.require :default, Rails.env
186
- end
187
- end
188
- ```
189
-
190
- To this:
191
-
192
- ```ruby
193
- Rails::Initializer.class_eval do
194
- def load_gems
195
- @bundler_loaded ||= Bundler.require :default, :assets, Rails.env
196
- end
197
- end
198
- ```
199
-
200
173
  ## Contributing
201
174
 
202
175
  1. Fork it
@@ -0,0 +1,11 @@
1
+ # Compass Rails
2
+
3
+ ## 2.0.alpha.0
4
+
5
+ * Removed rails 2.x support
6
+ * Added Alpha support for rails 4
7
+
8
+ ## 1.0.3
9
+
10
+ * StaticCompiler hack so sprite source files dont show up in manifest
11
+ * Compass version bump to 0.12.2
@@ -3,9 +3,9 @@ require File.expand_path('../lib/compass-rails/version', __FILE__)
3
3
 
4
4
  Gem::Specification.new do |gem|
5
5
  gem.authors = ["Scott Davis", "Chris Eppstein"]
6
- gem.email = ["jetviper21@gmail.com", "chris@eppsteins.net"]
7
- gem.description = %q{Integrate Compass into Rails 2.3 and up.}
8
- gem.summary = %q{Integrate Compass into Rails 2.3 and up.}
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) }
@@ -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=>"git://github.com/scottdavis/appraisal.git"
18
+ gem "appraisal", :git=>"https://github.com/scottdavis/appraisal.git"
18
19
  gem "rainbow"
19
20
  end
20
21
 
@@ -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=>"git://github.com/scottdavis/appraisal.git"
19
+ gem "appraisal", :git=>"https://github.com/scottdavis/appraisal.git"
19
20
  gem "rainbow"
20
21
  end
21
22
 
@@ -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=>"git://github.com/scottdavis/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", "2.3.14"
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=>"git://github.com/scottdavis/appraisal.git"
19
+ gem "appraisal", :git=>"https://github.com/scottdavis/appraisal.git"
18
20
  gem "rainbow"
19
21
  end
20
22
 
data/lib/compass-rails.rb CHANGED
@@ -4,6 +4,7 @@ require "compass-rails/configuration"
4
4
 
5
5
  module CompassRails
6
6
 
7
+ RAILS_4 = %r{^4.[0|1]}
7
8
  RAILS_32 = %r{^3.2}
8
9
  RAILS_31 = %r{^3.1}
9
10
  RAILS_23 = %r{^2.3}
@@ -12,6 +13,7 @@ module CompassRails
12
13
  extend self
13
14
 
14
15
  def load_rails
16
+ return true if rails_loaded?
15
17
  return if defined?(::Rails) && ::Rails.respond_to?(:application) && !::Rails.application.nil?
16
18
 
17
19
  rails_config_path = Dir.pwd
@@ -21,7 +23,7 @@ module CompassRails
21
23
  end
22
24
  #load the rails config
23
25
  require "#{rails_config_path}/config/application.rb"
24
- if rails31? || rails32?
26
+ if rails31? || rails32? || rails4?
25
27
  require 'sass-rails'
26
28
  require 'sprockets/railtie'
27
29
  require 'rails/engine'
@@ -85,21 +87,30 @@ module CompassRails
85
87
 
86
88
  def rails3?
87
89
  return false unless defined?(::Rails)
88
- rails_version =~ RAILS_3
90
+ version_match RAILS_3
89
91
  end
90
92
 
91
93
  def rails31?
92
94
  return false unless defined?(::Rails)
93
- rails_version =~ RAILS_31
95
+ version_match RAILS_31
94
96
  end
95
97
 
96
98
  def rails32?
97
99
  return false unless defined?(::Rails)
98
- rails_version =~ RAILS_32
100
+ version_match RAILS_32
99
101
  end
100
102
 
101
- def rails2?
102
- rails_version =~ RAILS_23
103
+ def rails4?
104
+ return false unless defined?(::Rails)
105
+ version_match RAILS_4
106
+ end
107
+
108
+ def version_match(version)
109
+ if (rails_version =~ version).nil?
110
+ return false
111
+ end
112
+
113
+ true
103
114
  end
104
115
 
105
116
  def booted!
@@ -111,10 +122,10 @@ module CompassRails
111
122
  end
112
123
 
113
124
  def configuration
114
- load_rails unless rails2?
125
+ load_rails
115
126
  config = Compass::Configuration::Data.new('rails')
116
127
  config.extend(Configuration::Default)
117
- if (rails31? || rails32?)
128
+ if (rails31? || rails32? || rails4?)
118
129
  if asset_pipeline_enabled?
119
130
  require "compass-rails/configuration/3_1"
120
131
  config.extend(Configuration::Rails3_1)
@@ -210,7 +221,11 @@ module CompassRails
210
221
  def asset_pipeline_enabled?
211
222
  return false unless rails_loaded?
212
223
  rails_config = ::Rails.application.config
213
- rails_config.respond_to?(:assets) && rails_config.assets.try(:enabled)
224
+ unless rails4?
225
+ rails_config.respond_to?(:assets) && rails_config.assets.try(:enabled)
226
+ else
227
+ rails_config.respond_to?(:assets)
228
+ end
214
229
  end
215
230
 
216
231
  private
@@ -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,6 +1,6 @@
1
1
  if CompassRails.rails31? || CompassRails.rails32?
2
- unless CompassRails.rails_loaded?
3
- CompassRails.load_rails
4
- end
2
+ CompassRails.load_rails
5
3
  require 'compass-rails/patches/importer'
6
- end
4
+ elsif CompassRails.rails4?
5
+ CompassRails.load_rails
6
+ end
@@ -2,6 +2,11 @@ require 'compass-rails/patches/static_compiler'
2
2
 
3
3
  module Sass::Script::Functions
4
4
  def generated_image_url(path, only_path = nil)
5
+ path = if Compass.configuration.generated_images_dir
6
+ full_path = File.join(Compass.configuration.generated_images_dir, path.value)
7
+ Sass::Script::String.new full_path.sub(File.join('app', 'assets', 'images'), "")[1..-1]
8
+ end
9
+
5
10
  asset_url(path, Sass::Script::String.new("image"))
6
11
  end
7
12
  end
@@ -9,7 +14,7 @@ end
9
14
 
10
15
  module Compass::RailsImageFunctionPatch
11
16
  private
12
-
17
+
13
18
  def image_path_for_size(image_file)
14
19
  begin
15
20
  file = ::Rails.application.assets.find_asset(image_file)
@@ -0,0 +1,30 @@
1
+ require 'compass-rails/patches/sass_importer'
2
+ require 'compass-rails/patches/sprite_importer'
3
+ module Sass::Script::Functions
4
+ def generated_image_url(path, only_path = nil)
5
+ asset_url(path)
6
+ end
7
+ end
8
+
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
+ module Sass::Script::Functions
24
+ include Compass::RailsImageFunctionPatch
25
+ end
26
+
27
+ # Wierd that this has to be re-included to pick up sub-modules. Ruby bug?
28
+ class Sass::Script::Functions::EvaluationContext
29
+ include Sass::Script::Functions
30
+ 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 Compass
5
- class SpriteImporter < Sass::Importers::Base
4
+ module CompassRails
5
+ class SpriteImporter < Compass::SpriteImporter
6
+ attr_reader :context, :root
6
7
 
7
- alias :old_find :find
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
- if pathname = resolve(file)
15
- context.depend_on(pathname)
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