-
Notifications
You must be signed in to change notification settings - Fork 331
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make sass-rails an wrapper for sassc-rails to allow a smooth upgrade …
…path
- Loading branch information
1 parent
ac38f1e
commit 706526d
Showing
247 changed files
with
9 additions
and
4,805 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,2 @@ | ||
require 'bundler' | ||
Bundler::GemHelper.install_tasks | ||
|
||
require 'rake/testtask' | ||
|
||
Rake::TestTask.new(:test) do |t| | ||
t.libs << 'lib' | ||
t.libs << 'test' | ||
t.pattern = 'test/**/*_test.rb' | ||
t.verbose = false | ||
end | ||
|
||
desc 'Default: run unit tests.' | ||
task default: :test |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
require 'sass/rails' | ||
require 'sassc/rails' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1 @@ | ||
module Sass | ||
module Rails | ||
autoload :Logger, 'sass/rails/logger' | ||
end | ||
end | ||
|
||
require 'sass/rails/version' | ||
require 'sass/rails/importer' | ||
require 'sass/rails/railtie' | ||
require 'sassc/rails' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,158 +1 @@ | ||
require 'active_support/deprecation/reporting' | ||
require 'sass/importers' | ||
require 'sprockets/file_reader' | ||
require 'sprockets/erb_processor' | ||
require 'sprockets/processor_utils' | ||
|
||
module Sass | ||
module Rails | ||
class SassImporter < Sass::Importers::Filesystem | ||
module Globbing | ||
GLOB = /(\A|\/)(\*|\*\*\/\*)\z/ | ||
|
||
def find_relative(name, base, options) | ||
if options[:sprockets] && m = name.match(GLOB) | ||
path = name.sub(m[0], "") | ||
base = File.expand_path(path, File.dirname(base)) | ||
glob_imports(base, m[2], options) | ||
else | ||
super | ||
end | ||
end | ||
|
||
def find(name, options) | ||
# globs must be relative | ||
return if name =~ GLOB | ||
super | ||
end | ||
|
||
private | ||
def glob_imports(base, glob, options) | ||
contents = "" | ||
context = options[:sprockets][:context] | ||
each_globbed_file(base, glob, context) do |filename| | ||
next if filename == options[:filename] | ||
contents << "@import #{filename.inspect};\n" | ||
end | ||
return nil if contents == "" | ||
Sass::Engine.new(contents, options.merge( | ||
:filename => base, | ||
:importer => self, | ||
:syntax => :scss | ||
)) | ||
end | ||
|
||
def each_globbed_file(base, glob, context) | ||
raise ArgumentError unless glob == "*" || glob == "**/*" | ||
|
||
exts = extensions.keys.map { |ext| Regexp.escape(".#{ext}") }.join("|") | ||
sass_re = Regexp.compile("(#{exts})$") | ||
|
||
context.depend_on(base) | ||
|
||
Dir["#{base}/#{glob}"].sort.each do |path| | ||
if File.directory?(path) | ||
context.depend_on(path) | ||
elsif sass_re =~ path | ||
yield path | ||
end | ||
end | ||
end | ||
end | ||
|
||
module ERB | ||
def extensions | ||
{ | ||
'css.erb' => :scss_erb, | ||
'scss.erb' => :scss_erb, | ||
'sass.erb' => :sass_erb | ||
}.merge(super) | ||
end | ||
|
||
def erb_extensions | ||
{ | ||
:scss_erb => :scss, | ||
:sass_erb => :sass | ||
} | ||
end | ||
|
||
def find_relative(*args) | ||
process_erb_engine(super) | ||
end | ||
|
||
def find(*args) | ||
process_erb_engine(super) | ||
end | ||
|
||
private | ||
def process_erb_engine(engine) | ||
if engine && engine.options[:sprockets] && syntax = erb_extensions[engine.options[:syntax]] | ||
context = engine.options[:sprockets][:context] | ||
|
||
input = { | ||
filename: engine.options[:filename], | ||
environment: context.environment, | ||
content_type: "text/#{syntax}", | ||
metadata: {} | ||
} | ||
|
||
processors = [Sprockets::ERBProcessor, Sprockets::FileReader] | ||
|
||
result = Sprockets::ProcessorUtils.call_processors(processors, input) | ||
|
||
Sass::Engine.new(result[:data], engine.options.merge(:syntax => syntax)) | ||
else | ||
engine | ||
end | ||
end | ||
end | ||
|
||
module Deprecated | ||
def extensions | ||
{ | ||
'css.scss' => :scss, | ||
'css.sass' => :sass, | ||
'css.scss.erb' => :scss_erb, | ||
'css.sass.erb' => :sass_erb | ||
}.merge(super) | ||
end | ||
|
||
def find_relative(*args) | ||
deprecate_extra_css_extension(super) | ||
end | ||
|
||
def find(*args) | ||
deprecate_extra_css_extension(super) | ||
end | ||
|
||
private | ||
def deprecate_extra_css_extension(engine) | ||
if engine && filename = engine.options[:filename] | ||
if filename.end_with?('.css.scss') | ||
msg = "Extra .css in SCSS file is unnecessary. Rename #{filename} to #{filename.sub('.css.scss', '.scss')}." | ||
elsif filename.end_with?('.css.sass') | ||
msg = "Extra .css in SASS file is unnecessary. Rename #{filename} to #{filename.sub('.css.sass', '.sass')}." | ||
elsif filename.end_with?('.css.scss.erb') | ||
msg = "Extra .css in SCSS/ERB file is unnecessary. Rename #{filename} to #{filename.sub('.css.scss.erb', '.scss.erb')}." | ||
elsif filename.end_with?('.css.sass.erb') | ||
msg = "Extra .css in SASS/ERB file is unnecessary. Rename #{filename} to #{filename.sub('.css.sass.erb', '.sass.erb')}." | ||
end | ||
|
||
ActiveSupport::Deprecation.warn(msg) if msg | ||
end | ||
|
||
engine | ||
end | ||
end | ||
|
||
include ERB | ||
include Deprecated | ||
include Globbing | ||
|
||
# Allow .css files to be @import'd | ||
def extensions | ||
{ 'css' => :scss }.merge(super) | ||
end | ||
end | ||
end | ||
end | ||
require 'sassc/rails/importer' |
Oops, something went wrong.