sass 3.7.4 → 4.0.0.alpha.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (257) hide show
  1. checksums.yaml +13 -5
  2. data/.yardopts +1 -1
  3. data/CODE_OF_CONDUCT.md +1 -1
  4. data/CONTRIBUTING.md +1 -146
  5. data/MIT-LICENSE +1 -1
  6. data/README.md +25 -39
  7. data/Rakefile +274 -0
  8. data/VERSION +1 -1
  9. data/VERSION_DATE +1 -1
  10. data/lib/sass.rb +3 -3
  11. data/lib/sass/cache_stores/filesystem.rb +2 -2
  12. data/lib/sass/cache_stores/memory.rb +5 -4
  13. data/lib/sass/callbacks.rb +2 -2
  14. data/lib/sass/css.rb +12 -12
  15. data/lib/sass/engine.rb +44 -62
  16. data/lib/sass/environment.rb +7 -35
  17. data/lib/sass/error.rb +14 -14
  18. data/lib/sass/exec/base.rb +14 -3
  19. data/lib/sass/exec/sass_convert.rb +6 -20
  20. data/lib/sass/exec/sass_scss.rb +29 -5
  21. data/lib/sass/features.rb +2 -3
  22. data/lib/sass/importers/filesystem.rb +6 -11
  23. data/lib/sass/logger.rb +3 -8
  24. data/lib/sass/logger/base.rb +2 -19
  25. data/lib/sass/plugin.rb +2 -3
  26. data/lib/sass/plugin/compiler.rb +67 -48
  27. data/lib/sass/plugin/configuration.rb +3 -3
  28. data/lib/sass/plugin/merb.rb +1 -1
  29. data/lib/sass/plugin/rack.rb +3 -3
  30. data/lib/sass/plugin/staleness_checker.rb +3 -3
  31. data/lib/sass/railtie.rb +1 -1
  32. data/lib/sass/script.rb +3 -3
  33. data/lib/sass/script/css_parser.rb +15 -5
  34. data/lib/sass/script/functions.rb +121 -337
  35. data/lib/sass/script/lexer.rb +36 -102
  36. data/lib/sass/script/parser.rb +153 -529
  37. data/lib/sass/script/tree/funcall.rb +34 -42
  38. data/lib/sass/script/tree/interpolation.rb +26 -171
  39. data/lib/sass/script/tree/list_literal.rb +8 -23
  40. data/lib/sass/script/tree/map_literal.rb +2 -2
  41. data/lib/sass/script/tree/node.rb +3 -3
  42. data/lib/sass/script/tree/operation.rb +16 -43
  43. data/lib/sass/script/tree/string_interpolation.rb +43 -64
  44. data/lib/sass/script/tree/variable.rb +1 -1
  45. data/lib/sass/script/value.rb +0 -2
  46. data/lib/sass/script/value/arg_list.rb +1 -1
  47. data/lib/sass/script/value/base.rb +9 -27
  48. data/lib/sass/script/value/color.rb +18 -26
  49. data/lib/sass/script/value/helpers.rb +18 -44
  50. data/lib/sass/script/value/list.rb +14 -35
  51. data/lib/sass/script/value/map.rb +2 -2
  52. data/lib/sass/script/value/number.rb +16 -26
  53. data/lib/sass/script/value/string.rb +1 -30
  54. data/lib/sass/scss.rb +2 -0
  55. data/lib/sass/scss/css_parser.rb +3 -7
  56. data/lib/sass/scss/parser.rb +78 -196
  57. data/lib/sass/scss/rx.rb +14 -7
  58. data/lib/sass/scss/script_lexer.rb +15 -0
  59. data/lib/sass/scss/script_parser.rb +25 -0
  60. data/lib/sass/scss/static_parser.rb +55 -38
  61. data/lib/sass/selector.rb +10 -7
  62. data/lib/sass/selector/abstract_sequence.rb +12 -15
  63. data/lib/sass/selector/comma_sequence.rb +6 -24
  64. data/lib/sass/selector/pseudo.rb +6 -19
  65. data/lib/sass/selector/sequence.rb +16 -14
  66. data/lib/sass/selector/simple.rb +7 -9
  67. data/lib/sass/selector/simple_sequence.rb +12 -16
  68. data/lib/sass/shared.rb +1 -1
  69. data/lib/sass/source/map.rb +9 -7
  70. data/lib/sass/source/position.rb +4 -4
  71. data/lib/sass/stack.rb +3 -23
  72. data/lib/sass/tree/charset_node.rb +1 -1
  73. data/lib/sass/tree/comment_node.rb +1 -1
  74. data/lib/sass/tree/function_node.rb +3 -2
  75. data/lib/sass/tree/node.rb +3 -5
  76. data/lib/sass/tree/prop_node.rb +58 -49
  77. data/lib/sass/tree/rule_node.rb +8 -15
  78. data/lib/sass/tree/visitors/check_nesting.rb +23 -19
  79. data/lib/sass/tree/visitors/convert.rb +13 -15
  80. data/lib/sass/tree/visitors/cssize.rb +15 -4
  81. data/lib/sass/tree/visitors/deep_copy.rb +2 -2
  82. data/lib/sass/tree/visitors/extend.rb +14 -10
  83. data/lib/sass/tree/visitors/perform.rb +18 -29
  84. data/lib/sass/tree/visitors/set_options.rb +2 -2
  85. data/lib/sass/tree/visitors/to_css.rb +47 -77
  86. data/lib/sass/util.rb +311 -98
  87. data/lib/sass/util/cross_platform_random.rb +19 -0
  88. data/lib/sass/util/multibyte_string_scanner.rb +133 -127
  89. data/lib/sass/util/normalized_map.rb +8 -1
  90. data/lib/sass/util/ordered_hash.rb +192 -0
  91. data/lib/sass/version.rb +6 -2
  92. data/test/sass/cache_test.rb +131 -0
  93. data/test/sass/callbacks_test.rb +61 -0
  94. data/test/sass/compiler_test.rb +236 -0
  95. data/test/sass/conversion_test.rb +2171 -0
  96. data/test/sass/css2sass_test.rb +526 -0
  97. data/test/sass/data/hsl-rgb.txt +319 -0
  98. data/test/sass/encoding_test.rb +219 -0
  99. data/test/sass/engine_test.rb +3400 -0
  100. data/test/sass/exec_test.rb +86 -0
  101. data/test/sass/extend_test.rb +1719 -0
  102. data/test/sass/fixtures/test_staleness_check_across_importers.css +1 -0
  103. data/test/sass/fixtures/test_staleness_check_across_importers.scss +1 -0
  104. data/test/sass/functions_test.rb +1984 -0
  105. data/test/sass/importer_test.rb +421 -0
  106. data/test/sass/logger_test.rb +58 -0
  107. data/test/sass/mock_importer.rb +49 -0
  108. data/test/sass/more_results/more1.css +9 -0
  109. data/test/sass/more_results/more1_with_line_comments.css +26 -0
  110. data/test/sass/more_results/more_import.css +29 -0
  111. data/test/sass/more_templates/_more_partial.sass +2 -0
  112. data/test/sass/more_templates/more1.sass +23 -0
  113. data/test/sass/more_templates/more_import.sass +11 -0
  114. data/test/sass/plugin_test.rb +556 -0
  115. data/test/sass/results/alt.css +4 -0
  116. data/test/sass/results/basic.css +9 -0
  117. data/test/sass/results/cached_import_option.css +3 -0
  118. data/test/sass/results/compact.css +5 -0
  119. data/test/sass/results/complex.css +86 -0
  120. data/test/sass/results/compressed.css +1 -0
  121. data/test/sass/results/expanded.css +19 -0
  122. data/test/sass/results/filename_fn.css +3 -0
  123. data/test/sass/results/if.css +3 -0
  124. data/test/sass/results/import.css +31 -0
  125. data/test/sass/results/import_charset.css +5 -0
  126. data/test/sass/results/import_charset_1_8.css +5 -0
  127. data/test/sass/results/import_charset_ibm866.css +5 -0
  128. data/test/sass/results/import_content.css +1 -0
  129. data/test/sass/results/line_numbers.css +49 -0
  130. data/test/sass/results/mixins.css +95 -0
  131. data/test/sass/results/multiline.css +24 -0
  132. data/test/sass/results/nested.css +22 -0
  133. data/test/sass/results/options.css +1 -0
  134. data/test/sass/results/parent_ref.css +13 -0
  135. data/test/sass/results/script.css +16 -0
  136. data/test/sass/results/scss_import.css +31 -0
  137. data/test/sass/results/scss_importee.css +2 -0
  138. data/test/sass/results/subdir/nested_subdir/nested_subdir.css +1 -0
  139. data/test/sass/results/subdir/subdir.css +3 -0
  140. data/test/sass/results/units.css +11 -0
  141. data/test/sass/results/warn.css +0 -0
  142. data/test/sass/results/warn_imported.css +0 -0
  143. data/test/sass/script_conversion_test.rb +306 -0
  144. data/test/sass/script_test.rb +1206 -0
  145. data/test/sass/scss/css_test.rb +1281 -0
  146. data/test/sass/scss/rx_test.rb +160 -0
  147. data/test/sass/scss/scss_test.rb +4147 -0
  148. data/test/sass/scss/test_helper.rb +37 -0
  149. data/test/sass/source_map_test.rb +1055 -0
  150. data/test/sass/superselector_test.rb +210 -0
  151. data/test/sass/templates/_cached_import_option_partial.scss +1 -0
  152. data/test/sass/templates/_double_import_loop2.sass +1 -0
  153. data/test/sass/templates/_filename_fn_import.scss +11 -0
  154. data/test/sass/templates/_imported_charset_ibm866.sass +4 -0
  155. data/test/sass/templates/_imported_charset_utf8.sass +4 -0
  156. data/test/sass/templates/_imported_content.sass +3 -0
  157. data/test/sass/templates/_partial.sass +2 -0
  158. data/test/sass/templates/_same_name_different_partiality.scss +1 -0
  159. data/test/sass/templates/alt.sass +16 -0
  160. data/test/sass/templates/basic.sass +23 -0
  161. data/test/sass/templates/bork1.sass +2 -0
  162. data/test/sass/templates/bork2.sass +2 -0
  163. data/test/sass/templates/bork3.sass +2 -0
  164. data/test/sass/templates/bork4.sass +2 -0
  165. data/test/sass/templates/bork5.sass +3 -0
  166. data/test/sass/templates/cached_import_option.scss +3 -0
  167. data/test/sass/templates/compact.sass +17 -0
  168. data/test/sass/templates/complex.sass +305 -0
  169. data/test/sass/templates/compressed.sass +15 -0
  170. data/test/sass/templates/double_import_loop1.sass +1 -0
  171. data/test/sass/templates/expanded.sass +17 -0
  172. data/test/sass/templates/filename_fn.scss +18 -0
  173. data/test/sass/templates/if.sass +11 -0
  174. data/test/sass/templates/import.sass +12 -0
  175. data/test/sass/templates/import_charset.sass +9 -0
  176. data/test/sass/templates/import_charset_1_8.sass +6 -0
  177. data/test/sass/templates/import_charset_ibm866.sass +11 -0
  178. data/test/sass/templates/import_content.sass +4 -0
  179. data/test/sass/templates/importee.less +2 -0
  180. data/test/sass/templates/importee.sass +19 -0
  181. data/test/sass/templates/line_numbers.sass +13 -0
  182. data/test/sass/templates/mixin_bork.sass +5 -0
  183. data/test/sass/templates/mixins.sass +76 -0
  184. data/test/sass/templates/multiline.sass +20 -0
  185. data/test/sass/templates/nested.sass +25 -0
  186. data/test/sass/templates/nested_bork1.sass +2 -0
  187. data/test/sass/templates/nested_bork2.sass +2 -0
  188. data/test/sass/templates/nested_bork3.sass +2 -0
  189. data/test/sass/templates/nested_bork4.sass +2 -0
  190. data/test/sass/templates/nested_import.sass +2 -0
  191. data/test/sass/templates/nested_mixin_bork.sass +6 -0
  192. data/test/sass/templates/options.sass +2 -0
  193. data/test/sass/templates/parent_ref.sass +25 -0
  194. data/test/sass/templates/same_name_different_ext.sass +2 -0
  195. data/test/sass/templates/same_name_different_ext.scss +1 -0
  196. data/test/sass/templates/same_name_different_partiality.scss +1 -0
  197. data/test/sass/templates/script.sass +101 -0
  198. data/test/sass/templates/scss_import.scss +12 -0
  199. data/test/sass/templates/scss_importee.scss +1 -0
  200. data/test/sass/templates/single_import_loop.sass +1 -0
  201. data/test/sass/templates/subdir/import_up1.scss +1 -0
  202. data/test/sass/templates/subdir/import_up2.scss +1 -0
  203. data/test/sass/templates/subdir/nested_subdir/_nested_partial.sass +2 -0
  204. data/test/sass/templates/subdir/nested_subdir/nested_subdir.sass +3 -0
  205. data/test/sass/templates/subdir/subdir.sass +6 -0
  206. data/test/sass/templates/units.sass +11 -0
  207. data/test/sass/templates/warn.sass +3 -0
  208. data/test/sass/templates/warn_imported.sass +4 -0
  209. data/test/sass/test_helper.rb +8 -0
  210. data/test/sass/util/multibyte_string_scanner_test.rb +147 -0
  211. data/test/sass/util/normalized_map_test.rb +51 -0
  212. data/test/sass/util/subset_map_test.rb +91 -0
  213. data/test/sass/util_test.rb +438 -0
  214. data/test/sass/value_helpers_test.rb +179 -0
  215. data/test/test_helper.rb +110 -0
  216. data/vendor/listen/CHANGELOG.md +1 -0
  217. data/vendor/listen/CONTRIBUTING.md +38 -0
  218. data/vendor/listen/Gemfile +20 -0
  219. data/vendor/listen/Guardfile +8 -0
  220. data/vendor/listen/LICENSE +20 -0
  221. data/vendor/listen/README.md +349 -0
  222. data/vendor/listen/Rakefile +5 -0
  223. data/vendor/listen/Vagrantfile +96 -0
  224. data/vendor/listen/lib/listen.rb +54 -0
  225. data/vendor/listen/lib/listen/adapter.rb +327 -0
  226. data/vendor/listen/lib/listen/adapters/bsd.rb +75 -0
  227. data/vendor/listen/lib/listen/adapters/darwin.rb +48 -0
  228. data/vendor/listen/lib/listen/adapters/linux.rb +81 -0
  229. data/vendor/listen/lib/listen/adapters/polling.rb +58 -0
  230. data/vendor/listen/lib/listen/adapters/windows.rb +91 -0
  231. data/vendor/listen/lib/listen/directory_record.rb +406 -0
  232. data/vendor/listen/lib/listen/listener.rb +323 -0
  233. data/vendor/listen/lib/listen/turnstile.rb +32 -0
  234. data/vendor/listen/lib/listen/version.rb +3 -0
  235. data/vendor/listen/listen.gemspec +28 -0
  236. data/vendor/listen/spec/listen/adapter_spec.rb +149 -0
  237. data/vendor/listen/spec/listen/adapters/bsd_spec.rb +36 -0
  238. data/vendor/listen/spec/listen/adapters/darwin_spec.rb +37 -0
  239. data/vendor/listen/spec/listen/adapters/linux_spec.rb +47 -0
  240. data/vendor/listen/spec/listen/adapters/polling_spec.rb +68 -0
  241. data/vendor/listen/spec/listen/adapters/windows_spec.rb +30 -0
  242. data/vendor/listen/spec/listen/directory_record_spec.rb +1250 -0
  243. data/vendor/listen/spec/listen/listener_spec.rb +258 -0
  244. data/vendor/listen/spec/listen/turnstile_spec.rb +56 -0
  245. data/vendor/listen/spec/listen_spec.rb +67 -0
  246. data/vendor/listen/spec/spec_helper.rb +25 -0
  247. data/vendor/listen/spec/support/adapter_helper.rb +666 -0
  248. data/vendor/listen/spec/support/directory_record_helper.rb +57 -0
  249. data/vendor/listen/spec/support/fixtures_helper.rb +29 -0
  250. data/vendor/listen/spec/support/listeners_helper.rb +179 -0
  251. data/vendor/listen/spec/support/platform_helper.rb +15 -0
  252. metadata +217 -76
  253. data/extra/sass-spec-ref.sh +0 -40
  254. data/lib/sass/deprecation.rb +0 -55
  255. data/lib/sass/logger/delayed.rb +0 -50
  256. data/lib/sass/script/value/callable.rb +0 -25
  257. data/lib/sass/script/value/function.rb +0 -19
