brakeman 4.4.0 → 4.5.0

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of brakeman might be problematic. Click here for more details.

Files changed (362) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGES.md +17 -0
  3. data/bundle/load.rb +7 -8
  4. data/bundle/ruby/2.5.0/gems/{ruby2ruby-2.4.1 → ruby2ruby-2.4.2}/History.rdoc +8 -0
  5. data/bundle/ruby/2.5.0/gems/{ruby2ruby-2.4.1 → ruby2ruby-2.4.2}/Manifest.txt +0 -0
  6. data/bundle/ruby/2.5.0/gems/{ruby2ruby-2.4.1 → ruby2ruby-2.4.2}/README.rdoc +0 -0
  7. data/bundle/ruby/2.5.0/gems/{ruby2ruby-2.4.1 → ruby2ruby-2.4.2}/lib/ruby2ruby.rb +34 -36
  8. data/bundle/ruby/2.5.0/gems/{ruby_parser-3.12.0 → ruby_parser-3.13.0}/History.rdoc +47 -0
  9. data/bundle/ruby/2.5.0/gems/{ruby_parser-3.12.0 → ruby_parser-3.13.0}/Manifest.txt +5 -4
  10. data/bundle/ruby/2.5.0/gems/{ruby_parser-3.12.0 → ruby_parser-3.13.0}/README.rdoc +0 -0
  11. data/bundle/ruby/2.5.0/gems/{ruby_parser-3.12.0 → ruby_parser-3.13.0}/compare/normalize.rb +29 -2
  12. data/bundle/ruby/2.5.0/gems/ruby_parser-3.13.0/debugging.md +18 -0
  13. data/bundle/ruby/2.5.0/gems/{ruby_parser-3.12.0 → ruby_parser-3.13.0}/lib/rp_extensions.rb +0 -7
  14. data/bundle/ruby/2.5.0/gems/{ruby_parser-3.12.0 → ruby_parser-3.13.0}/lib/rp_stringscanner.rb +0 -0
  15. data/bundle/ruby/2.5.0/gems/ruby_parser-3.13.0/lib/ruby20_parser.rb +6874 -0
  16. data/bundle/ruby/2.5.0/gems/{ruby_parser-3.12.0 → ruby_parser-3.13.0}/lib/ruby20_parser.y +284 -201
  17. data/bundle/ruby/2.5.0/gems/ruby_parser-3.13.0/lib/ruby21_parser.rb +6952 -0
  18. data/bundle/ruby/2.5.0/gems/{ruby_parser-3.12.0 → ruby_parser-3.13.0}/lib/ruby21_parser.y +281 -197
  19. data/bundle/ruby/2.5.0/gems/ruby_parser-3.13.0/lib/ruby22_parser.rb +6983 -0
  20. data/bundle/ruby/2.5.0/gems/{ruby_parser-3.12.0/lib/ruby_parser.yy → ruby_parser-3.13.0/lib/ruby22_parser.y} +280 -306
  21. data/bundle/ruby/2.5.0/gems/ruby_parser-3.13.0/lib/ruby23_parser.rb +6982 -0
  22. data/bundle/ruby/2.5.0/gems/{ruby_parser-3.12.0 → ruby_parser-3.13.0}/lib/ruby23_parser.y +282 -203
  23. data/bundle/ruby/2.5.0/gems/ruby_parser-3.13.0/lib/ruby24_parser.rb +6982 -0
  24. data/bundle/ruby/2.5.0/gems/{ruby_parser-3.12.0 → ruby_parser-3.13.0}/lib/ruby24_parser.y +282 -203
  25. data/bundle/ruby/2.5.0/gems/ruby_parser-3.13.0/lib/ruby25_parser.rb +6981 -0
  26. data/bundle/ruby/2.5.0/gems/{ruby_parser-3.12.0 → ruby_parser-3.13.0}/lib/ruby25_parser.y +282 -203
  27. data/bundle/ruby/2.5.0/gems/ruby_parser-3.13.0/lib/ruby26_parser.rb +6999 -0
  28. data/bundle/ruby/2.5.0/gems/ruby_parser-3.13.0/lib/ruby26_parser.y +2469 -0
  29. data/bundle/ruby/2.5.0/gems/{ruby_parser-3.12.0 → ruby_parser-3.13.0}/lib/ruby_lexer.rb +116 -118
  30. data/bundle/ruby/2.5.0/gems/{ruby_parser-3.12.0 → ruby_parser-3.13.0}/lib/ruby_lexer.rex +10 -8
  31. data/bundle/ruby/2.5.0/gems/{ruby_parser-3.12.0 → ruby_parser-3.13.0}/lib/ruby_lexer.rex.rb +8 -8
  32. data/bundle/ruby/2.5.0/gems/{ruby_parser-3.12.0 → ruby_parser-3.13.0}/lib/ruby_parser.rb +5 -7
  33. data/bundle/ruby/2.5.0/gems/ruby_parser-3.13.0/lib/ruby_parser.yy +2571 -0
  34. data/bundle/ruby/2.5.0/gems/ruby_parser-3.13.0/lib/ruby_parser_extras.rb +1360 -0
  35. data/bundle/ruby/2.5.0/gems/ruby_parser-3.13.0/tools/munge.rb +216 -0
  36. data/bundle/ruby/2.5.0/gems/ruby_parser-3.13.0/tools/ripper.rb +23 -0
  37. data/bundle/ruby/2.5.0/gems/ruby_parser-legacy-1.0.0/History.rdoc +6 -0
  38. data/bundle/ruby/2.5.0/gems/ruby_parser-legacy-1.0.0/Manifest.txt +19 -0
  39. data/bundle/ruby/2.5.0/gems/ruby_parser-legacy-1.0.0/README.rdoc +54 -0
  40. data/bundle/ruby/2.5.0/gems/ruby_parser-legacy-1.0.0/lib/ruby_parser/legacy.rb +5 -0
  41. data/bundle/ruby/2.5.0/gems/{ruby_parser-3.12.0/lib → ruby_parser-legacy-1.0.0/lib/ruby_parser/legacy}/ruby18_parser.rb +7 -6
  42. data/bundle/ruby/2.5.0/gems/{ruby_parser-3.12.0/lib → ruby_parser-legacy-1.0.0/lib/ruby_parser/legacy}/ruby18_parser.y +5 -4
  43. data/bundle/ruby/2.5.0/gems/{ruby_parser-3.12.0/lib → ruby_parser-legacy-1.0.0/lib/ruby_parser/legacy}/ruby19_parser.rb +7 -6
  44. data/bundle/ruby/2.5.0/gems/{ruby_parser-3.12.0/lib → ruby_parser-legacy-1.0.0/lib/ruby_parser/legacy}/ruby19_parser.y +5 -4
  45. data/bundle/ruby/2.5.0/gems/ruby_parser-legacy-1.0.0/lib/ruby_parser/legacy/ruby_lexer.rb +1412 -0
  46. data/bundle/ruby/2.5.0/gems/ruby_parser-legacy-1.0.0/lib/ruby_parser/legacy/ruby_lexer.rex +179 -0
  47. data/bundle/ruby/2.5.0/gems/ruby_parser-legacy-1.0.0/lib/ruby_parser/legacy/ruby_lexer.rex.rb +323 -0
  48. data/bundle/ruby/2.5.0/gems/ruby_parser-legacy-1.0.0/lib/ruby_parser/legacy/ruby_parser.rb +30 -0
  49. data/bundle/ruby/2.5.0/gems/{ruby_parser-3.12.0/lib → ruby_parser-legacy-1.0.0/lib/ruby_parser/legacy}/ruby_parser_extras.rb +43 -33
  50. data/bundle/ruby/2.5.0/gems/{safe_yaml-1.0.4 → safe_yaml-1.0.5}/CHANGES.md +5 -0
  51. data/bundle/ruby/2.5.0/gems/{safe_yaml-1.0.4 → safe_yaml-1.0.5}/Gemfile +0 -0
  52. data/bundle/ruby/2.5.0/gems/{safe_yaml-1.0.4 → safe_yaml-1.0.5}/LICENSE.txt +0 -0
  53. data/bundle/ruby/2.5.0/gems/{safe_yaml-1.0.4 → safe_yaml-1.0.5}/README.md +0 -0
  54. data/bundle/ruby/2.5.0/gems/{safe_yaml-1.0.4 → safe_yaml-1.0.5}/bundle_install_all_ruby_versions.sh +0 -0
  55. data/bundle/ruby/2.5.0/gems/{safe_yaml-1.0.4 → safe_yaml-1.0.5}/lib/safe_yaml.rb +0 -0
  56. data/bundle/ruby/2.5.0/gems/{safe_yaml-1.0.4 → safe_yaml-1.0.5}/lib/safe_yaml/deep.rb +0 -0
  57. data/bundle/ruby/2.5.0/gems/{safe_yaml-1.0.4 → safe_yaml-1.0.5}/lib/safe_yaml/libyaml_checker.rb +0 -0
  58. data/bundle/ruby/2.5.0/gems/{safe_yaml-1.0.4 → safe_yaml-1.0.5}/lib/safe_yaml/load.rb +0 -0
  59. data/bundle/ruby/2.5.0/gems/{safe_yaml-1.0.4 → safe_yaml-1.0.5}/lib/safe_yaml/parse/date.rb +2 -0
  60. data/bundle/ruby/2.5.0/gems/{safe_yaml-1.0.4 → safe_yaml-1.0.5}/lib/safe_yaml/parse/hexadecimal.rb +0 -0
  61. data/bundle/ruby/2.5.0/gems/{safe_yaml-1.0.4 → safe_yaml-1.0.5}/lib/safe_yaml/parse/sexagesimal.rb +0 -0
  62. data/bundle/ruby/2.5.0/gems/{safe_yaml-1.0.4 → safe_yaml-1.0.5}/lib/safe_yaml/psych_handler.rb +0 -0
  63. data/bundle/ruby/2.5.0/gems/{safe_yaml-1.0.4 → safe_yaml-1.0.5}/lib/safe_yaml/psych_resolver.rb +0 -0
  64. data/bundle/ruby/2.5.0/gems/{safe_yaml-1.0.4 → safe_yaml-1.0.5}/lib/safe_yaml/resolver.rb +0 -0
  65. data/bundle/ruby/2.5.0/gems/{safe_yaml-1.0.4 → safe_yaml-1.0.5}/lib/safe_yaml/safe_to_ruby_visitor.rb +0 -0
  66. data/bundle/ruby/2.5.0/gems/safe_yaml-1.0.5/lib/safe_yaml/store.rb +39 -0
  67. data/bundle/ruby/2.5.0/gems/{safe_yaml-1.0.4 → safe_yaml-1.0.5}/lib/safe_yaml/syck_hack.rb +0 -0
  68. data/bundle/ruby/2.5.0/gems/{safe_yaml-1.0.4 → safe_yaml-1.0.5}/lib/safe_yaml/syck_node_monkeypatch.rb +0 -0
  69. data/bundle/ruby/2.5.0/gems/{safe_yaml-1.0.4 → safe_yaml-1.0.5}/lib/safe_yaml/syck_resolver.rb +0 -0
  70. data/bundle/ruby/2.5.0/gems/{safe_yaml-1.0.4 → safe_yaml-1.0.5}/lib/safe_yaml/transform.rb +0 -0
  71. data/bundle/ruby/2.5.0/gems/{safe_yaml-1.0.4 → safe_yaml-1.0.5}/lib/safe_yaml/transform/to_boolean.rb +0 -0
  72. data/bundle/ruby/2.5.0/gems/{safe_yaml-1.0.4 → safe_yaml-1.0.5}/lib/safe_yaml/transform/to_date.rb +0 -0
  73. data/bundle/ruby/2.5.0/gems/{safe_yaml-1.0.4 → safe_yaml-1.0.5}/lib/safe_yaml/transform/to_float.rb +0 -0
  74. data/bundle/ruby/2.5.0/gems/{safe_yaml-1.0.4 → safe_yaml-1.0.5}/lib/safe_yaml/transform/to_integer.rb +0 -0
  75. data/bundle/ruby/2.5.0/gems/{safe_yaml-1.0.4 → safe_yaml-1.0.5}/lib/safe_yaml/transform/to_nil.rb +0 -0
  76. data/bundle/ruby/2.5.0/gems/{safe_yaml-1.0.4 → safe_yaml-1.0.5}/lib/safe_yaml/transform/to_symbol.rb +0 -0
  77. data/bundle/ruby/2.5.0/gems/{safe_yaml-1.0.4 → safe_yaml-1.0.5}/lib/safe_yaml/transform/transformation_map.rb +0 -0
  78. data/bundle/ruby/2.5.0/gems/{safe_yaml-1.0.4 → safe_yaml-1.0.5}/lib/safe_yaml/version.rb +1 -1
  79. data/bundle/ruby/2.5.0/gems/{safe_yaml-1.0.4 → safe_yaml-1.0.5}/run_specs_all_ruby_versions.sh +0 -0
  80. data/bundle/ruby/2.5.0/gems/{safe_yaml-1.0.4 → safe_yaml-1.0.5}/safe_yaml.gemspec +0 -0
  81. data/bundle/ruby/2.5.0/gems/{sexp_processor-4.11.0 → sexp_processor-4.12.0}/History.rdoc +8 -0
  82. data/bundle/ruby/2.5.0/gems/{sexp_processor-4.11.0 → sexp_processor-4.12.0}/Manifest.txt +0 -0
  83. data/bundle/ruby/2.5.0/gems/{sexp_processor-4.11.0 → sexp_processor-4.12.0}/README.rdoc +0 -0
  84. data/bundle/ruby/2.5.0/gems/{sexp_processor-4.11.0 → sexp_processor-4.12.0}/lib/composite_sexp_processor.rb +0 -0
  85. data/bundle/ruby/2.5.0/gems/{sexp_processor-4.11.0 → sexp_processor-4.12.0}/lib/pt_testcase.rb +2 -2
  86. data/bundle/ruby/2.5.0/gems/{sexp_processor-4.11.0 → sexp_processor-4.12.0}/lib/sexp.rb +4 -4
  87. data/bundle/ruby/2.5.0/gems/{sexp_processor-4.11.0 → sexp_processor-4.12.0}/lib/sexp_processor.rb +1 -1
  88. data/bundle/ruby/2.5.0/gems/{sexp_processor-4.11.0 → sexp_processor-4.12.0}/lib/strict_sexp.rb +3 -3
  89. data/bundle/ruby/2.5.0/gems/{sexp_processor-4.11.0 → sexp_processor-4.12.0}/lib/unique.rb +0 -0
  90. data/bundle/ruby/2.5.0/gems/{temple-0.8.0 → temple-0.8.1}/CHANGES +6 -0
  91. data/bundle/ruby/2.5.0/gems/{temple-0.8.0 → temple-0.8.1}/EXPRESSIONS.md +1 -1
  92. data/bundle/ruby/2.5.0/gems/{temple-0.8.0 → temple-0.8.1}/Gemfile +0 -0
  93. data/bundle/ruby/2.5.0/gems/{temple-0.8.0 → temple-0.8.1}/LICENSE +0 -0
  94. data/bundle/ruby/2.5.0/gems/{temple-0.8.0 → temple-0.8.1}/README.md +1 -1
  95. data/bundle/ruby/2.5.0/gems/{temple-0.8.0 → temple-0.8.1}/lib/temple.rb +0 -0
  96. data/bundle/ruby/2.5.0/gems/{temple-0.8.0 → temple-0.8.1}/lib/temple/engine.rb +0 -0
  97. data/bundle/ruby/2.5.0/gems/{temple-0.8.0 → temple-0.8.1}/lib/temple/erb/engine.rb +0 -0
  98. data/bundle/ruby/2.5.0/gems/{temple-0.8.0 → temple-0.8.1}/lib/temple/erb/parser.rb +0 -0
  99. data/bundle/ruby/2.5.0/gems/{temple-0.8.0 → temple-0.8.1}/lib/temple/erb/template.rb +0 -0
  100. data/bundle/ruby/2.5.0/gems/{temple-0.8.0 → temple-0.8.1}/lib/temple/erb/trimming.rb +0 -0
  101. data/bundle/ruby/2.5.0/gems/{temple-0.8.0 → temple-0.8.1}/lib/temple/exceptions.rb +0 -0
  102. data/bundle/ruby/2.5.0/gems/{temple-0.8.0 → temple-0.8.1}/lib/temple/filter.rb +0 -0
  103. data/bundle/ruby/2.5.0/gems/{temple-0.8.0 → temple-0.8.1}/lib/temple/filters/code_merger.rb +0 -0
  104. data/bundle/ruby/2.5.0/gems/{temple-0.8.0 → temple-0.8.1}/lib/temple/filters/control_flow.rb +0 -0
  105. data/bundle/ruby/2.5.0/gems/{temple-0.8.0 → temple-0.8.1}/lib/temple/filters/dynamic_inliner.rb +0 -0
  106. data/bundle/ruby/2.5.0/gems/{temple-0.8.0 → temple-0.8.1}/lib/temple/filters/encoding.rb +0 -0
  107. data/bundle/ruby/2.5.0/gems/{temple-0.8.0 → temple-0.8.1}/lib/temple/filters/eraser.rb +0 -0
  108. data/bundle/ruby/2.5.0/gems/{temple-0.8.0 → temple-0.8.1}/lib/temple/filters/escapable.rb +0 -0
  109. data/bundle/ruby/2.5.0/gems/{temple-0.8.0 → temple-0.8.1}/lib/temple/filters/multi_flattener.rb +0 -0
  110. data/bundle/ruby/2.5.0/gems/{temple-0.8.0 → temple-0.8.1}/lib/temple/filters/remove_bom.rb +0 -0
  111. data/bundle/ruby/2.5.0/gems/{temple-0.8.0 → temple-0.8.1}/lib/temple/filters/static_analyzer.rb +0 -0
  112. data/bundle/ruby/2.5.0/gems/{temple-0.8.0 → temple-0.8.1}/lib/temple/filters/static_merger.rb +0 -0
  113. data/bundle/ruby/2.5.0/gems/{temple-0.8.0 → temple-0.8.1}/lib/temple/filters/string_splitter.rb +0 -0
  114. data/bundle/ruby/2.5.0/gems/{temple-0.8.0 → temple-0.8.1}/lib/temple/filters/validator.rb +0 -0
  115. data/bundle/ruby/2.5.0/gems/{temple-0.8.0 → temple-0.8.1}/lib/temple/generator.rb +0 -0
  116. data/bundle/ruby/2.5.0/gems/{temple-0.8.0 → temple-0.8.1}/lib/temple/generators/array.rb +0 -0
  117. data/bundle/ruby/2.5.0/gems/{temple-0.8.0 → temple-0.8.1}/lib/temple/generators/array_buffer.rb +0 -0
  118. data/bundle/ruby/2.5.0/gems/{temple-0.8.0 → temple-0.8.1}/lib/temple/generators/erb.rb +0 -0
  119. data/bundle/ruby/2.5.0/gems/{temple-0.8.0 → temple-0.8.1}/lib/temple/generators/rails_output_buffer.rb +0 -0
  120. data/bundle/ruby/2.5.0/gems/{temple-0.8.0 → temple-0.8.1}/lib/temple/generators/string_buffer.rb +0 -0
  121. data/bundle/ruby/2.5.0/gems/{temple-0.8.0 → temple-0.8.1}/lib/temple/grammar.rb +0 -0
  122. data/bundle/ruby/2.5.0/gems/{temple-0.8.0 → temple-0.8.1}/lib/temple/html/attribute_merger.rb +0 -0
  123. data/bundle/ruby/2.5.0/gems/{temple-0.8.0 → temple-0.8.1}/lib/temple/html/attribute_remover.rb +0 -0
  124. data/bundle/ruby/2.5.0/gems/{temple-0.8.0 → temple-0.8.1}/lib/temple/html/attribute_sorter.rb +0 -0
  125. data/bundle/ruby/2.5.0/gems/{temple-0.8.0 → temple-0.8.1}/lib/temple/html/dispatcher.rb +0 -0
  126. data/bundle/ruby/2.5.0/gems/{temple-0.8.0 → temple-0.8.1}/lib/temple/html/fast.rb +0 -0
  127. data/bundle/ruby/2.5.0/gems/{temple-0.8.0 → temple-0.8.1}/lib/temple/html/filter.rb +0 -0
  128. data/bundle/ruby/2.5.0/gems/{temple-0.8.0 → temple-0.8.1}/lib/temple/html/pretty.rb +0 -0
  129. data/bundle/ruby/2.5.0/gems/{temple-0.8.0 → temple-0.8.1}/lib/temple/html/safe.rb +0 -0
  130. data/bundle/ruby/2.5.0/gems/{temple-0.8.0 → temple-0.8.1}/lib/temple/map.rb +0 -0
  131. data/bundle/ruby/2.5.0/gems/{temple-0.8.0 → temple-0.8.1}/lib/temple/mixins/dispatcher.rb +2 -1
  132. data/bundle/ruby/2.5.0/gems/{temple-0.8.0 → temple-0.8.1}/lib/temple/mixins/engine_dsl.rb +0 -0
  133. data/bundle/ruby/2.5.0/gems/{temple-0.8.0 → temple-0.8.1}/lib/temple/mixins/grammar_dsl.rb +0 -0
  134. data/bundle/ruby/2.5.0/gems/{temple-0.8.0 → temple-0.8.1}/lib/temple/mixins/options.rb +0 -0
  135. data/bundle/ruby/2.5.0/gems/{temple-0.8.0 → temple-0.8.1}/lib/temple/mixins/template.rb +0 -0
  136. data/bundle/ruby/2.5.0/gems/{temple-0.8.0 → temple-0.8.1}/lib/temple/parser.rb +0 -0
  137. data/bundle/ruby/2.5.0/gems/{temple-0.8.0 → temple-0.8.1}/lib/temple/static_analyzer.rb +0 -0
  138. data/bundle/ruby/2.5.0/gems/{temple-0.8.0 → temple-0.8.1}/lib/temple/templates.rb +0 -0
  139. data/bundle/ruby/2.5.0/gems/{temple-0.8.0 → temple-0.8.1}/lib/temple/templates/rails.rb +2 -2
  140. data/bundle/ruby/2.5.0/gems/{temple-0.8.0 → temple-0.8.1}/lib/temple/templates/tilt.rb +0 -0
  141. data/bundle/ruby/2.5.0/gems/{temple-0.8.0 → temple-0.8.1}/lib/temple/utils.rb +0 -0
  142. data/bundle/ruby/2.5.0/gems/temple-0.8.1/lib/temple/version.rb +3 -0
  143. data/bundle/ruby/2.5.0/gems/{temple-0.8.0 → temple-0.8.1}/temple.gemspec +0 -0
  144. data/bundle/ruby/2.5.0/gems/{unicode-display_width-1.4.1 → unicode-display_width-1.5.0}/CHANGELOG.md +4 -0
  145. data/bundle/ruby/2.5.0/gems/{unicode-display_width-1.4.1 → unicode-display_width-1.5.0}/MIT-LICENSE.txt +1 -1
  146. data/bundle/ruby/2.5.0/gems/{unicode-display_width-1.4.1 → unicode-display_width-1.5.0}/README.md +10 -10
  147. data/bundle/ruby/2.5.0/gems/unicode-display_width-1.5.0/data/display_width.marshal.gz +0 -0
  148. data/bundle/ruby/2.5.0/gems/{unicode-display_width-1.4.1 → unicode-display_width-1.5.0}/lib/unicode/display_width.rb +0 -0
  149. data/bundle/ruby/2.5.0/gems/{unicode-display_width-1.4.1 → unicode-display_width-1.5.0}/lib/unicode/display_width/constants.rb +2 -2
  150. data/bundle/ruby/2.5.0/gems/{unicode-display_width-1.4.1 → unicode-display_width-1.5.0}/lib/unicode/display_width/index.rb +0 -0
  151. data/bundle/ruby/2.5.0/gems/{unicode-display_width-1.4.1 → unicode-display_width-1.5.0}/lib/unicode/display_width/no_string_ext.rb +0 -0
  152. data/bundle/ruby/2.5.0/gems/{unicode-display_width-1.4.1 → unicode-display_width-1.5.0}/lib/unicode/display_width/string_ext.rb +0 -0
  153. data/lib/brakeman/checks/base_check.rb +16 -0
  154. data/lib/brakeman/checks/check_content_tag.rb +12 -0
  155. data/lib/brakeman/checks/check_cross_site_scripting.rb +6 -6
  156. data/lib/brakeman/checks/check_evaluation.rb +0 -1
  157. data/lib/brakeman/checks/check_execute.rb +18 -0
  158. data/lib/brakeman/checks/check_send.rb +0 -1
  159. data/lib/brakeman/checks/check_session_manipulation.rb +0 -1
  160. data/lib/brakeman/checks/check_sql.rb +12 -3
  161. data/lib/brakeman/file_parser.rb +8 -4
  162. data/lib/brakeman/parsers/haml_embedded.rb +44 -0
  163. data/lib/brakeman/parsers/slim_embedded.rb +44 -0
  164. data/lib/brakeman/parsers/template_parser.rb +2 -4
  165. data/lib/brakeman/processors/alias_processor.rb +23 -1
  166. data/lib/brakeman/processors/lib/call_conversion_helper.rb +4 -0
  167. data/lib/brakeman/processors/slim_template_processor.rb +16 -0
  168. data/lib/brakeman/processors/template_alias_processor.rb +2 -2
  169. data/lib/brakeman/scanner.rb +11 -10
  170. data/lib/brakeman/tracker.rb +5 -1
  171. data/lib/brakeman/tracker/config.rb +32 -7
  172. data/lib/brakeman/util.rb +17 -0
  173. data/lib/brakeman/version.rb +1 -1
  174. metadata +157 -320
  175. data/bundle/ruby/2.5.0/gems/ruby_parser-3.12.0/lib/ruby20_parser.rb +0 -6687
  176. data/bundle/ruby/2.5.0/gems/ruby_parser-3.12.0/lib/ruby21_parser.rb +0 -6767
  177. data/bundle/ruby/2.5.0/gems/ruby_parser-3.12.0/lib/ruby22_parser.rb +0 -6803
  178. data/bundle/ruby/2.5.0/gems/ruby_parser-3.12.0/lib/ruby22_parser.y +0 -2376
  179. data/bundle/ruby/2.5.0/gems/ruby_parser-3.12.0/lib/ruby23_parser.rb +0 -6818
  180. data/bundle/ruby/2.5.0/gems/ruby_parser-3.12.0/lib/ruby24_parser.rb +0 -6818
  181. data/bundle/ruby/2.5.0/gems/ruby_parser-3.12.0/lib/ruby25_parser.rb +0 -6818
  182. data/bundle/ruby/2.5.0/gems/sass-3.4.25/CODE_OF_CONDUCT.md +0 -10
  183. data/bundle/ruby/2.5.0/gems/sass-3.4.25/CONTRIBUTING.md +0 -148
  184. data/bundle/ruby/2.5.0/gems/sass-3.4.25/MIT-LICENSE +0 -20
  185. data/bundle/ruby/2.5.0/gems/sass-3.4.25/README.md +0 -227
  186. data/bundle/ruby/2.5.0/gems/sass-3.4.25/REVISION +0 -1
  187. data/bundle/ruby/2.5.0/gems/sass-3.4.25/VERSION +0 -1
  188. data/bundle/ruby/2.5.0/gems/sass-3.4.25/VERSION_DATE +0 -1
  189. data/bundle/ruby/2.5.0/gems/sass-3.4.25/VERSION_NAME +0 -1
  190. data/bundle/ruby/2.5.0/gems/sass-3.4.25/extra/sass-spec-ref.sh +0 -32
  191. data/bundle/ruby/2.5.0/gems/sass-3.4.25/extra/update_watch.rb +0 -13
  192. data/bundle/ruby/2.5.0/gems/sass-3.4.25/init.rb +0 -18
  193. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass.rb +0 -109
  194. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/cache_stores.rb +0 -15
  195. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/cache_stores/base.rb +0 -88
  196. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/cache_stores/chain.rb +0 -34
  197. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/cache_stores/filesystem.rb +0 -60
  198. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/cache_stores/memory.rb +0 -46
  199. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/cache_stores/null.rb +0 -25
  200. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/callbacks.rb +0 -67
  201. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/css.rb +0 -408
  202. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/deprecation.rb +0 -55
  203. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/engine.rb +0 -1226
  204. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/environment.rb +0 -215
  205. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/error.rb +0 -198
  206. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/exec.rb +0 -9
  207. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/exec/base.rb +0 -199
  208. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/exec/sass_convert.rb +0 -283
  209. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/exec/sass_scss.rb +0 -440
  210. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/features.rb +0 -47
  211. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/importers.rb +0 -23
  212. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/importers/base.rb +0 -182
  213. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/importers/deprecated_path.rb +0 -51
  214. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/importers/filesystem.rb +0 -219
  215. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/logger.rb +0 -17
  216. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/logger/base.rb +0 -36
  217. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/logger/delayed.rb +0 -50
  218. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/logger/log_level.rb +0 -45
  219. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/media.rb +0 -210
  220. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/plugin.rb +0 -134
  221. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/plugin/compiler.rb +0 -582
  222. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/plugin/configuration.rb +0 -134
  223. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/plugin/generic.rb +0 -15
  224. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/plugin/merb.rb +0 -48
  225. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/plugin/rack.rb +0 -60
  226. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/plugin/rails.rb +0 -47
  227. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/plugin/staleness_checker.rb +0 -199
  228. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/railtie.rb +0 -10
  229. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/repl.rb +0 -57
  230. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/root.rb +0 -7
  231. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/script.rb +0 -66
  232. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/script/css_lexer.rb +0 -33
  233. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/script/css_parser.rb +0 -33
  234. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/script/css_variable_warning.rb +0 -52
  235. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/script/functions.rb +0 -2693
  236. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/script/lexer.rb +0 -464
  237. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/script/parser.rb +0 -832
  238. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/script/tree.rb +0 -16
  239. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/script/tree/funcall.rb +0 -313
  240. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/script/tree/interpolation.rb +0 -223
  241. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/script/tree/list_literal.rb +0 -104
  242. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/script/tree/literal.rb +0 -49
  243. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/script/tree/map_literal.rb +0 -64
  244. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/script/tree/node.rb +0 -127
  245. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/script/tree/operation.rb +0 -156
  246. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/script/tree/selector.rb +0 -26
  247. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/script/tree/string_interpolation.rb +0 -125
  248. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/script/tree/unary_operation.rb +0 -69
  249. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/script/tree/variable.rb +0 -57
  250. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/script/value.rb +0 -11
  251. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/script/value/arg_list.rb +0 -36
  252. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/script/value/base.rb +0 -241
  253. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/script/value/bool.rb +0 -35
  254. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/script/value/color.rb +0 -698
  255. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/script/value/helpers.rb +0 -272
  256. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/script/value/list.rb +0 -113
  257. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/script/value/map.rb +0 -70
  258. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/script/value/null.rb +0 -44
  259. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/script/value/number.rb +0 -563
  260. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/script/value/string.rb +0 -138
  261. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/scss.rb +0 -14
  262. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/scss/css_parser.rb +0 -56
  263. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/scss/parser.rb +0 -1254
  264. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/scss/rx.rb +0 -140
  265. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/scss/static_parser.rb +0 -373
  266. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/selector.rb +0 -323
  267. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/selector/abstract_sequence.rb +0 -111
  268. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/selector/comma_sequence.rb +0 -191
  269. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/selector/pseudo.rb +0 -266
  270. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/selector/sequence.rb +0 -636
  271. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/selector/simple.rb +0 -117
  272. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/selector/simple_sequence.rb +0 -344
  273. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/shared.rb +0 -76
  274. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/source/map.rb +0 -213
  275. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/source/position.rb +0 -39
  276. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/source/range.rb +0 -41
  277. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/stack.rb +0 -120
  278. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/supports.rb +0 -225
  279. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/tree/at_root_node.rb +0 -83
  280. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/tree/charset_node.rb +0 -22
  281. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/tree/comment_node.rb +0 -82
  282. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/tree/content_node.rb +0 -9
  283. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/tree/css_import_node.rb +0 -68
  284. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/tree/debug_node.rb +0 -18
  285. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/tree/directive_node.rb +0 -59
  286. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/tree/each_node.rb +0 -24
  287. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/tree/error_node.rb +0 -18
  288. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/tree/extend_node.rb +0 -43
  289. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/tree/for_node.rb +0 -36
  290. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/tree/function_node.rb +0 -44
  291. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/tree/if_node.rb +0 -52
  292. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/tree/import_node.rb +0 -75
  293. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/tree/keyframe_rule_node.rb +0 -15
  294. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/tree/media_node.rb +0 -48
  295. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/tree/mixin_def_node.rb +0 -38
  296. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/tree/mixin_node.rb +0 -52
  297. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/tree/node.rb +0 -240
  298. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/tree/prop_node.rb +0 -170
  299. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/tree/return_node.rb +0 -19
  300. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/tree/root_node.rb +0 -44
  301. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/tree/rule_node.rb +0 -155
  302. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/tree/supports_node.rb +0 -38
  303. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/tree/trace_node.rb +0 -33
  304. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/tree/variable_node.rb +0 -36
  305. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/tree/visitors/base.rb +0 -72
  306. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/tree/visitors/check_nesting.rb +0 -173
  307. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/tree/visitors/convert.rb +0 -351
  308. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/tree/visitors/cssize.rb +0 -373
  309. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/tree/visitors/deep_copy.rb +0 -107
  310. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/tree/visitors/extend.rb +0 -70
  311. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/tree/visitors/perform.rb +0 -564
  312. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/tree/visitors/set_options.rb +0 -139
  313. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/tree/visitors/to_css.rb +0 -409
  314. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/tree/warn_node.rb +0 -18
  315. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/tree/while_node.rb +0 -18
  316. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/util.rb +0 -1375
  317. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/util/cross_platform_random.rb +0 -19
  318. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/util/multibyte_string_scanner.rb +0 -155
  319. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/util/normalized_map.rb +0 -129
  320. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/util/ordered_hash.rb +0 -192
  321. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/util/subset_map.rb +0 -109
  322. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/util/test.rb +0 -9
  323. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/version.rb +0 -124
  324. data/bundle/ruby/2.5.0/gems/sass-3.4.25/rails/init.rb +0 -1
  325. data/bundle/ruby/2.5.0/gems/sass-3.4.25/vendor/listen/CHANGELOG.md +0 -1
  326. data/bundle/ruby/2.5.0/gems/sass-3.4.25/vendor/listen/CONTRIBUTING.md +0 -38
  327. data/bundle/ruby/2.5.0/gems/sass-3.4.25/vendor/listen/Gemfile +0 -20
  328. data/bundle/ruby/2.5.0/gems/sass-3.4.25/vendor/listen/Guardfile +0 -8
  329. data/bundle/ruby/2.5.0/gems/sass-3.4.25/vendor/listen/LICENSE +0 -20
  330. data/bundle/ruby/2.5.0/gems/sass-3.4.25/vendor/listen/README.md +0 -349
  331. data/bundle/ruby/2.5.0/gems/sass-3.4.25/vendor/listen/Rakefile +0 -5
  332. data/bundle/ruby/2.5.0/gems/sass-3.4.25/vendor/listen/Vagrantfile +0 -96
  333. data/bundle/ruby/2.5.0/gems/sass-3.4.25/vendor/listen/lib/listen.rb +0 -54
  334. data/bundle/ruby/2.5.0/gems/sass-3.4.25/vendor/listen/lib/listen/adapter.rb +0 -327
  335. data/bundle/ruby/2.5.0/gems/sass-3.4.25/vendor/listen/lib/listen/adapters/bsd.rb +0 -75
  336. data/bundle/ruby/2.5.0/gems/sass-3.4.25/vendor/listen/lib/listen/adapters/darwin.rb +0 -48
  337. data/bundle/ruby/2.5.0/gems/sass-3.4.25/vendor/listen/lib/listen/adapters/linux.rb +0 -81
  338. data/bundle/ruby/2.5.0/gems/sass-3.4.25/vendor/listen/lib/listen/adapters/polling.rb +0 -58
  339. data/bundle/ruby/2.5.0/gems/sass-3.4.25/vendor/listen/lib/listen/adapters/windows.rb +0 -91
  340. data/bundle/ruby/2.5.0/gems/sass-3.4.25/vendor/listen/lib/listen/directory_record.rb +0 -406
  341. data/bundle/ruby/2.5.0/gems/sass-3.4.25/vendor/listen/lib/listen/listener.rb +0 -323
  342. data/bundle/ruby/2.5.0/gems/sass-3.4.25/vendor/listen/lib/listen/turnstile.rb +0 -32
  343. data/bundle/ruby/2.5.0/gems/sass-3.4.25/vendor/listen/lib/listen/version.rb +0 -3
  344. data/bundle/ruby/2.5.0/gems/sass-3.4.25/vendor/listen/listen.gemspec +0 -28
  345. data/bundle/ruby/2.5.0/gems/sass-3.4.25/vendor/listen/spec/listen/adapter_spec.rb +0 -149
  346. data/bundle/ruby/2.5.0/gems/sass-3.4.25/vendor/listen/spec/listen/adapters/bsd_spec.rb +0 -36
  347. data/bundle/ruby/2.5.0/gems/sass-3.4.25/vendor/listen/spec/listen/adapters/darwin_spec.rb +0 -37
  348. data/bundle/ruby/2.5.0/gems/sass-3.4.25/vendor/listen/spec/listen/adapters/linux_spec.rb +0 -47
  349. data/bundle/ruby/2.5.0/gems/sass-3.4.25/vendor/listen/spec/listen/adapters/polling_spec.rb +0 -68
  350. data/bundle/ruby/2.5.0/gems/sass-3.4.25/vendor/listen/spec/listen/adapters/windows_spec.rb +0 -30
  351. data/bundle/ruby/2.5.0/gems/sass-3.4.25/vendor/listen/spec/listen/directory_record_spec.rb +0 -1250
  352. data/bundle/ruby/2.5.0/gems/sass-3.4.25/vendor/listen/spec/listen/listener_spec.rb +0 -258
  353. data/bundle/ruby/2.5.0/gems/sass-3.4.25/vendor/listen/spec/listen/turnstile_spec.rb +0 -56
  354. data/bundle/ruby/2.5.0/gems/sass-3.4.25/vendor/listen/spec/listen_spec.rb +0 -67
  355. data/bundle/ruby/2.5.0/gems/sass-3.4.25/vendor/listen/spec/spec_helper.rb +0 -25
  356. data/bundle/ruby/2.5.0/gems/sass-3.4.25/vendor/listen/spec/support/adapter_helper.rb +0 -666
  357. data/bundle/ruby/2.5.0/gems/sass-3.4.25/vendor/listen/spec/support/directory_record_helper.rb +0 -57
  358. data/bundle/ruby/2.5.0/gems/sass-3.4.25/vendor/listen/spec/support/fixtures_helper.rb +0 -29
  359. data/bundle/ruby/2.5.0/gems/sass-3.4.25/vendor/listen/spec/support/listeners_helper.rb +0 -179
  360. data/bundle/ruby/2.5.0/gems/sass-3.4.25/vendor/listen/spec/support/platform_helper.rb +0 -15
  361. data/bundle/ruby/2.5.0/gems/temple-0.8.0/lib/temple/version.rb +0 -3
  362. data/bundle/ruby/2.5.0/gems/unicode-display_width-1.4.1/data/display_width.marshal.gz +0 -0
