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,35 +0,0 @@
1
- module Sass::Script::Value
2
- # A SassScript object representing a boolean (true or false) value.
3
- class Bool < Base
4
- # The true value in SassScript.
5
- #
6
- # This is assigned before new is overridden below so that we use the default implementation.
7
- TRUE = new(true)
8
-
9
- # The false value in SassScript.
10
- #
11
- # This is assigned before new is overridden below so that we use the default implementation.
12
- FALSE = new(false)
13
-
14
- # We override object creation so that users of the core API
15
- # will not need to know that booleans are specific constants.
16
- #
17
- # @param value A ruby value that will be tested for truthiness.
18
- # @return [Bool] TRUE if value is truthy, FALSE if value is falsey
19
- def self.new(value)
20
- value ? TRUE : FALSE
21
- end
22
-
23
- # The Ruby value of the boolean.
24
- #
25
- # @return [Boolean]
26
- attr_reader :value
27
- alias_method :to_bool, :value
28
-
29
- # @return [String] "true" or "false"
30
- def to_s(opts = {})
31
- @value.to_s
32
- end
33
- alias_method :to_sass, :to_s
34
- end
35
- end
@@ -1,698 +0,0 @@
1
- module Sass::Script::Value
2
- # A SassScript object representing a CSS color.
3
- #
4
- # A color may be represented internally as RGBA, HSLA, or both.
5
- # It's originally represented as whatever its input is;
6
- # if it's created with RGB values, it's represented as RGBA,
7
- # and if it's created with HSL values, it's represented as HSLA.
8
- # Once a property is accessed that requires the other representation --
9
- # for example, \{#red} for an HSL color --
10
- # that component is calculated and cached.
11
- #
12
- # The alpha channel of a color is independent of its RGB or HSL representation.
13
- # It's always stored, as 1 if nothing else is specified.
14
- # If only the alpha channel is modified using \{#with},
15
- # the cached RGB and HSL values are retained.
16
- class Color < Base
17
- # @private
18
- #
19
- # Convert a ruby integer to a rgba components
20
- # @param color [Integer]
21
- # @return [Array<Integer>] Array of 4 numbers representing r,g,b and alpha
22
- def self.int_to_rgba(color)
23
- rgba = (0..3).map {|n| color >> (n << 3) & 0xff}.reverse
24
- rgba[-1] = rgba[-1] / 255.0
25
- rgba
26
- end
27
-
28
- ALTERNATE_COLOR_NAMES = Sass::Util.map_vals(
29
- {
30
- 'aqua' => 0x00FFFFFF,
31
- 'darkgrey' => 0xA9A9A9FF,
32
- 'darkslategrey' => 0x2F4F4FFF,
33
- 'dimgrey' => 0x696969FF,
34
- 'fuchsia' => 0xFF00FFFF,
35
- 'grey' => 0x808080FF,
36
- 'lightgrey' => 0xD3D3D3FF,
37
- 'lightslategrey' => 0x778899FF,
38
- 'slategrey' => 0x708090FF,
39
- }, &method(:int_to_rgba))
40
-
41
- # A hash from color names to `[red, green, blue]` value arrays.
42
- COLOR_NAMES = Sass::Util.map_vals(
43
- {
44
- 'aliceblue' => 0xF0F8FFFF,
45
- 'antiquewhite' => 0xFAEBD7FF,
46
- 'aquamarine' => 0x7FFFD4FF,
47
- 'azure' => 0xF0FFFFFF,
48
- 'beige' => 0xF5F5DCFF,
49
- 'bisque' => 0xFFE4C4FF,
50
- 'black' => 0x000000FF,
51
- 'blanchedalmond' => 0xFFEBCDFF,
52
- 'blue' => 0x0000FFFF,
53
- 'blueviolet' => 0x8A2BE2FF,
54
- 'brown' => 0xA52A2AFF,
55
- 'burlywood' => 0xDEB887FF,
56
- 'cadetblue' => 0x5F9EA0FF,
57
- 'chartreuse' => 0x7FFF00FF,
58
- 'chocolate' => 0xD2691EFF,
59
- 'coral' => 0xFF7F50FF,
60
- 'cornflowerblue' => 0x6495EDFF,
61
- 'cornsilk' => 0xFFF8DCFF,
62
- 'crimson' => 0xDC143CFF,
63
- 'cyan' => 0x00FFFFFF,
64
- 'darkblue' => 0x00008BFF,
65
- 'darkcyan' => 0x008B8BFF,
66
- 'darkgoldenrod' => 0xB8860BFF,
67
- 'darkgray' => 0xA9A9A9FF,
68
- 'darkgreen' => 0x006400FF,
69
- 'darkkhaki' => 0xBDB76BFF,
70
- 'darkmagenta' => 0x8B008BFF,
71
- 'darkolivegreen' => 0x556B2FFF,
72
- 'darkorange' => 0xFF8C00FF,
73
- 'darkorchid' => 0x9932CCFF,
74
- 'darkred' => 0x8B0000FF,
75
- 'darksalmon' => 0xE9967AFF,
76
- 'darkseagreen' => 0x8FBC8FFF,
77
- 'darkslateblue' => 0x483D8BFF,
78
- 'darkslategray' => 0x2F4F4FFF,
79
- 'darkturquoise' => 0x00CED1FF,
80
- 'darkviolet' => 0x9400D3FF,
81
- 'deeppink' => 0xFF1493FF,
82
- 'deepskyblue' => 0x00BFFFFF,
83
- 'dimgray' => 0x696969FF,
84
- 'dodgerblue' => 0x1E90FFFF,
85
- 'firebrick' => 0xB22222FF,
86
- 'floralwhite' => 0xFFFAF0FF,
87
- 'forestgreen' => 0x228B22FF,
88
- 'gainsboro' => 0xDCDCDCFF,
89
- 'ghostwhite' => 0xF8F8FFFF,
90
- 'gold' => 0xFFD700FF,
91
- 'goldenrod' => 0xDAA520FF,
92
- 'gray' => 0x808080FF,
93
- 'green' => 0x008000FF,
94
- 'greenyellow' => 0xADFF2FFF,
95
- 'honeydew' => 0xF0FFF0FF,
96
- 'hotpink' => 0xFF69B4FF,
97
- 'indianred' => 0xCD5C5CFF,
98
- 'indigo' => 0x4B0082FF,
99
- 'ivory' => 0xFFFFF0FF,
100
- 'khaki' => 0xF0E68CFF,
101
- 'lavender' => 0xE6E6FAFF,
102
- 'lavenderblush' => 0xFFF0F5FF,
103
- 'lawngreen' => 0x7CFC00FF,
104
- 'lemonchiffon' => 0xFFFACDFF,
105
- 'lightblue' => 0xADD8E6FF,
106
- 'lightcoral' => 0xF08080FF,
107
- 'lightcyan' => 0xE0FFFFFF,
108
- 'lightgoldenrodyellow' => 0xFAFAD2FF,
109
- 'lightgreen' => 0x90EE90FF,
110
- 'lightgray' => 0xD3D3D3FF,
111
- 'lightpink' => 0xFFB6C1FF,
112
- 'lightsalmon' => 0xFFA07AFF,
113
- 'lightseagreen' => 0x20B2AAFF,
114
- 'lightskyblue' => 0x87CEFAFF,
115
- 'lightslategray' => 0x778899FF,
116
- 'lightsteelblue' => 0xB0C4DEFF,
117
- 'lightyellow' => 0xFFFFE0FF,
118
- 'lime' => 0x00FF00FF,
119
- 'limegreen' => 0x32CD32FF,
120
- 'linen' => 0xFAF0E6FF,
121
- 'magenta' => 0xFF00FFFF,
122
- 'maroon' => 0x800000FF,
123
- 'mediumaquamarine' => 0x66CDAAFF,
124
- 'mediumblue' => 0x0000CDFF,
125
- 'mediumorchid' => 0xBA55D3FF,
126
- 'mediumpurple' => 0x9370DBFF,
127
- 'mediumseagreen' => 0x3CB371FF,
128
- 'mediumslateblue' => 0x7B68EEFF,
129
- 'mediumspringgreen' => 0x00FA9AFF,
130
- 'mediumturquoise' => 0x48D1CCFF,
131
- 'mediumvioletred' => 0xC71585FF,
132
- 'midnightblue' => 0x191970FF,
133
- 'mintcream' => 0xF5FFFAFF,
134
- 'mistyrose' => 0xFFE4E1FF,
135
- 'moccasin' => 0xFFE4B5FF,
136
- 'navajowhite' => 0xFFDEADFF,
137
- 'navy' => 0x000080FF,
138
- 'oldlace' => 0xFDF5E6FF,
139
- 'olive' => 0x808000FF,
140
- 'olivedrab' => 0x6B8E23FF,
141
- 'orange' => 0xFFA500FF,
142
- 'orangered' => 0xFF4500FF,
143
- 'orchid' => 0xDA70D6FF,
144
- 'palegoldenrod' => 0xEEE8AAFF,
145
- 'palegreen' => 0x98FB98FF,
146
- 'paleturquoise' => 0xAFEEEEFF,
147
- 'palevioletred' => 0xDB7093FF,
148
- 'papayawhip' => 0xFFEFD5FF,
149
- 'peachpuff' => 0xFFDAB9FF,
150
- 'peru' => 0xCD853FFF,
151
- 'pink' => 0xFFC0CBFF,
152
- 'plum' => 0xDDA0DDFF,
153
- 'powderblue' => 0xB0E0E6FF,
154
- 'purple' => 0x800080FF,
155
- 'red' => 0xFF0000FF,
156
- 'rebeccapurple' => 0x663399FF,
157
- 'rosybrown' => 0xBC8F8FFF,
158
- 'royalblue' => 0x4169E1FF,
159
- 'saddlebrown' => 0x8B4513FF,
160
- 'salmon' => 0xFA8072FF,
161
- 'sandybrown' => 0xF4A460FF,
162
- 'seagreen' => 0x2E8B57FF,
163
- 'seashell' => 0xFFF5EEFF,
164
- 'sienna' => 0xA0522DFF,
165
- 'silver' => 0xC0C0C0FF,
166
- 'skyblue' => 0x87CEEBFF,
167
- 'slateblue' => 0x6A5ACDFF,
168
- 'slategray' => 0x708090FF,
169
- 'snow' => 0xFFFAFAFF,
170
- 'springgreen' => 0x00FF7FFF,
171
- 'steelblue' => 0x4682B4FF,
172
- 'tan' => 0xD2B48CFF,
173
- 'teal' => 0x008080FF,
174
- 'thistle' => 0xD8BFD8FF,
175
- 'tomato' => 0xFF6347FF,
176
- 'transparent' => 0x00000000,
177
- 'turquoise' => 0x40E0D0FF,
178
- 'violet' => 0xEE82EEFF,
179
- 'wheat' => 0xF5DEB3FF,
180
- 'white' => 0xFFFFFFFF,
181
- 'whitesmoke' => 0xF5F5F5FF,
182
- 'yellow' => 0xFFFF00FF,
183
- 'yellowgreen' => 0x9ACD32FF
184
- }, &method(:int_to_rgba))
185
-
186
- # A hash from `[red, green, blue, alpha]` value arrays to color names.
187
- COLOR_NAMES_REVERSE = COLOR_NAMES.invert.freeze
188
-
189
- # We add the alternate color names after inverting because
190
- # different ruby implementations and versions vary on the ordering of the result of invert.
191
- COLOR_NAMES.update(ALTERNATE_COLOR_NAMES).freeze
192
-
193
- # The user's original representation of the color.
194
- #
195
- # @return [String]
196
- attr_reader :representation
197
-
198
- # Constructs an RGB or HSL color object,
199
- # optionally with an alpha channel.
200
- #
201
- # RGB values are clipped within 0 and 255.
202
- # Saturation and lightness values are clipped within 0 and 100.
203
- # The alpha value is clipped within 0 and 1.
204
- #
205
- # @raise [Sass::SyntaxError] if any color value isn't in the specified range
206
- #
207
- # @overload initialize(attrs)
208
- # The attributes are specified as a hash. This hash must contain either
209
- # `:hue`, `:saturation`, and `:lightness` keys, or `:red`, `:green`, and
210
- # `:blue` keys. It cannot contain both HSL and RGB keys. It may also
211
- # optionally contain an `:alpha` key, and a `:representation` key
212
- # indicating the original representation of the color that the user wrote
213
- # in their stylesheet.
214
- #
215
- # @param attrs [{Symbol => Numeric}] A hash of color attributes to values
216
- # @raise [ArgumentError] if not enough attributes are specified,
217
- # or both RGB and HSL attributes are specified
218
- #
219
- # @overload initialize(rgba, [representation])
220
- # The attributes are specified as an array.
221
- # This overload only supports RGB or RGBA colors.
222
- #
223
- # @param rgba [Array<Numeric>] A three- or four-element array
224
- # of the red, green, blue, and optionally alpha values (respectively)
225
- # of the color
226
- # @param representation [String] The original representation of the color
227
- # that the user wrote in their stylesheet.
228
- # @raise [ArgumentError] if not enough attributes are specified
229
- def initialize(attrs, representation = nil, allow_both_rgb_and_hsl = false)
230
- super(nil)
231
-
232
- if attrs.is_a?(Array)
233
- unless (3..4).include?(attrs.size)
234
- raise ArgumentError.new("Color.new(array) expects a three- or four-element array")
235
- end
236
-
237
- red, green, blue = attrs[0...3].map {|c| Sass::Util.round(c)}
238
- @attrs = {:red => red, :green => green, :blue => blue}
239
- @attrs[:alpha] = attrs[3] ? attrs[3].to_f : 1
240
- @representation = representation
241
- else
242
- attrs = attrs.reject {|_k, v| v.nil?}
243
- hsl = [:hue, :saturation, :lightness] & attrs.keys
244
- rgb = [:red, :green, :blue] & attrs.keys
245
- if !allow_both_rgb_and_hsl && !hsl.empty? && !rgb.empty?
246
- raise ArgumentError.new("Color.new(hash) may not have both HSL and RGB keys specified")
247
- elsif hsl.empty? && rgb.empty?
248
- raise ArgumentError.new("Color.new(hash) must have either HSL or RGB keys specified")
249
- elsif !hsl.empty? && hsl.size != 3
250
- raise ArgumentError.new("Color.new(hash) must have all three HSL values specified")
251
- elsif !rgb.empty? && rgb.size != 3
252
- raise ArgumentError.new("Color.new(hash) must have all three RGB values specified")
253
- end
254
-
255
- @attrs = attrs
256
- @attrs[:hue] %= 360 if @attrs[:hue]
257
- @attrs[:alpha] ||= 1
258
- @representation = @attrs.delete(:representation)
259
- end
260
-
261
- [:red, :green, :blue].each do |k|
262
- next if @attrs[k].nil?
263
- @attrs[k] = Sass::Util.restrict(Sass::Util.round(@attrs[k]), 0..255)
264
- end
265
-
266
- [:saturation, :lightness].each do |k|
267
- next if @attrs[k].nil?
268
- @attrs[k] = Sass::Util.restrict(@attrs[k], 0..100)
269
- end
270
-
271
- @attrs[:alpha] = Sass::Util.restrict(@attrs[:alpha], 0..1)
272
- end
273
-
274
- # Create a new color from a valid CSS hex string.
275
- #
276
- # The leading hash is optional.
277
- #
278
- # @return [Color]
279
- def self.from_hex(hex_string, alpha = nil)
280
- unless hex_string =~ /^#?([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})$/i ||
281
- hex_string =~ /^#?([0-9a-f])([0-9a-f])([0-9a-f])$/i
282
- raise ArgumentError.new("#{hex_string.inspect} is not a valid hex color.")
283
- end
284
- red = $1.ljust(2, $1).to_i(16)
285
- green = $2.ljust(2, $2).to_i(16)
286
- blue = $3.ljust(2, $3).to_i(16)
287
-
288
- hex_string = "##{hex_string}" unless hex_string[0] == ?#
289
- attrs = {:red => red, :green => green, :blue => blue, :representation => hex_string}
290
- attrs[:alpha] = alpha if alpha
291
- new(attrs)
292
- end
293
-
294
- # The red component of the color.
295
- #
296
- # @return [Integer]
297
- def red
298
- hsl_to_rgb!
299
- @attrs[:red]
300
- end
301
-
302
- # The green component of the color.
303
- #
304
- # @return [Integer]
305
- def green
306
- hsl_to_rgb!
307
- @attrs[:green]
308
- end
309
-
310
- # The blue component of the color.
311
- #
312
- # @return [Integer]
313
- def blue
314
- hsl_to_rgb!
315
- @attrs[:blue]
316
- end
317
-
318
- # The hue component of the color.
319
- #
320
- # @return [Numeric]
321
- def hue
322
- rgb_to_hsl!
323
- @attrs[:hue]
324
- end
325
-
326
- # The saturation component of the color.
327
- #
328
- # @return [Numeric]
329
- def saturation
330
- rgb_to_hsl!
331
- @attrs[:saturation]
332
- end
333
-
334
- # The lightness component of the color.
335
- #
336
- # @return [Numeric]
337
- def lightness
338
- rgb_to_hsl!
339
- @attrs[:lightness]
340
- end
341
-
342
- # The alpha channel (opacity) of the color.
343
- # This is 1 unless otherwise defined.
344
- #
345
- # @return [Integer]
346
- def alpha
347
- @attrs[:alpha].to_f
348
- end
349
-
350
- # Returns whether this color object is translucent;
351
- # that is, whether the alpha channel is non-1.
352
- #
353
- # @return [Boolean]
354
- def alpha?
355
- alpha < 1
356
- end
357
-
358
- # Returns the red, green, and blue components of the color.
359
- #
360
- # @return [Array<Integer>] A frozen three-element array of the red, green, and blue
361
- # values (respectively) of the color
362
- def rgb
363
- [red, green, blue].freeze
364
- end
365
-
366
- # Returns the red, green, blue, and alpha components of the color.
367
- #
368
- # @return [Array<Integer>] A frozen four-element array of the red, green,
369
- # blue, and alpha values (respectively) of the color
370
- def rgba
371
- [red, green, blue, alpha].freeze
372
- end
373
-
374
- # Returns the hue, saturation, and lightness components of the color.
375
- #
376
- # @return [Array<Integer>] A frozen three-element array of the
377
- # hue, saturation, and lightness values (respectively) of the color
378
- def hsl
379
- [hue, saturation, lightness].freeze
380
- end
381
-
382
- # Returns the hue, saturation, lightness, and alpha components of the color.
383
- #
384
- # @return [Array<Integer>] A frozen four-element array of the hue,
385
- # saturation, lightness, and alpha values (respectively) of the color
386
- def hsla
387
- [hue, saturation, lightness, alpha].freeze
388
- end
389
-
390
- # The SassScript `==` operation.
391
- # **Note that this returns a {Sass::Script::Value::Bool} object,
392
- # not a Ruby boolean**.
393
- #
394
- # @param other [Value] The right-hand side of the operator
395
- # @return [Bool] True if this value is the same as the other,
396
- # false otherwise
397
- def eq(other)
398
- Sass::Script::Value::Bool.new(
399
- other.is_a?(Color) && rgb == other.rgb && alpha == other.alpha)
400
- end
401
-
402
- def hash
403
- [rgb, alpha].hash
404
- end
405
-
406
- # Returns a copy of this color with one or more channels changed.
407
- # RGB or HSL colors may be changed, but not both at once.
408
- #
409
- # For example:
410
- #
411
- # Color.new([10, 20, 30]).with(:blue => 40)
412
- # #=> rgb(10, 40, 30)
413
- # Color.new([126, 126, 126]).with(:red => 0, :green => 255)
414
- # #=> rgb(0, 255, 126)
415
- # Color.new([255, 0, 127]).with(:saturation => 60)
416
- # #=> rgb(204, 51, 127)
417
- # Color.new([1, 2, 3]).with(:alpha => 0.4)
418
- # #=> rgba(1, 2, 3, 0.4)
419
- #
420
- # @param attrs [{Symbol => Numeric}]
421
- # A map of channel names (`:red`, `:green`, `:blue`,
422
- # `:hue`, `:saturation`, `:lightness`, or `:alpha`) to values
423
- # @return [Color] The new Color object
424
- # @raise [ArgumentError] if both RGB and HSL keys are specified
425
- def with(attrs)
426
- attrs = attrs.reject {|_k, v| v.nil?}
427
- hsl = !([:hue, :saturation, :lightness] & attrs.keys).empty?
428
- rgb = !([:red, :green, :blue] & attrs.keys).empty?
429
- if hsl && rgb
430
- raise ArgumentError.new("Cannot specify HSL and RGB values for a color at the same time")
431
- end
432
-
433
- if hsl
434
- [:hue, :saturation, :lightness].each {|k| attrs[k] ||= send(k)}
435
- elsif rgb
436
- [:red, :green, :blue].each {|k| attrs[k] ||= send(k)}
437
- else
438
- # If we're just changing the alpha channel,
439
- # keep all the HSL/RGB stuff we've calculated
440
- attrs = @attrs.merge(attrs)
441
- end
442
- attrs[:alpha] ||= alpha
443
-
444
- Color.new(attrs, nil, :allow_both_rgb_and_hsl)
445
- end
446
-
447
- # The SassScript `+` operation.
448
- # Its functionality depends on the type of its argument:
449
- #
450
- # {Number}
451
- # : Adds the number to each of the RGB color channels.
452
- #
453
- # {Color}
454
- # : Adds each of the RGB color channels together.
455
- #
456
- # {Value}
457
- # : See {Value::Base#plus}.
458
- #
459
- # @param other [Value] The right-hand side of the operator
460
- # @return [Color] The resulting color
461
- # @raise [Sass::SyntaxError] if `other` is a number with units
462
- def plus(other)
463
- if other.is_a?(Sass::Script::Value::Number) || other.is_a?(Sass::Script::Value::Color)
464
- piecewise(other, :+)
465
- else
466
- super
467
- end
468
- end
469
-
470
- # The SassScript `-` operation.
471
- # Its functionality depends on the type of its argument:
472
- #
473
- # {Number}
474
- # : Subtracts the number from each of the RGB color channels.
475
- #
476
- # {Color}
477
- # : Subtracts each of the other color's RGB color channels from this color's.
478
- #
479
- # {Value}
480
- # : See {Value::Base#minus}.
481
- #
482
- # @param other [Value] The right-hand side of the operator
483
- # @return [Color] The resulting color
484
- # @raise [Sass::SyntaxError] if `other` is a number with units
485
- def minus(other)
486
- if other.is_a?(Sass::Script::Value::Number) || other.is_a?(Sass::Script::Value::Color)
487
- piecewise(other, :-)
488
- else
489
- super
490
- end
491
- end
492
-
493
- # The SassScript `*` operation.
494
- # Its functionality depends on the type of its argument:
495
- #
496
- # {Number}
497
- # : Multiplies the number by each of the RGB color channels.
498
- #
499
- # {Color}
500
- # : Multiplies each of the RGB color channels together.
501
- #
502
- # @param other [Number, Color] The right-hand side of the operator
503
- # @return [Color] The resulting color
504
- # @raise [Sass::SyntaxError] if `other` is a number with units
505
- def times(other)
506
- if other.is_a?(Sass::Script::Value::Number) || other.is_a?(Sass::Script::Value::Color)
507
- piecewise(other, :*)
508
- else
509
- raise NoMethodError.new(nil, :times)
510
- end
511
- end
512
-
513
- # The SassScript `/` operation.
514
- # Its functionality depends on the type of its argument:
515
- #
516
- # {Number}
517
- # : Divides each of the RGB color channels by the number.
518
- #
519
- # {Color}
520
- # : Divides each of this color's RGB color channels by the other color's.
521
- #
522
- # {Value}
523
- # : See {Value::Base#div}.
524
- #
525
- # @param other [Value] The right-hand side of the operator
526
- # @return [Color] The resulting color
527
- # @raise [Sass::SyntaxError] if `other` is a number with units
528
- def div(other)
529
- if other.is_a?(Sass::Script::Value::Number) ||
530
- other.is_a?(Sass::Script::Value::Color)
531
- piecewise(other, :/)
532
- else
533
- super
534
- end
535
- end
536
-
537
- # The SassScript `%` operation.
538
- # Its functionality depends on the type of its argument:
539
- #
540
- # {Number}
541
- # : Takes each of the RGB color channels module the number.
542
- #
543
- # {Color}
544
- # : Takes each of this color's RGB color channels modulo the other color's.
545
- #
546
- # @param other [Number, Color] The right-hand side of the operator
547
- # @return [Color] The resulting color
548
- # @raise [Sass::SyntaxError] if `other` is a number with units
549
- def mod(other)
550
- if other.is_a?(Sass::Script::Value::Number) ||
551
- other.is_a?(Sass::Script::Value::Color)
552
- piecewise(other, :%)
553
- else
554
- raise NoMethodError.new(nil, :mod)
555
- end
556
- end
557
-
558
- # Returns a string representation of the color.
559
- # This is usually the color's hex value,
560
- # but if the color has a name that's used instead.
561
- #
562
- # @return [String] The string representation
563
- def to_s(opts = {})
564
- return smallest if options[:style] == :compressed
565
- return representation if representation
566
- return name if name
567
- alpha? ? rgba_str : hex_str
568
- end
569
- alias_method :to_sass, :to_s
570
-
571
- # Returns a string representation of the color.
572
- #
573
- # @return [String] The hex value
574
- def inspect
575
- alpha? ? rgba_str : hex_str
576
- end
577
-
578
- # Returns the color's name, if it has one.
579
- #
580
- # @return [String, nil]
581
- def name
582
- COLOR_NAMES_REVERSE[rgba]
583
- end
584
-
585
- private
586
-
587
- def smallest
588
- small_explicit_str = alpha? ? rgba_str : hex_str.gsub(/^#(.)\1(.)\2(.)\3$/, '#\1\2\3')
589
- [representation, COLOR_NAMES_REVERSE[rgba], small_explicit_str].
590
- compact.min_by {|str| str.size}
591
- end
592
-
593
- def rgba_str
594
- split = options[:style] == :compressed ? ',' : ', '
595
- "rgba(#{rgb.join(split)}#{split}#{Number.round(alpha)})"
596
- end
597
-
598
- def hex_str
599
- red, green, blue = rgb.map {|num| num.to_s(16).rjust(2, '0')}
600
- "##{red}#{green}#{blue}"
601
- end
602
-
603
- def operation_name(operation)
604
- case operation
605
- when :+
606
- "add"
607
- when :-
608
- "subtract"
609
- when :*
610
- "multiply"
611
- when :/
612
- "divide"
613
- when :%
614
- "modulo"
615
- end
616
- end
617
-
618
- def piecewise(other, operation)
619
- other_num = other.is_a? Number
620
- if other_num && !other.unitless?
621
- raise Sass::SyntaxError.new(
622
- "Cannot #{operation_name(operation)} a number with units (#{other}) to a color (#{self})."
623
- )
624
- end
625
-
626
- result = []
627
- (0...3).each do |i|
628
- res = rgb[i].to_f.send(operation, other_num ? other.value : other.rgb[i])
629
- result[i] = [[res, 255].min, 0].max
630
- end
631
-
632
- if !other_num && other.alpha != alpha
633
- raise Sass::SyntaxError.new("Alpha channels must be equal: #{self} #{operation} #{other}")
634
- end
635
-
636
- with(:red => result[0], :green => result[1], :blue => result[2])
637
- end
638
-
639
- def hsl_to_rgb!
640
- return if @attrs[:red] && @attrs[:blue] && @attrs[:green]
641
-
642
- h = @attrs[:hue] / 360.0
643
- s = @attrs[:saturation] / 100.0
644
- l = @attrs[:lightness] / 100.0
645
-
646
- # Algorithm from the CSS3 spec: http://www.w3.org/TR/css3-color/#hsl-color.
647
- m2 = l <= 0.5 ? l * (s + 1) : l + s - l * s
648
- m1 = l * 2 - m2
649
- @attrs[:red], @attrs[:green], @attrs[:blue] = [
650
- hue_to_rgb(m1, m2, h + 1.0 / 3),
651
- hue_to_rgb(m1, m2, h),
652
- hue_to_rgb(m1, m2, h - 1.0 / 3)
653
- ].map {|c| Sass::Util.round(c * 0xff)}
654
- end
655
-
656
- def hue_to_rgb(m1, m2, h)
657
- h += 1 if h < 0
658
- h -= 1 if h > 1
659
- return m1 + (m2 - m1) * h * 6 if h * 6 < 1
660
- return m2 if h * 2 < 1
661
- return m1 + (m2 - m1) * (2.0 / 3 - h) * 6 if h * 3 < 2
662
- m1
663
- end
664
-
665
- def rgb_to_hsl!
666
- return if @attrs[:hue] && @attrs[:saturation] && @attrs[:lightness]
667
- r, g, b = [:red, :green, :blue].map {|k| @attrs[k] / 255.0}
668
-
669
- # Algorithm from http://en.wikipedia.org/wiki/HSL_and_HSV#Conversion_from_RGB_to_HSL_or_HSV
670
- max = [r, g, b].max
671
- min = [r, g, b].min
672
- d = max - min
673
-
674
- h =
675
- case max
676
- when min; 0
677
- when r; 60 * (g - b) / d
678
- when g; 60 * (b - r) / d + 120
679
- when b; 60 * (r - g) / d + 240
680
- end
681
-
682
- l = (max + min) / 2.0
683
-
684
- s =
685
- if max == min
686
- 0
687
- elsif l < 0.5
688
- d / (2 * l)
689
- else
690
- d / (2 - 2 * l)
691
- end
692
-
693
- @attrs[:hue] = h % 360
694
- @attrs[:saturation] = s * 100
695
- @attrs[:lightness] = l * 100
696
- end
697
- end
698
- end