data/VERSION CHANGED
@@ -1 +1 @@
1
- 3.7.4
1
+ 4.0.0.alpha.1
@@ -1 +1 @@
1
- 04 April 2019 00:49:58 UTC
1
+ 09 December 2015 23:19:20 UTC
@@ -47,7 +47,7 @@ module Sass
47
47
  #
48
48
  # @param contents [String] The contents of the Sass file.
49
49
  # @param options [{Symbol => Object}] An options hash;
50
- # see {file:SASS_REFERENCE.md#Options the Sass options documentation}
50
+ # see {file:SASS_REFERENCE.md#options the Sass options documentation}
51
51
  # @raise [Sass::SyntaxError] if there's an error in the document
52
52
  # @raise [Encoding::UndefinedConversionError] if the source encoding
53
53
  # cannot be converted to UTF-8
@@ -69,7 +69,7 @@ module Sass
69
69
  #
70
70
  # @param filename [String] The path to the Sass, SCSS, or CSS file on disk.
71
71
  # @param options [{Symbol => Object}] An options hash;
72
- # see {file:SASS_REFERENCE.md#Options the Sass options documentation}
72
+ # see {file:SASS_REFERENCE.md#options the Sass options documentation}
73
73
  # @return [String] The compiled CSS.
74
74
  #
