haml 3.2.0.alpha.10 → 3.2.0.alpha.13
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of haml might be problematic. Click here for more details.
- data/.yardopts +19 -7
- data/CHANGELOG.md +1224 -0
- data/FAQ.md +157 -0
- data/README.md +99 -62
- data/REFERENCE.md +1404 -0
- data/Rakefile +52 -341
- data/init.rb +1 -18
- data/lib/haml.rb +6 -30
- data/lib/haml/buffer.rb +37 -16
- data/lib/haml/compiler.rb +52 -13
- data/lib/haml/engine.rb +61 -44
- data/lib/haml/exec.rb +21 -4
- data/lib/haml/filters.rb +136 -166
- data/lib/haml/helpers.rb +37 -10
- data/lib/haml/helpers/action_view_extensions.rb +2 -1
- data/lib/haml/helpers/action_view_mods.rb +67 -181
- data/lib/haml/helpers/rails_323_textarea_fix.rb +39 -0
- data/lib/haml/helpers/xss_mods.rb +9 -11
- data/lib/haml/html.rb +22 -9
- data/lib/haml/html/erb.rb +1 -1
- data/lib/haml/parser.rb +22 -15
- data/lib/haml/railtie.rb +2 -13
- data/lib/haml/template.rb +18 -85
- data/lib/haml/template/options.rb +1 -1
- data/lib/haml/template/plugin.rb +15 -101
- data/lib/haml/util.rb +120 -603
- data/lib/haml/version.rb +1 -107
- data/test/{haml/engine_test.rb → engine_test.rb} +137 -143
- data/test/{haml/erb → erb}/_av_partial_1.erb +1 -1
- data/test/{haml/erb → erb}/_av_partial_2.erb +1 -1
- data/test/{haml/erb → erb}/action_view.erb +1 -1
- data/test/{haml/erb → erb}/standard.erb +0 -0
- data/test/filters_test.rb +141 -0
- data/test/gemfiles/Gemfile.rails-3.0.x +4 -6
- data/test/gemfiles/Gemfile.rails-3.1.x +5 -6
- data/test/gemfiles/Gemfile.rails-3.2.x +6 -0
- data/test/haml-spec/LICENSE +14 -0
- data/test/{haml/spec → haml-spec}/README.md +26 -17
- data/test/haml-spec/lua_haml_spec.lua +38 -0
- data/test/haml-spec/perl_haml_test.pl +81 -0
- data/test/haml-spec/ruby_haml_test.rb +23 -0
- data/test/{haml/spec → haml-spec}/tests.json +132 -54
- data/test/{haml/helper_test.rb → helper_test.rb} +50 -36
- data/test/{haml/html2haml → html2haml}/erb_tests.rb +0 -0
- data/test/{haml/html2haml_test.rb → html2haml_test.rb} +11 -5
- data/test/{haml/markaby → markaby}/standard.mab +0 -0
- data/test/{haml/mocks → mocks}/article.rb +0 -0
- data/test/{haml/results → results}/content_for_layout.xhtml +0 -0
- data/test/{haml/results → results}/eval_suppressed.xhtml +0 -0
- data/test/{haml/results → results}/helpers.xhtml +0 -0
- data/test/{haml/results → results}/helpful.xhtml +0 -0
- data/test/{haml/results → results}/just_stuff.xhtml +0 -0
- data/test/{haml/results → results}/list.xhtml +0 -0
- data/test/{haml/results → results}/nuke_inner_whitespace.xhtml +0 -0
- data/test/{haml/results → results}/nuke_outer_whitespace.xhtml +0 -0
- data/test/{haml/results → results}/original_engine.xhtml +0 -0
- data/test/{haml/results → results}/partial_layout.xhtml +0 -0
- data/test/{haml/results → results}/partials.xhtml +0 -0
- data/test/{haml/results → results}/render_layout.xhtml +0 -0
- data/test/{haml/results → results}/silent_script.xhtml +1 -1
- data/test/{haml/results → results}/standard.xhtml +0 -0
- data/test/{haml/results → results}/tag_parsing.xhtml +0 -0
- data/test/{haml/results → results}/very_basic.xhtml +0 -0
- data/test/{haml/results → results}/whitespace_handling.xhtml +46 -50
- data/test/{haml/template_test.rb → template_test.rb} +20 -81
- data/test/{haml/templates → templates}/_av_partial_1.haml +1 -1
- data/test/{haml/templates → templates}/_av_partial_1_ugly.haml +1 -1
- data/test/{haml/templates → templates}/_av_partial_2.haml +1 -1
- data/test/{haml/templates → templates}/_av_partial_2_ugly.haml +1 -1
- data/test/{haml/templates → templates}/_layout.erb +0 -0
- data/test/{haml/templates → templates}/_layout_for_partial.haml +0 -0
- data/test/{haml/templates → templates}/_partial.haml +0 -0
- data/test/{haml/templates → templates}/_text_area.haml +0 -0
- data/test/{haml/templates → templates}/action_view.haml +1 -1
- data/test/{haml/templates → templates}/action_view_ugly.haml +1 -1
- data/test/{haml/templates → templates}/breakage.haml +0 -0
- data/test/{haml/templates → templates}/content_for_layout.haml +0 -0
- data/test/{haml/templates → templates}/eval_suppressed.haml +0 -0
- data/test/{haml/templates → templates}/helpers.haml +0 -0
- data/test/{haml/templates → templates}/helpful.haml +0 -0
- data/test/{haml/templates → templates}/just_stuff.haml +0 -0
- data/test/{haml/templates → templates}/list.haml +0 -0
- data/test/{haml/templates → templates}/nuke_inner_whitespace.haml +0 -0
- data/test/{haml/templates → templates}/nuke_outer_whitespace.haml +0 -0
- data/test/{haml/templates → templates}/original_engine.haml +0 -0
- data/test/templates/partial_layout.haml +3 -0
- data/test/{haml/templates → templates}/partialize.haml +0 -0
- data/test/{haml/templates → templates}/partials.haml +0 -0
- data/test/{haml/templates → templates}/render_layout.haml +0 -0
- data/test/{haml/templates → templates}/silent_script.haml +2 -2
- data/test/{haml/templates → templates}/standard.haml +0 -0
- data/test/{haml/templates → templates}/standard_ugly.haml +0 -0
- data/test/{haml/templates → templates}/tag_parsing.haml +0 -0
- data/test/{haml/templates → templates}/very_basic.haml +0 -0
- data/test/{haml/templates → templates}/whitespace_handling.haml +0 -0
- data/test/test_helper.rb +42 -34
- data/test/util_test.rb +80 -0
- metadata +259 -427
- data/CONTRIBUTING +0 -3
- data/REVISION +0 -1
- data/VERSION +0 -1
- data/VERSION_NAME +0 -1
- data/extra/update_watch.rb +0 -13
- data/lib/haml/root.rb +0 -7
- data/lib/haml/shared.rb +0 -78
- data/lib/haml/template/patch.rb +0 -58
- data/lib/sass.rb +0 -8
- data/lib/sass/plugin.rb +0 -10
- data/lib/sass/rails2_shim.rb +0 -9
- data/lib/sass/rails3_shim.rb +0 -16
- data/test/benchmark.rb +0 -91
- data/test/gemfiles/Gemfile.rails-2.0.x +0 -8
- data/test/gemfiles/Gemfile.rails-2.0.x.lock +0 -38
- data/test/gemfiles/Gemfile.rails-2.1.x +0 -8
- data/test/gemfiles/Gemfile.rails-2.1.x.lock +0 -38
- data/test/gemfiles/Gemfile.rails-2.2.x +0 -8
- data/test/gemfiles/Gemfile.rails-2.2.x.lock +0 -38
- data/test/gemfiles/Gemfile.rails-2.3.x +0 -8
- data/test/gemfiles/Gemfile.rails-2.3.x.lock +0 -40
- data/test/gemfiles/Gemfile.rails-3.0.x.lock +0 -85
- data/test/gemfiles/Gemfile.rails-3.1.x.lock +0 -98
- data/test/gemfiles/Gemfile.rails-xss-2.3.x +0 -9
- data/test/gemfiles/Gemfile.rails-xss-2.3.x.lock +0 -42
- data/test/haml/results/filters.xhtml +0 -62
- data/test/haml/spec/lua_haml_spec.lua +0 -30
- data/test/haml/spec/ruby_haml_test.rb +0 -19
- data/test/haml/spec_test.rb +0 -44
- data/test/haml/templates/filters.haml +0 -66
- data/test/haml/templates/partial_layout.haml +0 -10
- data/test/haml/util_test.rb +0 -300
- data/test/linked_rails.rb +0 -42
- data/vendor/sass/CONTRIBUTING +0 -3
- data/vendor/sass/MIT-LICENSE +0 -20
- data/vendor/sass/README.md +0 -201
- data/vendor/sass/Rakefile +0 -339
- data/vendor/sass/TODO +0 -39
- data/vendor/sass/VERSION +0 -1
- data/vendor/sass/VERSION_NAME +0 -1
- data/vendor/sass/bin/sass +0 -8
- data/vendor/sass/bin/sass-convert +0 -7
- data/vendor/sass/bin/scss +0 -8
- data/vendor/sass/doc-src/FAQ.md +0 -35
- data/vendor/sass/doc-src/INDENTED_SYNTAX.md +0 -210
- data/vendor/sass/doc-src/SASS_CHANGELOG.md +0 -2327
- data/vendor/sass/doc-src/SASS_REFERENCE.md +0 -1965
- data/vendor/sass/doc-src/SCSS_FOR_SASS_USERS.md +0 -155
- data/vendor/sass/ext/extconf.rb +0 -10
- data/vendor/sass/extra/update_watch.rb +0 -13
- data/vendor/sass/init.rb +0 -18
- data/vendor/sass/lib/sass.rb +0 -73
- data/vendor/sass/lib/sass/cache_stores.rb +0 -15
- data/vendor/sass/lib/sass/cache_stores/base.rb +0 -86
- data/vendor/sass/lib/sass/cache_stores/chain.rb +0 -33
- data/vendor/sass/lib/sass/cache_stores/filesystem.rb +0 -60
- data/vendor/sass/lib/sass/cache_stores/memory.rb +0 -47
- data/vendor/sass/lib/sass/cache_stores/null.rb +0 -25
- data/vendor/sass/lib/sass/callbacks.rb +0 -66
- data/vendor/sass/lib/sass/css.rb +0 -295
- data/vendor/sass/lib/sass/engine.rb +0 -878
- data/vendor/sass/lib/sass/environment.rb +0 -166
- data/vendor/sass/lib/sass/error.rb +0 -201
- data/vendor/sass/lib/sass/exec.rb +0 -672
- data/vendor/sass/lib/sass/importers.rb +0 -22
- data/vendor/sass/lib/sass/importers/base.rb +0 -139
- data/vendor/sass/lib/sass/importers/filesystem.rb +0 -149
- data/vendor/sass/lib/sass/less.rb +0 -382
- data/vendor/sass/lib/sass/logger.rb +0 -15
- data/vendor/sass/lib/sass/logger/base.rb +0 -32
- data/vendor/sass/lib/sass/logger/log_level.rb +0 -49
- data/vendor/sass/lib/sass/plugin.rb +0 -132
- data/vendor/sass/lib/sass/plugin/compiler.rb +0 -383
- data/vendor/sass/lib/sass/plugin/configuration.rb +0 -123
- data/vendor/sass/lib/sass/plugin/generic.rb +0 -15
- data/vendor/sass/lib/sass/plugin/merb.rb +0 -48
- data/vendor/sass/lib/sass/plugin/rack.rb +0 -60
- data/vendor/sass/lib/sass/plugin/rails.rb +0 -47
- data/vendor/sass/lib/sass/plugin/staleness_checker.rb +0 -173
- data/vendor/sass/lib/sass/railtie.rb +0 -9
- data/vendor/sass/lib/sass/repl.rb +0 -58
- data/vendor/sass/lib/sass/root.rb +0 -7
- data/vendor/sass/lib/sass/script.rb +0 -40
- data/vendor/sass/lib/sass/script/bool.rb +0 -18
- data/vendor/sass/lib/sass/script/color.rb +0 -480
- data/vendor/sass/lib/sass/script/css_lexer.rb +0 -29
- data/vendor/sass/lib/sass/script/css_parser.rb +0 -31
- data/vendor/sass/lib/sass/script/funcall.rb +0 -175
- data/vendor/sass/lib/sass/script/functions.rb +0 -1386
- data/vendor/sass/lib/sass/script/interpolation.rb +0 -79
- data/vendor/sass/lib/sass/script/lexer.rb +0 -339
- data/vendor/sass/lib/sass/script/list.rb +0 -83
- data/vendor/sass/lib/sass/script/literal.rb +0 -250
- data/vendor/sass/lib/sass/script/node.rb +0 -99
- data/vendor/sass/lib/sass/script/number.rb +0 -452
- data/vendor/sass/lib/sass/script/operation.rb +0 -99
- data/vendor/sass/lib/sass/script/parser.rb +0 -474
- data/vendor/sass/lib/sass/script/string.rb +0 -51
- data/vendor/sass/lib/sass/script/string_interpolation.rb +0 -103
- data/vendor/sass/lib/sass/script/unary_operation.rb +0 -64
- data/vendor/sass/lib/sass/script/variable.rb +0 -59
- data/vendor/sass/lib/sass/scss.rb +0 -17
- data/vendor/sass/lib/sass/scss/css_parser.rb +0 -46
- data/vendor/sass/lib/sass/scss/parser.rb +0 -960
- data/vendor/sass/lib/sass/scss/rx.rb +0 -128
- data/vendor/sass/lib/sass/scss/sass_parser.rb +0 -11
- data/vendor/sass/lib/sass/scss/script_lexer.rb +0 -15
- data/vendor/sass/lib/sass/scss/script_parser.rb +0 -25
- data/vendor/sass/lib/sass/scss/static_parser.rb +0 -40
- data/vendor/sass/lib/sass/selector.rb +0 -361
- data/vendor/sass/lib/sass/selector/abstract_sequence.rb +0 -62
- data/vendor/sass/lib/sass/selector/comma_sequence.rb +0 -81
- data/vendor/sass/lib/sass/selector/sequence.rb +0 -233
- data/vendor/sass/lib/sass/selector/simple.rb +0 -113
- data/vendor/sass/lib/sass/selector/simple_sequence.rb +0 -134
- data/vendor/sass/lib/sass/shared.rb +0 -78
- data/vendor/sass/lib/sass/tree/charset_node.rb +0 -22
- data/vendor/sass/lib/sass/tree/comment_node.rb +0 -90
- data/vendor/sass/lib/sass/tree/debug_node.rb +0 -18
- data/vendor/sass/lib/sass/tree/directive_node.rb +0 -23
- data/vendor/sass/lib/sass/tree/each_node.rb +0 -24
- data/vendor/sass/lib/sass/tree/extend_node.rb +0 -29
- data/vendor/sass/lib/sass/tree/for_node.rb +0 -36
- data/vendor/sass/lib/sass/tree/function_node.rb +0 -27
- data/vendor/sass/lib/sass/tree/if_node.rb +0 -52
- data/vendor/sass/lib/sass/tree/import_node.rb +0 -68
- data/vendor/sass/lib/sass/tree/media_node.rb +0 -32
- data/vendor/sass/lib/sass/tree/mixin_def_node.rb +0 -27
- data/vendor/sass/lib/sass/tree/mixin_node.rb +0 -32
- data/vendor/sass/lib/sass/tree/node.rb +0 -201
- data/vendor/sass/lib/sass/tree/prop_node.rb +0 -148
- data/vendor/sass/lib/sass/tree/return_node.rb +0 -18
- data/vendor/sass/lib/sass/tree/root_node.rb +0 -28
- data/vendor/sass/lib/sass/tree/rule_node.rb +0 -136
- data/vendor/sass/lib/sass/tree/variable_node.rb +0 -30
- data/vendor/sass/lib/sass/tree/visitors/base.rb +0 -75
- data/vendor/sass/lib/sass/tree/visitors/check_nesting.rb +0 -133
- data/vendor/sass/lib/sass/tree/visitors/convert.rb +0 -260
- data/vendor/sass/lib/sass/tree/visitors/cssize.rb +0 -175
- data/vendor/sass/lib/sass/tree/visitors/deep_copy.rb +0 -87
- data/vendor/sass/lib/sass/tree/visitors/perform.rb +0 -332
- data/vendor/sass/lib/sass/tree/visitors/set_options.rb +0 -97
- data/vendor/sass/lib/sass/tree/visitors/to_css.rb +0 -210
- data/vendor/sass/lib/sass/tree/warn_node.rb +0 -18
- data/vendor/sass/lib/sass/tree/while_node.rb +0 -18
- data/vendor/sass/lib/sass/util.rb +0 -721
- data/vendor/sass/lib/sass/util/subset_map.rb +0 -101
- data/vendor/sass/lib/sass/version.rb +0 -112
- data/vendor/sass/rails/init.rb +0 -1
- data/vendor/sass/sass.gemspec +0 -33
- data/vendor/sass/test/Gemfile +0 -4
- data/vendor/sass/test/Gemfile.lock +0 -19
- data/vendor/sass/test/sass/cache_test.rb +0 -89
- data/vendor/sass/test/sass/callbacks_test.rb +0 -61
- data/vendor/sass/test/sass/conversion_test.rb +0 -1199
- data/vendor/sass/test/sass/css2sass_test.rb +0 -373
- data/vendor/sass/test/sass/data/hsl-rgb.txt +0 -319
- data/vendor/sass/test/sass/engine_test.rb +0 -2567
- data/vendor/sass/test/sass/extend_test.rb +0 -1348
- data/vendor/sass/test/sass/fixtures/test_staleness_check_across_importers.css +0 -1
- data/vendor/sass/test/sass/fixtures/test_staleness_check_across_importers.scss +0 -1
- data/vendor/sass/test/sass/functions_test.rb +0 -1038
- data/vendor/sass/test/sass/importer_test.rb +0 -192
- data/vendor/sass/test/sass/less_conversion_test.rb +0 -653
- data/vendor/sass/test/sass/logger_test.rb +0 -58
- data/vendor/sass/test/sass/mock_importer.rb +0 -49
- data/vendor/sass/test/sass/more_results/more1.css +0 -9
- data/vendor/sass/test/sass/more_results/more1_with_line_comments.css +0 -26
- data/vendor/sass/test/sass/more_results/more_import.css +0 -29
- data/vendor/sass/test/sass/more_templates/_more_partial.sass +0 -2
- data/vendor/sass/test/sass/more_templates/more1.sass +0 -23
- data/vendor/sass/test/sass/more_templates/more_import.sass +0 -11
- data/vendor/sass/test/sass/plugin_test.rb +0 -472
- data/vendor/sass/test/sass/results/alt.css +0 -4
- data/vendor/sass/test/sass/results/basic.css +0 -9
- data/vendor/sass/test/sass/results/compact.css +0 -5
- data/vendor/sass/test/sass/results/complex.css +0 -86
- data/vendor/sass/test/sass/results/compressed.css +0 -1
- data/vendor/sass/test/sass/results/expanded.css +0 -19
- data/vendor/sass/test/sass/results/if.css +0 -3
- data/vendor/sass/test/sass/results/import.css +0 -31
- data/vendor/sass/test/sass/results/import_charset.css +0 -4
- data/vendor/sass/test/sass/results/import_charset_1_8.css +0 -4
- data/vendor/sass/test/sass/results/import_charset_ibm866.css +0 -4
- data/vendor/sass/test/sass/results/line_numbers.css +0 -49
- data/vendor/sass/test/sass/results/mixins.css +0 -95
- data/vendor/sass/test/sass/results/multiline.css +0 -24
- data/vendor/sass/test/sass/results/nested.css +0 -22
- data/vendor/sass/test/sass/results/options.css +0 -1
- data/vendor/sass/test/sass/results/parent_ref.css +0 -13
- data/vendor/sass/test/sass/results/script.css +0 -16
- data/vendor/sass/test/sass/results/scss_import.css +0 -31
- data/vendor/sass/test/sass/results/scss_importee.css +0 -2
- data/vendor/sass/test/sass/results/subdir/nested_subdir/nested_subdir.css +0 -1
- data/vendor/sass/test/sass/results/subdir/subdir.css +0 -3
- data/vendor/sass/test/sass/results/units.css +0 -11
- data/vendor/sass/test/sass/results/warn.css +0 -0
- data/vendor/sass/test/sass/results/warn_imported.css +0 -0
- data/vendor/sass/test/sass/script_conversion_test.rb +0 -285
- data/vendor/sass/test/sass/script_test.rb +0 -514
- data/vendor/sass/test/sass/scss/css_test.rb +0 -922
- data/vendor/sass/test/sass/scss/rx_test.rb +0 -156
- data/vendor/sass/test/sass/scss/scss_test.rb +0 -1273
- data/vendor/sass/test/sass/scss/test_helper.rb +0 -37
- data/vendor/sass/test/sass/templates/_imported_charset_ibm866.sass +0 -4
- data/vendor/sass/test/sass/templates/_imported_charset_utf8.sass +0 -4
- data/vendor/sass/test/sass/templates/_partial.sass +0 -2
- data/vendor/sass/test/sass/templates/alt.sass +0 -16
- data/vendor/sass/test/sass/templates/basic.sass +0 -23
- data/vendor/sass/test/sass/templates/bork1.sass +0 -2
- data/vendor/sass/test/sass/templates/bork2.sass +0 -2
- data/vendor/sass/test/sass/templates/bork3.sass +0 -2
- data/vendor/sass/test/sass/templates/bork4.sass +0 -2
- data/vendor/sass/test/sass/templates/bork5.sass +0 -3
- data/vendor/sass/test/sass/templates/compact.sass +0 -17
- data/vendor/sass/test/sass/templates/complex.sass +0 -305
- data/vendor/sass/test/sass/templates/compressed.sass +0 -15
- data/vendor/sass/test/sass/templates/expanded.sass +0 -17
- data/vendor/sass/test/sass/templates/if.sass +0 -11
- data/vendor/sass/test/sass/templates/import.sass +0 -12
- data/vendor/sass/test/sass/templates/import_charset.sass +0 -7
- data/vendor/sass/test/sass/templates/import_charset_1_8.sass +0 -4
- data/vendor/sass/test/sass/templates/import_charset_ibm866.sass +0 -9
- data/vendor/sass/test/sass/templates/importee.less +0 -2
- data/vendor/sass/test/sass/templates/importee.sass +0 -19
- data/vendor/sass/test/sass/templates/line_numbers.sass +0 -13
- data/vendor/sass/test/sass/templates/mixin_bork.sass +0 -5
- data/vendor/sass/test/sass/templates/mixins.sass +0 -76
- data/vendor/sass/test/sass/templates/multiline.sass +0 -20
- data/vendor/sass/test/sass/templates/nested.sass +0 -25
- data/vendor/sass/test/sass/templates/nested_bork1.sass +0 -2
- data/vendor/sass/test/sass/templates/nested_bork2.sass +0 -2
- data/vendor/sass/test/sass/templates/nested_bork3.sass +0 -2
- data/vendor/sass/test/sass/templates/nested_bork4.sass +0 -2
- data/vendor/sass/test/sass/templates/nested_bork5.sass +0 -2
- data/vendor/sass/test/sass/templates/nested_import.sass +0 -2
- data/vendor/sass/test/sass/templates/nested_mixin_bork.sass +0 -6
- data/vendor/sass/test/sass/templates/options.sass +0 -2
- data/vendor/sass/test/sass/templates/parent_ref.sass +0 -25
- data/vendor/sass/test/sass/templates/script.sass +0 -101
- data/vendor/sass/test/sass/templates/scss_import.scss +0 -11
- data/vendor/sass/test/sass/templates/scss_importee.scss +0 -1
- data/vendor/sass/test/sass/templates/subdir/nested_subdir/_nested_partial.sass +0 -2
- data/vendor/sass/test/sass/templates/subdir/nested_subdir/nested_subdir.sass +0 -3
- data/vendor/sass/test/sass/templates/subdir/subdir.sass +0 -6
- data/vendor/sass/test/sass/templates/units.sass +0 -11
- data/vendor/sass/test/sass/templates/warn.sass +0 -3
- data/vendor/sass/test/sass/templates/warn_imported.sass +0 -4
- data/vendor/sass/test/sass/test_helper.rb +0 -8
- data/vendor/sass/test/sass/util/subset_map_test.rb +0 -91
- data/vendor/sass/test/sass/util_test.rb +0 -266
- data/vendor/sass/test/test_helper.rb +0 -69
- data/vendor/sass/vendor/fssm/Gemfile +0 -3
- data/vendor/sass/vendor/fssm/LICENSE +0 -20
- data/vendor/sass/vendor/fssm/README.markdown +0 -83
- data/vendor/sass/vendor/fssm/Rakefile +0 -11
- data/vendor/sass/vendor/fssm/example.rb +0 -12
- data/vendor/sass/vendor/fssm/fssm.gemspec +0 -24
- data/vendor/sass/vendor/fssm/lib/fssm.rb +0 -37
- data/vendor/sass/vendor/fssm/lib/fssm/backends/fsevents.rb +0 -36
- data/vendor/sass/vendor/fssm/lib/fssm/backends/inotify.rb +0 -26
- data/vendor/sass/vendor/fssm/lib/fssm/backends/polling.rb +0 -25
- data/vendor/sass/vendor/fssm/lib/fssm/backends/rbfsevent.rb +0 -42
- data/vendor/sass/vendor/fssm/lib/fssm/backends/rubycocoa/fsevents.rb +0 -131
- data/vendor/sass/vendor/fssm/lib/fssm/monitor.rb +0 -36
- data/vendor/sass/vendor/fssm/lib/fssm/path.rb +0 -94
- data/vendor/sass/vendor/fssm/lib/fssm/pathname.rb +0 -36
- data/vendor/sass/vendor/fssm/lib/fssm/state/directory.rb +0 -75
- data/vendor/sass/vendor/fssm/lib/fssm/state/file.rb +0 -24
- data/vendor/sass/vendor/fssm/lib/fssm/support.rb +0 -92
- data/vendor/sass/vendor/fssm/lib/fssm/tree.rb +0 -176
- data/vendor/sass/vendor/fssm/lib/fssm/version.rb +0 -3
- data/vendor/sass/vendor/fssm/profile/prof-cache.rb +0 -40
- data/vendor/sass/vendor/fssm/profile/prof-fssm-pathname.html +0 -1231
- data/vendor/sass/vendor/fssm/profile/prof-pathname-rubinius.rb +0 -35
- data/vendor/sass/vendor/fssm/profile/prof-pathname.rb +0 -68
- data/vendor/sass/vendor/fssm/profile/prof-plain-pathname.html +0 -988
- data/vendor/sass/vendor/fssm/profile/prof.html +0 -2379
- data/vendor/sass/vendor/fssm/spec/count_down_latch.rb +0 -151
- data/vendor/sass/vendor/fssm/spec/monitor_spec.rb +0 -202
- data/vendor/sass/vendor/fssm/spec/path_spec.rb +0 -96
- data/vendor/sass/vendor/fssm/spec/root/duck/quack.txt +0 -0
- data/vendor/sass/vendor/fssm/spec/root/file.css +0 -0
- data/vendor/sass/vendor/fssm/spec/root/file.rb +0 -0
- data/vendor/sass/vendor/fssm/spec/root/file.yml +0 -0
- data/vendor/sass/vendor/fssm/spec/root/moo/cow.txt +0 -0
- data/vendor/sass/vendor/fssm/spec/spec_helper.rb +0 -14
- data/vendor/sass/yard/callbacks.rb +0 -29
- data/vendor/sass/yard/default/fulldoc/html/css/common.sass +0 -26
- data/vendor/sass/yard/default/layout/html/footer.erb +0 -12
- data/vendor/sass/yard/inherited_hash.rb +0 -41
@@ -1,166 +0,0 @@
|
|
1
|
-
require 'set'
|
2
|
-
|
3
|
-
module Sass
|
4
|
-
# The lexical environment for SassScript.
|
5
|
-
# This keeps track of variable, mixin, and function definitions.
|
6
|
-
#
|
7
|
-
# A new environment is created for each level of Sass nesting.
|
8
|
-
# This allows variables to be lexically scoped.
|
9
|
-
# The new environment refers to the environment in the upper scope,
|
10
|
-
# so it has access to variables defined in enclosing scopes,
|
11
|
-
# but new variables are defined locally.
|
12
|
-
#
|
13
|
-
# Environment also keeps track of the {Engine} options
|
14
|
-
# so that they can be made available to {Sass::Script::Functions}.
|
15
|
-
class Environment
|
16
|
-
# The enclosing environment,
|
17
|
-
# or nil if this is the global environment.
|
18
|
-
#
|
19
|
-
# @return [Environment]
|
20
|
-
attr_reader :parent
|
21
|
-
attr_writer :options
|
22
|
-
|
23
|
-
# @param parent [Environment] See \{#parent}
|
24
|
-
def initialize(parent = nil)
|
25
|
-
@parent = parent
|
26
|
-
unless parent
|
27
|
-
@stack = []
|
28
|
-
@mixins_in_use = Set.new
|
29
|
-
set_var("important", Script::String.new("!important"))
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
|
-
# The options hash.
|
34
|
-
# See {file:SASS_REFERENCE.md#sass_options the Sass options documentation}.
|
35
|
-
#
|
36
|
-
# @return [{Symbol => Object}]
|
37
|
-
def options
|
38
|
-
@options || parent_options || {}
|
39
|
-
end
|
40
|
-
|
41
|
-
# Push a new stack frame onto the mixin/include stack.
|
42
|
-
#
|
43
|
-
# @param frame_info [{Symbol => Object}]
|
44
|
-
# Frame information has the following keys:
|
45
|
-
#
|
46
|
-
# `:filename`
|
47
|
-
# : The name of the file in which the lexical scope changed.
|
48
|
-
#
|
49
|
-
# `:mixin`
|
50
|
-
# : The name of the mixin in which the lexical scope changed,
|
51
|
-
# or `nil` if it wasn't within in a mixin.
|
52
|
-
#
|
53
|
-
# `:line`
|
54
|
-
# : The line of the file on which the lexical scope changed. Never nil.
|
55
|
-
def push_frame(frame_info)
|
56
|
-
top_of_stack = stack.last
|
57
|
-
if top_of_stack && top_of_stack.delete(:prepared)
|
58
|
-
top_of_stack.merge!(frame_info)
|
59
|
-
else
|
60
|
-
stack.push(top_of_stack = frame_info)
|
61
|
-
end
|
62
|
-
mixins_in_use << top_of_stack[:mixin] if top_of_stack[:mixin] && !top_of_stack[:prepared]
|
63
|
-
end
|
64
|
-
|
65
|
-
# Like \{#push\_frame}, but next time a stack frame is pushed,
|
66
|
-
# it will be merged with this frame.
|
67
|
-
#
|
68
|
-
# @param frame_info [{Symbol => Object}] Same as for \{#push\_frame}.
|
69
|
-
def prepare_frame(frame_info)
|
70
|
-
push_frame(frame_info.merge(:prepared => true))
|
71
|
-
end
|
72
|
-
|
73
|
-
# Pop a stack frame from the mixin/include stack.
|
74
|
-
def pop_frame
|
75
|
-
stack.pop if stack.last && stack.last[:prepared]
|
76
|
-
popped = stack.pop
|
77
|
-
mixins_in_use.delete(popped[:mixin]) if popped && popped[:mixin]
|
78
|
-
end
|
79
|
-
|
80
|
-
# A list of stack frames in the mixin/include stack.
|
81
|
-
# The last element in the list is the most deeply-nested frame.
|
82
|
-
#
|
83
|
-
# @return [Array<{Symbol => Object}>] The stack frames,
|
84
|
-
# of the form passed to \{#push\_frame}.
|
85
|
-
def stack
|
86
|
-
@stack ||= @parent.stack
|
87
|
-
end
|
88
|
-
|
89
|
-
# A set of names of mixins currently present in the stack.
|
90
|
-
#
|
91
|
-
# @return [Set<String>] The mixin names.
|
92
|
-
def mixins_in_use
|
93
|
-
@mixins_in_use ||= @parent.mixins_in_use
|
94
|
-
end
|
95
|
-
|
96
|
-
def stack_trace
|
97
|
-
trace = []
|
98
|
-
stack.reverse.each_with_index do |entry, i|
|
99
|
-
msg = "#{i == 0 ? "on" : "from"} line #{entry[:line]}"
|
100
|
-
msg << " of #{entry[:filename] || "an unknown file"}"
|
101
|
-
msg << ", in `#{entry[:mixin]}'" if entry[:mixin]
|
102
|
-
trace << msg
|
103
|
-
end
|
104
|
-
trace
|
105
|
-
end
|
106
|
-
|
107
|
-
private
|
108
|
-
|
109
|
-
def parent_options
|
110
|
-
@parent_options ||= @parent && @parent.options
|
111
|
-
end
|
112
|
-
|
113
|
-
class << self
|
114
|
-
private
|
115
|
-
UNDERSCORE, DASH = '_', '-'
|
116
|
-
|
117
|
-
# Note: when updating this,
|
118
|
-
# update sass/yard/inherited_hash.rb as well.
|
119
|
-
def inherited_hash(name)
|
120
|
-
class_eval <<RUBY, __FILE__, __LINE__ + 1
|
121
|
-
def #{name}(name)
|
122
|
-
_#{name}(name.tr(UNDERSCORE, DASH))
|
123
|
-
end
|
124
|
-
|
125
|
-
def _#{name}(name)
|
126
|
-
(@#{name}s && @#{name}s[name]) || @parent && @parent._#{name}(name)
|
127
|
-
end
|
128
|
-
protected :_#{name}
|
129
|
-
|
130
|
-
def set_#{name}(name, value)
|
131
|
-
name = name.tr(UNDERSCORE, DASH)
|
132
|
-
@#{name}s[name] = value unless try_set_#{name}(name, value)
|
133
|
-
end
|
134
|
-
|
135
|
-
def try_set_#{name}(name, value)
|
136
|
-
@#{name}s ||= {}
|
137
|
-
if @#{name}s.include?(name)
|
138
|
-
@#{name}s[name] = value
|
139
|
-
true
|
140
|
-
elsif @parent
|
141
|
-
@parent.try_set_#{name}(name, value)
|
142
|
-
else
|
143
|
-
false
|
144
|
-
end
|
145
|
-
end
|
146
|
-
protected :try_set_#{name}
|
147
|
-
|
148
|
-
def set_local_#{name}(name, value)
|
149
|
-
@#{name}s ||= {}
|
150
|
-
@#{name}s[name.tr(UNDERSCORE, DASH)] = value
|
151
|
-
end
|
152
|
-
RUBY
|
153
|
-
end
|
154
|
-
end
|
155
|
-
|
156
|
-
# variable
|
157
|
-
# Script::Literal
|
158
|
-
inherited_hash :var
|
159
|
-
# mixin
|
160
|
-
# Sass::Callable
|
161
|
-
inherited_hash :mixin
|
162
|
-
# function
|
163
|
-
# Sass::Callable
|
164
|
-
inherited_hash :function
|
165
|
-
end
|
166
|
-
end
|
@@ -1,201 +0,0 @@
|
|
1
|
-
module Sass
|
2
|
-
# An exception class that keeps track of
|
3
|
-
# the line of the Sass template it was raised on
|
4
|
-
# and the Sass file that was being parsed (if applicable).
|
5
|
-
#
|
6
|
-
# All Sass errors are raised as {Sass::SyntaxError}s.
|
7
|
-
#
|
8
|
-
# When dealing with SyntaxErrors,
|
9
|
-
# it's important to provide filename and line number information.
|
10
|
-
# This will be used in various error reports to users, including backtraces;
|
11
|
-
# see \{#sass\_backtrace} for details.
|
12
|
-
#
|
13
|
-
# Some of this information is usually provided as part of the constructor.
|
14
|
-
# New backtrace entries can be added with \{#add\_backtrace},
|
15
|
-
# which is called when an exception is raised between files (e.g. with `@import`).
|
16
|
-
#
|
17
|
-
# Often, a chunk of code will all have similar backtrace information -
|
18
|
-
# the same filename or even line.
|
19
|
-
# It may also be useful to have a default line number set.
|
20
|
-
# In those situations, the default values can be used
|
21
|
-
# by omitting the information on the original exception,
|
22
|
-
# and then calling \{#modify\_backtrace} in a wrapper `rescue`.
|
23
|
-
# When doing this, be sure that all exceptions ultimately end up
|
24
|
-
# with the information filled in.
|
25
|
-
class SyntaxError < StandardError
|
26
|
-
# The backtrace of the error within Sass files.
|
27
|
-
# This is an array of hashes containing information for a single entry.
|
28
|
-
# The hashes have the following keys:
|
29
|
-
#
|
30
|
-
# `:filename`
|
31
|
-
# : The name of the file in which the exception was raised,
|
32
|
-
# or `nil` if no filename is available.
|
33
|
-
#
|
34
|
-
# `:mixin`
|
35
|
-
# : The name of the mixin in which the exception was raised,
|
36
|
-
# or `nil` if it wasn't raised in a mixin.
|
37
|
-
#
|
38
|
-
# `:line`
|
39
|
-
# : The line of the file on which the error occurred. Never nil.
|
40
|
-
#
|
41
|
-
# This information is also included in standard backtrace format
|
42
|
-
# in the output of \{#backtrace}.
|
43
|
-
#
|
44
|
-
# @return [Aray<{Symbol => Object>}]
|
45
|
-
attr_accessor :sass_backtrace
|
46
|
-
|
47
|
-
# The text of the template where this error was raised.
|
48
|
-
#
|
49
|
-
# @return [String]
|
50
|
-
attr_accessor :sass_template
|
51
|
-
|
52
|
-
# @param msg [String] The error message
|
53
|
-
# @param attrs [{Symbol => Object}] The information in the backtrace entry.
|
54
|
-
# See \{#sass\_backtrace}
|
55
|
-
def initialize(msg, attrs = {})
|
56
|
-
@message = msg
|
57
|
-
@sass_backtrace = []
|
58
|
-
add_backtrace(attrs)
|
59
|
-
end
|
60
|
-
|
61
|
-
# The name of the file in which the exception was raised.
|
62
|
-
# This could be `nil` if no filename is available.
|
63
|
-
#
|
64
|
-
# @return [String, nil]
|
65
|
-
def sass_filename
|
66
|
-
sass_backtrace.first[:filename]
|
67
|
-
end
|
68
|
-
|
69
|
-
# The name of the mixin in which the error occurred.
|
70
|
-
# This could be `nil` if the error occurred outside a mixin.
|
71
|
-
#
|
72
|
-
# @return [Fixnum]
|
73
|
-
def sass_mixin
|
74
|
-
sass_backtrace.first[:mixin]
|
75
|
-
end
|
76
|
-
|
77
|
-
# The line of the Sass template on which the error occurred.
|
78
|
-
#
|
79
|
-
# @return [Fixnum]
|
80
|
-
def sass_line
|
81
|
-
sass_backtrace.first[:line]
|
82
|
-
end
|
83
|
-
|
84
|
-
# Adds an entry to the exception's Sass backtrace.
|
85
|
-
#
|
86
|
-
# @param attrs [{Symbol => Object}] The information in the backtrace entry.
|
87
|
-
# See \{#sass\_backtrace}
|
88
|
-
def add_backtrace(attrs)
|
89
|
-
sass_backtrace << attrs.reject {|k, v| v.nil?}
|
90
|
-
end
|
91
|
-
|
92
|
-
# Modify the top Sass backtrace entries
|
93
|
-
# (that is, the most deeply nested ones)
|
94
|
-
# to have the given attributes.
|
95
|
-
#
|
96
|
-
# Specifically, this goes through the backtrace entries
|
97
|
-
# from most deeply nested to least,
|
98
|
-
# setting the given attributes for each entry.
|
99
|
-
# If an entry already has one of the given attributes set,
|
100
|
-
# the pre-existing attribute takes precedence
|
101
|
-
# and is not used for less deeply-nested entries
|
102
|
-
# (even if they don't have that attribute set).
|
103
|
-
#
|
104
|
-
# @param attrs [{Symbol => Object}] The information to add to the backtrace entry.
|
105
|
-
# See \{#sass\_backtrace}
|
106
|
-
def modify_backtrace(attrs)
|
107
|
-
attrs = attrs.reject {|k, v| v.nil?}
|
108
|
-
# Move backwards through the backtrace
|
109
|
-
(0...sass_backtrace.size).to_a.reverse.each do |i|
|
110
|
-
entry = sass_backtrace[i]
|
111
|
-
sass_backtrace[i] = attrs.merge(entry)
|
112
|
-
attrs.reject! {|k, v| entry.include?(k)}
|
113
|
-
break if attrs.empty?
|
114
|
-
end
|
115
|
-
end
|
116
|
-
|
117
|
-
# @return [String] The error message
|
118
|
-
def to_s
|
119
|
-
@message
|
120
|
-
end
|
121
|
-
|
122
|
-
# Returns the standard exception backtrace,
|
123
|
-
# including the Sass backtrace.
|
124
|
-
#
|
125
|
-
# @return [Array<String>]
|
126
|
-
def backtrace
|
127
|
-
return nil if super.nil?
|
128
|
-
return super if sass_backtrace.all? {|h| h.empty?}
|
129
|
-
sass_backtrace.map do |h|
|
130
|
-
"#{h[:filename] || "(sass)"}:#{h[:line]}" +
|
131
|
-
(h[:mixin] ? ":in `#{h[:mixin]}'" : "")
|
132
|
-
end + super
|
133
|
-
end
|
134
|
-
|
135
|
-
# Returns a string representation of the Sass backtrace.
|
136
|
-
#
|
137
|
-
# @param default_filename [String] The filename to use for unknown files
|
138
|
-
# @see #sass_backtrace
|
139
|
-
# @return [String]
|
140
|
-
def sass_backtrace_str(default_filename = "an unknown file")
|
141
|
-
lines = self.message.split("\n")
|
142
|
-
msg = lines[0] + lines[1..-1].
|
143
|
-
map {|l| "\n" + (" " * "Syntax error: ".size) + l}.join
|
144
|
-
"Syntax error: #{msg}" +
|
145
|
-
Sass::Util.enum_with_index(sass_backtrace).map do |entry, i|
|
146
|
-
"\n #{i == 0 ? "on" : "from"} line #{entry[:line]}" +
|
147
|
-
" of #{entry[:filename] || default_filename}" +
|
148
|
-
(entry[:mixin] ? ", in `#{entry[:mixin]}'" : "")
|
149
|
-
end.join
|
150
|
-
end
|
151
|
-
|
152
|
-
class << self
|
153
|
-
# Returns an error report for an exception in CSS format.
|
154
|
-
#
|
155
|
-
# @param e [Exception]
|
156
|
-
# @param options [{Symbol => Object}] The options passed to {Sass::Engine#initialize}
|
157
|
-
# @return [String] The error report
|
158
|
-
# @raise [Exception] `e`, if the
|
159
|
-
# {file:SASS_REFERENCE.md#full_exception-option `:full_exception`} option
|
160
|
-
# is set to false.
|
161
|
-
def exception_to_css(e, options)
|
162
|
-
raise e unless options[:full_exception]
|
163
|
-
|
164
|
-
header = header_string(e, options)
|
165
|
-
|
166
|
-
<<END
|
167
|
-
/*
|
168
|
-
#{header}
|
169
|
-
|
170
|
-
Backtrace:\n#{e.backtrace.join("\n")}
|
171
|
-
*/
|
172
|
-
body:before {
|
173
|
-
white-space: pre;
|
174
|
-
font-family: monospace;
|
175
|
-
content: "#{header.gsub('"', '\"').gsub("\n", '\\A ')}"; }
|
176
|
-
END
|
177
|
-
end
|
178
|
-
|
179
|
-
private
|
180
|
-
|
181
|
-
def header_string(e, options)
|
182
|
-
unless e.is_a?(Sass::SyntaxError) && e.sass_line && e.sass_template
|
183
|
-
return "#{e.class}: #{e.message}"
|
184
|
-
end
|
185
|
-
|
186
|
-
line_offset = options[:line] || 1
|
187
|
-
line_num = e.sass_line + 1 - line_offset
|
188
|
-
min = [line_num - 6, 0].max
|
189
|
-
section = e.sass_template.rstrip.split("\n")[min ... line_num + 5]
|
190
|
-
return e.sass_backtrace_str if section.nil? || section.empty?
|
191
|
-
|
192
|
-
e.sass_backtrace_str + "\n\n" + Sass::Util.enum_with_index(section).
|
193
|
-
map {|line, i| "#{line_offset + min + i}: #{line}"}.join("\n")
|
194
|
-
end
|
195
|
-
end
|
196
|
-
end
|
197
|
-
|
198
|
-
# The class for Sass errors that are raised due to invalid unit conversions
|
199
|
-
# in SassScript.
|
200
|
-
class UnitConversionError < SyntaxError; end
|
201
|
-
end
|
@@ -1,672 +0,0 @@
|
|
1
|
-
require 'optparse'
|
2
|
-
require 'fileutils'
|
3
|
-
|
4
|
-
module Sass
|
5
|
-
# This module handles the various Sass executables (`sass` and `sass-convert`).
|
6
|
-
module Exec
|
7
|
-
# An abstract class that encapsulates the executable code for all three executables.
|
8
|
-
class Generic
|
9
|
-
# @param args [Array<String>] The command-line arguments
|
10
|
-
def initialize(args)
|
11
|
-
@args = args
|
12
|
-
@options = {}
|
13
|
-
end
|
14
|
-
|
15
|
-
# Parses the command-line arguments and runs the executable.
|
16
|
-
# Calls `Kernel#exit` at the end, so it never returns.
|
17
|
-
#
|
18
|
-
# @see #parse
|
19
|
-
def parse!
|
20
|
-
begin
|
21
|
-
parse
|
22
|
-
rescue Exception => e
|
23
|
-
raise e if @options[:trace] || e.is_a?(SystemExit)
|
24
|
-
|
25
|
-
$stderr.print "#{e.class}: " unless e.class == RuntimeError
|
26
|
-
$stderr.puts "#{e.message}"
|
27
|
-
$stderr.puts " Use --trace for backtrace."
|
28
|
-
exit 1
|
29
|
-
end
|
30
|
-
exit 0
|
31
|
-
end
|
32
|
-
|
33
|
-
# Parses the command-line arguments and runs the executable.
|
34
|
-
# This does not handle exceptions or exit the program.
|
35
|
-
#
|
36
|
-
# @see #parse!
|
37
|
-
def parse
|
38
|
-
@opts = OptionParser.new(&method(:set_opts))
|
39
|
-
@opts.parse!(@args)
|
40
|
-
|
41
|
-
process_result
|
42
|
-
|
43
|
-
@options
|
44
|
-
end
|
45
|
-
|
46
|
-
# @return [String] A description of the executable
|
47
|
-
def to_s
|
48
|
-
@opts.to_s
|
49
|
-
end
|
50
|
-
|
51
|
-
protected
|
52
|
-
|
53
|
-
# Finds the line of the source template
|
54
|
-
# on which an exception was raised.
|
55
|
-
#
|
56
|
-
# @param exception [Exception] The exception
|
57
|
-
# @return [String] The line number
|
58
|
-
def get_line(exception)
|
59
|
-
# SyntaxErrors have weird line reporting
|
60
|
-
# when there's trailing whitespace
|
61
|
-
return (exception.message.scan(/:(\d+)/).first || ["??"]).first if exception.is_a?(::SyntaxError)
|
62
|
-
(exception.backtrace[0].scan(/:(\d+)/).first || ["??"]).first
|
63
|
-
end
|
64
|
-
|
65
|
-
# Tells optparse how to parse the arguments
|
66
|
-
# available for all executables.
|
67
|
-
#
|
68
|
-
# This is meant to be overridden by subclasses
|
69
|
-
# so they can add their own options.
|
70
|
-
#
|
71
|
-
# @param opts [OptionParser]
|
72
|
-
def set_opts(opts)
|
73
|
-
opts.on('-s', '--stdin', :NONE, 'Read input from standard input instead of an input file') do
|
74
|
-
@options[:input] = $stdin
|
75
|
-
end
|
76
|
-
|
77
|
-
opts.on('--trace', :NONE, 'Show a full traceback on error') do
|
78
|
-
@options[:trace] = true
|
79
|
-
end
|
80
|
-
|
81
|
-
opts.on('--unix-newlines', 'Use Unix-style newlines in written files.') do
|
82
|
-
@options[:unix_newlines] = true if ::Sass::Util.windows?
|
83
|
-
end
|
84
|
-
|
85
|
-
opts.on_tail("-?", "-h", "--help", "Show this message") do
|
86
|
-
puts opts
|
87
|
-
exit
|
88
|
-
end
|
89
|
-
|
90
|
-
opts.on_tail("-v", "--version", "Print version") do
|
91
|
-
puts("Sass #{::Sass.version[:string]}")
|
92
|
-
exit
|
93
|
-
end
|
94
|
-
end
|
95
|
-
|
96
|
-
# Processes the options set by the command-line arguments.
|
97
|
-
# In particular, sets `@options[:input]` and `@options[:output]`
|
98
|
-
# to appropriate IO streams.
|
99
|
-
#
|
100
|
-
# This is meant to be overridden by subclasses
|
101
|
-
# so they can run their respective programs.
|
102
|
-
def process_result
|
103
|
-
input, output = @options[:input], @options[:output]
|
104
|
-
args = @args.dup
|
105
|
-
input ||=
|
106
|
-
begin
|
107
|
-
filename = args.shift
|
108
|
-
@options[:filename] = filename
|
109
|
-
open_file(filename) || $stdin
|
110
|
-
end
|
111
|
-
output ||= open_file(args.shift, 'w') || $stdout
|
112
|
-
|
113
|
-
@options[:input], @options[:output] = input, output
|
114
|
-
end
|
115
|
-
|
116
|
-
COLORS = { :red => 31, :green => 32, :yellow => 33 }
|
117
|
-
|
118
|
-
# Prints a status message about performing the given action,
|
119
|
-
# colored using the given color (via terminal escapes) if possible.
|
120
|
-
#
|
121
|
-
# @param name [#to_s] A short name for the action being performed.
|
122
|
-
# Shouldn't be longer than 11 characters.
|
123
|
-
# @param color [Symbol] The name of the color to use for this action.
|
124
|
-
# Can be `:red`, `:green`, or `:yellow`.
|
125
|
-
def puts_action(name, color, arg)
|
126
|
-
return if @options[:for_engine][:quiet]
|
127
|
-
printf color(color, "%11s %s\n"), name, arg
|
128
|
-
end
|
129
|
-
|
130
|
-
# Same as \{Kernel.puts}, but doesn't print anything if the `--quiet` option is set.
|
131
|
-
#
|
132
|
-
# @param args [Array] Passed on to \{Kernel.puts}
|
133
|
-
def puts(*args)
|
134
|
-
return if @options[:for_engine][:quiet]
|
135
|
-
Kernel.puts(*args)
|
136
|
-
end
|
137
|
-
|
138
|
-
# Wraps the given string in terminal escapes
|
139
|
-
# causing it to have the given color.
|
140
|
-
# If terminal esapes aren't supported on this platform,
|
141
|
-
# just returns the string instead.
|
142
|
-
#
|
143
|
-
# @param color [Symbol] The name of the color to use.
|
144
|
-
# Can be `:red`, `:green`, or `:yellow`.
|
145
|
-
# @param str [String] The string to wrap in the given color.
|
146
|
-
# @return [String] The wrapped string.
|
147
|
-
def color(color, str)
|
148
|
-
raise "[BUG] Unrecognized color #{color}" unless COLORS[color]
|
149
|
-
|
150
|
-
# Almost any real Unix terminal will support color,
|
151
|
-
# so we just filter for Windows terms (which don't set TERM)
|
152
|
-
# and not-real terminals, which aren't ttys.
|
153
|
-
return str if ENV["TERM"].nil? || ENV["TERM"].empty? || !STDOUT.tty?
|
154
|
-
return "\e[#{COLORS[color]}m#{str}\e[0m"
|
155
|
-
end
|
156
|
-
|
157
|
-
private
|
158
|
-
|
159
|
-
def open_file(filename, flag = 'r')
|
160
|
-
return if filename.nil?
|
161
|
-
flag = 'wb' if @options[:unix_newlines] && flag == 'w'
|
162
|
-
File.open(filename, flag)
|
163
|
-
end
|
164
|
-
|
165
|
-
def handle_load_error(err)
|
166
|
-
dep = err.message[/^no such file to load -- (.*)/, 1]
|
167
|
-
raise err if @options[:trace] || dep.nil? || dep.empty?
|
168
|
-
$stderr.puts <<MESSAGE
|
169
|
-
Required dependency #{dep} not found!
|
170
|
-
Run "gem install #{dep}" to get it.
|
171
|
-
Use --trace for backtrace.
|
172
|
-
MESSAGE
|
173
|
-
exit 1
|
174
|
-
end
|
175
|
-
end
|
176
|
-
|
177
|
-
# The `sass` executable.
|
178
|
-
class Sass < Generic
|
179
|
-
attr_reader :default_syntax
|
180
|
-
|
181
|
-
# @param args [Array<String>] The command-line arguments
|
182
|
-
def initialize(args)
|
183
|
-
super
|
184
|
-
@options[:for_engine] = {
|
185
|
-
:load_paths => ['.'] + (ENV['SASSPATH'] || '').split(File::PATH_SEPARATOR)
|
186
|
-
}
|
187
|
-
@default_syntax = :sass
|
188
|
-
end
|
189
|
-
|
190
|
-
protected
|
191
|
-
|
192
|
-
# Tells optparse how to parse the arguments.
|
193
|
-
#
|
194
|
-
# @param opts [OptionParser]
|
195
|
-
def set_opts(opts)
|
196
|
-
super
|
197
|
-
|
198
|
-
opts.banner = <<END
|
199
|
-
Usage: #{default_syntax} [options] [INPUT] [OUTPUT]
|
200
|
-
|
201
|
-
Description:
|
202
|
-
Converts SCSS or Sass files to CSS.
|
203
|
-
|
204
|
-
Options:
|
205
|
-
END
|
206
|
-
|
207
|
-
if @default_syntax == :sass
|
208
|
-
opts.on('--scss',
|
209
|
-
'Use the CSS-superset SCSS syntax.') do
|
210
|
-
@options[:for_engine][:syntax] = :scss
|
211
|
-
end
|
212
|
-
else
|
213
|
-
opts.on('--sass',
|
214
|
-
'Use the Indented syntax.') do
|
215
|
-
@options[:for_engine][:syntax] = :sass
|
216
|
-
end
|
217
|
-
end
|
218
|
-
opts.on('--watch', 'Watch files or directories for changes.',
|
219
|
-
'The location of the generated CSS can be set using a colon:',
|
220
|
-
" #{@default_syntax} --watch input.#{@default_syntax}:output.css",
|
221
|
-
" #{@default_syntax} --watch input-dir:output-dir") do
|
222
|
-
@options[:watch] = true
|
223
|
-
end
|
224
|
-
opts.on('--update', 'Compile files or directories to CSS.',
|
225
|
-
'Locations are set like --watch.') do
|
226
|
-
@options[:update] = true
|
227
|
-
end
|
228
|
-
opts.on('--stop-on-error', 'If a file fails to compile, exit immediately.',
|
229
|
-
'Only meaningful for --watch and --update.') do
|
230
|
-
@options[:stop_on_error] = true
|
231
|
-
end
|
232
|
-
opts.on('-f', '--force', 'Recompile all Sass files, even if the CSS file is newer.',
|
233
|
-
'Only meaningful for --update.') do
|
234
|
-
@options[:force] = true
|
235
|
-
end
|
236
|
-
opts.on('-c', '--check', "Just check syntax, don't evaluate.") do
|
237
|
-
require 'stringio'
|
238
|
-
@options[:check_syntax] = true
|
239
|
-
@options[:output] = StringIO.new
|
240
|
-
end
|
241
|
-
opts.on('-t', '--style NAME',
|
242
|
-
'Output style. Can be nested (default), compact, compressed, or expanded.') do |name|
|
243
|
-
@options[:for_engine][:style] = name.to_sym
|
244
|
-
end
|
245
|
-
opts.on('--precision NUMBER_OF_DIGITS', Integer,
|
246
|
-
'How many digits of precision to use when outputting decimal numbers. Defaults to 3.') do |precision|
|
247
|
-
::Sass::Script::Number.precision = precision
|
248
|
-
end
|
249
|
-
opts.on('-q', '--quiet', 'Silence warnings and status messages during compilation.') do
|
250
|
-
@options[:for_engine][:quiet] = true
|
251
|
-
end
|
252
|
-
opts.on('--compass', 'Make Compass imports available and load project configuration.') do
|
253
|
-
@options[:compass] = true
|
254
|
-
end
|
255
|
-
opts.on('-g', '--debug-info',
|
256
|
-
'Emit extra information in the generated CSS that can be used by the FireSass Firebug plugin.') do
|
257
|
-
@options[:for_engine][:debug_info] = true
|
258
|
-
end
|
259
|
-
opts.on('-l', '--line-numbers', '--line-comments',
|
260
|
-
'Emit comments in the generated CSS indicating the corresponding source line.') do
|
261
|
-
@options[:for_engine][:line_numbers] = true
|
262
|
-
end
|
263
|
-
opts.on('-i', '--interactive',
|
264
|
-
'Run an interactive SassScript shell.') do
|
265
|
-
@options[:interactive] = true
|
266
|
-
end
|
267
|
-
opts.on('-I', '--load-path PATH', 'Add a sass import path.') do |path|
|
268
|
-
@options[:for_engine][:load_paths] << path
|
269
|
-
end
|
270
|
-
opts.on('-r', '--require LIB', 'Require a Ruby library before running Sass.') do |lib|
|
271
|
-
require lib
|
272
|
-
end
|
273
|
-
opts.on('--cache-location PATH', 'The path to put cached Sass files. Defaults to .sass-cache.') do |loc|
|
274
|
-
@options[:for_engine][:cache_location] = loc
|
275
|
-
end
|
276
|
-
opts.on('-C', '--no-cache', "Don't cache to sassc files.") do
|
277
|
-
@options[:for_engine][:cache] = false
|
278
|
-
end
|
279
|
-
|
280
|
-
unless ::Sass::Util.ruby1_8?
|
281
|
-
opts.on('-E encoding', 'Specify the default encoding for Sass files.') do |encoding|
|
282
|
-
Encoding.default_external = encoding
|
283
|
-
end
|
284
|
-
end
|
285
|
-
end
|
286
|
-
|
287
|
-
# Processes the options set by the command-line arguments,
|
288
|
-
# and runs the Sass compiler appropriately.
|
289
|
-
def process_result
|
290
|
-
require 'sass'
|
291
|
-
|
292
|
-
if !@options[:update] && !@options[:watch] &&
|
293
|
-
@args.first && colon_path?(@args.first)
|
294
|
-
if @args.size == 1
|
295
|
-
@args = split_colon_path(@args.first)
|
296
|
-
else
|
297
|
-
@options[:update] = true
|
298
|
-
end
|
299
|
-
end
|
300
|
-
load_compass if @options[:compass]
|
301
|
-
return interactive if @options[:interactive]
|
302
|
-
return watch_or_update if @options[:watch] || @options[:update]
|
303
|
-
super
|
304
|
-
@options[:for_engine][:filename] = @options[:filename]
|
305
|
-
|
306
|
-
begin
|
307
|
-
input = @options[:input]
|
308
|
-
output = @options[:output]
|
309
|
-
|
310
|
-
@options[:for_engine][:syntax] ||= :scss if input.is_a?(File) && input.path =~ /\.scss$/
|
311
|
-
@options[:for_engine][:syntax] ||= @default_syntax
|
312
|
-
engine =
|
313
|
-
if input.is_a?(File) && !@options[:check_syntax]
|
314
|
-
::Sass::Engine.for_file(input.path, @options[:for_engine])
|
315
|
-
else
|
316
|
-
# We don't need to do any special handling of @options[:check_syntax] here,
|
317
|
-
# because the Sass syntax checking happens alongside evaluation
|
318
|
-
# and evaluation doesn't actually evaluate any code anyway.
|
319
|
-
::Sass::Engine.new(input.read(), @options[:for_engine])
|
320
|
-
end
|
321
|
-
|
322
|
-
input.close() if input.is_a?(File)
|
323
|
-
|
324
|
-
output.write(engine.render)
|
325
|
-
output.close() if output.is_a? File
|
326
|
-
rescue ::Sass::SyntaxError => e
|
327
|
-
raise e if @options[:trace]
|
328
|
-
raise e.sass_backtrace_str("standard input")
|
329
|
-
end
|
330
|
-
end
|
331
|
-
|
332
|
-
private
|
333
|
-
|
334
|
-
def load_compass
|
335
|
-
begin
|
336
|
-
require 'compass'
|
337
|
-
rescue LoadError
|
338
|
-
require 'rubygems'
|
339
|
-
begin
|
340
|
-
require 'compass'
|
341
|
-
rescue LoadError
|
342
|
-
puts "ERROR: Cannot load compass."
|
343
|
-
exit 1
|
344
|
-
end
|
345
|
-
end
|
346
|
-
Compass.add_project_configuration
|
347
|
-
Compass.configuration.project_path ||= Dir.pwd
|
348
|
-
@options[:for_engine][:load_paths] += Compass.configuration.sass_load_paths
|
349
|
-
end
|
350
|
-
|
351
|
-
def interactive
|
352
|
-
require 'sass/repl'
|
353
|
-
::Sass::Repl.new(@options).run
|
354
|
-
end
|
355
|
-
|
356
|
-
def watch_or_update
|
357
|
-
require 'sass/plugin'
|
358
|
-
::Sass::Plugin.options.merge! @options[:for_engine]
|
359
|
-
::Sass::Plugin.options[:unix_newlines] = @options[:unix_newlines]
|
360
|
-
|
361
|
-
if @options[:force]
|
362
|
-
raise "The --force flag may only be used with --update." unless @options[:update]
|
363
|
-
::Sass::Plugin.options[:always_update] = true
|
364
|
-
end
|
365
|
-
|
366
|
-
raise <<MSG if @args.empty?
|
367
|
-
What files should I watch? Did you mean something like:
|
368
|
-
#{@default_syntax} --watch input.#{@default_syntax}:output.css
|
369
|
-
#{@default_syntax} --watch input-dir:output-dir
|
370
|
-
MSG
|
371
|
-
|
372
|
-
if !colon_path?(@args[0]) && probably_dest_dir?(@args[1])
|
373
|
-
flag = @options[:update] ? "--update" : "--watch"
|
374
|
-
err =
|
375
|
-
if !File.exist?(@args[1])
|
376
|
-
"doesn't exist"
|
377
|
-
elsif @args[1] =~ /\.css$/
|
378
|
-
"is a CSS file"
|
379
|
-
end
|
380
|
-
raise <<MSG if err
|
381
|
-
File #{@args[1]} #{err}.
|
382
|
-
Did you mean: #{@default_syntax} #{flag} #{@args[0]}:#{@args[1]}
|
383
|
-
MSG
|
384
|
-
end
|
385
|
-
|
386
|
-
dirs, files = @args.map {|name| split_colon_path(name)}.
|
387
|
-
partition {|i, _| File.directory? i}
|
388
|
-
files.map! {|from, to| [from, to || from.gsub(/\.[^.]*?$/, '.css')]}
|
389
|
-
dirs.map! {|from, to| [from, to || from]}
|
390
|
-
::Sass::Plugin.options[:template_location] = dirs
|
391
|
-
|
392
|
-
::Sass::Plugin.on_updating_stylesheet do |_, css|
|
393
|
-
if File.exists? css
|
394
|
-
puts_action :overwrite, :yellow, css
|
395
|
-
else
|
396
|
-
puts_action :create, :green, css
|
397
|
-
end
|
398
|
-
end
|
399
|
-
|
400
|
-
had_error = false
|
401
|
-
::Sass::Plugin.on_creating_directory {|dirname| puts_action :directory, :green, dirname}
|
402
|
-
::Sass::Plugin.on_deleting_css {|filename| puts_action :delete, :yellow, filename}
|
403
|
-
::Sass::Plugin.on_compilation_error do |error, _, _|
|
404
|
-
raise error unless error.is_a?(::Sass::SyntaxError) && !@options[:stop_on_error]
|
405
|
-
had_error = true
|
406
|
-
puts_action :error, :red, "#{error.sass_filename} (Line #{error.sass_line}: #{error.message})"
|
407
|
-
end
|
408
|
-
|
409
|
-
if @options[:update]
|
410
|
-
::Sass::Plugin.update_stylesheets(files)
|
411
|
-
exit 1 if had_error
|
412
|
-
return
|
413
|
-
end
|
414
|
-
|
415
|
-
puts ">>> Sass is watching for changes. Press Ctrl-C to stop."
|
416
|
-
|
417
|
-
::Sass::Plugin.on_template_modified {|template| puts ">>> Change detected to: #{template}"}
|
418
|
-
::Sass::Plugin.on_template_created {|template| puts ">>> New template detected: #{template}"}
|
419
|
-
::Sass::Plugin.on_template_deleted {|template| puts ">>> Deleted template detected: #{template}"}
|
420
|
-
|
421
|
-
::Sass::Plugin.watch(files)
|
422
|
-
end
|
423
|
-
|
424
|
-
def colon_path?(path)
|
425
|
-
!split_colon_path(path)[1].nil?
|
426
|
-
end
|
427
|
-
|
428
|
-
def split_colon_path(path)
|
429
|
-
one, two = path.split(':', 2)
|
430
|
-
if one && two && ::Sass::Util.windows? &&
|
431
|
-
one =~ /\A[A-Za-z]\Z/ && two =~ /\A[\/\\]/
|
432
|
-
# If we're on Windows and we were passed a drive letter path,
|
433
|
-
# don't split on that colon.
|
434
|
-
one2, two = two.split(':', 2)
|
435
|
-
one = one + ':' + one2
|
436
|
-
end
|
437
|
-
return one, two
|
438
|
-
end
|
439
|
-
|
440
|
-
# Whether path is likely to be meant as the destination
|
441
|
-
# in a source:dest pair.
|
442
|
-
def probably_dest_dir?(path)
|
443
|
-
return false unless path
|
444
|
-
return false if colon_path?(path)
|
445
|
-
return Dir.glob(File.join(path, "*.s[ca]ss")).empty?
|
446
|
-
end
|
447
|
-
end
|
448
|
-
|
449
|
-
class Scss < Sass
|
450
|
-
# @param args [Array<String>] The command-line arguments
|
451
|
-
def initialize(args)
|
452
|
-
super
|
453
|
-
@default_syntax = :scss
|
454
|
-
end
|
455
|
-
end
|
456
|
-
|
457
|
-
# The `sass-convert` executable.
|
458
|
-
class SassConvert < Generic
|
459
|
-
# @param args [Array<String>] The command-line arguments
|
460
|
-
def initialize(args)
|
461
|
-
super
|
462
|
-
require 'sass'
|
463
|
-
@options[:for_tree] = {}
|
464
|
-
@options[:for_engine] = {:cache => false, :read_cache => true}
|
465
|
-
end
|
466
|
-
|
467
|
-
# Tells optparse how to parse the arguments.
|
468
|
-
#
|
469
|
-
# @param opts [OptionParser]
|
470
|
-
def set_opts(opts)
|
471
|
-
opts.banner = <<END
|
472
|
-
Usage: sass-convert [options] [INPUT] [OUTPUT]
|
473
|
-
|
474
|
-
Description:
|
475
|
-
Converts between CSS, Sass, and SCSS files.
|
476
|
-
E.g. converts from SCSS to Sass,
|
477
|
-
or converts from CSS to SCSS (adding appropriate nesting).
|
478
|
-
|
479
|
-
Options:
|
480
|
-
END
|
481
|
-
|
482
|
-
opts.on('-F', '--from FORMAT',
|
483
|
-
'The format to convert from. Can be css, scss, sass, less.',
|
484
|
-
'By default, this is inferred from the input filename.',
|
485
|
-
'If there is none, defaults to css.') do |name|
|
486
|
-
@options[:from] = name.downcase.to_sym
|
487
|
-
unless [:css, :scss, :sass, :less].include?(@options[:from])
|
488
|
-
raise "Unknown format for sass-convert --from: #{name}"
|
489
|
-
end
|
490
|
-
try_less_note if @options[:from] == :less
|
491
|
-
end
|
492
|
-
|
493
|
-
opts.on('-T', '--to FORMAT',
|
494
|
-
'The format to convert to. Can be scss or sass.',
|
495
|
-
'By default, this is inferred from the output filename.',
|
496
|
-
'If there is none, defaults to sass.') do |name|
|
497
|
-
@options[:to] = name.downcase.to_sym
|
498
|
-
unless [:scss, :sass].include?(@options[:to])
|
499
|
-
raise "Unknown format for sass-convert --to: #{name}"
|
500
|
-
end
|
501
|
-
end
|
502
|
-
|
503
|
-
opts.on('-R', '--recursive',
|
504
|
-
'Convert all the files in a directory. Requires --from and --to.') do
|
505
|
-
@options[:recursive] = true
|
506
|
-
end
|
507
|
-
|
508
|
-
opts.on('-i', '--in-place',
|
509
|
-
'Convert a file to its own syntax.',
|
510
|
-
'This can be used to update some deprecated syntax.') do
|
511
|
-
@options[:in_place] = true
|
512
|
-
end
|
513
|
-
|
514
|
-
opts.on('--dasherize', 'Convert underscores to dashes') do
|
515
|
-
@options[:for_tree][:dasherize] = true
|
516
|
-
end
|
517
|
-
|
518
|
-
opts.on('--old', 'Output the old-style ":prop val" property syntax.',
|
519
|
-
'Only meaningful when generating Sass.') do
|
520
|
-
@options[:for_tree][:old] = true
|
521
|
-
end
|
522
|
-
|
523
|
-
opts.on('-C', '--no-cache', "Don't cache to sassc files.") do
|
524
|
-
@options[:for_engine][:read_cache] = false
|
525
|
-
end
|
526
|
-
|
527
|
-
unless ::Sass::Util.ruby1_8?
|
528
|
-
opts.on('-E encoding', 'Specify the default encoding for Sass and CSS files.') do |encoding|
|
529
|
-
Encoding.default_external = encoding
|
530
|
-
end
|
531
|
-
end
|
532
|
-
|
533
|
-
super
|
534
|
-
end
|
535
|
-
|
536
|
-
# Processes the options set by the command-line arguments,
|
537
|
-
# and runs the CSS compiler appropriately.
|
538
|
-
def process_result
|
539
|
-
require 'sass'
|
540
|
-
|
541
|
-
if @options[:recursive]
|
542
|
-
process_directory
|
543
|
-
return
|
544
|
-
end
|
545
|
-
|
546
|
-
super
|
547
|
-
input = @options[:input]
|
548
|
-
raise "Error: '#{input.path}' is a directory (did you mean to use --recursive?)" if File.directory?(input)
|
549
|
-
output = @options[:output]
|
550
|
-
output = input if @options[:in_place]
|
551
|
-
process_file(input, output)
|
552
|
-
end
|
553
|
-
|
554
|
-
private
|
555
|
-
|
556
|
-
def process_directory
|
557
|
-
unless input = @options[:input] = @args.shift
|
558
|
-
raise "Error: directory required when using --recursive."
|
559
|
-
end
|
560
|
-
|
561
|
-
output = @options[:output] = @args.shift
|
562
|
-
raise "Error: --from required when using --recursive." unless @options[:from]
|
563
|
-
raise "Error: --to required when using --recursive." unless @options[:to]
|
564
|
-
raise "Error: '#{@options[:input]}' is not a directory" unless File.directory?(@options[:input])
|
565
|
-
if @options[:output] && File.exists?(@options[:output]) && !File.directory?(@options[:output])
|
566
|
-
raise "Error: '#{@options[:output]}' is not a directory"
|
567
|
-
end
|
568
|
-
@options[:output] ||= @options[:input]
|
569
|
-
|
570
|
-
from = @options[:from]
|
571
|
-
if @options[:to] == @options[:from] && !@options[:in_place]
|
572
|
-
fmt = @options[:from]
|
573
|
-
raise "Error: converting from #{fmt} to #{fmt} without --in-place"
|
574
|
-
end
|
575
|
-
|
576
|
-
ext = @options[:from]
|
577
|
-
Dir.glob("#{@options[:input]}/**/*.#{ext}") do |f|
|
578
|
-
output =
|
579
|
-
if @options[:in_place]
|
580
|
-
f
|
581
|
-
elsif @options[:output]
|
582
|
-
output_name = f.gsub(/\.(c|sa|sc|le)ss$/, ".#{@options[:to]}")
|
583
|
-
output_name[0...@options[:input].size] = @options[:output]
|
584
|
-
output_name
|
585
|
-
else
|
586
|
-
f.gsub(/\.(c|sa|sc|le)ss$/, ".#{@options[:to]}")
|
587
|
-
end
|
588
|
-
|
589
|
-
unless File.directory?(File.dirname(output))
|
590
|
-
puts_action :directory, :green, File.dirname(output)
|
591
|
-
FileUtils.mkdir_p(File.dirname(output))
|
592
|
-
end
|
593
|
-
puts_action :convert, :green, f
|
594
|
-
if File.exists?(output)
|
595
|
-
puts_action :overwrite, :yellow, output
|
596
|
-
else
|
597
|
-
puts_action :create, :green, output
|
598
|
-
end
|
599
|
-
|
600
|
-
input = open_file(f)
|
601
|
-
output = @options[:in_place] ? input : open_file(output, "w")
|
602
|
-
process_file(input, output)
|
603
|
-
end
|
604
|
-
end
|
605
|
-
|
606
|
-
def process_file(input, output)
|
607
|
-
if input.is_a?(File)
|
608
|
-
@options[:from] ||=
|
609
|
-
case input.path
|
610
|
-
when /\.scss$/; :scss
|
611
|
-
when /\.sass$/; :sass
|
612
|
-
when /\.less$/; :less
|
613
|
-
when /\.css$/; :css
|
614
|
-
end
|
615
|
-
elsif @options[:in_place]
|
616
|
-
raise "Error: the --in-place option requires a filename."
|
617
|
-
end
|
618
|
-
|
619
|
-
if output.is_a?(File)
|
620
|
-
@options[:to] ||=
|
621
|
-
case output.path
|
622
|
-
when /\.scss$/; :scss
|
623
|
-
when /\.sass$/; :sass
|
624
|
-
end
|
625
|
-
end
|
626
|
-
|
627
|
-
@options[:from] ||= :css
|
628
|
-
@options[:to] ||= :sass
|
629
|
-
@options[:for_engine][:syntax] = @options[:from]
|
630
|
-
|
631
|
-
out =
|
632
|
-
::Sass::Util.silence_sass_warnings do
|
633
|
-
if @options[:from] == :css
|
634
|
-
require 'sass/css'
|
635
|
-
::Sass::CSS.new(input.read, @options[:for_tree]).render(@options[:to])
|
636
|
-
elsif @options[:from] == :less
|
637
|
-
require 'sass/less'
|
638
|
-
try_less_note
|
639
|
-
input = input.read if input.is_a?(IO) && !input.is_a?(File) # Less is dumb
|
640
|
-
Less::Engine.new(input).to_tree.to_sass_tree.send("to_#{@options[:to]}", @options[:for_tree])
|
641
|
-
else
|
642
|
-
if input.is_a?(File)
|
643
|
-
::Sass::Engine.for_file(input.path, @options[:for_engine])
|
644
|
-
else
|
645
|
-
::Sass::Engine.new(input.read, @options[:for_engine])
|
646
|
-
end.to_tree.send("to_#{@options[:to]}", @options[:for_tree])
|
647
|
-
end
|
648
|
-
end
|
649
|
-
|
650
|
-
output = File.open(input.path, 'w') if @options[:in_place]
|
651
|
-
output.write(out)
|
652
|
-
rescue ::Sass::SyntaxError => e
|
653
|
-
raise e if @options[:trace]
|
654
|
-
file = " of #{e.sass_filename}" if e.sass_filename
|
655
|
-
raise "Error on line #{e.sass_line}#{file}: #{e.message}\n Use --trace for backtrace"
|
656
|
-
rescue LoadError => err
|
657
|
-
handle_load_error(err)
|
658
|
-
end
|
659
|
-
|
660
|
-
@@less_note_printed = false
|
661
|
-
def try_less_note
|
662
|
-
return if @@less_note_printed
|
663
|
-
@@less_note_printed = true
|
664
|
-
warn <<NOTE
|
665
|
-
* NOTE: Sass and Less are different languages, and they work differently.
|
666
|
-
* I'll do my best to translate, but some features -- especially mixins --
|
667
|
-
* should be checked by hand.
|
668
|
-
NOTE
|
669
|
-
end
|
670
|
-
end
|
671
|
-
end
|
672
|
-
end
|