Skip to content

Commit 72d132e

Browse files
author
Francesco Rodriguez
committed
add attr_reader method for @context
1 parent aeae25d commit 72d132e

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

lib/sass/rails/importer.rb

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ module Sprockets
44
class SassImporter < Sass::Importers::Filesystem
55
GLOB = /\*|\[.+\]/
66

7+
attr_reader :context
8+
79
def extensions
810
{
911
"css" => :scss,
@@ -35,17 +37,17 @@ def find_with_glob(name, options)
3537
def each_globbed_file(glob, base_pathname, options)
3638
Dir["#{base_pathname}/#{glob}"].sort.each do |filename|
3739
next if filename == options[:filename]
38-
yield filename if File.directory?(filename) || @context.asset_requirable?(filename)
40+
yield filename if File.directory?(filename) || context.asset_requirable?(filename)
3941
end
4042
end
4143

4244
def glob_imports(glob, base_pathname, options)
4345
contents = ""
4446
each_globbed_file(glob, base_pathname.dirname, options) do |filename|
4547
if File.directory?(filename)
46-
@context.depend_on(filename)
47-
elsif @context.asset_requirable?(filename)
48-
@context.depend_on(filename)
48+
context.depend_on(filename)
49+
elsif context.asset_requirable?(filename)
50+
context.depend_on(filename)
4951
contents << "@import #{Pathname.new(filename).relative_path_from(base_pathname.dirname).to_s.inspect};\n"
5052
end
5153
end

test/sass_rails_test.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,11 +62,13 @@ class SassRailsTest < Sass::Rails::TestCase
6262
end
6363
end
6464

65+
focus
6566
test 'sprockets require works correctly' do
6667
css_output = sprockets_render('scss_project', 'css_application.css')
6768
assert_match /globbed/, css_output
6869
end
6970

71+
focus
7072
test 'sass imports work correctly' do
7173
css_output = sprockets_render('scss_project', 'application.css.scss')
7274
assert_match /main/, css_output

0 commit comments

Comments
 (0)