75
75
  # @overload compile_file(filename, css_filename, options = {})
@@ -77,7 +77,7 @@ module Sass
77
77
  #
78
78
  # @param filename [String] The path to the Sass, SCSS, or CSS file on disk.
79
79
  # @param options [{Symbol => Object}] An options hash;
80
- # see {file:SASS_REFERENCE.md#Options the Sass options documentation}
80
+ # see {file:SASS_REFERENCE.md#options the Sass options documentation}
81
81
  # @param css_filename [String] The location to which to write the compiled CSS.
82
82
  def self.compile_file(filename, *args)
83
83
  options = args.last.is_a?(Hash) ? args.pop : {}
@@ -36,7 +36,7 @@ module Sass
36
36
  def _store(key, version, sha, contents)
37
37
  compiled_filename = path_to(key)
38
38
  FileUtils.mkdir_p(File.dirname(compiled_filename))
39
- Sass::Util.atomic_create_and_write_file(compiled_filename) do |f|
39
+ Sass::Util.atomic_create_and_write_file(compiled_filename, 0600) do |f|
40
40
  f.puts(version)
41
41
  f.puts(sha)
42
42
  f.write(contents)
@@ -52,7 +52,7 @@ module Sass
52
52
  # @param key [String]
53
53
  # @return [String] The path to the cache file.
