compass-rails 2.0.2 → 2.0.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 35b96ecdbcc4b8f31aa688118b7bd77d6d5db397
4
- data.tar.gz: f3df7f5b7e2b6cece063d59ca2514c07bd09e138
3
+ metadata.gz: 9d3ea3227955811ea299dc8f915573ae37ee90f5
4
+ data.tar.gz: 24816da0d21eeef9ba77e4ddeb9e5d5deeda2f4a
5
5
  SHA512:
6
- metadata.gz: 9add8d36252e6f429c3585f2710bcdd69147bd373d3b97fb0988980e154137a3e3ef8545d4f0221580f7564183a8d209bdd7aa37e688e82f5550ff8ce627fb59
7
- data.tar.gz: 88057fec2aeeeb78d17f516645c6c608d590226e1901344637391f734c5eeec0c63ad47ec2f1eae6ac1a61aab567ab3029a53c953a9add9770ee75cf41a14bb9
6
+ metadata.gz: 5a20909a5341932b4e5b88067d3dcbba5eaec2e7e9ed5b4c166fc55772b73e377e5363e8e6f80fcfe25b1e9bd6a7613deb12973b5200b197a31ac072a11bd387
7
+ data.tar.gz: f85fc30a47c2a9f77774ecdab8bfab905acb73366d0f9e58f1485b8de03b7c488031bab426c08067795e358eeff5ddd163de6e4bff61029996693659ef541645
@@ -1,14 +1,19 @@
1
1
  language: ruby
2
+
3
+ sudo: false
4
+
2
5
  rvm:
3
6
  - 1.9.3
4
7
  - 2.0
5
8
  - 2.1
6
9
  - 2.2
7
10
  - jruby-head
11
+ - rbx-2.4.1
8
12
 
9
13
  matrix:
10
14
  allow_failures:
11
15
  - rvm: jruby-head
16
+ - rvm: rbx-2.4.1
12
17
 
13
18
  gemfile:
14
19
  - gemfiles/rails31.gemfile
@@ -1,5 +1,12 @@
1
1
  # Change log
2
2
 
3
+ ## 2.0.2 - 2015-01-03
4
+
5
+ - 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
6
+ - Support up to sass-rails 5.0.1. Issue #198
7
+ - Fix sass_importer patches having incorrect method signatures. Issue #195
8
+ - Fixed incorrect path generation for sprites in Rails 4. Issue #190
9
+
3
10
  ## 2.0.0 - 2014-07-10
4
11
  ### Added
5
12
  - Support for Rails 4.2
data/Gemfile CHANGED
@@ -3,13 +3,10 @@ source 'https://rubygems.org'
3
3
  # Specify your gem's dependencies in compass-rails.gemspec
4
4
  gemspec
5
5
 
6
- group :assets do
7
- gem 'compass-blueprint'
8
- end
9
-
10
6
  group :test do
11
7
  gem 'mocha'
12
- gem "appraisal"
8
+ gem 'appraisal'
9
+ gem 'minitest'
13
10
  end
14
11
 
15
12
  unless ENV["CI"]
