sassc 2.1.0.pre1-x86-linux

Sign up to get free protection for your applications and to get access to all the features.
Files changed (58) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +17 -0
  3. data/.gitmodules +3 -0
  4. data/.travis.yml +11 -0
  5. data/CHANGELOG.md +66 -0
  6. data/CODE_OF_CONDUCT.md +10 -0
  7. data/Gemfile +2 -0
  8. data/LICENSE.txt +22 -0
  9. data/README.md +68 -0
  10. data/Rakefile +30 -0
  11. data/lib/sassc.rb +57 -0
  12. data/lib/sassc/dependency.rb +17 -0
  13. data/lib/sassc/engine.rb +139 -0
  14. data/lib/sassc/error.rb +37 -0
  15. data/lib/sassc/functions_handler.rb +75 -0
  16. data/lib/sassc/import_handler.rb +50 -0
  17. data/lib/sassc/importer.rb +31 -0
  18. data/lib/sassc/native.rb +70 -0
  19. data/lib/sassc/native/lib_c.rb +21 -0
  20. data/lib/sassc/native/native_context_api.rb +147 -0
  21. data/lib/sassc/native/native_functions_api.rb +164 -0
  22. data/lib/sassc/native/sass2scss_api.rb +10 -0
  23. data/lib/sassc/native/sass_input_style.rb +13 -0
  24. data/lib/sassc/native/sass_output_style.rb +12 -0
  25. data/lib/sassc/native/sass_value.rb +97 -0
  26. data/lib/sassc/native/string_list.rb +10 -0
  27. data/lib/sassc/sass_2_scss.rb +9 -0
  28. data/lib/sassc/script.rb +19 -0
  29. data/lib/sassc/script/functions.rb +8 -0
  30. data/lib/sassc/script/value.rb +137 -0
  31. data/lib/sassc/script/value/bool.rb +32 -0
  32. data/lib/sassc/script/value/color.rb +95 -0
  33. data/lib/sassc/script/value/list.rb +136 -0
  34. data/lib/sassc/script/value/map.rb +69 -0
  35. data/lib/sassc/script/value/number.rb +389 -0
  36. data/lib/sassc/script/value/string.rb +96 -0
  37. data/lib/sassc/script/value_conversion.rb +69 -0
  38. data/lib/sassc/script/value_conversion/base.rb +13 -0
  39. data/lib/sassc/script/value_conversion/bool.rb +13 -0
  40. data/lib/sassc/script/value_conversion/color.rb +18 -0
  41. data/lib/sassc/script/value_conversion/list.rb +25 -0
  42. data/lib/sassc/script/value_conversion/map.rb +21 -0
  43. data/lib/sassc/script/value_conversion/number.rb +13 -0
  44. data/lib/sassc/script/value_conversion/string.rb +17 -0
  45. data/lib/sassc/util.rb +231 -0
  46. data/lib/sassc/util/normalized_map.rb +117 -0
  47. data/lib/sassc/version.rb +5 -0
  48. data/sassc.gemspec +57 -0
  49. data/test/custom_importer_test.rb +127 -0
  50. data/test/engine_test.rb +314 -0
  51. data/test/error_test.rb +29 -0
  52. data/test/fixtures/paths.scss +10 -0
  53. data/test/functions_test.rb +303 -0
  54. data/test/native_test.rb +213 -0
  55. data/test/output_style_test.rb +107 -0
  56. data/test/sass_2_scss_test.rb +14 -0
  57. data/test/test_helper.rb +45 -0
  58. metadata +242 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: b061758cbf74fc360322b3f898ed3713b6c736b908abb277f424ac7076bf67ee
