sass 3.4.25 → 3.5.0.pre.rc.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (156) hide show
  1. checksums.yaml +4 -4
  2. data/.yardopts +1 -1
  3. data/README.md +1 -1
  4. data/Rakefile +13 -157
  5. data/VERSION +1 -1
  6. data/VERSION_DATE +1 -1
  7. data/VERSION_NAME +1 -1
  8. data/lib/sass.rb +3 -10
  9. data/lib/sass/cache_stores/filesystem.rb +1 -1
  10. data/lib/sass/css.rb +2 -3
  11. data/lib/sass/engine.rb +46 -32
  12. data/lib/sass/environment.rb +27 -6
  13. data/lib/sass/error.rb +5 -5
  14. data/lib/sass/exec/base.rb +3 -12
  15. data/lib/sass/features.rb +1 -0
  16. data/lib/sass/importers/filesystem.rb +2 -2
  17. data/lib/sass/plugin.rb +1 -1
  18. data/lib/sass/plugin/compiler.rb +21 -51
  19. data/lib/sass/plugin/configuration.rb +1 -1
  20. data/lib/sass/plugin/rack.rb +3 -3
  21. data/lib/sass/plugin/staleness_checker.rb +3 -3
  22. data/lib/sass/railtie.rb +1 -1
  23. data/lib/sass/script.rb +3 -3
  24. data/lib/sass/script/functions.rb +238 -47
  25. data/lib/sass/script/lexer.rb +8 -6
  26. data/lib/sass/script/parser.rb +76 -75
  27. data/lib/sass/script/tree/funcall.rb +35 -30
  28. data/lib/sass/script/tree/list_literal.rb +23 -8
  29. data/lib/sass/script/tree/map_literal.rb +2 -2
  30. data/lib/sass/script/tree/node.rb +2 -10
  31. data/lib/sass/script/tree/operation.rb +16 -50
  32. data/lib/sass/script/value.rb +2 -0
  33. data/lib/sass/script/value/arg_list.rb +1 -1
  34. data/lib/sass/script/value/base.rb +20 -3
  35. data/lib/sass/script/value/callable.rb +25 -0
  36. data/lib/sass/script/value/color.rb +10 -10
  37. data/lib/sass/script/value/function.rb +19 -0
  38. data/lib/sass/script/value/helpers.rb +16 -7
  39. data/lib/sass/script/value/list.rb +33 -12
  40. data/lib/sass/script/value/map.rb +2 -2
  41. data/lib/sass/script/value/number.rb +3 -3
  42. data/lib/sass/script/value/string.rb +12 -5
  43. data/lib/sass/scss/parser.rb +101 -45
  44. data/lib/sass/scss/rx.rb +5 -11
  45. data/lib/sass/scss/static_parser.rb +0 -7
  46. data/lib/sass/selector.rb +4 -0
  47. data/lib/sass/selector/abstract_sequence.rb +5 -5
  48. data/lib/sass/selector/comma_sequence.rb +3 -15
  49. data/lib/sass/selector/pseudo.rb +4 -0
  50. data/lib/sass/selector/sequence.rb +30 -3
  51. data/lib/sass/selector/simple.rb +13 -7
  52. data/lib/sass/selector/simple_sequence.rb +1 -1
  53. data/lib/sass/shared.rb +3 -5
  54. data/lib/sass/source/map.rb +4 -4
  55. data/lib/sass/source/position.rb +4 -4
  56. data/lib/sass/stack.rb +21 -1
  57. data/lib/sass/tree/charset_node.rb +1 -1
  58. data/lib/sass/tree/comment_node.rb +1 -1
  59. data/lib/sass/tree/node.rb +3 -3
  60. data/lib/sass/tree/prop_node.rb +46 -54
  61. data/lib/sass/tree/rule_node.rb +7 -15
  62. data/lib/sass/tree/visitors/check_nesting.rb +1 -1
  63. data/lib/sass/tree/visitors/convert.rb +2 -3
  64. data/lib/sass/tree/visitors/cssize.rb +1 -10
  65. data/lib/sass/tree/visitors/deep_copy.rb +2 -2
  66. data/lib/sass/tree/visitors/perform.rb +23 -12
  67. data/lib/sass/tree/visitors/set_options.rb +1 -1
  68. data/lib/sass/tree/visitors/to_css.rb +46 -12
  69. data/lib/sass/util.rb +16 -321
  70. data/lib/sass/util/multibyte_string_scanner.rb +127 -131
  71. data/lib/sass/util/normalized_map.rb +1 -8
  72. data/lib/sass/version.rb +2 -2
  73. data/test/sass-spec.yml +1 -1
  74. data/test/sass/compiler_test.rb +4 -14
  75. data/test/sass/conversion_test.rb +113 -162
  76. data/test/sass/css2sass_test.rb +17 -19
  77. data/test/sass/css_variable_test.rb +176 -70
  78. data/test/sass/encoding_test.rb +2 -32
  79. data/test/sass/engine_test.rb +114 -65
  80. data/test/sass/extend_test.rb +37 -51
  81. data/test/sass/functions_test.rb +57 -15
  82. data/test/sass/importer_test.rb +2 -2
  83. data/test/sass/more_templates/more1.sass +10 -10
  84. data/test/sass/more_templates/more_import.sass +2 -2
  85. data/test/sass/plugin_test.rb +9 -12
  86. data/test/sass/script_conversion_test.rb +9 -0
  87. data/test/sass/script_test.rb +38 -48
  88. data/test/sass/scss/css_test.rb +5 -19
  89. data/test/sass/scss/scss_test.rb +58 -39
  90. data/test/sass/source_map_test.rb +26 -28
  91. data/test/sass/templates/_partial.sass +1 -1
  92. data/test/sass/templates/basic.sass +10 -10
  93. data/test/sass/templates/bork1.sass +1 -1
  94. data/test/sass/templates/bork5.sass +1 -1
  95. data/test/sass/templates/compact.sass +10 -10
  96. data/test/sass/templates/complex.sass +187 -187
  97. data/test/sass/templates/compressed.sass +10 -10
  98. data/test/sass/templates/expanded.sass +10 -10
  99. data/test/sass/templates/import.sass +2 -2
  100. data/test/sass/templates/importee.sass +3 -3
  101. data/test/sass/templates/mixins.sass +22 -22
  102. data/test/sass/templates/multiline.sass +4 -4
  103. data/test/sass/templates/nested.sass +13 -13
  104. data/test/sass/templates/parent_ref.sass +12 -12
  105. data/test/sass/templates/script.sass +70 -70
  106. data/test/sass/templates/subdir/nested_subdir/_nested_partial.sass +1 -1
  107. data/test/sass/templates/subdir/nested_subdir/nested_subdir.sass +2 -2
  108. data/test/sass/templates/subdir/subdir.sass +3 -3
  109. data/test/sass/templates/units.sass +10 -10
  110. data/test/sass/util/multibyte_string_scanner_test.rb +139 -149
  111. data/test/sass/util_test.rb +0 -36
  112. data/test/test_helper.rb +39 -0
  113. metadata +30 -57
  114. data/extra/sass-spec-ref.sh +0 -32
  115. data/lib/sass/deprecation.rb +0 -55
  116. data/lib/sass/script/css_variable_warning.rb +0 -52
  117. data/lib/sass/util/cross_platform_random.rb +0 -19
  118. data/lib/sass/util/ordered_hash.rb +0 -192
  119. data/test/sass/results/import_charset_1_8.css +0 -5
  120. data/test/sass/templates/import_charset_1_8.sass +0 -6
  121. data/vendor/listen/CHANGELOG.md +0 -1
  122. data/vendor/listen/CONTRIBUTING.md +0 -38
  123. data/vendor/listen/Gemfile +0 -20
  124. data/vendor/listen/Guardfile +0 -8
  125. data/vendor/listen/LICENSE +0 -20
  126. data/vendor/listen/README.md +0 -349
  127. data/vendor/listen/Rakefile +0 -5
  128. data/vendor/listen/Vagrantfile +0 -96
  129. data/vendor/listen/lib/listen.rb +0 -54
  130. data/vendor/listen/lib/listen/adapter.rb +0 -327
  131. data/vendor/listen/lib/listen/adapters/bsd.rb +0 -75
  132. data/vendor/listen/lib/listen/adapters/darwin.rb +0 -48
  133. data/vendor/listen/lib/listen/adapters/linux.rb +0 -81
  134. data/vendor/listen/lib/listen/adapters/polling.rb +0 -58
  135. data/vendor/listen/lib/listen/adapters/windows.rb +0 -91
  136. data/vendor/listen/lib/listen/directory_record.rb +0 -406
  137. data/vendor/listen/lib/listen/listener.rb +0 -323
  138. data/vendor/listen/lib/listen/turnstile.rb +0 -32
  139. data/vendor/listen/lib/listen/version.rb +0 -3
  140. data/vendor/listen/listen.gemspec +0 -28
  141. data/vendor/listen/spec/listen/adapter_spec.rb +0 -149
  142. data/vendor/listen/spec/listen/adapters/bsd_spec.rb +0 -36
  143. data/vendor/listen/spec/listen/adapters/darwin_spec.rb +0 -37
  144. data/vendor/listen/spec/listen/adapters/linux_spec.rb +0 -47
  145. data/vendor/listen/spec/listen/adapters/polling_spec.rb +0 -68
  146. data/vendor/listen/spec/listen/adapters/windows_spec.rb +0 -30
  147. data/vendor/listen/spec/listen/directory_record_spec.rb +0 -1250
  148. data/vendor/listen/spec/listen/listener_spec.rb +0 -258
  149. data/vendor/listen/spec/listen/turnstile_spec.rb +0 -56
  150. data/vendor/listen/spec/listen_spec.rb +0 -67
  151. data/vendor/listen/spec/spec_helper.rb +0 -25
  152. data/vendor/listen/spec/support/adapter_helper.rb +0 -666
  153. data/vendor/listen/spec/support/directory_record_helper.rb +0 -57
  154. data/vendor/listen/spec/support/fixtures_helper.rb +0 -29
  155. data/vendor/listen/spec/support/listeners_helper.rb +0 -179
  156. data/vendor/listen/spec/support/platform_helper.rb +0 -15
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a8b2d6c079c8e8aec59e0dd45294419919f88239
4
- data.tar.gz: 5e31ebbe100aa0b066d414ee32e3f29d792907f6
3
+ metadata.gz: 4c783fad5337d350de6a05eb9157e74ea987103f
4
+ data.tar.gz: 20fb9514c3b8f7cbfd6fb72f1a0cc021e38b0993
5
5
  SHA512:
