classiccms 0.3.0 → 0.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/classiccms/application.rb +2 -3
- data/lib/classiccms/cli.rb +6 -0
- data/lib/classiccms/scaffold/Gemfile +4 -0
- data/lib/classiccms/{mongoid.yml → scaffold/config/mongoid.yml} +3 -4
- data/lib/classiccms/scaffold/spec/models/article_spec.rb +8 -0
- data/lib/classiccms/scaffold/spec/spec_helper.rb +24 -0
- data/lib/classiccms/version.rb +1 -1
- data/spec/cli_spec.rb +8 -0
- data/vendor/bundle/gems/libv8-3.3.10.4-x86_64-darwin-11/lib/libv8/build/v8/libv8.a +0 -0
- data/vendor/bundle/gems/libv8-3.3.10.4-x86_64-darwin-11/lib/libv8/build/v8/libv8preparser.a +0 -0
- data/vendor/bundle/gems/libv8-3.3.10.4-x86_64-darwin-11/lib/libv8/v8/include/v8-debug.h +395 -0
- data/vendor/bundle/gems/libv8-3.3.10.4-x86_64-darwin-11/lib/libv8/v8/include/v8-preparser.h +117 -0
- data/vendor/bundle/gems/libv8-3.3.10.4-x86_64-darwin-11/lib/libv8/v8/include/v8-profiler.h +505 -0
- data/vendor/bundle/gems/libv8-3.3.10.4-x86_64-darwin-11/lib/libv8/v8/include/v8-testing.h +104 -0
- data/vendor/bundle/gems/libv8-3.3.10.4-x86_64-darwin-11/lib/libv8/v8/include/v8.h +4124 -0
- data/vendor/bundle/gems/libv8-3.3.10.4-x86_64-darwin-11/lib/libv8/v8/include/v8stdint.h +53 -0
- data/vendor/bundle/gems/libv8-3.3.10.4-x86_64-darwin-11/lib/libv8/version.rb +6 -0
- data/vendor/bundle/gems/libv8-3.3.10.4-x86_64-darwin-11/lib/libv8.rb +15 -0
- data/vendor/bundle/gems/sass-3.1.19/.yardopts +11 -0
- data/vendor/bundle/gems/sass-3.1.19/CONTRIBUTING +3 -0
- data/vendor/bundle/gems/sass-3.1.19/MIT-LICENSE +20 -0
- data/vendor/bundle/gems/sass-3.1.19/README.md +200 -0
- data/vendor/bundle/gems/sass-3.1.19/REVISION +1 -0
- data/vendor/bundle/gems/sass-3.1.19/Rakefile +339 -0
- data/vendor/bundle/gems/sass-3.1.19/VERSION +1 -0
- data/vendor/bundle/gems/sass-3.1.19/VERSION_NAME +1 -0
- data/vendor/bundle/gems/sass-3.1.19/bin/sass +8 -0
- data/vendor/bundle/gems/sass-3.1.19/bin/sass-convert +7 -0
- data/vendor/bundle/gems/sass-3.1.19/bin/scss +8 -0
- data/vendor/bundle/gems/sass-3.1.19/extra/update_watch.rb +13 -0
- data/vendor/bundle/gems/sass-3.1.19/init.rb +18 -0
- data/vendor/bundle/gems/sass-3.1.19/lib/sass/cache_stores/base.rb +86 -0
- data/vendor/bundle/gems/sass-3.1.19/lib/sass/cache_stores/chain.rb +33 -0
- data/vendor/bundle/gems/sass-3.1.19/lib/sass/cache_stores/filesystem.rb +61 -0
- data/vendor/bundle/gems/sass-3.1.19/lib/sass/cache_stores/memory.rb +47 -0
- data/vendor/bundle/gems/sass-3.1.19/lib/sass/cache_stores/null.rb +25 -0
- data/vendor/bundle/gems/sass-3.1.19/lib/sass/cache_stores.rb +15 -0
- data/vendor/bundle/gems/sass-3.1.19/lib/sass/callbacks.rb +66 -0
- data/vendor/bundle/gems/sass-3.1.19/lib/sass/css.rb +390 -0
- data/vendor/bundle/gems/sass-3.1.19/lib/sass/engine.rb +880 -0
- data/vendor/bundle/gems/sass-3.1.19/lib/sass/environment.rb +180 -0
- data/vendor/bundle/gems/sass-3.1.19/lib/sass/error.rb +201 -0
- data/vendor/bundle/gems/sass-3.1.19/lib/sass/exec.rb +682 -0
- data/vendor/bundle/gems/sass-3.1.19/lib/sass/importers/base.rb +139 -0
- data/vendor/bundle/gems/sass-3.1.19/lib/sass/importers/filesystem.rb +149 -0
- data/vendor/bundle/gems/sass-3.1.19/lib/sass/importers.rb +22 -0
- data/vendor/bundle/gems/sass-3.1.19/lib/sass/less.rb +382 -0
- data/vendor/bundle/gems/sass-3.1.19/lib/sass/logger/base.rb +32 -0
- data/vendor/bundle/gems/sass-3.1.19/lib/sass/logger/log_level.rb +49 -0
- data/vendor/bundle/gems/sass-3.1.19/lib/sass/logger.rb +15 -0
- data/vendor/bundle/gems/sass-3.1.19/lib/sass/plugin/compiler.rb +384 -0
- data/vendor/bundle/gems/sass-3.1.19/lib/sass/plugin/configuration.rb +123 -0
- data/vendor/bundle/gems/sass-3.1.19/lib/sass/plugin/generic.rb +15 -0
- data/vendor/bundle/gems/sass-3.1.19/lib/sass/plugin/merb.rb +48 -0
- data/vendor/bundle/gems/sass-3.1.19/lib/sass/plugin/rack.rb +60 -0
- data/vendor/bundle/gems/sass-3.1.19/lib/sass/plugin/rails.rb +47 -0
- data/vendor/bundle/gems/sass-3.1.19/lib/sass/plugin/staleness_checker.rb +183 -0
- data/vendor/bundle/gems/sass-3.1.19/lib/sass/plugin.rb +132 -0
- data/vendor/bundle/gems/sass-3.1.19/lib/sass/railtie.rb +9 -0
- data/vendor/bundle/gems/sass-3.1.19/lib/sass/repl.rb +57 -0
- data/vendor/bundle/gems/sass-3.1.19/lib/sass/root.rb +7 -0
- data/vendor/bundle/gems/sass-3.1.19/lib/sass/script/bool.rb +18 -0
- data/vendor/bundle/gems/sass-3.1.19/lib/sass/script/color.rb +475 -0
- data/vendor/bundle/gems/sass-3.1.19/lib/sass/script/css_lexer.rb +29 -0
- data/vendor/bundle/gems/sass-3.1.19/lib/sass/script/css_parser.rb +31 -0
- data/vendor/bundle/gems/sass-3.1.19/lib/sass/script/funcall.rb +175 -0
- data/vendor/bundle/gems/sass-3.1.19/lib/sass/script/functions.rb +1381 -0
- data/vendor/bundle/gems/sass-3.1.19/lib/sass/script/interpolation.rb +79 -0
- data/vendor/bundle/gems/sass-3.1.19/lib/sass/script/lexer.rb +337 -0
- data/vendor/bundle/gems/sass-3.1.19/lib/sass/script/list.rb +84 -0
- data/vendor/bundle/gems/sass-3.1.19/lib/sass/script/literal.rb +230 -0
- data/vendor/bundle/gems/sass-3.1.19/lib/sass/script/node.rb +99 -0
- data/vendor/bundle/gems/sass-3.1.19/lib/sass/script/number.rb +452 -0
- data/vendor/bundle/gems/sass-3.1.19/lib/sass/script/operation.rb +107 -0
- data/vendor/bundle/gems/sass-3.1.19/lib/sass/script/parser.rb +474 -0
- data/vendor/bundle/gems/sass-3.1.19/lib/sass/script/string.rb +51 -0
- data/vendor/bundle/gems/sass-3.1.19/lib/sass/script/string_interpolation.rb +103 -0
- data/vendor/bundle/gems/sass-3.1.19/lib/sass/script/unary_operation.rb +64 -0
- data/vendor/bundle/gems/sass-3.1.19/lib/sass/script/variable.rb +58 -0
- data/vendor/bundle/gems/sass-3.1.19/lib/sass/script.rb +39 -0
- data/vendor/bundle/gems/sass-3.1.19/lib/sass/scss/css_parser.rb +46 -0
- data/vendor/bundle/gems/sass-3.1.19/lib/sass/scss/parser.rb +1055 -0
- data/vendor/bundle/gems/sass-3.1.19/lib/sass/scss/rx.rb +137 -0
- data/vendor/bundle/gems/sass-3.1.19/lib/sass/scss/sass_parser.rb +11 -0
- data/vendor/bundle/gems/sass-3.1.19/lib/sass/scss/script_lexer.rb +15 -0
- data/vendor/bundle/gems/sass-3.1.19/lib/sass/scss/script_parser.rb +25 -0
- data/vendor/bundle/gems/sass-3.1.19/lib/sass/scss/static_parser.rb +40 -0
- data/vendor/bundle/gems/sass-3.1.19/lib/sass/scss.rb +17 -0
- data/vendor/bundle/gems/sass-3.1.19/lib/sass/selector/abstract_sequence.rb +71 -0
- data/vendor/bundle/gems/sass-3.1.19/lib/sass/selector/comma_sequence.rb +86 -0
- data/vendor/bundle/gems/sass-3.1.19/lib/sass/selector/sequence.rb +296 -0
- data/vendor/bundle/gems/sass-3.1.19/lib/sass/selector/simple.rb +119 -0
- data/vendor/bundle/gems/sass-3.1.19/lib/sass/selector/simple_sequence.rb +154 -0
- data/vendor/bundle/gems/sass-3.1.19/lib/sass/selector.rb +373 -0
- data/vendor/bundle/gems/sass-3.1.19/lib/sass/shared.rb +76 -0
- data/vendor/bundle/gems/sass-3.1.19/lib/sass/tree/charset_node.rb +22 -0
- data/vendor/bundle/gems/sass-3.1.19/lib/sass/tree/comment_node.rb +90 -0
- data/vendor/bundle/gems/sass-3.1.19/lib/sass/tree/debug_node.rb +18 -0
- data/vendor/bundle/gems/sass-3.1.19/lib/sass/tree/directive_node.rb +28 -0
- data/vendor/bundle/gems/sass-3.1.19/lib/sass/tree/each_node.rb +24 -0
- data/vendor/bundle/gems/sass-3.1.19/lib/sass/tree/extend_node.rb +29 -0
- data/vendor/bundle/gems/sass-3.1.19/lib/sass/tree/for_node.rb +36 -0
- data/vendor/bundle/gems/sass-3.1.19/lib/sass/tree/function_node.rb +27 -0
- data/vendor/bundle/gems/sass-3.1.19/lib/sass/tree/if_node.rb +52 -0
- data/vendor/bundle/gems/sass-3.1.19/lib/sass/tree/import_node.rb +68 -0
- data/vendor/bundle/gems/sass-3.1.19/lib/sass/tree/media_node.rb +32 -0
- data/vendor/bundle/gems/sass-3.1.19/lib/sass/tree/mixin_def_node.rb +27 -0
- data/vendor/bundle/gems/sass-3.1.19/lib/sass/tree/mixin_node.rb +32 -0
- data/vendor/bundle/gems/sass-3.1.19/lib/sass/tree/node.rb +188 -0
- data/vendor/bundle/gems/sass-3.1.19/lib/sass/tree/prop_node.rb +148 -0
- data/vendor/bundle/gems/sass-3.1.19/lib/sass/tree/return_node.rb +18 -0
- data/vendor/bundle/gems/sass-3.1.19/lib/sass/tree/root_node.rb +28 -0
- data/vendor/bundle/gems/sass-3.1.19/lib/sass/tree/rule_node.rb +127 -0
- data/vendor/bundle/gems/sass-3.1.19/lib/sass/tree/variable_node.rb +30 -0
- data/vendor/bundle/gems/sass-3.1.19/lib/sass/tree/visitors/base.rb +75 -0
- data/vendor/bundle/gems/sass-3.1.19/lib/sass/tree/visitors/check_nesting.rb +127 -0
- data/vendor/bundle/gems/sass-3.1.19/lib/sass/tree/visitors/convert.rb +262 -0
- data/vendor/bundle/gems/sass-3.1.19/lib/sass/tree/visitors/cssize.rb +206 -0
- data/vendor/bundle/gems/sass-3.1.19/lib/sass/tree/visitors/deep_copy.rb +87 -0
- data/vendor/bundle/gems/sass-3.1.19/lib/sass/tree/visitors/extend.rb +42 -0
- data/vendor/bundle/gems/sass-3.1.19/lib/sass/tree/visitors/perform.rb +357 -0
- data/vendor/bundle/gems/sass-3.1.19/lib/sass/tree/visitors/set_options.rb +97 -0
- data/vendor/bundle/gems/sass-3.1.19/lib/sass/tree/visitors/to_css.rb +219 -0
- data/vendor/bundle/gems/sass-3.1.19/lib/sass/tree/warn_node.rb +18 -0
- data/vendor/bundle/gems/sass-3.1.19/lib/sass/tree/while_node.rb +18 -0
- data/vendor/bundle/gems/sass-3.1.19/lib/sass/util/multibyte_string_scanner.rb +134 -0
- data/vendor/bundle/gems/sass-3.1.19/lib/sass/util/subset_map.rb +101 -0
- data/vendor/bundle/gems/sass-3.1.19/lib/sass/util.rb +800 -0
- data/vendor/bundle/gems/sass-3.1.19/lib/sass/version.rb +112 -0
- data/vendor/bundle/gems/sass-3.1.19/lib/sass.rb +73 -0
- data/vendor/bundle/gems/sass-3.1.19/rails/init.rb +1 -0
- data/vendor/bundle/gems/sass-3.1.19/test/Gemfile +4 -0
- data/vendor/bundle/gems/sass-3.1.19/test/sass/cache_test.rb +89 -0
- data/vendor/bundle/gems/sass-3.1.19/test/sass/callbacks_test.rb +61 -0
- data/vendor/bundle/gems/sass-3.1.19/test/sass/conversion_test.rb +1245 -0
- data/vendor/bundle/gems/sass-3.1.19/test/sass/css2sass_test.rb +397 -0
- data/vendor/bundle/gems/sass-3.1.19/test/sass/data/hsl-rgb.txt +319 -0
- data/vendor/bundle/gems/sass-3.1.19/test/sass/engine_test.rb +2730 -0
- data/vendor/bundle/gems/sass-3.1.19/test/sass/extend_test.rb +1663 -0
- data/vendor/bundle/gems/sass-3.1.19/test/sass/fixtures/test_staleness_check_across_importers.css +1 -0
- data/vendor/bundle/gems/sass-3.1.19/test/sass/fixtures/test_staleness_check_across_importers.scss +1 -0
- data/vendor/bundle/gems/sass-3.1.19/test/sass/functions_test.rb +1047 -0
- data/vendor/bundle/gems/sass-3.1.19/test/sass/importer_test.rb +192 -0
- data/vendor/bundle/gems/sass-3.1.19/test/sass/less_conversion_test.rb +653 -0
- data/vendor/bundle/gems/sass-3.1.19/test/sass/logger_test.rb +58 -0
- data/vendor/bundle/gems/sass-3.1.19/test/sass/mock_importer.rb +49 -0
- data/vendor/bundle/gems/sass-3.1.19/test/sass/more_results/more1.css +9 -0
- data/vendor/bundle/gems/sass-3.1.19/test/sass/more_results/more1_with_line_comments.css +26 -0
- data/vendor/bundle/gems/sass-3.1.19/test/sass/more_results/more_import.css +29 -0
- data/vendor/bundle/gems/sass-3.1.19/test/sass/more_templates/_more_partial.sass +2 -0
- data/vendor/bundle/gems/sass-3.1.19/test/sass/more_templates/more1.sass +23 -0
- data/vendor/bundle/gems/sass-3.1.19/test/sass/more_templates/more_import.sass +11 -0
- data/vendor/bundle/gems/sass-3.1.19/test/sass/plugin_test.rb +496 -0
- data/vendor/bundle/gems/sass-3.1.19/test/sass/results/alt.css +4 -0
- data/vendor/bundle/gems/sass-3.1.19/test/sass/results/basic.css +9 -0
- data/vendor/bundle/gems/sass-3.1.19/test/sass/results/compact.css +5 -0
- data/vendor/bundle/gems/sass-3.1.19/test/sass/results/complex.css +86 -0
- data/vendor/bundle/gems/sass-3.1.19/test/sass/results/compressed.css +1 -0
- data/vendor/bundle/gems/sass-3.1.19/test/sass/results/expanded.css +19 -0
- data/vendor/bundle/gems/sass-3.1.19/test/sass/results/if.css +3 -0
- data/vendor/bundle/gems/sass-3.1.19/test/sass/results/import.css +31 -0
- data/vendor/bundle/gems/sass-3.1.19/test/sass/results/import_charset.css +5 -0
- data/vendor/bundle/gems/sass-3.1.19/test/sass/results/import_charset_1_8.css +5 -0
- data/vendor/bundle/gems/sass-3.1.19/test/sass/results/import_charset_ibm866.css +5 -0
- data/vendor/bundle/gems/sass-3.1.19/test/sass/results/line_numbers.css +49 -0
- data/vendor/bundle/gems/sass-3.1.19/test/sass/results/mixins.css +95 -0
- data/vendor/bundle/gems/sass-3.1.19/test/sass/results/multiline.css +24 -0
- data/vendor/bundle/gems/sass-3.1.19/test/sass/results/nested.css +22 -0
- data/vendor/bundle/gems/sass-3.1.19/test/sass/results/options.css +1 -0
- data/vendor/bundle/gems/sass-3.1.19/test/sass/results/parent_ref.css +13 -0
- data/vendor/bundle/gems/sass-3.1.19/test/sass/results/script.css +16 -0
- data/vendor/bundle/gems/sass-3.1.19/test/sass/results/scss_import.css +31 -0
- data/vendor/bundle/gems/sass-3.1.19/test/sass/results/scss_importee.css +2 -0
- data/vendor/bundle/gems/sass-3.1.19/test/sass/results/subdir/nested_subdir/nested_subdir.css +1 -0
- data/vendor/bundle/gems/sass-3.1.19/test/sass/results/subdir/subdir.css +3 -0
- data/vendor/bundle/gems/sass-3.1.19/test/sass/results/units.css +11 -0
- data/vendor/bundle/gems/sass-3.1.19/test/sass/results/warn.css +0 -0
- data/vendor/bundle/gems/sass-3.1.19/test/sass/results/warn_imported.css +0 -0
- data/vendor/bundle/gems/sass-3.1.19/test/sass/script_conversion_test.rb +285 -0
- data/vendor/bundle/gems/sass-3.1.19/test/sass/script_test.rb +519 -0
- data/vendor/bundle/gems/sass-3.1.19/test/sass/scss/css_test.rb +975 -0
- data/vendor/bundle/gems/sass-3.1.19/test/sass/scss/rx_test.rb +156 -0
- data/vendor/bundle/gems/sass-3.1.19/test/sass/scss/scss_test.rb +1308 -0
- data/vendor/bundle/gems/sass-3.1.19/test/sass/scss/test_helper.rb +37 -0
- data/vendor/bundle/gems/sass-3.1.19/test/sass/templates/_double_import_loop2.sass +1 -0
- data/vendor/bundle/gems/sass-3.1.19/test/sass/templates/_imported_charset_ibm866.sass +4 -0
- data/vendor/bundle/gems/sass-3.1.19/test/sass/templates/_imported_charset_utf8.sass +4 -0
- data/vendor/bundle/gems/sass-3.1.19/test/sass/templates/_partial.sass +2 -0
- data/vendor/bundle/gems/sass-3.1.19/test/sass/templates/alt.sass +16 -0
- data/vendor/bundle/gems/sass-3.1.19/test/sass/templates/basic.sass +23 -0
- data/vendor/bundle/gems/sass-3.1.19/test/sass/templates/bork1.sass +2 -0
- data/vendor/bundle/gems/sass-3.1.19/test/sass/templates/bork2.sass +2 -0
- data/vendor/bundle/gems/sass-3.1.19/test/sass/templates/bork3.sass +2 -0
- data/vendor/bundle/gems/sass-3.1.19/test/sass/templates/bork4.sass +2 -0
- data/vendor/bundle/gems/sass-3.1.19/test/sass/templates/bork5.sass +3 -0
- data/vendor/bundle/gems/sass-3.1.19/test/sass/templates/compact.sass +17 -0
- data/vendor/bundle/gems/sass-3.1.19/test/sass/templates/complex.sass +305 -0
- data/vendor/bundle/gems/sass-3.1.19/test/sass/templates/compressed.sass +15 -0
- data/vendor/bundle/gems/sass-3.1.19/test/sass/templates/double_import_loop1.sass +1 -0
- data/vendor/bundle/gems/sass-3.1.19/test/sass/templates/expanded.sass +17 -0
- data/vendor/bundle/gems/sass-3.1.19/test/sass/templates/if.sass +11 -0
- data/vendor/bundle/gems/sass-3.1.19/test/sass/templates/import.sass +12 -0
- data/vendor/bundle/gems/sass-3.1.19/test/sass/templates/import_charset.sass +9 -0
- data/vendor/bundle/gems/sass-3.1.19/test/sass/templates/import_charset_1_8.sass +6 -0
- data/vendor/bundle/gems/sass-3.1.19/test/sass/templates/import_charset_ibm866.sass +11 -0
- data/vendor/bundle/gems/sass-3.1.19/test/sass/templates/importee.less +2 -0
- data/vendor/bundle/gems/sass-3.1.19/test/sass/templates/importee.sass +19 -0
- data/vendor/bundle/gems/sass-3.1.19/test/sass/templates/line_numbers.sass +13 -0
- data/vendor/bundle/gems/sass-3.1.19/test/sass/templates/mixin_bork.sass +5 -0
- data/vendor/bundle/gems/sass-3.1.19/test/sass/templates/mixins.sass +76 -0
- data/vendor/bundle/gems/sass-3.1.19/test/sass/templates/multiline.sass +20 -0
- data/vendor/bundle/gems/sass-3.1.19/test/sass/templates/nested.sass +25 -0
- data/vendor/bundle/gems/sass-3.1.19/test/sass/templates/nested_bork1.sass +2 -0
- data/vendor/bundle/gems/sass-3.1.19/test/sass/templates/nested_bork2.sass +2 -0
- data/vendor/bundle/gems/sass-3.1.19/test/sass/templates/nested_bork3.sass +2 -0
- data/vendor/bundle/gems/sass-3.1.19/test/sass/templates/nested_bork4.sass +2 -0
- data/vendor/bundle/gems/sass-3.1.19/test/sass/templates/nested_bork5.sass +2 -0
- data/vendor/bundle/gems/sass-3.1.19/test/sass/templates/nested_import.sass +2 -0
- data/vendor/bundle/gems/sass-3.1.19/test/sass/templates/nested_mixin_bork.sass +6 -0
- data/vendor/bundle/gems/sass-3.1.19/test/sass/templates/options.sass +2 -0
- data/vendor/bundle/gems/sass-3.1.19/test/sass/templates/parent_ref.sass +25 -0
- data/vendor/bundle/gems/sass-3.1.19/test/sass/templates/script.sass +101 -0
- data/vendor/bundle/gems/sass-3.1.19/test/sass/templates/scss_import.scss +11 -0
- data/vendor/bundle/gems/sass-3.1.19/test/sass/templates/scss_importee.scss +1 -0
- data/vendor/bundle/gems/sass-3.1.19/test/sass/templates/single_import_loop.sass +1 -0
- data/vendor/bundle/gems/sass-3.1.19/test/sass/templates/subdir/nested_subdir/_nested_partial.sass +2 -0
- data/vendor/bundle/gems/sass-3.1.19/test/sass/templates/subdir/nested_subdir/nested_subdir.sass +3 -0
- data/vendor/bundle/gems/sass-3.1.19/test/sass/templates/subdir/subdir.sass +6 -0
- data/vendor/bundle/gems/sass-3.1.19/test/sass/templates/units.sass +11 -0
- data/vendor/bundle/gems/sass-3.1.19/test/sass/templates/warn.sass +3 -0
- data/vendor/bundle/gems/sass-3.1.19/test/sass/templates/warn_imported.sass +4 -0
- data/vendor/bundle/gems/sass-3.1.19/test/sass/test_helper.rb +8 -0
- data/vendor/bundle/gems/sass-3.1.19/test/sass/util/multibyte_string_scanner_test.rb +147 -0
- data/vendor/bundle/gems/sass-3.1.19/test/sass/util/subset_map_test.rb +91 -0
- data/vendor/bundle/gems/sass-3.1.19/test/sass/util_test.rb +282 -0
- data/vendor/bundle/gems/sass-3.1.19/test/test_helper.rb +70 -0
- data/vendor/bundle/gems/sass-3.1.19/vendor/listen/CHANGELOG.md +90 -0
- data/vendor/bundle/gems/sass-3.1.19/vendor/listen/Gemfile +35 -0
- data/vendor/bundle/gems/sass-3.1.19/vendor/listen/Guardfile +8 -0
- data/vendor/bundle/gems/sass-3.1.19/vendor/listen/LICENSE +20 -0
- data/vendor/bundle/gems/sass-3.1.19/vendor/listen/README.md +312 -0
- data/vendor/bundle/gems/sass-3.1.19/vendor/listen/Rakefile +47 -0
- data/vendor/bundle/gems/sass-3.1.19/vendor/listen/Vagrantfile +96 -0
- data/vendor/bundle/gems/sass-3.1.19/vendor/listen/lib/listen/adapter.rb +167 -0
- data/vendor/bundle/gems/sass-3.1.19/vendor/listen/lib/listen/adapters/darwin.rb +84 -0
- data/vendor/bundle/gems/sass-3.1.19/vendor/listen/lib/listen/adapters/linux.rb +110 -0
- data/vendor/bundle/gems/sass-3.1.19/vendor/listen/lib/listen/adapters/polling.rb +66 -0
- data/vendor/bundle/gems/sass-3.1.19/vendor/listen/lib/listen/adapters/windows.rb +81 -0
- data/vendor/bundle/gems/sass-3.1.19/vendor/listen/lib/listen/directory_record.rb +317 -0
- data/vendor/bundle/gems/sass-3.1.19/vendor/listen/lib/listen/listener.rb +203 -0
- data/vendor/bundle/gems/sass-3.1.19/vendor/listen/lib/listen/multi_listener.rb +121 -0
- data/vendor/bundle/gems/sass-3.1.19/vendor/listen/lib/listen/turnstile.rb +28 -0
- data/vendor/bundle/gems/sass-3.1.19/vendor/listen/lib/listen/version.rb +3 -0
- data/vendor/bundle/gems/sass-3.1.19/vendor/listen/lib/listen.rb +38 -0
- data/vendor/bundle/gems/sass-3.1.19/vendor/listen/listen.gemspec +26 -0
- data/vendor/bundle/gems/sass-3.1.19/vendor/listen/spec/listen/adapter_spec.rb +142 -0
- data/vendor/bundle/gems/sass-3.1.19/vendor/listen/spec/listen/adapters/darwin_spec.rb +31 -0
- data/vendor/bundle/gems/sass-3.1.19/vendor/listen/spec/listen/adapters/linux_spec.rb +41 -0
- data/vendor/bundle/gems/sass-3.1.19/vendor/listen/spec/listen/adapters/polling_spec.rb +68 -0
- data/vendor/bundle/gems/sass-3.1.19/vendor/listen/spec/listen/adapters/windows_spec.rb +24 -0
- data/vendor/bundle/gems/sass-3.1.19/vendor/listen/spec/listen/directory_record_spec.rb +1034 -0
- data/vendor/bundle/gems/sass-3.1.19/vendor/listen/spec/listen/listener_spec.rb +155 -0
- data/vendor/bundle/gems/sass-3.1.19/vendor/listen/spec/listen/multi_listener_spec.rb +156 -0
- data/vendor/bundle/gems/sass-3.1.19/vendor/listen/spec/listen/turnstile_spec.rb +56 -0
- data/vendor/bundle/gems/sass-3.1.19/vendor/listen/spec/listen_spec.rb +73 -0
- data/vendor/bundle/gems/sass-3.1.19/vendor/listen/spec/spec_helper.rb +16 -0
- data/vendor/bundle/gems/sass-3.1.19/vendor/listen/spec/support/adapter_helper.rb +716 -0
- data/vendor/bundle/gems/sass-3.1.19/vendor/listen/spec/support/directory_record_helper.rb +55 -0
- data/vendor/bundle/gems/sass-3.1.19/vendor/listen/spec/support/fixtures_helper.rb +29 -0
- data/vendor/bundle/gems/sass-3.1.19/vendor/listen/spec/support/listeners_helper.rb +144 -0
- data/vendor/bundle/gems/sass-3.1.19/vendor/listen/spec/support/platform_helper.rb +11 -0
- data/vendor/bundle/gems/therubyracer-0.10.1/.gitignore +13 -0
- data/vendor/bundle/gems/therubyracer-0.10.1/.gitmodules +3 -0
- data/vendor/bundle/gems/therubyracer-0.10.1/.travis.yml +9 -0
- data/vendor/bundle/gems/therubyracer-0.10.1/.yardopts +1 -0
- data/vendor/bundle/gems/therubyracer-0.10.1/Changelog.md +196 -0
- data/vendor/bundle/gems/therubyracer-0.10.1/Gemfile +1 -0
- data/vendor/bundle/gems/therubyracer-0.10.1/README.md +167 -0
- data/vendor/bundle/gems/therubyracer-0.10.1/Rakefile +23 -0
- data/vendor/bundle/gems/therubyracer-0.10.1/bin/therubyracer +11 -0
- data/vendor/bundle/gems/therubyracer-0.10.1/ext/v8/Makefile +213 -0
- data/vendor/bundle/gems/therubyracer-0.10.1/ext/v8/extconf.rb +26 -0
- data/vendor/bundle/gems/therubyracer-0.10.1/ext/v8/gem_make.out +156 -0
- data/vendor/bundle/gems/therubyracer-0.10.1/ext/v8/rr.cpp +189 -0
- data/vendor/bundle/gems/therubyracer-0.10.1/ext/v8/rr.h +41 -0
- data/vendor/bundle/gems/therubyracer-0.10.1/ext/v8/v8.cpp +48 -0
- data/vendor/bundle/gems/therubyracer-0.10.1/ext/v8/v8_array.cpp +48 -0
- data/vendor/bundle/gems/therubyracer-0.10.1/ext/v8/v8_array.h +8 -0
- data/vendor/bundle/gems/therubyracer-0.10.1/ext/v8/v8_callbacks.cpp +81 -0
- data/vendor/bundle/gems/therubyracer-0.10.1/ext/v8/v8_callbacks.h +8 -0
- data/vendor/bundle/gems/therubyracer-0.10.1/ext/v8/v8_context.cpp +92 -0
- data/vendor/bundle/gems/therubyracer-0.10.1/ext/v8/v8_context.h +6 -0
- data/vendor/bundle/gems/therubyracer-0.10.1/ext/v8/v8_date.cpp +34 -0
- data/vendor/bundle/gems/therubyracer-0.10.1/ext/v8/v8_date.h +6 -0
- data/vendor/bundle/gems/therubyracer-0.10.1/ext/v8/v8_debug.cpp +17 -0
- data/vendor/bundle/gems/therubyracer-0.10.1/ext/v8/v8_debug.h +6 -0
- data/vendor/bundle/gems/therubyracer-0.10.1/ext/v8/v8_exception.cpp +133 -0
- data/vendor/bundle/gems/therubyracer-0.10.1/ext/v8/v8_exception.h +11 -0
- data/vendor/bundle/gems/therubyracer-0.10.1/ext/v8/v8_external.cpp +70 -0
- data/vendor/bundle/gems/therubyracer-0.10.1/ext/v8/v8_external.h +8 -0
- data/vendor/bundle/gems/therubyracer-0.10.1/ext/v8/v8_function.cpp +69 -0
- data/vendor/bundle/gems/therubyracer-0.10.1/ext/v8/v8_function.h +11 -0
- data/vendor/bundle/gems/therubyracer-0.10.1/ext/v8/v8_handle.cpp +186 -0
- data/vendor/bundle/gems/therubyracer-0.10.1/ext/v8/v8_handle.h +48 -0
- data/vendor/bundle/gems/therubyracer-0.10.1/ext/v8/v8_locker.cpp +139 -0
- data/vendor/bundle/gems/therubyracer-0.10.1/ext/v8/v8_locker.h +6 -0
- data/vendor/bundle/gems/therubyracer-0.10.1/ext/v8/v8_message.cpp +67 -0
- data/vendor/bundle/gems/therubyracer-0.10.1/ext/v8/v8_message.h +10 -0
- data/vendor/bundle/gems/therubyracer-0.10.1/ext/v8/v8_object.cpp +122 -0
- data/vendor/bundle/gems/therubyracer-0.10.1/ext/v8/v8_object.h +10 -0
- data/vendor/bundle/gems/therubyracer-0.10.1/ext/v8/v8_script.cpp +36 -0
- data/vendor/bundle/gems/therubyracer-0.10.1/ext/v8/v8_script.h +8 -0
- data/vendor/bundle/gems/therubyracer-0.10.1/ext/v8/v8_string.cpp +52 -0
- data/vendor/bundle/gems/therubyracer-0.10.1/ext/v8/v8_string.h +9 -0
- data/vendor/bundle/gems/therubyracer-0.10.1/ext/v8/v8_template.cpp +344 -0
- data/vendor/bundle/gems/therubyracer-0.10.1/ext/v8/v8_template.h +8 -0
- data/vendor/bundle/gems/therubyracer-0.10.1/ext/v8/v8_try_catch.cpp +70 -0
- data/vendor/bundle/gems/therubyracer-0.10.1/ext/v8/v8_try_catch.h +5 -0
- data/vendor/bundle/gems/therubyracer-0.10.1/ext/v8/v8_v8.cpp +35 -0
- data/vendor/bundle/gems/therubyracer-0.10.1/ext/v8/v8_v8.h +6 -0
- data/vendor/bundle/gems/therubyracer-0.10.1/ext/v8/v8_value.cpp +175 -0
- data/vendor/bundle/gems/therubyracer-0.10.1/ext/v8/v8_value.h +10 -0
- data/vendor/bundle/gems/therubyracer-0.10.1/ext/v8/v8_weakref.cpp +61 -0
- data/vendor/bundle/gems/therubyracer-0.10.1/ext/v8/v8_weakref.h +29 -0
- data/vendor/bundle/gems/therubyracer-0.10.1/lib/v8/access.rb +87 -0
- data/vendor/bundle/gems/therubyracer-0.10.1/lib/v8/array.rb +17 -0
- data/vendor/bundle/gems/therubyracer-0.10.1/lib/v8/c/locker.rb +18 -0
- data/vendor/bundle/gems/therubyracer-0.10.1/lib/v8/cli.rb +133 -0
- data/vendor/bundle/gems/therubyracer-0.10.1/lib/v8/context.rb +111 -0
- data/vendor/bundle/gems/therubyracer-0.10.1/lib/v8/error.rb +130 -0
- data/vendor/bundle/gems/therubyracer-0.10.1/lib/v8/function.rb +44 -0
- data/vendor/bundle/gems/therubyracer-0.10.1/lib/v8/object.rb +69 -0
- data/vendor/bundle/gems/therubyracer-0.10.1/lib/v8/portal/caller.rb +37 -0
- data/vendor/bundle/gems/therubyracer-0.10.1/lib/v8/portal/constructor.rb +98 -0
- data/vendor/bundle/gems/therubyracer-0.10.1/lib/v8/portal/function.rb +63 -0
- data/vendor/bundle/gems/therubyracer-0.10.1/lib/v8/portal/interceptors.rb +152 -0
- data/vendor/bundle/gems/therubyracer-0.10.1/lib/v8/portal/proxies.rb +151 -0
- data/vendor/bundle/gems/therubyracer-0.10.1/lib/v8/portal/templates.rb +73 -0
- data/vendor/bundle/gems/therubyracer-0.10.1/lib/v8/portal.rb +86 -0
- data/vendor/bundle/gems/therubyracer-0.10.1/lib/v8/stack.rb +66 -0
- data/vendor/bundle/gems/therubyracer-0.10.1/lib/v8/tap.rb +9 -0
- data/vendor/bundle/gems/therubyracer-0.10.1/lib/v8/version.rb +3 -0
- data/vendor/bundle/gems/therubyracer-0.10.1/lib/v8.rb +23 -0
- data/vendor/bundle/gems/therubyracer-0.10.1/spec/ext/array_spec.rb +15 -0
- data/vendor/bundle/gems/therubyracer-0.10.1/spec/ext/cxt_spec.rb +57 -0
- data/vendor/bundle/gems/therubyracer-0.10.1/spec/ext/ext_spec_helper.rb +27 -0
- data/vendor/bundle/gems/therubyracer-0.10.1/spec/ext/func_spec.rb +64 -0
- data/vendor/bundle/gems/therubyracer-0.10.1/spec/ext/object_spec.rb +10 -0
- data/vendor/bundle/gems/therubyracer-0.10.1/spec/ext/string_spec.rb +11 -0
- data/vendor/bundle/gems/therubyracer-0.10.1/spec/ext/try_catch_spec.rb +60 -0
- data/vendor/bundle/gems/therubyracer-0.10.1/spec/redjs/.gitignore +1 -0
- data/vendor/bundle/gems/therubyracer-0.10.1/spec/redjs/README.txt +8 -0
- data/vendor/bundle/gems/therubyracer-0.10.1/spec/redjs/jsapi_spec.rb +922 -0
- data/vendor/bundle/gems/therubyracer-0.10.1/spec/redjs/loadme.js +1 -0
- data/vendor/bundle/gems/therubyracer-0.10.1/spec/redjs_helper.rb +3 -0
- data/vendor/bundle/gems/therubyracer-0.10.1/spec/spec_helper.rb +9 -0
- data/vendor/bundle/gems/therubyracer-0.10.1/spec/v8/error_spec.rb +131 -0
- data/vendor/bundle/gems/therubyracer-0.10.1/spec/v8/portal/proxies_spec.rb +106 -0
- data/vendor/bundle/gems/therubyracer-0.10.1/specmem/handle_memspec.rb +41 -0
- data/vendor/bundle/gems/therubyracer-0.10.1/specmem/object_memspec.rb +14 -0
- data/vendor/bundle/gems/therubyracer-0.10.1/specmem/proxies_memspec.rb +49 -0
- data/vendor/bundle/gems/therubyracer-0.10.1/specmem/spec_helper.rb +24 -0
- data/vendor/bundle/gems/therubyracer-0.10.1/specthread/spec_helper.rb +2 -0
- data/vendor/bundle/gems/therubyracer-0.10.1/specthread/threading_spec.rb +13 -0
- data/vendor/bundle/gems/therubyracer-0.10.1/thefrontside.png +0 -0
- data/vendor/bundle/gems/therubyracer-0.10.1/therubyracer.gemspec +29 -0
- data/vendor/bundle/specifications/libv8-3.3.10.4-x86_64-darwin-11.gemspec +33 -0
- data/vendor/bundle/specifications/sass-3.1.19.gemspec +35 -0
- metadata +365 -3
|
@@ -0,0 +1,475 @@
|
|
|
1
|
+
require 'sass/script/literal'
|
|
2
|
+
|
|
3
|
+
module Sass::Script
|
|
4
|
+
# A SassScript object representing a CSS color.
|
|
5
|
+
#
|
|
6
|
+
# A color may be represented internally as RGBA, HSLA, or both.
|
|
7
|
+
# It's originally represented as whatever its input is;
|
|
8
|
+
# if it's created with RGB values, it's represented as RGBA,
|
|
9
|
+
# and if it's created with HSL values, it's represented as HSLA.
|
|
10
|
+
# Once a property is accessed that requires the other representation --
|
|
11
|
+
# for example, \{#red} for an HSL color --
|
|
12
|
+
# that component is calculated and cached.
|
|
13
|
+
#
|
|
14
|
+
# The alpha channel of a color is independent of its RGB or HSL representation.
|
|
15
|
+
# It's always stored, as 1 if nothing else is specified.
|
|
16
|
+
# If only the alpha channel is modified using \{#with},
|
|
17
|
+
# the cached RGB and HSL values are retained.
|
|
18
|
+
class Color < Literal
|
|
19
|
+
class << self; include Sass::Util; end
|
|
20
|
+
|
|
21
|
+
# A hash from color names to `[red, green, blue]` value arrays.
|
|
22
|
+
HTML4_COLORS = map_vals({
|
|
23
|
+
'black' => 0x000000,
|
|
24
|
+
'silver' => 0xc0c0c0,
|
|
25
|
+
'gray' => 0x808080,
|
|
26
|
+
'white' => 0xffffff,
|
|
27
|
+
'maroon' => 0x800000,
|
|
28
|
+
'red' => 0xff0000,
|
|
29
|
+
'purple' => 0x800080,
|
|
30
|
+
'fuchsia' => 0xff00ff,
|
|
31
|
+
'green' => 0x008000,
|
|
32
|
+
'lime' => 0x00ff00,
|
|
33
|
+
'olive' => 0x808000,
|
|
34
|
+
'yellow' => 0xffff00,
|
|
35
|
+
'navy' => 0x000080,
|
|
36
|
+
'blue' => 0x0000ff,
|
|
37
|
+
'teal' => 0x008080,
|
|
38
|
+
'aqua' => 0x00ffff
|
|
39
|
+
}) {|color| (0..2).map {|n| color >> (n << 3) & 0xff}.reverse}
|
|
40
|
+
# A hash from `[red, green, blue]` value arrays to color names.
|
|
41
|
+
HTML4_COLORS_REVERSE = map_hash(HTML4_COLORS) {|k, v| [v, k]}
|
|
42
|
+
|
|
43
|
+
# Constructs an RGB or HSL color object,
|
|
44
|
+
# optionally with an alpha channel.
|
|
45
|
+
#
|
|
46
|
+
# The RGB values must be between 0 and 255.
|
|
47
|
+
# The saturation and lightness values must be between 0 and 100.
|
|
48
|
+
# The alpha value must be between 0 and 1.
|
|
49
|
+
#
|
|
50
|
+
# @raise [Sass::SyntaxError] if any color value isn't in the specified range
|
|
51
|
+
#
|
|
52
|
+
# @overload initialize(attrs)
|
|
53
|
+
# The attributes are specified as a hash.
|
|
54
|
+
# This hash must contain either `:hue`, `:saturation`, and `:value` keys,
|
|
55
|
+
# or `:red`, `:green`, and `:blue` keys.
|
|
56
|
+
# It cannot contain both HSL and RGB keys.
|
|
57
|
+
# It may also optionally contain an `:alpha` key.
|
|
58
|
+
#
|
|
59
|
+
# @param attrs [{Symbol => Numeric}] A hash of color attributes to values
|
|
60
|
+
# @raise [ArgumentError] if not enough attributes are specified,
|
|
61
|
+
# or both RGB and HSL attributes are specified
|
|
62
|
+
#
|
|
63
|
+
# @overload initialize(rgba)
|
|
64
|
+
# The attributes are specified as an array.
|
|
65
|
+
# This overload only supports RGB or RGBA colors.
|
|
66
|
+
#
|
|
67
|
+
# @param rgba [Array<Numeric>] A three- or four-element array
|
|
68
|
+
# of the red, green, blue, and optionally alpha values (respectively)
|
|
69
|
+
# of the color
|
|
70
|
+
# @raise [ArgumentError] if not enough attributes are specified
|
|
71
|
+
def initialize(attrs, allow_both_rgb_and_hsl = false)
|
|
72
|
+
super(nil)
|
|
73
|
+
|
|
74
|
+
if attrs.is_a?(Array)
|
|
75
|
+
unless (3..4).include?(attrs.size)
|
|
76
|
+
raise ArgumentError.new("Color.new(array) expects a three- or four-element array")
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
red, green, blue = attrs[0...3].map {|c| c.to_i}
|
|
80
|
+
@attrs = {:red => red, :green => green, :blue => blue}
|
|
81
|
+
@attrs[:alpha] = attrs[3] ? attrs[3].to_f : 1
|
|
82
|
+
else
|
|
83
|
+
attrs = attrs.reject {|k, v| v.nil?}
|
|
84
|
+
hsl = [:hue, :saturation, :lightness] & attrs.keys
|
|
85
|
+
rgb = [:red, :green, :blue] & attrs.keys
|
|
86
|
+
if !allow_both_rgb_and_hsl && !hsl.empty? && !rgb.empty?
|
|
87
|
+
raise ArgumentError.new("Color.new(hash) may not have both HSL and RGB keys specified")
|
|
88
|
+
elsif hsl.empty? && rgb.empty?
|
|
89
|
+
raise ArgumentError.new("Color.new(hash) must have either HSL or RGB keys specified")
|
|
90
|
+
elsif !hsl.empty? && hsl.size != 3
|
|
91
|
+
raise ArgumentError.new("Color.new(hash) must have all three HSL values specified")
|
|
92
|
+
elsif !rgb.empty? && rgb.size != 3
|
|
93
|
+
raise ArgumentError.new("Color.new(hash) must have all three RGB values specified")
|
|
94
|
+
end
|
|
95
|
+
|
|
96
|
+
@attrs = attrs
|
|
97
|
+
@attrs[:hue] %= 360 if @attrs[:hue]
|
|
98
|
+
@attrs[:alpha] ||= 1
|
|
99
|
+
end
|
|
100
|
+
|
|
101
|
+
[:red, :green, :blue].each do |k|
|
|
102
|
+
next if @attrs[k].nil?
|
|
103
|
+
@attrs[k] = @attrs[k].to_i
|
|
104
|
+
Sass::Util.check_range("#{k.to_s.capitalize} value", 0..255, @attrs[k])
|
|
105
|
+
end
|
|
106
|
+
|
|
107
|
+
[:saturation, :lightness].each do |k|
|
|
108
|
+
next if @attrs[k].nil?
|
|
109
|
+
value = Number.new(@attrs[k], ['%']) # Get correct unit for error messages
|
|
110
|
+
@attrs[k] = Sass::Util.check_range("#{k.to_s.capitalize}", 0..100, value, '%')
|
|
111
|
+
end
|
|
112
|
+
|
|
113
|
+
@attrs[:alpha] = Sass::Util.check_range("Alpha channel", 0..1, @attrs[:alpha])
|
|
114
|
+
end
|
|
115
|
+
|
|
116
|
+
# The red component of the color.
|
|
117
|
+
#
|
|
118
|
+
# @return [Fixnum]
|
|
119
|
+
def red
|
|
120
|
+
hsl_to_rgb!
|
|
121
|
+
@attrs[:red]
|
|
122
|
+
end
|
|
123
|
+
|
|
124
|
+
# The green component of the color.
|
|
125
|
+
#
|
|
126
|
+
# @return [Fixnum]
|
|
127
|
+
def green
|
|
128
|
+
hsl_to_rgb!
|
|
129
|
+
@attrs[:green]
|
|
130
|
+
end
|
|
131
|
+
|
|
132
|
+
# The blue component of the color.
|
|
133
|
+
#
|
|
134
|
+
# @return [Fixnum]
|
|
135
|
+
def blue
|
|
136
|
+
hsl_to_rgb!
|
|
137
|
+
@attrs[:blue]
|
|
138
|
+
end
|
|
139
|
+
|
|
140
|
+
# The hue component of the color.
|
|
141
|
+
#
|
|
142
|
+
# @return [Numeric]
|
|
143
|
+
def hue
|
|
144
|
+
rgb_to_hsl!
|
|
145
|
+
@attrs[:hue]
|
|
146
|
+
end
|
|
147
|
+
|
|
148
|
+
# The saturation component of the color.
|
|
149
|
+
#
|
|
150
|
+
# @return [Numeric]
|
|
151
|
+
def saturation
|
|
152
|
+
rgb_to_hsl!
|
|
153
|
+
@attrs[:saturation]
|
|
154
|
+
end
|
|
155
|
+
|
|
156
|
+
# The lightness component of the color.
|
|
157
|
+
#
|
|
158
|
+
# @return [Numeric]
|
|
159
|
+
def lightness
|
|
160
|
+
rgb_to_hsl!
|
|
161
|
+
@attrs[:lightness]
|
|
162
|
+
end
|
|
163
|
+
|
|
164
|
+
# The alpha channel (opacity) of the color.
|
|
165
|
+
# This is 1 unless otherwise defined.
|
|
166
|
+
#
|
|
167
|
+
# @return [Fixnum]
|
|
168
|
+
def alpha
|
|
169
|
+
@attrs[:alpha]
|
|
170
|
+
end
|
|
171
|
+
|
|
172
|
+
# Returns whether this color object is translucent;
|
|
173
|
+
# that is, whether the alpha channel is non-1.
|
|
174
|
+
#
|
|
175
|
+
# @return [Boolean]
|
|
176
|
+
def alpha?
|
|
177
|
+
alpha < 1
|
|
178
|
+
end
|
|
179
|
+
|
|
180
|
+
# Returns the red, green, and blue components of the color.
|
|
181
|
+
#
|
|
182
|
+
# @return [Array<Fixnum>] A frozen three-element array of the red, green, and blue
|
|
183
|
+
# values (respectively) of the color
|
|
184
|
+
def rgb
|
|
185
|
+
[red, green, blue].freeze
|
|
186
|
+
end
|
|
187
|
+
|
|
188
|
+
# Returns the hue, saturation, and lightness components of the color.
|
|
189
|
+
#
|
|
190
|
+
# @return [Array<Fixnum>] A frozen three-element array of the
|
|
191
|
+
# hue, saturation, and lightness values (respectively) of the color
|
|
192
|
+
def hsl
|
|
193
|
+
[hue, saturation, lightness].freeze
|
|
194
|
+
end
|
|
195
|
+
|
|
196
|
+
# The SassScript `==` operation.
|
|
197
|
+
# **Note that this returns a {Sass::Script::Bool} object,
|
|
198
|
+
# not a Ruby boolean**.
|
|
199
|
+
#
|
|
200
|
+
# @param other [Literal] The right-hand side of the operator
|
|
201
|
+
# @return [Bool] True if this literal is the same as the other,
|
|
202
|
+
# false otherwise
|
|
203
|
+
def eq(other)
|
|
204
|
+
Sass::Script::Bool.new(
|
|
205
|
+
other.is_a?(Color) && rgb == other.rgb && alpha == other.alpha)
|
|
206
|
+
end
|
|
207
|
+
|
|
208
|
+
# Returns a copy of this color with one or more channels changed.
|
|
209
|
+
# RGB or HSL colors may be changed, but not both at once.
|
|
210
|
+
#
|
|
211
|
+
# For example:
|
|
212
|
+
#
|
|
213
|
+
# Color.new([10, 20, 30]).with(:blue => 40)
|
|
214
|
+
# #=> rgb(10, 40, 30)
|
|
215
|
+
# Color.new([126, 126, 126]).with(:red => 0, :green => 255)
|
|
216
|
+
# #=> rgb(0, 255, 126)
|
|
217
|
+
# Color.new([255, 0, 127]).with(:saturation => 60)
|
|
218
|
+
# #=> rgb(204, 51, 127)
|
|
219
|
+
# Color.new([1, 2, 3]).with(:alpha => 0.4)
|
|
220
|
+
# #=> rgba(1, 2, 3, 0.4)
|
|
221
|
+
#
|
|
222
|
+
# @param attrs [{Symbol => Numeric}]
|
|
223
|
+
# A map of channel names (`:red`, `:green`, `:blue`,
|
|
224
|
+
# `:hue`, `:saturation`, `:lightness`, or `:alpha`) to values
|
|
225
|
+
# @return [Color] The new Color object
|
|
226
|
+
# @raise [ArgumentError] if both RGB and HSL keys are specified
|
|
227
|
+
def with(attrs)
|
|
228
|
+
attrs = attrs.reject {|k, v| v.nil?}
|
|
229
|
+
hsl = !([:hue, :saturation, :lightness] & attrs.keys).empty?
|
|
230
|
+
rgb = !([:red, :green, :blue] & attrs.keys).empty?
|
|
231
|
+
if hsl && rgb
|
|
232
|
+
raise ArgumentError.new("Cannot specify HSL and RGB values for a color at the same time")
|
|
233
|
+
end
|
|
234
|
+
|
|
235
|
+
if hsl
|
|
236
|
+
[:hue, :saturation, :lightness].each {|k| attrs[k] ||= send(k)}
|
|
237
|
+
elsif rgb
|
|
238
|
+
[:red, :green, :blue].each {|k| attrs[k] ||= send(k)}
|
|
239
|
+
else
|
|
240
|
+
# If we're just changing the alpha channel,
|
|
241
|
+
# keep all the HSL/RGB stuff we've calculated
|
|
242
|
+
attrs = @attrs.merge(attrs)
|
|
243
|
+
end
|
|
244
|
+
attrs[:alpha] ||= alpha
|
|
245
|
+
|
|
246
|
+
Color.new(attrs, :allow_both_rgb_and_hsl)
|
|
247
|
+
end
|
|
248
|
+
|
|
249
|
+
# The SassScript `+` operation.
|
|
250
|
+
# Its functionality depends on the type of its argument:
|
|
251
|
+
#
|
|
252
|
+
# {Number}
|
|
253
|
+
# : Adds the number to each of the RGB color channels.
|
|
254
|
+
#
|
|
255
|
+
# {Color}
|
|
256
|
+
# : Adds each of the RGB color channels together.
|
|
257
|
+
#
|
|
258
|
+
# {Literal}
|
|
259
|
+
# : See {Literal#plus}.
|
|
260
|
+
#
|
|
261
|
+
# @param other [Literal] The right-hand side of the operator
|
|
262
|
+
# @return [Color] The resulting color
|
|
263
|
+
# @raise [Sass::SyntaxError] if `other` is a number with units
|
|
264
|
+
def plus(other)
|
|
265
|
+
if other.is_a?(Sass::Script::Number) || other.is_a?(Sass::Script::Color)
|
|
266
|
+
piecewise(other, :+)
|
|
267
|
+
else
|
|
268
|
+
super
|
|
269
|
+
end
|
|
270
|
+
end
|
|
271
|
+
|
|
272
|
+
# The SassScript `-` operation.
|
|
273
|
+
# Its functionality depends on the type of its argument:
|
|
274
|
+
#
|
|
275
|
+
# {Number}
|
|
276
|
+
# : Subtracts the number from each of the RGB color channels.
|
|
277
|
+
#
|
|
278
|
+
# {Color}
|
|
279
|
+
# : Subtracts each of the other color's RGB color channels from this color's.
|
|
280
|
+
#
|
|
281
|
+
# {Literal}
|
|
282
|
+
# : See {Literal#minus}.
|
|
283
|
+
#
|
|
284
|
+
# @param other [Literal] The right-hand side of the operator
|
|
285
|
+
# @return [Color] The resulting color
|
|
286
|
+
# @raise [Sass::SyntaxError] if `other` is a number with units
|
|
287
|
+
def minus(other)
|
|
288
|
+
if other.is_a?(Sass::Script::Number) || other.is_a?(Sass::Script::Color)
|
|
289
|
+
piecewise(other, :-)
|
|
290
|
+
else
|
|
291
|
+
super
|
|
292
|
+
end
|
|
293
|
+
end
|
|
294
|
+
|
|
295
|
+
# The SassScript `*` operation.
|
|
296
|
+
# Its functionality depends on the type of its argument:
|
|
297
|
+
#
|
|
298
|
+
# {Number}
|
|
299
|
+
# : Multiplies the number by each of the RGB color channels.
|
|
300
|
+
#
|
|
301
|
+
# {Color}
|
|
302
|
+
# : Multiplies each of the RGB color channels together.
|
|
303
|
+
#
|
|
304
|
+
# @param other [Number, Color] The right-hand side of the operator
|
|
305
|
+
# @return [Color] The resulting color
|
|
306
|
+
# @raise [Sass::SyntaxError] if `other` is a number with units
|
|
307
|
+
def times(other)
|
|
308
|
+
if other.is_a?(Sass::Script::Number) || other.is_a?(Sass::Script::Color)
|
|
309
|
+
piecewise(other, :*)
|
|
310
|
+
else
|
|
311
|
+
raise NoMethodError.new(nil, :times)
|
|
312
|
+
end
|
|
313
|
+
end
|
|
314
|
+
|
|
315
|
+
# The SassScript `/` operation.
|
|
316
|
+
# Its functionality depends on the type of its argument:
|
|
317
|
+
#
|
|
318
|
+
# {Number}
|
|
319
|
+
# : Divides each of the RGB color channels by the number.
|
|
320
|
+
#
|
|
321
|
+
# {Color}
|
|
322
|
+
# : Divides each of this color's RGB color channels by the other color's.
|
|
323
|
+
#
|
|
324
|
+
# {Literal}
|
|
325
|
+
# : See {Literal#div}.
|
|
326
|
+
#
|
|
327
|
+
# @param other [Literal] The right-hand side of the operator
|
|
328
|
+
# @return [Color] The resulting color
|
|
329
|
+
# @raise [Sass::SyntaxError] if `other` is a number with units
|
|
330
|
+
def div(other)
|
|
331
|
+
if other.is_a?(Sass::Script::Number) || other.is_a?(Sass::Script::Color)
|
|
332
|
+
piecewise(other, :/)
|
|
333
|
+
else
|
|
334
|
+
super
|
|
335
|
+
end
|
|
336
|
+
end
|
|
337
|
+
|
|
338
|
+
# The SassScript `%` operation.
|
|
339
|
+
# Its functionality depends on the type of its argument:
|
|
340
|
+
#
|
|
341
|
+
# {Number}
|
|
342
|
+
# : Takes each of the RGB color channels module the number.
|
|
343
|
+
#
|
|
344
|
+
# {Color}
|
|
345
|
+
# : Takes each of this color's RGB color channels modulo the other color's.
|
|
346
|
+
#
|
|
347
|
+
# @param other [Number, Color] The right-hand side of the operator
|
|
348
|
+
# @return [Color] The resulting color
|
|
349
|
+
# @raise [Sass::SyntaxError] if `other` is a number with units
|
|
350
|
+
def mod(other)
|
|
351
|
+
if other.is_a?(Sass::Script::Number) || other.is_a?(Sass::Script::Color)
|
|
352
|
+
piecewise(other, :%)
|
|
353
|
+
else
|
|
354
|
+
raise NoMethodError.new(nil, :mod)
|
|
355
|
+
end
|
|
356
|
+
end
|
|
357
|
+
|
|
358
|
+
# Returns a string representation of the color.
|
|
359
|
+
# This is usually the color's hex value,
|
|
360
|
+
# but if the color has a name that's used instead.
|
|
361
|
+
#
|
|
362
|
+
# @return [String] The string representation
|
|
363
|
+
def to_s(opts = {})
|
|
364
|
+
return rgba_str if alpha?
|
|
365
|
+
return smallest if options[:style] == :compressed
|
|
366
|
+
return HTML4_COLORS_REVERSE[rgb] if HTML4_COLORS_REVERSE[rgb]
|
|
367
|
+
hex_str
|
|
368
|
+
end
|
|
369
|
+
alias_method :to_sass, :to_s
|
|
370
|
+
|
|
371
|
+
# Returns a string representation of the color.
|
|
372
|
+
#
|
|
373
|
+
# @return [String] The hex value
|
|
374
|
+
def inspect
|
|
375
|
+
alpha? ? rgba_str : hex_str
|
|
376
|
+
end
|
|
377
|
+
|
|
378
|
+
private
|
|
379
|
+
|
|
380
|
+
def smallest
|
|
381
|
+
small_hex_str = hex_str.gsub(/^#(.)\1(.)\2(.)\3$/, '#\1\2\3')
|
|
382
|
+
return small_hex_str unless (color = HTML4_COLORS_REVERSE[rgb]) &&
|
|
383
|
+
color.size <= small_hex_str.size
|
|
384
|
+
return color
|
|
385
|
+
end
|
|
386
|
+
|
|
387
|
+
def rgba_str
|
|
388
|
+
split = options[:style] == :compressed ? ',' : ', '
|
|
389
|
+
"rgba(#{rgb.join(split)}#{split}#{Number.round(alpha)})"
|
|
390
|
+
end
|
|
391
|
+
|
|
392
|
+
def hex_str
|
|
393
|
+
red, green, blue = rgb.map { |num| num.to_s(16).rjust(2, '0') }
|
|
394
|
+
"##{red}#{green}#{blue}"
|
|
395
|
+
end
|
|
396
|
+
|
|
397
|
+
def piecewise(other, operation)
|
|
398
|
+
other_num = other.is_a? Number
|
|
399
|
+
if other_num && !other.unitless?
|
|
400
|
+
raise Sass::SyntaxError.new("Cannot add a number with units (#{other}) to a color (#{self}).")
|
|
401
|
+
end
|
|
402
|
+
|
|
403
|
+
result = []
|
|
404
|
+
for i in (0...3)
|
|
405
|
+
res = rgb[i].send(operation, other_num ? other.value : other.rgb[i])
|
|
406
|
+
result[i] = [ [res, 255].min, 0 ].max
|
|
407
|
+
end
|
|
408
|
+
|
|
409
|
+
if !other_num && other.alpha != alpha
|
|
410
|
+
raise Sass::SyntaxError.new("Alpha channels must be equal: #{self} #{operation} #{other}")
|
|
411
|
+
end
|
|
412
|
+
|
|
413
|
+
with(:red => result[0], :green => result[1], :blue => result[2])
|
|
414
|
+
end
|
|
415
|
+
|
|
416
|
+
def hsl_to_rgb!
|
|
417
|
+
return if @attrs[:red] && @attrs[:blue] && @attrs[:green]
|
|
418
|
+
|
|
419
|
+
h = @attrs[:hue] / 360.0
|
|
420
|
+
s = @attrs[:saturation] / 100.0
|
|
421
|
+
l = @attrs[:lightness] / 100.0
|
|
422
|
+
|
|
423
|
+
# Algorithm from the CSS3 spec: http://www.w3.org/TR/css3-color/#hsl-color.
|
|
424
|
+
m2 = l <= 0.5 ? l * (s + 1) : l + s - l * s
|
|
425
|
+
m1 = l * 2 - m2
|
|
426
|
+
@attrs[:red], @attrs[:green], @attrs[:blue] = [
|
|
427
|
+
hue_to_rgb(m1, m2, h + 1.0/3),
|
|
428
|
+
hue_to_rgb(m1, m2, h),
|
|
429
|
+
hue_to_rgb(m1, m2, h - 1.0/3)
|
|
430
|
+
].map {|c| (c * 0xff).round}
|
|
431
|
+
end
|
|
432
|
+
|
|
433
|
+
def hue_to_rgb(m1, m2, h)
|
|
434
|
+
h += 1 if h < 0
|
|
435
|
+
h -= 1 if h > 1
|
|
436
|
+
return m1 + (m2 - m1) * h * 6 if h * 6 < 1
|
|
437
|
+
return m2 if h * 2 < 1
|
|
438
|
+
return m1 + (m2 - m1) * (2.0/3 - h) * 6 if h * 3 < 2
|
|
439
|
+
return m1
|
|
440
|
+
end
|
|
441
|
+
|
|
442
|
+
def rgb_to_hsl!
|
|
443
|
+
return if @attrs[:hue] && @attrs[:saturation] && @attrs[:lightness]
|
|
444
|
+
r, g, b = [:red, :green, :blue].map {|k| @attrs[k] / 255.0}
|
|
445
|
+
|
|
446
|
+
# Algorithm from http://en.wikipedia.org/wiki/HSL_and_HSV#Conversion_from_RGB_to_HSL_or_HSV
|
|
447
|
+
max = [r, g, b].max
|
|
448
|
+
min = [r, g, b].min
|
|
449
|
+
d = max - min
|
|
450
|
+
|
|
451
|
+
h =
|
|
452
|
+
case max
|
|
453
|
+
when min; 0
|
|
454
|
+
when r; 60 * (g-b)/d
|
|
455
|
+
when g; 60 * (b-r)/d + 120
|
|
456
|
+
when b; 60 * (r-g)/d + 240
|
|
457
|
+
end
|
|
458
|
+
|
|
459
|
+
l = (max + min)/2.0
|
|
460
|
+
|
|
461
|
+
s =
|
|
462
|
+
if max == min
|
|
463
|
+
0
|
|
464
|
+
elsif l < 0.5
|
|
465
|
+
d/(2*l)
|
|
466
|
+
else
|
|
467
|
+
d/(2 - 2*l)
|
|
468
|
+
end
|
|
469
|
+
|
|
470
|
+
@attrs[:hue] = h % 360
|
|
471
|
+
@attrs[:saturation] = s * 100
|
|
472
|
+
@attrs[:lightness] = l * 100
|
|
473
|
+
end
|
|
474
|
+
end
|
|
475
|
+
end
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
module Sass
|
|
2
|
+
module Script
|
|
3
|
+
# This is a subclass of {Lexer} for use in parsing plain CSS properties.
|
|
4
|
+
#
|
|
5
|
+
# @see Sass::SCSS::CssParser
|
|
6
|
+
class CssLexer < Lexer
|
|
7
|
+
private
|
|
8
|
+
|
|
9
|
+
def token
|
|
10
|
+
important || super
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def string(re, *args)
|
|
14
|
+
if re == :uri
|
|
15
|
+
return unless uri = scan(URI)
|
|
16
|
+
return [:string, Script::String.new(uri)]
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
return unless scan(STRING)
|
|
20
|
+
[:string, Script::String.new((@scanner[1] || @scanner[2]).gsub(/\\(['"])/, '\1'), :string)]
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def important
|
|
24
|
+
return unless s = scan(IMPORTANT)
|
|
25
|
+
[:raw, s]
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
end
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
require 'sass/script'
|
|
2
|
+
require 'sass/script/css_lexer'
|
|
3
|
+
|
|
4
|
+
module Sass
|
|
5
|
+
module Script
|
|
6
|
+
# This is a subclass of {Parser} for use in parsing plain CSS properties.
|
|
7
|
+
#
|
|
8
|
+
# @see Sass::SCSS::CssParser
|
|
9
|
+
class CssParser < Parser
|
|
10
|
+
private
|
|
11
|
+
|
|
12
|
+
# @private
|
|
13
|
+
def lexer_class; CssLexer; end
|
|
14
|
+
|
|
15
|
+
# We need a production that only does /,
|
|
16
|
+
# since * and % aren't allowed in plain CSS
|
|
17
|
+
production :div, :unary_plus, :div
|
|
18
|
+
|
|
19
|
+
def string
|
|
20
|
+
return number unless tok = try_tok(:string)
|
|
21
|
+
return tok.value unless @lexer.peek && @lexer.peek.type == :begin_interpolation
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
# Short-circuit all the SassScript-only productions
|
|
25
|
+
alias_method :interpolation, :space
|
|
26
|
+
alias_method :or_expr, :div
|
|
27
|
+
alias_method :unary_div, :ident
|
|
28
|
+
alias_method :paren, :string
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
end
|
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
require 'sass/script/functions'
|
|
2
|
+
|
|
3
|
+
module Sass
|
|
4
|
+
module Script
|
|
5
|
+
# A SassScript parse node representing a function call.
|
|
6
|
+
#
|
|
7
|
+
# A function call either calls one of the functions in {Script::Functions},
|
|
8
|
+
# or if no function with the given name exists
|
|
9
|
+
# it returns a string representation of the function call.
|
|
10
|
+
class Funcall < Node
|
|
11
|
+
# The name of the function.
|
|
12
|
+
#
|
|
13
|
+
# @return [String]
|
|
14
|
+
attr_reader :name
|
|
15
|
+
|
|
16
|
+
# The arguments to the function.
|
|
17
|
+
#
|
|
18
|
+
# @return [Array<Script::Node>]
|
|
19
|
+
attr_reader :args
|
|
20
|
+
|
|
21
|
+
# The keyword arguments to the function.
|
|
22
|
+
#
|
|
23
|
+
# @return [{String => Script::Node}]
|
|
24
|
+
attr_reader :keywords
|
|
25
|
+
|
|
26
|
+
# @param name [String] See \{#name}
|
|
27
|
+
# @param args [Array<Script::Node>] See \{#args}
|
|
28
|
+
# @param keywords [{String => Script::Node}] See \{#keywords}
|
|
29
|
+
def initialize(name, args, keywords)
|
|
30
|
+
@name = name
|
|
31
|
+
@args = args
|
|
32
|
+
@keywords = keywords
|
|
33
|
+
super()
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
# @return [String] A string representation of the function call
|
|
37
|
+
def inspect
|
|
38
|
+
args = @args.map {|a| a.inspect}.join(', ')
|
|
39
|
+
keywords = Sass::Util.hash_to_a(@keywords).
|
|
40
|
+
map {|k, v| "$#{k}: #{v.inspect}"}.join(', ')
|
|
41
|
+
"#{name}(#{args}#{', ' unless args.empty? || keywords.empty?}#{keywords})"
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
# @see Node#to_sass
|
|
45
|
+
def to_sass(opts = {})
|
|
46
|
+
args = @args.map {|a| a.to_sass(opts)}.join(', ')
|
|
47
|
+
keywords = Sass::Util.hash_to_a(@keywords).
|
|
48
|
+
map {|k, v| "$#{dasherize(k, opts)}: #{v.to_sass(opts)}"}.join(', ')
|
|
49
|
+
"#{dasherize(name, opts)}(#{args}#{', ' unless args.empty? || keywords.empty?}#{keywords})"
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
# Returns the arguments to the function.
|
|
53
|
+
#
|
|
54
|
+
# @return [Array<Node>]
|
|
55
|
+
# @see Node#children
|
|
56
|
+
def children
|
|
57
|
+
@args + @keywords.values
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
# @see Node#deep_copy
|
|
61
|
+
def deep_copy
|
|
62
|
+
node = dup
|
|
63
|
+
node.instance_variable_set('@args', args.map {|a| a.deep_copy})
|
|
64
|
+
node.instance_variable_set('@keywords', Hash[keywords.map {|k, v| [k, v.deep_copy]}])
|
|
65
|
+
node
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
protected
|
|
69
|
+
|
|
70
|
+
# Evaluates the function call.
|
|
71
|
+
#
|
|
72
|
+
# @param environment [Sass::Environment] The environment in which to evaluate the SassScript
|
|
73
|
+
# @return [Literal] The SassScript object that is the value of the function call
|
|
74
|
+
# @raise [Sass::SyntaxError] if the function call raises an ArgumentError
|
|
75
|
+
def _perform(environment)
|
|
76
|
+
args = @args.map {|a| a.perform(environment)}
|
|
77
|
+
if fn = environment.function(@name)
|
|
78
|
+
keywords = Sass::Util.map_hash(@keywords) {|k, v| [k, v.perform(environment)]}
|
|
79
|
+
return perform_sass_fn(fn, args, keywords)
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
ruby_name = @name.tr('-', '_')
|
|
83
|
+
args = construct_ruby_args(ruby_name, args, environment)
|
|
84
|
+
|
|
85
|
+
unless Functions.callable?(ruby_name)
|
|
86
|
+
opts(to_literal(args))
|
|
87
|
+
else
|
|
88
|
+
opts(Functions::EvaluationContext.new(environment.options).send(ruby_name, *args))
|
|
89
|
+
end
|
|
90
|
+
rescue ArgumentError => e
|
|
91
|
+
# If this is a legitimate Ruby-raised argument error, re-raise it.
|
|
92
|
+
# Otherwise, it's an error in the user's stylesheet, so wrap it.
|
|
93
|
+
if e.message =~ /^wrong number of arguments \(\d+ for \d+\)/ &&
|
|
94
|
+
e.backtrace[0] !~ /:in `(block in )?#{ruby_name}'$/
|
|
95
|
+
raise e
|
|
96
|
+
end
|
|
97
|
+
raise Sass::SyntaxError.new("#{e.message} for `#{name}'")
|
|
98
|
+
end
|
|
99
|
+
|
|
100
|
+
# This method is factored out from `_perform` so that compass can override
|
|
101
|
+
# it with a cross-browser implementation for functions that require vendor prefixes
|
|
102
|
+
# in the generated css.
|
|
103
|
+
def to_literal(args)
|
|
104
|
+
Script::String.new("#{name}(#{args.join(', ')})")
|
|
105
|
+
end
|
|
106
|
+
|
|
107
|
+
private
|
|
108
|
+
|
|
109
|
+
def construct_ruby_args(name, args, environment)
|
|
110
|
+
unless signature = Functions.signature(name.to_sym, args.size, @keywords.size)
|
|
111
|
+
return args if keywords.empty?
|
|
112
|
+
raise Sass::SyntaxError.new("Function #{name} doesn't support keyword arguments")
|
|
113
|
+
end
|
|
114
|
+
keywords = Sass::Util.map_hash(@keywords) {|k, v| [k, v.perform(environment)]}
|
|
115
|
+
|
|
116
|
+
# If the user passes more non-keyword args than the function expects,
|
|
117
|
+
# but it does expect keyword args, Ruby's arg handling won't raise an error.
|
|
118
|
+
# Since we don't want to make functions think about this,
|
|
119
|
+
# we'll handle it for them here.
|
|
120
|
+
if signature.var_kwargs && !signature.var_args && args.size > signature.args.size
|
|
121
|
+
raise Sass::SyntaxError.new(
|
|
122
|
+
"#{args[signature.args.size].inspect} is not a keyword argument for `#{name}'")
|
|
123
|
+
elsif keywords.empty?
|
|
124
|
+
return args
|
|
125
|
+
end
|
|
126
|
+
|
|
127
|
+
args = args + signature.args[args.size..-1].map do |argname|
|
|
128
|
+
if keywords.has_key?(argname)
|
|
129
|
+
keywords.delete(argname)
|
|
130
|
+
else
|
|
131
|
+
raise Sass::SyntaxError.new("Function #{name} requires an argument named $#{argname}")
|
|
132
|
+
end
|
|
133
|
+
end
|
|
134
|
+
|
|
135
|
+
if keywords.size > 0
|
|
136
|
+
if signature.var_kwargs
|
|
137
|
+
args << keywords
|
|
138
|
+
else
|
|
139
|
+
raise Sass::SyntaxError.new("Function #{name} doesn't take an argument named $#{keywords.keys.sort.first}")
|
|
140
|
+
end
|
|
141
|
+
end
|
|
142
|
+
|
|
143
|
+
args
|
|
144
|
+
end
|
|
145
|
+
|
|
146
|
+
def perform_sass_fn(function, args, keywords)
|
|
147
|
+
# TODO: merge with mixin arg evaluation?
|
|
148
|
+
keywords.each do |name, value|
|
|
149
|
+
# TODO: Make this fast
|
|
150
|
+
unless function.args.find {|(var, default)| var.underscored_name == name}
|
|
151
|
+
raise Sass::SyntaxError.new("Function #{@name} doesn't have an argument named $#{name}")
|
|
152
|
+
end
|
|
153
|
+
end
|
|
154
|
+
|
|
155
|
+
if args.size > function.args.size
|
|
156
|
+
raise ArgumentError.new("Wrong number of arguments (#{args.size} for #{function.args.size})")
|
|
157
|
+
end
|
|
158
|
+
|
|
159
|
+
environment = function.args.zip(args).
|
|
160
|
+
inject(Sass::Environment.new(function.environment)) do |env, ((var, default), value)|
|
|
161
|
+
env.set_local_var(var.name,
|
|
162
|
+
value || keywords[var.underscored_name] || (default && default.perform(env)))
|
|
163
|
+
raise Sass::SyntaxError.new("Function #{@name} is missing parameter #{var.inspect}.") unless env.var(var.name)
|
|
164
|
+
env
|
|
165
|
+
end
|
|
166
|
+
|
|
167
|
+
val = catch :_sass_return do
|
|
168
|
+
function.tree.each {|c| Sass::Tree::Visitors::Perform.visit(c, environment)}
|
|
169
|
+
raise Sass::SyntaxError.new("Function #{@name} finished without @return")
|
|
170
|
+
end
|
|
171
|
+
val
|
|
172
|
+
end
|
|
173
|
+
end
|
|
174
|
+
end
|
|
175
|
+
end
|