sprockets-sass 1.2.0 → 1.3.0

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore CHANGED
@@ -6,3 +6,7 @@ pkg/*
6
6
  .sass-cache
7
7
  .rspec
8
8
  .ruby-version
9
+
10
+ # Ignore IntelliJ IDEA project files.
11
+ *.iml
12
+ /.idea/
@@ -73,12 +73,21 @@ module Sprockets
73
73
 
74
74
  # Assemble the options for the `Sass::Engine`
75
75
  def sass_options
76
+ # Allow the use of custom SASS importers, making sure the
77
+ # custom importer is a `Sprockets::Sass::Importer`
78
+ if default_sass_options.has_key?(:importer) &&
79
+ default_sass_options[:importer].is_a?(Importer)
80
+ importer = default_sass_options[:importer]
81
+ else
82
+ importer = Importer.new
83
+ end
84
+
76
85
  merge_sass_options(default_sass_options, options).merge(
77
86
  :filename => eval_file,
78
87
  :line => line,
79
88
  :syntax => syntax,
80
89
  :cache_store => cache_store,
81
- :importer => Importer.new,
90
+ :importer => importer,
82
91
  :custom => { :sprockets_context => context }
83
92
  )
84
93
  end
@@ -1,5 +1,5 @@
1
1
  module Sprockets
2
2
  module Sass
3
- VERSION = '1.2.0'
3
+ VERSION = '1.3.0'
4
4
  end
5
5
  end
@@ -0,0 +1,32 @@
1
+ require 'spec_helper'
2
+
3
+ describe Sprockets::Sass::SassTemplate do
4
+
5
+ before :each do
6
+ # Create the custom importer.
7
+ @custom_importer = Sprockets::Sass::DummyImporter.new
8
+ Sprockets::Sass.options[:importer] = @custom_importer
9
+
10
+ # Initialize the environment.
11
+ @root = create_construct
12
+ @assets = @root.directory 'assets'
13
+ @env = Sprockets::Environment.new @root.to_s
14
+ @env.append_path @assets.to_s
15
+ @env.register_postprocessor 'text/css', :fail_postprocessor do |_, data|
16
+ data.gsub /@import/, 'fail engine'
17
+ end
18
+ end
19
+
20
+ after :each do
21
+ @root.destroy!
22
+ end
23
+
24
+ it 'allow specifying custom sass importer' do
25
+ @assets.file 'main.css.scss', %(@import "dep";)
26
+ @assets.file 'dep.css.scss', "$color: blue;\nbody { color: $color; }"
27
+ @env['main.css']
28
+
29
+ expect(@custom_importer.has_been_used).to be_truthy
30
+ end
31
+
32
+ end
@@ -372,7 +372,7 @@ describe Sprockets::Sass do
372
372
  template.should_receive(:require).with('sprockets/helpers').and_raise LoadError
373
373
  template.should_not_receive(:require).with 'sprockets/sass/functions'
374
374
  template.initialize_engine
375
- expect(Sprockets::Sass::SassTemplate.engine_initialized?).to be_true
375
+ expect(Sprockets::Sass::SassTemplate.engine_initialized?).to be_truthy
376
376
  end
377
377
 
378
378
  it 'does not add Sass functions if add_sass_functions is false' do
@@ -380,7 +380,7 @@ describe Sprockets::Sass do
380
380
  template = Sprockets::Sass::SassTemplate.new {}
381
381
  template.should_not_receive(:require).with 'sprockets/sass/functions'
382
382
  template.initialize_engine
383
- expect(Sprockets::Sass::SassTemplate.engine_initialized?).to be_true
383
+ expect(Sprockets::Sass::SassTemplate.engine_initialized?).to be_truthy
384
384
  Sprockets::Sass.add_sass_functions = true
385
385
  end
386
386
  end
@@ -0,0 +1,25 @@
1
+ module Sprockets
2
+ module Sass
3
+
4
+ class DummyImporter < Importer
5
+ attr_accessor :has_been_used
6
+
7
+ def initialize
8
+ super()
9
+ @has_been_used = false
10
+ end
11
+
12
+ def find(path, options)
13
+ @has_been_used = true
14
+ super(path, options)
15
+ end
16
+
17
+ def find_relative(uri, base, options, *args)
18
+ @has_been_used = true
19
+ super(uri, base, options, *args)
20
+ end
21
+
22
+ end
23
+
24
+ end
25
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sprockets-sass
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.0
4
+ version: 1.3.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-07-10 00:00:00.000000000 Z
12
+ date: 2014-11-14 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: sprockets
@@ -213,10 +213,12 @@ files:
213
213
  - lib/sprockets/sass/sass_template.rb
214
214
  - lib/sprockets/sass/scss_template.rb
215
215
  - lib/sprockets/sass/version.rb
216
+ - spec/custom_importer_spec.rb
216
217
  - spec/fixtures/image.jpg
217
218
  - spec/spec_helper.rb
218
219
  - spec/sprockets-sass_spec.rb
219
220
  - spec/support/be_fresh_matcher.rb
221
+ - spec/support/dummy_importer.rb
220
222
  - sprockets-sass.gemspec
221
223
  homepage: http://github.com/petebrowne/sprockets-sass
222
224
  licenses: []
@@ -232,7 +234,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
232
234
  version: '0'
233
235
  segments:
234
236
  - 0
235
- hash: -2591285633856815059
237
+ hash: 3139794298757869131
236
238
  required_rubygems_version: !ruby/object:Gem::Requirement
237
239
  none: false
238
240
  requirements:
@@ -241,7 +243,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
241
243
  version: '0'
242
244
  segments:
243
245
  - 0
244
- hash: -2591285633856815059
246
+ hash: 3139794298757869131
245
247
  requirements: []
246
248
  rubyforge_project: sprockets-sass
247
249
  rubygems_version: 1.8.23
@@ -249,7 +251,9 @@ signing_key:
249
251
  specification_version: 3
250
252
  summary: Better Sass integration with Sprockets 2.0
251
253
  test_files:
254
+ - spec/custom_importer_spec.rb
252
255
  - spec/fixtures/image.jpg
253
256
  - spec/spec_helper.rb
254
257
  - spec/sprockets-sass_spec.rb
255
258
  - spec/support/be_fresh_matcher.rb
259
+ - spec/support/dummy_importer.rb