6
- metadata.gz: 1782f895c1aaeef19491dfb41434ca10a60d28395f53a3ec19f8a65ec21c97625db3325732007fbc3155821c53adf9bcd00ced70e9fe3c1c935295b34f3dfdaf
7
- data.tar.gz: 39578a844dd4d6e381cb10ced82d5c6782ddd042c79cc5c4c9cc6a69163badbf1ce368526987447b955d44a3d20470ea5e4eae481ea9359d63eea09cab94ca70
6
+ metadata.gz: 89716ff7357b7a3ba527b5b8fd2e6da59b2b501f58930a6ee612611f34a26272fb5c13047aa1c06491da53ac7f9bf924710ca2478e9c04f354c07eb46d2f3841
7
+ data.tar.gz: 8b24c606daa11c7a38a557bf4efcb7e7d2b72411d8f8f0338af40bff915e80c048f0aaf9db93f0abb4202384599564a972388aa0789198e257fb2c95a2994baa
data/.yardopts CHANGED
@@ -1,6 +1,6 @@
1
1
  --readme README.md
2
2
  --markup markdown
3
- --markup-provider redcarpet
3
+ --markup-provider maruku
4
4
  --default-return ""
5
5
  --title "Sass Documentation"
6
6
  --query 'object.type != :classvariable'
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # Sass [![Gem Version](https://badge.fury.io/rb/sass.svg)](http://badge.fury.io/rb/sass) [![Inline docs](http://inch-ci.org/github/sass/sass.svg)](http://inch-ci.org/github/sass/sass)
1
+ # Sass [![Gem Version](https://badge.fury.io/rb/sass.png)](http://badge.fury.io/rb/sass) [![Inline docs](http://inch-ci.org/github/sass/sass.svg)](http://inch-ci.org/github/sass/sass)
2
2
 
