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.
- checksums.yaml +4 -4
- data/CHANGES.md +17 -0
- data/bundle/load.rb +7 -8
- data/bundle/ruby/2.5.0/gems/{ruby2ruby-2.4.1 → ruby2ruby-2.4.2}/History.rdoc +8 -0
- data/bundle/ruby/2.5.0/gems/{ruby2ruby-2.4.1 → ruby2ruby-2.4.2}/Manifest.txt +0 -0
- data/bundle/ruby/2.5.0/gems/{ruby2ruby-2.4.1 → ruby2ruby-2.4.2}/README.rdoc +0 -0
- data/bundle/ruby/2.5.0/gems/{ruby2ruby-2.4.1 → ruby2ruby-2.4.2}/lib/ruby2ruby.rb +34 -36
- data/bundle/ruby/2.5.0/gems/{ruby_parser-3.12.0 → ruby_parser-3.13.0}/History.rdoc +47 -0
- data/bundle/ruby/2.5.0/gems/{ruby_parser-3.12.0 → ruby_parser-3.13.0}/Manifest.txt +5 -4
- data/bundle/ruby/2.5.0/gems/{ruby_parser-3.12.0 → ruby_parser-3.13.0}/README.rdoc +0 -0
- data/bundle/ruby/2.5.0/gems/{ruby_parser-3.12.0 → ruby_parser-3.13.0}/compare/normalize.rb +29 -2
- data/bundle/ruby/2.5.0/gems/ruby_parser-3.13.0/debugging.md +18 -0
- data/bundle/ruby/2.5.0/gems/{ruby_parser-3.12.0 → ruby_parser-3.13.0}/lib/rp_extensions.rb +0 -7
- data/bundle/ruby/2.5.0/gems/{ruby_parser-3.12.0 → ruby_parser-3.13.0}/lib/rp_stringscanner.rb +0 -0
- data/bundle/ruby/2.5.0/gems/ruby_parser-3.13.0/lib/ruby20_parser.rb +6874 -0
- data/bundle/ruby/2.5.0/gems/{ruby_parser-3.12.0 → ruby_parser-3.13.0}/lib/ruby20_parser.y +284 -201
- data/bundle/ruby/2.5.0/gems/ruby_parser-3.13.0/lib/ruby21_parser.rb +6952 -0
- data/bundle/ruby/2.5.0/gems/{ruby_parser-3.12.0 → ruby_parser-3.13.0}/lib/ruby21_parser.y +281 -197
- data/bundle/ruby/2.5.0/gems/ruby_parser-3.13.0/lib/ruby22_parser.rb +6983 -0
- 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
- data/bundle/ruby/2.5.0/gems/ruby_parser-3.13.0/lib/ruby23_parser.rb +6982 -0
- data/bundle/ruby/2.5.0/gems/{ruby_parser-3.12.0 → ruby_parser-3.13.0}/lib/ruby23_parser.y +282 -203
- data/bundle/ruby/2.5.0/gems/ruby_parser-3.13.0/lib/ruby24_parser.rb +6982 -0
- data/bundle/ruby/2.5.0/gems/{ruby_parser-3.12.0 → ruby_parser-3.13.0}/lib/ruby24_parser.y +282 -203
- data/bundle/ruby/2.5.0/gems/ruby_parser-3.13.0/lib/ruby25_parser.rb +6981 -0
- data/bundle/ruby/2.5.0/gems/{ruby_parser-3.12.0 → ruby_parser-3.13.0}/lib/ruby25_parser.y +282 -203
- data/bundle/ruby/2.5.0/gems/ruby_parser-3.13.0/lib/ruby26_parser.rb +6999 -0
- data/bundle/ruby/2.5.0/gems/ruby_parser-3.13.0/lib/ruby26_parser.y +2469 -0
- data/bundle/ruby/2.5.0/gems/{ruby_parser-3.12.0 → ruby_parser-3.13.0}/lib/ruby_lexer.rb +116 -118
- data/bundle/ruby/2.5.0/gems/{ruby_parser-3.12.0 → ruby_parser-3.13.0}/lib/ruby_lexer.rex +10 -8
- data/bundle/ruby/2.5.0/gems/{ruby_parser-3.12.0 → ruby_parser-3.13.0}/lib/ruby_lexer.rex.rb +8 -8
- data/bundle/ruby/2.5.0/gems/{ruby_parser-3.12.0 → ruby_parser-3.13.0}/lib/ruby_parser.rb +5 -7
- data/bundle/ruby/2.5.0/gems/ruby_parser-3.13.0/lib/ruby_parser.yy +2571 -0
- data/bundle/ruby/2.5.0/gems/ruby_parser-3.13.0/lib/ruby_parser_extras.rb +1360 -0
- data/bundle/ruby/2.5.0/gems/ruby_parser-3.13.0/tools/munge.rb +216 -0
- data/bundle/ruby/2.5.0/gems/ruby_parser-3.13.0/tools/ripper.rb +23 -0
- data/bundle/ruby/2.5.0/gems/ruby_parser-legacy-1.0.0/History.rdoc +6 -0
- data/bundle/ruby/2.5.0/gems/ruby_parser-legacy-1.0.0/Manifest.txt +19 -0
- data/bundle/ruby/2.5.0/gems/ruby_parser-legacy-1.0.0/README.rdoc +54 -0
- data/bundle/ruby/2.5.0/gems/ruby_parser-legacy-1.0.0/lib/ruby_parser/legacy.rb +5 -0
- 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
- 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
- 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
- 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
- data/bundle/ruby/2.5.0/gems/ruby_parser-legacy-1.0.0/lib/ruby_parser/legacy/ruby_lexer.rb +1412 -0
- data/bundle/ruby/2.5.0/gems/ruby_parser-legacy-1.0.0/lib/ruby_parser/legacy/ruby_lexer.rex +179 -0
- data/bundle/ruby/2.5.0/gems/ruby_parser-legacy-1.0.0/lib/ruby_parser/legacy/ruby_lexer.rex.rb +323 -0
- data/bundle/ruby/2.5.0/gems/ruby_parser-legacy-1.0.0/lib/ruby_parser/legacy/ruby_parser.rb +30 -0
- 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
- data/bundle/ruby/2.5.0/gems/{safe_yaml-1.0.4 → safe_yaml-1.0.5}/CHANGES.md +5 -0
- data/bundle/ruby/2.5.0/gems/{safe_yaml-1.0.4 → safe_yaml-1.0.5}/Gemfile +0 -0
- data/bundle/ruby/2.5.0/gems/{safe_yaml-1.0.4 → safe_yaml-1.0.5}/LICENSE.txt +0 -0
- data/bundle/ruby/2.5.0/gems/{safe_yaml-1.0.4 → safe_yaml-1.0.5}/README.md +0 -0
- 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
- data/bundle/ruby/2.5.0/gems/{safe_yaml-1.0.4 → safe_yaml-1.0.5}/lib/safe_yaml.rb +0 -0
- data/bundle/ruby/2.5.0/gems/{safe_yaml-1.0.4 → safe_yaml-1.0.5}/lib/safe_yaml/deep.rb +0 -0
- 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
- data/bundle/ruby/2.5.0/gems/{safe_yaml-1.0.4 → safe_yaml-1.0.5}/lib/safe_yaml/load.rb +0 -0
- 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
- 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
- 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
- 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
- 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
- data/bundle/ruby/2.5.0/gems/{safe_yaml-1.0.4 → safe_yaml-1.0.5}/lib/safe_yaml/resolver.rb +0 -0
- 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
- data/bundle/ruby/2.5.0/gems/safe_yaml-1.0.5/lib/safe_yaml/store.rb +39 -0
- 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
- 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
- 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
- data/bundle/ruby/2.5.0/gems/{safe_yaml-1.0.4 → safe_yaml-1.0.5}/lib/safe_yaml/transform.rb +0 -0
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- data/bundle/ruby/2.5.0/gems/{safe_yaml-1.0.4 → safe_yaml-1.0.5}/lib/safe_yaml/version.rb +1 -1
- 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
- data/bundle/ruby/2.5.0/gems/{safe_yaml-1.0.4 → safe_yaml-1.0.5}/safe_yaml.gemspec +0 -0
- data/bundle/ruby/2.5.0/gems/{sexp_processor-4.11.0 → sexp_processor-4.12.0}/History.rdoc +8 -0
- data/bundle/ruby/2.5.0/gems/{sexp_processor-4.11.0 → sexp_processor-4.12.0}/Manifest.txt +0 -0
- data/bundle/ruby/2.5.0/gems/{sexp_processor-4.11.0 → sexp_processor-4.12.0}/README.rdoc +0 -0
- data/bundle/ruby/2.5.0/gems/{sexp_processor-4.11.0 → sexp_processor-4.12.0}/lib/composite_sexp_processor.rb +0 -0
- data/bundle/ruby/2.5.0/gems/{sexp_processor-4.11.0 → sexp_processor-4.12.0}/lib/pt_testcase.rb +2 -2
- data/bundle/ruby/2.5.0/gems/{sexp_processor-4.11.0 → sexp_processor-4.12.0}/lib/sexp.rb +4 -4
- data/bundle/ruby/2.5.0/gems/{sexp_processor-4.11.0 → sexp_processor-4.12.0}/lib/sexp_processor.rb +1 -1
- data/bundle/ruby/2.5.0/gems/{sexp_processor-4.11.0 → sexp_processor-4.12.0}/lib/strict_sexp.rb +3 -3
- data/bundle/ruby/2.5.0/gems/{sexp_processor-4.11.0 → sexp_processor-4.12.0}/lib/unique.rb +0 -0
- data/bundle/ruby/2.5.0/gems/{temple-0.8.0 → temple-0.8.1}/CHANGES +6 -0
- data/bundle/ruby/2.5.0/gems/{temple-0.8.0 → temple-0.8.1}/EXPRESSIONS.md +1 -1
- data/bundle/ruby/2.5.0/gems/{temple-0.8.0 → temple-0.8.1}/Gemfile +0 -0
- data/bundle/ruby/2.5.0/gems/{temple-0.8.0 → temple-0.8.1}/LICENSE +0 -0
- data/bundle/ruby/2.5.0/gems/{temple-0.8.0 → temple-0.8.1}/README.md +1 -1
- data/bundle/ruby/2.5.0/gems/{temple-0.8.0 → temple-0.8.1}/lib/temple.rb +0 -0
- data/bundle/ruby/2.5.0/gems/{temple-0.8.0 → temple-0.8.1}/lib/temple/engine.rb +0 -0
- data/bundle/ruby/2.5.0/gems/{temple-0.8.0 → temple-0.8.1}/lib/temple/erb/engine.rb +0 -0
- data/bundle/ruby/2.5.0/gems/{temple-0.8.0 → temple-0.8.1}/lib/temple/erb/parser.rb +0 -0
- data/bundle/ruby/2.5.0/gems/{temple-0.8.0 → temple-0.8.1}/lib/temple/erb/template.rb +0 -0
- data/bundle/ruby/2.5.0/gems/{temple-0.8.0 → temple-0.8.1}/lib/temple/erb/trimming.rb +0 -0
- data/bundle/ruby/2.5.0/gems/{temple-0.8.0 → temple-0.8.1}/lib/temple/exceptions.rb +0 -0
- data/bundle/ruby/2.5.0/gems/{temple-0.8.0 → temple-0.8.1}/lib/temple/filter.rb +0 -0
- data/bundle/ruby/2.5.0/gems/{temple-0.8.0 → temple-0.8.1}/lib/temple/filters/code_merger.rb +0 -0
- data/bundle/ruby/2.5.0/gems/{temple-0.8.0 → temple-0.8.1}/lib/temple/filters/control_flow.rb +0 -0
- data/bundle/ruby/2.5.0/gems/{temple-0.8.0 → temple-0.8.1}/lib/temple/filters/dynamic_inliner.rb +0 -0
- data/bundle/ruby/2.5.0/gems/{temple-0.8.0 → temple-0.8.1}/lib/temple/filters/encoding.rb +0 -0
- data/bundle/ruby/2.5.0/gems/{temple-0.8.0 → temple-0.8.1}/lib/temple/filters/eraser.rb +0 -0
- data/bundle/ruby/2.5.0/gems/{temple-0.8.0 → temple-0.8.1}/lib/temple/filters/escapable.rb +0 -0
- data/bundle/ruby/2.5.0/gems/{temple-0.8.0 → temple-0.8.1}/lib/temple/filters/multi_flattener.rb +0 -0
- data/bundle/ruby/2.5.0/gems/{temple-0.8.0 → temple-0.8.1}/lib/temple/filters/remove_bom.rb +0 -0
- data/bundle/ruby/2.5.0/gems/{temple-0.8.0 → temple-0.8.1}/lib/temple/filters/static_analyzer.rb +0 -0
- data/bundle/ruby/2.5.0/gems/{temple-0.8.0 → temple-0.8.1}/lib/temple/filters/static_merger.rb +0 -0
- data/bundle/ruby/2.5.0/gems/{temple-0.8.0 → temple-0.8.1}/lib/temple/filters/string_splitter.rb +0 -0
- data/bundle/ruby/2.5.0/gems/{temple-0.8.0 → temple-0.8.1}/lib/temple/filters/validator.rb +0 -0
- data/bundle/ruby/2.5.0/gems/{temple-0.8.0 → temple-0.8.1}/lib/temple/generator.rb +0 -0
- data/bundle/ruby/2.5.0/gems/{temple-0.8.0 → temple-0.8.1}/lib/temple/generators/array.rb +0 -0
- data/bundle/ruby/2.5.0/gems/{temple-0.8.0 → temple-0.8.1}/lib/temple/generators/array_buffer.rb +0 -0
- data/bundle/ruby/2.5.0/gems/{temple-0.8.0 → temple-0.8.1}/lib/temple/generators/erb.rb +0 -0
- data/bundle/ruby/2.5.0/gems/{temple-0.8.0 → temple-0.8.1}/lib/temple/generators/rails_output_buffer.rb +0 -0
- data/bundle/ruby/2.5.0/gems/{temple-0.8.0 → temple-0.8.1}/lib/temple/generators/string_buffer.rb +0 -0
- data/bundle/ruby/2.5.0/gems/{temple-0.8.0 → temple-0.8.1}/lib/temple/grammar.rb +0 -0
- data/bundle/ruby/2.5.0/gems/{temple-0.8.0 → temple-0.8.1}/lib/temple/html/attribute_merger.rb +0 -0
- data/bundle/ruby/2.5.0/gems/{temple-0.8.0 → temple-0.8.1}/lib/temple/html/attribute_remover.rb +0 -0
- data/bundle/ruby/2.5.0/gems/{temple-0.8.0 → temple-0.8.1}/lib/temple/html/attribute_sorter.rb +0 -0
- data/bundle/ruby/2.5.0/gems/{temple-0.8.0 → temple-0.8.1}/lib/temple/html/dispatcher.rb +0 -0
- data/bundle/ruby/2.5.0/gems/{temple-0.8.0 → temple-0.8.1}/lib/temple/html/fast.rb +0 -0
- data/bundle/ruby/2.5.0/gems/{temple-0.8.0 → temple-0.8.1}/lib/temple/html/filter.rb +0 -0
- data/bundle/ruby/2.5.0/gems/{temple-0.8.0 → temple-0.8.1}/lib/temple/html/pretty.rb +0 -0
- data/bundle/ruby/2.5.0/gems/{temple-0.8.0 → temple-0.8.1}/lib/temple/html/safe.rb +0 -0
- data/bundle/ruby/2.5.0/gems/{temple-0.8.0 → temple-0.8.1}/lib/temple/map.rb +0 -0
- data/bundle/ruby/2.5.0/gems/{temple-0.8.0 → temple-0.8.1}/lib/temple/mixins/dispatcher.rb +2 -1
- data/bundle/ruby/2.5.0/gems/{temple-0.8.0 → temple-0.8.1}/lib/temple/mixins/engine_dsl.rb +0 -0
- data/bundle/ruby/2.5.0/gems/{temple-0.8.0 → temple-0.8.1}/lib/temple/mixins/grammar_dsl.rb +0 -0
- data/bundle/ruby/2.5.0/gems/{temple-0.8.0 → temple-0.8.1}/lib/temple/mixins/options.rb +0 -0
- data/bundle/ruby/2.5.0/gems/{temple-0.8.0 → temple-0.8.1}/lib/temple/mixins/template.rb +0 -0
- data/bundle/ruby/2.5.0/gems/{temple-0.8.0 → temple-0.8.1}/lib/temple/parser.rb +0 -0
- data/bundle/ruby/2.5.0/gems/{temple-0.8.0 → temple-0.8.1}/lib/temple/static_analyzer.rb +0 -0
- data/bundle/ruby/2.5.0/gems/{temple-0.8.0 → temple-0.8.1}/lib/temple/templates.rb +0 -0
- data/bundle/ruby/2.5.0/gems/{temple-0.8.0 → temple-0.8.1}/lib/temple/templates/rails.rb +2 -2
- data/bundle/ruby/2.5.0/gems/{temple-0.8.0 → temple-0.8.1}/lib/temple/templates/tilt.rb +0 -0
- data/bundle/ruby/2.5.0/gems/{temple-0.8.0 → temple-0.8.1}/lib/temple/utils.rb +0 -0
- data/bundle/ruby/2.5.0/gems/temple-0.8.1/lib/temple/version.rb +3 -0
- data/bundle/ruby/2.5.0/gems/{temple-0.8.0 → temple-0.8.1}/temple.gemspec +0 -0
- data/bundle/ruby/2.5.0/gems/{unicode-display_width-1.4.1 → unicode-display_width-1.5.0}/CHANGELOG.md +4 -0
- data/bundle/ruby/2.5.0/gems/{unicode-display_width-1.4.1 → unicode-display_width-1.5.0}/MIT-LICENSE.txt +1 -1
- data/bundle/ruby/2.5.0/gems/{unicode-display_width-1.4.1 → unicode-display_width-1.5.0}/README.md +10 -10
- data/bundle/ruby/2.5.0/gems/unicode-display_width-1.5.0/data/display_width.marshal.gz +0 -0
- 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
- 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
- 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
- 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
- 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
- data/lib/brakeman/checks/base_check.rb +16 -0
- data/lib/brakeman/checks/check_content_tag.rb +12 -0
- data/lib/brakeman/checks/check_cross_site_scripting.rb +6 -6
- data/lib/brakeman/checks/check_evaluation.rb +0 -1
- data/lib/brakeman/checks/check_execute.rb +18 -0
- data/lib/brakeman/checks/check_send.rb +0 -1
- data/lib/brakeman/checks/check_session_manipulation.rb +0 -1
- data/lib/brakeman/checks/check_sql.rb +12 -3
- data/lib/brakeman/file_parser.rb +8 -4
- data/lib/brakeman/parsers/haml_embedded.rb +44 -0
- data/lib/brakeman/parsers/slim_embedded.rb +44 -0
- data/lib/brakeman/parsers/template_parser.rb +2 -4
- data/lib/brakeman/processors/alias_processor.rb +23 -1
- data/lib/brakeman/processors/lib/call_conversion_helper.rb +4 -0
- data/lib/brakeman/processors/slim_template_processor.rb +16 -0
- data/lib/brakeman/processors/template_alias_processor.rb +2 -2
- data/lib/brakeman/scanner.rb +11 -10
- data/lib/brakeman/tracker.rb +5 -1
- data/lib/brakeman/tracker/config.rb +32 -7
- data/lib/brakeman/util.rb +17 -0
- data/lib/brakeman/version.rb +1 -1
- metadata +157 -320
- data/bundle/ruby/2.5.0/gems/ruby_parser-3.12.0/lib/ruby20_parser.rb +0 -6687
- data/bundle/ruby/2.5.0/gems/ruby_parser-3.12.0/lib/ruby21_parser.rb +0 -6767
- data/bundle/ruby/2.5.0/gems/ruby_parser-3.12.0/lib/ruby22_parser.rb +0 -6803
- data/bundle/ruby/2.5.0/gems/ruby_parser-3.12.0/lib/ruby22_parser.y +0 -2376
- data/bundle/ruby/2.5.0/gems/ruby_parser-3.12.0/lib/ruby23_parser.rb +0 -6818
- data/bundle/ruby/2.5.0/gems/ruby_parser-3.12.0/lib/ruby24_parser.rb +0 -6818
- data/bundle/ruby/2.5.0/gems/ruby_parser-3.12.0/lib/ruby25_parser.rb +0 -6818
- data/bundle/ruby/2.5.0/gems/sass-3.4.25/CODE_OF_CONDUCT.md +0 -10
- data/bundle/ruby/2.5.0/gems/sass-3.4.25/CONTRIBUTING.md +0 -148
- data/bundle/ruby/2.5.0/gems/sass-3.4.25/MIT-LICENSE +0 -20
- data/bundle/ruby/2.5.0/gems/sass-3.4.25/README.md +0 -227
- data/bundle/ruby/2.5.0/gems/sass-3.4.25/REVISION +0 -1
- data/bundle/ruby/2.5.0/gems/sass-3.4.25/VERSION +0 -1
- data/bundle/ruby/2.5.0/gems/sass-3.4.25/VERSION_DATE +0 -1
- data/bundle/ruby/2.5.0/gems/sass-3.4.25/VERSION_NAME +0 -1
- data/bundle/ruby/2.5.0/gems/sass-3.4.25/extra/sass-spec-ref.sh +0 -32
- data/bundle/ruby/2.5.0/gems/sass-3.4.25/extra/update_watch.rb +0 -13
- data/bundle/ruby/2.5.0/gems/sass-3.4.25/init.rb +0 -18
- data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass.rb +0 -109
- data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/cache_stores.rb +0 -15
- data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/cache_stores/base.rb +0 -88
- data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/cache_stores/chain.rb +0 -34
- data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/cache_stores/filesystem.rb +0 -60
- data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/cache_stores/memory.rb +0 -46
- data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/cache_stores/null.rb +0 -25
- data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/callbacks.rb +0 -67
- data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/css.rb +0 -408
- data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/deprecation.rb +0 -55
- data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/engine.rb +0 -1226
- data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/environment.rb +0 -215
- data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/error.rb +0 -198
- data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/exec.rb +0 -9
- data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/exec/base.rb +0 -199
- data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/exec/sass_convert.rb +0 -283
- data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/exec/sass_scss.rb +0 -440
- data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/features.rb +0 -47
- data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/importers.rb +0 -23
- data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/importers/base.rb +0 -182
- data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/importers/deprecated_path.rb +0 -51
- data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/importers/filesystem.rb +0 -219
- data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/logger.rb +0 -17
- data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/logger/base.rb +0 -36
- data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/logger/delayed.rb +0 -50
- data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/logger/log_level.rb +0 -45
- data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/media.rb +0 -210
- data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/plugin.rb +0 -134
- data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/plugin/compiler.rb +0 -582
- data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/plugin/configuration.rb +0 -134
- data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/plugin/generic.rb +0 -15
- data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/plugin/merb.rb +0 -48
- data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/plugin/rack.rb +0 -60
- data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/plugin/rails.rb +0 -47
- data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/plugin/staleness_checker.rb +0 -199
- data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/railtie.rb +0 -10
- data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/repl.rb +0 -57
- data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/root.rb +0 -7
- data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/script.rb +0 -66
- data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/script/css_lexer.rb +0 -33
- data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/script/css_parser.rb +0 -33
- data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/script/css_variable_warning.rb +0 -52
- data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/script/functions.rb +0 -2693
- data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/script/lexer.rb +0 -464
- data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/script/parser.rb +0 -832
- data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/script/tree.rb +0 -16
- data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/script/tree/funcall.rb +0 -313
- data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/script/tree/interpolation.rb +0 -223
- data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/script/tree/list_literal.rb +0 -104
- data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/script/tree/literal.rb +0 -49
- data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/script/tree/map_literal.rb +0 -64
- data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/script/tree/node.rb +0 -127
- data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/script/tree/operation.rb +0 -156
- data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/script/tree/selector.rb +0 -26
- data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/script/tree/string_interpolation.rb +0 -125
- data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/script/tree/unary_operation.rb +0 -69
- data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/script/tree/variable.rb +0 -57
- data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/script/value.rb +0 -11
- data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/script/value/arg_list.rb +0 -36
- data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/script/value/base.rb +0 -241
- data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/script/value/bool.rb +0 -35
- data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/script/value/color.rb +0 -698
- data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/script/value/helpers.rb +0 -272
- data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/script/value/list.rb +0 -113
- data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/script/value/map.rb +0 -70
- data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/script/value/null.rb +0 -44
- data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/script/value/number.rb +0 -563
- data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/script/value/string.rb +0 -138
- data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/scss.rb +0 -14
- data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/scss/css_parser.rb +0 -56
- data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/scss/parser.rb +0 -1254
- data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/scss/rx.rb +0 -140
- data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/scss/static_parser.rb +0 -373
- data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/selector.rb +0 -323
- data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/selector/abstract_sequence.rb +0 -111
- data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/selector/comma_sequence.rb +0 -191
- data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/selector/pseudo.rb +0 -266
- data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/selector/sequence.rb +0 -636
- data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/selector/simple.rb +0 -117
- data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/selector/simple_sequence.rb +0 -344
- data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/shared.rb +0 -76
- data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/source/map.rb +0 -213
- data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/source/position.rb +0 -39
- data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/source/range.rb +0 -41
- data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/stack.rb +0 -120
- data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/supports.rb +0 -225
- data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/tree/at_root_node.rb +0 -83
- data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/tree/charset_node.rb +0 -22
- data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/tree/comment_node.rb +0 -82
- data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/tree/content_node.rb +0 -9
- data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/tree/css_import_node.rb +0 -68
- data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/tree/debug_node.rb +0 -18
- data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/tree/directive_node.rb +0 -59
- data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/tree/each_node.rb +0 -24
- data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/tree/error_node.rb +0 -18
- data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/tree/extend_node.rb +0 -43
- data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/tree/for_node.rb +0 -36
- data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/tree/function_node.rb +0 -44
- data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/tree/if_node.rb +0 -52
- data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/tree/import_node.rb +0 -75
- data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/tree/keyframe_rule_node.rb +0 -15
- data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/tree/media_node.rb +0 -48
- data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/tree/mixin_def_node.rb +0 -38
- data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/tree/mixin_node.rb +0 -52
- data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/tree/node.rb +0 -240
- data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/tree/prop_node.rb +0 -170
- data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/tree/return_node.rb +0 -19
- data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/tree/root_node.rb +0 -44
- data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/tree/rule_node.rb +0 -155
- data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/tree/supports_node.rb +0 -38
- data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/tree/trace_node.rb +0 -33
- data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/tree/variable_node.rb +0 -36
- data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/tree/visitors/base.rb +0 -72
- data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/tree/visitors/check_nesting.rb +0 -173
- data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/tree/visitors/convert.rb +0 -351
- data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/tree/visitors/cssize.rb +0 -373
- data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/tree/visitors/deep_copy.rb +0 -107
- data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/tree/visitors/extend.rb +0 -70
- data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/tree/visitors/perform.rb +0 -564
- data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/tree/visitors/set_options.rb +0 -139
- data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/tree/visitors/to_css.rb +0 -409
- data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/tree/warn_node.rb +0 -18
- data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/tree/while_node.rb +0 -18
- data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/util.rb +0 -1375
- data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/util/cross_platform_random.rb +0 -19
- data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/util/multibyte_string_scanner.rb +0 -155
- data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/util/normalized_map.rb +0 -129
- data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/util/ordered_hash.rb +0 -192
- data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/util/subset_map.rb +0 -109
- data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/util/test.rb +0 -9
- data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/version.rb +0 -124
- data/bundle/ruby/2.5.0/gems/sass-3.4.25/rails/init.rb +0 -1
- data/bundle/ruby/2.5.0/gems/sass-3.4.25/vendor/listen/CHANGELOG.md +0 -1
- data/bundle/ruby/2.5.0/gems/sass-3.4.25/vendor/listen/CONTRIBUTING.md +0 -38
- data/bundle/ruby/2.5.0/gems/sass-3.4.25/vendor/listen/Gemfile +0 -20
- data/bundle/ruby/2.5.0/gems/sass-3.4.25/vendor/listen/Guardfile +0 -8
- data/bundle/ruby/2.5.0/gems/sass-3.4.25/vendor/listen/LICENSE +0 -20
- data/bundle/ruby/2.5.0/gems/sass-3.4.25/vendor/listen/README.md +0 -349
- data/bundle/ruby/2.5.0/gems/sass-3.4.25/vendor/listen/Rakefile +0 -5
- data/bundle/ruby/2.5.0/gems/sass-3.4.25/vendor/listen/Vagrantfile +0 -96
- data/bundle/ruby/2.5.0/gems/sass-3.4.25/vendor/listen/lib/listen.rb +0 -54
- data/bundle/ruby/2.5.0/gems/sass-3.4.25/vendor/listen/lib/listen/adapter.rb +0 -327
- data/bundle/ruby/2.5.0/gems/sass-3.4.25/vendor/listen/lib/listen/adapters/bsd.rb +0 -75
- data/bundle/ruby/2.5.0/gems/sass-3.4.25/vendor/listen/lib/listen/adapters/darwin.rb +0 -48
- data/bundle/ruby/2.5.0/gems/sass-3.4.25/vendor/listen/lib/listen/adapters/linux.rb +0 -81
- data/bundle/ruby/2.5.0/gems/sass-3.4.25/vendor/listen/lib/listen/adapters/polling.rb +0 -58
- data/bundle/ruby/2.5.0/gems/sass-3.4.25/vendor/listen/lib/listen/adapters/windows.rb +0 -91
- data/bundle/ruby/2.5.0/gems/sass-3.4.25/vendor/listen/lib/listen/directory_record.rb +0 -406
- data/bundle/ruby/2.5.0/gems/sass-3.4.25/vendor/listen/lib/listen/listener.rb +0 -323
- data/bundle/ruby/2.5.0/gems/sass-3.4.25/vendor/listen/lib/listen/turnstile.rb +0 -32
- data/bundle/ruby/2.5.0/gems/sass-3.4.25/vendor/listen/lib/listen/version.rb +0 -3
- data/bundle/ruby/2.5.0/gems/sass-3.4.25/vendor/listen/listen.gemspec +0 -28
- data/bundle/ruby/2.5.0/gems/sass-3.4.25/vendor/listen/spec/listen/adapter_spec.rb +0 -149
- data/bundle/ruby/2.5.0/gems/sass-3.4.25/vendor/listen/spec/listen/adapters/bsd_spec.rb +0 -36
- data/bundle/ruby/2.5.0/gems/sass-3.4.25/vendor/listen/spec/listen/adapters/darwin_spec.rb +0 -37
- data/bundle/ruby/2.5.0/gems/sass-3.4.25/vendor/listen/spec/listen/adapters/linux_spec.rb +0 -47
- data/bundle/ruby/2.5.0/gems/sass-3.4.25/vendor/listen/spec/listen/adapters/polling_spec.rb +0 -68
- data/bundle/ruby/2.5.0/gems/sass-3.4.25/vendor/listen/spec/listen/adapters/windows_spec.rb +0 -30
- data/bundle/ruby/2.5.0/gems/sass-3.4.25/vendor/listen/spec/listen/directory_record_spec.rb +0 -1250
- data/bundle/ruby/2.5.0/gems/sass-3.4.25/vendor/listen/spec/listen/listener_spec.rb +0 -258
- data/bundle/ruby/2.5.0/gems/sass-3.4.25/vendor/listen/spec/listen/turnstile_spec.rb +0 -56
- data/bundle/ruby/2.5.0/gems/sass-3.4.25/vendor/listen/spec/listen_spec.rb +0 -67
- data/bundle/ruby/2.5.0/gems/sass-3.4.25/vendor/listen/spec/spec_helper.rb +0 -25
- data/bundle/ruby/2.5.0/gems/sass-3.4.25/vendor/listen/spec/support/adapter_helper.rb +0 -666
- data/bundle/ruby/2.5.0/gems/sass-3.4.25/vendor/listen/spec/support/directory_record_helper.rb +0 -57
- data/bundle/ruby/2.5.0/gems/sass-3.4.25/vendor/listen/spec/support/fixtures_helper.rb +0 -29
- data/bundle/ruby/2.5.0/gems/sass-3.4.25/vendor/listen/spec/support/listeners_helper.rb +0 -179
- data/bundle/ruby/2.5.0/gems/sass-3.4.25/vendor/listen/spec/support/platform_helper.rb +0 -15
- data/bundle/ruby/2.5.0/gems/temple-0.8.0/lib/temple/version.rb +0 -3
- data/bundle/ruby/2.5.0/gems/unicode-display_width-1.4.1/data/display_width.marshal.gz +0 -0
@@ -1,44 +0,0 @@
|
|
1
|
-
module Sass::Script::Value
|
2
|
-
# A SassScript object representing a null value.
|
3
|
-
class Null < Base
|
4
|
-
# The null value in SassScript.
|
5
|
-
#
|
6
|
-
# This is assigned before new is overridden below so that we use the default implementation.
|
7
|
-
NULL = new(nil)
|
8
|
-
|
9
|
-
# We override object creation so that users of the core API
|
10
|
-
# will not need to know that null is a specific constant.
|
11
|
-
#
|
12
|
-
# @private
|
13
|
-
# @return [Null] the {NULL} constant.
|
14
|
-
def self.new
|
15
|
-
NULL
|
16
|
-
end
|
17
|
-
|
18
|
-
# @return [Boolean] `false` (the Ruby boolean value)
|
19
|
-
def to_bool
|
20
|
-
false
|
21
|
-
end
|
22
|
-
|
23
|
-
# @return [Boolean] `true`
|
24
|
-
def null?
|
25
|
-
true
|
26
|
-
end
|
27
|
-
|
28
|
-
# @return [String] '' (An empty string)
|
29
|
-
def to_s(opts = {})
|
30
|
-
''
|
31
|
-
end
|
32
|
-
|
33
|
-
def to_sass(opts = {})
|
34
|
-
'null'
|
35
|
-
end
|
36
|
-
|
37
|
-
# Returns a string representing a null value.
|
38
|
-
#
|
39
|
-
# @return [String]
|
40
|
-
def inspect
|
41
|
-
'null'
|
42
|
-
end
|
43
|
-
end
|
44
|
-
end
|
@@ -1,563 +0,0 @@
|
|
1
|
-
module Sass::Script::Value
|
2
|
-
# A SassScript object representing a number.
|
3
|
-
# SassScript numbers can have decimal values,
|
4
|
-
# and can also have units.
|
5
|
-
# For example, `12`, `1px`, and `10.45em`
|
6
|
-
# are all valid values.
|
7
|
-
#
|
8
|
-
# Numbers can also have more complex units, such as `1px*em/in`.
|
9
|
-
# These cannot be inputted directly in Sass code at the moment.
|
10
|
-
class Number < Base
|
11
|
-
# The Ruby value of the number.
|
12
|
-
#
|
13
|
-
# @return [Numeric]
|
14
|
-
attr_reader :value
|
15
|
-
|
16
|
-
# A list of units in the numerator of the number.
|
17
|
-
# For example, `1px*em/in*cm` would return `["px", "em"]`
|
18
|
-
# @return [Array<String>]
|
19
|
-
attr_reader :numerator_units
|
20
|
-
|
21
|
-
# A list of units in the denominator of the number.
|
22
|
-
# For example, `1px*em/in*cm` would return `["in", "cm"]`
|
23
|
-
# @return [Array<String>]
|
24
|
-
attr_reader :denominator_units
|
25
|
-
|
26
|
-
# The original representation of this number.
|
27
|
-
# For example, although the result of `1px/2px` is `0.5`,
|
28
|
-
# the value of `#original` is `"1px/2px"`.
|
29
|
-
#
|
30
|
-
# This is only non-nil when the original value should be used as the CSS value,
|
31
|
-
# as in `font: 1px/2px`.
|
32
|
-
#
|
33
|
-
# @return [Boolean, nil]
|
34
|
-
attr_accessor :original
|
35
|
-
|
36
|
-
def self.precision
|
37
|
-
Thread.current[:sass_numeric_precision] || Thread.main[:sass_numeric_precision] || 5
|
38
|
-
end
|
39
|
-
|
40
|
-
# Sets the number of digits of precision
|
41
|
-
# For example, if this is `3`,
|
42
|
-
# `3.1415926` will be printed as `3.142`.
|
43
|
-
# The numeric precision is stored as a thread local for thread safety reasons.
|
44
|
-
# To set for all threads, be sure to set the precision on the main thread.
|
45
|
-
def self.precision=(digits)
|
46
|
-
Thread.current[:sass_numeric_precision] = digits.round
|
47
|
-
Thread.current[:sass_numeric_precision_factor] = nil
|
48
|
-
Thread.current[:sass_numeric_epsilon] = nil
|
49
|
-
end
|
50
|
-
|
51
|
-
# the precision factor used in numeric output
|
52
|
-
# it is derived from the `precision` method.
|
53
|
-
def self.precision_factor
|
54
|
-
Thread.current[:sass_numeric_precision_factor] ||= 10.0**precision
|
55
|
-
end
|
56
|
-
|
57
|
-
# Used in checking equality of floating point numbers. Any
|
58
|
-
# numbers within an `epsilon` of each other are considered functionally equal.
|
59
|
-
# The value for epsilon is one tenth of the current numeric precision.
|
60
|
-
def self.epsilon
|
61
|
-
Thread.current[:sass_numeric_epsilon] ||= 1 / (precision_factor * 10)
|
62
|
-
end
|
63
|
-
|
64
|
-
# Used so we don't allocate two new arrays for each new number.
|
65
|
-
NO_UNITS = []
|
66
|
-
|
67
|
-
# @param value [Numeric] The value of the number
|
68
|
-
# @param numerator_units [::String, Array<::String>] See \{#numerator\_units}
|
69
|
-
# @param denominator_units [::String, Array<::String>] See \{#denominator\_units}
|
70
|
-
def initialize(value, numerator_units = NO_UNITS, denominator_units = NO_UNITS)
|
71
|
-
numerator_units = [numerator_units] if numerator_units.is_a?(::String)
|
72
|
-
denominator_units = [denominator_units] if denominator_units.is_a?(::String)
|
73
|
-
super(value)
|
74
|
-
@numerator_units = numerator_units
|
75
|
-
@denominator_units = denominator_units
|
76
|
-
@options = nil
|
77
|
-
normalize!
|
78
|
-
end
|
79
|
-
|
80
|
-
# The SassScript `+` operation.
|
81
|
-
# Its functionality depends on the type of its argument:
|
82
|
-
#
|
83
|
-
# {Number}
|
84
|
-
# : Adds the two numbers together, converting units if possible.
|
85
|
-
#
|
86
|
-
# {Color}
|
87
|
-
# : Adds this number to each of the RGB color channels.
|
88
|
-
#
|
89
|
-
# {Value}
|
90
|
-
# : See {Value::Base#plus}.
|
91
|
-
#
|
92
|
-
# @param other [Value] The right-hand side of the operator
|
93
|
-
# @return [Value] The result of the operation
|
94
|
-
# @raise [Sass::UnitConversionError] if `other` is a number with incompatible units
|
95
|
-
def plus(other)
|
96
|
-
if other.is_a? Number
|
97
|
-
operate(other, :+)
|
98
|
-
elsif other.is_a?(Color)
|
99
|
-
other.plus(self)
|
100
|
-
else
|
101
|
-
super
|
102
|
-
end
|
103
|
-
end
|
104
|
-
|
105
|
-
# The SassScript binary `-` operation (e.g. `$a - $b`).
|
106
|
-
# Its functionality depends on the type of its argument:
|
107
|
-
#
|
108
|
-
# {Number}
|
109
|
-
# : Subtracts this number from the other, converting units if possible.
|
110
|
-
#
|
111
|
-
# {Value}
|
112
|
-
# : See {Value::Base#minus}.
|
113
|
-
#
|
114
|
-
# @param other [Value] The right-hand side of the operator
|
115
|
-
# @return [Value] The result of the operation
|
116
|
-
# @raise [Sass::UnitConversionError] if `other` is a number with incompatible units
|
117
|
-
def minus(other)
|
118
|
-
if other.is_a? Number
|
119
|
-
operate(other, :-)
|
120
|
-
else
|
121
|
-
super
|
122
|
-
end
|
123
|
-
end
|
124
|
-
|
125
|
-
# The SassScript unary `+` operation (e.g. `+$a`).
|
126
|
-
#
|
127
|
-
# @return [Number] The value of this number
|
128
|
-
def unary_plus
|
129
|
-
self
|
130
|
-
end
|
131
|
-
|
132
|
-
# The SassScript unary `-` operation (e.g. `-$a`).
|
133
|
-
#
|
134
|
-
# @return [Number] The negative value of this number
|
135
|
-
def unary_minus
|
136
|
-
Number.new(-value, @numerator_units, @denominator_units)
|
137
|
-
end
|
138
|
-
|
139
|
-
# The SassScript `*` operation.
|
140
|
-
# Its functionality depends on the type of its argument:
|
141
|
-
#
|
142
|
-
# {Number}
|
143
|
-
# : Multiplies the two numbers together, converting units appropriately.
|
144
|
-
#
|
145
|
-
# {Color}
|
146
|
-
# : Multiplies each of the RGB color channels by this number.
|
147
|
-
#
|
148
|
-
# @param other [Number, Color] The right-hand side of the operator
|
149
|
-
# @return [Number, Color] The result of the operation
|
150
|
-
# @raise [NoMethodError] if `other` is an invalid type
|
151
|
-
def times(other)
|
152
|
-
if other.is_a? Number
|
153
|
-
operate(other, :*)
|
154
|
-
elsif other.is_a? Color
|
155
|
-
other.times(self)
|
156
|
-
else
|
157
|
-
raise NoMethodError.new(nil, :times)
|
158
|
-
end
|
159
|
-
end
|
160
|
-
|
161
|
-
# The SassScript `/` operation.
|
162
|
-
# Its functionality depends on the type of its argument:
|
163
|
-
#
|
164
|
-
# {Number}
|
165
|
-
# : Divides this number by the other, converting units appropriately.
|
166
|
-
#
|
167
|
-
# {Value}
|
168
|
-
# : See {Value::Base#div}.
|
169
|
-
#
|
170
|
-
# @param other [Value] The right-hand side of the operator
|
171
|
-
# @return [Value] The result of the operation
|
172
|
-
def div(other)
|
173
|
-
if other.is_a? Number
|
174
|
-
res = operate(other, :/)
|
175
|
-
if original && other.original
|
176
|
-
res.original = "#{original}/#{other.original}"
|
177
|
-
end
|
178
|
-
res
|
179
|
-
else
|
180
|
-
super
|
181
|
-
end
|
182
|
-
end
|
183
|
-
|
184
|
-
# The SassScript `%` operation.
|
185
|
-
#
|
186
|
-
# @param other [Number] The right-hand side of the operator
|
187
|
-
# @return [Number] This number modulo the other
|
188
|
-
# @raise [NoMethodError] if `other` is an invalid type
|
189
|
-
# @raise [Sass::UnitConversionError] if `other` has incompatible units
|
190
|
-
def mod(other)
|
191
|
-
if other.is_a?(Number)
|
192
|
-
operate(other, :%)
|
193
|
-
else
|
194
|
-
raise NoMethodError.new(nil, :mod)
|
195
|
-
end
|
196
|
-
end
|
197
|
-
|
198
|
-
# The SassScript `==` operation.
|
199
|
-
#
|
200
|
-
# @param other [Value] The right-hand side of the operator
|
201
|
-
# @return [Boolean] Whether this number is equal to the other object
|
202
|
-
def eq(other)
|
203
|
-
return Bool::FALSE unless other.is_a?(Sass::Script::Value::Number)
|
204
|
-
this = self
|
205
|
-
begin
|
206
|
-
if unitless?
|
207
|
-
this = this.coerce(other.numerator_units, other.denominator_units)
|
208
|
-
else
|
209
|
-
other = other.coerce(@numerator_units, @denominator_units)
|
210
|
-
end
|
211
|
-
rescue Sass::UnitConversionError
|
212
|
-
return Bool::FALSE
|
213
|
-
end
|
214
|
-
Bool.new(basically_equal?(this.value, other.value))
|
215
|
-
end
|
216
|
-
|
217
|
-
def hash
|
218
|
-
[value, numerator_units, denominator_units].hash
|
219
|
-
end
|
220
|
-
|
221
|
-
# Hash-equality works differently than `==` equality for numbers.
|
222
|
-
# Hash-equality must be transitive, so it just compares the exact value,
|
223
|
-
# numerator units, and denominator units.
|
224
|
-
def eql?(other)
|
225
|
-
basically_equal?(value, other.value) && numerator_units == other.numerator_units &&
|
226
|
-
denominator_units == other.denominator_units
|
227
|
-
end
|
228
|
-
|
229
|
-
# The SassScript `>` operation.
|
230
|
-
#
|
231
|
-
# @param other [Number] The right-hand side of the operator
|
232
|
-
# @return [Boolean] Whether this number is greater than the other
|
233
|
-
# @raise [NoMethodError] if `other` is an invalid type
|
234
|
-
def gt(other)
|
235
|
-
raise NoMethodError.new(nil, :gt) unless other.is_a?(Number)
|
236
|
-
operate(other, :>)
|
237
|
-
end
|
238
|
-
|
239
|
-
# The SassScript `>=` operation.
|
240
|
-
#
|
241
|
-
# @param other [Number] The right-hand side of the operator
|
242
|
-
# @return [Boolean] Whether this number is greater than or equal to the other
|
243
|
-
# @raise [NoMethodError] if `other` is an invalid type
|
244
|
-
def gte(other)
|
245
|
-
raise NoMethodError.new(nil, :gte) unless other.is_a?(Number)
|
246
|
-
operate(other, :>=)
|
247
|
-
end
|
248
|
-
|
249
|
-
# The SassScript `<` operation.
|
250
|
-
#
|
251
|
-
# @param other [Number] The right-hand side of the operator
|
252
|
-
# @return [Boolean] Whether this number is less than the other
|
253
|
-
# @raise [NoMethodError] if `other` is an invalid type
|
254
|
-
def lt(other)
|
255
|
-
raise NoMethodError.new(nil, :lt) unless other.is_a?(Number)
|
256
|
-
operate(other, :<)
|
257
|
-
end
|
258
|
-
|
259
|
-
# The SassScript `<=` operation.
|
260
|
-
#
|
261
|
-
# @param other [Number] The right-hand side of the operator
|
262
|
-
# @return [Boolean] Whether this number is less than or equal to the other
|
263
|
-
# @raise [NoMethodError] if `other` is an invalid type
|
264
|
-
def lte(other)
|
265
|
-
raise NoMethodError.new(nil, :lte) unless other.is_a?(Number)
|
266
|
-
operate(other, :<=)
|
267
|
-
end
|
268
|
-
|
269
|
-
# @return [String] The CSS representation of this number
|
270
|
-
# @raise [Sass::SyntaxError] if this number has units that can't be used in CSS
|
271
|
-
# (e.g. `px*in`)
|
272
|
-
def to_s(opts = {})
|
273
|
-
return original if original
|
274
|
-
raise Sass::SyntaxError.new("#{inspect} isn't a valid CSS value.") unless legal_units?
|
275
|
-
inspect
|
276
|
-
end
|
277
|
-
|
278
|
-
# Returns a readable representation of this number.
|
279
|
-
#
|
280
|
-
# This representation is valid CSS (and valid SassScript)
|
281
|
-
# as long as there is only one unit.
|
282
|
-
#
|
283
|
-
# @return [String] The representation
|
284
|
-
def inspect(opts = {})
|
285
|
-
return original if original
|
286
|
-
|
287
|
-
value = self.class.round(self.value)
|
288
|
-
str = value.to_s
|
289
|
-
|
290
|
-
# Ruby will occasionally print in scientific notation if the number is
|
291
|
-
# small enough. That's technically valid CSS, but it's not well-supported
|
292
|
-
# and confusing.
|
293
|
-
str = ("%0.#{self.class.precision}f" % value).gsub(/0*$/, '') if str.include?('e')
|
294
|
-
|
295
|
-
# Sometimes numeric formatting will result in a decimal number with a trailing zero (x.0)
|
296
|
-
if str =~ /(.*)\.0$/
|
297
|
-
str = $1
|
298
|
-
end
|
299
|
-
|
300
|
-
# We omit a leading zero before the decimal point in compressed mode.
|
301
|
-
if @options && options[:style] == :compressed
|
302
|
-
str.sub!(/^(-)?0\./, '\1.')
|
303
|
-
end
|
304
|
-
|
305
|
-
unitless? ? str : "#{str}#{unit_str}"
|
306
|
-
end
|
307
|
-
alias_method :to_sass, :inspect
|
308
|
-
|
309
|
-
# @return [Integer] The integer value of the number
|
310
|
-
# @raise [Sass::SyntaxError] if the number isn't an integer
|
311
|
-
def to_i
|
312
|
-
super unless int?
|
313
|
-
value.to_i
|
314
|
-
end
|
315
|
-
|
316
|
-
# @return [Boolean] Whether or not this number is an integer.
|
317
|
-
def int?
|
318
|
-
basically_equal?(value % 1, 0.0)
|
319
|
-
end
|
320
|
-
|
321
|
-
# @return [Boolean] Whether or not this number has no units.
|
322
|
-
def unitless?
|
323
|
-
@numerator_units.empty? && @denominator_units.empty?
|
324
|
-
end
|
325
|
-
|
326
|
-
# Checks whether the number has the numerator unit specified.
|
327
|
-
#
|
328
|
-
# @example
|
329
|
-
# number = Sass::Script::Value::Number.new(10, "px")
|
330
|
-
# number.is_unit?("px") => true
|
331
|
-
# number.is_unit?(nil) => false
|
332
|
-
#
|
333
|
-
# @param unit [::String, nil] The unit the number should have or nil if the number
|
334
|
-
# should be unitless.
|
335
|
-
# @see Number#unitless? The unitless? method may be more readable.
|
336
|
-
def is_unit?(unit)
|
337
|
-
if unit
|
338
|
-
denominator_units.size == 0 && numerator_units.size == 1 && numerator_units.first == unit
|
339
|
-
else
|
340
|
-
unitless?
|
341
|
-
end
|
342
|
-
end
|
343
|
-
|
344
|
-
# @return [Boolean] Whether or not this number has units that can be represented in CSS
|
345
|
-
# (that is, zero or one \{#numerator\_units}).
|
346
|
-
def legal_units?
|
347
|
-
(@numerator_units.empty? || @numerator_units.size == 1) && @denominator_units.empty?
|
348
|
-
end
|
349
|
-
|
350
|
-
# Returns this number converted to other units.
|
351
|
-
# The conversion takes into account the relationship between e.g. mm and cm,
|
352
|
-
# as well as between e.g. in and cm.
|
353
|
-
#
|
354
|
-
# If this number has no units, it will simply return itself
|
355
|
-
# with the given units.
|
356
|
-
#
|
357
|
-
# An incompatible coercion, e.g. between px and cm, will raise an error.
|
358
|
-
#
|
359
|
-
# @param num_units [Array<String>] The numerator units to coerce this number into.
|
360
|
-
# See {\#numerator\_units}
|
361
|
-
# @param den_units [Array<String>] The denominator units to coerce this number into.
|
362
|
-
# See {\#denominator\_units}
|
363
|
-
# @return [Number] The number with the new units
|
364
|
-
# @raise [Sass::UnitConversionError] if the given units are incompatible with the number's
|
365
|
-
# current units
|
366
|
-
def coerce(num_units, den_units)
|
367
|
-
Number.new(if unitless?
|
368
|
-
value
|
369
|
-
else
|
370
|
-
value * coercion_factor(@numerator_units, num_units) /
|
371
|
-
coercion_factor(@denominator_units, den_units)
|
372
|
-
end, num_units, den_units)
|
373
|
-
end
|
374
|
-
|
375
|
-
# @param other [Number] A number to decide if it can be compared with this number.
|
376
|
-
# @return [Boolean] Whether or not this number can be compared with the other.
|
377
|
-
def comparable_to?(other)
|
378
|
-
operate(other, :+)
|
379
|
-
true
|
380
|
-
rescue Sass::UnitConversionError
|
381
|
-
false
|
382
|
-
end
|
383
|
-
|
384
|
-
# Returns a human readable representation of the units in this number.
|
385
|
-
# For complex units this takes the form of:
|
386
|
-
# numerator_unit1 * numerator_unit2 / denominator_unit1 * denominator_unit2
|
387
|
-
# @return [String] a string that represents the units in this number
|
388
|
-
def unit_str
|
389
|
-
rv = @numerator_units.sort.join("*")
|
390
|
-
if @denominator_units.any?
|
391
|
-
rv << "/"
|
392
|
-
rv << @denominator_units.sort.join("*")
|
393
|
-
end
|
394
|
-
rv
|
395
|
-
end
|
396
|
-
|
397
|
-
private
|
398
|
-
|
399
|
-
# @private
|
400
|
-
# @see Sass::Script::Number.basically_equal?
|
401
|
-
def basically_equal?(num1, num2)
|
402
|
-
self.class.basically_equal?(num1, num2)
|
403
|
-
end
|
404
|
-
|
405
|
-
# Checks whether two numbers are within an epsilon of each other.
|
406
|
-
# @return [Boolean]
|
407
|
-
def self.basically_equal?(num1, num2)
|
408
|
-
(num1 - num2).abs < epsilon
|
409
|
-
end
|
410
|
-
|
411
|
-
# @private
|
412
|
-
def self.round(num)
|
413
|
-
if num.is_a?(Float) && (num.infinite? || num.nan?)
|
414
|
-
num
|
415
|
-
elsif basically_equal?(num % 1, 0.0)
|
416
|
-
num.round
|
417
|
-
else
|
418
|
-
((num * precision_factor).round / precision_factor).to_f
|
419
|
-
end
|
420
|
-
end
|
421
|
-
|
422
|
-
OPERATIONS = [:+, :-, :<=, :<, :>, :>=, :%]
|
423
|
-
|
424
|
-
def operate(other, operation)
|
425
|
-
this = self
|
426
|
-
if OPERATIONS.include?(operation)
|
427
|
-
if unitless?
|
428
|
-
this = this.coerce(other.numerator_units, other.denominator_units)
|
429
|
-
else
|
430
|
-
other = other.coerce(@numerator_units, @denominator_units)
|
431
|
-
end
|
432
|
-
end
|
433
|
-
# avoid integer division
|
434
|
-
value = :/ == operation ? this.value.to_f : this.value
|
435
|
-
result = value.send(operation, other.value)
|
436
|
-
|
437
|
-
if result.is_a?(Numeric)
|
438
|
-
Number.new(result, *compute_units(this, other, operation))
|
439
|
-
else # Boolean op
|
440
|
-
Bool.new(result)
|
441
|
-
end
|
442
|
-
end
|
443
|
-
|
444
|
-
def coercion_factor(from_units, to_units)
|
445
|
-
# get a list of unmatched units
|
446
|
-
from_units, to_units = sans_common_units(from_units, to_units)
|
447
|
-
|
448
|
-
if from_units.size != to_units.size || !convertable?(from_units | to_units)
|
449
|
-
raise Sass::UnitConversionError.new(
|
450
|
-
"Incompatible units: '#{from_units.join('*')}' and '#{to_units.join('*')}'.")
|
451
|
-
end
|
452
|
-
|
453
|
-
from_units.zip(to_units).inject(1) {|m, p| m * conversion_factor(p[0], p[1])}
|
454
|
-
end
|
455
|
-
|
456
|
-
def compute_units(this, other, operation)
|
457
|
-
case operation
|
458
|
-
when :*
|
459
|
-
[this.numerator_units + other.numerator_units,
|
460
|
-
this.denominator_units + other.denominator_units]
|
461
|
-
when :/
|
462
|
-
[this.numerator_units + other.denominator_units,
|
463
|
-
this.denominator_units + other.numerator_units]
|
464
|
-
else
|
465
|
-
[this.numerator_units, this.denominator_units]
|
466
|
-
end
|
467
|
-
end
|
468
|
-
|
469
|
-
def normalize!
|
470
|
-
return if unitless?
|
471
|
-
@numerator_units, @denominator_units =
|
472
|
-
sans_common_units(@numerator_units, @denominator_units)
|
473
|
-
|
474
|
-
@denominator_units.each_with_index do |d, i|
|
475
|
-
next unless convertable?(d) && (u = @numerator_units.find(&method(:convertable?)))
|
476
|
-
@value /= conversion_factor(d, u)
|
477
|
-
@denominator_units.delete_at(i)
|
478
|
-
@numerator_units.delete_at(@numerator_units.index(u))
|
479
|
-
end
|
480
|
-
end
|
481
|
-
|
482
|
-
# This is the source data for all the unit logic. It's pre-processed to make
|
483
|
-
# it efficient to figure out whether a set of units is mutually compatible
|
484
|
-
# and what the conversion ratio is between two units.
|
485
|
-
#
|
486
|
-
# These come from http://www.w3.org/TR/2012/WD-css3-values-20120308/.
|
487
|
-
relative_sizes = [
|
488
|
-
{
|
489
|
-
'in' => Rational(1),
|
490
|
-
'cm' => Rational(1, 2.54),
|
491
|
-
'pc' => Rational(1, 6),
|
492
|
-
'mm' => Rational(1, 25.4),
|
493
|
-
'q' => Rational(1, 101.6),
|
494
|
-
'pt' => Rational(1, 72),
|
495
|
-
'px' => Rational(1, 96)
|
496
|
-
},
|
497
|
-
{
|
498
|
-
'deg' => Rational(1, 360),
|
499
|
-
'grad' => Rational(1, 400),
|
500
|
-
'rad' => Rational(1, 2 * Math::PI),
|
501
|
-
'turn' => Rational(1)
|
502
|
-
},
|
503
|
-
{
|
504
|
-
's' => Rational(1),
|
505
|
-
'ms' => Rational(1, 1000)
|
506
|
-
},
|
507
|
-
{
|
508
|
-
'Hz' => Rational(1),
|
509
|
-
'kHz' => Rational(1000)
|
510
|
-
},
|
511
|
-
{
|
512
|
-
'dpi' => Rational(1),
|
513
|
-
'dpcm' => Rational(254, 100),
|
514
|
-
'dppx' => Rational(96)
|
515
|
-
}
|
516
|
-
]
|
517
|
-
|
518
|
-
# A hash from each known unit to the set of units that it's mutually
|
519
|
-
# convertible with.
|
520
|
-
MUTUALLY_CONVERTIBLE = {}
|
521
|
-
relative_sizes.map do |values|
|
522
|
-
set = values.keys.to_set
|
523
|
-
values.keys.each {|name| MUTUALLY_CONVERTIBLE[name] = set}
|
524
|
-
end
|
525
|
-
|
526
|
-
# A two-dimensional hash from two units to the conversion ratio between
|
527
|
-
# them. Multiply `X` by `CONVERSION_TABLE[X][Y]` to convert it to `Y`.
|
528
|
-
CONVERSION_TABLE = {}
|
529
|
-
relative_sizes.each do |values|
|
530
|
-
values.each do |(name1, value1)|
|
531
|
-
CONVERSION_TABLE[name1] ||= {}
|
532
|
-
values.each do |(name2, value2)|
|
533
|
-
value = value1 / value2
|
534
|
-
CONVERSION_TABLE[name1][name2] = value.denominator == 1 ? value.to_i : value.to_f
|
535
|
-
end
|
536
|
-
end
|
537
|
-
end
|
538
|
-
|
539
|
-
def conversion_factor(from_unit, to_unit)
|
540
|
-
CONVERSION_TABLE[from_unit][to_unit]
|
541
|
-
end
|
542
|
-
|
543
|
-
def convertable?(units)
|
544
|
-
units = Array(units).to_set
|
545
|
-
return true if units.empty?
|
546
|
-
return false unless (mutually_convertible = MUTUALLY_CONVERTIBLE[units.first])
|
547
|
-
units.subset?(mutually_convertible)
|
548
|
-
end
|
549
|
-
|
550
|
-
def sans_common_units(units1, units2)
|
551
|
-
units2 = units2.dup
|
552
|
-
# Can't just use -, because we want px*px to coerce properly to px*mm
|
553
|
-
units1 = units1.map do |u|
|
554
|
-
j = units2.index(u)
|
555
|
-
next u unless j
|
556
|
-
units2.delete_at(j)
|
557
|
-
nil
|
558
|
-
end
|
559
|
-
units1.compact!
|
560
|
-
return units1, units2
|
561
|
-
end
|
562
|
-
end
|
563
|
-
end
|