Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/twbs/bootstrap-sass.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGleb Mazovetskiy <glex.spb@gmail.com>2018-08-22 00:34:39 +0300
committerGleb Mazovetskiy <glex.spb@gmail.com>2018-12-14 15:16:04 +0300
commita1c5ec516b5352f70ba93b704d36ecd8e284eabd (patch)
tree794bb70f440910b6f6b10c72f40e5bc359f6e5a3
parent3db610a768032bcabdaffc83bf0f343558fc9958 (diff)
sass -> sassc
Fixes #1156
-rw-r--r--Gemfile2
-rw-r--r--Rakefile18
-rw-r--r--assets/stylesheets/bootstrap/_theme.scss4
-rw-r--r--bootstrap-sass.gemspec8
-rw-r--r--lib/bootstrap-sass.rb16
-rw-r--r--tasks/converter/less_conversion.rb2
-rw-r--r--tasks/converter/network.rb4
-rw-r--r--test/compilation_test.rb4
-rw-r--r--test/dummy_rails/config/boot.rb2
-rw-r--r--test/dummy_sass_only/Gemfile2
-rw-r--r--test/dummy_sass_only/compile.rb21
-rw-r--r--test/dummy_sass_only/import_all.sass2
-rw-r--r--test/dummy_sass_only/import_all.scss2
-rw-r--r--test/sass_test.rb16
-rw-r--r--test/sprockets_rails_test.rb20
-rw-r--r--test/test_helper.rb3
16 files changed, 69 insertions, 57 deletions
diff --git a/Gemfile b/Gemfile
index 38da900a..a441504c 100644
--- a/Gemfile
+++ b/Gemfile
@@ -6,5 +6,5 @@ gemspec
gem 'compass', require: false
group :development do
- gem 'byebug', platforms: [:mri_21, :mri_22], require: false
+ gem 'byebug', platform: :mri, require: false
end
diff --git a/Rakefile b/Rakefile
index 3e88526d..ae42c2e2 100644
--- a/Rakefile
+++ b/Rakefile
@@ -1,4 +1,4 @@
-lib_path = File.join(File.dirname(__FILE__), 'lib')
+lib_path = File.join(__dir__, 'lib')
$:.unshift(lib_path) unless $:.include?(lib_path)
load './tasks/bower.rake'
@@ -42,11 +42,12 @@ end
desc 'Dumps output to a CSS file for testing'
task :debug do
- require 'sass'
+ require 'sassc'
+ require 'bootstrap-sass'
path = Bootstrap.stylesheets_path
- %w(bootstrap).each do |file|
- engine = Sass::Engine.for_file("#{path}/#{file}.scss", syntax: :scss, load_paths: [path])
- File.open("./#{file}.css", 'w') { |f| f.write(engine.render) }
+ %w(_bootstrap).each do |file|
+ engine = SassC::Engine.new(File.read("#{path}/#{file}.scss"), syntax: :scss, load_paths: [path])
+ File.open("tmp/#{file}.css", 'w') { |f| f.write(engine.render) }
end
end
@@ -64,7 +65,8 @@ end
desc 'Compile bootstrap-sass to tmp/ (or first arg)'
task :compile, :css_path do |t, args|
- require 'sass'
+ require 'sassc'
+ require 'bootstrap-sass'
require 'term/ansicolor'
path = 'assets/stylesheets'
@@ -74,8 +76,8 @@ task :compile, :css_path do |t, args|
%w(_bootstrap bootstrap/_theme).each do |file|
save_path = "#{css_path}/#{file.sub(/(^|\/)?_+/, '\1').sub('/', '-')}.css"
puts Term::ANSIColor.cyan(" #{save_path}") + '...'
- engine = Sass::Engine.for_file("#{path}/#{file}.scss", syntax: :scss, load_paths: [path])
- css = engine.render
+ engine = SassC::Engine.new(File.read("#{path}/#{file}.scss"), syntax: :scss, load_paths: [path])
+ css = engine.render
File.open(save_path, 'w') { |f| f.write css }
end
end
diff --git a/assets/stylesheets/bootstrap/_theme.scss b/assets/stylesheets/bootstrap/_theme.scss
index eb3a8f57..9c2a76cd 100644
--- a/assets/stylesheets/bootstrap/_theme.scss
+++ b/assets/stylesheets/bootstrap/_theme.scss
@@ -8,8 +8,8 @@
// Load core variables and mixins
// --------------------------------------------------
-@import "variables";
-@import "mixins";
+@import "bootstrap/variables";
+@import "bootstrap/mixins";
//
diff --git a/bootstrap-sass.gemspec b/bootstrap-sass.gemspec
index c8f833d9..1ab1786f 100644
--- a/bootstrap-sass.gemspec
+++ b/bootstrap-sass.gemspec
@@ -11,14 +11,14 @@ Gem::Specification.new do |s|
s.homepage = 'https://github.com/twbs/bootstrap-sass'
s.license = 'MIT'
- s.add_runtime_dependency 'sass', '>= 3.3.4'
+ s.add_runtime_dependency 'sassc', '>= 1.12.1'
s.add_runtime_dependency 'autoprefixer-rails', '>= 5.2.1'
# Testing dependencies
- s.add_development_dependency 'minitest', '~> 5.8'
- s.add_development_dependency 'minitest-reporters', '~> 1.1'
+ s.add_development_dependency 'minitest', '~> 5.11'
+ s.add_development_dependency 'minitest-reporters', '~> 1.3'
# Integration testing
- s.add_development_dependency 'capybara', '>= 2.5.0'
+ s.add_development_dependency 'capybara', '~> 3.6'
s.add_development_dependency 'poltergeist'
# Dummy Rails app dependencies
s.add_development_dependency 'actionpack', '>= 4.1.5'
diff --git a/lib/bootstrap-sass.rb b/lib/bootstrap-sass.rb
index bde132d4..a58e81cf 100644
--- a/lib/bootstrap-sass.rb
+++ b/lib/bootstrap-sass.rb
@@ -11,9 +11,12 @@ module Bootstrap
register_lotus
elsif sprockets?
register_sprockets
+ elsif defined?(::Sass) && ::Sass.respond_to?(:load_paths)
+ # The deprecated `sass` gem:
+ ::Sass.load_paths << stylesheets_path
+ # bootstrap requires minimum precision of 8, see https://github.com/twbs/bootstrap-sass/issues/409
+ ::Sass::Script::Number.precision = [8, ::Sass::Script::Number.precision].max
end
-
- configure_sass
end
# Paths
@@ -56,15 +59,6 @@ module Bootstrap
private
- def configure_sass
- require 'sass'
-
- ::Sass.load_paths << stylesheets_path
-
- # bootstrap requires minimum precision of 8, see https://github.com/twbs/bootstrap-sass/issues/409
- ::Sass::Script::Number.precision = [8, ::Sass::Script::Number.precision].max
- end
-
def register_compass_extension
::Compass::Frameworks.register(
'bootstrap',
diff --git a/tasks/converter/less_conversion.rb b/tasks/converter/less_conversion.rb
index c4eaed81..3ce692e4 100644
--- a/tasks/converter/less_conversion.rb
+++ b/tasks/converter/less_conversion.rb
@@ -124,6 +124,8 @@ class Converter
file = replace_all file, /(\s*)\.navbar-(right|left)\s*\{\s*@extend\s*\.pull-(right|left);\s*/, "\\1.navbar-\\2 {\\1 float: \\2 !important;\\1"
when 'tables.less'
file = replace_all file, /(@include\s*table-row-variant\()(\w+)/, "\\1'\\2'"
+ when 'theme.less'
+ file = replace_all file, /@import "/, '\0bootstrap/'
when 'thumbnails.less', 'labels.less', 'badges.less', 'buttons.less'
file = extract_nested_rule file, 'a&'
when 'glyphicons.less'
diff --git a/tasks/converter/network.rb b/tasks/converter/network.rb
index cc602760..aa62be5e 100644
--- a/tasks/converter/network.rb
+++ b/tasks/converter/network.rb
@@ -32,7 +32,7 @@ class Converter
if File.directory?(full_path)
files.each do |name|
path = "#{full_path}/#{name}"
- contents[name] = File.read(path, mode: 'rb') if File.exists?(path)
+ contents[name] = File.read(path, mode: 'rb') if File.exist?(path)
end
end
contents
@@ -51,7 +51,7 @@ class Converter
uri = URI(url)
cache_path = "./#@cache_path#{uri.path}#{uri.query.tr('?&=', '-') if uri.query}"
FileUtils.mkdir_p File.dirname(cache_path)
- if File.exists?(cache_path)
+ if File.exist?(cache_path)
log_http_get_file url, true
File.read(cache_path, mode: 'rb')
else
diff --git a/test/compilation_test.rb b/test/compilation_test.rb
index 6808813a..c44a97ac 100644
--- a/test/compilation_test.rb
+++ b/test/compilation_test.rb
@@ -1,13 +1,13 @@
require 'test_helper'
require 'fileutils'
-require 'sass'
+require 'sassc'
class CompilationTest < Minitest::Test
def test_compilation
path = 'assets/stylesheets'
%w(_bootstrap bootstrap/_theme).each do |file|
FileUtils.rm_rf('.sass-cache', secure: true)
- engine = Sass::Engine.for_file("#{path}/#{file}.scss", syntax: :scss, load_paths: [path])
+ engine = SassC::Engine.new(File.read("#{path}/#{file}.scss"), syntax: :scss, load_paths: [path])
FileUtils.mkdir_p("tmp/#{File.dirname(file)}")
File.open("tmp/#{file}.css", 'w') { |f|
f.write engine.render
diff --git a/test/dummy_rails/config/boot.rb b/test/dummy_rails/config/boot.rb
index ef360470..6266cfc5 100644
--- a/test/dummy_rails/config/boot.rb
+++ b/test/dummy_rails/config/boot.rb
@@ -1,5 +1,5 @@
# Set up gems listed in the Gemfile.
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../../../Gemfile', __FILE__)
-require 'bundler/setup' if File.exists?(ENV['BUNDLE_GEMFILE'])
+require 'bundler/setup' if File.exist?(ENV['BUNDLE_GEMFILE'])
$LOAD_PATH.unshift File.expand_path('../../../../lib', __FILE__)
diff --git a/test/dummy_sass_only/Gemfile b/test/dummy_sass_only/Gemfile
index bfde6fa1..784b2761 100644
--- a/test/dummy_sass_only/Gemfile
+++ b/test/dummy_sass_only/Gemfile
@@ -1,4 +1,4 @@
source 'https://rubygems.org'
-gem 'sass', '~> 3.3'
+gem 'sassc', '>= 1.12.1'
gem 'bootstrap-sass', path: '../..'
diff --git a/test/dummy_sass_only/compile.rb b/test/dummy_sass_only/compile.rb
index 09e67855..6253af11 100644
--- a/test/dummy_sass_only/compile.rb
+++ b/test/dummy_sass_only/compile.rb
@@ -1,13 +1,20 @@
-require 'sass'
+# frozen_string_literal: true
+
+require 'sassc'
require 'bootstrap-sass'
require 'fileutils'
-scss_path = File.expand_path('./import_all.sass', File.dirname(__FILE__))
-css = Sass.compile File.read(scss_path), syntax: 'sass'
+load_path = ARGV[0]
+out_path = ARGV[1]
+
+output = SassC::Engine.new(
+ File.read(File.expand_path('./import_all.scss', __dir__)),
+ syntax: :scss, load_paths: [load_path]
+).render
-if ARGV[0]
- FileUtils.mkdir_p File.dirname(ARGV[0])
- File.open(ARGV[0], 'w') { |f| f.write css }
+if out_path
+ FileUtils.mkdir_p(File.dirname(out_path))
+ File.write(out_path, output)
else
- puts css
+ puts output
end
diff --git a/test/dummy_sass_only/import_all.sass b/test/dummy_sass_only/import_all.sass
deleted file mode 100644
index a44a6e3b..00000000
--- a/test/dummy_sass_only/import_all.sass
+++ /dev/null
@@ -1,2 +0,0 @@
-@import 'bootstrap'
-@import 'bootstrap/theme' \ No newline at end of file
diff --git a/test/dummy_sass_only/import_all.scss b/test/dummy_sass_only/import_all.scss
new file mode 100644
index 00000000..f12e2230
--- /dev/null
+++ b/test/dummy_sass_only/import_all.scss
@@ -0,0 +1,2 @@
+@import 'bootstrap';
+@import 'bootstrap/theme';
diff --git a/test/sass_test.rb b/test/sass_test.rb
index fc54c77b..0cb43533 100644
--- a/test/sass_test.rb
+++ b/test/sass_test.rb
@@ -1,23 +1,25 @@
+# frozen_string_literal: true
+
require 'test_helper'
require 'shellwords'
+require 'fileutils'
class SassTest < Minitest::Test
DUMMY_PATH = 'test/dummy_sass_only'
def test_font_helper
- assert_match %r(url\(['"]?.*eot['"]?\)), @css
+ assert_match %r{url\(['"]?.*eot['"]?\)}, @css
end
def setup
- Dir.chdir DUMMY_PATH do
- %x[rm -rf .sass-cache/]
- %x[bundle]
- end
+ FileUtils.rm_rf(File.join(DUMMY_PATH, '.sass-cache'), secure: true)
css_path = File.join GEM_PATH, 'tmp/bootstrap-sass-only.css'
- command = "bundle exec ruby compile.rb #{Shellwords.escape css_path}"
success = Dir.chdir DUMMY_PATH do
silence_stdout_if !ENV['VERBOSE'] do
- system(command)
+ Bundler.with_original_env do
+ system('bundle') && system('bundle', 'exec', 'ruby', 'compile.rb',
+ Bootstrap.stylesheets_path, css_path)
+ end
end
end
assert success, 'Sass-only compilation failed'
diff --git a/test/sprockets_rails_test.rb b/test/sprockets_rails_test.rb
index 38707ca8..4969f289 100644
--- a/test/sprockets_rails_test.rb
+++ b/test/sprockets_rails_test.rb
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
require 'test_helper'
require 'fileutils'
require 'find'
@@ -6,22 +8,24 @@ require 'shellwords'
class SprocketsRailsTest < Minitest::Test
def test_sprockets_digest_asset_refs
- root = 'test/dummy_rails'
- command = "bundle exec rake assets:precompile GEMFILE=#{GEM_PATH}/Gemfile RAILS_ENV=production"
+ root = 'test/dummy_rails'
compiled = Dir.chdir root do
silence_stderr_if !ENV['VERBOSE'] do
- system(command)
+ Bundler.with_original_env do
+ system({ 'BUNDLE_GEMFILE' => File.join(GEM_PATH, 'Gemfile'),
+ 'RAILS_ENV' => 'production' },
+ 'bundle exec rake assets:precompile')
+ end
end
end
assert compiled, 'Could not precompile assets'
Dir.glob(File.join(root, 'public', 'assets', 'app*.{css,js}')) do |path|
- File.open(path, 'r') do |f|
- f.read.scan /url\("?[^"]+\.(?:jpg|png|eot|woff2?|ttf|svg)[^"]*"?\)/ do |m|
- assert_match /-[0-9a-f]{12,}\./, m
- end
+ File.read(path)
+ .scan(/url\("?[^"]+\.(?:jpg|png|eot|woff2?|ttf|svg)[^"]*"?\)/) do |m|
+ assert_match(/-[0-9a-f]{12,}\./, m)
end
end
ensure
- FileUtils.rm_rf %W(#{root}/public/assets/ #{root}/tmp/cache/), secure: true
+ FileUtils.rm_rf %W[#{root}/public/assets/ #{root}/tmp/cache/], secure: true
end
end
diff --git a/test/test_helper.rb b/test/test_helper.rb
index 304b2e0c..1e995a89 100644
--- a/test/test_helper.rb
+++ b/test/test_helper.rb
@@ -10,7 +10,7 @@ Dir['test/support/**/*.rb'].each do |file|
require_relative File.join('.', file)
end
-GEM_PATH = File.expand_path('../', File.dirname(__FILE__))
+GEM_PATH = File.expand_path('../', __dir__)
#= Capybara + Poltergeist
require 'capybara/poltergeist'
@@ -26,6 +26,7 @@ Capybara.register_driver :poltergeist do |app|
end
Capybara.configure do |config|
+ config.server = :webrick
config.app_host = 'http://localhost:7000'
config.default_driver = :poltergeist
config.javascript_driver = :poltergeist