3
3
  **Sass makes CSS fun again**. Sass is an extension of CSS,
4
4
  adding nested rules, variables, mixins, selector inheritance, and more.
data/Rakefile CHANGED
@@ -12,42 +12,8 @@ task :default => :test
12
12
 
13
13
  require 'rake/testtask'
14
14
 
15
- LINE_SIZE = 80
16
- DECORATION_CHAR = '#'
17
-
18
- def print_header(string)
19
- length = string.length
20
- puts DECORATION_CHAR * LINE_SIZE
21
- puts string.center(length + 2, ' ').center(LINE_SIZE, DECORATION_CHAR)
22
- puts DECORATION_CHAR * LINE_SIZE
23
- end
24
-
25
15
  desc "Run all tests"
26
- task :test do
27
- test_cases = [
28
- {
29
- 'env' => {'MATHN' => 'true'},
30
- 'tasks' => ['test:ruby', 'test:spec', :rubocop]
31
- },
32
- {
33
- 'env' => {'MATHN' => 'false'},
34
- 'tasks' => ['test:ruby']
35
- }
36
- ]
37
-
38
- test_cases.each do |test_case|
39
- env = test_case['env']
40
- tasks = test_case['tasks']
41
-
42
- env.each do |key, value|
43
- ENV[key] = value
44
- end
45
- tasks.each do |task|
46
- print_header("Running task: #{task}, env: #{env}")
47
- Rake::Task[task].execute
48
- end
49
- end
50
- end
16
+ task :test => ["test:ruby", "test:spec"]
51
17
 
