less 2.0.0 → 2.6.0
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.
- checksums.yaml +7 -0
- data/.gitignore +2 -0
- data/.gitmodules +1 -4
- data/.travis.yml +12 -0
- data/Changelog.md +17 -0
- data/Gemfile +10 -2
- data/README.md +30 -14
- data/Rakefile +2 -0
- data/bin/lessc +101 -1
- data/less.gemspec +5 -8
- data/lib/less/defaults.rb +13 -0
- data/lib/less/errors.rb +44 -0
- data/lib/less/java_script/rhino_context.rb +100 -0
- data/lib/less/java_script/v8_context.rb +105 -0
- data/lib/less/java_script.rb +34 -0
- data/lib/less/js/.gitattributes +10 -0
- data/lib/less/js/.gitignore +24 -0
- data/lib/less/js/.jshintrc +11 -0
- data/lib/less/js/.npmignore +1 -0
- data/lib/less/js/.travis.yml +8 -0
- data/lib/less/js/CHANGELOG.md +299 -0
- data/lib/less/js/CONTRIBUTING.md +50 -0
- data/lib/less/js/Gruntfile.js +298 -0
- data/lib/less/js/README.md +43 -12
- data/lib/less/js/benchmark/benchmark.less +205 -205
- data/lib/less/js/benchmark/less-benchmark.js +11 -14
- data/lib/less/js/bin/lessc +350 -43
- data/lib/less/js/bower.json +18 -0
- data/lib/less/js/build/README.md +51 -0
- data/lib/less/js/build/amd.js +6 -0
- data/lib/less/js/build/browser-header.js +4 -0
- data/lib/less/js/build/build.yml +162 -0
- data/lib/less/js/build/require-rhino.js +12 -0
- data/lib/less/js/build/rhino-header.js +4 -0
- data/lib/less/js/build/rhino-modules.js +131 -0
- data/lib/less/js/build/tasks/.gitkeep +1 -0
- data/lib/less/js/build.gradle +347 -0
- data/lib/less/js/dist/{less-1.0.44.js → less-1.1.4.js} +159 -45
- data/lib/less/js/dist/less-1.1.4.min.js +16 -0
- data/lib/less/js/dist/less-1.1.5.js +2805 -0
- data/lib/less/js/dist/less-1.1.5.min.js +9 -0
- data/lib/less/js/dist/less-1.1.6.js +3004 -0
- data/lib/less/js/dist/less-1.1.6.min.js +9 -0
- data/lib/less/js/dist/less-1.2.0.js +3293 -0
- data/lib/less/js/dist/less-1.2.0.min.js +9 -0
- data/lib/less/js/dist/less-1.2.1.js +3318 -0
- data/lib/less/js/dist/less-1.2.1.min.js +9 -0
- data/lib/less/js/dist/less-1.2.2.js +3337 -0
- data/lib/less/js/dist/less-1.2.2.min.js +9 -0
- data/lib/less/js/dist/less-1.3.0.js +3478 -0
- data/lib/less/js/dist/less-1.3.0.min.js +9 -0
- data/lib/less/js/dist/less-1.3.1.js +4011 -0
- data/lib/less/js/dist/less-1.3.1.min.js +9 -0
- data/lib/less/js/dist/less-1.3.2.js +4401 -0
- data/lib/less/js/dist/less-1.3.2.min.js +9 -0
- data/lib/less/js/dist/less-1.3.3.js +4413 -0
- data/lib/less/js/dist/less-1.3.3.min.js +9 -0
- data/lib/less/js/dist/less-1.4.0-beta.js +5830 -0
- data/lib/less/js/dist/less-1.4.0-beta.min.js +11 -0
- data/lib/less/js/dist/less-1.4.0.js +5830 -0
- data/lib/less/js/dist/less-1.4.0.min.js +11 -0
- data/lib/less/js/dist/less-1.4.1.js +5837 -0
- data/lib/less/js/dist/less-1.4.1.min.js +11 -0
- data/lib/less/js/dist/less-1.4.2.js +5837 -0
- data/lib/less/js/dist/less-1.4.2.min.js +11 -0
- data/lib/less/js/dist/less-1.5.0.js +6914 -0
- data/lib/less/js/dist/less-1.5.0.min.js +13 -0
- data/lib/less/js/dist/less-1.5.1.js +6941 -0
- data/lib/less/js/dist/less-1.5.1.min.js +13 -0
- data/lib/less/js/dist/less-1.6.0.js +7485 -0
- data/lib/less/js/dist/less-1.6.0.min.js +16 -0
- data/lib/less/js/dist/less-1.6.1.js +7513 -0
- data/lib/less/js/dist/less-1.6.1.min.js +16 -0
- data/lib/less/js/dist/less-1.6.2.js +7624 -0
- data/lib/less/js/dist/less-1.6.2.min.js +16 -0
- data/lib/less/js/dist/less-1.6.3.js +7627 -0
- data/lib/less/js/dist/less-1.6.3.min.js +16 -0
- data/lib/less/js/dist/less-1.7.0.js +7921 -0
- data/lib/less/js/dist/less-1.7.0.min.js +16 -0
- data/lib/less/js/dist/less-rhino-1.1.3.js +2460 -0
- data/lib/less/js/dist/less-rhino-1.1.5.js +2481 -0
- data/lib/less/js/dist/less-rhino-1.3.1.js +3725 -0
- data/lib/less/js/dist/less-rhino-1.3.2.js +3990 -0
- data/lib/less/js/dist/less-rhino-1.3.3.js +4002 -0
- data/lib/less/js/dist/less-rhino-1.4.0.js +4273 -0
- data/lib/less/js/dist/less-rhino-1.5.1.js +6831 -0
- data/lib/less/js/dist/less-rhino-1.6.2.js +9017 -0
- data/lib/less/js/dist/less-rhino-1.6.3.js +9020 -0
- data/lib/less/js/dist/less-rhino-1.7.0.js +9301 -0
- data/lib/less/js/dist/lessc-rhino-1.6.2.js +449 -0
- data/lib/less/js/dist/lessc-rhino-1.6.3.js +449 -0
- data/lib/less/js/dist/lessc-rhino-1.7.0.js +449 -0
- data/lib/less/js/gradle/wrapper/gradle-wrapper.jar +0 -0
- data/lib/less/js/gradle/wrapper/gradle-wrapper.properties +6 -0
- data/lib/less/js/gradlew +164 -0
- data/lib/less/js/gradlew.bat +90 -0
- data/lib/less/js/lib/less/browser.js +556 -248
- data/lib/less/js/lib/less/colors.js +151 -0
- data/lib/less/js/lib/less/encoder.js +4 -0
- data/lib/less/js/lib/less/env.js +136 -0
- data/lib/less/js/lib/less/extend-visitor.js +416 -0
- data/lib/less/js/lib/less/functions.js +622 -28
- data/lib/less/js/lib/less/import-visitor.js +142 -0
- data/lib/less/js/lib/less/index.js +198 -83
- data/lib/less/js/lib/less/join-selector-visitor.js +44 -0
- data/lib/less/js/lib/less/lessc_helper.js +82 -0
- data/lib/less/js/lib/less/parser.js +1419 -449
- data/lib/less/js/lib/less/rhino.js +448 -0
- data/lib/less/js/lib/less/source-map-output.js +141 -0
- data/lib/less/js/lib/less/to-css-visitor.js +240 -0
- data/lib/less/js/lib/less/tree/alpha.js +18 -6
- data/lib/less/js/lib/less/tree/anonymous.js +26 -5
- data/lib/less/js/lib/less/tree/assignment.js +29 -0
- data/lib/less/js/lib/less/tree/call.js +40 -14
- data/lib/less/js/lib/less/tree/color.js +122 -31
- data/lib/less/js/lib/less/tree/comment.js +19 -5
- data/lib/less/js/lib/less/tree/condition.js +49 -0
- data/lib/less/js/lib/less/tree/detached-ruleset.js +20 -0
- data/lib/less/js/lib/less/tree/dimension.js +304 -14
- data/lib/less/js/lib/less/tree/directive.js +57 -21
- data/lib/less/js/lib/less/tree/element.js +89 -13
- data/lib/less/js/lib/less/tree/expression.js +40 -9
- data/lib/less/js/lib/less/tree/extend.js +53 -0
- data/lib/less/js/lib/less/tree/import.js +84 -37
- data/lib/less/js/lib/less/tree/javascript.js +18 -11
- data/lib/less/js/lib/less/tree/keyword.js +19 -4
- data/lib/less/js/lib/less/tree/media.js +157 -0
- data/lib/less/js/lib/less/tree/mixin.js +261 -52
- data/lib/less/js/lib/less/tree/negative.js +24 -0
- data/lib/less/js/lib/less/tree/operation.js +39 -14
- data/lib/less/js/lib/less/tree/paren.js +23 -0
- data/lib/less/js/lib/less/tree/quoted.js +30 -11
- data/lib/less/js/lib/less/tree/rule.js +79 -27
- data/lib/less/js/lib/less/tree/ruleset-call.js +16 -0
- data/lib/less/js/lib/less/tree/ruleset.js +469 -94
- data/lib/less/js/lib/less/tree/selector.js +119 -18
- data/lib/less/js/lib/less/tree/unicode-descriptor.js +15 -0
- data/lib/less/js/lib/less/tree/url.js +44 -16
- data/lib/less/js/lib/less/tree/value.js +17 -7
- data/lib/less/js/lib/less/tree/variable.js +29 -9
- data/lib/less/js/lib/less/tree.js +88 -4
- data/lib/less/js/lib/less/visitor.js +146 -0
- data/lib/less/js/lib/source-map/source-map-0.1.31.js +1933 -0
- data/lib/less/js/lib/source-map/source-map-footer.js +4 -0
- data/lib/less/js/lib/source-map/source-map-header.js +3 -0
- data/lib/less/js/package.json +86 -11
- data/lib/less/js/test/browser/common.js +201 -0
- data/lib/less/js/test/browser/css/global-vars/simple.css +3 -0
- data/lib/less/js/test/browser/css/modify-vars/simple.css +8 -0
- data/lib/less/js/test/browser/css/postProcessor/postProcessor.css +4 -0
- data/lib/less/js/test/browser/css/relative-urls/urls.css +35 -0
- data/lib/less/js/test/browser/css/rootpath/urls.css +35 -0
- data/lib/less/js/test/browser/css/rootpath-relative/urls.css +35 -0
- data/lib/less/js/test/browser/css/urls.css +53 -0
- data/lib/less/js/test/browser/es5.js +27 -0
- data/lib/less/js/test/browser/jasmine-html.js +681 -0
- data/lib/less/js/test/browser/jasmine.css +82 -0
- data/lib/less/js/test/browser/jasmine.js +2600 -0
- data/lib/less/js/test/browser/less/console-errors/test-error.less +3 -0
- data/lib/less/js/test/browser/less/console-errors/test-error.txt +2 -0
- data/lib/less/js/test/browser/less/global-vars/simple.less +3 -0
- data/lib/less/js/test/browser/less/imports/urls.less +4 -0
- data/lib/less/js/test/browser/less/imports/urls2.less +4 -0
- data/lib/less/js/test/browser/less/modify-vars/imports/simple2.less +4 -0
- data/lib/less/js/test/browser/less/modify-vars/simple.less +8 -0
- data/lib/less/js/test/browser/less/postProcessor/postProcessor.less +4 -0
- data/lib/less/js/test/browser/less/relative-urls/urls.less +33 -0
- data/lib/less/js/test/browser/less/rootpath/urls.less +33 -0
- data/lib/less/js/test/browser/less/rootpath-relative/urls.less +33 -0
- data/lib/less/js/test/browser/less/urls.less +57 -0
- data/lib/less/js/test/browser/phantom-runner.js +150 -0
- data/lib/less/js/test/browser/runner-browser-options.js +42 -0
- data/lib/less/js/test/browser/runner-browser-spec.js +12 -0
- data/lib/less/js/test/browser/runner-console-errors.js +5 -0
- data/lib/less/js/test/browser/runner-errors-options.js +5 -0
- data/lib/less/js/test/browser/runner-errors-spec.js +4 -0
- data/lib/less/js/test/browser/runner-global-vars-options.js +4 -0
- data/lib/less/js/test/browser/runner-global-vars-spec.js +3 -0
- data/lib/less/js/test/browser/runner-legacy-options.js +4 -0
- data/lib/less/js/test/browser/runner-legacy-spec.js +3 -0
- data/lib/less/js/test/browser/runner-main-options.js +15 -0
- data/lib/less/js/test/browser/runner-main-spec.js +3 -0
- data/lib/less/js/test/browser/runner-modify-vars-options.js +2 -0
- data/lib/less/js/test/browser/runner-modify-vars-spec.js +43 -0
- data/lib/less/js/test/browser/runner-no-js-errors-options.js +4 -0
- data/lib/less/js/test/browser/runner-no-js-errors-spec.js +4 -0
- data/lib/less/js/test/browser/runner-postProcessor-options.js +4 -0
- data/lib/less/js/test/browser/runner-postProcessor.js +3 -0
- data/lib/less/js/test/browser/runner-production-options.js +3 -0
- data/lib/less/js/test/browser/runner-production-spec.js +5 -0
- data/lib/less/js/test/browser/runner-relative-urls-options.js +3 -0
- data/lib/less/js/test/browser/runner-relative-urls-spec.js +3 -0
- data/lib/less/js/test/browser/runner-rootpath-options.js +3 -0
- data/lib/less/js/test/browser/runner-rootpath-relative-options.js +4 -0
- data/lib/less/js/test/browser/runner-rootpath-relative-spec.js +3 -0
- data/lib/less/js/test/browser/runner-rootpath-spec.js +3 -0
- data/lib/less/js/test/browser/test-runner-template.tmpl +47 -0
- data/lib/less/js/test/css/charsets.css +1 -0
- data/lib/less/js/test/css/colors.css +45 -0
- data/lib/less/js/test/css/comments.css +24 -7
- data/lib/less/js/test/css/compression/compression.css +3 -0
- data/lib/less/js/test/css/css-3.css +91 -4
- data/lib/less/js/test/css/css-escapes.css +5 -1
- data/lib/less/js/test/css/css-guards.css +37 -0
- data/lib/less/js/test/css/css.css +29 -16
- data/lib/less/js/test/css/debug/linenumbers-all.css +49 -0
- data/lib/less/js/test/css/debug/linenumbers-comments.css +40 -0
- data/lib/less/js/test/css/debug/linenumbers-mediaquery.css +40 -0
- data/lib/less/js/test/css/detached-rulesets.css +71 -0
- data/lib/less/js/test/css/empty.css +0 -0
- data/lib/less/js/test/css/extend-chaining.css +81 -0
- data/lib/less/js/test/css/extend-clearfix.css +19 -0
- data/lib/less/js/test/css/extend-exact.css +37 -0
- data/lib/less/js/test/css/extend-media.css +24 -0
- data/lib/less/js/test/css/extend-nest.css +57 -0
- data/lib/less/js/test/css/extend-selector.css +80 -0
- data/lib/less/js/test/css/extend.css +76 -0
- data/lib/less/js/test/css/extract-and-length.css +133 -0
- data/lib/less/js/test/css/functions.css +128 -0
- data/lib/less/js/test/css/globalVars/extended.css +12 -0
- data/lib/less/js/test/css/globalVars/simple.css +6 -0
- data/lib/less/js/test/css/ie-filters.css +9 -0
- data/lib/less/js/test/css/import-inline.css +5 -0
- data/lib/less/js/test/css/import-interpolation.css +6 -0
- data/lib/less/js/test/css/import-once.css +15 -0
- data/lib/less/js/test/css/import-reference.css +68 -0
- data/lib/less/js/test/css/import.css +30 -8
- data/lib/less/js/test/css/javascript.css +3 -2
- data/lib/less/js/test/css/legacy/legacy.css +7 -0
- data/lib/less/js/test/css/media.css +200 -2
- data/lib/less/js/test/css/merge.css +34 -0
- data/lib/less/js/test/css/mixins-args.css +58 -6
- data/lib/less/js/test/css/mixins-guards-default-func.css +129 -0
- data/lib/less/js/test/css/mixins-guards.css +82 -0
- data/lib/less/js/test/css/mixins-important.css +45 -0
- data/lib/less/js/test/css/mixins-interpolated.css +39 -0
- data/lib/less/js/test/css/mixins-named-args.css +27 -0
- data/lib/less/js/test/css/mixins-pattern.css +8 -6
- data/lib/less/js/test/css/mixins.css +91 -0
- data/lib/less/js/test/css/modifyVars/extended.css +9 -0
- data/lib/less/js/test/css/no-output.css +0 -0
- data/lib/less/js/test/css/operations.css +3 -0
- data/lib/less/js/test/css/parens.css +22 -6
- data/lib/less/js/test/css/property-name-interp.css +20 -0
- data/lib/less/js/test/css/rulesets.css +6 -2
- data/lib/less/js/test/css/scope.css +29 -6
- data/lib/less/js/test/css/selectors.css +122 -1
- data/lib/less/js/test/css/static-urls/urls.css +45 -0
- data/lib/less/js/test/css/strings.css +10 -5
- data/lib/less/js/test/css/url-args/urls.css +56 -0
- data/lib/less/js/test/css/urls.css +71 -0
- data/lib/less/js/test/css/variables-in-at-rules.css +18 -0
- data/lib/less/js/test/css/variables.css +23 -2
- data/lib/less/js/test/css/whitespace.css +9 -3
- data/lib/less/js/test/data/data-uri-fail.png +0 -0
- data/lib/less/js/test/data/image.jpg +1 -0
- data/lib/less/js/test/data/page.html +1 -0
- data/lib/less/js/test/index.js +45 -0
- data/lib/less/js/test/less/charsets.less +3 -0
- data/lib/less/js/test/less/colors.less +56 -4
- data/lib/less/js/test/less/comments.less +28 -8
- data/lib/less/js/test/less/compression/compression.less +36 -0
- data/lib/less/js/test/less/css-3.less +80 -6
- data/lib/less/js/test/less/css-escapes.less +6 -1
- data/lib/less/js/test/less/css-guards.less +102 -0
- data/lib/less/js/test/less/css.less +25 -13
- data/lib/less/js/test/less/debug/import/test.less +25 -0
- data/lib/less/js/test/less/debug/linenumbers.less +33 -0
- data/lib/less/js/test/less/detached-rulesets.less +103 -0
- data/lib/less/js/test/less/empty.less +0 -0
- data/lib/less/js/test/less/errors/add-mixed-units.less +3 -0
- data/lib/less/js/test/less/errors/add-mixed-units.txt +4 -0
- data/lib/less/js/test/less/errors/add-mixed-units2.less +3 -0
- data/lib/less/js/test/less/errors/add-mixed-units2.txt +4 -0
- data/lib/less/js/test/less/errors/at-rules-undefined-var.less +4 -0
- data/lib/less/js/test/less/errors/at-rules-undefined-var.txt +4 -0
- data/lib/less/js/test/less/errors/bad-variable-declaration1.less +1 -0
- data/lib/less/js/test/less/errors/bad-variable-declaration1.txt +2 -0
- data/lib/less/js/test/less/errors/color-func-invalid-color.less +3 -0
- data/lib/less/js/test/less/errors/color-func-invalid-color.txt +4 -0
- data/lib/less/js/test/less/errors/comment-in-selector.less +1 -0
- data/lib/less/js/test/less/errors/comment-in-selector.txt +2 -0
- data/lib/less/js/test/less/errors/css-guard-default-func.less +4 -0
- data/lib/less/js/test/less/errors/css-guard-default-func.txt +4 -0
- data/lib/less/js/test/less/errors/detached-ruleset-1.less +6 -0
- data/lib/less/js/test/less/errors/detached-ruleset-1.txt +4 -0
- data/lib/less/js/test/less/errors/detached-ruleset-2.less +6 -0
- data/lib/less/js/test/less/errors/detached-ruleset-2.txt +4 -0
- data/lib/less/js/test/less/errors/detached-ruleset-3.less +4 -0
- data/lib/less/js/test/less/errors/detached-ruleset-3.txt +4 -0
- data/lib/less/js/test/less/errors/detached-ruleset-4.less +5 -0
- data/lib/less/js/test/less/errors/detached-ruleset-4.txt +3 -0
- data/lib/less/js/test/less/errors/detached-ruleset-5.less +4 -0
- data/lib/less/js/test/less/errors/detached-ruleset-5.txt +3 -0
- data/lib/less/js/test/less/errors/detached-ruleset-6.less +5 -0
- data/lib/less/js/test/less/errors/detached-ruleset-6.txt +4 -0
- data/lib/less/js/test/less/errors/divide-mixed-units.less +3 -0
- data/lib/less/js/test/less/errors/divide-mixed-units.txt +4 -0
- data/lib/less/js/test/less/errors/extend-no-selector.less +3 -0
- data/lib/less/js/test/less/errors/extend-no-selector.txt +3 -0
- data/lib/less/js/test/less/errors/extend-not-at-end.less +3 -0
- data/lib/less/js/test/less/errors/extend-not-at-end.txt +3 -0
- data/lib/less/js/test/less/errors/import-missing.less +6 -0
- data/lib/less/js/test/less/errors/import-missing.txt +3 -0
- data/lib/less/js/test/less/errors/import-no-semi.less +1 -0
- data/lib/less/js/test/less/errors/import-no-semi.txt +2 -0
- data/lib/less/js/test/less/errors/import-subfolder1.less +1 -0
- data/lib/less/js/test/less/errors/import-subfolder1.txt +3 -0
- data/lib/less/js/test/less/errors/import-subfolder2.less +1 -0
- data/lib/less/js/test/less/errors/import-subfolder2.txt +4 -0
- data/lib/less/js/test/less/errors/imports/import-subfolder1.less +1 -0
- data/lib/less/js/test/less/errors/imports/import-subfolder2.less +1 -0
- data/lib/less/js/test/less/errors/imports/import-test.less +4 -0
- data/lib/less/js/test/less/errors/imports/subfolder/mixin-not-defined.less +1 -0
- data/lib/less/js/test/less/errors/imports/subfolder/parse-error-curly-bracket.less +1 -0
- data/lib/less/js/test/less/errors/javascript-error.less +3 -0
- data/lib/less/js/test/less/errors/javascript-error.txt +4 -0
- data/lib/less/js/test/less/errors/javascript-undefined-var.less +3 -0
- data/lib/less/js/test/less/errors/javascript-undefined-var.txt +4 -0
- data/lib/less/js/test/less/errors/mixed-mixin-definition-args-1.less +6 -0
- data/lib/less/js/test/less/errors/mixed-mixin-definition-args-1.txt +4 -0
- data/lib/less/js/test/less/errors/mixed-mixin-definition-args-2.less +6 -0
- data/lib/less/js/test/less/errors/mixed-mixin-definition-args-2.txt +4 -0
- data/lib/less/js/test/less/errors/mixin-not-defined.less +11 -0
- data/lib/less/js/test/less/errors/mixin-not-defined.txt +3 -0
- data/lib/less/js/test/less/errors/mixin-not-matched.less +6 -0
- data/lib/less/js/test/less/errors/mixin-not-matched.txt +3 -0
- data/lib/less/js/test/less/errors/mixin-not-matched2.less +6 -0
- data/lib/less/js/test/less/errors/mixin-not-matched2.txt +3 -0
- data/lib/less/js/test/less/errors/mixin-not-visible-in-scope-1.less +9 -0
- data/lib/less/js/test/less/errors/mixin-not-visible-in-scope-1.txt +4 -0
- data/lib/less/js/test/less/errors/mixins-guards-default-func-1.less +9 -0
- data/lib/less/js/test/less/errors/mixins-guards-default-func-1.txt +4 -0
- data/lib/less/js/test/less/errors/mixins-guards-default-func-2.less +9 -0
- data/lib/less/js/test/less/errors/mixins-guards-default-func-2.txt +4 -0
- data/lib/less/js/test/less/errors/mixins-guards-default-func-3.less +9 -0
- data/lib/less/js/test/less/errors/mixins-guards-default-func-3.txt +4 -0
- data/lib/less/js/test/less/errors/multiple-guards-on-css-selectors.less +4 -0
- data/lib/less/js/test/less/errors/multiple-guards-on-css-selectors.txt +4 -0
- data/lib/less/js/test/less/errors/multiple-guards-on-css-selectors2.less +4 -0
- data/lib/less/js/test/less/errors/multiple-guards-on-css-selectors2.txt +4 -0
- data/lib/less/js/test/less/errors/multiply-mixed-units.less +7 -0
- data/lib/less/js/test/less/errors/multiply-mixed-units.txt +4 -0
- data/lib/less/js/test/less/errors/parens-error-1.less +3 -0
- data/lib/less/js/test/less/errors/parens-error-1.txt +4 -0
- data/lib/less/js/test/less/errors/parens-error-2.less +3 -0
- data/lib/less/js/test/less/errors/parens-error-2.txt +4 -0
- data/lib/less/js/test/less/errors/parens-error-3.less +3 -0
- data/lib/less/js/test/less/errors/parens-error-3.txt +4 -0
- data/lib/less/js/test/less/errors/parse-error-curly-bracket.less +4 -0
- data/lib/less/js/test/less/errors/parse-error-curly-bracket.txt +4 -0
- data/lib/less/js/test/less/errors/parse-error-extra-parens.less +5 -0
- data/lib/less/js/test/less/errors/parse-error-extra-parens.txt +3 -0
- data/lib/less/js/test/less/errors/parse-error-missing-bracket.less +2 -0
- data/lib/less/js/test/less/errors/parse-error-missing-bracket.txt +3 -0
- data/lib/less/js/test/less/errors/parse-error-missing-parens.less +5 -0
- data/lib/less/js/test/less/errors/parse-error-missing-parens.txt +3 -0
- data/lib/less/js/test/less/errors/parse-error-with-import.less +13 -0
- data/lib/less/js/test/less/errors/parse-error-with-import.txt +4 -0
- data/lib/less/js/test/less/errors/percentage-missing-space.less +3 -0
- data/lib/less/js/test/less/errors/percentage-missing-space.txt +4 -0
- data/lib/less/js/test/less/errors/property-asterisk-only-name.less +3 -0
- data/lib/less/js/test/less/errors/property-asterisk-only-name.txt +4 -0
- data/lib/less/js/test/less/errors/property-ie5-hack.less +3 -0
- data/lib/less/js/test/less/errors/property-ie5-hack.txt +4 -0
- data/lib/less/js/test/less/errors/property-in-root.less +4 -0
- data/lib/less/js/test/less/errors/property-in-root.txt +4 -0
- data/lib/less/js/test/less/errors/property-in-root2.less +1 -0
- data/lib/less/js/test/less/errors/property-in-root2.txt +4 -0
- data/lib/less/js/test/less/errors/property-in-root3.less +4 -0
- data/lib/less/js/test/less/errors/property-in-root3.txt +3 -0
- data/lib/less/js/test/less/errors/property-interp-not-defined.less +1 -0
- data/lib/less/js/test/less/errors/property-interp-not-defined.txt +2 -0
- data/lib/less/js/test/less/errors/recursive-variable.less +1 -0
- data/lib/less/js/test/less/errors/recursive-variable.txt +2 -0
- data/lib/less/js/test/less/errors/svg-gradient1.less +3 -0
- data/lib/less/js/test/less/errors/svg-gradient1.txt +4 -0
- data/lib/less/js/test/less/errors/svg-gradient2.less +3 -0
- data/lib/less/js/test/less/errors/svg-gradient2.txt +4 -0
- data/lib/less/js/test/less/errors/svg-gradient3.less +3 -0
- data/lib/less/js/test/less/errors/svg-gradient3.txt +4 -0
- data/lib/less/js/test/less/errors/unit-function.less +3 -0
- data/lib/less/js/test/less/errors/unit-function.txt +4 -0
- data/lib/less/js/test/less/extend-chaining.less +91 -0
- data/lib/less/js/test/less/extend-clearfix.less +19 -0
- data/lib/less/js/test/less/extend-exact.less +46 -0
- data/lib/less/js/test/less/extend-media.less +24 -0
- data/lib/less/js/test/less/extend-nest.less +65 -0
- data/lib/less/js/test/less/extend-selector.less +99 -0
- data/lib/less/js/test/less/extend.less +81 -0
- data/lib/less/js/test/less/extract-and-length.less +133 -0
- data/lib/less/js/test/less/functions.less +142 -4
- data/lib/less/js/test/less/globalVars/extended.json +5 -0
- data/lib/less/js/test/less/globalVars/extended.less +10 -0
- data/lib/less/js/test/less/globalVars/simple.json +3 -0
- data/lib/less/js/test/less/globalVars/simple.less +3 -0
- data/lib/less/js/test/less/ie-filters.less +15 -0
- data/lib/less/js/test/less/import/deeper/import-once-test-a.less +1 -0
- data/lib/less/js/test/less/import/import-and-relative-paths-test.less +17 -0
- data/lib/less/js/test/less/import/import-charset-test.less +1 -0
- data/lib/less/js/test/less/import/import-interpolation.less +1 -0
- data/lib/less/js/test/less/import/import-interpolation2.less +5 -0
- data/lib/less/js/test/less/import/import-once-test-c.less +6 -0
- data/lib/less/js/test/less/import/import-reference.less +51 -0
- data/lib/less/js/test/less/import/import-test-a.less +1 -0
- data/lib/less/js/test/less/import/import-test-c.less +0 -1
- data/lib/less/js/test/less/import/import-test-e.less +2 -0
- data/lib/less/js/test/less/import/import-test-f.less +5 -0
- data/lib/less/js/test/less/import/imports/font.less +8 -0
- data/lib/less/js/test/less/import/imports/logo.less +5 -0
- data/lib/less/js/test/less/import/invalid-css.less +1 -0
- data/lib/less/js/test/less/import/urls.less +1 -0
- data/lib/less/js/test/less/import-inline.less +2 -0
- data/lib/less/js/test/less/import-interpolation.less +8 -0
- data/lib/less/js/test/less/import-once.less +6 -0
- data/lib/less/js/test/less/import-reference.less +21 -0
- data/lib/less/js/test/less/import.less +16 -3
- data/lib/less/js/test/less/javascript.less +5 -3
- data/lib/less/js/test/less/legacy/legacy.less +7 -0
- data/lib/less/js/test/less/media.less +212 -3
- data/lib/less/js/test/less/merge.less +78 -0
- data/lib/less/js/test/less/mixins-args.less +113 -16
- data/lib/less/js/test/less/mixins-guards-default-func.less +195 -0
- data/lib/less/js/test/less/mixins-guards.less +159 -0
- data/lib/less/js/test/less/mixins-important.less +25 -0
- data/lib/less/js/test/less/mixins-interpolated.less +69 -0
- data/lib/less/js/test/less/mixins-named-args.less +36 -0
- data/lib/less/js/test/less/mixins-nested.less +2 -2
- data/lib/less/js/test/less/mixins-pattern.less +7 -1
- data/lib/less/js/test/less/mixins.less +94 -0
- data/lib/less/js/test/less/modifyVars/extended.json +5 -0
- data/lib/less/js/test/less/modifyVars/extended.less +11 -0
- data/lib/less/js/test/less/no-js-errors/no-js-errors.less +3 -0
- data/lib/less/js/test/less/no-js-errors/no-js-errors.txt +4 -0
- data/lib/less/js/test/less/no-output.less +2 -0
- data/lib/less/js/test/less/operations.less +30 -26
- data/lib/less/js/test/less/parens.less +24 -5
- data/lib/less/js/test/less/property-name-interp.less +53 -0
- data/lib/less/js/test/less/scope.less +73 -1
- data/lib/less/js/test/less/selectors.less +132 -0
- data/lib/less/js/test/less/sourcemaps/basic.json +3 -0
- data/lib/less/js/test/less/sourcemaps/basic.less +27 -0
- data/lib/less/js/test/less/sourcemaps/imported.css +7 -0
- data/lib/less/js/test/less/static-urls/urls.less +33 -0
- data/lib/less/js/test/less/strings.less +9 -1
- data/lib/less/js/test/less/url-args/urls.less +63 -0
- data/lib/less/js/test/less/urls.less +72 -0
- data/lib/less/js/test/less/variables-in-at-rules.less +20 -0
- data/lib/less/js/test/less/variables.less +44 -11
- data/lib/less/js/test/less/whitespace.less +7 -0
- data/lib/less/js/test/less-test.js +244 -60
- data/lib/less/js/test/rhino/test-header.js +15 -0
- data/lib/less/js/test/sourcemaps/basic.json +1 -0
- data/lib/less/js/test/sourcemaps/index.html +17 -0
- data/lib/less/loader.rb +208 -42
- data/lib/less/parser.rb +91 -30
- data/lib/less/version.rb +2 -2
- data/lib/less.rb +23 -8
- data/spec/less/faulty/faulty.less +3 -0
- data/spec/less/loader_spec.rb +45 -0
- data/spec/less/parser_spec.rb +141 -4
- data/spec/less/some/some.css +0 -0
- data/spec/less/some/some.less +4 -0
- data/spec/spec_helper.rb +4 -2
- metadata +418 -76
- data/lib/less/js/Makefile +0 -56
- data/lib/less/js/build/ecma-5.js +0 -120
- data/lib/less/js/build/header.js +0 -7
data/lib/less/parser.rb
CHANGED
|
@@ -1,46 +1,107 @@
|
|
|
1
|
-
|
|
2
|
-
require 'v8'
|
|
1
|
+
require 'pathname'
|
|
3
2
|
|
|
4
3
|
module Less
|
|
4
|
+
|
|
5
|
+
# Convert lesscss source into an abstract syntax Tree
|
|
5
6
|
class Parser
|
|
6
7
|
|
|
8
|
+
# Construct and configure new Less::Parser
|
|
9
|
+
#
|
|
10
|
+
# @param [Hash] options configuration options
|
|
11
|
+
# @option options [Array] :paths a list of directories to search when handling \@import statements
|
|
12
|
+
# @option options [String] :filename to associate with resulting parse trees (useful for generating errors)
|
|
13
|
+
# @option options [TrueClass, FalseClass] :compress
|
|
14
|
+
# @option options [TrueClass, FalseClass] :strictImports
|
|
15
|
+
# @option options [TrueClass, FalseClass] :relativeUrls
|
|
16
|
+
# @option options [String] :dumpLineNumbers one of 'mediaquery', 'comments', or 'all'
|
|
7
17
|
def initialize(options = {})
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
18
|
+
# LeSS supported _env_ options :
|
|
19
|
+
#
|
|
20
|
+
# - paths (unmodified) - paths to search for imports on
|
|
21
|
+
# - optimization - optimization level (for the chunker)
|
|
22
|
+
# - mime (browser only) mime type for sheet import
|
|
23
|
+
# - contents (browser only)
|
|
24
|
+
# - strictImports
|
|
25
|
+
# - dumpLineNumbers - whether to dump line numbers
|
|
26
|
+
# - compress - whether to compress
|
|
27
|
+
# - processImports - whether to process imports. if false then imports will not be imported
|
|
28
|
+
# - relativeUrls (true/false) whether to adjust URL's to be relative
|
|
29
|
+
# - errback (error callback function)
|
|
30
|
+
# - rootpath string
|
|
31
|
+
# - entryPath string
|
|
32
|
+
# - files (internal) - list of files that have been imported, used for import-once
|
|
33
|
+
# - currentFileInfo (internal) - information about the current file -
|
|
34
|
+
# for error reporting and importing and making urls relative etc :
|
|
35
|
+
# this.currentFileInfo = {
|
|
36
|
+
# filename: filename,
|
|
37
|
+
# relativeUrls: this.relativeUrls,
|
|
38
|
+
# rootpath: options.rootpath || "",
|
|
39
|
+
# currentDirectory: entryPath,
|
|
40
|
+
# entryPath: entryPath,
|
|
41
|
+
# rootFilename: filename
|
|
42
|
+
# };
|
|
43
|
+
#
|
|
44
|
+
env = {}
|
|
45
|
+
Less.defaults.merge(options).each do |key, val|
|
|
46
|
+
env[key.to_s] =
|
|
47
|
+
case val
|
|
48
|
+
when Symbol, Pathname then val.to_s
|
|
49
|
+
when Array
|
|
50
|
+
val.map!(&:to_s) if key.to_sym == :paths # might contain Pathname-s
|
|
51
|
+
val # keep the original passed Array
|
|
52
|
+
else val # true/false/String/Method
|
|
53
|
+
end
|
|
11
54
|
end
|
|
12
|
-
@parser = Less.Parser.new(
|
|
55
|
+
@parser = Less::JavaScript.exec { Less['Parser'].new(env) }
|
|
13
56
|
end
|
|
14
57
|
|
|
58
|
+
# Convert `less` source into a abstract syntaxt tree
|
|
59
|
+
# @param [String] less the source to parse
|
|
60
|
+
# @return [Less::Tree] the parsed tree
|
|
15
61
|
def parse(less)
|
|
16
|
-
error,tree = nil
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
62
|
+
error, tree = nil, nil
|
|
63
|
+
Less::JavaScript.exec do
|
|
64
|
+
@parser.parse(less, lambda { |*args| # (error, tree)
|
|
65
|
+
# v8 >= 0.10 passes this as first arg :
|
|
66
|
+
if args.size > 2
|
|
67
|
+
error, tree = args[-2], args[-1]
|
|
68
|
+
elsif args.last.respond_to?(:message) && args.last.message
|
|
69
|
+
# might get invoked as callback(error)
|
|
70
|
+
error = args.last
|
|
71
|
+
else
|
|
72
|
+
error, tree = *args
|
|
73
|
+
end
|
|
74
|
+
fail error.message unless error.nil?
|
|
75
|
+
})
|
|
76
|
+
end
|
|
77
|
+
Tree.new(tree) if tree
|
|
21
78
|
end
|
|
22
79
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
class Tree
|
|
26
|
-
def initialize(tree)
|
|
27
|
-
@tree = tree
|
|
80
|
+
def imports
|
|
81
|
+
Less::JavaScript.exec { @parser.imports.files.map { |file, _| file } }
|
|
28
82
|
end
|
|
29
83
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
@
|
|
84
|
+
private
|
|
85
|
+
|
|
86
|
+
# Abstract LessCSS syntax tree Less. Mainly used to emit CSS
|
|
87
|
+
class Tree
|
|
88
|
+
|
|
89
|
+
# Create a tree from a native javascript object.
|
|
90
|
+
# @param [V8::Object] tree the native less.js tree
|
|
91
|
+
def initialize(tree)
|
|
92
|
+
@tree = tree
|
|
93
|
+
end
|
|
94
|
+
|
|
95
|
+
# Serialize this tree into CSS.
|
|
96
|
+
# By default this will be in pretty-printed form.
|
|
97
|
+
# @param [Hash] opts modifications to the output
|
|
98
|
+
# @option opts [Boolean] :compress minify output instead of pretty-printing
|
|
99
|
+
def to_css(options = {})
|
|
100
|
+
Less::JavaScript.exec { @tree.toCSS(options) }
|
|
101
|
+
end
|
|
102
|
+
|
|
44
103
|
end
|
|
104
|
+
|
|
45
105
|
end
|
|
106
|
+
|
|
46
107
|
end
|
data/lib/less/version.rb
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
module Less
|
|
2
|
-
VERSION = '2.
|
|
3
|
-
end
|
|
2
|
+
VERSION = '2.6.0'
|
|
3
|
+
end
|
data/lib/less.rb
CHANGED
|
@@ -1,17 +1,32 @@
|
|
|
1
|
-
$:.unshift(File.dirname(__FILE__)) unless
|
|
2
|
-
$:.include?(File.dirname(__FILE__)) || $:.include?(File.expand_path(File.dirname(__FILE__)))
|
|
3
1
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
2
|
+
require 'less/defaults'
|
|
3
|
+
require 'less/errors'
|
|
4
|
+
require 'less/loader'
|
|
5
|
+
require 'less/parser'
|
|
6
|
+
require 'less/version'
|
|
7
|
+
require 'less/java_script'
|
|
9
8
|
|
|
9
|
+
module Less
|
|
10
|
+
extend Less::Defaults
|
|
11
|
+
|
|
12
|
+
# NOTE: keep the @loader as less-rails depends on
|
|
13
|
+
# it as it overrides some less/tree.js functions!
|
|
10
14
|
@loader = Less::Loader.new
|
|
11
15
|
@less = @loader.require('less/index')
|
|
12
16
|
|
|
17
|
+
def self.[](name)
|
|
18
|
+
@less[name]
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
# exposes less.Parser
|
|
13
22
|
def self.Parser
|
|
14
|
-
|
|
23
|
+
self['Parser']
|
|
15
24
|
end
|
|
16
25
|
|
|
26
|
+
# exposes less.tree e.g. for attaching custom functions
|
|
27
|
+
# Less.tree.functions['foo'] = lambda { |*args| 'bar' }
|
|
28
|
+
def self.tree
|
|
29
|
+
self['tree']
|
|
30
|
+
end
|
|
31
|
+
|
|
17
32
|
end
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
require 'stringio'
|
|
3
|
+
|
|
4
|
+
describe Less::Loader do
|
|
5
|
+
|
|
6
|
+
describe 'eval console.log()' do
|
|
7
|
+
|
|
8
|
+
it 'should write message to $stdout' do
|
|
9
|
+
stdout = $stdout; io_stub = StringIO.new
|
|
10
|
+
begin
|
|
11
|
+
$stdout = io_stub
|
|
12
|
+
subject.environment.runtime.eval("console.log('log much?');")
|
|
13
|
+
ensure
|
|
14
|
+
$stdout = stdout
|
|
15
|
+
end
|
|
16
|
+
io_stub.string.should == "log much?\n"
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
it 'should write messages to $stdout' do
|
|
20
|
+
stdout = $stdout; io_stub = StringIO.new
|
|
21
|
+
begin
|
|
22
|
+
$stdout = io_stub
|
|
23
|
+
subject.environment.runtime.eval("console.log('1','2','3');")
|
|
24
|
+
ensure
|
|
25
|
+
$stdout = stdout
|
|
26
|
+
end
|
|
27
|
+
io_stub.string.should == "1, 2, 3\n"
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
describe 'eval process.exit()' do
|
|
33
|
+
|
|
34
|
+
process = Less::Loader::Process
|
|
35
|
+
|
|
36
|
+
it 'should not raise an error' do
|
|
37
|
+
process.any_instance.should_receive(:warn) do |msg|
|
|
38
|
+
msg.should match(/JS process\.exit\(-2\)/)
|
|
39
|
+
end
|
|
40
|
+
subject.environment.runtime.eval("process.exit(-2);")
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
end
|
data/spec/less/parser_spec.rb
CHANGED
|
@@ -4,6 +4,10 @@ describe Less::Parser do
|
|
|
4
4
|
|
|
5
5
|
cwd = Pathname(__FILE__).dirname
|
|
6
6
|
|
|
7
|
+
it "instantiates" do
|
|
8
|
+
lambda { Less::Parser.new }.should_not raise_error
|
|
9
|
+
end
|
|
10
|
+
|
|
7
11
|
describe "simple usage" do
|
|
8
12
|
it "parse less into a tree" do
|
|
9
13
|
root = subject.parse(".class {width: 1+1}")
|
|
@@ -11,20 +15,153 @@ describe Less::Parser do
|
|
|
11
15
|
end
|
|
12
16
|
|
|
13
17
|
it "accepts options when assembling the parse tree" do
|
|
14
|
-
subject.parse(".class {width: 1+1}").to_css(:compress => true).strip.should eql ".class{width:2
|
|
18
|
+
subject.parse(".class {width: 1+1}").to_css(:compress => true).strip.should eql ".class{width:2}"
|
|
15
19
|
end
|
|
16
20
|
end
|
|
21
|
+
|
|
17
22
|
it "throws a ParseError if the lesscss is bogus" do
|
|
18
|
-
|
|
23
|
+
lambda { subject.parse('{^)') }.should raise_error(Less::ParseError, /missing opening `\(`/)
|
|
19
24
|
end
|
|
20
25
|
|
|
21
|
-
|
|
22
|
-
|
|
26
|
+
it "passes exceptions from the less compiler" do
|
|
27
|
+
lambda { subject.parse('body { color: @a; }').to_css }.should raise_error(Less::ParseError, /variable @a is undefined/)
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
describe "when configured with source mapping" do
|
|
31
|
+
subject { Less::Parser.new(:filename => 'one.less', :paths => [ cwd.join('one'), cwd.join('two') ], :dumpLineNumbers => 'mediaquery') }
|
|
32
|
+
|
|
33
|
+
it "prints source maps" do
|
|
34
|
+
subject.parse('@import "one.less"; @import "two.less";').to_css(:compress => false).gsub(/\n/,'').strip.should eql "@media -sass-debug-info{filename{font-family:file\\:\\/\\/one\\.less}line{font-family:\\000031}}.one { width: 1;}@media -sass-debug-info{filename{font-family:file\\:\\/\\/two\\.less}line{font-family:\\000031}}.two { width: 1;}"
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
describe "when configured with multiple load paths" do
|
|
40
|
+
subject { Less::Parser.new :paths => [ cwd.join('one'), cwd.join('two'), cwd.join('faulty') ] }
|
|
23
41
|
|
|
24
42
|
it "will load files from both paths" do
|
|
43
|
+
subject.parse('@import "one.less";').to_css.gsub(/\n/,'').strip.should eql ".one { width: 1;}"
|
|
44
|
+
subject.parse('@import "two.less";').to_css.gsub(/\n/,'').strip.should eql ".two { width: 1;}"
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
it "passes exceptions from less imported less files" do
|
|
48
|
+
lambda { subject.parse('@import "faulty.less";').to_css }.should raise_error(Less::ParseError, /variable @a is undefined/)
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
it "will track imported files" do
|
|
52
|
+
subject.parse('@import "one.less";')
|
|
53
|
+
subject.parse('@import "two.less";')
|
|
54
|
+
# Parser#imports returns full path names
|
|
55
|
+
subject.imports.grep(/one\.less$/).should_not be_empty
|
|
56
|
+
subject.imports.grep(/two\.less$/).should_not be_empty
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
it "reports type, line, column and filename of (parse) error" do
|
|
60
|
+
begin
|
|
61
|
+
subject.parse('@import "faulty.less";').to_css
|
|
62
|
+
rescue Less::ParseError => e
|
|
63
|
+
e.type.should == 'Name'
|
|
64
|
+
e.filename.should == cwd.join('faulty/faulty.less').to_s
|
|
65
|
+
e.line.should == 2
|
|
66
|
+
e.column.should == 9
|
|
67
|
+
else
|
|
68
|
+
fail "parse error not raised"
|
|
69
|
+
end
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
describe "when load paths are specified in as default options" do
|
|
75
|
+
before do
|
|
76
|
+
Less.paths << cwd.join('one')
|
|
77
|
+
Less.paths << cwd.join('two')
|
|
78
|
+
@parser = Less::Parser.new
|
|
79
|
+
end
|
|
80
|
+
after do
|
|
81
|
+
Less.paths.clear
|
|
82
|
+
end
|
|
83
|
+
|
|
84
|
+
it "will load files from default load paths" do
|
|
25
85
|
@parser.parse('@import "one.less";').to_css.gsub(/\n/,'').strip.should eql ".one { width: 1;}"
|
|
26
86
|
@parser.parse('@import "two.less";').to_css.gsub(/\n/,'').strip.should eql ".two { width: 1;}"
|
|
27
87
|
end
|
|
28
88
|
end
|
|
29
89
|
|
|
90
|
+
describe "relative urls" do
|
|
91
|
+
|
|
92
|
+
it "keeps relative imports when true" do
|
|
93
|
+
parser = Less::Parser.new :paths => [ cwd ], :relativeUrls => true
|
|
94
|
+
expected = "@import \"some/some.css\";\nbody {\n background: url('some/assets/logo.png');\n}\n"
|
|
95
|
+
expect( parser.parse('@import "some/some.less";').to_css ).to eql expected
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
it "does not keep relative imports when false" do
|
|
99
|
+
parser = Less::Parser.new :paths => [ cwd ], :relativeUrls => false
|
|
100
|
+
expected = "@import \"some.css\";\nbody {\n background: url('assets/logo.png');\n}\n"
|
|
101
|
+
expect( parser.parse('@import "some/some.less";').to_css ).to eql expected
|
|
102
|
+
end
|
|
103
|
+
|
|
104
|
+
end
|
|
105
|
+
|
|
106
|
+
# NOTE: runs JS tests from less.js it's a replacement for less-test.js
|
|
107
|
+
describe "less-test", :integration => true do
|
|
108
|
+
|
|
109
|
+
TEST_LESS_DIR = File.expand_path('../../lib/less/js/test/less', File.dirname(__FILE__))
|
|
110
|
+
TEST_CSS_DIR = File.expand_path('../../lib/less/js/test/css' , File.dirname(__FILE__))
|
|
111
|
+
|
|
112
|
+
before :all do
|
|
113
|
+
# functions.less test expects these exposed :
|
|
114
|
+
Less.tree.functions[:add] = lambda do |*args| # function (a, b)
|
|
115
|
+
a, b = args[-2], args[-1]
|
|
116
|
+
Less.tree['Dimension'].new(a['value'] + b['value'])
|
|
117
|
+
# return new(less.tree.Dimension)(a.value + b.value);
|
|
118
|
+
end
|
|
119
|
+
Less.tree.functions[:increment] = lambda do |*args| # function (a)
|
|
120
|
+
a = args[-1]
|
|
121
|
+
Less.tree['Dimension'].new(a['value'] + 1)
|
|
122
|
+
# return new(less.tree.Dimension)(a.value + 1);
|
|
123
|
+
end
|
|
124
|
+
Less.tree.functions[:_color] = lambda do |*args| # function (str)
|
|
125
|
+
str = args[-1]
|
|
126
|
+
if str.value == 'evil red'
|
|
127
|
+
# if (str.value === "evil red")
|
|
128
|
+
Less.tree['Color'].new('600')
|
|
129
|
+
# return new(less.tree.Color)("600")
|
|
130
|
+
end
|
|
131
|
+
end
|
|
132
|
+
end
|
|
133
|
+
|
|
134
|
+
after :all do
|
|
135
|
+
Less.tree.functions[:add] = nil
|
|
136
|
+
Less.tree.functions[:increment] = nil
|
|
137
|
+
Less.tree.functions[:_color] = nil
|
|
138
|
+
end
|
|
139
|
+
|
|
140
|
+
Dir.glob(File.join(TEST_LESS_DIR, '*.less')).each do |less_file|
|
|
141
|
+
|
|
142
|
+
base_name = File.basename(less_file, '.less')
|
|
143
|
+
css_file = File.join(TEST_CSS_DIR, "#{base_name}.css")
|
|
144
|
+
raise "missing css file: #{css_file}" unless File.exists?(css_file)
|
|
145
|
+
|
|
146
|
+
less_content = File.read(less_file)
|
|
147
|
+
case base_name
|
|
148
|
+
when 'javascript'
|
|
149
|
+
# adjust less .eval line :
|
|
150
|
+
# title: `process.title`;
|
|
151
|
+
# later replaced by line :
|
|
152
|
+
# title: `typeof process.title`;
|
|
153
|
+
# with something that won't fail (since we're not in Node.JS)
|
|
154
|
+
less_content.sub!('process.title', '"node"')
|
|
155
|
+
end
|
|
156
|
+
|
|
157
|
+
it "#{base_name}.less" do
|
|
158
|
+
parser = Less::Parser.new(:filename => less_file, :paths => [ File.dirname(less_file) ])
|
|
159
|
+
less = parser.parse( less_content )
|
|
160
|
+
less.to_css(:strictMath => true, :silent => true).should == File.read(css_file)
|
|
161
|
+
end
|
|
162
|
+
|
|
163
|
+
end
|
|
164
|
+
|
|
165
|
+
end
|
|
166
|
+
|
|
30
167
|
end
|
|
File without changes
|
data/spec/spec_helper.rb
CHANGED