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.

Files changed (389) hide show
  1. data/.yardopts +19 -7
  2. data/CHANGELOG.md +1224 -0
  3. data/FAQ.md +157 -0
  4. data/README.md +99 -62
  5. data/REFERENCE.md +1404 -0
  6. data/Rakefile +52 -341
  7. data/init.rb +1 -18
  8. data/lib/haml.rb +6 -30
  9. data/lib/haml/buffer.rb +37 -16
  10. data/lib/haml/compiler.rb +52 -13
  11. data/lib/haml/engine.rb +61 -44
  12. data/lib/haml/exec.rb +21 -4
  13. data/lib/haml/filters.rb +136 -166
  14. data/lib/haml/helpers.rb +37 -10
  15. data/lib/haml/helpers/action_view_extensions.rb +2 -1
  16. data/lib/haml/helpers/action_view_mods.rb +67 -181
  17. data/lib/haml/helpers/rails_323_textarea_fix.rb +39 -0
  18. data/lib/haml/helpers/xss_mods.rb +9 -11
  19. data/lib/haml/html.rb +22 -9
  20. data/lib/haml/html/erb.rb +1 -1
  21. data/lib/haml/parser.rb +22 -15
  22. data/lib/haml/railtie.rb +2 -13
  23. data/lib/haml/template.rb +18 -85
  24. data/lib/haml/template/options.rb +1 -1
  25. data/lib/haml/template/plugin.rb +15 -101
  26. data/lib/haml/util.rb +120 -603
  27. data/lib/haml/version.rb +1 -107
  28. data/test/{haml/engine_test.rb → engine_test.rb} +137 -143
  29. data/test/{haml/erb → erb}/_av_partial_1.erb +1 -1
  30. data/test/{haml/erb → erb}/_av_partial_2.erb +1 -1
  31. data/test/{haml/erb → erb}/action_view.erb +1 -1
  32. data/test/{haml/erb → erb}/standard.erb +0 -0
  33. data/test/filters_test.rb +141 -0
  34. data/test/gemfiles/Gemfile.rails-3.0.x +4 -6
  35. data/test/gemfiles/Gemfile.rails-3.1.x +5 -6
  36. data/test/gemfiles/Gemfile.rails-3.2.x +6 -0
  37. data/test/haml-spec/LICENSE +14 -0
  38. data/test/{haml/spec → haml-spec}/README.md +26 -17
  39. data/test/haml-spec/lua_haml_spec.lua +38 -0
  40. data/test/haml-spec/perl_haml_test.pl +81 -0
  41. data/test/haml-spec/ruby_haml_test.rb +23 -0
  42. data/test/{haml/spec → haml-spec}/tests.json +132 -54
  43. data/test/{haml/helper_test.rb → helper_test.rb} +50 -36
  44. data/test/{haml/html2haml → html2haml}/erb_tests.rb +0 -0
  45. data/test/{haml/html2haml_test.rb → html2haml_test.rb} +11 -5
  46. data/test/{haml/markaby → markaby}/standard.mab +0 -0
  47. data/test/{haml/mocks → mocks}/article.rb +0 -0
  48. data/test/{haml/results → results}/content_for_layout.xhtml +0 -0
  49. data/test/{haml/results → results}/eval_suppressed.xhtml +0 -0
  50. data/test/{haml/results → results}/helpers.xhtml +0 -0
  51. data/test/{haml/results → results}/helpful.xhtml +0 -0
  52. data/test/{haml/results → results}/just_stuff.xhtml +0 -0
  53. data/test/{haml/results → results}/list.xhtml +0 -0
  54. data/test/{haml/results → results}/nuke_inner_whitespace.xhtml +0 -0
  55. data/test/{haml/results → results}/nuke_outer_whitespace.xhtml +0 -0
  56. data/test/{haml/results → results}/original_engine.xhtml +0 -0
  57. data/test/{haml/results → results}/partial_layout.xhtml +0 -0
  58. data/test/{haml/results → results}/partials.xhtml +0 -0
  59. data/test/{haml/results → results}/render_layout.xhtml +0 -0
  60. data/test/{haml/results → results}/silent_script.xhtml +1 -1
  61. data/test/{haml/results → results}/standard.xhtml +0 -0
  62. data/test/{haml/results → results}/tag_parsing.xhtml +0 -0
  63. data/test/{haml/results → results}/very_basic.xhtml +0 -0
  64. data/test/{haml/results → results}/whitespace_handling.xhtml +46 -50
  65. data/test/{haml/template_test.rb → template_test.rb} +20 -81
  66. data/test/{haml/templates → templates}/_av_partial_1.haml +1 -1
  67. data/test/{haml/templates → templates}/_av_partial_1_ugly.haml +1 -1
  68. data/test/{haml/templates → templates}/_av_partial_2.haml +1 -1
  69. data/test/{haml/templates → templates}/_av_partial_2_ugly.haml +1 -1
  70. data/test/{haml/templates → templates}/_layout.erb +0 -0
  71. data/test/{haml/templates → templates}/_layout_for_partial.haml +0 -0
  72. data/test/{haml/templates → templates}/_partial.haml +0 -0
  73. data/test/{haml/templates → templates}/_text_area.haml +0 -0
  74. data/test/{haml/templates → templates}/action_view.haml +1 -1
  75. data/test/{haml/templates → templates}/action_view_ugly.haml +1 -1
  76. data/test/{haml/templates → templates}/breakage.haml +0 -0
  77. data/test/{haml/templates → templates}/content_for_layout.haml +0 -0
  78. data/test/{haml/templates → templates}/eval_suppressed.haml +0 -0
  79. data/test/{haml/templates → templates}/helpers.haml +0 -0
  80. data/test/{haml/templates → templates}/helpful.haml +0 -0
  81. data/test/{haml/templates → templates}/just_stuff.haml +0 -0
  82. data/test/{haml/templates → templates}/list.haml +0 -0
  83. data/test/{haml/templates → templates}/nuke_inner_whitespace.haml +0 -0
  84. data/test/{haml/templates → templates}/nuke_outer_whitespace.haml +0 -0
  85. data/test/{haml/templates → templates}/original_engine.haml +0 -0
  86. data/test/templates/partial_layout.haml +3 -0
  87. data/test/{haml/templates → templates}/partialize.haml +0 -0
  88. data/test/{haml/templates → templates}/partials.haml +0 -0
  89. data/test/{haml/templates → templates}/render_layout.haml +0 -0
  90. data/test/{haml/templates → templates}/silent_script.haml +2 -2
  91. data/test/{haml/templates → templates}/standard.haml +0 -0
  92. data/test/{haml/templates → templates}/standard_ugly.haml +0 -0
  93. data/test/{haml/templates → templates}/tag_parsing.haml +0 -0
  94. data/test/{haml/templates → templates}/very_basic.haml +0 -0
  95. data/test/{haml/templates → templates}/whitespace_handling.haml +0 -0
  96. data/test/test_helper.rb +42 -34
  97. data/test/util_test.rb +80 -0
  98. metadata +259 -427
  99. data/CONTRIBUTING +0 -3
  100. data/REVISION +0 -1
  101. data/VERSION +0 -1
  102. data/VERSION_NAME +0 -1
  103. data/extra/update_watch.rb +0 -13
  104. data/lib/haml/root.rb +0 -7
  105. data/lib/haml/shared.rb +0 -78
  106. data/lib/haml/template/patch.rb +0 -58
  107. data/lib/sass.rb +0 -8
  108. data/lib/sass/plugin.rb +0 -10
  109. data/lib/sass/rails2_shim.rb +0 -9
  110. data/lib/sass/rails3_shim.rb +0 -16
  111. data/test/benchmark.rb +0 -91
  112. data/test/gemfiles/Gemfile.rails-2.0.x +0 -8
  113. data/test/gemfiles/Gemfile.rails-2.0.x.lock +0 -38
  114. data/test/gemfiles/Gemfile.rails-2.1.x +0 -8
  115. data/test/gemfiles/Gemfile.rails-2.1.x.lock +0 -38
  116. data/test/gemfiles/Gemfile.rails-2.2.x +0 -8
  117. data/test/gemfiles/Gemfile.rails-2.2.x.lock +0 -38
  118. data/test/gemfiles/Gemfile.rails-2.3.x +0 -8
  119. data/test/gemfiles/Gemfile.rails-2.3.x.lock +0 -40
  120. data/test/gemfiles/Gemfile.rails-3.0.x.lock +0 -85
  121. data/test/gemfiles/Gemfile.rails-3.1.x.lock +0 -98
  122. data/test/gemfiles/Gemfile.rails-xss-2.3.x +0 -9
  123. data/test/gemfiles/Gemfile.rails-xss-2.3.x.lock +0 -42
  124. data/test/haml/results/filters.xhtml +0 -62
  125. data/test/haml/spec/lua_haml_spec.lua +0 -30
  126. data/test/haml/spec/ruby_haml_test.rb +0 -19
  127. data/test/haml/spec_test.rb +0 -44
  128. data/test/haml/templates/filters.haml +0 -66
  129. data/test/haml/templates/partial_layout.haml +0 -10
  130. data/test/haml/util_test.rb +0 -300
  131. data/test/linked_rails.rb +0 -42
  132. data/vendor/sass/CONTRIBUTING +0 -3
  133. data/vendor/sass/MIT-LICENSE +0 -20
  134. data/vendor/sass/README.md +0 -201
  135. data/vendor/sass/Rakefile +0 -339
  136. data/vendor/sass/TODO +0 -39
  137. data/vendor/sass/VERSION +0 -1
  138. data/vendor/sass/VERSION_NAME +0 -1
  139. data/vendor/sass/bin/sass +0 -8
  140. data/vendor/sass/bin/sass-convert +0 -7
  141. data/vendor/sass/bin/scss +0 -8
  142. data/vendor/sass/doc-src/FAQ.md +0 -35
  143. data/vendor/sass/doc-src/INDENTED_SYNTAX.md +0 -210
  144. data/vendor/sass/doc-src/SASS_CHANGELOG.md +0 -2327
  145. data/vendor/sass/doc-src/SASS_REFERENCE.md +0 -1965
  146. data/vendor/sass/doc-src/SCSS_FOR_SASS_USERS.md +0 -155
  147. data/vendor/sass/ext/extconf.rb +0 -10
  148. data/vendor/sass/extra/update_watch.rb +0 -13
  149. data/vendor/sass/init.rb +0 -18
  150. data/vendor/sass/lib/sass.rb +0 -73
  151. data/vendor/sass/lib/sass/cache_stores.rb +0 -15
  152. data/vendor/sass/lib/sass/cache_stores/base.rb +0 -86
  153. data/vendor/sass/lib/sass/cache_stores/chain.rb +0 -33
  154. data/vendor/sass/lib/sass/cache_stores/filesystem.rb +0 -60
  155. data/vendor/sass/lib/sass/cache_stores/memory.rb +0 -47
  156. data/vendor/sass/lib/sass/cache_stores/null.rb +0 -25
  157. data/vendor/sass/lib/sass/callbacks.rb +0 -66
  158. data/vendor/sass/lib/sass/css.rb +0 -295
  159. data/vendor/sass/lib/sass/engine.rb +0 -878
  160. data/vendor/sass/lib/sass/environment.rb +0 -166
  161. data/vendor/sass/lib/sass/error.rb +0 -201
  162. data/vendor/sass/lib/sass/exec.rb +0 -672
  163. data/vendor/sass/lib/sass/importers.rb +0 -22
  164. data/vendor/sass/lib/sass/importers/base.rb +0 -139
  165. data/vendor/sass/lib/sass/importers/filesystem.rb +0 -149
  166. data/vendor/sass/lib/sass/less.rb +0 -382
  167. data/vendor/sass/lib/sass/logger.rb +0 -15
  168. data/vendor/sass/lib/sass/logger/base.rb +0 -32
  169. data/vendor/sass/lib/sass/logger/log_level.rb +0 -49
  170. data/vendor/sass/lib/sass/plugin.rb +0 -132
  171. data/vendor/sass/lib/sass/plugin/compiler.rb +0 -383
  172. data/vendor/sass/lib/sass/plugin/configuration.rb +0 -123
  173. data/vendor/sass/lib/sass/plugin/generic.rb +0 -15
  174. data/vendor/sass/lib/sass/plugin/merb.rb +0 -48
  175. data/vendor/sass/lib/sass/plugin/rack.rb +0 -60
  176. data/vendor/sass/lib/sass/plugin/rails.rb +0 -47
  177. data/vendor/sass/lib/sass/plugin/staleness_checker.rb +0 -173
  178. data/vendor/sass/lib/sass/railtie.rb +0 -9
  179. data/vendor/sass/lib/sass/repl.rb +0 -58
  180. data/vendor/sass/lib/sass/root.rb +0 -7
  181. data/vendor/sass/lib/sass/script.rb +0 -40
  182. data/vendor/sass/lib/sass/script/bool.rb +0 -18
  183. data/vendor/sass/lib/sass/script/color.rb +0 -480
  184. data/vendor/sass/lib/sass/script/css_lexer.rb +0 -29
  185. data/vendor/sass/lib/sass/script/css_parser.rb +0 -31
  186. data/vendor/sass/lib/sass/script/funcall.rb +0 -175
  187. data/vendor/sass/lib/sass/script/functions.rb +0 -1386
  188. data/vendor/sass/lib/sass/script/interpolation.rb +0 -79
  189. data/vendor/sass/lib/sass/script/lexer.rb +0 -339
  190. data/vendor/sass/lib/sass/script/list.rb +0 -83
  191. data/vendor/sass/lib/sass/script/literal.rb +0 -250
  192. data/vendor/sass/lib/sass/script/node.rb +0 -99
  193. data/vendor/sass/lib/sass/script/number.rb +0 -452
  194. data/vendor/sass/lib/sass/script/operation.rb +0 -99
  195. data/vendor/sass/lib/sass/script/parser.rb +0 -474
  196. data/vendor/sass/lib/sass/script/string.rb +0 -51
  197. data/vendor/sass/lib/sass/script/string_interpolation.rb +0 -103
  198. data/vendor/sass/lib/sass/script/unary_operation.rb +0 -64
  199. data/vendor/sass/lib/sass/script/variable.rb +0 -59
  200. data/vendor/sass/lib/sass/scss.rb +0 -17
  201. data/vendor/sass/lib/sass/scss/css_parser.rb +0 -46
  202. data/vendor/sass/lib/sass/scss/parser.rb +0 -960
  203. data/vendor/sass/lib/sass/scss/rx.rb +0 -128
  204. data/vendor/sass/lib/sass/scss/sass_parser.rb +0 -11
  205. data/vendor/sass/lib/sass/scss/script_lexer.rb +0 -15
  206. data/vendor/sass/lib/sass/scss/script_parser.rb +0 -25
  207. data/vendor/sass/lib/sass/scss/static_parser.rb +0 -40
  208. data/vendor/sass/lib/sass/selector.rb +0 -361
  209. data/vendor/sass/lib/sass/selector/abstract_sequence.rb +0 -62
  210. data/vendor/sass/lib/sass/selector/comma_sequence.rb +0 -81
  211. data/vendor/sass/lib/sass/selector/sequence.rb +0 -233
  212. data/vendor/sass/lib/sass/selector/simple.rb +0 -113
  213. data/vendor/sass/lib/sass/selector/simple_sequence.rb +0 -134
  214. data/vendor/sass/lib/sass/shared.rb +0 -78
  215. data/vendor/sass/lib/sass/tree/charset_node.rb +0 -22
  216. data/vendor/sass/lib/sass/tree/comment_node.rb +0 -90
  217. data/vendor/sass/lib/sass/tree/debug_node.rb +0 -18
  218. data/vendor/sass/lib/sass/tree/directive_node.rb +0 -23
  219. data/vendor/sass/lib/sass/tree/each_node.rb +0 -24
  220. data/vendor/sass/lib/sass/tree/extend_node.rb +0 -29
  221. data/vendor/sass/lib/sass/tree/for_node.rb +0 -36
  222. data/vendor/sass/lib/sass/tree/function_node.rb +0 -27
  223. data/vendor/sass/lib/sass/tree/if_node.rb +0 -52
  224. data/vendor/sass/lib/sass/tree/import_node.rb +0 -68
  225. data/vendor/sass/lib/sass/tree/media_node.rb +0 -32
  226. data/vendor/sass/lib/sass/tree/mixin_def_node.rb +0 -27
  227. data/vendor/sass/lib/sass/tree/mixin_node.rb +0 -32
  228. data/vendor/sass/lib/sass/tree/node.rb +0 -201
  229. data/vendor/sass/lib/sass/tree/prop_node.rb +0 -148
  230. data/vendor/sass/lib/sass/tree/return_node.rb +0 -18
  231. data/vendor/sass/lib/sass/tree/root_node.rb +0 -28
  232. data/vendor/sass/lib/sass/tree/rule_node.rb +0 -136
  233. data/vendor/sass/lib/sass/tree/variable_node.rb +0 -30
  234. data/vendor/sass/lib/sass/tree/visitors/base.rb +0 -75
  235. data/vendor/sass/lib/sass/tree/visitors/check_nesting.rb +0 -133
  236. data/vendor/sass/lib/sass/tree/visitors/convert.rb +0 -260
  237. data/vendor/sass/lib/sass/tree/visitors/cssize.rb +0 -175
  238. data/vendor/sass/lib/sass/tree/visitors/deep_copy.rb +0 -87
  239. data/vendor/sass/lib/sass/tree/visitors/perform.rb +0 -332
  240. data/vendor/sass/lib/sass/tree/visitors/set_options.rb +0 -97
  241. data/vendor/sass/lib/sass/tree/visitors/to_css.rb +0 -210
  242. data/vendor/sass/lib/sass/tree/warn_node.rb +0 -18
  243. data/vendor/sass/lib/sass/tree/while_node.rb +0 -18
  244. data/vendor/sass/lib/sass/util.rb +0 -721
  245. data/vendor/sass/lib/sass/util/subset_map.rb +0 -101
  246. data/vendor/sass/lib/sass/version.rb +0 -112
  247. data/vendor/sass/rails/init.rb +0 -1
  248. data/vendor/sass/sass.gemspec +0 -33
  249. data/vendor/sass/test/Gemfile +0 -4
  250. data/vendor/sass/test/Gemfile.lock +0 -19
  251. data/vendor/sass/test/sass/cache_test.rb +0 -89
  252. data/vendor/sass/test/sass/callbacks_test.rb +0 -61
  253. data/vendor/sass/test/sass/conversion_test.rb +0 -1199
  254. data/vendor/sass/test/sass/css2sass_test.rb +0 -373
  255. data/vendor/sass/test/sass/data/hsl-rgb.txt +0 -319
  256. data/vendor/sass/test/sass/engine_test.rb +0 -2567
  257. data/vendor/sass/test/sass/extend_test.rb +0 -1348
  258. data/vendor/sass/test/sass/fixtures/test_staleness_check_across_importers.css +0 -1
  259. data/vendor/sass/test/sass/fixtures/test_staleness_check_across_importers.scss +0 -1
  260. data/vendor/sass/test/sass/functions_test.rb +0 -1038
  261. data/vendor/sass/test/sass/importer_test.rb +0 -192
  262. data/vendor/sass/test/sass/less_conversion_test.rb +0 -653
  263. data/vendor/sass/test/sass/logger_test.rb +0 -58
  264. data/vendor/sass/test/sass/mock_importer.rb +0 -49
  265. data/vendor/sass/test/sass/more_results/more1.css +0 -9
  266. data/vendor/sass/test/sass/more_results/more1_with_line_comments.css +0 -26
  267. data/vendor/sass/test/sass/more_results/more_import.css +0 -29
  268. data/vendor/sass/test/sass/more_templates/_more_partial.sass +0 -2
  269. data/vendor/sass/test/sass/more_templates/more1.sass +0 -23
  270. data/vendor/sass/test/sass/more_templates/more_import.sass +0 -11
  271. data/vendor/sass/test/sass/plugin_test.rb +0 -472
  272. data/vendor/sass/test/sass/results/alt.css +0 -4
  273. data/vendor/sass/test/sass/results/basic.css +0 -9
  274. data/vendor/sass/test/sass/results/compact.css +0 -5
  275. data/vendor/sass/test/sass/results/complex.css +0 -86
  276. data/vendor/sass/test/sass/results/compressed.css +0 -1
  277. data/vendor/sass/test/sass/results/expanded.css +0 -19
  278. data/vendor/sass/test/sass/results/if.css +0 -3
  279. data/vendor/sass/test/sass/results/import.css +0 -31
  280. data/vendor/sass/test/sass/results/import_charset.css +0 -4
  281. data/vendor/sass/test/sass/results/import_charset_1_8.css +0 -4
  282. data/vendor/sass/test/sass/results/import_charset_ibm866.css +0 -4
  283. data/vendor/sass/test/sass/results/line_numbers.css +0 -49
  284. data/vendor/sass/test/sass/results/mixins.css +0 -95
  285. data/vendor/sass/test/sass/results/multiline.css +0 -24
  286. data/vendor/sass/test/sass/results/nested.css +0 -22
  287. data/vendor/sass/test/sass/results/options.css +0 -1
  288. data/vendor/sass/test/sass/results/parent_ref.css +0 -13
  289. data/vendor/sass/test/sass/results/script.css +0 -16
  290. data/vendor/sass/test/sass/results/scss_import.css +0 -31
  291. data/vendor/sass/test/sass/results/scss_importee.css +0 -2
  292. data/vendor/sass/test/sass/results/subdir/nested_subdir/nested_subdir.css +0 -1
  293. data/vendor/sass/test/sass/results/subdir/subdir.css +0 -3
  294. data/vendor/sass/test/sass/results/units.css +0 -11
  295. data/vendor/sass/test/sass/results/warn.css +0 -0
  296. data/vendor/sass/test/sass/results/warn_imported.css +0 -0
  297. data/vendor/sass/test/sass/script_conversion_test.rb +0 -285
  298. data/vendor/sass/test/sass/script_test.rb +0 -514
  299. data/vendor/sass/test/sass/scss/css_test.rb +0 -922
  300. data/vendor/sass/test/sass/scss/rx_test.rb +0 -156
  301. data/vendor/sass/test/sass/scss/scss_test.rb +0 -1273
  302. data/vendor/sass/test/sass/scss/test_helper.rb +0 -37
  303. data/vendor/sass/test/sass/templates/_imported_charset_ibm866.sass +0 -4
  304. data/vendor/sass/test/sass/templates/_imported_charset_utf8.sass +0 -4
  305. data/vendor/sass/test/sass/templates/_partial.sass +0 -2
  306. data/vendor/sass/test/sass/templates/alt.sass +0 -16
  307. data/vendor/sass/test/sass/templates/basic.sass +0 -23
  308. data/vendor/sass/test/sass/templates/bork1.sass +0 -2
  309. data/vendor/sass/test/sass/templates/bork2.sass +0 -2
  310. data/vendor/sass/test/sass/templates/bork3.sass +0 -2
  311. data/vendor/sass/test/sass/templates/bork4.sass +0 -2
  312. data/vendor/sass/test/sass/templates/bork5.sass +0 -3
  313. data/vendor/sass/test/sass/templates/compact.sass +0 -17
  314. data/vendor/sass/test/sass/templates/complex.sass +0 -305
  315. data/vendor/sass/test/sass/templates/compressed.sass +0 -15
  316. data/vendor/sass/test/sass/templates/expanded.sass +0 -17
  317. data/vendor/sass/test/sass/templates/if.sass +0 -11
  318. data/vendor/sass/test/sass/templates/import.sass +0 -12
  319. data/vendor/sass/test/sass/templates/import_charset.sass +0 -7
  320. data/vendor/sass/test/sass/templates/import_charset_1_8.sass +0 -4
  321. data/vendor/sass/test/sass/templates/import_charset_ibm866.sass +0 -9
  322. data/vendor/sass/test/sass/templates/importee.less +0 -2
  323. data/vendor/sass/test/sass/templates/importee.sass +0 -19
  324. data/vendor/sass/test/sass/templates/line_numbers.sass +0 -13
  325. data/vendor/sass/test/sass/templates/mixin_bork.sass +0 -5
  326. data/vendor/sass/test/sass/templates/mixins.sass +0 -76
  327. data/vendor/sass/test/sass/templates/multiline.sass +0 -20
  328. data/vendor/sass/test/sass/templates/nested.sass +0 -25
  329. data/vendor/sass/test/sass/templates/nested_bork1.sass +0 -2
  330. data/vendor/sass/test/sass/templates/nested_bork2.sass +0 -2
  331. data/vendor/sass/test/sass/templates/nested_bork3.sass +0 -2
  332. data/vendor/sass/test/sass/templates/nested_bork4.sass +0 -2
  333. data/vendor/sass/test/sass/templates/nested_bork5.sass +0 -2
  334. data/vendor/sass/test/sass/templates/nested_import.sass +0 -2
  335. data/vendor/sass/test/sass/templates/nested_mixin_bork.sass +0 -6
  336. data/vendor/sass/test/sass/templates/options.sass +0 -2
  337. data/vendor/sass/test/sass/templates/parent_ref.sass +0 -25
  338. data/vendor/sass/test/sass/templates/script.sass +0 -101
  339. data/vendor/sass/test/sass/templates/scss_import.scss +0 -11
  340. data/vendor/sass/test/sass/templates/scss_importee.scss +0 -1
  341. data/vendor/sass/test/sass/templates/subdir/nested_subdir/_nested_partial.sass +0 -2
  342. data/vendor/sass/test/sass/templates/subdir/nested_subdir/nested_subdir.sass +0 -3
  343. data/vendor/sass/test/sass/templates/subdir/subdir.sass +0 -6
  344. data/vendor/sass/test/sass/templates/units.sass +0 -11
  345. data/vendor/sass/test/sass/templates/warn.sass +0 -3
  346. data/vendor/sass/test/sass/templates/warn_imported.sass +0 -4
  347. data/vendor/sass/test/sass/test_helper.rb +0 -8
  348. data/vendor/sass/test/sass/util/subset_map_test.rb +0 -91
  349. data/vendor/sass/test/sass/util_test.rb +0 -266
  350. data/vendor/sass/test/test_helper.rb +0 -69
  351. data/vendor/sass/vendor/fssm/Gemfile +0 -3
  352. data/vendor/sass/vendor/fssm/LICENSE +0 -20
  353. data/vendor/sass/vendor/fssm/README.markdown +0 -83
  354. data/vendor/sass/vendor/fssm/Rakefile +0 -11
  355. data/vendor/sass/vendor/fssm/example.rb +0 -12
  356. data/vendor/sass/vendor/fssm/fssm.gemspec +0 -24
  357. data/vendor/sass/vendor/fssm/lib/fssm.rb +0 -37
  358. data/vendor/sass/vendor/fssm/lib/fssm/backends/fsevents.rb +0 -36
  359. data/vendor/sass/vendor/fssm/lib/fssm/backends/inotify.rb +0 -26
  360. data/vendor/sass/vendor/fssm/lib/fssm/backends/polling.rb +0 -25
  361. data/vendor/sass/vendor/fssm/lib/fssm/backends/rbfsevent.rb +0 -42
  362. data/vendor/sass/vendor/fssm/lib/fssm/backends/rubycocoa/fsevents.rb +0 -131
  363. data/vendor/sass/vendor/fssm/lib/fssm/monitor.rb +0 -36
  364. data/vendor/sass/vendor/fssm/lib/fssm/path.rb +0 -94
  365. data/vendor/sass/vendor/fssm/lib/fssm/pathname.rb +0 -36
  366. data/vendor/sass/vendor/fssm/lib/fssm/state/directory.rb +0 -75
  367. data/vendor/sass/vendor/fssm/lib/fssm/state/file.rb +0 -24
  368. data/vendor/sass/vendor/fssm/lib/fssm/support.rb +0 -92
  369. data/vendor/sass/vendor/fssm/lib/fssm/tree.rb +0 -176
  370. data/vendor/sass/vendor/fssm/lib/fssm/version.rb +0 -3
  371. data/vendor/sass/vendor/fssm/profile/prof-cache.rb +0 -40
  372. data/vendor/sass/vendor/fssm/profile/prof-fssm-pathname.html +0 -1231
  373. data/vendor/sass/vendor/fssm/profile/prof-pathname-rubinius.rb +0 -35
  374. data/vendor/sass/vendor/fssm/profile/prof-pathname.rb +0 -68
  375. data/vendor/sass/vendor/fssm/profile/prof-plain-pathname.html +0 -988
  376. data/vendor/sass/vendor/fssm/profile/prof.html +0 -2379
  377. data/vendor/sass/vendor/fssm/spec/count_down_latch.rb +0 -151
  378. data/vendor/sass/vendor/fssm/spec/monitor_spec.rb +0 -202
  379. data/vendor/sass/vendor/fssm/spec/path_spec.rb +0 -96
  380. data/vendor/sass/vendor/fssm/spec/root/duck/quack.txt +0 -0
  381. data/vendor/sass/vendor/fssm/spec/root/file.css +0 -0
  382. data/vendor/sass/vendor/fssm/spec/root/file.rb +0 -0
  383. data/vendor/sass/vendor/fssm/spec/root/file.yml +0 -0
  384. data/vendor/sass/vendor/fssm/spec/root/moo/cow.txt +0 -0
  385. data/vendor/sass/vendor/fssm/spec/spec_helper.rb +0 -14
  386. data/vendor/sass/yard/callbacks.rb +0 -29
  387. data/vendor/sass/yard/default/fulldoc/html/css/common.sass +0 -26
  388. data/vendor/sass/yard/default/layout/html/footer.erb +0 -12
  389. data/vendor/sass/yard/inherited_hash.rb +0 -41
