less 2.2.2 → 2.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/Changelog.md +17 -0
- data/Gemfile +7 -3
- data/README.md +29 -13
- data/bin/lessc +3 -1
- data/less.gemspec +2 -6
- data/lib/less/defaults.rb +3 -3
- data/lib/less/java_script/rhino_context.rb +17 -27
- data/lib/less/java_script/v8_context.rb +11 -11
- 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 +194 -194
- data/lib/less/js/benchmark/less-benchmark.js +9 -10
- data/lib/less/js/bin/lessc +310 -37
- data/lib/less/js/bower.json +18 -0
- data/lib/less/js/build/README.md +51 -0
- data/lib/less/js/build/amd.js +1 -1
- 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 +7 -2
- 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.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.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 +547 -250
- 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 +576 -36
- data/lib/less/js/lib/less/import-visitor.js +142 -0
- data/lib/less/js/lib/less/index.js +187 -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 +1286 -523
- data/lib/less/js/lib/less/rhino.js +415 -29
- 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 +17 -5
- data/lib/less/js/lib/less/tree/anonymous.js +25 -4
- data/lib/less/js/lib/less/tree/assignment.js +17 -5
- data/lib/less/js/lib/less/tree/call.js +36 -13
- data/lib/less/js/lib/less/tree/color.js +119 -31
- data/lib/less/js/lib/less/tree/comment.js +18 -4
- data/lib/less/js/lib/less/tree/condition.js +35 -28
- data/lib/less/js/lib/less/tree/detached-ruleset.js +20 -0
- data/lib/less/js/lib/less/tree/dimension.js +291 -16
- data/lib/less/js/lib/less/tree/directive.js +56 -22
- data/lib/less/js/lib/less/tree/element.js +78 -17
- data/lib/less/js/lib/less/tree/expression.js +39 -8
- data/lib/less/js/lib/less/tree/extend.js +53 -0
- data/lib/less/js/lib/less/tree/import.js +81 -36
- data/lib/less/js/lib/less/tree/javascript.js +17 -10
- data/lib/less/js/lib/less/tree/keyword.js +8 -3
- data/lib/less/js/lib/less/tree/media.js +70 -27
- data/lib/less/js/lib/less/tree/mixin.js +250 -70
- data/lib/less/js/lib/less/tree/negative.js +24 -0
- data/lib/less/js/lib/less/tree/operation.js +38 -13
- data/lib/less/js/lib/less/tree/paren.js +9 -2
- data/lib/less/js/lib/less/tree/quoted.js +29 -10
- data/lib/less/js/lib/less/tree/rule.js +77 -29
- data/lib/less/js/lib/less/tree/ruleset-call.js +16 -0
- data/lib/less/js/lib/less/tree/ruleset.js +445 -107
- data/lib/less/js/lib/less/tree/selector.js +117 -30
- data/lib/less/js/lib/less/tree/unicode-descriptor.js +15 -0
- data/lib/less/js/lib/less/tree/url.js +43 -15
- data/lib/less/js/lib/less/tree/value.js +16 -6
- data/lib/less/js/lib/less/tree/variable.js +26 -8
- data/lib/less/js/lib/less/tree.js +82 -2
- 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 +29 -0
- data/lib/less/js/test/css/comments.css +15 -2
- data/lib/less/js/test/css/compression/compression.css +3 -0
- data/lib/less/js/test/css/css-3.css +73 -2
- data/lib/less/js/test/css/css-escapes.css +4 -0
- data/lib/less/js/test/css/css-guards.css +37 -0
- data/lib/less/js/test/css/css.css +20 -14
- 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 +117 -2
- 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 +7 -3
- 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 +23 -10
- 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 +141 -1
- data/lib/less/js/test/css/merge.css +34 -0
- data/lib/less/js/test/css/mixins-args.css +41 -4
- data/lib/less/js/test/css/mixins-guards-default-func.css +129 -0
- data/lib/less/js/test/css/mixins-guards.css +24 -0
- data/lib/less/js/test/css/mixins-important.css +28 -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 +4 -0
- data/lib/less/js/test/css/mixins.css +70 -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/parens.css +21 -5
- data/lib/less/js/test/css/property-name-interp.css +20 -0
- data/lib/less/js/test/css/scope.css +23 -0
- data/lib/less/js/test/css/selectors.css +84 -0
- data/lib/less/js/test/css/static-urls/urls.css +45 -0
- data/lib/less/js/test/css/strings.css +5 -2
- 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 +22 -4
- data/lib/less/js/test/css/whitespace.css +4 -0
- 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 +37 -4
- data/lib/less/js/test/less/comments.less +21 -3
- data/lib/less/js/test/less/compression/compression.less +36 -0
- data/lib/less/js/test/less/css-3.less +70 -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 +23 -15
- 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 +130 -6
- 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 +7 -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-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 +13 -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 +158 -3
- data/lib/less/js/test/less/merge.less +78 -0
- data/lib/less/js/test/less/mixins-args.less +93 -15
- data/lib/less/js/test/less/mixins-guards-default-func.less +195 -0
- data/lib/less/js/test/less/mixins-guards.less +65 -0
- data/lib/less/js/test/less/mixins-important.less +8 -1
- 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 +4 -1
- data/lib/less/js/test/less/mixins.less +74 -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 +27 -27
- 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 +101 -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 +7 -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 +42 -13
- data/lib/less/js/test/less/whitespace.less +7 -0
- data/lib/less/js/test/less-test.js +251 -65
- 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 +191 -27
- data/lib/less/parser.rb +47 -8
- data/lib/less/version.rb +2 -2
- data/spec/less/loader_spec.rb +45 -0
- data/spec/less/parser_spec.rb +43 -17
- data/spec/less/some/some.css +0 -0
- data/spec/less/some/some.less +4 -0
- metadata +352 -57
- data/lib/less/js/CHANGELOG +0 -41
- data/lib/less/js/Makefile +0 -75
- data/lib/less/js/build/ecma-5.js +0 -120
- data/lib/less/js/build/header.js +0 -7
- data/lib/less/js/lib/less/cssmin.js +0 -355
@@ -1,73 +1,259 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
1
|
+
/*jshint latedef: nofunc */
|
2
|
+
|
3
|
+
module.exports = function() {
|
4
|
+
var path = require('path'),
|
5
|
+
fs = require('fs'),
|
6
|
+
sys = require('util');
|
7
|
+
|
8
|
+
var less = require('../lib/less');
|
9
|
+
var stylize = require('../lib/less/lessc_helper').stylize;
|
10
|
+
|
11
|
+
var globals = Object.keys(global);
|
12
|
+
|
13
|
+
var oneTestOnly = process.argv[2];
|
14
|
+
|
15
|
+
var isVerbose = process.env.npm_config_loglevel === 'verbose';
|
16
|
+
|
17
|
+
var totalTests = 0,
|
18
|
+
failedTests = 0,
|
19
|
+
passedTests = 0;
|
20
|
+
|
21
|
+
|
22
|
+
less.tree.functions.add = function (a, b) {
|
23
|
+
return new(less.tree.Dimension)(a.value + b.value);
|
24
|
+
};
|
25
|
+
less.tree.functions.increment = function (a) {
|
26
|
+
return new(less.tree.Dimension)(a.value + 1);
|
27
|
+
};
|
28
|
+
less.tree.functions._color = function (str) {
|
29
|
+
if (str.value === "evil red") { return new(less.tree.Color)("600"); }
|
30
|
+
};
|
31
|
+
|
32
|
+
function testSourcemap(name, err, compiledLess, doReplacements, sourcemap) {
|
33
|
+
fs.readFile(path.join('test/', name) + '.json', 'utf8', function (e, expectedSourcemap) {
|
34
|
+
sys.print("- " + name + ": ");
|
35
|
+
if (sourcemap === expectedSourcemap) {
|
36
|
+
ok('OK');
|
37
|
+
} else if (err) {
|
38
|
+
fail("ERROR: " + (err && err.message));
|
39
|
+
if (isVerbose) {
|
40
|
+
console.error();
|
41
|
+
console.error(err.stack);
|
42
|
+
}
|
30
43
|
} else {
|
31
|
-
|
44
|
+
difference("FAIL", expectedSourcemap, sourcemap);
|
32
45
|
}
|
33
|
-
sys.puts("");
|
34
46
|
});
|
35
|
-
}
|
36
|
-
|
37
|
-
|
38
|
-
function
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
if (err) {
|
48
|
-
callback(err);
|
47
|
+
}
|
48
|
+
|
49
|
+
function testErrors(name, err, compiledLess, doReplacements) {
|
50
|
+
fs.readFile(path.join('test/less/', name) + '.txt', 'utf8', function (e, expectedErr) {
|
51
|
+
sys.print("- " + name + ": ");
|
52
|
+
expectedErr = doReplacements(expectedErr, 'test/less/errors/');
|
53
|
+
if (!err) {
|
54
|
+
if (compiledLess) {
|
55
|
+
fail("No Error", 'red');
|
56
|
+
} else {
|
57
|
+
fail("No Error, No Output");
|
58
|
+
}
|
49
59
|
} else {
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
}
|
54
|
-
|
60
|
+
var errMessage = less.formatError(err);
|
61
|
+
if (errMessage === expectedErr) {
|
62
|
+
ok('OK');
|
63
|
+
} else {
|
64
|
+
difference("FAIL", expectedErr, errMessage);
|
55
65
|
}
|
56
66
|
}
|
57
67
|
});
|
58
|
-
}
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
68
|
+
}
|
69
|
+
|
70
|
+
function globalReplacements(input, directory) {
|
71
|
+
var p = path.join(process.cwd(), directory),
|
72
|
+
pathimport = path.join(process.cwd(), directory + "import/"),
|
73
|
+
pathesc = p.replace(/[.:/\\]/g, function(a) { return '\\' + (a=='\\' ? '\/' : a); }),
|
74
|
+
pathimportesc = pathimport.replace(/[.:/\\]/g, function(a) { return '\\' + (a=='\\' ? '\/' : a); });
|
75
|
+
|
76
|
+
return input.replace(/\{path\}/g, p)
|
77
|
+
.replace(/\{pathesc\}/g, pathesc)
|
78
|
+
.replace(/\{pathimport\}/g, pathimport)
|
79
|
+
.replace(/\{pathimportesc\}/g, pathimportesc)
|
80
|
+
.replace(/\r\n/g, '\n');
|
81
|
+
}
|
82
|
+
|
83
|
+
function checkGlobalLeaks() {
|
84
|
+
return Object.keys(global).filter(function(v) {
|
85
|
+
return globals.indexOf(v) < 0;
|
86
|
+
});
|
87
|
+
}
|
88
|
+
|
89
|
+
function runTestSet(options, foldername, verifyFunction, nameModifier, doReplacements, getFilename) {
|
90
|
+
foldername = foldername || "";
|
91
|
+
|
92
|
+
if(!doReplacements) {
|
93
|
+
doReplacements = globalReplacements;
|
94
|
+
}
|
95
|
+
|
96
|
+
function getBasename(file) {
|
97
|
+
return foldername + path.basename(file, '.less');
|
98
|
+
}
|
99
|
+
|
100
|
+
fs.readdirSync(path.join('test/less/', foldername)).forEach(function (file) {
|
101
|
+
if (! /\.less/.test(file)) { return; }
|
102
|
+
|
103
|
+
var name = getBasename(file);
|
104
|
+
|
105
|
+
if (oneTestOnly && name !== oneTestOnly) {
|
106
|
+
return;
|
107
|
+
}
|
108
|
+
|
109
|
+
totalTests++;
|
110
|
+
|
111
|
+
if (options.sourceMap) {
|
112
|
+
var sourceMapOutput;
|
113
|
+
options.writeSourceMap = function(output) {
|
114
|
+
sourceMapOutput = output;
|
115
|
+
};
|
116
|
+
options.sourceMapOutputFilename = name + ".css";
|
117
|
+
options.sourceMapBasepath = path.join(process.cwd(), "test/less");
|
118
|
+
options.sourceMapRootpath = "testweb/";
|
119
|
+
}
|
120
|
+
|
121
|
+
options.getVars = function(file) {
|
122
|
+
return JSON.parse(fs.readFileSync(getFilename(getBasename(file), 'vars'), 'utf8'));
|
123
|
+
};
|
124
|
+
|
125
|
+
toCSS(options, path.join('test/less/', foldername + file), function (err, less) {
|
126
|
+
|
127
|
+
if (verifyFunction) {
|
128
|
+
return verifyFunction(name, err, less, doReplacements, sourceMapOutput);
|
129
|
+
}
|
130
|
+
var css_name = name;
|
131
|
+
if(nameModifier) { css_name = nameModifier(name); }
|
132
|
+
fs.readFile(path.join('test/css', css_name) + '.css', 'utf8', function (e, css) {
|
133
|
+
sys.print("- " + css_name + ": ");
|
134
|
+
|
135
|
+
css = css && doReplacements(css, 'test/less/' + foldername);
|
136
|
+
if (less === css) { ok('OK'); }
|
137
|
+
else if (err) {
|
138
|
+
fail("ERROR: " + (err && err.message));
|
139
|
+
if (isVerbose) {
|
140
|
+
console.error();
|
141
|
+
console.error(err.stack);
|
142
|
+
}
|
143
|
+
} else {
|
144
|
+
difference("FAIL", css, less);
|
145
|
+
}
|
146
|
+
});
|
147
|
+
});
|
148
|
+
});
|
149
|
+
}
|
150
|
+
|
151
|
+
function diff(left, right) {
|
152
|
+
require('diff').diffLines(left, right).forEach(function(item) {
|
153
|
+
if(item.added || item.removed) {
|
154
|
+
var text = item.value.replace("\n", String.fromCharCode(182) + "\n");
|
155
|
+
sys.print(stylize(text, item.added ? 'green' : 'red'));
|
156
|
+
} else {
|
157
|
+
sys.print(item.value);
|
158
|
+
}
|
159
|
+
});
|
160
|
+
console.log("");
|
161
|
+
}
|
162
|
+
|
163
|
+
function fail(msg) {
|
164
|
+
console.error(stylize(msg, 'red'));
|
165
|
+
failedTests++;
|
166
|
+
endTest();
|
167
|
+
}
|
168
|
+
|
169
|
+
function difference(msg, left, right) {
|
170
|
+
console.warn(stylize(msg, 'yellow'));
|
171
|
+
failedTests++;
|
172
|
+
|
173
|
+
diff(left, right);
|
174
|
+
endTest();
|
175
|
+
}
|
176
|
+
|
177
|
+
function ok(msg) {
|
178
|
+
console.log(stylize(msg, 'green'));
|
179
|
+
passedTests++;
|
180
|
+
endTest();
|
181
|
+
}
|
182
|
+
|
183
|
+
function endTest() {
|
184
|
+
var leaked = checkGlobalLeaks();
|
185
|
+
if (failedTests + passedTests === totalTests) {
|
186
|
+
console.log("");
|
187
|
+
if (failedTests > 0) {
|
188
|
+
console.error(failedTests + stylize(" Failed", "red") + ", " + passedTests + " passed");
|
189
|
+
} else {
|
190
|
+
console.log(stylize("All Passed ", "green") + passedTests + " run");
|
191
|
+
}
|
192
|
+
if (leaked.length > 0) {
|
193
|
+
console.log("");
|
194
|
+
console.warn(stylize("Global leak detected: ", "red") + leaked.join(', '));
|
195
|
+
}
|
196
|
+
|
197
|
+
if (leaked.length || failedTests) {
|
198
|
+
//process.exit(1);
|
199
|
+
process.on('exit', function() { process.reallyExit(1) });
|
200
|
+
}
|
201
|
+
}
|
202
|
+
}
|
203
|
+
|
204
|
+
function toCSS(options, path, callback) {
|
205
|
+
var css;
|
206
|
+
options = options || {};
|
207
|
+
fs.readFile(path, 'utf8', function (e, str) {
|
208
|
+
if (e) { return callback(e); }
|
209
|
+
|
210
|
+
options.paths = [require('path').dirname(path)];
|
211
|
+
options.filename = require('path').resolve(process.cwd(), path);
|
212
|
+
options.optimization = options.optimization || 0;
|
213
|
+
|
214
|
+
var parser = new(less.Parser)(options);
|
215
|
+
var additionalData = {};
|
216
|
+
if (options.globalVars) {
|
217
|
+
additionalData.globalVars = options.getVars(path);
|
218
|
+
} else if (options.modifyVars) {
|
219
|
+
additionalData.modifyVars = options.getVars(path);
|
220
|
+
}
|
221
|
+
if (options.banner) {
|
222
|
+
additionalData.banner = options.banner;
|
223
|
+
}
|
224
|
+
parser.parse(str, function (err, tree) {
|
225
|
+
if (err) {
|
226
|
+
callback(err);
|
227
|
+
} else {
|
228
|
+
try {
|
229
|
+
css = tree.toCSS(options);
|
230
|
+
var css2 = tree.toCSS(options); // integration test that 2nd call gets same output
|
231
|
+
if (css2 !== css) { throw new Error("css not equal to 2nd call"); }
|
232
|
+
callback(null, css);
|
233
|
+
} catch (e) {
|
234
|
+
callback(e);
|
235
|
+
}
|
236
|
+
}
|
237
|
+
}, additionalData);
|
238
|
+
});
|
239
|
+
}
|
240
|
+
|
241
|
+
function testNoOptions() {
|
242
|
+
totalTests++;
|
243
|
+
try {
|
244
|
+
sys.print("- Integration - creating parser without options: ");
|
245
|
+
new(less.Parser)();
|
246
|
+
} catch(e) {
|
247
|
+
fail(stylize("FAIL\n", "red"));
|
248
|
+
return;
|
249
|
+
}
|
250
|
+
ok(stylize("OK\n", "green"));
|
251
|
+
}
|
252
|
+
|
253
|
+
return {
|
254
|
+
runTestSet: runTestSet,
|
255
|
+
testErrors: testErrors,
|
256
|
+
testSourcemap: testSourcemap,
|
257
|
+
testNoOptions: testNoOptions
|
70
258
|
};
|
71
|
-
|
72
|
-
'\033[' + styles[style][1] + 'm';
|
73
|
-
}
|
259
|
+
};
|
@@ -0,0 +1,15 @@
|
|
1
|
+
function initRhinoTest() {
|
2
|
+
process = { title: 'dummy' };
|
3
|
+
|
4
|
+
less.tree.functions.add = function (a, b) {
|
5
|
+
return new(less.tree.Dimension)(a.value + b.value);
|
6
|
+
};
|
7
|
+
less.tree.functions.increment = function (a) {
|
8
|
+
return new(less.tree.Dimension)(a.value + 1);
|
9
|
+
};
|
10
|
+
less.tree.functions._color = function (str) {
|
11
|
+
if (str.value === "evil red") { return new(less.tree.Color)("600"); }
|
12
|
+
};
|
13
|
+
}
|
14
|
+
|
15
|
+
initRhinoTest();
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"sourcemaps/basic.css","sources":["testweb/sourcemaps/imported.css","testweb/sourcemaps/basic.less"],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;ACAA;EACE,YAAA;EAJA,UAAA;EAWA,iBAAA;EALA,WAAA;EACA,mBAAA;;AAJF,EASE;AATF,EASM;EACF,gBAAA;;AACA,EAFF,GAEI,KAFJ;AAEE,EAFF,GAEI,KAFA;AAEF,EAFE,GAEA,KAFJ;AAEE,EAFE,GAEA,KAFA;EAGA,UAAA;;AALN;AAAI;AAUJ;EATE,iBAAA;;AADF,EAEE;AAFE,EAEF;AAFF,EAEM;AAFF,EAEE;AAQN,OARE;AAQF,OARM;EACF,gBAAA;;AACA,EAFF,GAEI,KAFJ;AAEE,EAFF,GAEI,KAFJ;AAEE,EAFF,GAEI,KAFA;AAEF,EAFF,GAEI,KAFA;AAEF,EAFF,GAEI,KAFJ;AAEE,EAFF,GAEI,KAFJ;AAEE,EAFF,GAEI,KAFA;AAEF,EAFF,GAEI,KAFA;AAEF,EAFE,GAEA,KAFJ;AAEE,EAFE,GAEA,KAFJ;AAEE,EAFE,GAEA,KAFA;AAEF,EAFE,GAEA,KAFA;AAEF,EAFE,GAEA,KAFJ;AAEE,EAFE,GAEA,KAFJ;AAEE,EAFE,GAEA,KAFA;AAEF,EAFE,GAEA,KAFA;AAQN,OARE,GAQF,UARE;AAQF,OARE,GAEI,KAFJ;AAQF,OARE,GAQF,UARM;AAQN,OARE,GAEI,KAFA;AAEF,EAFF,GAQF,UARE;AAEE,EAFF,GAQF,UARM;AAQN,OARM,GAQN,UARE;AAQF,OARM,GAEA,KAFJ;AAQF,OARM,GAQN,UARM;AAQN,OARM,GAEA,KAFA;AAEF,EAFE,GAQN,UARE;AAEE,EAFE,GAQN,UARM;EAGA,UAAA;;AAKN;EACE,WAAA"}
|
@@ -0,0 +1,17 @@
|
|
1
|
+
<html>
|
2
|
+
<link type="text/css" rel="stylesheet" media="all" href="import.css">
|
3
|
+
<link type="text/css" rel="stylesheet" media="all" href="basic.css">
|
4
|
+
<head>
|
5
|
+
</head>
|
6
|
+
<body>
|
7
|
+
<div id="import-test">id import-test</div>
|
8
|
+
<div id="import">id import-test</div>
|
9
|
+
<div class="imported inline">class imported inline</div>
|
10
|
+
<div id="mixin">class mixin</div>
|
11
|
+
<div class="a">class a</div>
|
12
|
+
<div class="b">class b</div>
|
13
|
+
<div class="b">class b<div class="c">class c</div></div>
|
14
|
+
<div class="a">class a<div class="d">class d</div></div>
|
15
|
+
<div class="extend">class extend<div class="c">class c</div></div>
|
16
|
+
</body>
|
17
|
+
</html>
|
data/lib/less/loader.rb
CHANGED
@@ -1,69 +1,233 @@
|
|
1
1
|
require 'pathname'
|
2
2
|
require 'commonjs'
|
3
|
+
require 'net/http'
|
4
|
+
require 'uri'
|
5
|
+
require 'base64'
|
3
6
|
|
4
7
|
module Less
|
5
8
|
class Loader
|
6
|
-
|
9
|
+
|
7
10
|
attr_reader :environment
|
8
|
-
|
11
|
+
|
9
12
|
def initialize
|
10
13
|
context_wrapper = Less::JavaScript.context_wrapper.instance
|
11
14
|
@context = context_wrapper.unwrap
|
12
15
|
@context['process'] = Process.new
|
13
16
|
@context['console'] = Console.new
|
17
|
+
@context['Buffer'] = Buffer
|
14
18
|
path = Pathname(__FILE__).dirname.join('js', 'lib')
|
15
19
|
@environment = CommonJS::Environment.new(@context, :path => path.to_s)
|
16
|
-
@environment.native('path', Path
|
17
|
-
@environment.native('util',
|
18
|
-
@environment.native('fs',
|
20
|
+
@environment.native('path', Path)
|
21
|
+
@environment.native('util', Util)
|
22
|
+
@environment.native('fs', FS)
|
23
|
+
@environment.native('url', Url)
|
24
|
+
@environment.native('http', Http)
|
19
25
|
end
|
20
|
-
|
26
|
+
|
21
27
|
def require(module_id)
|
22
28
|
@environment.require(module_id)
|
23
29
|
end
|
24
|
-
|
25
|
-
#
|
26
|
-
|
27
|
-
class
|
28
|
-
def
|
29
|
-
|
30
|
+
|
31
|
+
# JS exports (required by less.js) :
|
32
|
+
|
33
|
+
class Process # :nodoc:
|
34
|
+
def exit(*args)
|
35
|
+
warn("JS process.exit(#{args.first}) called from: \n#{caller.join("\n")}")
|
30
36
|
end
|
37
|
+
end
|
31
38
|
|
32
|
-
|
39
|
+
class Console # :nodoc:
|
40
|
+
def log(*msgs)
|
41
|
+
puts msgs.join(', ')
|
42
|
+
end
|
43
|
+
|
44
|
+
def warn(*msgs)
|
45
|
+
$stderr.puts msgs.join(', ')
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
# stubbed JS modules (required by less.js) :
|
50
|
+
|
51
|
+
module Path # :nodoc:
|
52
|
+
def self.join(*components)
|
53
|
+
# node.js expands path on join
|
54
|
+
File.expand_path(File.join(*components))
|
55
|
+
end
|
56
|
+
|
57
|
+
def self.dirname(path)
|
33
58
|
File.dirname(path)
|
34
59
|
end
|
35
60
|
|
36
|
-
def basename(path)
|
61
|
+
def self.basename(path)
|
37
62
|
File.basename(path)
|
38
63
|
end
|
64
|
+
|
65
|
+
def self.extname(path)
|
66
|
+
File.extname(path)
|
67
|
+
end
|
68
|
+
|
69
|
+
def self.resolve(path)
|
70
|
+
File.basename(path)
|
71
|
+
end
|
72
|
+
|
39
73
|
end
|
40
|
-
|
41
|
-
|
42
|
-
|
74
|
+
|
75
|
+
module Util # :nodoc:
|
76
|
+
|
77
|
+
def self.error(*errors)
|
43
78
|
raise errors.join(' ')
|
44
79
|
end
|
80
|
+
|
81
|
+
def self.puts(*args)
|
82
|
+
args.each { |arg| STDOUT.puts(arg) }
|
83
|
+
end
|
84
|
+
|
45
85
|
end
|
46
86
|
|
47
|
-
|
48
|
-
|
87
|
+
module FS # :nodoc:
|
88
|
+
|
89
|
+
def self.statSync(path)
|
49
90
|
File.stat(path)
|
50
91
|
end
|
51
92
|
|
52
|
-
def readFile(path, encoding, callback)
|
93
|
+
def self.readFile(path, encoding, callback)
|
53
94
|
callback.call(nil, File.read(path))
|
54
95
|
end
|
96
|
+
|
97
|
+
def self.readFileSync(path, encoding = nil)
|
98
|
+
buf = Buffer.new(File.read(path), encoding)
|
99
|
+
encoding.nil? ? buf : buf.toString(encoding)
|
100
|
+
end
|
101
|
+
|
55
102
|
end
|
56
103
|
|
57
|
-
class
|
58
|
-
|
104
|
+
class Buffer # :nodoc:
|
105
|
+
|
106
|
+
attr_accessor :data
|
107
|
+
|
108
|
+
def initialize(data, encoding = nil)
|
109
|
+
unless data.is_a? String
|
110
|
+
data = data.to_ruby
|
111
|
+
end
|
112
|
+
@data = data
|
113
|
+
end
|
114
|
+
|
115
|
+
def length
|
116
|
+
@data.length
|
117
|
+
end
|
118
|
+
|
119
|
+
def toString(encoding = nil, begPos = 0, endPos = length)
|
120
|
+
data = @data[ begPos..endPos ]
|
121
|
+
if encoding == 'base64'
|
122
|
+
data = Base64.encode64(data)
|
123
|
+
data.delete!("\n"); data
|
124
|
+
else # encoding == 'binary'
|
125
|
+
data
|
126
|
+
end
|
59
127
|
end
|
60
128
|
end
|
61
129
|
|
62
|
-
|
63
|
-
|
64
|
-
|
130
|
+
module Url # :nodoc:
|
131
|
+
|
132
|
+
def self.resolve(*args)
|
133
|
+
URI.join(*args)
|
134
|
+
end
|
135
|
+
|
136
|
+
def self.parse(url_string)
|
137
|
+
u = URI.parse(url_string)
|
138
|
+
result = {}
|
139
|
+
result['protocol'] = u.scheme + ':' if u.scheme
|
140
|
+
result['hostname'] = u.host if u.host
|
141
|
+
result['pathname'] = u.path if u.path
|
142
|
+
result['port'] = u.port if u.port
|
143
|
+
result['query'] = u.query if u.query
|
144
|
+
result['search'] = '?' + u.query if u.query
|
145
|
+
result['hash'] = '#' + u.fragment if u.fragment
|
146
|
+
result
|
147
|
+
end
|
148
|
+
|
149
|
+
end
|
150
|
+
|
151
|
+
module Http # :nodoc:
|
152
|
+
|
153
|
+
def self.get(options, callback)
|
154
|
+
err = nil
|
155
|
+
begin
|
156
|
+
#less always sends options as an object, so no need to check for string
|
157
|
+
uri_hash = {}
|
158
|
+
uri_hash[:host] = options['hostname'] ? options['hostname'] : options['host']
|
159
|
+
path_components = options['path'] ? options['path'].split('?', 2) : [''] #have to do this because node expects path and query to be combined
|
160
|
+
if path_components.length > 1
|
161
|
+
uri_hash[:path] = path_components[0]
|
162
|
+
uri_hash[:query] = path_components[0]
|
163
|
+
else
|
164
|
+
uri_hash[:path] = path_components[0]
|
165
|
+
end
|
166
|
+
uri_hash[:port] = options['port'] ? options['port'] : Net::HTTP.http_default_port
|
167
|
+
uri_hash[:scheme] = uri_hash[:port] == Net::HTTP.https_default_port ? 'https' : 'http' #have to check this way because of node's http.get
|
168
|
+
case uri_hash[:scheme]
|
169
|
+
when 'http'
|
170
|
+
uri = URI::HTTP.build(uri_hash)
|
171
|
+
when 'https'
|
172
|
+
uri = URI::HTTPS.build(uri_hash)
|
173
|
+
else
|
174
|
+
raise Exception, 'Less import only supports http and https'
|
175
|
+
end
|
176
|
+
http = Net::HTTP.new uri.host, uri.port
|
177
|
+
if uri.scheme == 'https'
|
178
|
+
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
|
179
|
+
http.use_ssl = true
|
180
|
+
end
|
181
|
+
response = nil
|
182
|
+
http.start do |req|
|
183
|
+
response = req.get(uri.to_s)
|
184
|
+
end
|
185
|
+
callback.call ServerResponse.new(response.read_body, response.code.to_i)
|
186
|
+
rescue => e
|
187
|
+
err = e.message
|
188
|
+
ensure
|
189
|
+
ret = HttpGetResult.new(err)
|
190
|
+
end
|
191
|
+
ret
|
192
|
+
end
|
193
|
+
|
194
|
+
class HttpGetResult
|
195
|
+
attr_accessor :err
|
196
|
+
|
197
|
+
def initialize(err)
|
198
|
+
@err = err
|
199
|
+
end
|
200
|
+
|
201
|
+
def on(event, callback)
|
202
|
+
case event
|
203
|
+
when 'error'
|
204
|
+
callback.call(@err) if @err #only call when error exists
|
205
|
+
else
|
206
|
+
callback.call()
|
207
|
+
end
|
208
|
+
end
|
65
209
|
end
|
210
|
+
|
211
|
+
class ServerResponse
|
212
|
+
attr_accessor :statusCode
|
213
|
+
attr_accessor :data #faked because ServerResponse acutally implements WriteableStream
|
214
|
+
|
215
|
+
def initialize(data, status_code)
|
216
|
+
@data = data
|
217
|
+
@statusCode = status_code
|
218
|
+
end
|
219
|
+
|
220
|
+
def on(event, callback)
|
221
|
+
case event
|
222
|
+
when 'data'
|
223
|
+
callback.call(@data)
|
224
|
+
else
|
225
|
+
callback.call()
|
226
|
+
end
|
227
|
+
end
|
228
|
+
end
|
229
|
+
|
66
230
|
end
|
67
|
-
|
231
|
+
|
68
232
|
end
|
69
|
-
end
|
233
|
+
end
|