classiccms 0.3.0 → 0.3.1
Sign up to get free protection for your applications and to get access to all the features.
- 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,800 @@
|
|
1
|
+
require 'erb'
|
2
|
+
require 'set'
|
3
|
+
require 'enumerator'
|
4
|
+
require 'stringio'
|
5
|
+
require 'rbconfig'
|
6
|
+
|
7
|
+
require 'sass/root'
|
8
|
+
require 'sass/util/subset_map'
|
9
|
+
|
10
|
+
module Sass
|
11
|
+
# A module containing various useful functions.
|
12
|
+
module Util
|
13
|
+
extend self
|
14
|
+
|
15
|
+
# An array of ints representing the Ruby version number.
|
16
|
+
# @api public
|
17
|
+
RUBY_VERSION = ::RUBY_VERSION.split(".").map {|s| s.to_i}
|
18
|
+
|
19
|
+
# The Ruby engine we're running under. Defaults to `"ruby"`
|
20
|
+
# if the top-level constant is undefined.
|
21
|
+
# @api public
|
22
|
+
RUBY_ENGINE = defined?(::RUBY_ENGINE) ? ::RUBY_ENGINE : "ruby"
|
23
|
+
|
24
|
+
# Returns the path of a file relative to the Sass root directory.
|
25
|
+
#
|
26
|
+
# @param file [String] The filename relative to the Sass root
|
27
|
+
# @return [String] The filename relative to the the working directory
|
28
|
+
def scope(file)
|
29
|
+
File.join(Sass::ROOT_DIR, file)
|
30
|
+
end
|
31
|
+
|
32
|
+
# Converts an array of `[key, value]` pairs to a hash.
|
33
|
+
#
|
34
|
+
# @example
|
35
|
+
# to_hash([[:foo, "bar"], [:baz, "bang"]])
|
36
|
+
# #=> {:foo => "bar", :baz => "bang"}
|
37
|
+
# @param arr [Array<(Object, Object)>] An array of pairs
|
38
|
+
# @return [Hash] A hash
|
39
|
+
def to_hash(arr)
|
40
|
+
Hash[arr.compact]
|
41
|
+
end
|
42
|
+
|
43
|
+
# Maps the keys in a hash according to a block.
|
44
|
+
#
|
45
|
+
# @example
|
46
|
+
# map_keys({:foo => "bar", :baz => "bang"}) {|k| k.to_s}
|
47
|
+
# #=> {"foo" => "bar", "baz" => "bang"}
|
48
|
+
# @param hash [Hash] The hash to map
|
49
|
+
# @yield [key] A block in which the keys are transformed
|
50
|
+
# @yieldparam key [Object] The key that should be mapped
|
51
|
+
# @yieldreturn [Object] The new value for the key
|
52
|
+
# @return [Hash] The mapped hash
|
53
|
+
# @see #map_vals
|
54
|
+
# @see #map_hash
|
55
|
+
def map_keys(hash)
|
56
|
+
to_hash(hash.map {|k, v| [yield(k), v]})
|
57
|
+
end
|
58
|
+
|
59
|
+
# Maps the values in a hash according to a block.
|
60
|
+
#
|
61
|
+
# @example
|
62
|
+
# map_values({:foo => "bar", :baz => "bang"}) {|v| v.to_sym}
|
63
|
+
# #=> {:foo => :bar, :baz => :bang}
|
64
|
+
# @param hash [Hash] The hash to map
|
65
|
+
# @yield [value] A block in which the values are transformed
|
66
|
+
# @yieldparam value [Object] The value that should be mapped
|
67
|
+
# @yieldreturn [Object] The new value for the value
|
68
|
+
# @return [Hash] The mapped hash
|
69
|
+
# @see #map_keys
|
70
|
+
# @see #map_hash
|
71
|
+
def map_vals(hash)
|
72
|
+
to_hash(hash.map {|k, v| [k, yield(v)]})
|
73
|
+
end
|
74
|
+
|
75
|
+
# Maps the key-value pairs of a hash according to a block.
|
76
|
+
#
|
77
|
+
# @example
|
78
|
+
# map_hash({:foo => "bar", :baz => "bang"}) {|k, v| [k.to_s, v.to_sym]}
|
79
|
+
# #=> {"foo" => :bar, "baz" => :bang}
|
80
|
+
# @param hash [Hash] The hash to map
|
81
|
+
# @yield [key, value] A block in which the key-value pairs are transformed
|
82
|
+
# @yieldparam [key] The hash key
|
83
|
+
# @yieldparam [value] The hash value
|
84
|
+
# @yieldreturn [(Object, Object)] The new value for the `[key, value]` pair
|
85
|
+
# @return [Hash] The mapped hash
|
86
|
+
# @see #map_keys
|
87
|
+
# @see #map_vals
|
88
|
+
def map_hash(hash)
|
89
|
+
# Using &block here completely hoses performance on 1.8.
|
90
|
+
to_hash(hash.map {|k, v| yield k, v})
|
91
|
+
end
|
92
|
+
|
93
|
+
# Computes the powerset of the given array.
|
94
|
+
# This is the set of all subsets of the array.
|
95
|
+
#
|
96
|
+
# @example
|
97
|
+
# powerset([1, 2, 3]) #=>
|
98
|
+
# Set[Set[], Set[1], Set[2], Set[3], Set[1, 2], Set[2, 3], Set[1, 3], Set[1, 2, 3]]
|
99
|
+
# @param arr [Enumerable]
|
100
|
+
# @return [Set<Set>] The subsets of `arr`
|
101
|
+
def powerset(arr)
|
102
|
+
arr.inject([Set.new].to_set) do |powerset, el|
|
103
|
+
new_powerset = Set.new
|
104
|
+
powerset.each do |subset|
|
105
|
+
new_powerset << subset
|
106
|
+
new_powerset << subset + [el]
|
107
|
+
end
|
108
|
+
new_powerset
|
109
|
+
end
|
110
|
+
end
|
111
|
+
|
112
|
+
# Restricts a number to falling within a given range.
|
113
|
+
# Returns the number if it falls within the range,
|
114
|
+
# or the closest value in the range if it doesn't.
|
115
|
+
#
|
116
|
+
# @param value [Numeric]
|
117
|
+
# @param range [Range<Numeric>]
|
118
|
+
# @return [Numeric]
|
119
|
+
def restrict(value, range)
|
120
|
+
[[value, range.first].max, range.last].min
|
121
|
+
end
|
122
|
+
|
123
|
+
# Concatenates all strings that are adjacent in an array,
|
124
|
+
# while leaving other elements as they are.
|
125
|
+
#
|
126
|
+
# @example
|
127
|
+
# merge_adjacent_strings([1, "foo", "bar", 2, "baz"])
|
128
|
+
# #=> [1, "foobar", 2, "baz"]
|
129
|
+
# @param arr [Array]
|
130
|
+
# @return [Array] The enumerable with strings merged
|
131
|
+
def merge_adjacent_strings(arr)
|
132
|
+
# Optimize for the common case of one element
|
133
|
+
return arr if arr.size < 2
|
134
|
+
arr.inject([]) do |a, e|
|
135
|
+
if e.is_a?(String)
|
136
|
+
if a.last.is_a?(String)
|
137
|
+
a.last << e
|
138
|
+
else
|
139
|
+
a << e.dup
|
140
|
+
end
|
141
|
+
else
|
142
|
+
a << e
|
143
|
+
end
|
144
|
+
a
|
145
|
+
end
|
146
|
+
end
|
147
|
+
|
148
|
+
# Intersperses a value in an enumerable, as would be done with `Array#join`
|
149
|
+
# but without concatenating the array together afterwards.
|
150
|
+
#
|
151
|
+
# @param enum [Enumerable]
|
152
|
+
# @param val
|
153
|
+
# @return [Array]
|
154
|
+
def intersperse(enum, val)
|
155
|
+
enum.inject([]) {|a, e| a << e << val}[0...-1]
|
156
|
+
end
|
157
|
+
|
158
|
+
# Substitutes a sub-array of one array with another sub-array.
|
159
|
+
#
|
160
|
+
# @param ary [Array] The array in which to make the substitution
|
161
|
+
# @param from [Array] The sequence of elements to replace with `to`
|
162
|
+
# @param to [Array] The sequence of elements to replace `from` with
|
163
|
+
def substitute(ary, from, to)
|
164
|
+
res = ary.dup
|
165
|
+
i = 0
|
166
|
+
while i < res.size
|
167
|
+
if res[i...i+from.size] == from
|
168
|
+
res[i...i+from.size] = to
|
169
|
+
end
|
170
|
+
i += 1
|
171
|
+
end
|
172
|
+
res
|
173
|
+
end
|
174
|
+
|
175
|
+
# Destructively strips whitespace from the beginning and end
|
176
|
+
# of the first and last elements, respectively,
|
177
|
+
# in the array (if those elements are strings).
|
178
|
+
#
|
179
|
+
# @param arr [Array]
|
180
|
+
# @return [Array] `arr`
|
181
|
+
def strip_string_array(arr)
|
182
|
+
arr.first.lstrip! if arr.first.is_a?(String)
|
183
|
+
arr.last.rstrip! if arr.last.is_a?(String)
|
184
|
+
arr
|
185
|
+
end
|
186
|
+
|
187
|
+
# Return an array of all possible paths through the given arrays.
|
188
|
+
#
|
189
|
+
# @param arrs [Array<Array>]
|
190
|
+
# @return [Array<Arrays>]
|
191
|
+
#
|
192
|
+
# @example
|
193
|
+
# paths([[1, 2], [3, 4], [5]]) #=>
|
194
|
+
# # [[1, 3, 5],
|
195
|
+
# # [2, 3, 5],
|
196
|
+
# # [1, 4, 5],
|
197
|
+
# # [2, 4, 5]]
|
198
|
+
def paths(arrs)
|
199
|
+
arrs.inject([[]]) do |paths, arr|
|
200
|
+
flatten(arr.map {|e| paths.map {|path| path + [e]}}, 1)
|
201
|
+
end
|
202
|
+
end
|
203
|
+
|
204
|
+
# Computes a single longest common subsequence for `x` and `y`.
|
205
|
+
# If there are more than one longest common subsequences,
|
206
|
+
# the one returned is that which starts first in `x`.
|
207
|
+
#
|
208
|
+
# @param x [Array]
|
209
|
+
# @param y [Array]
|
210
|
+
# @yield [a, b] An optional block to use in place of a check for equality
|
211
|
+
# between elements of `x` and `y`.
|
212
|
+
# @yieldreturn [Object, nil] If the two values register as equal,
|
213
|
+
# this will return the value to use in the LCS array.
|
214
|
+
# @return [Array] The LCS
|
215
|
+
def lcs(x, y, &block)
|
216
|
+
x = [nil, *x]
|
217
|
+
y = [nil, *y]
|
218
|
+
block ||= proc {|a, b| a == b && a}
|
219
|
+
lcs_backtrace(lcs_table(x, y, &block), x, y, x.size-1, y.size-1, &block)
|
220
|
+
end
|
221
|
+
|
222
|
+
# Converts a Hash to an Array. This is usually identical to `Hash#to_a`,
|
223
|
+
# with the following exceptions:
|
224
|
+
#
|
225
|
+
# * In Ruby 1.8, `Hash#to_a` is not deterministically ordered, but this is.
|
226
|
+
# * In Ruby 1.9 when running tests, this is ordered in the same way it would
|
227
|
+
# be under Ruby 1.8 (sorted key order rather than insertion order).
|
228
|
+
#
|
229
|
+
# @param hash [Hash]
|
230
|
+
# @return [Array]
|
231
|
+
def hash_to_a(hash)
|
232
|
+
return hash.to_a unless ruby1_8? || defined?(Test::Unit)
|
233
|
+
return hash.sort_by {|k, v| k}
|
234
|
+
end
|
235
|
+
|
236
|
+
# Asserts that `value` falls within `range` (inclusive), leaving
|
237
|
+
# room for slight floating-point errors.
|
238
|
+
#
|
239
|
+
# @param name [String] The name of the value. Used in the error message.
|
240
|
+
# @param range [Range] The allowed range of values.
|
241
|
+
# @param value [Numeric, Sass::Script::Number] The value to check.
|
242
|
+
# @param unit [String] The unit of the value. Used in error reporting.
|
243
|
+
# @return [Numeric] `value` adjusted to fall within range, if it
|
244
|
+
# was outside by a floating-point margin.
|
245
|
+
def check_range(name, range, value, unit='')
|
246
|
+
grace = (-0.00001..0.00001)
|
247
|
+
str = value.to_s
|
248
|
+
value = value.value if value.is_a?(Sass::Script::Number)
|
249
|
+
return value if range.include?(value)
|
250
|
+
return range.first if grace.include?(value - range.first)
|
251
|
+
return range.last if grace.include?(value - range.last)
|
252
|
+
raise ArgumentError.new(
|
253
|
+
"#{name} #{str} must be between #{range.first}#{unit} and #{range.last}#{unit}")
|
254
|
+
end
|
255
|
+
|
256
|
+
# Returns whether or not `seq1` is a subsequence of `seq2`. That is, whether
|
257
|
+
# or not `seq2` contains every element in `seq1` in the same order (and
|
258
|
+
# possibly more elements besides).
|
259
|
+
#
|
260
|
+
# @param seq1 [Array]
|
261
|
+
# @param seq2 [Array]
|
262
|
+
# @return [Boolean]
|
263
|
+
def subsequence?(seq1, seq2)
|
264
|
+
i = j = 0
|
265
|
+
loop do
|
266
|
+
return true if i == seq1.size
|
267
|
+
return false if j == seq2.size
|
268
|
+
i += 1 if seq1[i] == seq2[j]
|
269
|
+
j += 1
|
270
|
+
end
|
271
|
+
end
|
272
|
+
|
273
|
+
# Returns information about the caller of the previous method.
|
274
|
+
#
|
275
|
+
# @param entry [String] An entry in the `#caller` list, or a similarly formatted string
|
276
|
+
# @return [[String, Fixnum, (String, nil)]] An array containing the filename, line, and method name of the caller.
|
277
|
+
# The method name may be nil
|
278
|
+
def caller_info(entry = caller[1])
|
279
|
+
info = entry.scan(/^(.*?):(-?.*?)(?::.*`(.+)')?$/).first
|
280
|
+
info[1] = info[1].to_i
|
281
|
+
# This is added by Rubinius to designate a block, but we don't care about it.
|
282
|
+
info[2].sub!(/ \{\}\Z/, '') if info[2]
|
283
|
+
info
|
284
|
+
end
|
285
|
+
|
286
|
+
# Returns whether one version string represents a more recent version than another.
|
287
|
+
#
|
288
|
+
# @param v1 [String] A version string.
|
289
|
+
# @param v2 [String] Another version string.
|
290
|
+
# @return [Boolean]
|
291
|
+
def version_gt(v1, v2)
|
292
|
+
# Construct an array to make sure the shorter version is padded with nil
|
293
|
+
Array.new([v1.length, v2.length].max).zip(v1.split("."), v2.split(".")) do |_, p1, p2|
|
294
|
+
p1 ||= "0"
|
295
|
+
p2 ||= "0"
|
296
|
+
release1 = p1 =~ /^[0-9]+$/
|
297
|
+
release2 = p2 =~ /^[0-9]+$/
|
298
|
+
if release1 && release2
|
299
|
+
# Integer comparison if both are full releases
|
300
|
+
p1, p2 = p1.to_i, p2.to_i
|
301
|
+
next if p1 == p2
|
302
|
+
return p1 > p2
|
303
|
+
elsif !release1 && !release2
|
304
|
+
# String comparison if both are prereleases
|
305
|
+
next if p1 == p2
|
306
|
+
return p1 > p2
|
307
|
+
else
|
308
|
+
# If only one is a release, that one is newer
|
309
|
+
return release1
|
310
|
+
end
|
311
|
+
end
|
312
|
+
end
|
313
|
+
|
314
|
+
# Returns whether one version string represents the same or a more
|
315
|
+
# recent version than another.
|
316
|
+
#
|
317
|
+
# @param v1 [String] A version string.
|
318
|
+
# @param v2 [String] Another version string.
|
319
|
+
# @return [Boolean]
|
320
|
+
def version_geq(v1, v2)
|
321
|
+
version_gt(v1, v2) || !version_gt(v2, v1)
|
322
|
+
end
|
323
|
+
|
324
|
+
# Throws a NotImplementedError for an abstract method.
|
325
|
+
#
|
326
|
+
# @param obj [Object] `self`
|
327
|
+
# @raise [NotImplementedError]
|
328
|
+
def abstract(obj)
|
329
|
+
raise NotImplementedError.new("#{obj.class} must implement ##{caller_info[2]}")
|
330
|
+
end
|
331
|
+
|
332
|
+
# Silence all output to STDERR within a block.
|
333
|
+
#
|
334
|
+
# @yield A block in which no output will be printed to STDERR
|
335
|
+
def silence_warnings
|
336
|
+
the_real_stderr, $stderr = $stderr, StringIO.new
|
337
|
+
yield
|
338
|
+
ensure
|
339
|
+
$stderr = the_real_stderr
|
340
|
+
end
|
341
|
+
|
342
|
+
@@silence_warnings = false
|
343
|
+
# Silences all Sass warnings within a block.
|
344
|
+
#
|
345
|
+
# @yield A block in which no Sass warnings will be printed
|
346
|
+
def silence_sass_warnings
|
347
|
+
old_level, Sass.logger.log_level = Sass.logger.log_level, :error
|
348
|
+
yield
|
349
|
+
ensure
|
350
|
+
Sass.logger.log_level = old_level
|
351
|
+
end
|
352
|
+
|
353
|
+
# The same as `Kernel#warn`, but is silenced by \{#silence\_sass\_warnings}.
|
354
|
+
#
|
355
|
+
# @param msg [String]
|
356
|
+
def sass_warn(msg)
|
357
|
+
Sass.logger.warn(msg)
|
358
|
+
end
|
359
|
+
|
360
|
+
## Cross Rails Version Compatibility
|
361
|
+
|
362
|
+
# Returns the root of the Rails application,
|
363
|
+
# if this is running in a Rails context.
|
364
|
+
# Returns `nil` if no such root is defined.
|
365
|
+
#
|
366
|
+
# @return [String, nil]
|
367
|
+
def rails_root
|
368
|
+
if defined?(::Rails.root)
|
369
|
+
return ::Rails.root.to_s if ::Rails.root
|
370
|
+
raise "ERROR: Rails.root is nil!"
|
371
|
+
end
|
372
|
+
return RAILS_ROOT.to_s if defined?(RAILS_ROOT)
|
373
|
+
return nil
|
374
|
+
end
|
375
|
+
|
376
|
+
# Returns the environment of the Rails application,
|
377
|
+
# if this is running in a Rails context.
|
378
|
+
# Returns `nil` if no such environment is defined.
|
379
|
+
#
|
380
|
+
# @return [String, nil]
|
381
|
+
def rails_env
|
382
|
+
return ::Rails.env.to_s if defined?(::Rails.env)
|
383
|
+
return RAILS_ENV.to_s if defined?(RAILS_ENV)
|
384
|
+
return nil
|
385
|
+
end
|
386
|
+
|
387
|
+
# Returns whether this environment is using ActionPack
|
388
|
+
# version 3.0.0 or greater.
|
389
|
+
#
|
390
|
+
# @return [Boolean]
|
391
|
+
def ap_geq_3?
|
392
|
+
ap_geq?("3.0.0.beta1")
|
393
|
+
end
|
394
|
+
|
395
|
+
# Returns whether this environment is using ActionPack
|
396
|
+
# of a version greater than or equal to that specified.
|
397
|
+
#
|
398
|
+
# @param version [String] The string version number to check against.
|
399
|
+
# Should be greater than or equal to Rails 3,
|
400
|
+
# because otherwise ActionPack::VERSION isn't autoloaded
|
401
|
+
# @return [Boolean]
|
402
|
+
def ap_geq?(version)
|
403
|
+
# The ActionPack module is always loaded automatically in Rails >= 3
|
404
|
+
return false unless defined?(ActionPack) && defined?(ActionPack::VERSION) &&
|
405
|
+
defined?(ActionPack::VERSION::STRING)
|
406
|
+
|
407
|
+
version_geq(ActionPack::VERSION::STRING, version)
|
408
|
+
end
|
409
|
+
|
410
|
+
# Returns an ActionView::Template* class.
|
411
|
+
# In pre-3.0 versions of Rails, most of these classes
|
412
|
+
# were of the form `ActionView::TemplateFoo`,
|
413
|
+
# while afterwards they were of the form `ActionView;:Template::Foo`.
|
414
|
+
#
|
415
|
+
# @param name [#to_s] The name of the class to get.
|
416
|
+
# For example, `:Error` will return `ActionView::TemplateError`
|
417
|
+
# or `ActionView::Template::Error`.
|
418
|
+
def av_template_class(name)
|
419
|
+
return ActionView.const_get("Template#{name}") if ActionView.const_defined?("Template#{name}")
|
420
|
+
return ActionView::Template.const_get(name.to_s)
|
421
|
+
end
|
422
|
+
|
423
|
+
## Cross-OS Compatibility
|
424
|
+
|
425
|
+
# Whether or not this is running on Windows.
|
426
|
+
#
|
427
|
+
# @return [Boolean]
|
428
|
+
def windows?
|
429
|
+
RbConfig::CONFIG['host_os'] =~ /mswin|windows|mingw/i
|
430
|
+
end
|
431
|
+
|
432
|
+
# Whether or not this is running on IronRuby.
|
433
|
+
#
|
434
|
+
# @return [Boolean]
|
435
|
+
def ironruby?
|
436
|
+
RUBY_ENGINE == "ironruby"
|
437
|
+
end
|
438
|
+
|
439
|
+
# Like `Dir.glob`, but works with backslash-separated paths on Windows.
|
440
|
+
#
|
441
|
+
# @param path [String]
|
442
|
+
def glob(path)
|
443
|
+
path = path.gsub('\\', '/') if windows?
|
444
|
+
Dir.glob(path)
|
445
|
+
end
|
446
|
+
|
447
|
+
## Cross-Ruby-Version Compatibility
|
448
|
+
|
449
|
+
# Whether or not this is running under Ruby 1.8 or lower.
|
450
|
+
#
|
451
|
+
# Note that IronRuby counts as Ruby 1.8,
|
452
|
+
# because it doesn't support the Ruby 1.9 encoding API.
|
453
|
+
#
|
454
|
+
# @return [Boolean]
|
455
|
+
def ruby1_8?
|
456
|
+
# IronRuby says its version is 1.9, but doesn't support any of the encoding APIs.
|
457
|
+
# We have to fall back to 1.8 behavior.
|
458
|
+
ironruby? || (Sass::Util::RUBY_VERSION[0] == 1 && Sass::Util::RUBY_VERSION[1] < 9)
|
459
|
+
end
|
460
|
+
|
461
|
+
# Whether or not this is running under Ruby 1.8.6 or lower.
|
462
|
+
# Note that lower versions are not officially supported.
|
463
|
+
#
|
464
|
+
# @return [Boolean]
|
465
|
+
def ruby1_8_6?
|
466
|
+
ruby1_8? && Sass::Util::RUBY_VERSION[2] < 7
|
467
|
+
end
|
468
|
+
|
469
|
+
# Checks that the encoding of a string is valid in Ruby 1.9
|
470
|
+
# and cleans up potential encoding gotchas like the UTF-8 BOM.
|
471
|
+
# If it's not, yields an error string describing the invalid character
|
472
|
+
# and the line on which it occurrs.
|
473
|
+
#
|
474
|
+
# @param str [String] The string of which to check the encoding
|
475
|
+
# @yield [msg] A block in which an encoding error can be raised.
|
476
|
+
# Only yields if there is an encoding error
|
477
|
+
# @yieldparam msg [String] The error message to be raised
|
478
|
+
# @return [String] `str`, potentially with encoding gotchas like BOMs removed
|
479
|
+
def check_encoding(str)
|
480
|
+
if ruby1_8?
|
481
|
+
return str.gsub(/\A\xEF\xBB\xBF/, '') # Get rid of the UTF-8 BOM
|
482
|
+
elsif str.valid_encoding?
|
483
|
+
# Get rid of the Unicode BOM if possible
|
484
|
+
if str.encoding.name =~ /^UTF-(8|16|32)(BE|LE)?$/
|
485
|
+
return str.gsub(Regexp.new("\\A\uFEFF".encode(str.encoding.name)), '')
|
486
|
+
else
|
487
|
+
return str
|
488
|
+
end
|
489
|
+
end
|
490
|
+
|
491
|
+
encoding = str.encoding
|
492
|
+
newlines = Regexp.new("\r\n|\r|\n".encode(encoding).force_encoding("binary"))
|
493
|
+
str.force_encoding("binary").split(newlines).each_with_index do |line, i|
|
494
|
+
begin
|
495
|
+
line.encode(encoding)
|
496
|
+
rescue Encoding::UndefinedConversionError => e
|
497
|
+
yield <<MSG.rstrip, i + 1
|
498
|
+
Invalid #{encoding.name} character #{e.error_char.dump}
|
499
|
+
MSG
|
500
|
+
end
|
501
|
+
end
|
502
|
+
return str
|
503
|
+
end
|
504
|
+
|
505
|
+
# Like {\#check\_encoding}, but also checks for a `@charset` declaration
|
506
|
+
# at the beginning of the file and uses that encoding if it exists.
|
507
|
+
#
|
508
|
+
# The Sass encoding rules are simple.
|
509
|
+
# If a `@charset` declaration exists,
|
510
|
+
# we assume that that's the original encoding of the document.
|
511
|
+
# Otherwise, we use whatever encoding Ruby has.
|
512
|
+
# Then we convert that to UTF-8 to process internally.
|
513
|
+
# The UTF-8 end result is what's returned by this method.
|
514
|
+
#
|
515
|
+
# @param str [String] The string of which to check the encoding
|
516
|
+
# @yield [msg] A block in which an encoding error can be raised.
|
517
|
+
# Only yields if there is an encoding error
|
518
|
+
# @yieldparam msg [String] The error message to be raised
|
519
|
+
# @return [(String, Encoding)] The original string encoded as UTF-8,
|
520
|
+
# and the source encoding of the string (or `nil` under Ruby 1.8)
|
521
|
+
# @raise [Encoding::UndefinedConversionError] if the source encoding
|
522
|
+
# cannot be converted to UTF-8
|
523
|
+
# @raise [ArgumentError] if the document uses an unknown encoding with `@charset`
|
524
|
+
def check_sass_encoding(str, &block)
|
525
|
+
return check_encoding(str, &block), nil if ruby1_8?
|
526
|
+
# We allow any printable ASCII characters but double quotes in the charset decl
|
527
|
+
bin = str.dup.force_encoding("BINARY")
|
528
|
+
encoding = Sass::Util::ENCODINGS_TO_CHECK.find do |enc|
|
529
|
+
re = Sass::Util::CHARSET_REGEXPS[enc]
|
530
|
+
re && bin =~ re
|
531
|
+
end
|
532
|
+
charset, bom = $1, $2
|
533
|
+
if charset
|
534
|
+
charset = charset.force_encoding(encoding).encode("UTF-8")
|
535
|
+
if endianness = encoding[/[BL]E$/]
|
536
|
+
begin
|
537
|
+
Encoding.find(charset + endianness)
|
538
|
+
charset << endianness
|
539
|
+
rescue ArgumentError # Encoding charset + endianness doesn't exist
|
540
|
+
end
|
541
|
+
end
|
542
|
+
str.force_encoding(charset)
|
543
|
+
elsif bom
|
544
|
+
str.force_encoding(encoding)
|
545
|
+
end
|
546
|
+
|
547
|
+
str = check_encoding(str, &block)
|
548
|
+
return str.encode("UTF-8"), str.encoding
|
549
|
+
end
|
550
|
+
|
551
|
+
unless ruby1_8?
|
552
|
+
# @private
|
553
|
+
def _enc(string, encoding)
|
554
|
+
string.encode(encoding).force_encoding("BINARY")
|
555
|
+
end
|
556
|
+
|
557
|
+
# We could automatically add in any non-ASCII-compatible encodings here,
|
558
|
+
# but there's not really a good way to do that
|
559
|
+
# without manually checking that each encoding
|
560
|
+
# encodes all ASCII characters properly,
|
561
|
+
# which takes long enough to affect the startup time of the CLI.
|
562
|
+
ENCODINGS_TO_CHECK = %w[UTF-8 UTF-16BE UTF-16LE UTF-32BE UTF-32LE]
|
563
|
+
|
564
|
+
CHARSET_REGEXPS = Hash.new do |h, e|
|
565
|
+
h[e] =
|
566
|
+
begin
|
567
|
+
# /\A(?:\uFEFF)?@charset "(.*?)"|\A(\uFEFF)/
|
568
|
+
Regexp.new(/\A(?:#{_enc("\uFEFF", e)})?#{
|
569
|
+
_enc('@charset "', e)}(.*?)#{_enc('"', e)}|\A(#{
|
570
|
+
_enc("\uFEFF", e)})/)
|
571
|
+
rescue Encoding::ConverterNotFound => _
|
572
|
+
nil # JRuby on Java 5 doesn't support UTF-32
|
573
|
+
rescue
|
574
|
+
# /\A@charset "(.*?)"/
|
575
|
+
Regexp.new(/\A#{_enc('@charset "', e)}(.*?)#{_enc('"', e)}/)
|
576
|
+
end
|
577
|
+
end
|
578
|
+
end
|
579
|
+
|
580
|
+
# Checks to see if a class has a given method.
|
581
|
+
# For example:
|
582
|
+
#
|
583
|
+
# Sass::Util.has?(:public_instance_method, String, :gsub) #=> true
|
584
|
+
#
|
585
|
+
# Method collections like `Class#instance_methods`
|
586
|
+
# return strings in Ruby 1.8 and symbols in Ruby 1.9 and on,
|
587
|
+
# so this handles checking for them in a compatible way.
|
588
|
+
#
|
589
|
+
# @param attr [#to_s] The (singular) name of the method-collection method
|
590
|
+
# (e.g. `:instance_methods`, `:private_methods`)
|
591
|
+
# @param klass [Module] The class to check the methods of which to check
|
592
|
+
# @param method [String, Symbol] The name of the method do check for
|
593
|
+
# @return [Boolean] Whether or not the given collection has the given method
|
594
|
+
def has?(attr, klass, method)
|
595
|
+
klass.send("#{attr}s").include?(ruby1_8? ? method.to_s : method.to_sym)
|
596
|
+
end
|
597
|
+
|
598
|
+
# A version of `Enumerable#enum_with_index` that works in Ruby 1.8 and 1.9.
|
599
|
+
#
|
600
|
+
# @param enum [Enumerable] The enumerable to get the enumerator for
|
601
|
+
# @return [Enumerator] The with-index enumerator
|
602
|
+
def enum_with_index(enum)
|
603
|
+
ruby1_8? ? enum.enum_with_index : enum.each_with_index
|
604
|
+
end
|
605
|
+
|
606
|
+
# A version of `Enumerable#enum_cons` that works in Ruby 1.8 and 1.9.
|
607
|
+
#
|
608
|
+
# @param enum [Enumerable] The enumerable to get the enumerator for
|
609
|
+
# @param n [Fixnum] The size of each cons
|
610
|
+
# @return [Enumerator] The consed enumerator
|
611
|
+
def enum_cons(enum, n)
|
612
|
+
ruby1_8? ? enum.enum_cons(n) : enum.each_cons(n)
|
613
|
+
end
|
614
|
+
|
615
|
+
# A version of `Enumerable#enum_slice` that works in Ruby 1.8 and 1.9.
|
616
|
+
#
|
617
|
+
# @param enum [Enumerable] The enumerable to get the enumerator for
|
618
|
+
# @param n [Fixnum] The size of each slice
|
619
|
+
# @return [Enumerator] The consed enumerator
|
620
|
+
def enum_slice(enum, n)
|
621
|
+
ruby1_8? ? enum.enum_slice(n) : enum.each_slice(n)
|
622
|
+
end
|
623
|
+
|
624
|
+
# Destructively removes all elements from an array that match a block, and
|
625
|
+
# returns the removed elements.
|
626
|
+
#
|
627
|
+
# @param array [Array] The array from which to remove elements.
|
628
|
+
# @yield [el] Called for each element.
|
629
|
+
# @yieldparam el [*] The element to test.
|
630
|
+
# @yieldreturn [Boolean] Whether or not to extract the element.
|
631
|
+
# @return [Array] The extracted elements.
|
632
|
+
def extract!(array)
|
633
|
+
out = []
|
634
|
+
array.reject! do |e|
|
635
|
+
next false unless yield e
|
636
|
+
out << e
|
637
|
+
true
|
638
|
+
end
|
639
|
+
out
|
640
|
+
end
|
641
|
+
|
642
|
+
# Returns the ASCII code of the given character.
|
643
|
+
#
|
644
|
+
# @param c [String] All characters but the first are ignored.
|
645
|
+
# @return [Fixnum] The ASCII code of `c`.
|
646
|
+
def ord(c)
|
647
|
+
ruby1_8? ? c[0] : c.ord
|
648
|
+
end
|
649
|
+
|
650
|
+
# Flattens the first `n` nested arrays in a cross-version manner.
|
651
|
+
#
|
652
|
+
# @param arr [Array] The array to flatten
|
653
|
+
# @param n [Fixnum] The number of levels to flatten
|
654
|
+
# @return [Array] The flattened array
|
655
|
+
def flatten(arr, n)
|
656
|
+
return arr.flatten(n) unless ruby1_8_6?
|
657
|
+
return arr if n == 0
|
658
|
+
arr.inject([]) {|res, e| e.is_a?(Array) ? res.concat(flatten(e, n - 1)) : res << e}
|
659
|
+
end
|
660
|
+
|
661
|
+
# Returns the hash code for a set in a cross-version manner.
|
662
|
+
# Aggravatingly, this is order-dependent in Ruby 1.8.6.
|
663
|
+
#
|
664
|
+
# @param set [Set]
|
665
|
+
# @return [Fixnum] The order-independent hashcode of `set`
|
666
|
+
def set_hash(set)
|
667
|
+
return set.hash unless ruby1_8_6?
|
668
|
+
set.map {|e| e.hash}.uniq.sort.hash
|
669
|
+
end
|
670
|
+
|
671
|
+
# Tests the hash-equality of two sets in a cross-version manner.
|
672
|
+
# Aggravatingly, this is order-dependent in Ruby 1.8.6.
|
673
|
+
#
|
674
|
+
# @param set1 [Set]
|
675
|
+
# @param set2 [Set]
|
676
|
+
# @return [Boolean] Whether or not the sets are hashcode equal
|
677
|
+
def set_eql?(set1, set2)
|
678
|
+
return set1.eql?(set2) unless ruby1_8_6?
|
679
|
+
set1.to_a.uniq.sort_by {|e| e.hash}.eql?(set2.to_a.uniq.sort_by {|e| e.hash})
|
680
|
+
end
|
681
|
+
|
682
|
+
# Like `Object#inspect`, but preserves non-ASCII characters rather than escaping them under Ruby 1.9.2.
|
683
|
+
# This is necessary so that the precompiled Haml template can be `#encode`d into `@options[:encoding]`
|
684
|
+
# before being evaluated.
|
685
|
+
#
|
686
|
+
# @param obj {Object}
|
687
|
+
# @return {String}
|
688
|
+
def inspect_obj(obj)
|
689
|
+
return obj.inspect unless version_geq(::RUBY_VERSION, "1.9.2")
|
690
|
+
return ':' + inspect_obj(obj.to_s) if obj.is_a?(Symbol)
|
691
|
+
return obj.inspect unless obj.is_a?(String)
|
692
|
+
'"' + obj.gsub(/[\x00-\x7F]+/) {|s| s.inspect[1...-1]} + '"'
|
693
|
+
end
|
694
|
+
|
695
|
+
# Extracts the non-string vlaues from an array containing both strings and non-strings.
|
696
|
+
# These values are replaced with escape sequences.
|
697
|
+
# This can be undone using \{#inject\_values}.
|
698
|
+
#
|
699
|
+
# This is useful e.g. when we want to do string manipulation
|
700
|
+
# on an interpolated string.
|
701
|
+
#
|
702
|
+
# The precise format of the resulting string is not guaranteed.
|
703
|
+
# However, it is guaranteed that newlines and whitespace won't be affected.
|
704
|
+
#
|
705
|
+
# @param arr [Array] The array from which values are extracted.
|
706
|
+
# @return [(String, Array)] The resulting string, and an array of extracted values.
|
707
|
+
def extract_values(arr)
|
708
|
+
values = []
|
709
|
+
return arr.map do |e|
|
710
|
+
next e.gsub('{', '{{') if e.is_a?(String)
|
711
|
+
values << e
|
712
|
+
next "{#{values.count - 1}}"
|
713
|
+
end.join, values
|
714
|
+
end
|
715
|
+
|
716
|
+
# Undoes \{#extract\_values} by transforming a string with escape sequences
|
717
|
+
# into an array of strings and non-string values.
|
718
|
+
#
|
719
|
+
# @param str [String] The string with escape sequences.
|
720
|
+
# @param values [Array] The array of values to inject.
|
721
|
+
# @return [Array] The array of strings and values.
|
722
|
+
def inject_values(str, values)
|
723
|
+
return [str.gsub('{{', '{')] if values.empty?
|
724
|
+
# Add an extra { so that we process the tail end of the string
|
725
|
+
result = (str + '{{').scan(/(.*?)(?:(\{\{)|\{(\d+)\})/m).map do |(pre, esc, n)|
|
726
|
+
[pre, esc ? '{' : '', n ? values[n.to_i] : '']
|
727
|
+
end.flatten(1)
|
728
|
+
result[-2] = '' # Get rid of the extra {
|
729
|
+
merge_adjacent_strings(result).reject {|s| s == ''}
|
730
|
+
end
|
731
|
+
|
732
|
+
# Allows modifications to be performed on the string form
|
733
|
+
# of an array containing both strings and non-strings.
|
734
|
+
#
|
735
|
+
# @param arr [Array] The array from which values are extracted.
|
736
|
+
# @yield [str] A block in which string manipulation can be done to the array.
|
737
|
+
# @yieldparam str [String] The string form of `arr`.
|
738
|
+
# @yieldreturn [String] The modified string.
|
739
|
+
# @return [Array] The modified, interpolated array.
|
740
|
+
def with_extracted_values(arr)
|
741
|
+
str, vals = extract_values(arr)
|
742
|
+
str = yield str
|
743
|
+
inject_values(str, vals)
|
744
|
+
end
|
745
|
+
|
746
|
+
## Static Method Stuff
|
747
|
+
|
748
|
+
# The context in which the ERB for \{#def\_static\_method} will be run.
|
749
|
+
class StaticConditionalContext
|
750
|
+
# @param set [#include?] The set of variables that are defined for this context.
|
751
|
+
def initialize(set)
|
752
|
+
@set = set
|
753
|
+
end
|
754
|
+
|
755
|
+
# Checks whether or not a variable is defined for this context.
|
756
|
+
#
|
757
|
+
# @param name [Symbol] The name of the variable
|
758
|
+
# @return [Boolean]
|
759
|
+
def method_missing(name, *args, &block)
|
760
|
+
super unless args.empty? && block.nil?
|
761
|
+
@set.include?(name)
|
762
|
+
end
|
763
|
+
end
|
764
|
+
|
765
|
+
private
|
766
|
+
|
767
|
+
# Calculates the memoization table for the Least Common Subsequence algorithm.
|
768
|
+
# Algorithm from [Wikipedia](http://en.wikipedia.org/wiki/Longest_common_subsequence_problem#Computing_the_length_of_the_LCS)
|
769
|
+
def lcs_table(x, y)
|
770
|
+
c = Array.new(x.size) {[]}
|
771
|
+
x.size.times {|i| c[i][0] = 0}
|
772
|
+
y.size.times {|j| c[0][j] = 0}
|
773
|
+
(1...x.size).each do |i|
|
774
|
+
(1...y.size).each do |j|
|
775
|
+
c[i][j] =
|
776
|
+
if yield x[i], y[j]
|
777
|
+
c[i-1][j-1] + 1
|
778
|
+
else
|
779
|
+
[c[i][j-1], c[i-1][j]].max
|
780
|
+
end
|
781
|
+
end
|
782
|
+
end
|
783
|
+
return c
|
784
|
+
end
|
785
|
+
|
786
|
+
# Computes a single longest common subsequence for arrays x and y.
|
787
|
+
# Algorithm from [Wikipedia](http://en.wikipedia.org/wiki/Longest_common_subsequence_problem#Reading_out_an_LCS)
|
788
|
+
def lcs_backtrace(c, x, y, i, j, &block)
|
789
|
+
return [] if i == 0 || j == 0
|
790
|
+
if v = yield(x[i], y[j])
|
791
|
+
return lcs_backtrace(c, x, y, i-1, j-1, &block) << v
|
792
|
+
end
|
793
|
+
|
794
|
+
return lcs_backtrace(c, x, y, i, j-1, &block) if c[i][j-1] > c[i-1][j]
|
795
|
+
return lcs_backtrace(c, x, y, i-1, j, &block)
|
796
|
+
end
|
797
|
+
end
|
798
|
+
end
|
799
|
+
|
800
|
+
require 'sass/util/multibyte_string_scanner'
|