@@ -1,18 +0,0 @@
1
- module Sass
2
- module Tree
3
- # A dynamic node representing a Sass `@warn` statement.
4
- #
5
- # @see Sass::Tree
6
- class WarnNode < Node
7
- # The expression to print.
8
- # @return [Script::Tree::Node]
9
- attr_accessor :expr
10
-
11
- # @param expr [Script::Tree::Node] The expression to print
12
- def initialize(expr)
13
- @expr = expr
14
- super()
15
- end
16
- end
17
- end
18
- end
@@ -1,18 +0,0 @@
1
- require 'sass/tree/node'
2
-
3
- module Sass::Tree
4
- # A dynamic node representing a Sass `@while` loop.
5
- #
6
- # @see Sass::Tree
7
- class WhileNode < Node
8
- # The parse tree for the continuation expression.
9
- # @return [Script::Tree::Node]
10
- attr_accessor :expr
11
-
12
- # @param expr [Script::Tree::Node] See \{#expr}
13
- def initialize(expr)
14
- @expr = expr
15
- super()
16
- end
17
- end
18
- end
@@ -1,1375 +0,0 @@
1
- # -*- coding: utf-8 -*-
2
- require 'erb'
3
- require 'set'
4
- require 'enumerator'
5
- require 'stringio'
6
- require 'rbconfig'
7
- require 'uri'
8
- require 'thread'
9
- require 'pathname'
10
-
11
- require 'sass/root'
12
- require 'sass/util/subset_map'
13
-
14
- module Sass
15
- # A module containing various useful functions.
16
- # @comment
17
- # rubocop:disable ModuleLength
18
- module Util
19
- extend self
20
-
21
- # An array of ints representing the Ruby version number.
22
- # @api public
23
- RUBY_VERSION_COMPONENTS = RUBY_VERSION.split(".").map {|s| s.to_i}
24
-
25
- # The Ruby engine we're running under. Defaults to `"ruby"`
26
- # if the top-level constant is undefined.
27
- # @api public
28
- RUBY_ENGINE = defined?(::RUBY_ENGINE) ? ::RUBY_ENGINE : "ruby"
29
-
30
- # Returns the path of a file relative to the Sass root directory.
31
- #
32
- # @param file [String] The filename relative to the Sass root
33
- # @return [String] The filename relative to the the working directory
34
- def scope(file)
35
- File.join(Sass::ROOT_DIR, file)
36
- end
37
-
38
- # Converts an array of `[key, value]` pairs to a hash.
39
- #
40
- # @example
41
- # to_hash([[:foo, "bar"], [:baz, "bang"]])
42
- # #=> {:foo => "bar", :baz => "bang"}
43
- # @param arr [Array<(Object, Object)>] An array of pairs
44
- # @return [Hash] A hash
45
- def to_hash(arr)
46
- ordered_hash(*arr.compact)
47
- end
48
-
49
- # Maps the keys in a hash according to a block.
50
- #
51
- # @example
52
- # map_keys({:foo => "bar", :baz => "bang"}) {|k| k.to_s}
53
- # #=> {"foo" => "bar", "baz" => "bang"}
54
- # @param hash [Hash] The hash to map
55
- # @yield [key] A block in which the keys are transformed
56
- # @yieldparam key [Object] The key that should be mapped
57
- # @yieldreturn [Object] The new value for the key
58
- # @return [Hash] The mapped hash
59
- # @see #map_vals
60
- # @see #map_hash
61
- def map_keys(hash)
62
- map_hash(hash) {|k, v| [yield(k), v]}
63
- end
64
-
65
- # Maps the values in a hash according to a block.
66
- #
67
- # @example
68
- # map_values({:foo => "bar", :baz => "bang"}) {|v| v.to_sym}
69
- # #=> {:foo => :bar, :baz => :bang}
70
- # @param hash [Hash] The hash to map
71
- # @yield [value] A block in which the values are transformed
72
- # @yieldparam value [Object] The value that should be mapped
73
- # @yieldreturn [Object] The new value for the value
74
- # @return [Hash] The mapped hash
75
- # @see #map_keys
76
- # @see #map_hash
77
- def map_vals(hash)
78
- # We don't delegate to map_hash for performance here
79
- # because map_hash does more than is necessary.
80
- rv = hash.class.new
81
- hash = hash.as_stored if hash.is_a?(NormalizedMap)
82
- hash.each do |k, v|
83
- rv[k] = yield(v)
84
- end
85
- rv
86
- end
87
-
88
- # Maps the key-value pairs of a hash according to a block.
89
- #
90
- # @example
91
- # map_hash({:foo => "bar", :baz => "bang"}) {|k, v| [k.to_s, v.to_sym]}
92
- # #=> {"foo" => :bar, "baz" => :bang}
93
- # @param hash [Hash] The hash to map
94
- # @yield [key, value] A block in which the key-value pairs are transformed
95
- # @yieldparam [key] The hash key
96
- # @yieldparam [value] The hash value
97
- # @yieldreturn [(Object, Object)] The new value for the `[key, value]` pair
98
- # @return [Hash] The mapped hash
99
- # @see #map_keys
100
- # @see #map_vals
101
- def map_hash(hash)
102
- # Copy and modify is more performant than mapping to an array and using
103
- # to_hash on the result.
104
- rv = hash.class.new
105
- hash.each do |k, v|
106
- new_key, new_value = yield(k, v)
107
- new_key = hash.denormalize(new_key) if hash.is_a?(NormalizedMap) && new_key == k
108
- rv[new_key] = new_value
109
- end
110
- rv
111
- end
112
-
113
- # Computes the powerset of the given array.
114
- # This is the set of all subsets of the array.
115
- #
116
- # @example
117
- # powerset([1, 2, 3]) #=>
118
- # Set[Set[], Set[1], Set[2], Set[3], Set[1, 2], Set[2, 3], Set[1, 3], Set[1, 2, 3]]
119
- # @param arr [Enumerable]
120
- # @return [Set<Set>] The subsets of `arr`
121
- def powerset(arr)
122
- arr.inject([Set.new].to_set) do |powerset, el|
123
- new_powerset = Set.new
124
- powerset.each do |subset|
125
- new_powerset << subset
126
- new_powerset << subset + [el]
127
- end
128
- new_powerset
129
- end
130
- end
131
-
132
- # Restricts a number to falling within a given range.
133
- # Returns the number if it falls within the range,
134
- # or the closest value in the range if it doesn't.
135
- #
136
- # @param value [Numeric]
137
- # @param range [Range<Numeric>]
138
- # @return [Numeric]
139
- def restrict(value, range)
140
- [[value, range.first].max, range.last].min
141
- end
142
-
143
- # Like [Fixnum.round], but leaves rooms for slight floating-point
144
- # differences.
145
- #
146
- # @param value [Numeric]
147
- # @return [Numeric]
148
- def round(value)
149
- # If the number is within epsilon of X.5, round up (or down for negative
150
- # numbers).
151
- return value.round if (value % 1) - 0.5 <= -1 * Script::Value::Number.epsilon
152
- value > 0 ? value.ceil : value.floor
153
- end
154
-
155
- # Concatenates all strings that are adjacent in an array,
156
- # while leaving other elements as they are.
157
- #
158
- # @example
159
- # merge_adjacent_strings([1, "foo", "bar", 2, "baz"])
160
- # #=> [1, "foobar", 2, "baz"]
161
- # @param arr [Array]
162
- # @return [Array] The enumerable with strings merged
163
- def merge_adjacent_strings(arr)
164
- # Optimize for the common case of one element
165
- return arr if arr.size < 2
166
- arr.inject([]) do |a, e|
167
- if e.is_a?(String)
168
- if a.last.is_a?(String)
169
- a.last << e
170
- else
171
- a << e.dup
172
- end
173
- else
174
- a << e
175
- end
176
- a
177
- end
178
- end
179
-
180
- # Non-destructively replaces all occurrences of a subsequence in an array
181
- # with another subsequence.
182
- #
183
- # @example
184
- # replace_subseq([1, 2, 3, 4, 5], [2, 3], [:a, :b])
185
- # #=> [1, :a, :b, 4, 5]
186
- #
187
- # @param arr [Array] The array whose subsequences will be replaced.
188
- # @param subseq [Array] The subsequence to find and replace.
189
- # @param replacement [Array] The sequence that `subseq` will be replaced with.
190
- # @return [Array] `arr` with `subseq` replaced with `replacement`.
191
- def replace_subseq(arr, subseq, replacement)
192
- new = []
193
- matched = []
194
- i = 0
195
- arr.each do |elem|
196
- if elem != subseq[i]
197
- new.push(*matched)
198
- matched = []
199
- i = 0
200
- new << elem
201
- next
202
- end
203
-
204
- if i == subseq.length - 1
205
- matched = []
206
- i = 0
207
- new.push(*replacement)
208
- else
209
- matched << elem
210
- i += 1
211
- end
212
- end
213
- new.push(*matched)
214
- new
215
- end
216
-
217
- # Intersperses a value in an enumerable, as would be done with `Array#join`
218
- # but without concatenating the array together afterwards.
219
- #
220
- # @param enum [Enumerable]
221
- # @param val
222
- # @return [Array]
223
- def intersperse(enum, val)
224
- enum.inject([]) {|a, e| a << e << val}[0...-1]
225
- end
226
-
227
- def slice_by(enum)
228
- results = []
229
- enum.each do |value|
230
- key = yield(value)
231
- if !results.empty? && results.last.first == key
232
- results.last.last << value
233
- else
234
- results << [key, [value]]
235
- end
236
- end
237
- results
238
- end
239
-
240
- # Substitutes a sub-array of one array with another sub-array.
241
- #
242
- # @param ary [Array] The array in which to make the substitution
243
- # @param from [Array] The sequence of elements to replace with `to`
244
- # @param to [Array] The sequence of elements to replace `from` with
245
- def substitute(ary, from, to)
246
- res = ary.dup
247
- i = 0
248
- while i < res.size
249
- if res[i...i + from.size] == from
250
- res[i...i + from.size] = to
251
- end
252
- i += 1
253
- end
254
- res
255
- end
256
-
257
- # Destructively strips whitespace from the beginning and end
258
- # of the first and last elements, respectively,
259
- # in the array (if those elements are strings).
260
- #
261
- # @param arr [Array]
262
- # @return [Array] `arr`
263
- def strip_string_array(arr)
264
- arr.first.lstrip! if arr.first.is_a?(String)
265
- arr.last.rstrip! if arr.last.is_a?(String)
266
- arr
267
- end
268
-
269
- # Return an array of all possible paths through the given arrays.
270
- #
271
- # @param arrs [Array<Array>]
272
- # @return [Array<Arrays>]
273
- #
274
- # @example
275
- # paths([[1, 2], [3, 4], [5]]) #=>
276
- # # [[1, 3, 5],
277
- # # [2, 3, 5],
278
- # # [1, 4, 5],
279
- # # [2, 4, 5]]
280
- def paths(arrs)
281
- arrs.inject([[]]) do |paths, arr|
282
- arr.map {|e| paths.map {|path| path + [e]}}.flatten(1)
283
- end
284
- end
285
-
286
- # Computes a single longest common subsequence for `x` and `y`.
287
- # If there are more than one longest common subsequences,
288
- # the one returned is that which starts first in `x`.
289
- #
290
- # @param x [Array]
291
- # @param y [Array]
292
- # @yield [a, b] An optional block to use in place of a check for equality
293
- # between elements of `x` and `y`.
294
- # @yieldreturn [Object, nil] If the two values register as equal,
295
- # this will return the value to use in the LCS array.
296
- # @return [Array] The LCS
297
- def lcs(x, y, &block)
298
- x = [nil, *x]
299
- y = [nil, *y]
300
- block ||= proc {|a, b| a == b && a}
301
- lcs_backtrace(lcs_table(x, y, &block), x, y, x.size - 1, y.size - 1, &block)
302
- end
303
-
304
- # Converts a Hash to an Array. This is usually identical to `Hash#to_a`,
305
- # with the following exceptions:
306
- #
307
- # * In Ruby 1.8, `Hash#to_a` is not deterministically ordered, but this is.
308
- # * In Ruby 1.9 when running tests, this is ordered in the same way it would
309
- # be under Ruby 1.8 (sorted key order rather than insertion order).
310
- #
311
- # @param hash [Hash]
312
- # @return [Array]
313
- def hash_to_a(hash)
314
- return hash.to_a unless ruby1_8? || defined?(Test::Unit)
315
- hash.sort_by {|k, _v| k}
316
- end
317
-
318
- # Performs the equivalent of `enum.group_by.to_a`, but with a guaranteed
319
- # order. Unlike {Util#hash_to_a}, the resulting order isn't sorted key order;
320
- # instead, it's the same order as `#group_by` has under Ruby 1.9 (key
321
- # appearance order).
322
- #
323
- # @param enum [Enumerable]
324
- # @return [Array<[Object, Array]>] An array of pairs.
325
- def group_by_to_a(enum)
326
- return enum.group_by {|e| yield(e)}.to_a unless ruby1_8?
327
- order = {}
328
- arr = []
329
- groups = enum.group_by do |e|
330
- res = yield(e)
331
- unless order.include?(res)
332
- order[res] = order.size
333
- end
334
- res
335
- end
336
- groups.each do |key, vals|
337
- arr[order[key]] = [key, vals]
338
- end
339
- arr
340
- end
341
-
342
- # Like `String.upcase`, but only ever upcases ASCII letters.
343
- def upcase(string)
344
- return string.upcase unless ruby2_4?
345
- string.upcase(:ascii)
346
- end
347
-
348
- # Like `String.downcase`, but only ever downcases ASCII letters.
349
- def downcase(string)
350
- return string.downcase unless ruby2_4?
351
- string.downcase(:ascii)
352
- end
353
-
354
- # Returns a sub-array of `minuend` containing only elements that are also in
355
- # `subtrahend`. Ensures that the return value has the same order as
356
- # `minuend`, even on Rubinius where that's not guaranteed by `Array#-`.
357
- #
358
- # @param minuend [Array]
359
- # @param subtrahend [Array]
360
- # @return [Array]
361
- def array_minus(minuend, subtrahend)
362
- return minuend - subtrahend unless rbx?
363
- set = Set.new(minuend) - subtrahend
364
- minuend.select {|e| set.include?(e)}
365
- end
366
-
367
- # Returns the maximum of `val1` and `val2`. We use this over \{Array.max} to
368
- # avoid unnecessary garbage collection.
369
- def max(val1, val2)
370
- val1 > val2 ? val1 : val2
371
- end
372
-
373
- # Returns the minimum of `val1` and `val2`. We use this over \{Array.min} to
374
- # avoid unnecessary garbage collection.
375
- def min(val1, val2)
376
- val1 <= val2 ? val1 : val2
377
- end
378
-
379
- # Returns a string description of the character that caused an
380
- # `Encoding::UndefinedConversionError`.
381
- #
382
- # @param e [Encoding::UndefinedConversionError]
383
- # @return [String]
384
- def undefined_conversion_error_char(e)
385
- # Rubinius (as of 2.0.0.rc1) pre-quotes the error character.
386
- return e.error_char if rbx?
387
- # JRuby (as of 1.7.2) doesn't have an error_char field on
388
- # Encoding::UndefinedConversionError.
389
- return e.error_char.dump unless jruby?
390
- e.message[/^"[^"]+"/] # "
391
- end
392
-
393
- # Asserts that `value` falls within `range` (inclusive), leaving
394
- # room for slight floating-point errors.
395
- #
396
- # @param name [String] The name of the value. Used in the error message.
397
- # @param range [Range] The allowed range of values.
398
- # @param value [Numeric, Sass::Script::Value::Number] The value to check.
399
- # @param unit [String] The unit of the value. Used in error reporting.
400
- # @return [Numeric] `value` adjusted to fall within range, if it
401
- # was outside by a floating-point margin.
402
- def check_range(name, range, value, unit = '')
403
- grace = (-0.00001..0.00001)
404
- str = value.to_s
405
- value = value.value if value.is_a?(Sass::Script::Value::Number)
406
- return value if range.include?(value)
407
- return range.first if grace.include?(value - range.first)
408
- return range.last if grace.include?(value - range.last)
409
- raise ArgumentError.new(
410
- "#{name} #{str} must be between #{range.first}#{unit} and #{range.last}#{unit}")
411
- end
412
-
413
- # Returns whether or not `seq1` is a subsequence of `seq2`. That is, whether
414
- # or not `seq2` contains every element in `seq1` in the same order (and
415
- # possibly more elements besides).
416
- #
417
- # @param seq1 [Array]
418
- # @param seq2 [Array]
419
- # @return [Boolean]
420
- def subsequence?(seq1, seq2)
421
- i = j = 0
422
- loop do
423
- return true if i == seq1.size
424
- return false if j == seq2.size
425
- i += 1 if seq1[i] == seq2[j]
426
- j += 1
427
- end
428
- end
429
-
430
- # Returns information about the caller of the previous method.
431
- #
432
- # @param entry [String] An entry in the `#caller` list, or a similarly formatted string
433
- # @return [[String, Integer, (String, nil)]]
434
- # An array containing the filename, line, and method name of the caller.
435
- # The method name may be nil
436
- def caller_info(entry = nil)
437
- # JRuby evaluates `caller` incorrectly when it's in an actual default argument.
438
- entry ||= caller[1]
439
- info = entry.scan(/^((?:[A-Za-z]:)?.*?):(-?.*?)(?::.*`(.+)')?$/).first
440
- info[1] = info[1].to_i
441
- # This is added by Rubinius to designate a block, but we don't care about it.
442
- info[2].sub!(/ \{\}\Z/, '') if info[2]
443
- info
444
- end
445
-
446
- # Returns whether one version string represents a more recent version than another.
447
- #
448
- # @param v1 [String] A version string.
449
- # @param v2 [String] Another version string.
450
- # @return [Boolean]
451
- def version_gt(v1, v2)
452
- # Construct an array to make sure the shorter version is padded with nil
453
- Array.new([v1.length, v2.length].max).zip(v1.split("."), v2.split(".")) do |_, p1, p2|
454
- p1 ||= "0"
455
- p2 ||= "0"
456
- release1 = p1 =~ /^[0-9]+$/
457
- release2 = p2 =~ /^[0-9]+$/
458
- if release1 && release2
459
- # Integer comparison if both are full releases
460
- p1, p2 = p1.to_i, p2.to_i
461
- next if p1 == p2
462
- return p1 > p2
463
- elsif !release1 && !release2
464
- # String comparison if both are prereleases
465
- next if p1 == p2
466
- return p1 > p2
467
- else
468
- # If only one is a release, that one is newer
469
- return release1
470
- end
471
- end
472
- end
473
-
474
- # Returns whether one version string represents the same or a more
475
- # recent version than another.
476
- #
477
- # @param v1 [String] A version string.
478
- # @param v2 [String] Another version string.
479
- # @return [Boolean]
480
- def version_geq(v1, v2)
481
- version_gt(v1, v2) || !version_gt(v2, v1)
482
- end
483
-
484
- # Throws a NotImplementedError for an abstract method.
485
- #
486
- # @param obj [Object] `self`
487
- # @raise [NotImplementedError]
488
- def abstract(obj)
489
- raise NotImplementedError.new("#{obj.class} must implement ##{caller_info[2]}")
490
- end
491
-
492
- # Prints a deprecation warning for the caller method.
493
- #
494
- # @param obj [Object] `self`
495
- # @param message [String] A message describing what to do instead.
496
- def deprecated(obj, message = nil)
497
- obj_class = obj.is_a?(Class) ? "#{obj}." : "#{obj.class}#"
498
- full_message = "DEPRECATION WARNING: #{obj_class}#{caller_info[2]} " +
499
- "will be removed in a future version of Sass.#{("\n" + message) if message}"
500
- Sass::Util.sass_warn full_message
501
- end
502
-
503
- # Silence all output to STDERR within a block.
504
- #
505
- # @yield A block in which no output will be printed to STDERR
506
- def silence_warnings
507
- the_real_stderr, $stderr = $stderr, StringIO.new
508
- yield
509
- ensure
510
- $stderr = the_real_stderr
511
- end
512
-
513
- # Silences all Sass warnings within a block.
514
- #
515
- # @yield A block in which no Sass warnings will be printed
516
- def silence_sass_warnings
517
- old_level, Sass.logger.log_level = Sass.logger.log_level, :error
518
- yield
519
- ensure
520
- Sass.logger.log_level = old_level
521
- end
522
-
523
- # The same as `Kernel#warn`, but is silenced by \{#silence\_sass\_warnings}.
524
- #
525
- # @param msg [String]
526
- def sass_warn(msg)
527
- msg += "\n" unless ruby1?
528
- Sass.logger.warn(msg)
529
- end
530
-
531
- ## Cross Rails Version Compatibility
532
-
533
- # Returns the root of the Rails application,
534
- # if this is running in a Rails context.
535
- # Returns `nil` if no such root is defined.
536
- #
537
- # @return [String, nil]
538
- def rails_root
539
- if defined?(::Rails.root)
540
- return ::Rails.root.to_s if ::Rails.root
541
- raise "ERROR: Rails.root is nil!"
542
- end
543
- return RAILS_ROOT.to_s if defined?(RAILS_ROOT)
544
- nil
545
- end
546
-
547
- # Returns the environment of the Rails application,
548
- # if this is running in a Rails context.
549
- # Returns `nil` if no such environment is defined.
550
- #
551
- # @return [String, nil]
552
- def rails_env
553
- return ::Rails.env.to_s if defined?(::Rails.env)
554
- return RAILS_ENV.to_s if defined?(RAILS_ENV)
555
- nil
556
- end
557
-
558
- # Returns whether this environment is using ActionPack
559
- # version 3.0.0 or greater.
560
- #
561
- # @return [Boolean]
562
- def ap_geq_3?
563
- ap_geq?("3.0.0.beta1")
564
- end
565
-
566
- # Returns whether this environment is using ActionPack
567
- # of a version greater than or equal to that specified.
568
- #
569
- # @param version [String] The string version number to check against.
570
- # Should be greater than or equal to Rails 3,
571
- # because otherwise ActionPack::VERSION isn't autoloaded
572
- # @return [Boolean]
573
- def ap_geq?(version)
574
- # The ActionPack module is always loaded automatically in Rails >= 3
575
- return false unless defined?(ActionPack) && defined?(ActionPack::VERSION) &&
576
- defined?(ActionPack::VERSION::STRING)
577
-
578
- version_geq(ActionPack::VERSION::STRING, version)
579
- end
580
-
581
- # Returns whether this environment is using Listen
582
- # version 2.0.0 or greater.
583
- #
584
- # @return [Boolean]
585
- def listen_geq_2?
586
- return @listen_geq_2 if defined?(@listen_geq_2)
587
- @listen_geq_2 =
588
- begin
589
- # Make sure we're loading listen/version from the same place that
590
- # we're loading listen itself.
591
- load_listen!
592
- require 'listen/version'
593
- version_geq(::Listen::VERSION, '2.0.0')
594
- rescue LoadError
595
- false
596
- end
597
- end
598
-
599
- # Returns an ActionView::Template* class.
600
- # In pre-3.0 versions of Rails, most of these classes
601
- # were of the form `ActionView::TemplateFoo`,
602
- # while afterwards they were of the form `ActionView;:Template::Foo`.
603
- #
604
- # @param name [#to_s] The name of the class to get.
605
- # For example, `:Error` will return `ActionView::TemplateError`
606
- # or `ActionView::Template::Error`.
607
- def av_template_class(name)
608
- return ActionView.const_get("Template#{name}") if ActionView.const_defined?("Template#{name}")
609
- ActionView::Template.const_get(name.to_s)
610
- end
611
-
612
- ## Cross-OS Compatibility
613
- #
614
- # These methods are cached because some of them are called quite frequently
615
- # and even basic checks like String#== are too costly to be called repeatedly.
616
-
617
- # Whether or not this is running on Windows.
618
- #
619
- # @return [Boolean]
620
- def windows?
621
- return @windows if defined?(@windows)
622
- @windows = (RbConfig::CONFIG['host_os'] =~ /mswin|windows|mingw/i)
623
- end
624
-
625
- # Whether or not this is running on IronRuby.
626
- #
627
- # @return [Boolean]
628
- def ironruby?
629
- return @ironruby if defined?(@ironruby)
630
- @ironruby = RUBY_ENGINE == "ironruby"
631
- end
632
-
633
- # Whether or not this is running on Rubinius.
634
- #
635
- # @return [Boolean]
636
- def rbx?
637
- return @rbx if defined?(@rbx)
638
- @rbx = RUBY_ENGINE == "rbx"
639
- end
640
-
641
- # Whether or not this is running on JRuby.
642
- #
643
- # @return [Boolean]
644
- def jruby?
645
- return @jruby if defined?(@jruby)
646
- @jruby = RUBY_PLATFORM =~ /java/
647
- end
648
-
649
- # Returns an array of ints representing the JRuby version number.
650
- #
651
- # @return [Array<Integer>]
652
- def jruby_version
653
- @jruby_version ||= ::JRUBY_VERSION.split(".").map {|s| s.to_i}
654
- end
655
-
656
- # Like `Dir.glob`, but works with backslash-separated paths on Windows.
657
- #
658
- # @param path [String]
659
- def glob(path)
660
- path = path.tr('\\', '/') if windows?
661
- if block_given?
662
- Dir.glob(path) {|f| yield(f)}
663
- else
664
- Dir.glob(path)
665
- end
666
- end
667
-
668
- # Like `Pathname.new`, but normalizes Windows paths to always use backslash
669
- # separators.
670
- #
671
- # `Pathname#relative_path_from` can break if the two pathnames aren't
672
- # consistent in their slash style.
673
- #
674
- # @param path [String]
675
- # @return [Pathname]
676
- def pathname(path)
677
- path = path.tr("/", "\\") if windows?
678
- Pathname.new(path)
679
- end
680
-
681
- # Like `Pathname#cleanpath`, but normalizes Windows paths to always use
682
- # backslash separators. Normally, `Pathname#cleanpath` actually does the
683
- # reverse -- it will convert backslashes to forward slashes, which can break
684
- # `Pathname#relative_path_from`.
685
- #
686
- # @param path [String, Pathname]
687
- # @return [Pathname]
688
- def cleanpath(path)
689
- path = Pathname.new(path) unless path.is_a?(Pathname)
690
- pathname(path.cleanpath.to_s)
691
- end
692
-
693
- # Returns `path` with all symlinks resolved.
694
- #
695
- # @param path [String, Pathname]
696
- # @return [Pathname]
697
- def realpath(path)
698
- path = Pathname.new(path) unless path.is_a?(Pathname)
699
-
700
- # Explicitly DON'T run #pathname here. We don't want to convert
701
- # to Windows directory separators because we're comparing these
702
- # against the paths returned by Listen, which use forward
703
- # slashes everywhere.
704
- begin
705
- path.realpath
706
- rescue SystemCallError
707
- # If [path] doesn't actually exist, don't bail, just
708
- # return the original.
709
- path
710
- end
711
- end
712
-
713
- # Returns `path` relative to `from`.
714
- #
715
- # This is like `Pathname#relative_path_from` except it accepts both strings
716
- # and pathnames, it handles Windows path separators correctly, and it throws
717
- # an error rather than crashing if the paths use different encodings
718
- # (https://github.com/ruby/ruby/pull/713).
719
- #
720
- # @param path [String, Pathname]
721
- # @param from [String, Pathname]
722
- # @return [Pathname?]
723
- def relative_path_from(path, from)
724
- pathname(path.to_s).relative_path_from(pathname(from.to_s))
725
- rescue NoMethodError => e
726
- raise e unless e.name == :zero?
727
-
728
- # Work around https://github.com/ruby/ruby/pull/713.
729
- path = path.to_s
730
- from = from.to_s
731
- raise ArgumentError("Incompatible path encodings: #{path.inspect} is #{path.encoding}, " +
732
- "#{from.inspect} is #{from.encoding}")
733
- end
734
-
735
- # Converts `path` to a "file:" URI. This handles Windows paths correctly.
736
- #
737
- # @param path [String, Pathname]
738
- # @return [String]
739
- def file_uri_from_path(path)
740
- path = path.to_s if path.is_a?(Pathname)
741
- path = path.tr('\\', '/') if windows?
742
- path = Sass::Util.escape_uri(path)
743
- return path.start_with?('/') ? "file://" + path : path unless windows?
744
- return "file:///" + path.tr("\\", "/") if path =~ %r{^[a-zA-Z]:[/\\]}
745
- return "file:" + path.tr("\\", "/") if path =~ %r{\\\\[^\\]+\\[^\\/]+}
746
- path.tr("\\", "/")
747
- end
748
-
749
- # Retries a filesystem operation if it fails on Windows. Windows
750
- # has weird and flaky locking rules that can cause operations to fail.
751
- #
752
- # @yield [] The filesystem operation.
753
- def retry_on_windows
754
- return yield unless windows?
755
-
756
- begin
757
- yield
758
- rescue SystemCallError
759
- sleep 0.1
760
- yield
761
- end
762
- end
763
-
764
- # Prepare a value for a destructuring assignment (e.g. `a, b =
765
- # val`). This works around a performance bug when using
766
- # ActiveSupport, and only needs to be called when `val` is likely
767
- # to be `nil` reasonably often.
768
- #
769
- # See [this bug report](http://redmine.ruby-lang.org/issues/4917).
770
- #
771
- # @param val [Object]
772
- # @return [Object]
773
- def destructure(val)
774
- val || []
775
- end
776
-
777
- ## Cross-Ruby-Version Compatibility
778
-
779
- # Whether or not this is running under a Ruby version under 2.0.
780
- #
781
- # @return [Boolean]
782
- def ruby1?
783
- return @ruby1 if defined?(@ruby1)
784
- @ruby1 = RUBY_VERSION_COMPONENTS[0] <= 1
785
- end
786
-
787
- # Whether or not this is running under Ruby 1.8 or lower.
788
- #
789
- # Note that IronRuby counts as Ruby 1.8,
790
- # because it doesn't support the Ruby 1.9 encoding API.
791
- #
792
- # @return [Boolean]
793
- def ruby1_8?
794
- # IronRuby says its version is 1.9, but doesn't support any of the encoding APIs.
795
- # We have to fall back to 1.8 behavior.
796
- return @ruby1_8 if defined?(@ruby1_8)
797
- @ruby1_8 = ironruby? ||
798
- (RUBY_VERSION_COMPONENTS[0] == 1 && RUBY_VERSION_COMPONENTS[1] < 9)
799
- end
800
-
801
- # Whether or not this is running under Ruby 1.9.2 exactly.
802
- #
803
- # @return [Boolean]
804
- def ruby1_9_2?
805
- return @ruby1_9_2 if defined?(@ruby1_9_2)
806
- @ruby1_9_2 = RUBY_VERSION_COMPONENTS == [1, 9, 2]
807
- end
808
-
809
- # Whether or not this is running under Ruby 2.4 or higher.
810
- #
811
- # @return [Boolean]
812
- def ruby2_4?
813
- return @ruby2_4 if defined?(@ruby2_4)
814
- @ruby2_4 =
815
- if RUBY_VERSION_COMPONENTS[0] == 2
816
- RUBY_VERSION_COMPONENTS[1] >= 4
817
- else
818
- RUBY_VERSION_COMPONENTS[0] > 2
819
- end
820
- end
821
-
822
- # Wehter or not this is running under JRuby 1.6 or lower.
823
- def jruby1_6?
824
- return @jruby1_6 if defined?(@jruby1_6)
825
- @jruby1_6 = jruby? && jruby_version[0] == 1 && jruby_version[1] < 7
826
- end
827
-
828
- # Whether or not this is running under MacRuby.
829
- #
830
- # @return [Boolean]
831
- def macruby?
832
- return @macruby if defined?(@macruby)
833
- @macruby = RUBY_ENGINE == 'macruby'
834
- end
835
-
836
- require 'sass/util/ordered_hash' if ruby1_8?
837
-
838
- # Converts a hash or a list of pairs into an order-preserving hash.
839
- #
840
- # On Ruby 1.8.7, this uses the orderedhash gem to simulate an
841
- # order-preserving hash. On Ruby 1.9 and up, it just uses the native Hash
842
- # class, since that preserves the order itself.
843
- #
844
- # @overload ordered_hash(hash)
845
- # @param hash [Hash] a normal hash to convert to an ordered hash
846
- # @return [Hash]
847
- # @overload ordered_hash(*pairs)
848
- # @example
849
- # ordered_hash([:foo, "bar"], [:baz, "bang"])
850
- # #=> {:foo => "bar", :baz => "bang"}
851
- # ordered_hash #=> {}
852
- # @param pairs [Array<(Object, Object)>] the list of key/value pairs for
853
- # the hash.
854
- # @return [Hash]
855
- def ordered_hash(*pairs_or_hash)
856
- if pairs_or_hash.length == 1 && pairs_or_hash.first.is_a?(Hash)
857
- hash = pairs_or_hash.first
858
- return hash unless ruby1_8?
859
- return OrderedHash.new.merge hash
860
- end
861
-
862
- return Hash[pairs_or_hash] unless ruby1_8?
863
- (pairs_or_hash.is_a?(NormalizedMap) ? NormalizedMap : OrderedHash)[*pairs_or_hash.flatten(1)]
864
- end
865
-
866
- unless ruby1_8?
867
- CHARSET_REGEXP = /\A@charset "([^"]+)"/
868
- bom = "\uFEFF"
869
- UTF_8_BOM = bom.encode("UTF-8").force_encoding('BINARY')
870
- UTF_16BE_BOM = bom.encode("UTF-16BE").force_encoding('BINARY')
871
- UTF_16LE_BOM = bom.encode("UTF-16LE").force_encoding('BINARY')
872
- end
873
-
874
- # Like {\#check\_encoding}, but also checks for a `@charset` declaration
875
- # at the beginning of the file and uses that encoding if it exists.
876
- #
877
- # Sass follows CSS's decoding rules.
878
- #
879
- # @param str [String] The string of which to check the encoding
880
- # @return [(String, Encoding)] The original string encoded as UTF-8,
881
- # and the source encoding of the string (or `nil` under Ruby 1.8)
882
- # @raise [Encoding::UndefinedConversionError] if the source encoding
883
- # cannot be converted to UTF-8
884
- # @raise [ArgumentError] if the document uses an unknown encoding with `@charset`
885
- # @raise [Sass::SyntaxError] If the document declares an encoding that
886
- # doesn't match its contents, or it doesn't declare an encoding and its
887
- # contents are invalid in the native encoding.
888
- def check_sass_encoding(str)
889
- # On Ruby 1.8 we can't do anything complicated with encodings.
890
- # Instead, we just strip out a UTF-8 BOM if it exists and
891
- # sanitize according to Section 3.3 of CSS Syntax Level 3. We
892
- # don't sanitize null characters since they might be components
893
- # of other characters.
894
- if ruby1_8?
895
- return str.gsub(/\A\xEF\xBB\xBF/, '').gsub(/\r\n?|\f/, "\n"), nil
896
- end
897
-
898
- # Determine the fallback encoding following section 3.2 of CSS Syntax Level 3 and Encodings:
899
- # http://www.w3.org/TR/2013/WD-css-syntax-3-20130919/#determine-the-fallback-encoding
900
- # http://encoding.spec.whatwg.org/#decode
901
- binary = str.dup.force_encoding("BINARY")
902
- if binary.start_with?(UTF_8_BOM)
903
- binary.slice! 0, UTF_8_BOM.length
904
- str = binary.force_encoding('UTF-8')
905
- elsif binary.start_with?(UTF_16BE_BOM)
906
- binary.slice! 0, UTF_16BE_BOM.length
907
- str = binary.force_encoding('UTF-16BE')
908
- elsif binary.start_with?(UTF_16LE_BOM)
909
- binary.slice! 0, UTF_16LE_BOM.length
910
- str = binary.force_encoding('UTF-16LE')
911
- elsif binary =~ CHARSET_REGEXP
912
- charset = $1.force_encoding('US-ASCII')
913
- # Ruby 1.9.2 doesn't recognize a UTF-16 encoding without an endian marker.
914
- if ruby1_9_2? && charset.downcase == 'utf-16'
915
- encoding = Encoding.find('UTF-8')
916
- else
917
- encoding = Encoding.find(charset)
918
- if encoding.name == 'UTF-16' || encoding.name == 'UTF-16BE'
919
- encoding = Encoding.find('UTF-8')
920
- end
921
- end
922
- str = binary.force_encoding(encoding)
923
- elsif str.encoding.name == "ASCII-8BIT"
924
- # Normally we want to fall back on believing the Ruby string
925
- # encoding, but if that's just binary we want to make sure
926
- # it's valid UTF-8.
927
- str = str.force_encoding('utf-8')
928
- end
929
-
930
- find_encoding_error(str) unless str.valid_encoding?
931
-
932
- begin
933
- # If the string is valid, preprocess it according to section 3.3 of CSS Syntax Level 3.
934
- return str.encode("UTF-8").gsub(/\r\n?|\f/, "\n").tr("\u0000", "�"), str.encoding
935
- rescue EncodingError
936
- find_encoding_error(str)
937
- end
938
- end
939
-
940
- # Checks to see if a class has a given method.
941
- # For example:
942
- #
943
- # Sass::Util.has?(:public_instance_method, String, :gsub) #=> true
944
- #
945
- # Method collections like `Class#instance_methods`
946
- # return strings in Ruby 1.8 and symbols in Ruby 1.9 and on,
947
- # so this handles checking for them in a compatible way.
948
- #
949
- # @param attr [#to_s] The (singular) name of the method-collection method
950
- # (e.g. `:instance_methods`, `:private_methods`)
951
- # @param klass [Module] The class to check the methods of which to check
952
- # @param method [String, Symbol] The name of the method do check for
953
- # @return [Boolean] Whether or not the given collection has the given method
954
- def has?(attr, klass, method)
955
- klass.send("#{attr}s").include?(ruby1_8? ? method.to_s : method.to_sym)
956
- end
957
-
958
- # A version of `Enumerable#enum_with_index` that works in Ruby 1.8 and 1.9.
959
- #
960
- # @param enum [Enumerable] The enumerable to get the enumerator for
961
- # @return [Enumerator] The with-index enumerator
962
- def enum_with_index(enum)
963
- ruby1_8? ? enum.enum_with_index : enum.each_with_index
964
- end
965
-
966
- # A version of `Enumerable#enum_cons` that works in Ruby 1.8 and 1.9.
967
- #
968
- # @param enum [Enumerable] The enumerable to get the enumerator for
969
- # @param n [Integer] The size of each cons
970
- # @return [Enumerator] The consed enumerator
971
- def enum_cons(enum, n)
972
- ruby1_8? ? enum.enum_cons(n) : enum.each_cons(n)
973
- end
974
-
975
- # A version of `Enumerable#enum_slice` that works in Ruby 1.8 and 1.9.
976
- #
977
- # @param enum [Enumerable] The enumerable to get the enumerator for
978
- # @param n [Integer] The size of each slice
979
- # @return [Enumerator] The consed enumerator
980
- def enum_slice(enum, n)
981
- ruby1_8? ? enum.enum_slice(n) : enum.each_slice(n)
982
- end
983
-
984
- # Destructively removes all elements from an array that match a block, and
985
- # returns the removed elements.
986
- #
987
- # @param array [Array] The array from which to remove elements.
988
- # @yield [el] Called for each element.
989
- # @yieldparam el [*] The element to test.
990
- # @yieldreturn [Boolean] Whether or not to extract the element.
991
- # @return [Array] The extracted elements.
992
- def extract!(array)
993
- out = []
994
- array.reject! do |e|
995
- next false unless yield e
996
- out << e
997
- true
998
- end
999
- out
1000
- end
1001
-
1002
- # Returns the ASCII code of the given character.
1003
- #
1004
- # @param c [String] All characters but the first are ignored.
1005
- # @return [Integer] The ASCII code of `c`.
1006
- def ord(c)
1007
- ruby1_8? ? c[0] : c.ord
1008
- end
1009
-
1010
- # Flattens the first level of nested arrays in `arrs`. Unlike
1011
- # `Array#flatten`, this orders the result by taking the first
1012
- # values from each array in order, then the second, and so on.
1013
- #
1014
- # @param arrs [Array] The array to flatten.
1015
- # @return [Array] The flattened array.
1016
- def flatten_vertically(arrs)
1017
- result = []
1018
- arrs = arrs.map {|sub| sub.is_a?(Array) ? sub.dup : Array(sub)}
1019
- until arrs.empty?
1020
- arrs.reject! do |arr|
1021
- result << arr.shift
1022
- arr.empty?
1023
- end
1024
- end
1025
- result
1026
- end
1027
-
1028
- # Like `Object#inspect`, but preserves non-ASCII characters rather than
1029
- # escaping them under Ruby 1.9.2. This is necessary so that the
1030
- # precompiled Haml template can be `#encode`d into `@options[:encoding]`
1031
- # before being evaluated.
1032
- #
1033
- # @param obj {Object}
1034
- # @return {String}
1035
- def inspect_obj(obj)
1036
- return obj.inspect unless version_geq(RUBY_VERSION, "1.9.2")
1037
- return ':' + inspect_obj(obj.to_s) if obj.is_a?(Symbol)
1038
- return obj.inspect unless obj.is_a?(String)
1039
- '"' + obj.gsub(/[\x00-\x7F]+/) {|s| s.inspect[1...-1]} + '"'
1040
- end
1041
-
1042
- # Extracts the non-string vlaues from an array containing both strings and non-strings.
1043
- # These values are replaced with escape sequences.
1044
- # This can be undone using \{#inject\_values}.
1045
- #
1046
- # This is useful e.g. when we want to do string manipulation
1047
- # on an interpolated string.
1048
- #
1049
- # The precise format of the resulting string is not guaranteed.
1050
- # However, it is guaranteed that newlines and whitespace won't be affected.
1051
- #
1052
- # @param arr [Array] The array from which values are extracted.
1053
- # @return [(String, Array)] The resulting string, and an array of extracted values.
1054
- def extract_values(arr)
1055
- values = []
1056
- mapped = arr.map do |e|
1057
- next e.gsub('{', '{{') if e.is_a?(String)
1058
- values << e
1059
- next "{#{values.count - 1}}"
1060
- end
1061
- return mapped.join, values
1062
- end
1063
-
1064
- # Undoes \{#extract\_values} by transforming a string with escape sequences
1065
- # into an array of strings and non-string values.
1066
- #
1067
- # @param str [String] The string with escape sequences.
1068
- # @param values [Array] The array of values to inject.
1069
- # @return [Array] The array of strings and values.
1070
- def inject_values(str, values)
1071
- return [str.gsub('{{', '{')] if values.empty?
1072
- # Add an extra { so that we process the tail end of the string
1073
- result = (str + '{{').scan(/(.*?)(?:(\{\{)|\{(\d+)\})/m).map do |(pre, esc, n)|
1074
- [pre, esc ? '{' : '', n ? values[n.to_i] : '']
1075
- end.flatten(1)
1076
- result[-2] = '' # Get rid of the extra {
1077
- merge_adjacent_strings(result).reject {|s| s == ''}
1078
- end
1079
-
1080
- # Allows modifications to be performed on the string form
1081
- # of an array containing both strings and non-strings.
1082
- #
1083
- # @param arr [Array] The array from which values are extracted.
1084
- # @yield [str] A block in which string manipulation can be done to the array.
1085
- # @yieldparam str [String] The string form of `arr`.
1086
- # @yieldreturn [String] The modified string.
1087
- # @return [Array] The modified, interpolated array.
1088
- def with_extracted_values(arr)
1089
- str, vals = extract_values(arr)
1090
- str = yield str
1091
- inject_values(str, vals)
1092
- end
1093
-
1094
- # Builds a sourcemap file name given the generated CSS file name.
1095
- #
1096
- # @param css [String] The generated CSS file name.
1097
- # @return [String] The source map file name.
1098
- def sourcemap_name(css)
1099
- css + ".map"
1100
- end
1101
-
1102
- # Escapes certain characters so that the result can be used
1103
- # as the JSON string value. Returns the original string if
1104
- # no escaping is necessary.
1105
- #
1106
- # @param s [String] The string to be escaped
1107
- # @return [String] The escaped string
1108
- def json_escape_string(s)
1109
- return s if s !~ /["\\\b\f\n\r\t]/
1110
-
1111
- result = ""
1112
- s.split("").each do |c|
1113
- case c
1114
- when '"', "\\"
1115
- result << "\\" << c
1116
- when "\n" then result << "\\n"
1117
- when "\t" then result << "\\t"
1118
- when "\r" then result << "\\r"
1119
- when "\f" then result << "\\f"
1120
- when "\b" then result << "\\b"
1121
- else
1122
- result << c
1123
- end
1124
- end
1125
- result
1126
- end
1127
-
1128
- # Converts the argument into a valid JSON value.
1129
- #
1130
- # @param v [Integer, String, Array, Boolean, nil]
1131
- # @return [String]
1132
- def json_value_of(v)
1133
- case v
1134
- when Integer
1135
- v.to_s
1136
- when String
1137
- "\"" + json_escape_string(v) + "\""
1138
- when Array
1139
- "[" + v.map {|x| json_value_of(x)}.join(",") + "]"
1140
- when NilClass
1141
- "null"
1142
- when TrueClass
1143
- "true"
1144
- when FalseClass
1145
- "false"
1146
- else
1147
- raise ArgumentError.new("Unknown type: #{v.class.name}")
1148
- end
1149
- end
1150
-
1151
- VLQ_BASE_SHIFT = 5
1152
- VLQ_BASE = 1 << VLQ_BASE_SHIFT
1153
- VLQ_BASE_MASK = VLQ_BASE - 1
1154
- VLQ_CONTINUATION_BIT = VLQ_BASE
1155
-
1156
- BASE64_DIGITS = ('A'..'Z').to_a + ('a'..'z').to_a + ('0'..'9').to_a + ['+', '/']
1157
- BASE64_DIGIT_MAP = begin
1158
- map = {}
1159
- Sass::Util.enum_with_index(BASE64_DIGITS).map do |digit, i|
1160
- map[digit] = i
1161
- end
1162
- map
1163
- end
1164
-
1165
- # Encodes `value` as VLQ (http://en.wikipedia.org/wiki/VLQ).
1166
- #
1167
- # @param value [Integer]
1168
- # @return [String] The encoded value
1169
- def encode_vlq(value)
1170
- if value < 0
1171
- value = ((-value) << 1) | 1
1172
- else
1173
- value <<= 1
1174
- end
1175
-
1176
- result = ''
1177
- begin
1178
- digit = value & VLQ_BASE_MASK
1179
- value >>= VLQ_BASE_SHIFT
1180
- if value > 0
1181
- digit |= VLQ_CONTINUATION_BIT
1182
- end
1183
- result << BASE64_DIGITS[digit]
1184
- end while value > 0
1185
- result
1186
- end
1187
-
1188
- # This is a hack around the fact that you can't instantiate a URI parser on
1189
- # 1.8, so we have to have this hacky stuff to work around it. When 1.8
1190
- # support is dropped, we can remove this method.
1191
- #
1192
- # @private
1193
- URI_ESCAPE = URI.const_defined?("DEFAULT_PARSER") ? URI::DEFAULT_PARSER : URI
1194
-
1195
- # URI-escape `string`.
1196
- #
1197
- # @param string [String]
1198
- # @return [String]
1199
- def escape_uri(string)
1200
- URI_ESCAPE.escape string
1201
- end
1202
-
1203
- # A cross-platform implementation of `File.absolute_path`.
1204
- #
1205
- # @param path [String]
1206
- # @param dir_string [String] The directory to consider [path] relative to.
1207
- # @return [String] The absolute version of `path`.
1208
- def absolute_path(path, dir_string = nil)
1209
- # Ruby 1.8 doesn't support File.absolute_path.
1210
- return File.absolute_path(path, dir_string) unless ruby1_8?
1211
-
1212
- # File.expand_path expands "~", which we don't want.
1213
- return File.expand_path(path, dir_string) unless path[0] == ?~
1214
- File.expand_path(File.join(".", path), dir_string)
1215
- end
1216
-
1217
- ## Static Method Stuff
1218
-
1219
- # The context in which the ERB for \{#def\_static\_method} will be run.
1220
- class StaticConditionalContext
1221
- # @param set [#include?] The set of variables that are defined for this context.
1222
- def initialize(set)
1223
- @set = set
1224
- end
1225
-
1226
- # Checks whether or not a variable is defined for this context.
1227
- #
1228
- # @param name [Symbol] The name of the variable
1229
- # @return [Boolean]
1230
- def method_missing(name, *args)
1231
- super unless args.empty? && !block_given?
1232
- @set.include?(name)
1233
- end
1234
- end
1235
-
1236
- # @private
1237
- ATOMIC_WRITE_MUTEX = Mutex.new
1238
-
1239
- # This creates a temp file and yields it for writing. When the
1240
- # write is complete, the file is moved into the desired location.
1241
- # The atomicity of this operation is provided by the filesystem's
1242
- # rename operation.
1243
- #
1244
- # @param filename [String] The file to write to.
1245
- # @param perms [Integer] The permissions used for creating this file.
1246
- # Will be masked by the process umask. Defaults to readable/writeable
1247
- # by all users however the umask usually changes this to only be writable
1248
- # by the process's user.
1249
- # @yieldparam tmpfile [Tempfile] The temp file that can be written to.
1250
- # @return The value returned by the block.
1251
- def atomic_create_and_write_file(filename, perms = 0666)
1252
- require 'tempfile'
1253
- tmpfile = Tempfile.new(File.basename(filename), File.dirname(filename))
1254
- tmpfile.binmode if tmpfile.respond_to?(:binmode)
1255
- result = yield tmpfile
1256
- tmpfile.close
1257
- ATOMIC_WRITE_MUTEX.synchronize do
1258
- begin
1259
- File.chmod(perms & ~File.umask, tmpfile.path)
1260
- rescue Errno::EPERM
1261
- # If we don't have permissions to chmod the file, don't let that crash
1262
- # the compilation. See issue 1215.
1263
- end
1264
- File.rename tmpfile.path, filename
1265
- end
1266
- result
1267
- ensure
1268
- # close and remove the tempfile if it still exists,
1269
- # presumably due to an error during write
1270
- tmpfile.close if tmpfile
1271
- tmpfile.unlink if tmpfile
1272
- end
1273
-
1274
- def load_listen!
1275
- if defined?(gem)
1276
- begin
1277
- gem 'listen', '>= 1.1.0', '< 3.0.0'
1278
- require 'listen'
1279
- rescue Gem::LoadError
1280
- dir = scope("vendor/listen/lib")
1281
- $LOAD_PATH.unshift dir
1282
- begin
1283
- require 'listen'
1284
- rescue LoadError => e
1285
- if version_geq(RUBY_VERSION, "1.9.3")
1286
- version_constraint = "~> 3.0"
1287
- else
1288
- version_constraint = "~> 1.1"
1289
- end
1290
- e.message << "\n" <<
1291
- "Run \"gem install listen --version '#{version_constraint}'\" to get it."
1292
- raise e
1293
- end
1294
- end
1295
- else
1296
- begin
1297
- require 'listen'
1298
- rescue LoadError => e
1299
- dir = scope("vendor/listen/lib")
1300
- if $LOAD_PATH.include?(dir)
1301
- raise e unless File.exist?(scope(".git"))
1302
- e.message << "\n" <<
1303
- 'Run "git submodule update --init" to get the bundled version.'
1304
- else
1305
- $LOAD_PATH.unshift dir
1306
- retry
1307
- end
1308
- end
1309
- end
1310
- end
1311
-
1312
- private
1313
-
1314
- def find_encoding_error(str)
1315
- encoding = str.encoding
1316
- cr = Regexp.quote("\r".encode(encoding).force_encoding('BINARY'))
1317
- lf = Regexp.quote("\n".encode(encoding).force_encoding('BINARY'))
1318
- ff = Regexp.quote("\f".encode(encoding).force_encoding('BINARY'))
1319
- line_break = /#{cr}#{lf}?|#{ff}|#{lf}/
1320
-
1321
- str.force_encoding("binary").split(line_break).each_with_index do |line, i|
1322
- begin
1323
- line.encode(encoding)
1324
- rescue Encoding::UndefinedConversionError => e
1325
- raise Sass::SyntaxError.new(
1326
- "Invalid #{encoding.name} character #{undefined_conversion_error_char(e)}",
1327
- :line => i + 1)
1328
- end
1329
- end
1330
-
1331
- # We shouldn't get here, but it's possible some weird encoding stuff causes it.
1332
- return str, str.encoding
1333
- end
1334
-
1335
- # Calculates the memoization table for the Least Common Subsequence algorithm.
1336
- # Algorithm from [Wikipedia](http://en.wikipedia.org/wiki/Longest_common_subsequence_problem#Computing_the_length_of_the_LCS)
1337
- def lcs_table(x, y)
1338
- # This method does not take a block as an explicit parameter for performance reasons.
1339
- c = Array.new(x.size) {[]}
1340
- x.size.times {|i| c[i][0] = 0}
1341
- y.size.times {|j| c[0][j] = 0}
1342
- (1...x.size).each do |i|
1343
- (1...y.size).each do |j|
1344
- c[i][j] =
1345
- if yield x[i], y[j]
1346
- c[i - 1][j - 1] + 1
1347
- else
1348
- [c[i][j - 1], c[i - 1][j]].max
1349
- end
1350
- end
1351
- end
1352
- c
1353
- end
1354
- # rubocop:disable ParameterLists
1355
-
1356
- # Computes a single longest common subsequence for arrays x and y.
1357
- # Algorithm from [Wikipedia](http://en.wikipedia.org/wiki/Longest_common_subsequence_problem#Reading_out_an_LCS)
1358
- def lcs_backtrace(c, x, y, i, j, &block)
1359
- # rubocop:enable ParameterList
1360
- return [] if i == 0 || j == 0
1361
- if (v = yield(x[i], y[j]))
1362
- return lcs_backtrace(c, x, y, i - 1, j - 1, &block) << v
1363
- end
1364
-
1365
- return lcs_backtrace(c, x, y, i, j - 1, &block) if c[i][j - 1] > c[i - 1][j]
1366
- lcs_backtrace(c, x, y, i - 1, j, &block)
1367
- end
1368
-
1369
- singleton_methods.each {|method| module_function method}
1370
- end
1371
- end
1372
-
1373
- require 'sass/util/multibyte_string_scanner'
1374
- require 'sass/util/normalized_map'
1375
- require 'sass/util/cross_platform_random'