4
+ data.tar.gz: 6fb0b162a89e85615f42b2f2da1ef128b25114cbf5b9e3448f3131f9468c5538
5
+ SHA512:
6
+ metadata.gz: 5445a9dafba0aa2ed8942bf5f5103cbe80ace0e9532ca644c50a867866e491cd89cec28a3f52d4688792f501fc854fcf9e044ef95edb146a82f3f4160f8463e6
7
+ data.tar.gz: 92a4df2b15f0dd26c5364f826c4ba85bb74d168283e4c2ac37686fa032cb9ad4512a6aeffbc0c931a773176f0e912e0e217252d6349caf33f188895821ea4803
data/.gitignore ADDED
@@ -0,0 +1,17 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /.rvmrc
4
+ /Gemfile.lock
5
+ /_yardoc/
6
+ /coverage/
7
+ /doc/
8
+ /pkg/
9
+ /spec/reports/
10
+ /tmp/
11
+ *.bundle
12
+ *.so
13
+ *.o
14
+ *.a
15
+ *.gem
16
+ mkmf.log
17
+ vendor/bundle
data/.gitmodules ADDED
@@ -0,0 +1,3 @@
1
+ [submodule "ext/libsass"]
2
+ path = ext/libsass
3
+ url = https://github.com/sass/libsass.git
data/.travis.yml ADDED
@@ -0,0 +1,11 @@
1
+ language: ruby
2
+
3
+ bundler_args: "--binstubs --standalone --without documentation --path ../bundle"
4
+ script: "bundle exec rake test"
5
+ rvm:
6
+ - 2.3.8
7
+ - 2.4.5
8
+ - 2.5.3
9
+ - 2.6.1
10
+ notifications:
11
+ email: false
data/CHANGELOG.md ADDED
@@ -0,0 +1,66 @@
1
+ - **2.1.0.pre1**
2
+ - [Update Libsass to 3.6.0](https://github.com/sass/sassc-ruby/pull/96/files)
3
+ - [Support old Ruby versions](https://github.com/sass/sassc-ruby/pull/117/files)
4
+ - **2.0.1**
5
+ - [Relax FFI dependency](https://github.com/sass/sassc-ruby/pull/102)
6
+ - **2.0.0**
7
+ - [Remove dependency on Ruby Sass](https://github.com/sass/sassc-ruby/pull/85)
8
+ - [frozen_string_literal all files](https://github.com/sass/sassc-ruby/pull/85)
9
+ - **1.12.1**
10
+ - [Downgrade to libsass 3.5.2 to fix css imports](https://github.com/sass/sassc-ruby/pull/81)
11
+ - **1.12.0**
12
+ - [Update Libsass to 3.5.4](https://github.com/sass/sassc-ruby/pull/78)
13
+ - [bundler is a development dependency](https://github.com/sass/sassc-ruby/pull/51)
14
+ - **1.11.4**
15
+ - Fix `Value::List` related issue with sass 3.5.0
16
+ - **1.11.3**
17
+ - [Require Sass::Deprecation module](https://github.com/sass/sassc-ruby/pull/68)
18
+ - **1.11.2**
19
+ - [Update to libsass 3.4.3](https://github.com/sass/sassc-ruby/pull/65)
20
+ - **1.11.1**
21
+ - [Update to libsass 3.4.1](https://github.com/sass/sassc-ruby/pull/61)
22
+ - **1.11.0**
23
+ - [Add support for lists in functions](https://github.com/sass/sassc-ruby/pull/55)
24
+ - [Update to libsass 3.4.0](https://github.com/sass/sassc-ruby/pull/57)
25
+ - **1.10.1**
26
+ - [Add sourcemap getter](https://github.com/sass/sassc-ruby/pull/48)
27
+ - **1.10.0**
28
+ - [Improved error messages](https://github.com/sass/sassc-ruby/pull/34)
29
+ - Update to Libsass 3.3.6
30
+ - **1.9.0**
31
+ - Support boolean script support
32
+ - **1.8.5**
33
+ - Update to Libsass 3.3.4
34
+ - **1.8.4**
35
+ - Update to Libsass 3.3.3
36
+ - **1.8.3**
37
+ - [Passing empty string into engine does not raise error](https://github.com/sass/sassc-ruby/pull/31)
38
+ - **1.8.2**
39
+ - Update to Libsass 3.3.2
40
+ - **1.8.1**
41
+ - Update to Libsass 3.3.1
42
+ - **1.8.0**
43
+ - Update to Libsass 3.3.0
44
+ - **1.8.0.pre2**
45
+ - Fix bug with looking up gem_path
46
+ - **1.8.0.pre1**
47
+ - [Update to Libsass 3.3.0-beta3](https://github.com/sass/sassc-ruby/pull/20)
48
+ - **1.7.1**
49
+ - Some updates to `Engine` API.
50
+ - **1.7.0**
51
+ - [Support Precision](https://github.com/sass/sassc-ruby/pull/19)
52
+ - **1.6.0**
53
+ - [Support Sass Color types](https://github.com/bolandrm/sassc-ruby/pull/14)
54
+ - [Support quoted strings](https://github.com/bolandrm/sassc-ruby/pull/13)
55
+ - [Improve custom function error handling](https://github.com/bolandrm/sassc-ruby/pull/15)
56
+ - **1.5.1**
57
+ - 2nd attempt at fixing compilation bug (issue [#12](https://github.com/bolandrm/sassc-ruby/issues/12))
58
+ - **1.5.0**
59
+ - Add support for inline source maps
60
+ - Fix compilation bug (issue [#12](https://github.com/bolandrm/sassc-ruby/issues/12))
61
+ - **1.4.0**
62
+ - Add support for line number comments
63
+ - **1.3.0**
64
+ - Support Sass color custom function arguments
65
+ - Adds error handling for exceptions in custom functions
66
+ - Custom functions may have optional/default arguments
@@ -0,0 +1,10 @@
1
+ Sass is more than a technology; Sass is driven by the community of individuals
2
+ that power its development and use every day. As a community, we want to embrace
3
+ the very differences that have made our collaboration so powerful, and work
4
+ together to provide the best environment for learning, growing, and sharing of
5
+ ideas. It is imperative that we keep Sass a fun, welcoming, challenging, and
6
+ fair place to play.
7
+
8
+ [The full community guidelines can be found on the Sass website.][link]
9
+
10
+ [link]: https://sass-lang.com/community-guidelines
data/Gemfile ADDED
@@ -0,0 +1,2 @@
1
+ source "https://rubygems.org"
2
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) Ryan Boland & Contributors
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,68 @@
1
+ # SassC [![Build Status](https://travis-ci.org/sass/sassc-ruby.svg?branch=master)](https://travis-ci.org/sass/sassc-ruby) [![Gem Version](https://badge.fury.io/rb/sassc.svg)](http://badge.fury.io/rb/sassc)
2
+
3
+ Use `libsass` with Ruby!
4
+
5
+ This gem combines the speed of `libsass`, the [Sass C implementation](https://github.com/sass/libsass), with the ease of use of the original [Ruby Sass](https://github.com/sass/ruby-sass) library.
6
+
7
+ ### libsass Version
8
+
9
+ [3.6.0](https://github.com/sass/libsass/releases/3.6.0)
10
+
11
+ ## Installation
12
+
13
+ Add this line to your application's Gemfile:
14
+
15
+ ```ruby
16
+ gem 'sassc'
17
+ ```
18
+
19
+ And then execute:
20
+
21
+ ```bash
22
+ bundle
23
+ ```
24
+
25
+ Or install it yourself as:
26
+
27
+ ```bash
28
+ gem install sassc
29
+ ```
30
+
31
+ ## Usage
32
+
33
+ This library utilizes `libsass` to allow you to compile SCSS or SASS syntax
34
+ to CSS. To compile, use a `SassC::Engine`, e.g.:
35
+
36
+ ```ruby
37
+ SassC::Engine.new(sass, style: :compressed).render
38
+ ```
39
+
40
+ **Note**: If you want to use this library with Rails/Sprockets, check out
41
+ [sassc-rails](https://github.com/bolandrm/sassc-rails).
42
+
43
+ Additionally, you can use `SassC::Sass2Scss` to convert Sass syntax to Scss syntax.
44
+
45
+ ## Credits
46
+
47
+ This gem is maintained by [Ryan Boland](https://ryanboland.com)
48
+ and [awesome contributors](https://github.com/bolandrm/sassc-ruby/graphs/contributors).
49
+
50
+ ## Changelog
51
+
52
+ See [CHANGELOG.md](CHANGELOG.md).
53
+
54
+ ## Contributing
55
+
56
+ ### Project Setup
57
+
58
+ 1. Clone repo
59
+ 1. Install dependencies - `bundle install`
60
+ 1. Run the tests - `bundle exec rake test`
61
+
62
+ ### Code Changes
63
+
64
+ 1. Fork it ( https://github.com/sass/sassc-ruby/fork )
65
+ 1. Create your feature branch (`git checkout -b my-new-feature`)
66
+ 1. Commit your changes (`git commit -am 'Add some feature'`) - try to include tests
67
+ 1. Push to the branch (`git push origin my-new-feature`)
68
+ 1. Create a new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,30 @@
1
+ require 'bundler/gem_tasks'
2
+
3
+ task default: :test
4
+
5
+ require 'rake/extensiontask'
6
+ gem_spec = Gem::Specification.load("sassc.gemspec")
7
+ Rake::ExtensionTask.new('libsass', gem_spec) do |ext|
8
+ ext.name = 'libsass'
9
+ ext.ext_dir = 'ext'
10
+ ext.lib_dir = 'lib/sassc'
11
+ ext.cross_compile = true
12
+ ext.cross_platform = %w[x86-mingw32 x64-mingw32 x86-linux x86_64-linux]
13
+ ext.cross_compiling do |spec|
14
+ spec.files.reject! { |path| File.fnmatch?('ext/*', path) }
15
+ end
16
+ end
17
+
18
+ desc 'Compile all native gems via rake-compiler-dock (Docker)'
19
+ task 'gem:native' do
20
+ require 'rake_compiler_dock'
21
+ RakeCompilerDock.sh "bundle && gem i rake --no-document && "\
22
+ "rake cross native gem MAKE='nice make -j`nproc`' "\
23
+ "RUBY_CC_VERSION=2.6.0:2.5.0:2.4.0:2.3.0"
24
+ end
25
+
26
+ desc "Run all tests"
27
+ task test: 'compile:libsass' do
28
+ $LOAD_PATH.unshift('lib', 'test')
29
+ Dir.glob('./test/**/*_test.rb') { |f| require f }
30
+ end
data/lib/sassc.rb ADDED
@@ -0,0 +1,57 @@
1
+ # frozen_string_literal: true
2
+
3
+ module SassC
4
+ # The global load paths for Sass files. This is meant for plugins and
5
+ # libraries to register the paths to their Sass stylesheets to that they may
6
+ # be `@imported`. This load path is used by every instance of {Sass::Engine}.
7
+ # They are lower-precedence than any load paths passed in via the
8
+ # {file:SASS_REFERENCE.md#load_paths-option `:load_paths` option}.
9
+ #
10
+ # If the `SASS_PATH` environment variable is set,
11
+ # the initial value of `load_paths` will be initialized based on that.
12
+ # The variable should be a colon-separated list of path names
13
+ # (semicolon-separated on Windows).
14
+ #
15
+ # Note that files on the global load path are never compiled to CSS
16
+ # themselves, even if they aren't partials. They exist only to be imported.
17
+ #
18
+ # @example
19
+ # SassC.load_paths << File.dirname(__FILE__ + '/sass')
20
+ # @return [Array<String, Pathname, Sass::Importers::Base>]
21
+ def self.load_paths
22
+ @load_paths ||= if ENV['SASS_PATH']
23
+ ENV['SASS_PATH'].split(SassC::Util.windows? ? ';' : ':')
24
+ else
25
+ []
26
+ end
27
+ end
28
+ end
29
+
30
+ require_relative "sassc/version"
31
+ require_relative "sassc/native"
32
+ require_relative "sassc/import_handler"
33
+ require_relative "sassc/importer"
34
+ require_relative "sassc/util"
35
+ require_relative "sassc/util/normalized_map"
36
+ require_relative "sassc/script"
37
+ require_relative "sassc/script/value"
38
+ require_relative "sassc/script/value/bool"
39
+ require_relative "sassc/script/value/number"
40
+ require_relative "sassc/script/value/color"
41
+ require_relative "sassc/script/value/string"
42
+ require_relative "sassc/script/value/list"
43
+ require_relative "sassc/script/value/map"
44
+ require_relative "sassc/script/functions"
45
+ require_relative "sassc/script/value_conversion"
46
+ require_relative "sassc/script/value_conversion/base"
47
+ require_relative "sassc/script/value_conversion/string"
48
+ require_relative "sassc/script/value_conversion/number"
49
+ require_relative "sassc/script/value_conversion/color"
50
+ require_relative "sassc/script/value_conversion/map"
51
+ require_relative "sassc/script/value_conversion/list"
52
+ require_relative "sassc/script/value_conversion/bool"
53
+ require_relative "sassc/functions_handler"
54
+ require_relative "sassc/dependency"
55
+ require_relative "sassc/error"
56
+ require_relative "sassc/engine"
57
+ require_relative "sassc/sass_2_scss"
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+
3
+ module SassC
4
+ class Dependency
5
+ attr_reader :filename
6
+ attr_reader :options
7
+
8
+ def initialize(filename)
9
+ @filename = filename
10
+ @options = { filename: @filename }
11
+ end
12
+
13
+ def self.from_filenames(filenames)
14
+ filenames.map { |f| new(f) }
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,139 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "error"
4
+
5
+ module SassC
6
+ class Engine
7
+ OUTPUT_STYLES = %i[
8
+ sass_style_nested
9
+ sass_style_expanded
10
+ sass_style_compact
11
+ sass_style_compressed
12
+ ]
13
+
14
+ attr_reader :template, :options
15
+
16
+ def initialize(template, options = {})
17
+ @template = template
18
+ @options = options
19
+ end
20
+
21
+ def render
22
+ return @template.dup if @template.empty?
23
+
24
+ data_context = Native.make_data_context(@template)
25
+ context = Native.data_context_get_context(data_context)
26
+ native_options = Native.context_get_options(context)
27
+
28
+ Native.option_set_is_indented_syntax_src(native_options, true) if sass?
29
+ Native.option_set_input_path(native_options, filename) if filename
30
+ Native.option_set_precision(native_options, precision) if precision
31
+ Native.option_set_include_path(native_options, load_paths)
32
+ Native.option_set_output_style(native_options, output_style_enum)
33
+ Native.option_set_source_comments(native_options, true) if line_comments?
34
+ Native.option_set_source_map_file(native_options, source_map_file) if source_map_file
35
+ Native.option_set_source_map_embed(native_options, true) if source_map_embed?
36
+ Native.option_set_source_map_contents(native_options, true) if source_map_contents?
37
+ Native.option_set_omit_source_map_url(native_options, true) if omit_source_map_url?
38
+
39
+ import_handler.setup(native_options)
40
+ functions_handler.setup(native_options)
41
+
42
+ status = Native.compile_data_context(data_context)
43
+
44
+ if status != 0
45
+ message = Native.context_get_error_message(context)
46
+ filename = Native.context_get_error_file(context)
47
+ line = Native.context_get_error_line(context)
48
+
49
+ raise SyntaxError.new(message, filename: filename, line: line)
50
+ end
51
+
52
+ css = Native.context_get_output_string(context)
53
+
54
+ @dependencies = Native.context_get_included_files(context)
55
+ @source_map = Native.context_get_source_map_string(context)
56
+
57
+ Native.delete_data_context(data_context)
58
+
59
+ css.force_encoding(@template.encoding)
60
+
61
+ return css unless quiet?
62
+ end
63
+
64
+ def dependencies
65
+ raise NotRenderedError unless @dependencies
66
+ Dependency.from_filenames(@dependencies)
67
+ end
68
+
69
+ def source_map
70
+ raise NotRenderedError unless @source_map
71
+ @source_map
72
+ end
73
+
74
+ def filename
75
+ @options[:filename]
76
+ end
77
+
78
+ private
79
+
80
+ def quiet?
81
+ @options[:quiet]
82
+ end
83
+
84
+ def precision
85
+ @options[:precision]
86
+ end
87
+
88
+ def sass?
89
+ @options[:syntax] && @options[:syntax].to_sym == :sass
90
+ end
91
+
92
+ def line_comments?
93
+ @options[:line_comments]
94
+ end
95
+
96
+ def source_map_embed?
97
+ @options[:source_map_embed]
98
+ end
99
+
100
+ def source_map_contents?
101
+ @options[:source_map_contents]
102
+ end
103
+
104
+ def omit_source_map_url?
105
+ @options[:omit_source_map_url]
106
+ end
107
+
108
+ def source_map_file
109
+ @options[:source_map_file]
110
+ end
111
+
112
+ def import_handler
113
+ @import_handler ||= ImportHandler.new(@options)
114
+ end
115
+
116
+ def functions_handler
117
+ @functions_handler = FunctionsHandler.new(@options)
118
+ end
119
+
120
+ def output_style_enum
121
+ @output_style_enum ||= Native::SassOutputStyle[output_style]
122
+ end
123
+
124
+ def output_style
125
+ @output_style ||= begin
126
+ style = @options.fetch(:style, :sass_style_nested).to_s
127
+ style = "sass_style_#{style}" unless style.include?("sass_style_")
128
+ style = style.to_sym
129
+ raise InvalidStyleError unless Native::SassOutputStyle.symbols.include?(style)
130
+ style
131
+ end
132
+ end
133
+
134
+ def load_paths
135
+ paths = (@options[:load_paths] || []) + SassC.load_paths
136
+ paths.join(File::PATH_SEPARATOR) unless paths.empty?
137
+ end
138
+ end
139
+ end