compass-rails 2.0.0 → 3.1.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 +4 -4
- data/.gitignore +1 -0
- data/.travis.yml +34 -4
- data/Appraisals +30 -0
- data/CHANGELOG.md +82 -0
- data/Gemfile +3 -8
- data/README.md +13 -11
- data/Rakefile +4 -23
- data/compass-rails.gemspec +3 -2
- data/gemfiles/rails31.gemfile +6 -10
- data/gemfiles/rails32.gemfile +6 -10
- data/gemfiles/rails40.gemfile +6 -10
- data/gemfiles/rails42.gemfile +19 -0
- data/gemfiles/rails50.gemfile +19 -0
- data/gemfiles/rails51.gemfile +19 -0
- data/gemfiles/rails_edge.gemfile +22 -0
- data/lib/compass-rails/patches/3_1.rb +3 -12
- data/lib/compass-rails/patches/4_0.rb +23 -29
- data/lib/compass-rails/patches/compass.rb +3 -3
- data/lib/compass-rails/patches/importer.rb +10 -12
- data/lib/compass-rails/patches/sass_importer.rb +67 -7
- data/lib/compass-rails/patches/sprite_importer.rb +4 -4
- data/lib/compass-rails/patches.rb +0 -3
- data/lib/compass-rails/railties/3_1.rb +5 -12
- data/lib/compass-rails/railties/4_0.rb +11 -9
- data/lib/compass-rails/railties.rb +1 -3
- data/lib/compass-rails/version.rb +1 -3
- data/lib/compass-rails.rb +16 -125
- data/test/compass_rails_spec.rb +58 -0
- data/test/fixtures/assets/images/letters/a.png +0 -0
- data/test/fixtures/assets/images/letters/b.png +0 -0
- data/test/fixtures/assets/images/numbers/sprite-1.png +0 -0
- data/test/fixtures/assets/images/numbers/sprite-2.png +0 -0
- data/test/fixtures/assets/stylesheets/application.css.scss +23 -0
- data/test/fixtures/assets/stylesheets/partials/_partial_1.scss +3 -0
- data/test/fixtures/assets/stylesheets/partials/_partial_2.scss +3 -0
- data/test/helpers/command_helper.rb +2 -15
- data/test/helpers/debug_helper.rb +1 -1
- data/test/helpers/file_helper.rb +2 -17
- data/test/helpers/rails_helper.rb +43 -32
- data/test/helpers/rails_project.rb +30 -70
- data/test/test_helper.rb +8 -3
- metadata +55 -19
- data/changelog.markdown +0 -11
- data/lib/compass-rails/installer.rb +0 -30
- data/test/integrations/.gitkeep +0 -0
- data/test/integrations/rails_31_test.rb +0 -46
- data/test/integrations/rails_32_test.rb +0 -46
- data/test/integrations/rails_40_test.rb +0 -46
- data/test/units/.gitkeep +0 -0
|
@@ -7,18 +7,23 @@ end
|
|
|
7
7
|
klass.class_eval do
|
|
8
8
|
def evaluate(context, locals, &block)
|
|
9
9
|
# Use custom importer that knows about Sprockets Caching
|
|
10
|
-
cache_store =
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
10
|
+
cache_store =
|
|
11
|
+
if defined?(Sprockets::SassProcessor::CacheStore)
|
|
12
|
+
Sprockets::SassProcessor::CacheStore.new(sprockets_cache_store, context.environment)
|
|
13
|
+
else
|
|
14
|
+
Sprockets::SassCacheStore.new(context.environment)
|
|
15
|
+
end
|
|
14
16
|
|
|
17
|
+
paths = context.environment.paths.map { |path| CompassRails::SpriteImporter.new(path) }
|
|
18
|
+
paths += context.environment.paths.map { |path| sass_importer(context, path) }
|
|
19
|
+
paths += ::Rails.application.config.sass.load_paths
|
|
15
20
|
|
|
16
21
|
options = CompassRails.sass_config.merge( {
|
|
17
22
|
:filename => eval_file,
|
|
18
23
|
:line => line,
|
|
19
24
|
:syntax => syntax,
|
|
20
25
|
:cache_store => cache_store,
|
|
21
|
-
:importer =>
|
|
26
|
+
:importer => sass_importer(context, context.pathname),
|
|
22
27
|
:load_paths => paths,
|
|
23
28
|
:sprockets => {
|
|
24
29
|
:context => context,
|
|
@@ -26,11 +31,66 @@ klass.class_eval do
|
|
|
26
31
|
}
|
|
27
32
|
})
|
|
28
33
|
|
|
29
|
-
::Sass::Engine.new(data, options)
|
|
34
|
+
engine = ::Sass::Engine.new(data, options)
|
|
35
|
+
|
|
36
|
+
engine.dependencies.map do |dependency|
|
|
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) if File.exist?(filename)
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
engine.render
|
|
30
49
|
rescue ::Sass::SyntaxError => e
|
|
31
50
|
# Annotates exception message with parse line number
|
|
32
51
|
context.__LINE__ = e.sass_backtrace.first[:line]
|
|
33
52
|
raise e
|
|
34
53
|
end
|
|
35
|
-
end
|
|
36
54
|
|
|
55
|
+
private
|
|
56
|
+
|
|
57
|
+
def sass_importer_artiy
|
|
58
|
+
@sass_importer_artiy ||= sass_importer_class.instance_method(:initialize).arity
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
def sass_importer(context, path)
|
|
62
|
+
case sass_importer_artiy.abs
|
|
63
|
+
when 1
|
|
64
|
+
sass_importer_class.new(path)
|
|
65
|
+
else
|
|
66
|
+
sass_importer_class.new(context, path)
|
|
67
|
+
end
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
# if using haml-rails, self.class.parent = Haml::Filters (which doesn't have an implementation)
|
|
71
|
+
def sass_importer_class
|
|
72
|
+
@sass_importer_class ||= if defined?(self.class.parent::SassImporter)
|
|
73
|
+
self.class.parent::SassImporter
|
|
74
|
+
elsif defined?(Sass::Rails::SassTemplate)
|
|
75
|
+
Sass::Rails::SassImporter
|
|
76
|
+
else
|
|
77
|
+
Sprockets::SassImporter
|
|
78
|
+
end
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
def sprockets_cache_store
|
|
82
|
+
cache =
|
|
83
|
+
case Rails.application.config.assets.cache_store
|
|
84
|
+
when :null_store
|
|
85
|
+
Sprockets::Cache::NullStore.new
|
|
86
|
+
when :memory_store, :mem_cache_store
|
|
87
|
+
Sprockets::Cache::MemoryStore.new
|
|
88
|
+
else
|
|
89
|
+
path = "#{Rails.application.config.root}/tmp/cache/assets/#{Rails.env}"
|
|
90
|
+
|
|
91
|
+
Sprockets::Cache::FileStore.new(path)
|
|
92
|
+
end
|
|
93
|
+
|
|
94
|
+
Sprockets::Cache.new(cache, Rails.logger)
|
|
95
|
+
end
|
|
96
|
+
end
|
|
@@ -3,19 +3,19 @@ require 'compass/sprite_importer'
|
|
|
3
3
|
|
|
4
4
|
module CompassRails
|
|
5
5
|
class SpriteImporter < Compass::SpriteImporter
|
|
6
|
-
attr_reader :
|
|
6
|
+
attr_reader :root
|
|
7
7
|
|
|
8
|
-
def initialize(
|
|
9
|
-
@context = context
|
|
8
|
+
def initialize(root)
|
|
10
9
|
@root = root
|
|
11
10
|
end
|
|
12
11
|
|
|
13
12
|
def find(uri, options)
|
|
14
13
|
if old = super(uri, options)
|
|
14
|
+
context = options[:sprockets][:context]
|
|
15
15
|
self.class.files(uri).each do |file|
|
|
16
16
|
relative_path = Pathname.new(file).relative_path_from(Pathname.new(root))
|
|
17
17
|
begin
|
|
18
|
-
pathname = context.resolve(relative_path)
|
|
18
|
+
pathname = context.resolve(relative_path.to_s)
|
|
19
19
|
context.depend_on_asset(pathname)
|
|
20
20
|
rescue Sprockets::FileNotFound
|
|
21
21
|
|
|
@@ -3,16 +3,9 @@ module CompassRails
|
|
|
3
3
|
|
|
4
4
|
initializer "compass.initialize_rails", :group => :all do |app|
|
|
5
5
|
require 'compass'
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
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
|
|
@@ -32,11 +25,11 @@ module CompassRails
|
|
|
32
25
|
|
|
33
26
|
# Clear entries in Hike::Index for this sprite's directory.
|
|
34
27
|
# This makes sure the asset can be found by find_assets
|
|
35
|
-
|
|
28
|
+
CompassRails.sprockets.send(:trail).instance_variable_get(:@entries).delete(File.dirname(filename))
|
|
36
29
|
|
|
37
30
|
pathname = Pathname.new(filename)
|
|
38
31
|
logical_path = pathname.relative_path_from(Pathname.new(Compass.configuration.images_path))
|
|
39
|
-
asset =
|
|
32
|
+
asset = CompassRails.sprockets.find_asset(logical_path)
|
|
40
33
|
target = File.join(Rails.public_path, Rails.application.config.assets.prefix, asset.digest_path)
|
|
41
34
|
|
|
42
35
|
# Adds the asset to the manifest file.
|
|
@@ -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
|
|
@@ -28,19 +25,24 @@ module CompassRails
|
|
|
28
25
|
|
|
29
26
|
# Clear entries in Hike::Index for this sprite's directory.
|
|
30
27
|
# This makes sure the asset can be found by find_assets
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
28
|
+
if CompassRails.sprockets.respond_to?(:trail, true)
|
|
29
|
+
index = CompassRails.sprockets.send(:trail).index
|
|
30
|
+
else
|
|
31
|
+
index = CompassRails.sprockets.index
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
index.instance_variable_get(:@entries).delete(File.dirname(filename))
|
|
35
|
+
index.instance_variable_get(:@stats).delete(filename)
|
|
34
36
|
|
|
35
37
|
pathname = Pathname.new(filename)
|
|
36
|
-
logical_path = pathname.relative_path_from(Pathname.new(Compass.configuration.images_path))
|
|
37
|
-
asset =
|
|
38
|
+
logical_path = pathname.relative_path_from(Pathname.new(Compass.configuration.images_path)).to_s
|
|
39
|
+
asset = CompassRails.sprockets.find_asset(logical_path)
|
|
38
40
|
target = File.join(Rails.public_path, Rails.application.config.assets.prefix, asset.digest_path)
|
|
39
41
|
|
|
40
42
|
# Adds the asset to the manifest file.
|
|
41
43
|
|
|
42
44
|
manifest = ActionView::Base.assets_manifest
|
|
43
|
-
manifest.assets[logical_path
|
|
45
|
+
manifest.assets[logical_path] = asset.digest_path
|
|
44
46
|
|
|
45
47
|
|
|
46
48
|
# Adds the fingerprinted asset to the public directory
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
if defined?(::Rails)
|
|
2
2
|
if CompassRails.rails31? || CompassRails.rails32?
|
|
3
3
|
require "compass-rails/railties/3_1"
|
|
4
|
-
elsif CompassRails.rails4?
|
|
5
|
-
require "compass-rails/railties/4_0"
|
|
6
4
|
else
|
|
7
|
-
|
|
5
|
+
require "compass-rails/railties/4_0"
|
|
8
6
|
end
|
|
9
7
|
end
|
data/lib/compass-rails.rb
CHANGED
|
@@ -4,60 +4,45 @@ require "compass-rails/configuration"
|
|
|
4
4
|
|
|
5
5
|
module CompassRails
|
|
6
6
|
|
|
7
|
-
RAILS_4 = %r{^4.[0|1|2]}
|
|
8
7
|
RAILS_32 = %r{^3.2}
|
|
9
8
|
RAILS_31 = %r{^3.1}
|
|
10
9
|
|
|
11
10
|
extend self
|
|
12
11
|
|
|
13
|
-
def
|
|
14
|
-
return
|
|
15
|
-
return if defined?(::Rails) && ::Rails.respond_to?(:application) && !::Rails.application.nil?
|
|
12
|
+
def setup_fake_rails_env_paths(sprockets_env)
|
|
13
|
+
return unless rails_loaded?
|
|
16
14
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
15
|
+
if sprockets_env.respond_to?(:trail, true)
|
|
16
|
+
sprockets_trail = sprockets_env.send(:trail)
|
|
17
|
+
else
|
|
18
|
+
sprockets_trail = sprockets_env.index
|
|
21
19
|
end
|
|
22
|
-
#load the rails config
|
|
23
|
-
require "#{rails_config_path}/config/application.rb"
|
|
24
|
-
require 'sass-rails'
|
|
25
|
-
require 'sprockets/railtie'
|
|
26
|
-
require 'rails/engine'
|
|
27
|
-
@app ||= ::Rails.application.initialize!
|
|
28
|
-
end
|
|
29
|
-
|
|
30
20
|
|
|
31
|
-
def setup_fake_rails_env_paths(sprockets_env)
|
|
32
|
-
return unless rails_loaded?
|
|
33
21
|
keys = ['app/assets', 'lib/assets', 'vendor/assets']
|
|
34
22
|
local = keys.map {|path| ::Rails.root.join(path) }.map { |path| [File.join(path, 'images'), File.join(path, 'stylesheets')] }.flatten!
|
|
35
|
-
|
|
23
|
+
sprockets_trail.paths.unshift(*local)
|
|
36
24
|
paths = []
|
|
37
25
|
::Rails::Engine.subclasses.each do |subclass|
|
|
38
26
|
paths = subclass.paths
|
|
39
27
|
keys.each do |key|
|
|
40
|
-
|
|
28
|
+
sprockets_trail.paths.unshift(*paths[key].existent_directories)
|
|
41
29
|
end
|
|
42
30
|
end
|
|
43
31
|
end
|
|
44
32
|
|
|
45
33
|
def sass_config
|
|
46
|
-
load_rails
|
|
47
34
|
::Rails.application.config.sass
|
|
48
35
|
end
|
|
49
36
|
|
|
50
37
|
def sprockets
|
|
51
|
-
|
|
52
|
-
@sprockets ||= ::Rails.application.assets
|
|
38
|
+
@sprockets ||= Rails.application.assets || ::Sprockets::Railtie.build_environment(Rails.application)
|
|
53
39
|
end
|
|
54
40
|
|
|
55
41
|
def context
|
|
56
|
-
load_rails
|
|
57
42
|
@context ||= begin
|
|
58
43
|
sprockets.version = ::Rails.env + "-#{sprockets.version}"
|
|
59
44
|
setup_fake_rails_env_paths(sprockets)
|
|
60
|
-
context = ::
|
|
45
|
+
context = ::CompassRails.sprockets.context_class
|
|
61
46
|
context.extend(::Sprockets::Helpers::IsolatedHelper)
|
|
62
47
|
context.extend(::Sprockets::Helpers::RailsHelper)
|
|
63
48
|
context.extend(::Sass::Rails::Railtie::SassContext)
|
|
@@ -67,10 +52,6 @@ module CompassRails
|
|
|
67
52
|
end
|
|
68
53
|
end
|
|
69
54
|
|
|
70
|
-
def installer(*args)
|
|
71
|
-
CompassRails::Installer.new(*args)
|
|
72
|
-
end
|
|
73
|
-
|
|
74
55
|
def rails_loaded?
|
|
75
56
|
defined?(::Rails)
|
|
76
57
|
end
|
|
@@ -91,29 +72,11 @@ module CompassRails
|
|
|
91
72
|
version_match RAILS_32
|
|
92
73
|
end
|
|
93
74
|
|
|
94
|
-
def rails4?
|
|
95
|
-
return false unless defined?(::Rails)
|
|
96
|
-
version_match RAILS_4
|
|
97
|
-
end
|
|
98
|
-
|
|
99
75
|
def version_match(version)
|
|
100
|
-
|
|
101
|
-
return false
|
|
102
|
-
end
|
|
103
|
-
|
|
104
|
-
true
|
|
105
|
-
end
|
|
106
|
-
|
|
107
|
-
def booted!
|
|
108
|
-
CompassRails.const_set(:BOOTED, true)
|
|
109
|
-
end
|
|
110
|
-
|
|
111
|
-
def booted?
|
|
112
|
-
defined?(CompassRails::BOOTED) && CompassRails::BOOTED
|
|
76
|
+
!(rails_version =~ version).nil?
|
|
113
77
|
end
|
|
114
78
|
|
|
115
79
|
def configuration
|
|
116
|
-
load_rails
|
|
117
80
|
config = Compass::Configuration::Data.new('rails')
|
|
118
81
|
config.extend(CompassRails::Configuration)
|
|
119
82
|
config
|
|
@@ -123,50 +86,6 @@ module CompassRails
|
|
|
123
86
|
::Rails.application.config.assets.prefix
|
|
124
87
|
end
|
|
125
88
|
|
|
126
|
-
def env_production?
|
|
127
|
-
if defined?(::Rails) && ::Rails.respond_to?(:env)
|
|
128
|
-
::Rails.env.production?
|
|
129
|
-
elsif defined?(RAILS_ENV)
|
|
130
|
-
RAILS_ENV == "production"
|
|
131
|
-
end
|
|
132
|
-
end
|
|
133
|
-
|
|
134
|
-
def root
|
|
135
|
-
@root ||= begin
|
|
136
|
-
if defined?(::Rails) && ::Rails.respond_to?(:root)
|
|
137
|
-
::Rails.root
|
|
138
|
-
elsif defined?(RAILS_ROOT)
|
|
139
|
-
Pathname.new(RAILS_ROOT)
|
|
140
|
-
else
|
|
141
|
-
Pathname.new(Dir.pwd)
|
|
142
|
-
end
|
|
143
|
-
end
|
|
144
|
-
end
|
|
145
|
-
|
|
146
|
-
def check_for_double_boot!
|
|
147
|
-
if booted?
|
|
148
|
-
Compass::Util.compass_warn("Warning: Compass was booted twice. Compass-rails has got your back; please remove your compass initializer.")
|
|
149
|
-
else
|
|
150
|
-
booted!
|
|
151
|
-
end
|
|
152
|
-
end
|
|
153
|
-
|
|
154
|
-
def sass_plugin_enabled?
|
|
155
|
-
unless rails31?
|
|
156
|
-
defined?(Sass::Plugin) && !Sass::Plugin.options[:never_update]
|
|
157
|
-
end
|
|
158
|
-
end
|
|
159
|
-
|
|
160
|
-
# Rails projects without asset pipeline use this in their compass initializer.
|
|
161
|
-
def initialize!(config = nil)
|
|
162
|
-
check_for_double_boot!
|
|
163
|
-
config ||= Compass.detect_configuration_file(root)
|
|
164
|
-
Compass.add_project_configuration(config, :project_type => :rails)
|
|
165
|
-
Compass.discover_extensions!
|
|
166
|
-
Compass.configure_sass_plugin!
|
|
167
|
-
Compass.handle_configuration_change! if sass_plugin_enabled?
|
|
168
|
-
end
|
|
169
|
-
|
|
170
89
|
def configure_rails!(app)
|
|
171
90
|
return unless app.config.respond_to?(:sass)
|
|
172
91
|
sass_config = app.config.sass
|
|
@@ -189,31 +108,6 @@ module CompassRails
|
|
|
189
108
|
end
|
|
190
109
|
end
|
|
191
110
|
|
|
192
|
-
def boot_config
|
|
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
|
|
204
|
-
end
|
|
205
|
-
end
|
|
206
|
-
|
|
207
|
-
def asset_pipeline_enabled?
|
|
208
|
-
return false unless rails_loaded? && ::Rails.respond_to?(:application) && !::Rails.application.nil?
|
|
209
|
-
rails_config = ::Rails.application.config
|
|
210
|
-
if rails_config.respond_to?(:assets)
|
|
211
|
-
rails_config.assets.enabled != false
|
|
212
|
-
else
|
|
213
|
-
false
|
|
214
|
-
end
|
|
215
|
-
end
|
|
216
|
-
|
|
217
111
|
private
|
|
218
112
|
|
|
219
113
|
# sets the sass config value only if the corresponding compass-based setting
|
|
@@ -226,11 +120,8 @@ module CompassRails
|
|
|
226
120
|
|
|
227
121
|
end
|
|
228
122
|
|
|
229
|
-
|
|
230
|
-
Compass.
|
|
231
|
-
|
|
232
|
-
require "compass-rails/
|
|
233
|
-
|
|
234
|
-
require "compass-rails/installer"
|
|
235
|
-
|
|
236
|
-
|
|
123
|
+
if defined?(::Rails)
|
|
124
|
+
Compass::AppIntegration.register(:rails, "::CompassRails")
|
|
125
|
+
require "compass-rails/patches"
|
|
126
|
+
require "compass-rails/railties"
|
|
127
|
+
end
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
require 'test_helper'
|
|
2
|
+
|
|
3
|
+
describe CompassRails do
|
|
4
|
+
include CompassRails::Test::RailsHelpers
|
|
5
|
+
|
|
6
|
+
it "compiles a basic compass stylesheet" do
|
|
7
|
+
within_rails_app('test_railtie') do |project|
|
|
8
|
+
project.setup_asset_fixtures!
|
|
9
|
+
|
|
10
|
+
assert project.boots?
|
|
11
|
+
|
|
12
|
+
project.precompile!
|
|
13
|
+
|
|
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
|
+
assert_match '.letters-a', css
|
|
22
|
+
assert_match '.letters-a', css
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
it "supports rails config arguments" do
|
|
28
|
+
within_rails_app('test_railtie') do |project|
|
|
29
|
+
assert_equal "scss", project.rails_property("sass.preferred_syntax")
|
|
30
|
+
assert_equal "public/assets", project.rails_property("compass.css_dir")
|
|
31
|
+
|
|
32
|
+
project.set_rails('sass.preferred_syntax', :sass)
|
|
33
|
+
project.set_rails('compass.css_dir', "public/stylesheets")
|
|
34
|
+
|
|
35
|
+
assert_equal "sass", project.rails_property("sass.preferred_syntax")
|
|
36
|
+
assert_equal "public/stylesheets", project.rails_property("compass.css_dir")
|
|
37
|
+
end
|
|
38
|
+
end unless ENV['DEBUG_COMPILE']
|
|
39
|
+
|
|
40
|
+
it "compiles when in production mode" do
|
|
41
|
+
within_rails_app('test_railtie') do |project|
|
|
42
|
+
project.setup_asset_fixtures!
|
|
43
|
+
|
|
44
|
+
# Mimic Rails production mode
|
|
45
|
+
project.set_rails('assets.compile', false)
|
|
46
|
+
|
|
47
|
+
assert project.boots?
|
|
48
|
+
|
|
49
|
+
project.precompile!
|
|
50
|
+
|
|
51
|
+
project.compiled_stylesheet 'public/assets/application*.css' do |css|
|
|
52
|
+
refute css.empty?
|
|
53
|
+
assert_match 'body container', css
|
|
54
|
+
assert_match '.numbers-sprite-1', css
|
|
55
|
+
end
|
|
56
|
+
end
|
|
57
|
+
end
|
|
58
|
+
end
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
// Import Compass
|
|
2
|
+
@import "compass";
|
|
3
|
+
|
|
4
|
+
// Glob import SCSS partials
|
|
5
|
+
@import "partials/*";
|
|
6
|
+
|
|
7
|
+
// Import Sprites
|
|
8
|
+
@import "letters/*.png";
|
|
9
|
+
@include all-letters-sprites;
|
|
10
|
+
|
|
11
|
+
// Inline Sprites
|
|
12
|
+
$numbers-inline: true;
|
|
13
|
+
@import "numbers/sprite-*.png";
|
|
14
|
+
@include all-numbers-sprites;
|
|
15
|
+
|
|
16
|
+
// Try out some compass stuff
|
|
17
|
+
body{
|
|
18
|
+
@include background-image(linear-gradient(white, #aaaaaa));
|
|
19
|
+
|
|
20
|
+
container{
|
|
21
|
+
@include border-radius(4px, 4px);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
@@ -43,7 +43,7 @@ module CompassRails
|
|
|
43
43
|
BUNDLER_COMMAND = 'bundle'
|
|
44
44
|
|
|
45
45
|
def run_command(command, gemfile=nil)
|
|
46
|
-
debug
|
|
46
|
+
debug "Running: #{command} with gemfile: #{gemfile}"
|
|
47
47
|
capture_all_output { CompassRails::Test::CommandRunner.new(command, gemfile).run }
|
|
48
48
|
end
|
|
49
49
|
|
|
@@ -75,14 +75,10 @@ class CompassRails::Test::CommandRunner
|
|
|
75
75
|
end
|
|
76
76
|
|
|
77
77
|
def run
|
|
78
|
-
|
|
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]
|
data/test/helpers/file_helper.rb
CHANGED
|
@@ -3,20 +3,10 @@ module CompassRails
|
|
|
3
3
|
module FileHelper
|
|
4
4
|
include DebugHelper
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
debug(Rainbow("Creating Directory: #{dir}").foreground(:green))
|
|
8
|
-
::FileUtils.mkdir_p dir
|
|
9
|
-
assert File.directory?(dir), "mkdir_p: #{dir} failed"
|
|
10
|
-
end
|
|
11
|
-
|
|
12
|
-
def rm_rf(path)
|
|
13
|
-
debug(Rainbow("Removing: #{path}").foreground(:red))
|
|
14
|
-
::FileUtils.rm_rf(path)
|
|
15
|
-
assert !File.directory?(path), "rm_rf: #{path} failed"
|
|
16
|
-
end
|
|
6
|
+
delegate :mkdir_p, :rm, :rm_rf, :cp_r, :touch, to: ::FileUtils
|
|
17
7
|
|
|
18
8
|
def cd(path, &block)
|
|
19
|
-
debug
|
|
9
|
+
debug "Entering: #{path}"
|
|
20
10
|
Dir.chdir(path, &block)
|
|
21
11
|
end
|
|
22
12
|
|
|
@@ -26,11 +16,6 @@ module CompassRails
|
|
|
26
16
|
File.open(file_name, 'w') { |file| file << content }
|
|
27
17
|
end
|
|
28
18
|
|
|
29
|
-
def touch(file)
|
|
30
|
-
debug(Rainbow("Touching File: #{file}").foreground(:green))
|
|
31
|
-
::FileUtils.touch(file)
|
|
32
|
-
end
|
|
33
|
-
|
|
34
19
|
def inject_into_file(file_name, replacement, position, anchor)
|
|
35
20
|
case position
|
|
36
21
|
when :after
|