@@ -1,97 +0,0 @@
1
- # A visitor for setting options on the Sass tree
2
- class Sass::Tree::Visitors::SetOptions < Sass::Tree::Visitors::Base
3
- # @param root [Tree::Node] The root node of the tree to visit.
4
- # @param options [{Symbol => Object}] The options has to set.
5
- def self.visit(root, options); new(options).send(:visit, root); end
6
-
7
- protected
8
-
9
- def initialize(options)
10
- @options = options
11
- end
12
-
13
- def visit(node)
14
- node.instance_variable_set('@options', @options)
15
- super
16
- end
17
-
18
- def visit_debug(node)
19
- node.expr.options = @options
20
- yield
21
- end
22
-
23
- def visit_each(node)
24
- node.list.options = @options
25
- yield
26
- end
27
-
28
- def visit_extend(node)
29
- node.selector.each {|c| c.options = @options if c.is_a?(Sass::Script::Node)}
30
- yield
31
- end
32
-
33
- def visit_for(node)
34
- node.from.options = @options
35
- node.to.options = @options
36
- yield
37
- end
38
-
39
- def visit_function(node)
40
- node.args.each do |k, v|
41
- k.options = @options
42
- v.options = @options if v
43
- end
44
- yield
45
- end
46
-
47
- def visit_if(node)
48
- node.expr.options = @options if node.expr
49
- visit(node.else) if node.else
50
- yield
51
- end
52
-
53
- def visit_mixindef(node)
54
- node.args.each do |k, v|
55
- k.options = @options
56
- v.options = @options if v
57
- end
58
- yield
59
- end
60
-
61
- def visit_mixin(node)
62
- node.args.each {|a| a.options = @options}
63
- node.keywords.each {|k, v| v.options = @options}
64
- yield
65
- end
66
-
67
- def visit_prop(node)
68
- node.name.each {|c| c.options = @options if c.is_a?(Sass::Script::Node)}
69
- node.value.options = @options
70
- yield
71
- end
72
-
73
- def visit_return(node)
74
- node.expr.options = @options
75
- yield
76
- end
77
-
78
- def visit_rule(node)
79
- node.rule.each {|c| c.options = @options if c.is_a?(Sass::Script::Node)}
80
- yield
81
- end
82
-
83
- def visit_variable(node)
84
- node.expr.options = @options
85
- yield
86
- end
87
-
88
- def visit_warn(node)
89
- node.expr.options = @options
90
- yield
91
- end
92
-
93
- def visit_while(node)
94
- node.expr.options = @options
95
- yield
96
- end
97
- end
@@ -1,210 +0,0 @@
1
- # A visitor for converting a Sass tree into CSS.
2
- class Sass::Tree::Visitors::ToCss < Sass::Tree::Visitors::Base
3
- protected
4
-
5
- def initialize
6
- @tabs = 0
7
- end
8
-
9
- def visit(node)
10
- super
11
- rescue Sass::SyntaxError => e
12
- e.modify_backtrace(:filename => node.filename, :line => node.line)
13
- raise e
14
- end
15
-
16
- def with_tabs(tabs)
17
- old_tabs, @tabs = @tabs, tabs
18
- yield
19
- ensure
20
- @tabs = old_tabs
21
- end
22
-
23
- def visit_root(node)
24
- result = String.new
25
- node.children.each do |child|
26
- next if child.invisible?
27
- child_str = visit(child)
28
- result << child_str + (node.style == :compressed ? '' : "\n")
29
- end
30
- result.rstrip!
31
- return "" if result.empty?
32
- result << "\n"
33
- unless Sass::Util.ruby1_8? || result.ascii_only?
34
- if node.children.first.is_a?(Sass::Tree::CharsetNode)
35
- begin
36
- encoding = node.children.first.name
37
- # Default to big-endian encoding, because we have to decide somehow
38
- encoding << 'BE' if encoding =~ /\Autf-(16|32)\Z/i
39
- result = result.encode(Encoding.find(encoding))
40
- rescue EncodingError
41
- end
42
- end
43
-
44
- result = "@charset \"#{result.encoding.name}\";#{
45
- node.style == :compressed ? '' : "\n"
46
- }".encode(result.encoding) + result
47
- end
48
- result
49
- rescue Sass::SyntaxError => e
50
- e.sass_template ||= node.template
51
- raise e
52
- end
53
-
54
- def visit_charset(node)
55
- "@charset \"#{node.name}\";"
56
- end
57
-
58
- def visit_comment(node)
59
- return if node.invisible?
60
- spaces = (' ' * [@tabs - node.resolved_value[/^ */].size, 0].max)
61
-
62
- content = node.resolved_value.gsub(/^/, spaces).gsub(%r{^(\s*)//(.*)$}) do |md|
63
- "#{$1}/*#{$2} */"
64
- end
65
- content.gsub!(/\n +(\* *(?!\/))?/, ' ') if (node.style == :compact || node.style == :compressed) && !node.loud
66
- content
67
- end
68
-
69
- def visit_directive(node)
70
- return node.value + ";" unless node.has_children
71
- return node.value + " {}" if node.children.empty?
72
- result = if node.style == :compressed
73
- "#{node.value}{"
74
- else
75
- "#{' ' * @tabs}#{node.value} {" + (node.style == :compact ? ' ' : "\n")
76
- end
77
- was_prop = false
78
- first = true
79
- node.children.each do |child|
80
- next if child.invisible?
81
- if node.style == :compact
82
- if child.is_a?(Sass::Tree::PropNode)
83
- with_tabs(first || was_prop ? 0 : @tabs + 1) {result << visit(child) << ' '}
84
- else
85
- result[-1] = "\n" if was_prop
86
- rendered = with_tabs(@tabs + 1) {visit(child).dup}
87
- rendered = rendered.lstrip if first
88
- result << rendered.rstrip + "\n"
89
- end
90
- was_prop = child.is_a?(Sass::Tree::PropNode)
91
- first = false
92
- elsif node.style == :compressed
93
- result << (was_prop ? ";" : "") << with_tabs(0) {visit(child)}
94
- was_prop = child.is_a?(Sass::Tree::PropNode)
95
- else
96
- result << with_tabs(@tabs + 1) {visit(child)} + "\n"
97
- end
98
- end
99
- result.rstrip + if node.style == :compressed
100
- "}"
101
- else
102
- (node.style == :expanded ? "\n" : " ") + "}\n"
103
- end
104
- end
105
-
106
- def visit_media(node)
107
- str = with_tabs(@tabs + node.tabs) {visit_directive(node)}
108
- str.gsub!(/\n\Z/, '') unless node.style == :compressed || node.group_end
109
- str
110
- end
111
-
112
- def visit_prop(node)
113
- tab_str = ' ' * (@tabs + node.tabs)
114
- if node.style == :compressed
115
- "#{tab_str}#{node.resolved_name}:#{node.resolved_value}"
116
- else
117
- "#{tab_str}#{node.resolved_name}: #{node.resolved_value};"
118
- end
119
- end
120
-
121
- def visit_rule(node)
122
- with_tabs(@tabs + node.tabs) do
123
- rule_separator = node.style == :compressed ? ',' : ', '
124
- line_separator =
125
- case node.style
126
- when :nested, :expanded; "\n"
127
- when :compressed; ""
128
- else; " "
129
- end
130
- rule_indent = ' ' * @tabs
131
- per_rule_indent, total_indent = [:nested, :expanded].include?(node.style) ? [rule_indent, ''] : ['', rule_indent]
132
-
133
- joined_rules = node.resolved_rules.members.map do |seq|
134
- rule_part = seq.to_a.join
135
- rule_part.gsub!(/\s*([^,])\s*\n\s*/m, '\1 ') if node.style == :compressed
136
- rule_part
137
- end.join(rule_separator)
138
-
139
- joined_rules.sub!(/\A\s*/, per_rule_indent)
140
- joined_rules.gsub!(/\s*\n\s*/, "#{line_separator}#{per_rule_indent}")
141
- total_rule = total_indent << joined_rules
142
-
143
- to_return = ''
144
- old_spaces = ' ' * @tabs
145
- spaces = ' ' * (@tabs + 1)
146
- if node.style != :compressed
147
- if node.options[:debug_info]
148
- to_return << visit(debug_info_rule(node.debug_info, node.options)) << "\n"
149
- elsif node.options[:trace_selectors]
150
- to_return << "#{old_spaces}/* "
151
- to_return << node.stack_trace.join("\n #{old_spaces}")
152
- to_return << " */\n"
153
- elsif node.options[:line_comments]
154
- to_return << "#{old_spaces}/* line #{node.line}"
155
-
156
- if node.filename
157
- relative_filename = if node.options[:css_filename]
158
- begin
159
- Pathname.new(node.filename).relative_path_from(
160
- Pathname.new(File.dirname(node.options[:css_filename]))).to_s
161
- rescue ArgumentError
162
- nil
163
- end
164
- end
165
- relative_filename ||= node.filename
166
- to_return << ", #{relative_filename}"
167
- end
168
-
169
- to_return << " */\n"
170
- end
171
- end
172
-
173
- if node.style == :compact
174
- properties = with_tabs(0) {node.children.map {|a| visit(a)}.join(' ')}
175
- to_return << "#{total_rule} { #{properties} }#{"\n" if node.group_end}"
176
- elsif node.style == :compressed
177
- properties = with_tabs(0) {node.children.map {|a| visit(a)}.join(';')}
178
- to_return << "#{total_rule}{#{properties}}"
179
- else
180
- properties = with_tabs(@tabs + 1) {node.children.map {|a| visit(a)}.join("\n")}
181
- end_props = (node.style == :expanded ? "\n" + old_spaces : ' ')
182
- to_return << "#{total_rule} {\n#{properties}#{end_props}}#{"\n" if node.group_end}"
183
- end
184
-
185
- to_return
186
- end
187
- end
188
-
189
- private
190
-
191
- def debug_info_rule(debug_info, options)
192
- node = Sass::Tree::DirectiveNode.new("@media -sass-debug-info")
193
- debug_info.map {|k, v| [k.to_s, v.to_s]}.sort.each do |k, v|
194
- rule = Sass::Tree::RuleNode.new([""])
195
- rule.resolved_rules = Sass::Selector::CommaSequence.new(
196
- [Sass::Selector::Sequence.new(
197
- [Sass::Selector::SimpleSequence.new(
198
- [Sass::Selector::Element.new(k.to_s.gsub(/[^\w-]/, "\\\\\\0"), nil)])
199
- ])
200
- ])
201
- prop = Sass::Tree::PropNode.new([""], Sass::Script::String.new(''), :new)
202
- prop.resolved_name = "font-family"
203
- prop.resolved_value = Sass::SCSS::RX.escape_ident(v.to_s)
204
- rule << prop
205
- node << rule
206
- end
207
- node.options = options.merge(:debug_info => false, :line_comments => false, :style => :compressed)
208
- node
209
- end
210
- end
@@ -1,18 +0,0 @@
1
- module Sass
2
- module Tree
3
- # A dynamic node representing a Sass `@warn` statement.
4
- #
5
- # @see Sass::Tree
6
- class WarnNode < Node
7
- # The expression to print.
8
- # @return [Script::Node]
9
- attr_accessor :expr
10
-
11
- # @param expr [Script::Node] The expression to print
12
- def initialize(expr)
13
- @expr = expr
14
- super()
15
- end
16
- end
17
- end
18
- end
@@ -1,18 +0,0 @@
1
- require 'sass/tree/node'
2
-
3
- module Sass::Tree
4
- # A dynamic node representing a Sass `@while` loop.
5
- #
6
- # @see Sass::Tree
7
- class WhileNode < Node
8
- # The parse tree for the continuation expression.
9
- # @return [Script::Node]
10
- attr_accessor :expr
11
-
12
- # @param expr [Script::Node] See \{#expr}
13
- def initialize(expr)
14
- @expr = expr
15
- super()
16
- end
17
- end
18
- end
@@ -1,721 +0,0 @@
1
- require 'erb'
2
- require 'set'
3
- require 'enumerator'
4
- require 'stringio'
5
- require 'strscan'
6
- require 'rbconfig'
7
-
8
- require 'sass/root'
9
- require 'sass/util/subset_map'
10
-
11
- module Sass
12
- # A module containing various useful functions.
13
- module Util
14
- extend self
15
-
16
- # An array of ints representing the Ruby version number.
17
- # @api public
18
- RUBY_VERSION = ::RUBY_VERSION.split(".").map {|s| s.to_i}
19
-
20
- # The Ruby engine we're running under. Defaults to `"ruby"`
21
- # if the top-level constant is undefined.
22
- # @api public
23
- RUBY_ENGINE = defined?(::RUBY_ENGINE) ? ::RUBY_ENGINE : "ruby"
24
-
25
- # Returns the path of a file relative to the Sass root directory.
26
- #
27
- # @param file [String] The filename relative to the Sass root
28
- # @return [String] The filename relative to the the working directory
29
- def scope(file)
30
- File.join(Sass::ROOT_DIR, file)
31
- end
32
-
33
- # Converts an array of `[key, value]` pairs to a hash.
34
- #
35
- # @example
36
- # to_hash([[:foo, "bar"], [:baz, "bang"]])
37
- # #=> {:foo => "bar", :baz => "bang"}
38
- # @param arr [Array<(Object, Object)>] An array of pairs
39
- # @return [Hash] A hash
40
- def to_hash(arr)
41
- Hash[arr.compact]
42
- end
43
-
44
- # Maps the keys in a hash according to a block.
45
- #
46
- # @example
47
- # map_keys({:foo => "bar", :baz => "bang"}) {|k| k.to_s}
48
- # #=> {"foo" => "bar", "baz" => "bang"}
49
- # @param hash [Hash] The hash to map
50
- # @yield [key] A block in which the keys are transformed
51
- # @yieldparam key [Object] The key that should be mapped
52
- # @yieldreturn [Object] The new value for the key
53
- # @return [Hash] The mapped hash
54
- # @see #map_vals
55
- # @see #map_hash
56
- def map_keys(hash)
57
- to_hash(hash.map {|k, v| [yield(k), v]})
58
- end
59
-
60
- # Maps the values in a hash according to a block.
61
- #
62
- # @example
63
- # map_values({:foo => "bar", :baz => "bang"}) {|v| v.to_sym}
64
- # #=> {:foo => :bar, :baz => :bang}
65
- # @param hash [Hash] The hash to map
66
- # @yield [value] A block in which the values are transformed
67
- # @yieldparam value [Object] The value that should be mapped
68
- # @yieldreturn [Object] The new value for the value
69
- # @return [Hash] The mapped hash
70
- # @see #map_keys
71
- # @see #map_hash
72
- def map_vals(hash)
73
- to_hash(hash.map {|k, v| [k, yield(v)]})
74
- end
75
-
76
- # Maps the key-value pairs of a hash according to a block.
77
- #
78
- # @example
79
- # map_hash({:foo => "bar", :baz => "bang"}) {|k, v| [k.to_s, v.to_sym]}
80
- # #=> {"foo" => :bar, "baz" => :bang}
81
- # @param hash [Hash] The hash to map
82
- # @yield [key, value] A block in which the key-value pairs are transformed
83
- # @yieldparam [key] The hash key
84
- # @yieldparam [value] The hash value
85
- # @yieldreturn [(Object, Object)] The new value for the `[key, value]` pair
86
- # @return [Hash] The mapped hash
87
- # @see #map_keys
88
- # @see #map_vals
89
- def map_hash(hash, &block)
90
- to_hash(hash.map(&block))
91
- end
92
-
93
- # Computes the powerset of the given array.
94
- # This is the set of all subsets of the array.
95
- #
96
- # @example
97
- # powerset([1, 2, 3]) #=>
98
- # Set[Set[], Set[1], Set[2], Set[3], Set[1, 2], Set[2, 3], Set[1, 3], Set[1, 2, 3]]
99
- # @param arr [Enumerable]
100
- # @return [Set<Set>] The subsets of `arr`
101
- def powerset(arr)
102
- arr.inject([Set.new].to_set) do |powerset, el|
103
- new_powerset = Set.new
104
- powerset.each do |subset|
105
- new_powerset << subset
106
- new_powerset << subset + [el]
107
- end
108
- new_powerset
109
- end
110
- end
111
-
112
- # Restricts a number to falling within a given range.
113
- # Returns the number if it falls within the range,
114
- # or the closest value in the range if it doesn't.
115
- #
116
- # @param value [Numeric]
117
- # @param range [Range<Numeric>]
118
- # @return [Numeric]
119
- def restrict(value, range)
120
- [[value, range.first].max, range.last].min
121
- end
122
-
123
- # Concatenates all strings that are adjacent in an array,
124
- # while leaving other elements as they are.
125
- #
126
- # @example
127
- # merge_adjacent_strings([1, "foo", "bar", 2, "baz"])
128
- # #=> [1, "foobar", 2, "baz"]
129
- # @param arr [Array]
130
- # @return [Array] The enumerable with strings merged
131
- def merge_adjacent_strings(arr)
132
- # Optimize for the common case of one element
133
- return arr if arr.size < 2
134
- arr.inject([]) do |a, e|
135
- if e.is_a?(String)
136
- if a.last.is_a?(String)
137
- a.last << e
138
- else
139
- a << e.dup
140
- end
141
- else
142
- a << e
143
- end
144
- a
145
- end
146
- end
147
-
148
- # Intersperses a value in an enumerable, as would be done with `Array#join`
149
- # but without concatenating the array together afterwards.
150
- #
151
- # @param enum [Enumerable]
152
- # @param val
153
- # @return [Array]
154
- def intersperse(enum, val)
155
- enum.inject([]) {|a, e| a << e << val}[0...-1]
156
- end
157
-
158
- # Substitutes a sub-array of one array with another sub-array.
159
- #
160
- # @param ary [Array] The array in which to make the substitution
161
- # @param from [Array] The sequence of elements to replace with `to`
162
- # @param to [Array] The sequence of elements to replace `from` with
163
- def substitute(ary, from, to)
164
- res = ary.dup
165
- i = 0
166
- while i < res.size
167
- if res[i...i+from.size] == from
168
- res[i...i+from.size] = to
169
- end
170
- i += 1
171
- end
172
- res
173
- end
174
-
175
- # Destructively strips whitespace from the beginning and end
176
- # of the first and last elements, respectively,
177
- # in the array (if those elements are strings).
178
- #
179
- # @param arr [Array]
180
- # @return [Array] `arr`
181
- def strip_string_array(arr)
182
- arr.first.lstrip! if arr.first.is_a?(String)
183
- arr.last.rstrip! if arr.last.is_a?(String)
184
- arr
185
- end
186
-
187
- # Return an array of all possible paths through the given arrays.
188
- #
189
- # @param arrs [Array<Array>]
190
- # @return [Array<Arrays>]
191
- #
192
- # @example
193
- # paths([[1, 2], [3, 4], [5]]) #=>
194
- # # [[1, 3, 5],
195
- # # [2, 3, 5],
196
- # # [1, 4, 5],
197
- # # [2, 4, 5]]
198
- def paths(arrs)
199
- arrs.inject([[]]) do |paths, arr|
200
- flatten(arr.map {|e| paths.map {|path| path + [e]}}, 1)
201
- end
202
- end
203
-
204
- # Computes a single longest common subsequence for `x` and `y`.
205
- # If there are more than one longest common subsequences,
206
- # the one returned is that which starts first in `x`.
207
- #
208
- # @param x [Array]
209
- # @param y [Array]
210
- # @yield [a, b] An optional block to use in place of a check for equality
211
- # between elements of `x` and `y`.
212
- # @yieldreturn [Object, nil] If the two values register as equal,
213
- # this will return the value to use in the LCS array.
214
- # @return [Array] The LCS
215
- def lcs(x, y, &block)
216
- x = [nil, *x]
217
- y = [nil, *y]
218
- block ||= proc {|a, b| a == b && a}
219
- lcs_backtrace(lcs_table(x, y, &block), x, y, x.size-1, y.size-1, &block)
220
- end
221
-
222
- # Returns information about the caller of the previous method.
223
- #
224
- # @param entry [String] An entry in the `#caller` list, or a similarly formatted string
225
- # @return [[String, Fixnum, (String, nil)]] An array containing the filename, line, and method name of the caller.
226
- # The method name may be nil
227
- def caller_info(entry = caller[1])
228
- info = entry.scan(/^(.*?):(-?.*?)(?::.*`(.+)')?$/).first
229
- info[1] = info[1].to_i
230
- # This is added by Rubinius to designate a block, but we don't care about it.
231
- info[2].sub!(/ \{\}\Z/, '') if info[2]
232
- info
233
- end
234
-
235
- # Returns whether one version string represents a more recent version than another.
236
- #
237
- # @param v1 [String] A version string.
238
- # @param v2 [String] Another version string.
239
- # @return [Boolean]
240
- def version_gt(v1, v2)
241
- # Construct an array to make sure the shorter version is padded with nil
242
- Array.new([v1.length, v2.length].max).zip(v1.split("."), v2.split(".")) do |_, p1, p2|
243
- p1 ||= "0"
244
- p2 ||= "0"
245
- release1 = p1 =~ /^[0-9]+$/
246
- release2 = p2 =~ /^[0-9]+$/
247
- if release1 && release2
248
- # Integer comparison if both are full releases
249
- p1, p2 = p1.to_i, p2.to_i
250
- next if p1 == p2
251
- return p1 > p2
252
- elsif !release1 && !release2
253
- # String comparison if both are prereleases
254
- next if p1 == p2
255
- return p1 > p2
256
- else
257
- # If only one is a release, that one is newer
258
- return release1
259
- end
260
- end
261
- end
262
-
263
- # Returns whether one version string represents the same or a more
264
- # recent version than another.
265
- #
266
- # @param v1 [String] A version string.
267
- # @param v2 [String] Another version string.
268
- # @return [Boolean]
269
- def version_geq(v1, v2)
270
- version_gt(v1, v2) || !version_gt(v2, v1)
271
- end
272
-
273
- # Throws a NotImplementedError for an abstract method.
274
- #
275
- # @param obj [Object] `self`
276
- # @raise [NotImplementedError]
277
- def abstract(obj)
278
- raise NotImplementedError.new("#{obj.class} must implement ##{caller_info[2]}")
279
- end
280
-
281
- # Silence all output to STDERR within a block.
282
- #
283
- # @yield A block in which no output will be printed to STDERR
284
- def silence_warnings
285
- the_real_stderr, $stderr = $stderr, StringIO.new
286
- yield
287
- ensure
288
- $stderr = the_real_stderr
289
- end
290
-
291
- @@silence_warnings = false
292
- # Silences all Sass warnings within a block.
293
- #
294
- # @yield A block in which no Sass warnings will be printed
295
- def silence_sass_warnings
296
- old_level, Sass.logger.log_level = Sass.logger.log_level, :error
297
- yield
298
- ensure
299
- Sass.logger.log_level = old_level
300
- end
301
-
302
- # The same as `Kernel#warn`, but is silenced by \{#silence\_sass\_warnings}.
303
- #
304
- # @param msg [String]
305
- def sass_warn(msg)
306
- Sass.logger.warn(msg)
307
- end
308
-
309
- ## Cross Rails Version Compatibility
310
-
311
- # Returns the root of the Rails application,
312
- # if this is running in a Rails context.
313
- # Returns `nil` if no such root is defined.
314
- #
315
- # @return [String, nil]
316
- def rails_root
317
- if defined?(::Rails.root)
318
- return ::Rails.root.to_s if ::Rails.root
319
- raise "ERROR: Rails.root is nil!"
320
- end
321
- return RAILS_ROOT.to_s if defined?(RAILS_ROOT)
322
- return nil
323
- end
324
-
325
- # Returns the environment of the Rails application,
326
- # if this is running in a Rails context.
327
- # Returns `nil` if no such environment is defined.
328
- #
329
- # @return [String, nil]
330
- def rails_env
331
- return ::Rails.env.to_s if defined?(::Rails.env)
332
- return RAILS_ENV.to_s if defined?(RAILS_ENV)
333
- return nil
334
- end
335
-
336
- # Returns whether this environment is using ActionPack
337
- # version 3.0.0 or greater.
338
- #
339
- # @return [Boolean]
340
- def ap_geq_3?
341
- ap_geq?("3.0.0.beta1")
342
- end
343
-
344
- # Returns whether this environment is using ActionPack
345
- # of a version greater than or equal to that specified.
346
- #
347
- # @param version [String] The string version number to check against.
348
- # Should be greater than or equal to Rails 3,
349
- # because otherwise ActionPack::VERSION isn't autoloaded
350
- # @return [Boolean]
351
- def ap_geq?(version)
352
- # The ActionPack module is always loaded automatically in Rails >= 3
353
- return false unless defined?(ActionPack) && defined?(ActionPack::VERSION) &&
354
- defined?(ActionPack::VERSION::STRING)
355
-
356
- version_geq(ActionPack::VERSION::STRING, version)
357
- end
358
-
359
- # Returns an ActionView::Template* class.
360
- # In pre-3.0 versions of Rails, most of these classes
361
- # were of the form `ActionView::TemplateFoo`,
362
- # while afterwards they were of the form `ActionView;:Template::Foo`.
363
- #
364
- # @param name [#to_s] The name of the class to get.
365
- # For example, `:Error` will return `ActionView::TemplateError`
366
- # or `ActionView::Template::Error`.
367
- def av_template_class(name)
368
- return ActionView.const_get("Template#{name}") if ActionView.const_defined?("Template#{name}")
369
- return ActionView::Template.const_get(name.to_s)
370
- end
371
-
372
- ## Cross-OS Compatibility
373
-
374
- # Whether or not this is running on Windows.
375
- #
376
- # @return [Boolean]
377
- def windows?
378
- RbConfig::CONFIG['host_os'] =~ /mswin|windows|mingw/i
379
- end
380
-
381
- # Whether or not this is running on IronRuby.
382
- #
383
- # @return [Boolean]
384
- def ironruby?
385
- RUBY_ENGINE == "ironruby"
386
- end
387
-
388
- ## Cross-Ruby-Version Compatibility
389
-
390
- # Whether or not this is running under Ruby 1.8 or lower.
391
- #
392
- # Note that IronRuby counts as Ruby 1.8,
393
- # because it doesn't support the Ruby 1.9 encoding API.
394
- #
395
- # @return [Boolean]
396
- def ruby1_8?
397
- # IronRuby says its version is 1.9, but doesn't support any of the encoding APIs.
398
- # We have to fall back to 1.8 behavior.
399
- ironruby? || (Sass::Util::RUBY_VERSION[0] == 1 && Sass::Util::RUBY_VERSION[1] < 9)
400
- end
401
-
402
- # Whether or not this is running under Ruby 1.8.6 or lower.
403
- # Note that lower versions are not officially supported.
404
- #
405
- # @return [Boolean]
406
- def ruby1_8_6?
407
- ruby1_8? && Sass::Util::RUBY_VERSION[2] < 7
408
- end
409
-
410
- # Checks that the encoding of a string is valid in Ruby 1.9
411
- # and cleans up potential encoding gotchas like the UTF-8 BOM.
412
- # If it's not, yields an error string describing the invalid character
413
- # and the line on which it occurrs.
414
- #
415
- # @param str [String] The string of which to check the encoding
416
- # @yield [msg] A block in which an encoding error can be raised.
417
- # Only yields if there is an encoding error
418
- # @yieldparam msg [String] The error message to be raised
419
- # @return [String] `str`, potentially with encoding gotchas like BOMs removed
420
- def check_encoding(str)
421
- if ruby1_8?
422
- return str.gsub(/\A\xEF\xBB\xBF/, '') # Get rid of the UTF-8 BOM
423
- elsif str.valid_encoding?
424
- # Get rid of the Unicode BOM if possible
425
- if str.encoding.name =~ /^UTF-(8|16|32)(BE|LE)?$/
426
- return str.gsub(Regexp.new("\\A\uFEFF".encode(str.encoding.name)), '')
427
- else
428
- return str
429
- end
430
- end
431
-
432
- encoding = str.encoding
433
- newlines = Regexp.new("\r\n|\r|\n".encode(encoding).force_encoding("binary"))
434
- str.force_encoding("binary").split(newlines).each_with_index do |line, i|
435
- begin
436
- line.encode(encoding)
437
- rescue Encoding::UndefinedConversionError => e
438
- yield <<MSG.rstrip, i + 1
439
- Invalid #{encoding.name} character #{e.error_char.dump}
440
- MSG
441
- end
442
- end
443
- return str
444
- end
445
-
446
- # Like {\#check\_encoding}, but also checks for a `@charset` declaration
447
- # at the beginning of the file and uses that encoding if it exists.
448
- #
449
- # The Sass encoding rules are simple.
450
- # If a `@charset` declaration exists,
451
- # we assume that that's the original encoding of the document.
452
- # Otherwise, we use whatever encoding Ruby has.
453
- # Then we convert that to UTF-8 to process internally.
454
- # The UTF-8 end result is what's returned by this method.
455
- #
456
- # @param str [String] The string of which to check the encoding
457
- # @yield [msg] A block in which an encoding error can be raised.
458
- # Only yields if there is an encoding error
459
- # @yieldparam msg [String] The error message to be raised
460
- # @return [(String, Encoding)] The original string encoded as UTF-8,
461
- # and the source encoding of the string (or `nil` under Ruby 1.8)
462
- # @raise [Encoding::UndefinedConversionError] if the source encoding
463
- # cannot be converted to UTF-8
464
- # @raise [ArgumentError] if the document uses an unknown encoding with `@charset`
465
- def check_sass_encoding(str, &block)
466
- return check_encoding(str, &block), nil if ruby1_8?
467
- # We allow any printable ASCII characters but double quotes in the charset decl
468
- bin = str.dup.force_encoding("BINARY")
469
- encoding = Sass::Util::ENCODINGS_TO_CHECK.find do |enc|
470
- re = Sass::Util::CHARSET_REGEXPS[enc]
471
- re && bin =~ re
472
- end
473
- charset, bom = $1, $2
474
- if charset
475
- charset = charset.force_encoding(encoding).encode("UTF-8")
476
- if endianness = encoding[/[BL]E$/]
477
- begin
478
- Encoding.find(charset + endianness)
479
- charset << endianness
480
- rescue ArgumentError # Encoding charset + endianness doesn't exist
481
- end
482
- end
483
- str.force_encoding(charset)
484
- elsif bom
485
- str.force_encoding(encoding)
486
- end
487
-
488
- str = check_encoding(str, &block)
489
- return str.encode("UTF-8"), str.encoding
490
- end
491
-
492
- unless ruby1_8?
493
- # @private
494
- def _enc(string, encoding)
495
- string.encode(encoding).force_encoding("BINARY")
496
- end
497
-
498
- # We could automatically add in any non-ASCII-compatible encodings here,
499
- # but there's not really a good way to do that
500
- # without manually checking that each encoding
501
- # encodes all ASCII characters properly,
502
- # which takes long enough to affect the startup time of the CLI.
503
- ENCODINGS_TO_CHECK = %w[UTF-8 UTF-16BE UTF-16LE UTF-32BE UTF-32LE]
504
-
505
- CHARSET_REGEXPS = Hash.new do |h, e|
506
- h[e] =
507
- begin
508
- # /\A(?:\uFEFF)?@charset "(.*?)"|\A(\uFEFF)/
509
- Regexp.new(/\A(?:#{_enc("\uFEFF", e)})?#{
510
- _enc('@charset "', e)}(.*?)#{_enc('"', e)}|\A(#{
511
- _enc("\uFEFF", e)})/)
512
- rescue Encoding::ConverterNotFound => _
513
- nil # JRuby on Java 5 doesn't support UTF-32
514
- rescue
515
- # /\A@charset "(.*?)"/
516
- Regexp.new(/\A#{_enc('@charset "', e)}(.*?)#{_enc('"', e)}/)
517
- end
518
- end
519
- end
520
-
521
- # Checks to see if a class has a given method.
522
- # For example:
523
- #
524
- # Sass::Util.has?(:public_instance_method, String, :gsub) #=> true
525
- #
526
- # Method collections like `Class#instance_methods`
527
- # return strings in Ruby 1.8 and symbols in Ruby 1.9 and on,
528
- # so this handles checking for them in a compatible way.
529
- #
530
- # @param attr [#to_s] The (singular) name of the method-collection method
531
- # (e.g. `:instance_methods`, `:private_methods`)
532
- # @param klass [Module] The class to check the methods of which to check
533
- # @param method [String, Symbol] The name of the method do check for
534
- # @return [Boolean] Whether or not the given collection has the given method
535
- def has?(attr, klass, method)
536
- klass.send("#{attr}s").include?(ruby1_8? ? method.to_s : method.to_sym)
537
- end
538
-
539
- # A version of `Enumerable#enum_with_index` that works in Ruby 1.8 and 1.9.
540
- #
541
- # @param enum [Enumerable] The enumerable to get the enumerator for
542
- # @return [Enumerator] The with-index enumerator
543
- def enum_with_index(enum)
544
- ruby1_8? ? enum.enum_with_index : enum.each_with_index
545
- end
546
-
547
- # A version of `Enumerable#enum_cons` that works in Ruby 1.8 and 1.9.
548
- #
549
- # @param enum [Enumerable] The enumerable to get the enumerator for
550
- # @param n [Fixnum] The size of each cons
551
- # @return [Enumerator] The consed enumerator
552
- def enum_cons(enum, n)
553
- ruby1_8? ? enum.enum_cons(n) : enum.each_cons(n)
554
- end
555
-
556
- # A version of `Enumerable#enum_slice` that works in Ruby 1.8 and 1.9.
557
- #
558
- # @param enum [Enumerable] The enumerable to get the enumerator for
559
- # @param n [Fixnum] The size of each slice
560
- # @return [Enumerator] The consed enumerator
561
- def enum_slice(enum, n)
562
- ruby1_8? ? enum.enum_slice(n) : enum.each_slice(n)
563
- end
564
-
565
- # Returns the ASCII code of the given character.
566
- #
567
- # @param c [String] All characters but the first are ignored.
568
- # @return [Fixnum] The ASCII code of `c`.
569
- def ord(c)
570
- ruby1_8? ? c[0] : c.ord
571
- end
572
-
573
- # Flattens the first `n` nested arrays in a cross-version manner.
574
- #
575
- # @param arr [Array] The array to flatten
576
- # @param n [Fixnum] The number of levels to flatten
577
- # @return [Array] The flattened array
578
- def flatten(arr, n)
579
- return arr.flatten(n) unless ruby1_8_6?
580
- return arr if n == 0
581
- arr.inject([]) {|res, e| e.is_a?(Array) ? res.concat(flatten(e, n - 1)) : res << e}
582
- end
583
-
584
- # Returns the hash code for a set in a cross-version manner.
585
- # Aggravatingly, this is order-dependent in Ruby 1.8.6.
586
- #
587
- # @param set [Set]
588
- # @return [Fixnum] The order-independent hashcode of `set`
589
- def set_hash(set)
590
- return set.hash unless ruby1_8_6?
591
- set.map {|e| e.hash}.uniq.sort.hash
592
- end
593
-
594
- # Tests the hash-equality of two sets in a cross-version manner.
595
- # Aggravatingly, this is order-dependent in Ruby 1.8.6.
596
- #
597
- # @param set1 [Set]
598
- # @param set2 [Set]
599
- # @return [Boolean] Whether or not the sets are hashcode equal
600
- def set_eql?(set1, set2)
601
- return set1.eql?(set2) unless ruby1_8_6?
602
- set1.to_a.uniq.sort_by {|e| e.hash}.eql?(set2.to_a.uniq.sort_by {|e| e.hash})
603
- end
604
-
605
- # Like `Object#inspect`, but preserves non-ASCII characters rather than escaping them under Ruby 1.9.2.
606
- # This is necessary so that the precompiled Haml template can be `#encode`d into `@options[:encoding]`
607
- # before being evaluated.
608
- #
609
- # @param obj {Object}
610
- # @return {String}
611
- def inspect_obj(obj)
612
- return obj.inspect unless version_geq(::RUBY_VERSION, "1.9.2")
613
- return ':' + inspect_obj(obj.to_s) if obj.is_a?(Symbol)
614
- return obj.inspect unless obj.is_a?(String)
615
- '"' + obj.gsub(/[\x00-\x7F]+/) {|s| s.inspect[1...-1]} + '"'
616
- end
617
-
618
- # Extracts the non-string vlaues from an array containing both strings and non-strings.
619
- # These values are replaced with escape sequences.
620
- # This can be undone using \{#inject\_values}.
621
- #
622
- # This is useful e.g. when we want to do string manipulation
623
- # on an interpolated string.
624
- #
625
- # The precise format of the resulting string is not guaranteed.
626
- # However, it is guaranteed that newlines and whitespace won't be affected.
627
- #
628
- # @param arr [Array] The array from which values are extracted.
629
- # @return [(String, Array)] The resulting string, and an array of extracted values.
630
- def extract_values(arr)
631
- values = []
632
- return arr.map do |e|
633
- next e.gsub('{', '{{') if e.is_a?(String)
634
- values << e
635
- next "{#{values.count - 1}}"
636
- end.join, values
637
- end
638
-
639
- # Undoes \{#extract\_values} by transforming a string with escape sequences
640
- # into an array of strings and non-string values.
641
- #
642
- # @param str [String] The string with escape sequences.
643
- # @param values [Array] The array of values to inject.
644
- # @return [Array] The array of strings and values.
645
- def inject_values(str, values)
646
- return [str.gsub('{{', '{')] if values.empty?
647
- # Add an extra { so that we process the tail end of the string
648
- result = (str + '{{').scan(/(.*?)(?:(\{\{)|\{(\d+)\})/m).map do |(pre, esc, n)|
649
- [pre, esc ? '{' : '', n ? values[n.to_i] : '']
650
- end.flatten(1)
651
- result[-2] = '' # Get rid of the extra {
652
- merge_adjacent_strings(result).reject {|s| s == ''}
653
- end
654
-
655
- # Allows modifications to be performed on the string form
656
- # of an array containing both strings and non-strings.
657
- #
658
- # @param arr [Array] The array from which values are extracted.
659
- # @yield [str] A block in which string manipulation can be done to the array.
660
- # @yieldparam str [String] The string form of `arr`.
661
- # @yieldreturn [String] The modified string.
662
- # @return [Array] The modified, interpolated array.
663
- def with_extracted_values(arr)
664
- str, vals = extract_values(arr)
665
- str = yield str
666
- inject_values(str, vals)
667
- end
668
-
669
- ## Static Method Stuff
670
-
671
- # The context in which the ERB for \{#def\_static\_method} will be run.
672
- class StaticConditionalContext
673
- # @param set [#include?] The set of variables that are defined for this context.
674
- def initialize(set)
675
- @set = set
676
- end
677
-
678
- # Checks whether or not a variable is defined for this context.
679
- #
680
- # @param name [Symbol] The name of the variable
681
- # @return [Boolean]
682
- def method_missing(name, *args, &block)
683
- super unless args.empty? && block.nil?
684
- @set.include?(name)
685
- end
686
- end
687
-
688
- private
689
-
690
- # Calculates the memoization table for the Least Common Subsequence algorithm.
691
- # Algorithm from [Wikipedia](http://en.wikipedia.org/wiki/Longest_common_subsequence_problem#Computing_the_length_of_the_LCS)
692
- def lcs_table(x, y)
693
- c = Array.new(x.size) {[]}
694
- x.size.times {|i| c[i][0] = 0}
695
- y.size.times {|j| c[0][j] = 0}
696
- (1...x.size).each do |i|
697
- (1...y.size).each do |j|
698
- c[i][j] =
699
- if yield x[i], y[j]
700
- c[i-1][j-1] + 1
701
- else
702
- [c[i][j-1], c[i-1][j]].max
703
- end
704
- end
705
- end
706
- return c
707
- end
708
-
709
- # Computes a single longest common subsequence for arrays x and y.
710
- # Algorithm from [Wikipedia](http://en.wikipedia.org/wiki/Longest_common_subsequence_problem#Reading_out_an_LCS)
711
- def lcs_backtrace(c, x, y, i, j, &block)
712
- return [] if i == 0 || j == 0
713
- if v = yield(x[i], y[j])
714
- return lcs_backtrace(c, x, y, i-1, j-1, &block) << v
715
- end
716
-
717
- return lcs_backtrace(c, x, y, i, j-1, &block) if c[i][j-1] > c[i-1][j]
718
- return lcs_backtrace(c, x, y, i-1, j, &block)
719
- end
720
- end
721
- end