From ccb3273f6fd1d47042727ac4720b265fa80f0ee8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Eloy=20P=C3=A9rez?= Date: Fri, 11 Mar 2022 20:49:46 +0100 Subject: [PATCH] Delete sass --- .gitignore | 1 - Gemfile | 1 - lib/sinatra/base.rb | 12 +- sinatra-contrib/ideas.md | 4 +- .../lib/sinatra/engine_tracking.rb | 10 -- sinatra-contrib/lib/sinatra/namespace.rb | 2 +- sinatra-contrib/lib/sinatra/respond_with.rb | 1 - sinatra-contrib/sinatra-contrib.gemspec | 1 - sinatra-contrib/spec/namespace_spec.rb | 4 +- .../spec/respond_with/not_html.sass | 2 - test/sass_test.rb | 115 ------------------ test/scss_test.rb | 88 -------------- test/views/error.sass | 2 - test/views/hello.sass | 2 - test/views/hello.scss | 3 - 15 files changed, 6 insertions(+), 242 deletions(-) delete mode 100644 sinatra-contrib/spec/respond_with/not_html.sass delete mode 100644 test/sass_test.rb delete mode 100644 test/scss_test.rb delete mode 100644 test/views/error.sass delete mode 100644 test/views/hello.sass delete mode 100644 test/views/hello.scss diff --git a/.gitignore b/.gitignore index 9aef613a..f37e0f56 100644 --- a/.gitignore +++ b/.gitignore @@ -3,7 +3,6 @@ .DS_STORE *.swp *.rbc -*.sass-cache /pkg /Gemfile.lock /coverage diff --git a/Gemfile b/Gemfile index 6f59f993..142d0422 100644 --- a/Gemfile +++ b/Gemfile @@ -45,7 +45,6 @@ gem 'rabl' gem 'builder' gem 'erubi' gem 'haml', '~> 5' -gem 'sass' gem 'celluloid', '~> 0.16.0' gem 'commonmarker', '~> 0.20.0', platforms: [ :ruby ] gem 'pandoc-ruby', '~> 2.0.2' diff --git a/lib/sinatra/base.rb b/lib/sinatra/base.rb index a9804685..8777a06f 100644 --- a/lib/sinatra/base.rb +++ b/lib/sinatra/base.rb @@ -685,7 +685,7 @@ module Sinatra # Possible options are: # :content_type The content type to use, same arguments as content_type. # :layout If set to something falsy, no layout is rendered, otherwise - # the specified layout is used (Ignored for `sass`) + # the specified layout is used # :layout_engine Engine to use for rendering the layout. # :locals A hash with local variables that should be available # in the template @@ -711,16 +711,6 @@ module Sinatra render(:haml, template, options, locals, &block) end - def sass(template, options = {}, locals = {}) - options.merge! :layout => false, :default_content_type => :css - render :sass, template, options, locals - end - - def scss(template, options = {}, locals = {}) - options.merge! :layout => false, :default_content_type => :css - render :scss, template, options, locals - end - def builder(template = nil, options = {}, locals = {}, &block) options[:default_content_type] = :xml render_ruby(:builder, template, options, locals, &block) diff --git a/sinatra-contrib/ideas.md b/sinatra-contrib/ideas.md index 8460115d..fc4df978 100644 --- a/sinatra-contrib/ideas.md +++ b/sinatra-contrib/ideas.md @@ -11,7 +11,7 @@ * `sinatra-smart-cache`: update cache header only if arguments are more restrictive than curent value, set caching headers that way for most helper - methods (i.e. `sass` or `send_file`) + methods (i.e. `send_file`) * Some verbose logging extension: Log what filters, routes, error handlers, templates, and so on is used. @@ -26,4 +26,4 @@ * Rewrite of `sinatra-compass`? -* Helpers for HTML escaping and such. \ No newline at end of file +* Helpers for HTML escaping and such. diff --git a/sinatra-contrib/lib/sinatra/engine_tracking.rb b/sinatra-contrib/lib/sinatra/engine_tracking.rb index a30782e2..b80b6b08 100644 --- a/sinatra-contrib/lib/sinatra/engine_tracking.rb +++ b/sinatra-contrib/lib/sinatra/engine_tracking.rb @@ -25,16 +25,6 @@ module Sinatra @current_engine == :haml end - # @return [Boolean] Returns true if current engine is `:sass`. - def sass? - @current_engine == :sass - end - - # @return [Boolean] Returns true if current engine is `:scss`. - def scss? - @current_engine == :scss - end - # @return [Boolean] Returns true if current engine is `:builder`. def builder? @current_engine == :builder diff --git a/sinatra-contrib/lib/sinatra/namespace.rb b/sinatra-contrib/lib/sinatra/namespace.rb index db9daf38..efa209ee 100644 --- a/sinatra-contrib/lib/sinatra/namespace.rb +++ b/sinatra-contrib/lib/sinatra/namespace.rb @@ -225,7 +225,7 @@ module Sinatra attr_reader :base, :templates ALLOWED_ENGINES = [ - :erb, :erubi, :haml, :hamlit, :builder, :nokogiri, :sass, :scss, + :erb, :erubi, :haml, :hamlit, :builder, :nokogiri, :liquid, :markdown, :rdoc, :asciidoc, :radius, :markaby, :rabl, :slim, :creole, :mediawiki, :coffee, :yajl, :wlang ] diff --git a/sinatra-contrib/lib/sinatra/respond_with.rb b/sinatra-contrib/lib/sinatra/respond_with.rb index 40294244..cd41544f 100644 --- a/sinatra-contrib/lib/sinatra/respond_with.rb +++ b/sinatra-contrib/lib/sinatra/respond_with.rb @@ -237,7 +237,6 @@ module Sinatra def self.engines engines = { - :css => [:sass, :scss], :xml => [:builder, :nokogiri], :js => [:coffee], :html => [:erb, :erubi, :haml, :hamlit, :slim, :liquid, :radius, diff --git a/sinatra-contrib/sinatra-contrib.gemspec b/sinatra-contrib/sinatra-contrib.gemspec index e31b1481..4f48dec3 100644 --- a/sinatra-contrib/sinatra-contrib.gemspec +++ b/sinatra-contrib/sinatra-contrib.gemspec @@ -46,7 +46,6 @@ EOF s.add_development_dependency "haml" s.add_development_dependency "erubi" s.add_development_dependency "slim" - s.add_development_dependency "sass" s.add_development_dependency "builder" s.add_development_dependency "liquid" s.add_development_dependency "redcarpet" diff --git a/sinatra-contrib/spec/namespace_spec.rb b/sinatra-contrib/spec/namespace_spec.rb index 85a76284..eba3d86a 100644 --- a/sinatra-contrib/spec/namespace_spec.rb +++ b/sinatra-contrib/spec/namespace_spec.rb @@ -773,9 +773,9 @@ RSpec.describe Sinatra::Namespace do it 'sets hashes correctly' do mock_app do namespace '/foo' do - set erb: 'o', sass: 'k' + set erb: 'o', haml: 'k' get '/bar' do - settings.erb + settings.sass + settings.erb + settings.haml end end end diff --git a/sinatra-contrib/spec/respond_with/not_html.sass b/sinatra-contrib/spec/respond_with/not_html.sass deleted file mode 100644 index 50f8864f..00000000 --- a/sinatra-contrib/spec/respond_with/not_html.sass +++ /dev/null @@ -1,2 +0,0 @@ -body - color: red diff --git a/test/sass_test.rb b/test/sass_test.rb deleted file mode 100644 index 4d189f8a..00000000 --- a/test/sass_test.rb +++ /dev/null @@ -1,115 +0,0 @@ -require File.expand_path('helper', __dir__) - -begin -require 'sass' - -class SassTest < Minitest::Test - def sass_app(options = {}, &block) - mock_app do - set :views, __dir__ + '/views' - set options - get('/', &block) - end - get '/' - end - - it 'renders inline Sass strings' do - sass_app { sass "#sass\n background-color: white\n" } - assert ok? - assert_equal "#sass {\n background-color: white; }\n", body - end - - it 'defaults content type to css' do - sass_app { sass "#sass\n background-color: white\n" } - assert ok? - assert_equal "text/css;charset=utf-8", response['Content-Type'] - end - - it 'defaults allows setting content type per route' do - sass_app do - content_type :html - sass "#sass\n background-color: white\n" - end - assert ok? - assert_equal "text/html;charset=utf-8", response['Content-Type'] - end - - it 'defaults allows setting content type globally' do - sass_app(:sass => { :content_type => 'html' }) { - sass "#sass\n background-color: white\n" - } - assert ok? - assert_equal "text/html;charset=utf-8", response['Content-Type'] - end - - it 'renders .sass files in views path' do - sass_app { sass :hello } - assert ok? - assert_equal "#sass {\n background-color: white; }\n", body - end - - it 'ignores the layout option' do - sass_app { sass :hello, :layout => :layout2 } - assert ok? - assert_equal "#sass {\n background-color: white; }\n", body - end - - it "raises error if template not found" do - mock_app { get('/') { sass :no_such_template } } - assert_raises(Errno::ENOENT) { get('/') } - end - - it "passes SASS options to the Sass engine" do - sass_app do - sass( - "#sass\n background-color: white\n color: black\n", - :style => :compact - ) - end - assert ok? - assert_equal("#sass { background-color: white; color: black; }\n", body) - end - - it "passes default SASS options to the Sass engine" do - mock_app do - set :sass, {:style => :compact} # default Sass style is :nested - get('/') { sass("#sass\n background-color: white\n color: black\n") } - end - get '/' - assert ok? - assert_equal "#sass { background-color: white; color: black; }\n", body - end - - it "merges the default SASS options with the overrides" do - mock_app do - # default Sass attribute_syntax is :normal (with : in front) - set :sass, {:style => :compact, :attribute_syntax => :alternate } - get('/') { sass("#sass\n background-color: white\n color: black\n") } - get('/raised') do - # retains global attribute_syntax settings - sass( - "#sass\n :background-color white\n :color black\n", - :style => :expanded - ) - end - get('/expanded_normal') do - sass( - "#sass\n :background-color white\n :color black\n", - :style => :expanded, :attribute_syntax => :normal - ) - end - end - get '/' - assert ok? - assert_equal "#sass { background-color: white; color: black; }\n", body - assert_raises(Sass::SyntaxError) { get('/raised') } - get '/expanded_normal' - assert ok? - assert_equal "#sass {\n background-color: white;\n color: black;\n}\n", - body - end -end - -rescue LoadError - warn "#{$!}: skipping sass tests" -end diff --git a/test/scss_test.rb b/test/scss_test.rb deleted file mode 100644 index e08d7bb6..00000000 --- a/test/scss_test.rb +++ /dev/null @@ -1,88 +0,0 @@ -require File.expand_path('helper', __dir__) - -begin -require 'sass' - -class ScssTest < Minitest::Test - def scss_app(options = {}, &block) - mock_app do - set :views, __dir__ + '/views' - set options - get('/', &block) - end - get '/' - end - - it 'renders inline Scss strings' do - scss_app { scss "#scss {\n background-color: white; }\n" } - assert ok? - assert_equal "#scss {\n background-color: white; }\n", body - end - - it 'defaults content type to css' do - scss_app { scss "#scss {\n background-color: white; }\n" } - assert ok? - assert_equal "text/css;charset=utf-8", response['Content-Type'] - end - - it 'defaults allows setting content type per route' do - scss_app do - content_type :html - scss "#scss {\n background-color: white; }\n" - end - assert ok? - assert_equal "text/html;charset=utf-8", response['Content-Type'] - end - - it 'defaults allows setting content type globally' do - scss_app(:scss => { :content_type => 'html' }) { - scss "#scss {\n background-color: white; }\n" - } - assert ok? - assert_equal "text/html;charset=utf-8", response['Content-Type'] - end - - it 'renders .scss files in views path' do - scss_app { scss :hello } - assert ok? - assert_equal "#scss {\n background-color: white; }\n", body - end - - it 'ignores the layout option' do - scss_app { scss :hello, :layout => :layout2 } - assert ok? - assert_equal "#scss {\n background-color: white; }\n", body - end - - it "raises error if template not found" do - mock_app { get('/') { scss(:no_such_template) } } - assert_raises(Errno::ENOENT) { get('/') } - end - - it "passes scss options to the scss engine" do - scss_app do - scss( - "#scss {\n background-color: white;\n color: black\n}", - :style => :compact - ) - end - assert ok? - assert_equal "#scss { background-color: white; color: black; }\n", body - end - - it "passes default scss options to the scss engine" do - mock_app do - set :scss, {:style => :compact} # default scss style is :nested - get('/') { - scss("#scss {\n background-color: white;\n color: black;\n}") - } - end - get '/' - assert ok? - assert_equal "#scss { background-color: white; color: black; }\n", body - end -end - -rescue LoadError - warn "#{$!}: skipping scss tests" -end diff --git a/test/views/error.sass b/test/views/error.sass deleted file mode 100644 index 42fc56b3..00000000 --- a/test/views/error.sass +++ /dev/null @@ -1,2 +0,0 @@ -#sass - +argle-bargle diff --git a/test/views/hello.sass b/test/views/hello.sass deleted file mode 100644 index c2e90462..00000000 --- a/test/views/hello.sass +++ /dev/null @@ -1,2 +0,0 @@ -#sass - background-color: white diff --git a/test/views/hello.scss b/test/views/hello.scss deleted file mode 100644 index 87d1200f..00000000 --- a/test/views/hello.scss +++ /dev/null @@ -1,3 +0,0 @@ -#scss { - background-color: white -} \ No newline at end of file