Skip to content

Commit 706526d

Browse files
committed
Make sass-rails an wrapper for sassc-rails to allow a smooth upgrade path
1 parent ac38f1e commit 706526d

File tree

247 files changed

+9
-4805
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

247 files changed

+9
-4805
lines changed

.travis.yml

Lines changed: 0 additions & 65 deletions
This file was deleted.

Gemfile

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,3 @@ source "https://rubygems.org"
22

33
# Specify your gem's dependencies in sass-rails.gemspec
44
gemspec
5-
6-
gem "rails", github: "rails/rails"
7-
gem "arel", github: "rails/arel"
8-
gem "rack", github: "rack/rack"
9-
gem "sprockets", github: "rails/sprockets", branch: "master"
10-
gem "sprockets-rails", github: "rails/sprockets-rails", branch: "master"

MIT-LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Copyright (c) 2011-2016 Christopher Eppstein
1+
Copyright (c) 2011-2019 Christopher Eppstein
22

33
Permission is hereby granted, free of charge, to any person obtaining
44
a copy of this software and associated documentation files (the

Rakefile

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,2 @@
11
require 'bundler'
22
Bundler::GemHelper.install_tasks
3-
4-
require 'rake/testtask'
5-
6-
Rake::TestTask.new(:test) do |t|
7-
t.libs << 'lib'
8-
t.libs << 'test'
9-
t.pattern = 'test/**/*_test.rb'
10-
t.verbose = false
11-
end
12-
13-
desc 'Default: run unit tests.'
14-
task default: :test

gemfiles/Gemfile-rails-4-2

Lines changed: 0 additions & 11 deletions
This file was deleted.

gemfiles/Gemfile-rails-5-0

Lines changed: 0 additions & 8 deletions
This file was deleted.

gemfiles/Gemfile-rails-5-1

Lines changed: 0 additions & 8 deletions
This file was deleted.

gemfiles/Gemfile-rails-edge

Lines changed: 0 additions & 8 deletions
This file was deleted.

lib/rails/generators/sass/assets/assets_generator.rb

Lines changed: 0 additions & 13 deletions
This file was deleted.

lib/rails/generators/sass/assets/templates/stylesheet.sass

Lines changed: 0 additions & 3 deletions
This file was deleted.

lib/rails/generators/sass/scaffold/scaffold_generator.rb

Lines changed: 0 additions & 9 deletions
This file was deleted.

lib/rails/generators/sass_scaffold.rb

Lines changed: 0 additions & 15 deletions
This file was deleted.

lib/rails/generators/scss/assets/assets_generator.rb

Lines changed: 0 additions & 13 deletions
This file was deleted.

lib/rails/generators/scss/assets/templates/stylesheet.scss

Lines changed: 0 additions & 3 deletions
This file was deleted.

lib/rails/generators/scss/scaffold/scaffold_generator.rb

Lines changed: 0 additions & 10 deletions
This file was deleted.

lib/sass-rails.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
require 'sass/rails'
1+
require 'sassc/rails'

lib/sass/rails.rb

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1 @@
1-
module Sass
2-
module Rails
3-
autoload :Logger, 'sass/rails/logger'
4-
end
5-
end
6-
7-
require 'sass/rails/version'
8-
require 'sass/rails/importer'
9-
require 'sass/rails/railtie'
1+
require 'sassc/rails'

lib/sass/rails/importer.rb

Lines changed: 1 addition & 158 deletions
Original file line numberDiff line numberDiff line change
@@ -1,158 +1 @@
1-
require 'active_support/deprecation/reporting'
2-
require 'sass/importers'
3-
require 'sprockets/file_reader'
4-
require 'sprockets/erb_processor'
5-
require 'sprockets/processor_utils'
6-
7-
module Sass
8-
module Rails
9-
class SassImporter < Sass::Importers::Filesystem
10-
module Globbing
11-
GLOB = /(\A|\/)(\*|\*\*\/\*)\z/
12-
13-
def find_relative(name, base, options)
14-
if options[:sprockets] && m = name.match(GLOB)
15-
path = name.sub(m[0], "")
16-
base = File.expand_path(path, File.dirname(base))
17-
glob_imports(base, m[2], options)
18-
else
19-
super
20-
end
21-
end
22-
23-
def find(name, options)
24-
# globs must be relative
25-
return if name =~ GLOB
26-
super
27-
end
28-
29-
private
30-
def glob_imports(base, glob, options)
31-
contents = ""
32-
context = options[:sprockets][:context]
33-
each_globbed_file(base, glob, context) do |filename|
34-
next if filename == options[:filename]
35-
contents << "@import #{filename.inspect};\n"
36-
end
37-
return nil if contents == ""
38-
Sass::Engine.new(contents, options.merge(
39-
:filename => base,
40-
:importer => self,
41-
:syntax => :scss
42-
))
43-
end
44-
45-
def each_globbed_file(base, glob, context)
46-
raise ArgumentError unless glob == "*" || glob == "**/*"
47-
48-
exts = extensions.keys.map { |ext| Regexp.escape(".#{ext}") }.join("|")
49-
sass_re = Regexp.compile("(#{exts})$")
50-
51-
context.depend_on(base)
52-
53-
Dir["#{base}/#{glob}"].sort.each do |path|
54-
if File.directory?(path)
55-
context.depend_on(path)
56-
elsif sass_re =~ path
57-
yield path
58-
end
59-
end
60-
end
61-
end
62-
63-
module ERB
64-
def extensions
65-
{
66-
'css.erb' => :scss_erb,
67-
'scss.erb' => :scss_erb,
68-
'sass.erb' => :sass_erb
69-
}.merge(super)
70-
end
71-
72-
def erb_extensions
73-
{
74-
:scss_erb => :scss,
75-
:sass_erb => :sass
76-
}
77-
end
78-
79-
def find_relative(*args)
80-
process_erb_engine(super)
81-
end
82-
83-
def find(*args)
84-
process_erb_engine(super)
85-
end
86-
87-
private
88-
def process_erb_engine(engine)
89-
if engine && engine.options[:sprockets] && syntax = erb_extensions[engine.options[:syntax]]
90-
context = engine.options[:sprockets][:context]
91-
92-
input = {
93-
filename: engine.options[:filename],
94-
environment: context.environment,
95-
content_type: "text/#{syntax}",
96-
metadata: {}
97-
}
98-
99-
processors = [Sprockets::ERBProcessor, Sprockets::FileReader]
100-
101-
result = Sprockets::ProcessorUtils.call_processors(processors, input)
102-
103-
Sass::Engine.new(result[:data], engine.options.merge(:syntax => syntax))
104-
else
105-
engine
106-
end
107-
end
108-
end
109-
110-
module Deprecated
111-
def extensions
112-
{
113-
'css.scss' => :scss,
114-
'css.sass' => :sass,
115-
'css.scss.erb' => :scss_erb,
116-
'css.sass.erb' => :sass_erb
117-
}.merge(super)
118-
end
119-
120-
def find_relative(*args)
121-
deprecate_extra_css_extension(super)
122-
end
123-
124-
def find(*args)
125-
deprecate_extra_css_extension(super)
126-
end
127-
128-
private
129-
def deprecate_extra_css_extension(engine)
130-
if engine && filename = engine.options[:filename]
131-
if filename.end_with?('.css.scss')
132-
msg = "Extra .css in SCSS file is unnecessary. Rename #{filename} to #{filename.sub('.css.scss', '.scss')}."
133-
elsif filename.end_with?('.css.sass')
134-
msg = "Extra .css in SASS file is unnecessary. Rename #{filename} to #{filename.sub('.css.sass', '.sass')}."
135-
elsif filename.end_with?('.css.scss.erb')
136-
msg = "Extra .css in SCSS/ERB file is unnecessary. Rename #{filename} to #{filename.sub('.css.scss.erb', '.scss.erb')}."
137-
elsif filename.end_with?('.css.sass.erb')
138-
msg = "Extra .css in SASS/ERB file is unnecessary. Rename #{filename} to #{filename.sub('.css.sass.erb', '.sass.erb')}."
139-
end
140-
141-
ActiveSupport::Deprecation.warn(msg) if msg
142-
end
143-
144-
engine
145-
end
146-
end
147-
148-
include ERB
149-
include Deprecated
150-
include Globbing
151-
152-
# Allow .css files to be @import'd
153-
def extensions
154-
{ 'css' => :scss }.merge(super)
155-
end
156-
end
157-
end
158-
end
1+
require 'sassc/rails/importer'

0 commit comments

Comments
 (0)