data/README.md CHANGED
@@ -5,6 +5,7 @@
5
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
  [![Gem Version](https://badge.fury.io/rb/compass-rails.svg)](http://badge.fury.io/rb/compass-rails)
8
+ [![Coverage Status](https://coveralls.io/repos/Compass/compass-rails/badge.png)](https://coveralls.io/r/Compass/compass-rails)
8
9
 
9
10
  Compass rails is an adapter for the [Compass Stylesheet Authoring
10
11
  Framework](http://compass-style.org) for [Ruby on Rails](http://rubyonrails.org/).
@@ -53,13 +54,11 @@ Use `application.css` to require files that use compass features. Ex:
53
54
 
54
55
  ### Configuration
55
56
 
56
- If you have a compass configuration file (recommended) then you can
57
- use the [Compass configuration
57
+ Compass-rails is configured out of the box to work with Rails.
58
+
59
+ Advanced users can choose to add a `config/compass.rb` and take advantage of the [Compass configuration
58
60
  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.
61
+ as is.
63
62
 
64
63
  ### Installing Compass extensions
65
64
 
data/Rakefile CHANGED
@@ -2,7 +2,7 @@
2
2
  require 'rubygems'
3
3
  require 'bundler'
4
4
  Bundler.setup
5
- require 'rake/dsl_definition' rescue nil
5
+ require 'rake/dsl_definition'
6
6
 
7
7
  require "bundler/gem_tasks"
8
8
  require 'appraisal'
@@ -18,17 +18,8 @@ require 'fileutils'
18
18
  Rake::TestTask.new :test do |t|
19
19
  t.libs << 'lib'
20
20
  t.libs << 'test'
21
- test_files = FileList['test/**/*_test.rb']
21
+ test_files = FileList['test/**/*_{test,spec}.rb']
22
22
  test_files.exclude('test/rails/*', 'test/haml/*')
23
23
  t.test_files = test_files
24
24
  t.verbose = true
25
25
  end
26
-
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
@@ -16,6 +16,7 @@ end
16
16
  group :test do
17
17
  gem "mocha"
18
18
  gem "appraisal"
19
+ gem "minitest"
19
20
  end
20
21
 
21
22
  gemspec :path => "../"
@@ -16,6 +16,7 @@ end
16
16
  group :test do
17
17
  gem "mocha"
18
18
  gem "appraisal"
19
+ gem "minitest"
19
20
  end
20
21
 
21
22
  gemspec :path => "../"
@@ -16,6 +16,7 @@ end
16
16
  group :test do
17
17
  gem "mocha"
18
18
  gem "appraisal"
19
+ gem "minitest"
19
20
  end
20
21
 
21
22
  gemspec :path => "../"
@@ -16,6 +16,7 @@ end
16
16
  group :test do
17
17
  gem "mocha"
18
18
  gem "appraisal"
19
+ gem "minitest"
19
20
  end
20
21
 
21
22
  gemspec :path => "../"
@@ -10,27 +10,6 @@ module CompassRails
10
10
 
11
11
  extend self
12
12
 
13
- def load_rails
14
- return true if rails_loaded?
15
- return if defined?(::Rails) && ::Rails.respond_to?(:application) && !::Rails.application.nil?
16
-
17
- rails_path = Dir.pwd
18
- if File.exists?(File.join(rails_path, 'config', 'application.rb'))
19
- raise 'Rails application not found' if rails_config_path == '/'
20
- rails_config_path = File.join(rails_config_path, '..')
21
- #load the rails config
22
- require "#{rails_config_path}/config/application.rb"
23
- require 'sass-rails'
24
- require 'sprockets/railtie'
25
- @app ||= ::Rails.application.initialize!
26
- require 'rails/engine'
27
- return true
28
- end
29
-
30
- false
31
- end
32
-
33
-
34
13
  def setup_fake_rails_env_paths(sprockets_env)
35
14
  return unless rails_loaded?
36
15
  keys = ['app/assets', 'lib/assets', 'vendor/assets']
@@ -46,17 +25,14 @@ module CompassRails
46
25
  end
47
26
 
48
27
  def sass_config
49
- load_rails
50
28
  ::Rails.application.config.sass
51
29
  end
52
30
 
53
31
  def sprockets
54
- load_rails
55
32
  @sprockets ||= ::Rails.application.assets
56
33
  end
57
34
 
58
35
  def context
59
- load_rails
60
36
  @context ||= begin
61
37
  sprockets.version = ::Rails.env + "-#{sprockets.version}"
62
38
  setup_fake_rails_env_paths(sprockets)
@@ -70,10 +46,6 @@ module CompassRails
70
46
  end
71
47
  end
72
48
 
73
- def installer(*args)
74
- CompassRails::Installer.new(*args)
75
- end
76
-
77
49
  def rails_loaded?
78
50
  defined?(::Rails)
79
51
  end
@@ -100,23 +72,10 @@ module CompassRails
100
72
  end
101
73
 
102
74
  def version_match(version)
103
- if (rails_version =~ version).nil?
104
- return false
105
- end
106
-
107
- true
108
- end
109
-
110
- def booted!
111
- CompassRails.const_set(:BOOTED, true)
112
- end
113
-
114
- def booted?
115
- defined?(CompassRails::BOOTED) && CompassRails::BOOTED
75
+ !(rails_version =~ version).nil?
116
76
  end
117
77
 
118
78
  def configuration
119
- load_rails
120
79
  config = Compass::Configuration::Data.new('rails')
121
80
  config.extend(CompassRails::Configuration)
122
81
  config
@@ -126,50 +85,6 @@ module CompassRails
126
85
  ::Rails.application.config.assets.prefix
127
86
  end
128
87
 
129
- def env_production?
130
- if defined?(::Rails) && ::Rails.respond_to?(:env)
131
- ::Rails.env.production?
132
- elsif defined?(RAILS_ENV)
133
- RAILS_ENV == "production"
134
- end
135
- end
136
-
137
- def root
138
- @root ||= begin
139
- if defined?(::Rails) && ::Rails.respond_to?(:root)
140
- ::Rails.root
141
- elsif defined?(RAILS_ROOT)
142
- Pathname.new(RAILS_ROOT)
143
- else
144
- Pathname.new(Dir.pwd)
145
- end
146
- end
147
- end
148
-
149
- def check_for_double_boot!
150
- if booted?
151
- Compass::Util.compass_warn("Warning: Compass was booted twice. Compass-rails has got your back; please remove your compass initializer.")
152
- else
153
- booted!
154
- end
155
- end
156
-
157
- def sass_plugin_enabled?
158
- unless rails31?
159
- defined?(Sass::Plugin) && !Sass::Plugin.options[:never_update]
160
- end
161
- end
162
-
163
- # Rails projects without asset pipeline use this in their compass initializer.
164
- def initialize!(config = nil)
165
- check_for_double_boot!
166
- config ||= Compass.detect_configuration_file(root)
167
- Compass.add_project_configuration(config, :project_type => :rails)
168
- Compass.discover_extensions!
169
- Compass.configure_sass_plugin!
170
- Compass.handle_configuration_change! if sass_plugin_enabled?
171
- end
172
-
173
88
  def configure_rails!(app)
174
89
  return unless app.config.respond_to?(:sass)
175
90
  sass_config = app.config.sass
@@ -192,31 +107,6 @@ module CompassRails
192
107
  end
193
108
  end
194
109
 
195
- def boot_config
196
- config = begin
197
- if (config_file = Compass.detect_configuration_file) &&
198
- (config_data = Compass.configuration_for(config_file))
199
- config_data
200
- else
201
- Compass::Configuration::Data.new("compass_rails_boot")
202
- end
203
- end
204
-
205
- config.tap do |c|
206
- c.top_level.project_type = :rails
207
- end
208
- end
209
-
210
- def asset_pipeline_enabled?
211
- return false unless rails_loaded? && ::Rails.respond_to?(:application) && !::Rails.application.nil?
212
- rails_config = ::Rails.application.config
213
- if rails_config.respond_to?(:assets)
214
- rails_config.assets.enabled != false
215
- else
216
- false
217
- end
218
- end
219
-
220
110
  private
221
111
 
222
112
  # sets the sass config value only if the corresponding compass-based setting
@@ -231,10 +121,7 @@ end
231
121
 
232
122
  if defined?(::Rails)
233
123
  Compass::AppIntegration.register(:rails, "::CompassRails")
234
- Compass.add_configuration(CompassRails.boot_config)
235
-
236
124
  require "compass-rails/patches"
237
125
  require "compass-rails/railties"
238
- require "compass-rails/installer"
239
126
  end
240
127
 
@@ -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
@@ -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
+ ::Rails.application.assets.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(::Rails.application.assets, 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
@@ -34,7 +34,15 @@ klass.class_eval do
34
34
  engine = ::Sass::Engine.new(data, options)
35
35
 
36
36
  engine.dependencies.map do |dependency|
37
- context.depend_on(dependency.options[:filename])
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)
45
+ end
38
46
  end
39
47
 
40
48
  engine.render
@@ -57,17 +65,17 @@ klass.class_eval do
57
65
  self.class.parent::SassImporter.new(path)
58
66
  else
59
67
  self.class.parent::SassImporter.new(context, path)
60
- end
68
+ end
61
69
  end
62
70
 
63
71
  def sprockets_cache_store
64
72
  case Rails.application.config.assets.cache_store
65
- when :null_store
66
- Sprockets::Cache::NullStore.new
67
- when :memory_store, :mem_cache_store
68
- Sprockets::Cache::MemoryStore.new
69
- else
70
- Sprockets::Cache::FileStore.new(Dir::tmpdir)
73
+ when :null_store
74
+ Sprockets::Cache::NullStore.new
75
+ when :memory_store, :mem_cache_store
76
+ Sprockets::Cache::MemoryStore.new
77
+ else
78
+ Sprockets::Cache::FileStore.new(Dir::tmpdir)
71
79
  end
72
80
  end
73
81
  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
@@ -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
@@ -26,12 +23,6 @@ module CompassRails
26
23
  caller.grep(%r{/sprockets/rails/task.rb}).any? && #OMG HAX - check if we're being precompiled
27
24
  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
25
 
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
26
  pathname = Pathname.new(filename)
36
27
  logical_path = pathname.relative_path_from(Pathname.new(Compass.configuration.images_path))
37
28
  asset = Rails.application.assets.find_asset(logical_path)
@@ -1,5 +1,5 @@
1
1
  module CompassRails
2
2
  unless defined?(::CompassRails::VERSION)
3
- VERSION = "2.0.2"
3
+ VERSION = "2.0.3"
4
4
  end
5
5
  end
@@ -1,36 +1,37 @@
1
1
  require 'test_helper'
2
2
 
3
- class RailsTest < Test::Unit::TestCase
3
+ describe CompassRails do
4
4
  include CompassRails::Test::RailsHelpers
5
5
 
6
- def test_rails_app_created
6
+ it "compiles a basic compass stylesheet" do
7
7
  within_rails_app('test_railtie') do |project|
8
+ project.setup_asset_fixtures!
9
+
8
10
  assert project.boots?
9
- end
10
- end
11
11
 
12
- def test_rails_assets_precompile
13
- within_rails_app('test_railtie') do |project|
14
- rm(project.file("app/assets/javascripts/application.js"))
15
- rm(project.file("app/assets/stylesheets/application.css"))
16
- touch(project.file("app/assets/stylesheets/application.css.sass"))
17
- assert project.precompiles?, "Missing compiled css after assets:precompile"
18
- end
19
- end
12
+ project.precompile!
20
13
 
21
- def test_sass_preferred_syntax
22
- within_rails_app('test_railtie') do |project|
23
- assert_equal "scss", project.rails_property("sass.preferred_syntax")
24
- project.set_rails('sass.preferred_syntax', :sass)
25
- assert_equal "sass", project.rails_property("sass.preferred_syntax")
14
+ project.compiled_stylesheet 'public/assets/application*.css' do |css|
15
+ refute css.empty?
16
+ assert_match 'body container', css
17
+ assert_match "-webkit-linear-gradient", css
18
+ assert_match "-moz-border-radius", css
19
+ assert_match '.numbers-sprite-1', css
20
+ assert_match '.numbers-sprite-2', css
21
+ end
26
22
  end
27
23
  end
28
24
 
29
- def test_compass_css_dir
25
+ it "supports rails config arguments" do
30
26
  within_rails_app('test_railtie') do |project|
27
+ assert_equal "scss", project.rails_property("sass.preferred_syntax")
31
28
  assert_equal "public/assets", project.rails_property("compass.css_dir")
29
+
30
+ project.set_rails('sass.preferred_syntax', :sass)
32
31
  project.set_rails('compass.css_dir', "public/stylesheets")
32
+
33
+ assert_equal "sass", project.rails_property("sass.preferred_syntax")
33
34
  assert_equal "public/stylesheets", project.rails_property("compass.css_dir")
34
35
  end
35
- end
36
- end
36
+ end unless ENV['DEBUG_COMPILE']
37
+ end
@@ -0,0 +1,19 @@
1
+ // Import Compass
2
+ @import "compass";
3
+
4
+ // Glob import SCSS partials
5
+ @import "partials/*";
6
+
7
+ // Import Sprites and Inline them to save
8
+ $numbers-inline: true;
9
+ @import "numbers/sprite-*.png";
10
+ @include all-numbers-sprites;
11
+
12
+ // Try out some compass stuff
13
+ body{
14
+ @include background-image(linear-gradient(white, #aaaaaa));
15
+
16
+ container{
17
+ @include border-radius(4px, 4px);
18
+ }
19
+ }
@@ -0,0 +1,3 @@
1
+ .partial1 {
2
+ display: none;
3
+ }
@@ -0,0 +1,3 @@
1
+ .partial2{
2
+ display: block;
3
+ }
@@ -75,14 +75,10 @@ class CompassRails::Test::CommandRunner
75
75
  end
76
76
 
77
77
  def run
78
- announce
79
- with_clean_env do
80
- %x{#{@command}}
81
- end
78
+ with_clean_env { %x{#{@command}} }
82
79
  end
83
80
 
84
81
  def exec
85
- announce
86
82
  with_clean_env { Kernel.exec(@command) }
87
83
  end
88
84
 
@@ -96,15 +92,6 @@ class CompassRails::Test::CommandRunner
96
92
  restore_env
97
93
  end
98
94
 
99
- def announce
100
- return
101
- if @gemfile
102
- puts ">> BUNDLE_GEMFILE=#{@gemfile} #{@command}"
103
- else
104
- puts ">> #{@command}"
105
- end
106
- end
107
-
108
95
  def unset_bundler_env_vars
109
96
  BUNDLER_ENV_VARS.each do |key|
110
97
  @original_env[key] = ENV[key]
@@ -3,23 +3,7 @@ module CompassRails
3
3
  module FileHelper
4
4
  include DebugHelper
5
5
 
6
- def mkdir_p(dir)
7
- debug "Creating Directory: #{dir}"
8
- ::FileUtils.mkdir_p dir
9
- assert File.directory?(dir), "mkdir_p: #{dir} failed"
10
- end
11
-
12
- def rm(path)
13
- debug "Removing: #{path}"
14
- ::FileUtils.rm(path)
15
- assert !File.file?(path), "rm: #{path} failed"
16
- end
17
-
18
- def rm_rf(path)
19
- debug "Removing: #{path}"
20
- ::FileUtils.rm_rf(path)
21
- assert !File.directory?(path), "rm_rf: #{path} failed"
22
- end
6
+ delegate :mkdir_p, :rm, :rm_rf, :cp_r, :touch, to: ::FileUtils
23
7
 
24
8
  def cd(path, &block)
25
9
  debug "Entering: #{path}"
@@ -32,11 +16,6 @@ module CompassRails
32
16
  File.open(file_name, 'w') { |file| file << content }
33
17
  end
34
18
 
35
- def touch(file)
36
- debug "Touching File: #{file}"
37
- ::FileUtils.touch(file)
38
- end
39
-
40
19
  def inject_into_file(file_name, replacement, position, anchor)
41
20
  case position
42
21
  when :after
@@ -25,39 +25,37 @@ module CompassRails
25
25
  RAILS_3_1 => GEMFILES_DIR.join("rails31.gemfile").to_s
26
26
  }
27
27
 
28
- GENERATOR_OPTIONS = Hash.new(['-q', '-G', '-O', '--skip-bundle'])
28
+ GENERATOR_OPTIONS = ['-q', '-G', '-O', '--skip-bundle']
29
29
 
30
- GENERATOR_COMMAND = Hash.new("new")
31
-
32
- def rails_command(options)
33
- debug "Running Rails command with: rails #{options.join(' ')}"
34
- run_command("rails #{options.join(' ')}", GEMFILES[rails_version])
35
- end
30
+ def rails_command(options)
31
+ debug cmd = "rails #{options.join(' ')}"
32
+ run_command(cmd, GEMFILES[rails_version])
33
+ end
36
34
 
37
- def rails_version
38
- @rails_version ||= VERSION_LOOKUP.detect { |version, regex| CompassRails.version_match(regex) }.first
39
- end
35
+ def rails_version
36
+ @rails_version ||= VERSION_LOOKUP.detect { |version, regex| CompassRails.version_match(regex) }.first
37
+ end
40
38
 
41
- # Generate a rails application without polluting our current set of requires
42
- # with the rails libraries. This will allow testing against multiple versions of rails
43
- # by manipulating the load path.
44
- def generate_rails_app(name, options=[])
45
- options += GENERATOR_OPTIONS[rails_version]
46
- rails_command([GENERATOR_COMMAND[rails_version], name, *options])
47
- end
39
+ # Generate a rails application without polluting our current set of requires
40
+ # with the rails libraries. This will allow testing against multiple versions of rails
41
+ # by manipulating the load path.
42
+ def generate_rails_app(name, options = [])
43
+ options += GENERATOR_OPTIONS
44
+ rails_command(['new', name, *options])
45
+ end
48
46
 
49
- def within_rails_app(named, asset_pipeline_enabled = true, &block)
50
- dir = "#{named}-#{rails_version}"
51
- rm_rf File.join(WORKING_DIR, dir)
52
- mkdir_p WORKING_DIR
53
- cd(WORKING_DIR) do
54
- generate_rails_app(dir, asset_pipeline_enabled ? [] : ["-S"])
55
- cd(dir) do
56
- yield RailsProject.new(File.join(WORKING_DIR, dir), rails_version, asset_pipeline_enabled)
47
+ def within_rails_app(named, &block)
48
+ dir = "#{named}-#{rails_version}"
49
+ rm_rf File.join(WORKING_DIR, dir)
50
+ mkdir_p WORKING_DIR
51
+ cd(WORKING_DIR) do
52
+ generate_rails_app(dir, [])
53
+ cd(dir) do
54
+ yield RailsProject.new(File.join(WORKING_DIR, dir), rails_version)
55
+ end
57
56
  end
57
+ rm_rf File.join(WORKING_DIR, dir) unless ENV['DEBUG_COMPILE']
58
58
  end
59
- rm_rf File.join(WORKING_DIR, dir)
60
- end
61
59
 
62
60
  end
63
61
  end
@@ -7,20 +7,13 @@ module CompassRails
7
7
  include RailsHelpers
8
8
  include Kernal::Captures
9
9
 
10
-
11
- GEMFILE = 'Gemfile'
12
- GEMFILE_LOCK = 'Gemfile.lock'
13
- ENVIRONMENT = 'config/environment.rb'
14
- COMPASS_CONFIG = 'config/compass.rb'
15
10
  APPLICATION_FILE = 'config/application.rb'
16
- BOOT_FILE = 'config/boot.rb'
17
11
 
18
- attr_reader :directory, :version, :asset_pipeline_enabled
12
+ attr_reader :directory, :version
19
13
 
20
- def initialize(directory, version, asset_pipeline_enabled = true)
14
+ def initialize(directory, version)
21
15
  @directory = Pathname.new(directory)
22
16
  @version = version
23
- @asset_pipeline_enabled = asset_pipeline_enabled
24
17
  end
25
18
 
26
19
  ## FILE METHODS
@@ -37,61 +30,40 @@ module CompassRails
37
30
  directory.join(path)
38
31
  end
39
32
 
40
- def has_file?(file)
41
- File.exist? directory.join(file)
42
- end
43
-
44
- def screen_file
45
- if asset_pipeline_enabled
46
- return directory.join('app', 'assets', 'stylesheets', 'screen.css.scss')
47
- else
48
- return directory.join('app', 'assets', 'stylesheets','screen.scss')
49
- end
50
- end
51
-
52
- def has_screen_file?
53
- screen_file.exist?
54
- end
55
-
56
- def has_compass_import?
57
- File.read(screen_file).include?("compass/reset")
58
- end
59
-
60
- def has_config?
61
- directory.join('config', 'compass.rb').exist?
62
- end
63
-
64
33
  # RAILS METHODS
65
34
 
66
- def rails3?
67
- directory.join(APPLICATION_FILE).exist?
68
- end
69
-
70
35
  def boots?
71
36
  rails_property("compass.project_type") == "rails"
72
37
  end
73
38
 
74
- def precompiles?
39
+ def precompile!
75
40
  run_command("rake assets:precompile", GEMFILES[version])
76
- !Dir[file("public/assets/application*.css")].empty?
77
41
  end
78
42
 
79
- def rails_property(key)
80
- rails_command(['runner', "'puts Rails.application.config.#{key}'"]).chomp
43
+ def setup_asset_fixtures!
44
+ rm_rf file("app/assets")
45
+ cp_r CompassRails::Test.root.join('test', 'fixtures', 'assets'), file("app")
81
46
  end
82
47
 
83
- # COMPASS METHODS
48
+ def precompiled?(path)
49
+ !Dir[asset_path(path)].empty?
50
+ end
84
51
 
85
- def run_compass(command)
86
- run_command("compass #{command}", GEMFILES[version])
52
+ def compiled_stylesheet(path, &block)
53
+ File.open(asset_path(path)).read.tap do |css|
54
+ debug(css)
55
+ yield css if block_given?
56
+ end
87
57
  end
88
58
 
89
- def set_compass(property, value)
90
- file = directory.join(COMPASS_CONFIG)
91
- unless file.exist?
92
- touch file
59
+ def asset_path(path_pattern)
60
+ Dir[file(path_pattern)].first.tap do |asset|
61
+ raise 'Asset not found' if asset.nil?
93
62
  end
94
- inject_at_bottom(file, "#{property} = '#{value}'")
63
+ end
64
+
65
+ def rails_property(key)
66
+ rails_command(['runner', "'puts Rails.application.config.#{key}'"]).chomp
95
67
  end
96
68
 
97
69
  def set_rails(property, value)
@@ -99,20 +71,6 @@ module CompassRails
99
71
  inject_into_file(directory.join(APPLICATION_FILE), value, :after, 'class Application < Rails::Application')
100
72
  end
101
73
 
102
- private
103
-
104
- ## GEM METHODS
105
-
106
- def add_to_gemfile(name, requirements)
107
- gemfile = directory.join(GEMFILE)
108
- debug "Adding gem #{name} to file: #{gemfile}"
109
- if requirements
110
- gem_string = " gem '#{name}', #{requirements}\n"
111
- else
112
- gem_string = " gem '#{name}'\n"
113
- end
114
- inject_at_bottom(gemfile, gem_string)
115
- end
116
74
  end
117
75
  end
118
76
  end
@@ -1,9 +1,14 @@
1
- require 'test/unit'
1
+ require 'minitest/autorun'
2
2
  require 'compass-rails'
3
+ require 'active_support/all'
3
4
 
4
5
  module CompassRails
5
6
  module Test
6
7
  ROOT_PATH = File.expand_path('../../', __FILE__)
8
+
9
+ def self.root
10
+ Pathname.new(ROOT_PATH)
11
+ end
7
12
  end
8
13
  end
9
14
 
@@ -11,4 +16,5 @@ end
11
16
  require File.join(File.expand_path('../', __FILE__), 'helpers', "#{helper}_helper")
12
17
  end
13
18
 
14
- require File.join(File.expand_path('../', __FILE__), 'helpers', "rails_project")
19
+ require File.join(File.expand_path('../', __FILE__), 'helpers', "rails_project")
20
+
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: 2.0.2
4
+ version: 2.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Scott Davis
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2015-01-04 00:00:00.000000000 Z
13
+ date: 2015-01-07 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: compass
@@ -79,7 +79,6 @@ files:
79
79
  - gemfiles/rails42.gemfile
80
80
  - lib/compass-rails.rb
81
81
  - lib/compass-rails/configuration.rb
82
- - lib/compass-rails/installer.rb
83
82
  - lib/compass-rails/patches.rb
84
83
  - lib/compass-rails/patches/3_1.rb
85
84
  - lib/compass-rails/patches/4_0.rb
@@ -93,16 +92,19 @@ files:
93
92
  - lib/compass-rails/railties/4_0.rb
94
93
  - lib/compass-rails/version.rb
95
94
  - sache.json
95
+ - test/compass_rails_spec.rb
96
96
  - test/fixtures/.gitkeep
97
+ - test/fixtures/assets/images/numbers/sprite-1.png
98
+ - test/fixtures/assets/images/numbers/sprite-2.png
99
+ - test/fixtures/assets/stylesheets/application.css.scss
100
+ - test/fixtures/assets/stylesheets/partials/_partial_1.scss
101
+ - test/fixtures/assets/stylesheets/partials/_partial_2.scss
97
102
  - test/helpers/command_helper.rb
98
103
  - test/helpers/debug_helper.rb
99
104
  - test/helpers/file_helper.rb
100
105
  - test/helpers/rails_helper.rb
101
106
  - test/helpers/rails_project.rb
102
- - test/integrations/.gitkeep
103
- - test/integrations/rails_test.rb
104
107
  - test/test_helper.rb
105
- - test/units/.gitkeep
106
108
  homepage: https://github.com/Compass/compass-rails
107
109
  licenses:
108
110
  - MIT
@@ -128,14 +130,17 @@ signing_key:
128
130
  specification_version: 4
129
131
  summary: Integrate Compass into Rails 3.0 and up.
130
132
  test_files:
133
+ - test/compass_rails_spec.rb
131
134
  - test/fixtures/.gitkeep
135
+ - test/fixtures/assets/images/numbers/sprite-1.png
136
+ - test/fixtures/assets/images/numbers/sprite-2.png
137
+ - test/fixtures/assets/stylesheets/application.css.scss
138
+ - test/fixtures/assets/stylesheets/partials/_partial_1.scss
139
+ - test/fixtures/assets/stylesheets/partials/_partial_2.scss
132
140
  - test/helpers/command_helper.rb
133
141
  - test/helpers/debug_helper.rb
134
142
  - test/helpers/file_helper.rb
135
143
  - test/helpers/rails_helper.rb
136
144
  - test/helpers/rails_project.rb
137
- - test/integrations/.gitkeep
138
- - test/integrations/rails_test.rb
139
145
  - test/test_helper.rb
140
- - test/units/.gitkeep
141
146
  has_rdoc:
@@ -1,30 +0,0 @@
1
- module CompassRails
2
- class Installer < Compass::Installers::ManifestInstaller
3
-
4
- SASS_FILE_REGEX = %r{(.*)(?:\.css)?\.(sass|scss)}
5
-
6
- def completed_configuration
7
- @completed_configuration ||= CompassRails.configuration
8
- end
9
-
10
- def install_stylesheet(from, to, options)
11
- if CompassRails.rails_loaded? && CompassRails.asset_pipeline_enabled?
12
- _, name, ext = SASS_FILE_REGEX.match(to).to_a
13
- to = "#{name}.css.#{ext}"
14
- end
15
- super(from, to, options)
16
- end
17
-
18
- def write_configuration_files
19
- config_file = CompassRails.root.join('config', 'compass.rb')
20
- unless config_file.exist?
21
- write_file config_file.to_s, CompassRails.configuration.serialize
22
- end
23
- end
24
-
25
- def prepare
26
- write_configuration_files
27
- end
28
-
29
- end
30
- end
File without changes
File without changes