52
18
  namespace :test do
53
19
  desc "Run the ruby tests (without sass-spec)"
@@ -82,7 +48,7 @@ namespace :test do
82
48
  end
83
49
  default_options = {
84
50
  :spec_directory => SassSpec::SPEC_DIR,
85
- :engine_adapter => SassEngineAdapter.new,
51
+ :engine_adapter => SassEngineAdapter.new("sass"),
86
52
  :generate => false,
87
53
  :tap => false,
88
54
  :skip => false,
@@ -110,26 +76,31 @@ def ruby_version_at_least?(version_string)
110
76
  ruby_version >= version
111
77
  end
112
78
 
113
- begin
79
+ if ruby_version_at_least?("2.2.0") &&
80
+ (ENV.has_key?("RUBOCOP") && ENV["RUBOCOP"] == "true" ||
81
+ !(ENV.has_key?("RUBOCOP") || ENV.has_key?("TEST")))
114
82
  require 'rubocop/rake_task'
115
83
  RuboCop = Rubocop unless defined?(RuboCop)
116
84
  RuboCop::RakeTask.new do |t|
117
85
  t.patterns = FileList["lib/**/*"]
118
86
  end
119
- rescue LoadError
87
+ else
120
88
  task :rubocop do
121
- puts "Rubocop is disabled."
89
+ puts "Skipping rubocop style check."
90
+ next if ENV.has_key?("RUBOCOP") && ENV["RUBOCOP"] != "true"
122
91
  puts "Passing this check is required in order for your patch to be accepted."
123
- puts "Install Rubocop and then run the style check with: rake rubocop."
92
+ puts "Use Ruby 2.2 or greater and then run the style check with: rake rubocop"
124
93
  end
125
94
  end
126
95
 
96
+ task :test => :rubocop
97
+
127
98
  # ----- Packaging -----
128
99
 
129
100
  # Don't use Rake::GemPackageTast because we want prerequisites to run
130
101
  # before we load the gemspec.
131
102
  desc "Build all the packages."
132
- task :package => [:revision_file, :date_file, :submodules, :permissions] do
103
+ task :package => [:revision_file, :date_file, :permissions] do
133
104
  version = get_version
134
105
  File.open(scope('VERSION'), 'w') {|f| f.puts(version)}
135
106
  load scope('sass.gemspec')
@@ -222,49 +193,10 @@ def changed_since?(rev, *files)
222
193
  return !$?.success?
223
194
  end
224
195
 
225
- task :submodules do
226
- if File.exist?(File.dirname(__FILE__) + "/.git")
227
- sh %{git submodule sync}
228
- sh %{git submodule update --init}
229
- elsif !File.exist?(File.dirname(__FILE__) + "/vendor/listen/lib")
230
- warn <<WARN
231
- WARNING: vendor/listen doesn't exist, and this isn't a git repository so
232
- I can't get it automatically!
233
- WARN
234
- end
235
- end
236
-
237
- task :release_edge do
238
- ensure_git_cleanup do
239
- puts "#{'=' * 50} Running rake release_edge"
240
-
241
- sh %{git checkout master}
242
- sh %{git reset --hard origin/master}
243
- sh %{rake package}
244
- version = get_version
245
- if version.include?('.rc.')
246
- puts "#{'=' * 20} Not releasing edge gem for RC version"
247
- next
248
- end
249
-
250
- sh %{gem push pkg/sass-#{version}.gem}
251
- end
252
- end
253
-
254
196
  # Get the version string. If this is being installed from Git,
255
197
  # this includes the proper prerelease version.
256
198
  def get_version
257
- written_version = File.read(scope('VERSION').strip)
258
- return written_version unless File.exist?(scope('.git'))
259
-
260
- # Get the current master branch version
261
- version = written_version.split('.')
262
- version.map! {|n| n =~ /^[0-9]+$/ ? n.to_i : n}
263
- return written_version unless version.size == 5 && version[3] == "alpha" # prerelease
264
-
265
- return written_version if (commit_count = `git log --pretty=oneline HEAD ^stable | wc -l`).empty?
266
- version[4] = commit_count.strip
267
- version.join('.')
199
+ File.read(scope('VERSION').strip)
268
200
  end
269
201
 
270
202
  task :watch_for_update do
@@ -336,27 +268,6 @@ rescue LoadError
336
268
  task :yard => :rdoc
337
269
  end
338
270
 
339
- task :pages do
340
- ensure_git_cleanup do
341
- puts "#{'=' * 50} Running rake pages"
342
- sh %{git checkout sass-pages}
343
- sh %{git reset --hard origin/sass-pages}
344
-
345
- Dir.chdir("/var/www/sass-pages") do
346
- sh %{git fetch origin}
347
-
348
- sh %{git checkout stable}
349
- sh %{git reset --hard origin/stable}
350
-
351
- sh %{git checkout sass-pages}
352
- sh %{git reset --hard origin/sass-pages}
353
- sh %{rake build --trace}
354
- sh %{mkdir -p tmp}
355
- sh %{touch tmp/restart.txt}
356
- end
357
- end
358
- end
359
-
360
271
  # ----- Coverage -----
361
272
 
362
273
  begin
@@ -396,58 +307,3 @@ END
396
307
  RubyProf.const_get("#{(ENV['OUTPUT'] || 'Flat').capitalize}Printer").new(result).print
397
308
  end
398
309
  rescue LoadError; end
399
-
400
- # ----- Handling Updates -----
401
-
402
- def email_on_error
403
- yield
404
- rescue Exception => e
405
- IO.popen("sendmail nex342@gmail.com", "w") do |sm|
406
- sm << "From: nex3@nex-3.com\n" <<
407
- "To: nex342@gmail.com\n" <<
408
- "Subject: Exception when running rake #{Rake.application.top_level_tasks.join(', ')}\n" <<
409
- e.message << "\n\n" <<
410
- e.backtrace.join("\n")
411
- end
412
- ensure
413
- raise e if e
414
- end
415
-
416
- def ensure_git_cleanup
417
- email_on_error {yield}
418
- ensure
419
- sh %{git reset --hard HEAD}
420
- sh %{git clean -xdf}
421
- sh %{git checkout master}
422
- end
423
-
424
- task :handle_update do
425
- email_on_error do
426
- unless ENV["REF"] =~ %r{^refs/heads/(master|stable|sass-pages)$}
427
- puts "#{'=' * 20} Ignoring rake handle_update REF=#{ENV["REF"].inspect}"
428
- next
429
- end
430
- branch = $1
431
-
432
- puts
433
- puts
434
- puts '=' * 150
435
- puts "Running rake handle_update REF=#{ENV["REF"].inspect}"
436
-
437
- sh %{git fetch origin}
438
- sh %{git checkout stable}
439
- sh %{git reset --hard origin/stable}
440
- sh %{git checkout master}
441
- sh %{git reset --hard origin/master}
442
-
443
- case branch
444
- when "master"
445
- sh %{rake release_edge --trace}
446
- when "stable", "sass-pages"
447
- sh %{rake pages --trace}
448
- end
449
-
450
- puts 'Done running handle_update'
451
- puts '=' * 150
452
- end
453
- end
data/VERSION CHANGED
@@ -1 +1 @@
1
- 3.4.25
1
+ 3.5.0-rc.1
@@ -1 +1 @@
1
- 07 July 2017 22:00:34 UTC
1
+ 30 August 2016 22:11:04 UTC
@@ -1 +1 @@
1
- Selective Steve
1
+ Bleeding Edge
@@ -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 : {}
@@ -100,10 +100,3 @@ require 'sass/engine'
100
100
  require 'sass/plugin' if defined?(Merb::Plugins)
101
101
  require 'sass/railtie'
102
102
  require 'sass/features'
103
-
104
- if Sass::Util.ruby1?
105
- Sass::Util.sass_warn(
106
- "DEPRECATION WARNING:\n" +
107
- "Sass 3.5 will no longer support Ruby #{RUBY_VERSION}.\n" +
108
- "Please upgrade to Ruby 2.0.0 or greater as soon as possible.\n")
109
- end
@@ -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" % (Sass::Util.ord(c))}
55
+ key = key.gsub(/[<>:\\|?*%]/) {|c| "%%%03d" % c.ord}
56
56
  File.join(cache_location, key)
57
57
  end
58
58
  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`).
@@ -51,8 +51,7 @@ module Sass
51
51
  raise err
52
52
  end
53
53
 
54
- # Returns the original encoding of the document,
55
- # or `nil` under Ruby 1.8.
54
+ # Returns the original encoding of the document.
56
55
  #
57
56
  # @return [Encoding, nil]
58
57
  # @raise [Encoding::UndefinedConversionError] if the source encoding
@@ -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,7 +79,13 @@ module Sass
80
79
  #
81
80
  # `type`: `String`
82
81
  # : The user-friendly name of the type of the callable.
83
- Callable = Struct.new(:name, :args, :splat, :environment, :tree, :has_content, :type)
82
+ #
83
+ # `origin`: `Symbol`
84
+ # : From whence comes the callable: `:stylesheet`, `:builtin`, `:css`
85
+ # A callable with an origin of `:stylesheet` was defined in the stylesheet itself.
86
+ # A callable with an origin of `:builtin` was defined in ruby.
87
+ # A callable (function) with an origin of `:css` returns a function call with arguments to CSS.
88
+ Callable = Struct.new(:name, :args, :splat, :environment, :tree, :has_content, :type, :origin)
84
89
 
85
90
  # This class handles the parsing and compilation of the Sass template.
86
91
  # Example usage:
@@ -90,20 +95,18 @@ module Sass
90
95
  # output = sass_engine.render
91
96
  # puts output
92
97
  class Engine
93
- @@old_property_deprecation = Deprecation.new
94
-
95
98
  # A line of Sass code.
96
99
  #
97
100
  # `text`: `String`
98
101
  # : The text in the line, without any whitespace at the beginning or end.
99
102
  #
100
- # `tabs`: `Integer`
103
+ # `tabs`: `Fixnum`
101
104
  # : The level of indentation of the line.
102
105
  #
103
- # `index`: `Integer`
106
+ # `index`: `Fixnum`
104
107
  # : The line number in the original document.
105
108
  #
106
- # `offset`: `Integer`
109
+ # `offset`: `Fixnum`
107
110
  # : The number of bytes in on the line that the text begins.
108
111
  # This ends up being the number of bytes of leading whitespace.
109
112
  #
@@ -171,7 +174,7 @@ module Sass
171
174
  # default values and resolving aliases.
172
175
  #
173
176
  # @param options [{Symbol => Object}] The options hash;
174
- # see {file:SASS_REFERENCE.md#Options the Sass options documentation}
177
+ # see {file:SASS_REFERENCE.md#options the Sass options documentation}
175
178
  # @return [{Symbol => Object}] The normalized options hash.
176
179
  # @private
177
180
  def self.normalize_options(options)
@@ -225,7 +228,7 @@ module Sass
225
228
  #
226
229
  # @param filename [String] The path to the Sass or SCSS file
227
230
  # @param options [{Symbol => Object}] The options hash;
228
- # See {file:SASS_REFERENCE.md#Options the Sass options documentation}.
231
+ # See {file:SASS_REFERENCE.md#options the Sass options documentation}.
229
232
  # @return [Sass::Engine] The Engine for the given Sass or SCSS file.
230
233
  # @raise [Sass::SyntaxError] if there's an error in the document.
231
234
  def self.for_file(filename, options)
@@ -243,7 +246,7 @@ module Sass
243
246
  end
244
247
 
245
248
  # The options for the Sass engine.
246
- # See {file:SASS_REFERENCE.md#Options the Sass options documentation}.
249
+ # See {file:SASS_REFERENCE.md#options the Sass options documentation}.
247
250
  #
248
251
  # @return [{Symbol => Object}]
249
252
  attr_reader :options
@@ -260,9 +263,9 @@ module Sass
260
263
  # that can be converted to Unicode.
261
264
  # If the template contains an `@charset` declaration,
262
265
  # that overrides the Ruby encoding
263
- # (see {file:SASS_REFERENCE.md#Encodings the encoding documentation})
266
+ # (see {file:SASS_REFERENCE.md#encodings the encoding documentation})
264
267
  # @param options [{Symbol => Object}] An options hash.
265
- # See {file:SASS_REFERENCE.md#Options the Sass options documentation}.
268
+ # See {file:SASS_REFERENCE.md#options the Sass options documentation}.
266
269
  # @see {Sass::Engine.for_file}
267
270
  # @see {Sass::Plugin}
268
271
  def initialize(template, options = {})
@@ -316,8 +319,7 @@ module Sass
316
319
  end
317
320
  end
318
321
 
319
- # Returns the original encoding of the document,
320
- # or `nil` under Ruby 1.8.
322
+ # Returns the original encoding of the document.
321
323
  #
322
324
  # @return [Encoding, nil]
323
325
  # @raise [Encoding::UndefinedConversionError] if the source encoding
@@ -386,7 +388,7 @@ ERR
386
388
  rendered << "\n" if rendered[-1] != ?\n
387
389
  rendered << "\n" unless compressed
388
390
  rendered << "/*# sourceMappingURL="
389
- rendered << Sass::Util.escape_uri(sourcemap_uri)
391
+ rendered << URI::DEFAULT_PARSER.escape(sourcemap_uri)
390
392
  rendered << " */\n"
391
393
  return rendered, sourcemap
392
394
  end
@@ -628,11 +630,6 @@ WARNING
628
630
  raise SyntaxError.new("Invalid property: \"#{line.text}\".",
629
631
  :line => @line) if name.nil? || value.nil?
630
632
 
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
633
  value_start_offset = name_end_offset = name_start_offset + name.length
637
634
  unless value.empty?
638
635
  # +1 and -1 both compensate for the leading ':', which is part of line.text
@@ -695,7 +692,14 @@ WARNING
695
692
  end
696
693
 
697
694
  name = line.text[0...scanner.pos]
698
- if (scanned = scanner.scan(/\s*:(?:\s+|$)/)) # test for a property
695
+ could_be_property =
696
+ if name.start_with?('--')
697
+ (scanned = scanner.scan(/\s*:/))
698
+ else
699
+ (scanned = scanner.scan(/\s*:(?:\s+|$)/))
700
+ end
701
+
702
+ if could_be_property # test for a property
699
703
  offset += scanned.length
700
704
  property = parse_property(name, res, scanner.rest, :new, line, offset)
701
705
  property.name_source_range = ident_range
@@ -722,22 +726,32 @@ WARNING
722
726
  # rubocop:disable ParameterLists
723
727
  def parse_property(name, parsed_name, value, prop, line, start_offset)
724
728
  # rubocop:enable ParameterLists
725
- if value.strip.empty?
726
- expr = Sass::Script::Tree::Literal.new(Sass::Script::Value::String.new(""))
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(""))]
727
743
  end_offset = start_offset
728
744
  else
729
- expr = parse_script(value,
730
- :offset => to_parser_offset(start_offset),
731
- :css_variable => name.start_with?("--"))
745
+ expr = parse_script(value, :offset => to_parser_offset(start_offset))
732
746
  end_offset = expr.source_range.end_pos.offset - 1
747
+ parsed_value = [expr]
733
748
  end
734
-
735
- node = Tree::PropNode.new(parse_interp(name), expr, prop)
749
+ node = Tree::PropNode.new(parse_interp(name), parsed_value, prop)
736
750
  node.value_source_range = Sass::Source::Range.new(
737
751
  Sass::Source::Position.new(line.index, to_parser_offset(start_offset)),
738
752
  Sass::Source::Position.new(line.index, to_parser_offset(end_offset)),
739
753
  @options[:filename], @options[:importer])
740
- if value.strip.empty? && line.children.empty?
754
+ if !node.custom_property? && value.strip.empty? && line.children.empty?
741
755
  raise SyntaxError.new(
742
756
  "Invalid property: \"#{node.declaration}\" (no value)." +
743
757
  node.pseudo_class_selector_message)
@@ -1154,9 +1168,9 @@ WARNING
1154
1168
  end
1155
1169
 
1156
1170
  def parse_script(script, options = {})
1157
- line = options.delete(:line) || @line
1158
- offset = options.delete(:offset) || @offset + 1
1159
- Script.parse(script, line, offset, @options.merge(options))
1171
+ line = options[:line] || @line
1172
+ offset = options[:offset] || @offset + 1
1173
+ Script.parse(script, line, offset, @options)
1160
1174
  end
1161
1175
 
1162
1176
  def format_comment_text(text, silent)