54
54
  def path_to(key)
55
- key = key.gsub(/[<>:\\|?*%]/) {|c| "%%%03d" % c.ord}
55
+ key = key.gsub(/[<>:\\|?*%]/) {|c| "%%%03d" % Sass::Util.ord(c)}
56
56
  File.join(cache_location, key)
57
57
  end
58
58
  end
@@ -26,10 +26,11 @@ module Sass
26
26
 
27
27
  # @see Base#retrieve
28
28
  def retrieve(key, sha)
29
- return unless @contents.has_key?(key)
30
- return unless @contents[key][:sha] == sha
31
- obj = @contents[key][:obj]
32
- obj.respond_to?(:deep_copy) ? obj.deep_copy : obj.dup
29
+ if @contents.has_key?(key)
30
+ return unless @contents[key][:sha] == sha
31
+ obj = @contents[key][:obj]
32
+ obj.respond_to?(:deep_copy) ? obj.deep_copy : obj.dup
33
+ end
33
34
  end
34
35
 
35
36
  # @see Base#store
@@ -51,12 +51,12 @@ module Sass
51
51
  def define_callback(name)
52
52
  class_eval <<RUBY, __FILE__, __LINE__ + 1
53
53
  def on_#{name}(&block)
54
- @_sass_callbacks = {} unless defined? @_sass_callbacks
54
+ @_sass_callbacks ||= {}
55
55
  (@_sass_callbacks[#{name.inspect}] ||= []) << block
56
56
  end
57
57
 
58
58
  def run_#{name}(*args)
59
- return unless defined? @_sass_callbacks
59
+ return unless @_sass_callbacks
60
60
  return unless @_sass_callbacks[#{name.inspect}]
61
61
  @_sass_callbacks[#{name.inspect}].each {|c| c[*args]}
62
62
  end
@@ -18,7 +18,7 @@ module Sass
18
18
  # that can be converted to Unicode.
19
19
  # If the stylesheet contains an `@charset` declaration,
20
20
  # that overrides the Ruby encoding
21
- # (see {file:SASS_REFERENCE.md#Encodings the encoding documentation})
21
+ # (see {file:SASS_REFERENCE.md#encodings the encoding documentation})
22
22
  # @option options :old [Boolean] (false)
23
23
  # Whether or not to output old property syntax
24
24
  # (`:color blue` as opposed to `color: blue`).
@@ -31,11 +31,10 @@ module Sass
31
31
  template = template.read
32
32
  end
33
33
 
34
- @options = options.merge(:_convert => true)
34
+ @options = options.dup
35
35
  # Backwards compatibility
36
36
  @options[:old] = true if @options[:alternate] == false
37
37
  @template = template
38
- @checked_encoding = false
39
38
  end
40
39
 
41
40
  # Converts the CSS template into Sass or SCSS code.
@@ -51,7 +50,8 @@ module Sass
51
50
  raise err
52
51
  end
53
52
 
54
- # Returns the original encoding of the document.
53
+ # Returns the original encoding of the document,
54
+ # or `nil` under Ruby 1.8.
55
55
  #
56
56
  # @return [Encoding, nil]
57
57
  # @raise [Encoding::UndefinedConversionError] if the source encoding
@@ -75,14 +75,14 @@ module Sass
75
75
  # @return [Tree::Node] The root node of the parsed tree
76
76
  def build_tree
77
77
  root = Sass::SCSS::CssParser.new(@template, @options[:filename], nil).parse
78
- parse_selectors(root)
79
- expand_commas(root)
80
- nest_seqs(root)
81
- parent_ref_rules(root)
82
- flatten_rules(root)
83
- bubble_subject(root)
84
- fold_commas(root)
85
- dump_selectors(root)
78
+ parse_selectors root
79
+ expand_commas root
80
+ nest_seqs root
81
+ parent_ref_rules root
82
+ flatten_rules root
83
+ bubble_subject root
84
+ fold_commas root
85
+ dump_selectors root
86
86
  root
87
87
  end
88
88
 
@@ -1,7 +1,6 @@
1
1
  require 'set'
2
2
  require 'digest/sha1'
3
3
  require 'sass/cache_stores'
4
- require 'sass/deprecation'
5
4
  require 'sass/source/position'
6
5
  require 'sass/source/range'
7
6
  require 'sass/source/map'
@@ -80,13 +79,7 @@ module Sass
80
79
  #
81
80
  # `type`: `String`
82
81
  # : The user-friendly name of the type of the callable.
83
- #
84
- # `origin`: `Symbol`
85
- # : From whence comes the callable: `:stylesheet`, `:builtin`, `:css`
86
- # A callable with an origin of `:stylesheet` was defined in the stylesheet itself.
87
- # A callable with an origin of `:builtin` was defined in ruby.
88
- # A callable (function) with an origin of `:css` returns a function call with arguments to CSS.
89
- Callable = Struct.new(:name, :args, :splat, :environment, :tree, :has_content, :type, :origin)
82
+ Callable = Struct.new(:name, :args, :splat, :environment, :tree, :has_content, :type)
90
83
 
91
84
  # This class handles the parsing and compilation of the Sass template.
92
85
  # Example usage:
@@ -96,20 +89,18 @@ module Sass
96
89
  # output = sass_engine.render
97
90
  # puts output
98
91
  class Engine
99
- @@old_property_deprecation = Deprecation.new
100
-
101
92
  # A line of Sass code.
102
93
  #
103
94
  # `text`: `String`
104
95
  # : The text in the line, without any whitespace at the beginning or end.
105
96
  #
106
- # `tabs`: `Integer`
97
+ # `tabs`: `Fixnum`
107
98
  # : The level of indentation of the line.
108
99
  #
109
- # `index`: `Integer`
100
+ # `index`: `Fixnum`
110
101
  # : The line number in the original document.
111
102
  #
112
- # `offset`: `Integer`
103
+ # `offset`: `Fixnum`
113
104
  # : The number of bytes in on the line that the text begins.
114
105
  # This ends up being the number of bytes of leading whitespace.
115
106
  #
@@ -177,11 +168,11 @@ module Sass
177
168
  # default values and resolving aliases.
178
169
  #
179
170
  # @param options [{Symbol => Object}] The options hash;
180
- # see {file:SASS_REFERENCE.md#Options the Sass options documentation}
171
+ # see {file:SASS_REFERENCE.md#options the Sass options documentation}
181
172
  # @return [{Symbol => Object}] The normalized options hash.
182
173
  # @private
183
174
  def self.normalize_options(options)
184
- options = DEFAULT_OPTIONS.merge(options.reject {|_k, v| v.nil?})
175
+ options = DEFAULT_OPTIONS.merge(options.reject {|k, v| v.nil?})
185
176
 
186
177
  # If the `:filename` option is passed in without an importer,
187
178
  # assume it's using the default filesystem importer.
@@ -231,7 +222,7 @@ module Sass
231
222
  #
232
223
  # @param filename [String] The path to the Sass or SCSS file
233
224
  # @param options [{Symbol => Object}] The options hash;
234
- # See {file:SASS_REFERENCE.md#Options the Sass options documentation}.
225
+ # See {file:SASS_REFERENCE.md#options the Sass options documentation}.
235
226
  # @return [Sass::Engine] The Engine for the given Sass or SCSS file.
236
227
  # @raise [Sass::SyntaxError] if there's an error in the document.
237
228
  def self.for_file(filename, options)
@@ -249,7 +240,7 @@ module Sass
249
240
  end
250
241
 
251
242
  # The options for the Sass engine.
252
- # See {file:SASS_REFERENCE.md#Options the Sass options documentation}.
243
+ # See {file:SASS_REFERENCE.md#options the Sass options documentation}.
253
244
  #
254
245
  # @return [{Symbol => Object}]
255
246
  attr_reader :options
@@ -266,17 +257,14 @@ module Sass
266
257
  # that can be converted to Unicode.
267
258
  # If the template contains an `@charset` declaration,
268
259
  # that overrides the Ruby encoding
269
- # (see {file:SASS_REFERENCE.md#Encodings the encoding documentation})
260
+ # (see {file:SASS_REFERENCE.md#encodings the encoding documentation})
270
261
  # @param options [{Symbol => Object}] An options hash.
271
- # See {file:SASS_REFERENCE.md#Options the Sass options documentation}.
262
+ # See {file:SASS_REFERENCE.md#options the Sass options documentation}.
272
263
  # @see {Sass::Engine.for_file}
273
264
  # @see {Sass::Plugin}
274
265
  def initialize(template, options = {})
275
266
  @options = self.class.normalize_options(options)
276
267
  @template = template
277
- @checked_encoding = false
278
- @filename = nil
279
- @line = nil
280
268
  end
281
269
 
282
270
  # Render the template to CSS.
@@ -322,7 +310,8 @@ module Sass
322
310
  end
323
311
  end
324
312
 
325
- # Returns the original encoding of the document.
313
+ # Returns the original encoding of the document,
314
+ # or `nil` under Ruby 1.8.
326
315
  #
327
316
  # @return [Encoding, nil]
328
317
  # @raise [Encoding::UndefinedConversionError] if the source encoding
@@ -375,7 +364,7 @@ Error generating source map: couldn't determine public URL for "#{filename}".
375
364
  Without a public URL, there's nothing for the source map to link to.
376
365
  An importer was not set for this file.
377
366
  ERR
378
- elsif Sass::Util.silence_sass_warnings do
367
+ elsif Sass::Util.silence_warnings do
379
368
  sourcemap_dir = nil if @options[:sourcemap] == :file
380
369
  importer.public_url(filename, sourcemap_dir).nil?
381
370
  end
@@ -391,7 +380,7 @@ ERR
391
380
  rendered << "\n" if rendered[-1] != ?\n
392
381
  rendered << "\n" unless compressed
393
382
  rendered << "/*# sourceMappingURL="
394
- rendered << URI::DEFAULT_PARSER.escape(sourcemap_uri)
383
+ rendered << Sass::Util.escape_uri(sourcemap_uri)
395
384
  rendered << " */\n"
396
385
  return rendered, sourcemap
397
386
  end
@@ -487,7 +476,7 @@ ERR
487
476
 
488
477
  line_tabs = line_tab_str.scan(tab_str).size
489
478
  if tab_str * line_tabs != line_tab_str
490
- message = <<END.strip.tr("\n", ' ')
479
+ message = <<END.strip.gsub("\n", ' ')
491
480
  Inconsistent indentation: #{Sass::Shared.human_indentation line_tab_str, true} used for indentation,
492
481
  but the rest of the document was indented using #{Sass::Shared.human_indentation tab_str}.
493
482
  END
@@ -499,13 +488,16 @@ END
499
488
  lines
500
489
  end
501
490
 
491
+ # @comment
492
+ # rubocop:disable ParameterLists
502
493
  def try_comment(line, last, tab_str, comment_tab_str, index)
494
+ # rubocop:enable ParameterLists
503
495
  return unless last && last.comment?
504
496
  # Nested comment stuff must be at least one whitespace char deeper
505
497
  # than the normal indentation
506
498
  return unless line =~ /^#{tab_str}\s/
507
499
  unless line =~ /^(?:#{comment_tab_str})(.*)$/
508
- raise SyntaxError.new(<<MSG.strip.tr("\n", " "), :line => index)
500
+ raise SyntaxError.new(<<MSG.strip.gsub("\n", " "), :line => index)
509
501
  Inconsistent indentation:
510
502
  previous line was indented by #{Sass::Shared.human_indentation comment_tab_str},
511
503
  but this line was indented by #{Sass::Shared.human_indentation line[/^\s*/]}.
@@ -524,6 +516,10 @@ MSG
524
516
  nodes = []
525
517
  while (line = arr[i]) && line.tabs >= base
526
518
  if line.tabs > base
519
+ raise SyntaxError.new(
520
+ "The line was indented #{line.tabs - base} levels deeper than the previous line.",
521
+ :line => line.index) if line.tabs > base + 1
522
+
527
523
  nodes.last.children, i = tree(arr, i)
528
524
  else
529
525
  nodes << line
@@ -578,8 +574,8 @@ MSG
578
574
  if continued_comment &&
579
575
  child.line == continued_comment.line +
580
576
  continued_comment.lines + 1
581
- continued_comment.value.last.sub!(%r{ \*/\Z}, '')
582
- child.value.first.gsub!(%r{\A/\*}, ' *')
577
+ continued_comment.value.last.sub!(/ \*\/\Z/, '')
578
+ child.value.first.gsub!(/\A\/\*/, ' *')
583
579
  continued_comment.value += ["\n"] + child.value
584
580
  next
585
581
  end
@@ -628,11 +624,6 @@ WARNING
628
624
  raise SyntaxError.new("Invalid property: \"#{line.text}\".",
629
625
  :line => @line) if name.nil? || value.nil?
630
626
 
631
- @@old_property_deprecation.warn(@options[:filename], @line, <<WARNING)
632
- Old-style properties like "#{line.text}" are deprecated and will be an error in future versions of Sass.
633
- Use "#{name}: #{value}" instead.
634
- WARNING
635
-
636
627
  value_start_offset = name_end_offset = name_start_offset + name.length
637
628
  unless value.empty?
638
629
  # +1 and -1 both compensate for the leading ':', which is part of line.text
@@ -695,14 +686,7 @@ WARNING
695
686
  end
696
687
 
697
688
  name = line.text[0...scanner.pos]
698
- could_be_property =
699
- if name.start_with?('--')
700
- (scanned = scanner.scan(/\s*:/))
701
- else
702
- (scanned = scanner.scan(/\s*:(?:\s+|$)/))
703
- end
704
-
705
- if could_be_property # test for a property
689
+ if (scanned = scanner.scan(/\s*:(?:\s+|$)/)) # test for a property
706
690
  offset += scanned.length
707
691
  property = parse_property(name, res, scanner.rest, :new, line, offset)
708
692
  property.name_source_range = ident_range
@@ -725,33 +709,23 @@ WARNING
725
709
  end
726
710
  end
727
711
 
712
+ # @comment
713
+ # rubocop:disable ParameterLists
728
714
  def parse_property(name, parsed_name, value, prop, line, start_offset)
729
-
730
- if name.start_with?('--')
731
- unless line.children.empty?
732
- raise SyntaxError.new("Illegal nesting: Nothing may be nested beneath custom properties.",
733
- :line => @line + 1)
734
- end
735
-
736
- parser = Sass::SCSS::Parser.new(value,
737
- @options[:filename], @options[:importer],
738
- @line, to_parser_offset(@offset))
739
- parsed_value = parser.parse_declaration_value
740
- end_offset = start_offset + value.length
741
- elsif value.strip.empty?
742
- parsed_value = [Sass::Script::Tree::Literal.new(Sass::Script::Value::String.new(""))]
715
+ # rubocop:enable ParameterLists
716
+ if value.strip.empty?
717
+ expr = Sass::Script::Tree::Literal.new(Sass::Script::Value::String.new(""))
743
718
  end_offset = start_offset
744
719
  else
745
720
  expr = parse_script(value, :offset => to_parser_offset(start_offset))
746
721
  end_offset = expr.source_range.end_pos.offset - 1
747
- parsed_value = [expr]
748
722
  end
749
- node = Tree::PropNode.new(parse_interp(name), parsed_value, prop)
723
+ node = Tree::PropNode.new(parse_interp(name), expr, prop)
750
724
  node.value_source_range = Sass::Source::Range.new(
751
725
  Sass::Source::Position.new(line.index, to_parser_offset(start_offset)),
752
726
  Sass::Source::Position.new(line.index, to_parser_offset(end_offset)),
753
727
  @options[:filename], @options[:importer])
754
- if !node.custom_property? && value.strip.empty? && line.children.empty?
728
+ if value.strip.empty? && line.children.empty?
755
729
  raise SyntaxError.new(
756
730
  "Invalid property: \"#{node.declaration}\" (no value)." +
757
731
  node.pseudo_class_selector_message)
@@ -824,12 +798,14 @@ WARNING
824
798
  :each, :while, :if, :else, :extend, :import, :media, :charset, :content,
825
799
  :at_root, :error]
826
800
 
801
+ # @comment
802
+ # rubocop:disable MethodLength
827
803
  def parse_directive(parent, line, root)
828
804
  directive, whitespace, value = line.text[1..-1].split(/(\s+)/, 2)
829
805
  raise SyntaxError.new("Invalid directive: '@'.") unless directive
830
806
  offset = directive.size + whitespace.size + 1 if whitespace
831
807
 
832
- directive_name = directive.tr('-', '_').to_sym
808
+ directive_name = directive.gsub('-', '_').to_sym
833
809
  if DIRECTIVES.include?(directive_name)
834
810
  return send("parse_#{directive_name}_directive", parent, line, root, value, offset)
835
811
  end
@@ -884,6 +860,8 @@ WARNING
884
860
  )
885
861
  Tree::ExtendNode.new(interp_parsed, optional, selector_range)
886
862
  end
863
+ # @comment
864
+ # rubocop:enable MethodLength
887
865
 
888
866
  def parse_warn_directive(parent, line, root, value, offset)
889
867
  raise SyntaxError.new("Invalid warn directive '@warn': expected expression.") unless value
@@ -1034,6 +1012,8 @@ WARNING
1034
1012
  values
1035
1013
  end
1036
1014
 
1015
+ # @comment
1016
+ # rubocop:disable MethodLength
1037
1017
  def parse_import_arg(scanner, offset)
1038
1018
  return if scanner.eos?
1039
1019
 
@@ -1108,6 +1088,8 @@ WARNING
1108
1088
  end
1109
1089
  node
1110
1090
  end
1091
+ # @comment
1092
+ # rubocop:enable MethodLength
1111
1093
 
1112
1094
  def parse_mixin_directive(parent, line, root, value, offset)
1113
1095
  parse_mixin_definition(line)
@@ -1178,7 +1160,7 @@ WARNING
1178
1160
  end
1179
1161
 
1180
1162
  return "/* */" if content.empty?
1181
- content.last.gsub!(%r{ ?\*/ *$}, '')
1163
+ content.last.gsub!(/ ?\*\/ *$/, '')
1182
1164
  first = content.shift unless removed_first
1183
1165
  content.map! {|l| l.gsub!(/^\*( ?)/, '\1') || (l.empty? ? "" : " ") + l}
1184
1166
  content.unshift first unless removed_first
@@ -1220,7 +1202,7 @@ WARNING
1220
1202
  else
1221
1203
  res << "\\" * [0, escapes - 1].max
1222
1204
  if scan[1].include?("\n")
1223
- line += scan[1].count("\n")
1205
+ line = line + scan[1].count("\n")
1224
1206
  offset = scan.matched_size - scan[1].rindex("\n")
1225
1207
  else
1226
1208
  offset += scan.matched_size
@@ -81,19 +81,12 @@ module Sass
81
81
  inherited_hash_reader :function
82
82
 
83
83
  # @param options [{Symbol => Object}] The options hash. See
84
- # {file:SASS_REFERENCE.md#Options the Sass options documentation}.
84
+ # {file:SASS_REFERENCE.md#options the Sass options documentation}.
85
85
  # @param parent [Environment] See \{#parent}
86
86
  def initialize(parent = nil, options = nil)
87
87
  @parent = parent
88
88
  @options = options || (parent && parent.options) || {}
89
- @stack = @parent.nil? ? Sass::Stack.new : nil
90
- @caller = nil
91
- @content = nil
92
- @filename = nil
93
- @functions = nil
94
- @mixins = nil
95
- @selector = nil
96
- @vars = nil
89
+ @stack = Sass::Stack.new if @parent.nil?
97
90
  end
98
91
 
99
92
  # Returns whether this is the global environment.
@@ -175,10 +168,6 @@ module Sass
175
168
 
176
169
  # A read-only wrapper for a lexical environment for SassScript.
177
170
  class ReadOnlyEnvironment < BaseEnvironment
178
- def initialize(parent = nil, options = nil)
179
- super
180
- @content_cached = nil
181
- end
182
171
  # The read-only environment of the caller of this environment's mixin or function.
183
172
  #
184
173
  # @see BaseEnvironment#caller
@@ -189,31 +178,14 @@ module Sass
189
178
  @caller ||= env.is_a?(ReadOnlyEnvironment) ? env : ReadOnlyEnvironment.new(env, env.options)
190
179
  end
191
180
 
192
- # The content passed to this environment. If the content's environment isn't already
193
- # read-only, it's made read-only.
181
+ # The read-only content passed to this environment.
194
182
  #
195
183
  # @see BaseEnvironment#content
196
- #
197
- # @return {[Array<Sass::Tree::Node>, ReadOnlyEnvironment]?} The content nodes and
198
- # the lexical environment of the content block.
199
- # Returns `nil` when there is no content in this environment.
184
+ # @return {ReadOnlyEnvironment}
200
185
  def content
201
- # Return the cached content from a previous invocation if any
202
- return @content if @content_cached
203
- # get the content with a read-write environment from the superclass
204
- read_write_content = super
205
- if read_write_content
206
- tree, env = read_write_content
207
- # make the content's environment read-only
208
- if env && !env.is_a?(ReadOnlyEnvironment)
209
- env = ReadOnlyEnvironment.new(env, env.options)
210
- end
211
- @content_cached = true
212
- @content = [tree, env]
213
- else
214
- @content_cached = true
215
- @content = nil
216
- end
186
+ return @content if @content
187
+ env = super
188
+ @content ||= env.is_a?(ReadOnlyEnvironment) ? env : ReadOnlyEnvironment.new(env, env.options)
217
189
  end
218
190
  end
219
191