classiccms 0.3.0 → 0.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (369) hide show
  1. data/lib/classiccms/application.rb +2 -3
  2. data/lib/classiccms/cli.rb +6 -0
  3. data/lib/classiccms/scaffold/Gemfile +4 -0
  4. data/lib/classiccms/{mongoid.yml → scaffold/config/mongoid.yml} +3 -4
  5. data/lib/classiccms/scaffold/spec/models/article_spec.rb +8 -0
  6. data/lib/classiccms/scaffold/spec/spec_helper.rb +24 -0
  7. data/lib/classiccms/version.rb +1 -1
  8. data/spec/cli_spec.rb +8 -0
  9. data/vendor/bundle/gems/libv8-3.3.10.4-x86_64-darwin-11/lib/libv8/build/v8/libv8.a +0 -0
  10. data/vendor/bundle/gems/libv8-3.3.10.4-x86_64-darwin-11/lib/libv8/build/v8/libv8preparser.a +0 -0
  11. data/vendor/bundle/gems/libv8-3.3.10.4-x86_64-darwin-11/lib/libv8/v8/include/v8-debug.h +395 -0
  12. data/vendor/bundle/gems/libv8-3.3.10.4-x86_64-darwin-11/lib/libv8/v8/include/v8-preparser.h +117 -0
  13. data/vendor/bundle/gems/libv8-3.3.10.4-x86_64-darwin-11/lib/libv8/v8/include/v8-profiler.h +505 -0
  14. data/vendor/bundle/gems/libv8-3.3.10.4-x86_64-darwin-11/lib/libv8/v8/include/v8-testing.h +104 -0
  15. data/vendor/bundle/gems/libv8-3.3.10.4-x86_64-darwin-11/lib/libv8/v8/include/v8.h +4124 -0
  16. data/vendor/bundle/gems/libv8-3.3.10.4-x86_64-darwin-11/lib/libv8/v8/include/v8stdint.h +53 -0
  17. data/vendor/bundle/gems/libv8-3.3.10.4-x86_64-darwin-11/lib/libv8/version.rb +6 -0
  18. data/vendor/bundle/gems/libv8-3.3.10.4-x86_64-darwin-11/lib/libv8.rb +15 -0
  19. data/vendor/bundle/gems/sass-3.1.19/.yardopts +11 -0
  20. data/vendor/bundle/gems/sass-3.1.19/CONTRIBUTING +3 -0
  21. data/vendor/bundle/gems/sass-3.1.19/MIT-LICENSE +20 -0
  22. data/vendor/bundle/gems/sass-3.1.19/README.md +200 -0
  23. data/vendor/bundle/gems/sass-3.1.19/REVISION +1 -0
  24. data/vendor/bundle/gems/sass-3.1.19/Rakefile +339 -0
  25. data/vendor/bundle/gems/sass-3.1.19/VERSION +1 -0
  26. data/vendor/bundle/gems/sass-3.1.19/VERSION_NAME +1 -0
  27. data/vendor/bundle/gems/sass-3.1.19/bin/sass +8 -0
  28. data/vendor/bundle/gems/sass-3.1.19/bin/sass-convert +7 -0
  29. data/vendor/bundle/gems/sass-3.1.19/bin/scss +8 -0
  30. data/vendor/bundle/gems/sass-3.1.19/extra/update_watch.rb +13 -0
  31. data/vendor/bundle/gems/sass-3.1.19/init.rb +18 -0
  32. data/vendor/bundle/gems/sass-3.1.19/lib/sass/cache_stores/base.rb +86 -0
  33. data/vendor/bundle/gems/sass-3.1.19/lib/sass/cache_stores/chain.rb +33 -0
  34. data/vendor/bundle/gems/sass-3.1.19/lib/sass/cache_stores/filesystem.rb +61 -0
  35. data/vendor/bundle/gems/sass-3.1.19/lib/sass/cache_stores/memory.rb +47 -0
  36. data/vendor/bundle/gems/sass-3.1.19/lib/sass/cache_stores/null.rb +25 -0
  37. data/vendor/bundle/gems/sass-3.1.19/lib/sass/cache_stores.rb +15 -0
  38. data/vendor/bundle/gems/sass-3.1.19/lib/sass/callbacks.rb +66 -0
  39. data/vendor/bundle/gems/sass-3.1.19/lib/sass/css.rb +390 -0
  40. data/vendor/bundle/gems/sass-3.1.19/lib/sass/engine.rb +880 -0
  41. data/vendor/bundle/gems/sass-3.1.19/lib/sass/environment.rb +180 -0
  42. data/vendor/bundle/gems/sass-3.1.19/lib/sass/error.rb +201 -0
  43. data/vendor/bundle/gems/sass-3.1.19/lib/sass/exec.rb +682 -0
  44. data/vendor/bundle/gems/sass-3.1.19/lib/sass/importers/base.rb +139 -0
  45. data/vendor/bundle/gems/sass-3.1.19/lib/sass/importers/filesystem.rb +149 -0
  46. data/vendor/bundle/gems/sass-3.1.19/lib/sass/importers.rb +22 -0
  47. data/vendor/bundle/gems/sass-3.1.19/lib/sass/less.rb +382 -0
  48. data/vendor/bundle/gems/sass-3.1.19/lib/sass/logger/base.rb +32 -0
  49. data/vendor/bundle/gems/sass-3.1.19/lib/sass/logger/log_level.rb +49 -0
  50. data/vendor/bundle/gems/sass-3.1.19/lib/sass/logger.rb +15 -0
  51. data/vendor/bundle/gems/sass-3.1.19/lib/sass/plugin/compiler.rb +384 -0
  52. data/vendor/bundle/gems/sass-3.1.19/lib/sass/plugin/configuration.rb +123 -0
  53. data/vendor/bundle/gems/sass-3.1.19/lib/sass/plugin/generic.rb +15 -0
  54. data/vendor/bundle/gems/sass-3.1.19/lib/sass/plugin/merb.rb +48 -0
  55. data/vendor/bundle/gems/sass-3.1.19/lib/sass/plugin/rack.rb +60 -0
  56. data/vendor/bundle/gems/sass-3.1.19/lib/sass/plugin/rails.rb +47 -0
  57. data/vendor/bundle/gems/sass-3.1.19/lib/sass/plugin/staleness_checker.rb +183 -0
  58. data/vendor/bundle/gems/sass-3.1.19/lib/sass/plugin.rb +132 -0
  59. data/vendor/bundle/gems/sass-3.1.19/lib/sass/railtie.rb +9 -0
  60. data/vendor/bundle/gems/sass-3.1.19/lib/sass/repl.rb +57 -0
  61. data/vendor/bundle/gems/sass-3.1.19/lib/sass/root.rb +7 -0
  62. data/vendor/bundle/gems/sass-3.1.19/lib/sass/script/bool.rb +18 -0
  63. data/vendor/bundle/gems/sass-3.1.19/lib/sass/script/color.rb +475 -0
  64. data/vendor/bundle/gems/sass-3.1.19/lib/sass/script/css_lexer.rb +29 -0
  65. data/vendor/bundle/gems/sass-3.1.19/lib/sass/script/css_parser.rb +31 -0
  66. data/vendor/bundle/gems/sass-3.1.19/lib/sass/script/funcall.rb +175 -0
  67. data/vendor/bundle/gems/sass-3.1.19/lib/sass/script/functions.rb +1381 -0
  68. data/vendor/bundle/gems/sass-3.1.19/lib/sass/script/interpolation.rb +79 -0
  69. data/vendor/bundle/gems/sass-3.1.19/lib/sass/script/lexer.rb +337 -0
  70. data/vendor/bundle/gems/sass-3.1.19/lib/sass/script/list.rb +84 -0
  71. data/vendor/bundle/gems/sass-3.1.19/lib/sass/script/literal.rb +230 -0
  72. data/vendor/bundle/gems/sass-3.1.19/lib/sass/script/node.rb +99 -0
  73. data/vendor/bundle/gems/sass-3.1.19/lib/sass/script/number.rb +452 -0
  74. data/vendor/bundle/gems/sass-3.1.19/lib/sass/script/operation.rb +107 -0
  75. data/vendor/bundle/gems/sass-3.1.19/lib/sass/script/parser.rb +474 -0
  76. data/vendor/bundle/gems/sass-3.1.19/lib/sass/script/string.rb +51 -0
  77. data/vendor/bundle/gems/sass-3.1.19/lib/sass/script/string_interpolation.rb +103 -0
  78. data/vendor/bundle/gems/sass-3.1.19/lib/sass/script/unary_operation.rb +64 -0
  79. data/vendor/bundle/gems/sass-3.1.19/lib/sass/script/variable.rb +58 -0
  80. data/vendor/bundle/gems/sass-3.1.19/lib/sass/script.rb +39 -0
  81. data/vendor/bundle/gems/sass-3.1.19/lib/sass/scss/css_parser.rb +46 -0
  82. data/vendor/bundle/gems/sass-3.1.19/lib/sass/scss/parser.rb +1055 -0
  83. data/vendor/bundle/gems/sass-3.1.19/lib/sass/scss/rx.rb +137 -0
  84. data/vendor/bundle/gems/sass-3.1.19/lib/sass/scss/sass_parser.rb +11 -0
  85. data/vendor/bundle/gems/sass-3.1.19/lib/sass/scss/script_lexer.rb +15 -0
  86. data/vendor/bundle/gems/sass-3.1.19/lib/sass/scss/script_parser.rb +25 -0
  87. data/vendor/bundle/gems/sass-3.1.19/lib/sass/scss/static_parser.rb +40 -0
  88. data/vendor/bundle/gems/sass-3.1.19/lib/sass/scss.rb +17 -0
  89. data/vendor/bundle/gems/sass-3.1.19/lib/sass/selector/abstract_sequence.rb +71 -0
  90. data/vendor/bundle/gems/sass-3.1.19/lib/sass/selector/comma_sequence.rb +86 -0
  91. data/vendor/bundle/gems/sass-3.1.19/lib/sass/selector/sequence.rb +296 -0
  92. data/vendor/bundle/gems/sass-3.1.19/lib/sass/selector/simple.rb +119 -0
  93. data/vendor/bundle/gems/sass-3.1.19/lib/sass/selector/simple_sequence.rb +154 -0
  94. data/vendor/bundle/gems/sass-3.1.19/lib/sass/selector.rb +373 -0
  95. data/vendor/bundle/gems/sass-3.1.19/lib/sass/shared.rb +76 -0
  96. data/vendor/bundle/gems/sass-3.1.19/lib/sass/tree/charset_node.rb +22 -0
  97. data/vendor/bundle/gems/sass-3.1.19/lib/sass/tree/comment_node.rb +90 -0
  98. data/vendor/bundle/gems/sass-3.1.19/lib/sass/tree/debug_node.rb +18 -0
  99. data/vendor/bundle/gems/sass-3.1.19/lib/sass/tree/directive_node.rb +28 -0
  100. data/vendor/bundle/gems/sass-3.1.19/lib/sass/tree/each_node.rb +24 -0
  101. data/vendor/bundle/gems/sass-3.1.19/lib/sass/tree/extend_node.rb +29 -0
  102. data/vendor/bundle/gems/sass-3.1.19/lib/sass/tree/for_node.rb +36 -0
  103. data/vendor/bundle/gems/sass-3.1.19/lib/sass/tree/function_node.rb +27 -0
  104. data/vendor/bundle/gems/sass-3.1.19/lib/sass/tree/if_node.rb +52 -0
  105. data/vendor/bundle/gems/sass-3.1.19/lib/sass/tree/import_node.rb +68 -0
  106. data/vendor/bundle/gems/sass-3.1.19/lib/sass/tree/media_node.rb +32 -0
  107. data/vendor/bundle/gems/sass-3.1.19/lib/sass/tree/mixin_def_node.rb +27 -0
  108. data/vendor/bundle/gems/sass-3.1.19/lib/sass/tree/mixin_node.rb +32 -0
  109. data/vendor/bundle/gems/sass-3.1.19/lib/sass/tree/node.rb +188 -0
  110. data/vendor/bundle/gems/sass-3.1.19/lib/sass/tree/prop_node.rb +148 -0
  111. data/vendor/bundle/gems/sass-3.1.19/lib/sass/tree/return_node.rb +18 -0
  112. data/vendor/bundle/gems/sass-3.1.19/lib/sass/tree/root_node.rb +28 -0
  113. data/vendor/bundle/gems/sass-3.1.19/lib/sass/tree/rule_node.rb +127 -0
  114. data/vendor/bundle/gems/sass-3.1.19/lib/sass/tree/variable_node.rb +30 -0
  115. data/vendor/bundle/gems/sass-3.1.19/lib/sass/tree/visitors/base.rb +75 -0
  116. data/vendor/bundle/gems/sass-3.1.19/lib/sass/tree/visitors/check_nesting.rb +127 -0
  117. data/vendor/bundle/gems/sass-3.1.19/lib/sass/tree/visitors/convert.rb +262 -0
  118. data/vendor/bundle/gems/sass-3.1.19/lib/sass/tree/visitors/cssize.rb +206 -0
  119. data/vendor/bundle/gems/sass-3.1.19/lib/sass/tree/visitors/deep_copy.rb +87 -0
  120. data/vendor/bundle/gems/sass-3.1.19/lib/sass/tree/visitors/extend.rb +42 -0
  121. data/vendor/bundle/gems/sass-3.1.19/lib/sass/tree/visitors/perform.rb +357 -0
  122. data/vendor/bundle/gems/sass-3.1.19/lib/sass/tree/visitors/set_options.rb +97 -0
  123. data/vendor/bundle/gems/sass-3.1.19/lib/sass/tree/visitors/to_css.rb +219 -0
  124. data/vendor/bundle/gems/sass-3.1.19/lib/sass/tree/warn_node.rb +18 -0
  125. data/vendor/bundle/gems/sass-3.1.19/lib/sass/tree/while_node.rb +18 -0
  126. data/vendor/bundle/gems/sass-3.1.19/lib/sass/util/multibyte_string_scanner.rb +134 -0
  127. data/vendor/bundle/gems/sass-3.1.19/lib/sass/util/subset_map.rb +101 -0
  128. data/vendor/bundle/gems/sass-3.1.19/lib/sass/util.rb +800 -0
  129. data/vendor/bundle/gems/sass-3.1.19/lib/sass/version.rb +112 -0
  130. data/vendor/bundle/gems/sass-3.1.19/lib/sass.rb +73 -0
  131. data/vendor/bundle/gems/sass-3.1.19/rails/init.rb +1 -0
  132. data/vendor/bundle/gems/sass-3.1.19/test/Gemfile +4 -0
  133. data/vendor/bundle/gems/sass-3.1.19/test/sass/cache_test.rb +89 -0
  134. data/vendor/bundle/gems/sass-3.1.19/test/sass/callbacks_test.rb +61 -0
  135. data/vendor/bundle/gems/sass-3.1.19/test/sass/conversion_test.rb +1245 -0
  136. data/vendor/bundle/gems/sass-3.1.19/test/sass/css2sass_test.rb +397 -0
  137. data/vendor/bundle/gems/sass-3.1.19/test/sass/data/hsl-rgb.txt +319 -0
  138. data/vendor/bundle/gems/sass-3.1.19/test/sass/engine_test.rb +2730 -0
  139. data/vendor/bundle/gems/sass-3.1.19/test/sass/extend_test.rb +1663 -0
  140. data/vendor/bundle/gems/sass-3.1.19/test/sass/fixtures/test_staleness_check_across_importers.css +1 -0
  141. data/vendor/bundle/gems/sass-3.1.19/test/sass/fixtures/test_staleness_check_across_importers.scss +1 -0
  142. data/vendor/bundle/gems/sass-3.1.19/test/sass/functions_test.rb +1047 -0
  143. data/vendor/bundle/gems/sass-3.1.19/test/sass/importer_test.rb +192 -0
  144. data/vendor/bundle/gems/sass-3.1.19/test/sass/less_conversion_test.rb +653 -0
  145. data/vendor/bundle/gems/sass-3.1.19/test/sass/logger_test.rb +58 -0
  146. data/vendor/bundle/gems/sass-3.1.19/test/sass/mock_importer.rb +49 -0
  147. data/vendor/bundle/gems/sass-3.1.19/test/sass/more_results/more1.css +9 -0
  148. data/vendor/bundle/gems/sass-3.1.19/test/sass/more_results/more1_with_line_comments.css +26 -0
  149. data/vendor/bundle/gems/sass-3.1.19/test/sass/more_results/more_import.css +29 -0
  150. data/vendor/bundle/gems/sass-3.1.19/test/sass/more_templates/_more_partial.sass +2 -0
  151. data/vendor/bundle/gems/sass-3.1.19/test/sass/more_templates/more1.sass +23 -0
  152. data/vendor/bundle/gems/sass-3.1.19/test/sass/more_templates/more_import.sass +11 -0
  153. data/vendor/bundle/gems/sass-3.1.19/test/sass/plugin_test.rb +496 -0
  154. data/vendor/bundle/gems/sass-3.1.19/test/sass/results/alt.css +4 -0
  155. data/vendor/bundle/gems/sass-3.1.19/test/sass/results/basic.css +9 -0
  156. data/vendor/bundle/gems/sass-3.1.19/test/sass/results/compact.css +5 -0
  157. data/vendor/bundle/gems/sass-3.1.19/test/sass/results/complex.css +86 -0
  158. data/vendor/bundle/gems/sass-3.1.19/test/sass/results/compressed.css +1 -0
  159. data/vendor/bundle/gems/sass-3.1.19/test/sass/results/expanded.css +19 -0
  160. data/vendor/bundle/gems/sass-3.1.19/test/sass/results/if.css +3 -0
  161. data/vendor/bundle/gems/sass-3.1.19/test/sass/results/import.css +31 -0
  162. data/vendor/bundle/gems/sass-3.1.19/test/sass/results/import_charset.css +5 -0
  163. data/vendor/bundle/gems/sass-3.1.19/test/sass/results/import_charset_1_8.css +5 -0
  164. data/vendor/bundle/gems/sass-3.1.19/test/sass/results/import_charset_ibm866.css +5 -0
  165. data/vendor/bundle/gems/sass-3.1.19/test/sass/results/line_numbers.css +49 -0
  166. data/vendor/bundle/gems/sass-3.1.19/test/sass/results/mixins.css +95 -0
  167. data/vendor/bundle/gems/sass-3.1.19/test/sass/results/multiline.css +24 -0
  168. data/vendor/bundle/gems/sass-3.1.19/test/sass/results/nested.css +22 -0
  169. data/vendor/bundle/gems/sass-3.1.19/test/sass/results/options.css +1 -0
  170. data/vendor/bundle/gems/sass-3.1.19/test/sass/results/parent_ref.css +13 -0
  171. data/vendor/bundle/gems/sass-3.1.19/test/sass/results/script.css +16 -0
  172. data/vendor/bundle/gems/sass-3.1.19/test/sass/results/scss_import.css +31 -0
  173. data/vendor/bundle/gems/sass-3.1.19/test/sass/results/scss_importee.css +2 -0
  174. data/vendor/bundle/gems/sass-3.1.19/test/sass/results/subdir/nested_subdir/nested_subdir.css +1 -0
  175. data/vendor/bundle/gems/sass-3.1.19/test/sass/results/subdir/subdir.css +3 -0
  176. data/vendor/bundle/gems/sass-3.1.19/test/sass/results/units.css +11 -0
  177. data/vendor/bundle/gems/sass-3.1.19/test/sass/results/warn.css +0 -0
  178. data/vendor/bundle/gems/sass-3.1.19/test/sass/results/warn_imported.css +0 -0
  179. data/vendor/bundle/gems/sass-3.1.19/test/sass/script_conversion_test.rb +285 -0
  180. data/vendor/bundle/gems/sass-3.1.19/test/sass/script_test.rb +519 -0
  181. data/vendor/bundle/gems/sass-3.1.19/test/sass/scss/css_test.rb +975 -0
  182. data/vendor/bundle/gems/sass-3.1.19/test/sass/scss/rx_test.rb +156 -0
  183. data/vendor/bundle/gems/sass-3.1.19/test/sass/scss/scss_test.rb +1308 -0
  184. data/vendor/bundle/gems/sass-3.1.19/test/sass/scss/test_helper.rb +37 -0
  185. data/vendor/bundle/gems/sass-3.1.19/test/sass/templates/_double_import_loop2.sass +1 -0
  186. data/vendor/bundle/gems/sass-3.1.19/test/sass/templates/_imported_charset_ibm866.sass +4 -0
  187. data/vendor/bundle/gems/sass-3.1.19/test/sass/templates/_imported_charset_utf8.sass +4 -0
  188. data/vendor/bundle/gems/sass-3.1.19/test/sass/templates/_partial.sass +2 -0
  189. data/vendor/bundle/gems/sass-3.1.19/test/sass/templates/alt.sass +16 -0
  190. data/vendor/bundle/gems/sass-3.1.19/test/sass/templates/basic.sass +23 -0
  191. data/vendor/bundle/gems/sass-3.1.19/test/sass/templates/bork1.sass +2 -0
  192. data/vendor/bundle/gems/sass-3.1.19/test/sass/templates/bork2.sass +2 -0
  193. data/vendor/bundle/gems/sass-3.1.19/test/sass/templates/bork3.sass +2 -0
  194. data/vendor/bundle/gems/sass-3.1.19/test/sass/templates/bork4.sass +2 -0
  195. data/vendor/bundle/gems/sass-3.1.19/test/sass/templates/bork5.sass +3 -0
  196. data/vendor/bundle/gems/sass-3.1.19/test/sass/templates/compact.sass +17 -0
  197. data/vendor/bundle/gems/sass-3.1.19/test/sass/templates/complex.sass +305 -0
  198. data/vendor/bundle/gems/sass-3.1.19/test/sass/templates/compressed.sass +15 -0
  199. data/vendor/bundle/gems/sass-3.1.19/test/sass/templates/double_import_loop1.sass +1 -0
  200. data/vendor/bundle/gems/sass-3.1.19/test/sass/templates/expanded.sass +17 -0
  201. data/vendor/bundle/gems/sass-3.1.19/test/sass/templates/if.sass +11 -0
  202. data/vendor/bundle/gems/sass-3.1.19/test/sass/templates/import.sass +12 -0
  203. data/vendor/bundle/gems/sass-3.1.19/test/sass/templates/import_charset.sass +9 -0
  204. data/vendor/bundle/gems/sass-3.1.19/test/sass/templates/import_charset_1_8.sass +6 -0
  205. data/vendor/bundle/gems/sass-3.1.19/test/sass/templates/import_charset_ibm866.sass +11 -0
  206. data/vendor/bundle/gems/sass-3.1.19/test/sass/templates/importee.less +2 -0
  207. data/vendor/bundle/gems/sass-3.1.19/test/sass/templates/importee.sass +19 -0
  208. data/vendor/bundle/gems/sass-3.1.19/test/sass/templates/line_numbers.sass +13 -0
  209. data/vendor/bundle/gems/sass-3.1.19/test/sass/templates/mixin_bork.sass +5 -0
  210. data/vendor/bundle/gems/sass-3.1.19/test/sass/templates/mixins.sass +76 -0
  211. data/vendor/bundle/gems/sass-3.1.19/test/sass/templates/multiline.sass +20 -0
  212. data/vendor/bundle/gems/sass-3.1.19/test/sass/templates/nested.sass +25 -0
  213. data/vendor/bundle/gems/sass-3.1.19/test/sass/templates/nested_bork1.sass +2 -0
  214. data/vendor/bundle/gems/sass-3.1.19/test/sass/templates/nested_bork2.sass +2 -0
  215. data/vendor/bundle/gems/sass-3.1.19/test/sass/templates/nested_bork3.sass +2 -0
  216. data/vendor/bundle/gems/sass-3.1.19/test/sass/templates/nested_bork4.sass +2 -0
  217. data/vendor/bundle/gems/sass-3.1.19/test/sass/templates/nested_bork5.sass +2 -0
  218. data/vendor/bundle/gems/sass-3.1.19/test/sass/templates/nested_import.sass +2 -0
  219. data/vendor/bundle/gems/sass-3.1.19/test/sass/templates/nested_mixin_bork.sass +6 -0
  220. data/vendor/bundle/gems/sass-3.1.19/test/sass/templates/options.sass +2 -0
  221. data/vendor/bundle/gems/sass-3.1.19/test/sass/templates/parent_ref.sass +25 -0
  222. data/vendor/bundle/gems/sass-3.1.19/test/sass/templates/script.sass +101 -0
  223. data/vendor/bundle/gems/sass-3.1.19/test/sass/templates/scss_import.scss +11 -0
  224. data/vendor/bundle/gems/sass-3.1.19/test/sass/templates/scss_importee.scss +1 -0
  225. data/vendor/bundle/gems/sass-3.1.19/test/sass/templates/single_import_loop.sass +1 -0
  226. data/vendor/bundle/gems/sass-3.1.19/test/sass/templates/subdir/nested_subdir/_nested_partial.sass +2 -0
  227. data/vendor/bundle/gems/sass-3.1.19/test/sass/templates/subdir/nested_subdir/nested_subdir.sass +3 -0
  228. data/vendor/bundle/gems/sass-3.1.19/test/sass/templates/subdir/subdir.sass +6 -0
  229. data/vendor/bundle/gems/sass-3.1.19/test/sass/templates/units.sass +11 -0
  230. data/vendor/bundle/gems/sass-3.1.19/test/sass/templates/warn.sass +3 -0
  231. data/vendor/bundle/gems/sass-3.1.19/test/sass/templates/warn_imported.sass +4 -0
  232. data/vendor/bundle/gems/sass-3.1.19/test/sass/test_helper.rb +8 -0
  233. data/vendor/bundle/gems/sass-3.1.19/test/sass/util/multibyte_string_scanner_test.rb +147 -0
  234. data/vendor/bundle/gems/sass-3.1.19/test/sass/util/subset_map_test.rb +91 -0
  235. data/vendor/bundle/gems/sass-3.1.19/test/sass/util_test.rb +282 -0
  236. data/vendor/bundle/gems/sass-3.1.19/test/test_helper.rb +70 -0
  237. data/vendor/bundle/gems/sass-3.1.19/vendor/listen/CHANGELOG.md +90 -0
  238. data/vendor/bundle/gems/sass-3.1.19/vendor/listen/Gemfile +35 -0
  239. data/vendor/bundle/gems/sass-3.1.19/vendor/listen/Guardfile +8 -0
  240. data/vendor/bundle/gems/sass-3.1.19/vendor/listen/LICENSE +20 -0
  241. data/vendor/bundle/gems/sass-3.1.19/vendor/listen/README.md +312 -0
  242. data/vendor/bundle/gems/sass-3.1.19/vendor/listen/Rakefile +47 -0
  243. data/vendor/bundle/gems/sass-3.1.19/vendor/listen/Vagrantfile +96 -0
  244. data/vendor/bundle/gems/sass-3.1.19/vendor/listen/lib/listen/adapter.rb +167 -0
  245. data/vendor/bundle/gems/sass-3.1.19/vendor/listen/lib/listen/adapters/darwin.rb +84 -0
  246. data/vendor/bundle/gems/sass-3.1.19/vendor/listen/lib/listen/adapters/linux.rb +110 -0
  247. data/vendor/bundle/gems/sass-3.1.19/vendor/listen/lib/listen/adapters/polling.rb +66 -0
  248. data/vendor/bundle/gems/sass-3.1.19/vendor/listen/lib/listen/adapters/windows.rb +81 -0
  249. data/vendor/bundle/gems/sass-3.1.19/vendor/listen/lib/listen/directory_record.rb +317 -0
  250. data/vendor/bundle/gems/sass-3.1.19/vendor/listen/lib/listen/listener.rb +203 -0
  251. data/vendor/bundle/gems/sass-3.1.19/vendor/listen/lib/listen/multi_listener.rb +121 -0
  252. data/vendor/bundle/gems/sass-3.1.19/vendor/listen/lib/listen/turnstile.rb +28 -0
  253. data/vendor/bundle/gems/sass-3.1.19/vendor/listen/lib/listen/version.rb +3 -0
  254. data/vendor/bundle/gems/sass-3.1.19/vendor/listen/lib/listen.rb +38 -0
  255. data/vendor/bundle/gems/sass-3.1.19/vendor/listen/listen.gemspec +26 -0
  256. data/vendor/bundle/gems/sass-3.1.19/vendor/listen/spec/listen/adapter_spec.rb +142 -0
  257. data/vendor/bundle/gems/sass-3.1.19/vendor/listen/spec/listen/adapters/darwin_spec.rb +31 -0
  258. data/vendor/bundle/gems/sass-3.1.19/vendor/listen/spec/listen/adapters/linux_spec.rb +41 -0
  259. data/vendor/bundle/gems/sass-3.1.19/vendor/listen/spec/listen/adapters/polling_spec.rb +68 -0
  260. data/vendor/bundle/gems/sass-3.1.19/vendor/listen/spec/listen/adapters/windows_spec.rb +24 -0
  261. data/vendor/bundle/gems/sass-3.1.19/vendor/listen/spec/listen/directory_record_spec.rb +1034 -0
  262. data/vendor/bundle/gems/sass-3.1.19/vendor/listen/spec/listen/listener_spec.rb +155 -0
  263. data/vendor/bundle/gems/sass-3.1.19/vendor/listen/spec/listen/multi_listener_spec.rb +156 -0
  264. data/vendor/bundle/gems/sass-3.1.19/vendor/listen/spec/listen/turnstile_spec.rb +56 -0
  265. data/vendor/bundle/gems/sass-3.1.19/vendor/listen/spec/listen_spec.rb +73 -0
  266. data/vendor/bundle/gems/sass-3.1.19/vendor/listen/spec/spec_helper.rb +16 -0
  267. data/vendor/bundle/gems/sass-3.1.19/vendor/listen/spec/support/adapter_helper.rb +716 -0
  268. data/vendor/bundle/gems/sass-3.1.19/vendor/listen/spec/support/directory_record_helper.rb +55 -0
  269. data/vendor/bundle/gems/sass-3.1.19/vendor/listen/spec/support/fixtures_helper.rb +29 -0
  270. data/vendor/bundle/gems/sass-3.1.19/vendor/listen/spec/support/listeners_helper.rb +144 -0
  271. data/vendor/bundle/gems/sass-3.1.19/vendor/listen/spec/support/platform_helper.rb +11 -0
  272. data/vendor/bundle/gems/therubyracer-0.10.1/.gitignore +13 -0
  273. data/vendor/bundle/gems/therubyracer-0.10.1/.gitmodules +3 -0
  274. data/vendor/bundle/gems/therubyracer-0.10.1/.travis.yml +9 -0
  275. data/vendor/bundle/gems/therubyracer-0.10.1/.yardopts +1 -0
  276. data/vendor/bundle/gems/therubyracer-0.10.1/Changelog.md +196 -0
  277. data/vendor/bundle/gems/therubyracer-0.10.1/Gemfile +1 -0
  278. data/vendor/bundle/gems/therubyracer-0.10.1/README.md +167 -0
  279. data/vendor/bundle/gems/therubyracer-0.10.1/Rakefile +23 -0
  280. data/vendor/bundle/gems/therubyracer-0.10.1/bin/therubyracer +11 -0
  281. data/vendor/bundle/gems/therubyracer-0.10.1/ext/v8/Makefile +213 -0
  282. data/vendor/bundle/gems/therubyracer-0.10.1/ext/v8/extconf.rb +26 -0
  283. data/vendor/bundle/gems/therubyracer-0.10.1/ext/v8/gem_make.out +156 -0
  284. data/vendor/bundle/gems/therubyracer-0.10.1/ext/v8/rr.cpp +189 -0
  285. data/vendor/bundle/gems/therubyracer-0.10.1/ext/v8/rr.h +41 -0
  286. data/vendor/bundle/gems/therubyracer-0.10.1/ext/v8/v8.cpp +48 -0
  287. data/vendor/bundle/gems/therubyracer-0.10.1/ext/v8/v8_array.cpp +48 -0
  288. data/vendor/bundle/gems/therubyracer-0.10.1/ext/v8/v8_array.h +8 -0
  289. data/vendor/bundle/gems/therubyracer-0.10.1/ext/v8/v8_callbacks.cpp +81 -0
  290. data/vendor/bundle/gems/therubyracer-0.10.1/ext/v8/v8_callbacks.h +8 -0
  291. data/vendor/bundle/gems/therubyracer-0.10.1/ext/v8/v8_context.cpp +92 -0
  292. data/vendor/bundle/gems/therubyracer-0.10.1/ext/v8/v8_context.h +6 -0
  293. data/vendor/bundle/gems/therubyracer-0.10.1/ext/v8/v8_date.cpp +34 -0
  294. data/vendor/bundle/gems/therubyracer-0.10.1/ext/v8/v8_date.h +6 -0
  295. data/vendor/bundle/gems/therubyracer-0.10.1/ext/v8/v8_debug.cpp +17 -0
  296. data/vendor/bundle/gems/therubyracer-0.10.1/ext/v8/v8_debug.h +6 -0
  297. data/vendor/bundle/gems/therubyracer-0.10.1/ext/v8/v8_exception.cpp +133 -0
  298. data/vendor/bundle/gems/therubyracer-0.10.1/ext/v8/v8_exception.h +11 -0
  299. data/vendor/bundle/gems/therubyracer-0.10.1/ext/v8/v8_external.cpp +70 -0
  300. data/vendor/bundle/gems/therubyracer-0.10.1/ext/v8/v8_external.h +8 -0
  301. data/vendor/bundle/gems/therubyracer-0.10.1/ext/v8/v8_function.cpp +69 -0
  302. data/vendor/bundle/gems/therubyracer-0.10.1/ext/v8/v8_function.h +11 -0
  303. data/vendor/bundle/gems/therubyracer-0.10.1/ext/v8/v8_handle.cpp +186 -0
  304. data/vendor/bundle/gems/therubyracer-0.10.1/ext/v8/v8_handle.h +48 -0
  305. data/vendor/bundle/gems/therubyracer-0.10.1/ext/v8/v8_locker.cpp +139 -0
  306. data/vendor/bundle/gems/therubyracer-0.10.1/ext/v8/v8_locker.h +6 -0
  307. data/vendor/bundle/gems/therubyracer-0.10.1/ext/v8/v8_message.cpp +67 -0
  308. data/vendor/bundle/gems/therubyracer-0.10.1/ext/v8/v8_message.h +10 -0
  309. data/vendor/bundle/gems/therubyracer-0.10.1/ext/v8/v8_object.cpp +122 -0
  310. data/vendor/bundle/gems/therubyracer-0.10.1/ext/v8/v8_object.h +10 -0
  311. data/vendor/bundle/gems/therubyracer-0.10.1/ext/v8/v8_script.cpp +36 -0
  312. data/vendor/bundle/gems/therubyracer-0.10.1/ext/v8/v8_script.h +8 -0
  313. data/vendor/bundle/gems/therubyracer-0.10.1/ext/v8/v8_string.cpp +52 -0
  314. data/vendor/bundle/gems/therubyracer-0.10.1/ext/v8/v8_string.h +9 -0
  315. data/vendor/bundle/gems/therubyracer-0.10.1/ext/v8/v8_template.cpp +344 -0
  316. data/vendor/bundle/gems/therubyracer-0.10.1/ext/v8/v8_template.h +8 -0
  317. data/vendor/bundle/gems/therubyracer-0.10.1/ext/v8/v8_try_catch.cpp +70 -0
  318. data/vendor/bundle/gems/therubyracer-0.10.1/ext/v8/v8_try_catch.h +5 -0
  319. data/vendor/bundle/gems/therubyracer-0.10.1/ext/v8/v8_v8.cpp +35 -0
  320. data/vendor/bundle/gems/therubyracer-0.10.1/ext/v8/v8_v8.h +6 -0
  321. data/vendor/bundle/gems/therubyracer-0.10.1/ext/v8/v8_value.cpp +175 -0
  322. data/vendor/bundle/gems/therubyracer-0.10.1/ext/v8/v8_value.h +10 -0
  323. data/vendor/bundle/gems/therubyracer-0.10.1/ext/v8/v8_weakref.cpp +61 -0
  324. data/vendor/bundle/gems/therubyracer-0.10.1/ext/v8/v8_weakref.h +29 -0
  325. data/vendor/bundle/gems/therubyracer-0.10.1/lib/v8/access.rb +87 -0
  326. data/vendor/bundle/gems/therubyracer-0.10.1/lib/v8/array.rb +17 -0
  327. data/vendor/bundle/gems/therubyracer-0.10.1/lib/v8/c/locker.rb +18 -0
  328. data/vendor/bundle/gems/therubyracer-0.10.1/lib/v8/cli.rb +133 -0
  329. data/vendor/bundle/gems/therubyracer-0.10.1/lib/v8/context.rb +111 -0
  330. data/vendor/bundle/gems/therubyracer-0.10.1/lib/v8/error.rb +130 -0
  331. data/vendor/bundle/gems/therubyracer-0.10.1/lib/v8/function.rb +44 -0
  332. data/vendor/bundle/gems/therubyracer-0.10.1/lib/v8/object.rb +69 -0
  333. data/vendor/bundle/gems/therubyracer-0.10.1/lib/v8/portal/caller.rb +37 -0
  334. data/vendor/bundle/gems/therubyracer-0.10.1/lib/v8/portal/constructor.rb +98 -0
  335. data/vendor/bundle/gems/therubyracer-0.10.1/lib/v8/portal/function.rb +63 -0
  336. data/vendor/bundle/gems/therubyracer-0.10.1/lib/v8/portal/interceptors.rb +152 -0
  337. data/vendor/bundle/gems/therubyracer-0.10.1/lib/v8/portal/proxies.rb +151 -0
  338. data/vendor/bundle/gems/therubyracer-0.10.1/lib/v8/portal/templates.rb +73 -0
  339. data/vendor/bundle/gems/therubyracer-0.10.1/lib/v8/portal.rb +86 -0
  340. data/vendor/bundle/gems/therubyracer-0.10.1/lib/v8/stack.rb +66 -0
  341. data/vendor/bundle/gems/therubyracer-0.10.1/lib/v8/tap.rb +9 -0
  342. data/vendor/bundle/gems/therubyracer-0.10.1/lib/v8/version.rb +3 -0
  343. data/vendor/bundle/gems/therubyracer-0.10.1/lib/v8.rb +23 -0
  344. data/vendor/bundle/gems/therubyracer-0.10.1/spec/ext/array_spec.rb +15 -0
  345. data/vendor/bundle/gems/therubyracer-0.10.1/spec/ext/cxt_spec.rb +57 -0
  346. data/vendor/bundle/gems/therubyracer-0.10.1/spec/ext/ext_spec_helper.rb +27 -0
  347. data/vendor/bundle/gems/therubyracer-0.10.1/spec/ext/func_spec.rb +64 -0
  348. data/vendor/bundle/gems/therubyracer-0.10.1/spec/ext/object_spec.rb +10 -0
  349. data/vendor/bundle/gems/therubyracer-0.10.1/spec/ext/string_spec.rb +11 -0
  350. data/vendor/bundle/gems/therubyracer-0.10.1/spec/ext/try_catch_spec.rb +60 -0
  351. data/vendor/bundle/gems/therubyracer-0.10.1/spec/redjs/.gitignore +1 -0
  352. data/vendor/bundle/gems/therubyracer-0.10.1/spec/redjs/README.txt +8 -0
  353. data/vendor/bundle/gems/therubyracer-0.10.1/spec/redjs/jsapi_spec.rb +922 -0
  354. data/vendor/bundle/gems/therubyracer-0.10.1/spec/redjs/loadme.js +1 -0
  355. data/vendor/bundle/gems/therubyracer-0.10.1/spec/redjs_helper.rb +3 -0
  356. data/vendor/bundle/gems/therubyracer-0.10.1/spec/spec_helper.rb +9 -0
  357. data/vendor/bundle/gems/therubyracer-0.10.1/spec/v8/error_spec.rb +131 -0
  358. data/vendor/bundle/gems/therubyracer-0.10.1/spec/v8/portal/proxies_spec.rb +106 -0
  359. data/vendor/bundle/gems/therubyracer-0.10.1/specmem/handle_memspec.rb +41 -0
  360. data/vendor/bundle/gems/therubyracer-0.10.1/specmem/object_memspec.rb +14 -0
  361. data/vendor/bundle/gems/therubyracer-0.10.1/specmem/proxies_memspec.rb +49 -0
  362. data/vendor/bundle/gems/therubyracer-0.10.1/specmem/spec_helper.rb +24 -0
  363. data/vendor/bundle/gems/therubyracer-0.10.1/specthread/spec_helper.rb +2 -0
  364. data/vendor/bundle/gems/therubyracer-0.10.1/specthread/threading_spec.rb +13 -0
  365. data/vendor/bundle/gems/therubyracer-0.10.1/thefrontside.png +0 -0
  366. data/vendor/bundle/gems/therubyracer-0.10.1/therubyracer.gemspec +29 -0
  367. data/vendor/bundle/specifications/libv8-3.3.10.4-x86_64-darwin-11.gemspec +33 -0
  368. data/vendor/bundle/specifications/sass-3.1.19.gemspec +35 -0
  369. metadata +365 -3
@@ -0,0 +1,1381 @@
1
+ module Sass::Script
2
+ # Methods in this module are accessible from the SassScript context.
3
+ # For example, you can write
4
+ #
5
+ # $color = hsl(120deg, 100%, 50%)
6
+ #
7
+ # and it will call {Sass::Script::Functions#hsl}.
8
+ #
9
+ # The following functions are provided:
10
+ #
11
+ # *Note: These functions are described in more detail below.*
12
+ #
13
+ # ## RGB Functions
14
+ #
15
+ # \{#rgb rgb($red, $green, $blue)}
16
+ # : Converts an `rgb(red, green, blue)` triplet into a color.
17
+ #
18
+ # \{#rgba rgba($red, $green, $blue, $alpha)}
19
+ # : Converts an `rgba(red, green, blue, alpha)` quadruplet into a color.
20
+ #
21
+ # \{#rgba rgba($color, $alpha)}
22
+ # : Adds an alpha layer to any color value.
23
+ #
24
+ # \{#red red($color)}
25
+ # : Gets the red component of a color.
26
+ #
27
+ # \{#green green($color)}
28
+ # : Gets the green component of a color.
29
+ #
30
+ # \{#blue blue($color)}
31
+ # : Gets the blue component of a color.
32
+ #
33
+ # \{#mix mix($color-1, $color-2, \[$weight\])}
34
+ # : Mixes two colors together.
35
+ #
36
+ # ## HSL Functions
37
+ #
38
+ # \{#hsl hsl($hue, $saturation, $lightness)}
39
+ # : Converts an `hsl(hue, saturation, lightness)` triplet into a color.
40
+ #
41
+ # \{#hsla hsla($hue, $saturation, $lightness, $alpha)}
42
+ # : Converts an `hsla(hue, saturation, lightness, alpha)` quadruplet into a color.
43
+ #
44
+ # \{#hue hue($color)}
45
+ # : Gets the hue component of a color.
46
+ #
47
+ # \{#saturation saturation($color)}
48
+ # : Gets the saturation component of a color.
49
+ #
50
+ # \{#lightness lightness($color)}
51
+ # : Gets the lightness component of a color.
52
+ #
53
+ # \{#adjust_hue adjust-hue($color, $degrees)}
54
+ # : Changes the hue of a color.
55
+ #
56
+ # \{#lighten lighten($color, $amount)}
57
+ # : Makes a color lighter.
58
+ #
59
+ # \{#darken darken($color, $amount)}
60
+ # : Makes a color darker.
61
+ #
62
+ # \{#saturate saturate($color, $amount)}
63
+ # : Makes a color more saturated.
64
+ #
65
+ # \{#desaturate desaturate($color, $amount)}
66
+ # : Makes a color less saturated.
67
+ #
68
+ # \{#grayscale grayscale($color)}
69
+ # : Converts a color to grayscale.
70
+ #
71
+ # \{#complement complement($color)}
72
+ # : Returns the complement of a color.
73
+ #
74
+ # \{#invert invert($color)}
75
+ # : Returns the inverse of a color.
76
+ #
77
+ # ## Opacity Functions
78
+ #
79
+ # \{#alpha alpha($color)} / \{#opacity opacity($color)}
80
+ # : Gets the alpha component (opacity) of a color.
81
+ #
82
+ # \{#rgba rgba($color, $alpha)}
83
+ # : Add or change an alpha layer for any color value.
84
+ #
85
+ # \{#opacify opacify($color, $amount)} / \{#fade_in fade-in($color, $amount)}
86
+ # : Makes a color more opaque.
87
+ #
88
+ # \{#transparentize transparentize($color, $amount)} / \{#fade_out fade-out($color, $amount)}
89
+ # : Makes a color more transparent.
90
+ #
91
+ # ## Other Color Functions
92
+ #
93
+ # \{#adjust_color adjust-color($color, \[$red\], \[$green\], \[$blue\], \[$hue\], \[$saturation\], \[$lightness\], \[$alpha\]}
94
+ # : Increase or decrease any of the components of a color.
95
+ #
96
+ # \{#scale_color scale-color($color, \[$red\], \[$green\], \[$blue\], \[$saturation\], \[$lightness\], \[$alpha\]}
97
+ # : Fluidly scale one or more components of a color.
98
+ #
99
+ # \{#change_color change-color($color, \[$red\], \[$green\], \[$blue\], \[$hue\], \[$saturation\], \[$lightness\], \[$alpha\]}
100
+ # : Changes one or more properties of a color.
101
+ #
102
+ # ## String Functions
103
+ #
104
+ # \{#unquote unquote($string)}
105
+ # : Removes the quotes from a string.
106
+ #
107
+ # \{#quote quote($string)}
108
+ # : Adds quotes to a string.
109
+ #
110
+ # ## Number Functions
111
+ #
112
+ # \{#percentage percentage($value)}
113
+ # : Converts a unitless number to a percentage.
114
+ #
115
+ # \{#round round($value)}
116
+ # : Rounds a number to the nearest whole number.
117
+ #
118
+ # \{#ceil ceil($value)}
119
+ # : Rounds a number up to the nearest whole number.
120
+ #
121
+ # \{#floor floor($value)}
122
+ # : Rounds a number down to the nearest whole number.
123
+ #
124
+ # \{#abs abs($value)}
125
+ # : Returns the absolute value of a number.
126
+ #
127
+ # ## List Functions {#list-functions}
128
+ #
129
+ # \{#length length($list)}
130
+ # : Returns the length of a list.
131
+ #
132
+ # \{#nth nth($list, $n)}
133
+ # : Returns a specific item in a list.
134
+ #
135
+ # \{#join join($list1, $list2, \[$separator\])}
136
+ # : Joins together two lists into one.
137
+ #
138
+ # ## Introspection Functions
139
+ #
140
+ # \{#type_of type-of($value)}
141
+ # : Returns the type of a value.
142
+ #
143
+ # \{#unit unit($number)}
144
+ # : Returns the units associated with a number.
145
+ #
146
+ # \{#unitless unitless($number)}
147
+ # : Returns whether a number has units or not.
148
+ #
149
+ # \{#comparable comparable($number-1, $number-2)}
150
+ # : Returns whether two numbers can be added or compared.
151
+ #
152
+ # ## Miscellaneous Functions
153
+ #
154
+ # \{#if if($condition, $if-true, $if-false)}
155
+ # : Returns one of two values, depending on whether or not a condition is true.
156
+ #
157
+ # ## Adding Custom Functions
158
+ #
159
+ # New Sass functions can be added by adding Ruby methods to this module.
160
+ # For example:
161
+ #
162
+ # module Sass::Script::Functions
163
+ # def reverse(string)
164
+ # assert_type string, :String
165
+ # Sass::Script::String.new(string.value.reverse)
166
+ # end
167
+ # declare :reverse, :args => [:string]
168
+ # end
169
+ #
170
+ # Calling {declare} tells Sass the argument names for your function.
171
+ # If omitted, the function will still work, but will not be able to accept keyword arguments.
172
+ # {declare} can also allow your function to take arbitrary keyword arguments.
173
+ #
174
+ # There are a few things to keep in mind when modifying this module.
175
+ # First of all, the arguments passed are {Sass::Script::Literal} objects.
176
+ # Literal objects are also expected to be returned.
177
+ # This means that Ruby values must be unwrapped and wrapped.
178
+ #
179
+ # Most Literal objects support the {Sass::Script::Literal#value value} accessor
180
+ # for getting their Ruby values.
181
+ # Color objects, though, must be accessed using {Sass::Script::Color#rgb rgb},
182
+ # {Sass::Script::Color#red red}, {Sass::Script::Color#blue green}, or {Sass::Script::Color#blue blue}.
183
+ #
184
+ # Second, making Ruby functions accessible from Sass introduces the temptation
185
+ # to do things like database access within stylesheets.
186
+ # This is generally a bad idea;
187
+ # since Sass files are by default only compiled once,
188
+ # dynamic code is not a great fit.
189
+ #
190
+ # If you really, really need to compile Sass on each request,
191
+ # first make sure you have adequate caching set up.
192
+ # Then you can use {Sass::Engine} to render the code,
193
+ # using the {file:SASS_REFERENCE.md#custom-option `options` parameter}
194
+ # to pass in data that {EvaluationContext#options can be accessed}
195
+ # from your Sass functions.
196
+ #
197
+ # Within one of the functions in this module,
198
+ # methods of {EvaluationContext} can be used.
199
+ #
200
+ # ### Caveats
201
+ #
202
+ # When creating new {Literal} objects within functions,
203
+ # be aware that it's not safe to call {Literal#to_s #to_s}
204
+ # (or other methods that use the string representation)
205
+ # on those objects without first setting {Node#options= the #options attribute}.
206
+ module Functions
207
+ @signatures = {}
208
+
209
+ # A class representing a Sass function signature.
210
+ #
211
+ # @attr args [Array<Symbol>] The names of the arguments to the function.
212
+ # @attr var_args [Boolean] Whether the function takes a variable number of arguments.
213
+ # @attr var_kwargs [Boolean] Whether the function takes an arbitrary set of keyword arguments.
214
+ Signature = Struct.new(:args, :var_args, :var_kwargs)
215
+
216
+ # Declare a Sass signature for a Ruby-defined function.
217
+ # This includes the names of the arguments,
218
+ # whether the function takes a variable number of arguments,
219
+ # and whether the function takes an arbitrary set of keyword arguments.
220
+ #
221
+ # It's not necessary to declare a signature for a function.
222
+ # However, without a signature it won't support keyword arguments.
223
+ #
224
+ # A single function can have multiple signatures declared
225
+ # as long as each one takes a different number of arguments.
226
+ # It's also possible to declare multiple signatures
227
+ # that all take the same number of arguments,
228
+ # but none of them but the first will be used
229
+ # unless the user uses keyword arguments.
230
+ #
231
+ # @param method_name [Symbol] The name of the method
232
+ # whose signature is being declared.
233
+ # @param args [Array<Symbol>] The names of the arguments for the function signature.
234
+ # @option options :var_args [Boolean] (false)
235
+ # Whether the function accepts a variable number of (unnamed) arguments
236
+ # in addition to the named arguments.
237
+ # @option options :var_kwargs [Boolean] (false)
238
+ # Whether the function accepts other keyword arguments
239
+ # in addition to those in `:args`.
240
+ # If this is true, the Ruby function will be passed a hash from strings
241
+ # to {Sass::Script::Literal}s as the last argument.
242
+ # In addition, if this is true and `:var_args` is not,
243
+ # Sass will ensure that the last argument passed is a hash.
244
+ #
245
+ # @example
246
+ # declare :rgba, [:hex, :alpha]
247
+ # declare :rgba, [:red, :green, :blue, :alpha]
248
+ # declare :accepts_anything, [], :var_args => true, :var_kwargs => true
249
+ # declare :some_func, [:foo, :bar, :baz], :var_kwargs => true
250
+ def self.declare(method_name, args, options = {})
251
+ @signatures[method_name] ||= []
252
+ @signatures[method_name] << Signature.new(
253
+ args.map {|s| s.to_s},
254
+ options[:var_args],
255
+ options[:var_kwargs])
256
+ end
257
+
258
+ # Determine the correct signature for the number of arguments
259
+ # passed in for a given function.
260
+ # If no signatures match, the first signature is returned for error messaging.
261
+ #
262
+ # @param method_name [Symbol] The name of the Ruby function to be called.
263
+ # @param arg_arity [Number] The number of unnamed arguments the function was passed.
264
+ # @param kwarg_arity [Number] The number of keyword arguments the function was passed.
265
+ #
266
+ # @return [{Symbol => Object}, nil]
267
+ # The signature options for the matching signature,
268
+ # or nil if no signatures are declared for this function. See {declare}.
269
+ def self.signature(method_name, arg_arity, kwarg_arity)
270
+ return unless @signatures[method_name]
271
+ @signatures[method_name].each do |signature|
272
+ return signature if signature.args.size == arg_arity + kwarg_arity
273
+ next unless signature.args.size < arg_arity + kwarg_arity
274
+
275
+ # We have enough args.
276
+ # Now we need to figure out which args are varargs
277
+ # and if the signature allows them.
278
+ t_arg_arity, t_kwarg_arity = arg_arity, kwarg_arity
279
+ if signature.args.size > t_arg_arity
280
+ # we transfer some kwargs arity to args arity
281
+ # if it does not have enough args -- assuming the names will work out.
282
+ t_kwarg_arity -= (signature.args.size - t_arg_arity)
283
+ t_arg_arity = signature.args.size
284
+ end
285
+
286
+ if ( t_arg_arity == signature.args.size || t_arg_arity > signature.args.size && signature.var_args ) &&
287
+ (t_kwarg_arity == 0 || t_kwarg_arity > 0 && signature.var_kwargs)
288
+ return signature
289
+ end
290
+ end
291
+ @signatures[method_name].first
292
+ end
293
+
294
+ # The context in which methods in {Script::Functions} are evaluated.
295
+ # That means that all instance methods of {EvaluationContext}
296
+ # are available to use in functions.
297
+ class EvaluationContext
298
+ include Functions
299
+
300
+ # The options hash for the {Sass::Engine} that is processing the function call
301
+ #
302
+ # @return [{Symbol => Object}]
303
+ attr_reader :options
304
+
305
+ # @param options [{Symbol => Object}] See \{#options}
306
+ def initialize(options)
307
+ @options = options
308
+ end
309
+
310
+ # Asserts that the type of a given SassScript value
311
+ # is the expected type (designated by a symbol).
312
+ #
313
+ # Valid types are `:Bool`, `:Color`, `:Number`, and `:String`.
314
+ # Note that `:String` will match both double-quoted strings
315
+ # and unquoted identifiers.
316
+ #
317
+ # @example
318
+ # assert_type value, :String
319
+ # assert_type value, :Number
320
+ # @param value [Sass::Script::Literal] A SassScript value
321
+ # @param type [Symbol] The name of the type the value is expected to be
322
+ # @param name [String, nil] The name of the argument.
323
+ def assert_type(value, type, name = nil)
324
+ return if value.is_a?(Sass::Script.const_get(type))
325
+ err = "#{value.inspect} is not a #{type.to_s.downcase}"
326
+ err = "$#{name}: " + err if name
327
+ raise ArgumentError.new(err)
328
+ end
329
+ end
330
+
331
+ class << self
332
+ # Returns whether user function with a given name exists.
333
+ #
334
+ # @param function_name [String]
335
+ # @return [Boolean]
336
+ alias_method :callable?, :public_method_defined?
337
+
338
+ private
339
+ def include(*args)
340
+ r = super
341
+ # We have to re-include ourselves into EvaluationContext to work around
342
+ # an icky Ruby restriction.
343
+ EvaluationContext.send :include, self
344
+ r
345
+ end
346
+ end
347
+
348
+ # Creates a {Color} object from red, green, and blue values.
349
+ #
350
+ # @param red [Number]
351
+ # A number between 0 and 255 inclusive,
352
+ # or between 0% and 100% inclusive
353
+ # @param green [Number]
354
+ # A number between 0 and 255 inclusive,
355
+ # or between 0% and 100% inclusive
356
+ # @param blue [Number]
357
+ # A number between 0 and 255 inclusive,
358
+ # or between 0% and 100% inclusive
359
+ # @see #rgba
360
+ # @return [Color]
361
+ def rgb(red, green, blue)
362
+ assert_type red, :Number
363
+ assert_type green, :Number
364
+ assert_type blue, :Number
365
+
366
+ Color.new([red, green, blue].map do |c|
367
+ v = c.value
368
+ if c.numerator_units == ["%"] && c.denominator_units.empty?
369
+ v = Sass::Util.check_range("Color value", 0..100, c, '%')
370
+ v * 255 / 100.0
371
+ else
372
+ Sass::Util.check_range("Color value", 0..255, c)
373
+ end
374
+ end)
375
+ end
376
+ declare :rgb, [:red, :green, :blue]
377
+
378
+ # @see #rgb
379
+ # @overload rgba(red, green, blue, alpha)
380
+ # Creates a {Color} object from red, green, and blue values,
381
+ # as well as an alpha channel indicating opacity.
382
+ #
383
+ # @param red [Number]
384
+ # A number between 0 and 255 inclusive
385
+ # @param green [Number]
386
+ # A number between 0 and 255 inclusive
387
+ # @param blue [Number]
388
+ # A number between 0 and 255 inclusive
389
+ # @param alpha [Number]
390
+ # A number between 0 and 1
391
+ # @return [Color]
392
+ #
393
+ # @overload rgba(color, alpha)
394
+ # Sets the opacity of a color.
395
+ #
396
+ # @example
397
+ # rgba(#102030, 0.5) => rgba(16, 32, 48, 0.5)
398
+ # rgba(blue, 0.2) => rgba(0, 0, 255, 0.2)
399
+ #
400
+ # @param color [Color]
401
+ # @param alpha [Number]
402
+ # A number between 0 and 1
403
+ # @return [Color]
404
+ def rgba(*args)
405
+ case args.size
406
+ when 2
407
+ color, alpha = args
408
+
409
+ assert_type color, :Color
410
+ assert_type alpha, :Number
411
+
412
+ Sass::Util.check_range('Alpha channel', 0..1, alpha)
413
+ color.with(:alpha => alpha.value)
414
+ when 4
415
+ red, green, blue, alpha = args
416
+ rgba(rgb(red, green, blue), alpha)
417
+ else
418
+ raise ArgumentError.new("wrong number of arguments (#{args.size} for 4)")
419
+ end
420
+ end
421
+ declare :rgba, [:red, :green, :blue, :alpha]
422
+ declare :rgba, [:color, :alpha]
423
+
424
+ # Creates a {Color} object from hue, saturation, and lightness.
425
+ # Uses the algorithm from the [CSS3 spec](http://www.w3.org/TR/css3-color/#hsl-color).
426
+ #
427
+ # @param hue [Number] The hue of the color.
428
+ # Should be between 0 and 360 degrees, inclusive
429
+ # @param saturation [Number] The saturation of the color.
430
+ # Must be between `0%` and `100%`, inclusive
431
+ # @param lightness [Number] The lightness of the color.
432
+ # Must be between `0%` and `100%`, inclusive
433
+ # @return [Color] The resulting color
434
+ # @see #hsla
435
+ # @raise [ArgumentError] if `saturation` or `lightness` are out of bounds
436
+ def hsl(hue, saturation, lightness)
437
+ hsla(hue, saturation, lightness, Number.new(1))
438
+ end
439
+ declare :hsl, [:hue, :saturation, :lightness]
440
+
441
+ # Creates a {Color} object from hue, saturation, and lightness,
442
+ # as well as an alpha channel indicating opacity.
443
+ # Uses the algorithm from the [CSS3 spec](http://www.w3.org/TR/css3-color/#hsl-color).
444
+ #
445
+ # @param hue [Number] The hue of the color.
446
+ # Should be between 0 and 360 degrees, inclusive
447
+ # @param saturation [Number] The saturation of the color.
448
+ # Must be between `0%` and `100%`, inclusive
449
+ # @param lightness [Number] The lightness of the color.
450
+ # Must be between `0%` and `100%`, inclusive
451
+ # @param alpha [Number] The opacity of the color.
452
+ # Must be between 0 and 1, inclusive
453
+ # @return [Color] The resulting color
454
+ # @see #hsl
455
+ # @raise [ArgumentError] if `saturation`, `lightness`, or `alpha` are out of bounds
456
+ def hsla(hue, saturation, lightness, alpha)
457
+ assert_type hue, :Number
458
+ assert_type saturation, :Number
459
+ assert_type lightness, :Number
460
+ assert_type alpha, :Number
461
+
462
+ Sass::Util.check_range('Alpha channel', 0..1, alpha)
463
+
464
+ h = hue.value
465
+ s = Sass::Util.check_range('Saturation', 0..100, saturation, '%')
466
+ l = Sass::Util.check_range('Lightness', 0..100, lightness, '%')
467
+
468
+ Color.new(:hue => h, :saturation => s, :lightness => l, :alpha => alpha.value)
469
+ end
470
+ declare :hsla, [:hue, :saturation, :lightness, :alpha]
471
+
472
+ # Returns the red component of a color.
473
+ #
474
+ # @param color [Color]
475
+ # @return [Number]
476
+ # @raise [ArgumentError] If `color` isn't a color
477
+ def red(color)
478
+ assert_type color, :Color
479
+ Sass::Script::Number.new(color.red)
480
+ end
481
+ declare :red, [:color]
482
+
483
+ # Returns the green component of a color.
484
+ #
485
+ # @param color [Color]
486
+ # @return [Number]
487
+ # @raise [ArgumentError] If `color` isn't a color
488
+ def green(color)
489
+ assert_type color, :Color
490
+ Sass::Script::Number.new(color.green)
491
+ end
492
+ declare :green, [:color]
493
+
494
+ # Returns the blue component of a color.
495
+ #
496
+ # @param color [Color]
497
+ # @return [Number]
498
+ # @raise [ArgumentError] If `color` isn't a color
499
+ def blue(color)
500
+ assert_type color, :Color
501
+ Sass::Script::Number.new(color.blue)
502
+ end
503
+ declare :blue, [:color]
504
+
505
+ # Returns the hue component of a color.
506
+ #
507
+ # See [the CSS3 HSL specification](http://en.wikipedia.org/wiki/HSL_and_HSV#Conversion_from_RGB_to_HSL_or_HSV).
508
+ #
509
+ # Calculated from RGB where necessary via [this algorithm](http://en.wikipedia.org/wiki/HSL_and_HSV#Conversion_from_RGB_to_HSL_or_HSV).
510
+ #
511
+ # @param color [Color]
512
+ # @return [Number] between 0deg and 360deg
513
+ # @see #adjust_hue
514
+ # @raise [ArgumentError] if `color` isn't a color
515
+ def hue(color)
516
+ assert_type color, :Color
517
+ Sass::Script::Number.new(color.hue, ["deg"])
518
+ end
519
+ declare :hue, [:color]
520
+
521
+ # Returns the saturation component of a color.
522
+ #
523
+ # See [the CSS3 HSL specification](http://en.wikipedia.org/wiki/HSL_and_HSV#Conversion_from_RGB_to_HSL_or_HSV).
524
+ #
525
+ # Calculated from RGB where necessary via [this algorithm](http://en.wikipedia.org/wiki/HSL_and_HSV#Conversion_from_RGB_to_HSL_or_HSV).
526
+ #
527
+ # @param color [Color]
528
+ # @return [Number] between 0% and 100%
529
+ # @see #saturate
530
+ # @see #desaturate
531
+ # @raise [ArgumentError] if `color` isn't a color
532
+ def saturation(color)
533
+ assert_type color, :Color
534
+ Sass::Script::Number.new(color.saturation, ["%"])
535
+ end
536
+ declare :saturation, [:color]
537
+
538
+ # Returns the hue component of a color.
539
+ #
540
+ # See [the CSS3 HSL specification](http://en.wikipedia.org/wiki/HSL_and_HSV#Conversion_from_RGB_to_HSL_or_HSV).
541
+ #
542
+ # Calculated from RGB where necessary via [this algorithm](http://en.wikipedia.org/wiki/HSL_and_HSV#Conversion_from_RGB_to_HSL_or_HSV).
543
+ #
544
+ # @param color [Color]
545
+ # @return [Number] between 0% and 100%
546
+ # @see #lighten
547
+ # @see #darken
548
+ # @raise [ArgumentError] if `color` isn't a color
549
+ def lightness(color)
550
+ assert_type color, :Color
551
+ Sass::Script::Number.new(color.lightness, ["%"])
552
+ end
553
+ declare :lightness, [:color]
554
+
555
+ # Returns the alpha component (opacity) of a color.
556
+ # This is 1 unless otherwise specified.
557
+ #
558
+ # This function also supports the proprietary Microsoft
559
+ # `alpha(opacity=20)` syntax.
560
+ #
561
+ # @overload def alpha(color)
562
+ # @param color [Color]
563
+ # @return [Number]
564
+ # @see #opacify
565
+ # @see #transparentize
566
+ # @raise [ArgumentError] If `color` isn't a color
567
+ def alpha(*args)
568
+ if args.all? do |a|
569
+ a.is_a?(Sass::Script::String) && a.type == :identifier &&
570
+ a.value =~ /^[a-zA-Z]+\s*=/
571
+ end
572
+ # Support the proprietary MS alpha() function
573
+ return Sass::Script::String.new("alpha(#{args.map {|a| a.to_s}.join(", ")})")
574
+ end
575
+
576
+ opacity(*args)
577
+ end
578
+ declare :alpha, [:color]
579
+
580
+ # Returns the alpha component (opacity) of a color.
581
+ # This is 1 unless otherwise specified.
582
+ #
583
+ # @param color [Color]
584
+ # @return [Number]
585
+ # @see #opacify
586
+ # @see #transparentize
587
+ # @raise [ArgumentError] If `color` isn't a color
588
+ def opacity(color)
589
+ assert_type color, :Color
590
+ Sass::Script::Number.new(color.alpha)
591
+ end
592
+ declare :opacity, [:color]
593
+
594
+ # Makes a color more opaque.
595
+ # Takes a color and an amount between 0 and 1,
596
+ # and returns a color with the opacity increased by that value.
597
+ #
598
+ # @example
599
+ # opacify(rgba(0, 0, 0, 0.5), 0.1) => rgba(0, 0, 0, 0.6)
600
+ # opacify(rgba(0, 0, 17, 0.8), 0.2) => #001
601
+ # @param color [Color]
602
+ # @param amount [Number]
603
+ # @return [Color]
604
+ # @see #transparentize
605
+ # @raise [ArgumentError] If `color` isn't a color,
606
+ # or `number` isn't a number between 0 and 1
607
+ def opacify(color, amount)
608
+ _adjust(color, amount, :alpha, 0..1, :+)
609
+ end
610
+ declare :opacify, [:color, :amount]
611
+
612
+ alias_method :fade_in, :opacify
613
+ declare :fade_in, [:color, :amount]
614
+
615
+ # Makes a color more transparent.
616
+ # Takes a color and an amount between 0 and 1,
617
+ # and returns a color with the opacity decreased by that value.
618
+ #
619
+ # @example
620
+ # transparentize(rgba(0, 0, 0, 0.5), 0.1) => rgba(0, 0, 0, 0.4)
621
+ # transparentize(rgba(0, 0, 0, 0.8), 0.2) => rgba(0, 0, 0, 0.6)
622
+ # @param color [Color]
623
+ # @param amount [Number]
624
+ # @return [Color]
625
+ # @see #opacify
626
+ # @raise [ArgumentError] If `color` isn't a color,
627
+ # or `number` isn't a number between 0 and 1
628
+ def transparentize(color, amount)
629
+ _adjust(color, amount, :alpha, 0..1, :-)
630
+ end
631
+ declare :transparentize, [:color, :amount]
632
+
633
+ alias_method :fade_out, :transparentize
634
+ declare :fade_out, [:color, :amount]
635
+
636
+ # Makes a color lighter.
637
+ # Takes a color and an amount between 0% and 100%,
638
+ # and returns a color with the lightness increased by that value.
639
+ #
640
+ # @example
641
+ # lighten(hsl(0, 0%, 0%), 30%) => hsl(0, 0, 30)
642
+ # lighten(#800, 20%) => #e00
643
+ # @param color [Color]
644
+ # @param amount [Number]
645
+ # @return [Color]
646
+ # @see #darken
647
+ # @raise [ArgumentError] If `color` isn't a color,
648
+ # or `number` isn't a number between 0% and 100%
649
+ def lighten(color, amount)
650
+ _adjust(color, amount, :lightness, 0..100, :+, "%")
651
+ end
652
+ declare :lighten, [:color, :amount]
653
+
654
+ # Makes a color darker.
655
+ # Takes a color and an amount between 0% and 100%,
656
+ # and returns a color with the lightness decreased by that value.
657
+ #
658
+ # @example
659
+ # darken(hsl(25, 100%, 80%), 30%) => hsl(25, 100%, 50%)
660
+ # darken(#800, 20%) => #200
661
+ # @param color [Color]
662
+ # @param amount [Number]
663
+ # @return [Color]
664
+ # @see #lighten
665
+ # @raise [ArgumentError] If `color` isn't a color,
666
+ # or `number` isn't a number between 0% and 100%
667
+ def darken(color, amount)
668
+ _adjust(color, amount, :lightness, 0..100, :-, "%")
669
+ end
670
+ declare :darken, [:color, :amount]
671
+
672
+ # Makes a color more saturated.
673
+ # Takes a color and an amount between 0% and 100%,
674
+ # and returns a color with the saturation increased by that value.
675
+ #
676
+ # @example
677
+ # saturate(hsl(120, 30%, 90%), 20%) => hsl(120, 50%, 90%)
678
+ # saturate(#855, 20%) => #9e3f3f
679
+ # @param color [Color]
680
+ # @param amount [Number]
681
+ # @return [Color]
682
+ # @see #desaturate
683
+ # @raise [ArgumentError] If `color` isn't a color,
684
+ # or `number` isn't a number between 0% and 100%
685
+ def saturate(color, amount)
686
+ _adjust(color, amount, :saturation, 0..100, :+, "%")
687
+ end
688
+ declare :saturate, [:color, :amount]
689
+
690
+ # Makes a color less saturated.
691
+ # Takes a color and an amount between 0% and 100%,
692
+ # and returns a color with the saturation decreased by that value.
693
+ #
694
+ # @example
695
+ # desaturate(hsl(120, 30%, 90%), 20%) => hsl(120, 10%, 90%)
696
+ # desaturate(#855, 20%) => #726b6b
697
+ # @param color [Color]
698
+ # @param amount [Number]
699
+ # @return [Color]
700
+ # @see #saturate
701
+ # @raise [ArgumentError] If `color` isn't a color,
702
+ # or `number` isn't a number between 0% and 100%
703
+ def desaturate(color, amount)
704
+ _adjust(color, amount, :saturation, 0..100, :-, "%")
705
+ end
706
+ declare :desaturate, [:color, :amount]
707
+
708
+ # Changes the hue of a color while retaining the lightness and saturation.
709
+ # Takes a color and a number of degrees (usually between -360deg and 360deg),
710
+ # and returns a color with the hue rotated by that value.
711
+ #
712
+ # @example
713
+ # adjust-hue(hsl(120, 30%, 90%), 60deg) => hsl(180, 30%, 90%)
714
+ # adjust-hue(hsl(120, 30%, 90%), 060deg) => hsl(60, 30%, 90%)
715
+ # adjust-hue(#811, 45deg) => #886a11
716
+ # @param color [Color]
717
+ # @param amount [Number]
718
+ # @return [Color]
719
+ # @raise [ArgumentError] If `color` isn't a color, or `number` isn't a number
720
+ def adjust_hue(color, degrees)
721
+ assert_type color, :Color
722
+ assert_type degrees, :Number
723
+ color.with(:hue => color.hue + degrees.value)
724
+ end
725
+ declare :adjust_hue, [:color, :degrees]
726
+
727
+ # Adjusts one or more properties of a color.
728
+ # This can change the red, green, blue, hue, saturation, value, and alpha properties.
729
+ # The properties are specified as keyword arguments,
730
+ # and are added to or subtracted from the color's current value for that property.
731
+ #
732
+ # `$red`, `$green`, and `$blue` properties should be between 0 and 255.
733
+ # `$saturation` and `$lightness` should be between 0% and 100%.
734
+ # `$alpha` should be between 0 and 1.
735
+ #
736
+ # All properties are optional.
737
+ # You can't specify both RGB properties (`$red`, `$green`, `$blue`)
738
+ # and HSL properties (`$hue`, `$saturation`, `$value`) at the same time.
739
+ #
740
+ # @example
741
+ # adjust-color(#102030, $blue: 5) => #102035
742
+ # adjust-color(#102030, $red: -5, $blue: 5) => #0b2035
743
+ # adjust-color(hsl(25, 100%, 80%), $lightness: -30%, $alpha: -0.4) => hsla(25, 100%, 50%, 0.6)
744
+ # @param color [Color]
745
+ # @param red [Number]
746
+ # @param green [Number]
747
+ # @param blue [Number]
748
+ # @param hue [Number]
749
+ # @param saturation [Number]
750
+ # @param lightness [Number]
751
+ # @param alpha [Number]
752
+ # @return [Color]
753
+ # @raise [ArgumentError] if `color` is not a color,
754
+ # if any keyword argument is not a number,
755
+ # if any keyword argument is not in the legal range,
756
+ # if an unexpected keyword argument is given,
757
+ # or if both HSL and RGB properties are given.
758
+ def adjust_color(color, kwargs)
759
+ assert_type color, :Color
760
+ with = Sass::Util.map_hash({
761
+ "red" => [-255..255, ""],
762
+ "green" => [-255..255, ""],
763
+ "blue" => [-255..255, ""],
764
+ "hue" => nil,
765
+ "saturation" => [-100..100, "%"],
766
+ "lightness" => [-100..100, "%"],
767
+ "alpha" => [-1..1, ""]
768
+ }) do |name, (range, units)|
769
+
770
+ next unless val = kwargs.delete(name)
771
+ assert_type val, :Number, name
772
+ Sass::Util.check_range("$#{name}: Amount", range, val, units) if range
773
+ adjusted = color.send(name) + val.value
774
+ adjusted = [0, Sass::Util.restrict(adjusted, range)].max if range
775
+ [name.to_sym, adjusted]
776
+ end
777
+
778
+ unless kwargs.empty?
779
+ name, val = kwargs.to_a.first
780
+ raise ArgumentError.new("Unknown argument $#{name} (#{val})")
781
+ end
782
+
783
+ color.with(with)
784
+ end
785
+ declare :adjust_color, [:color], :var_kwargs => true
786
+
787
+ # Scales one or more properties of a color by a percentage value.
788
+ # Unlike \{#adjust_color adjust-color}, which changes a color's properties by fixed amounts,
789
+ # \{#scale_color scale-color} fluidly changes them based on how high or low they already are.
790
+ # That means that lightening an already-light color with \{#scale_color scale-color}
791
+ # won't change the lightness much,
792
+ # but lightening a dark color by the same amount will change it more dramatically.
793
+ # This has the benefit of making `scale-color($color, ...)` have a similar effect
794
+ # regardless of what `$color` is.
795
+ #
796
+ # For example, the lightness of a color can be anywhere between 0 and 100.
797
+ # If `scale-color($color, $lightness: 40%)` is called, the resulting color's lightness
798
+ # will be 40% of the way between its original lightness and 100.
799
+ # If `scale-color($color, $lightness: -40%)` is called instead,
800
+ # the lightness will be 40% of the way between the original and 0.
801
+ #
802
+ # This can change the red, green, blue, saturation, value, and alpha properties.
803
+ # The properties are specified as keyword arguments.
804
+ # All arguments should be percentages between 0% and 100%.
805
+ #
806
+ # All properties are optional.
807
+ # You can't specify both RGB properties (`$red`, `$green`, `$blue`)
808
+ # and HSL properties (`$saturation`, `$value`) at the same time.
809
+ #
810
+ # @example
811
+ # scale-color(hsl(120, 70, 80), $lightness: 50%) => hsl(120, 70, 90)
812
+ # scale-color(rgb(200, 150, 170), $green: -40%, $blue: 70%) => rgb(200, 90, 229)
813
+ # scale-color(hsl(200, 70, 80), $saturation: -90%, $alpha: -30%) => hsla(200, 7, 80, 0.7)
814
+ # @param color [Color]
815
+ # @param red [Number]
816
+ # @param green [Number]
817
+ # @param blue [Number]
818
+ # @param saturation [Number]
819
+ # @param lightness [Number]
820
+ # @param alpha [Number]
821
+ # @return [Color]
822
+ # @raise [ArgumentError] if `color` is not a color,
823
+ # if any keyword argument is not a percentage between 0% and 100%,
824
+ # if an unexpected keyword argument is given,
825
+ # or if both HSL and RGB properties are given.
826
+ def scale_color(color, kwargs)
827
+ assert_type color, :Color
828
+ with = Sass::Util.map_hash({
829
+ "red" => 255,
830
+ "green" => 255,
831
+ "blue" => 255,
832
+ "saturation" => 100,
833
+ "lightness" => 100,
834
+ "alpha" => 1
835
+ }) do |name, max|
836
+
837
+ next unless val = kwargs.delete(name)
838
+ assert_type val, :Number, name
839
+ if !(val.numerator_units == ['%'] && val.denominator_units.empty?)
840
+ raise ArgumentError.new("$#{name}: Amount #{val} must be a % (e.g. #{val.value}%)")
841
+ else
842
+ Sass::Util.check_range("$#{name}: Amount", -100..100, val, '%')
843
+ end
844
+
845
+ current = color.send(name)
846
+ scale = val.value/100.0
847
+ diff = scale > 0 ? max - current : current
848
+ [name.to_sym, current + diff*scale]
849
+ end
850
+
851
+ unless kwargs.empty?
852
+ name, val = kwargs.to_a.first
853
+ raise ArgumentError.new("Unknown argument $#{name} (#{val})")
854
+ end
855
+
856
+ color.with(with)
857
+ end
858
+ declare :scale_color, [:color], :var_kwargs => true
859
+
860
+ # Changes one or more properties of a color.
861
+ # This can change the red, green, blue, hue, saturation, value, and alpha properties.
862
+ # The properties are specified as keyword arguments,
863
+ # and replace the color's current value for that property.
864
+ #
865
+ # `$red`, `$green`, and `$blue` properties should be between 0 and 255.
866
+ # `$saturation` and `$lightness` should be between 0% and 100%.
867
+ # `$alpha` should be between 0 and 1.
868
+ #
869
+ # All properties are optional.
870
+ # You can't specify both RGB properties (`$red`, `$green`, `$blue`)
871
+ # and HSL properties (`$hue`, `$saturation`, `$value`) at the same time.
872
+ #
873
+ # @example
874
+ # change-color(#102030, $blue: 5) => #102005
875
+ # change-color(#102030, $red: 120, $blue: 5) => #782005
876
+ # change-color(hsl(25, 100%, 80%), $lightness: 40%, $alpha: 0.8) => hsla(25, 100%, 40%, 0.8)
877
+ # @param color [Color]
878
+ # @param red [Number]
879
+ # @param green [Number]
880
+ # @param blue [Number]
881
+ # @param hue [Number]
882
+ # @param saturation [Number]
883
+ # @param lightness [Number]
884
+ # @param alpha [Number]
885
+ # @return [Color]
886
+ # @raise [ArgumentError] if `color` is not a color,
887
+ # if any keyword argument is not a number,
888
+ # if any keyword argument is not in the legal range,
889
+ # if an unexpected keyword argument is given,
890
+ # or if both HSL and RGB properties are given.
891
+ def change_color(color, kwargs)
892
+ assert_type color, :Color
893
+ with = Sass::Util.map_hash(%w[red green blue hue saturation lightness alpha]) do |name, max|
894
+ next unless val = kwargs.delete(name)
895
+ assert_type val, :Number, name
896
+ [name.to_sym, val.value]
897
+ end
898
+
899
+ unless kwargs.empty?
900
+ name, val = kwargs.to_a.first
901
+ raise ArgumentError.new("Unknown argument $#{name} (#{val})")
902
+ end
903
+
904
+ color.with(with)
905
+ end
906
+ declare :change_color, [:color], :var_kwargs => true
907
+
908
+ # Mixes together two colors.
909
+ # Specifically, takes the average of each of the RGB components,
910
+ # optionally weighted by the given percentage.
911
+ # The opacity of the colors is also considered when weighting the components.
912
+ #
913
+ # The weight specifies the amount of the first color that should be included
914
+ # in the returned color.
915
+ # The default, 50%, means that half the first color
916
+ # and half the second color should be used.
917
+ # 25% means that a quarter of the first color
918
+ # and three quarters of the second color should be used.
919
+ #
920
+ # @example
921
+ # mix(#f00, #00f) => #7f007f
922
+ # mix(#f00, #00f, 25%) => #3f00bf
923
+ # mix(rgba(255, 0, 0, 0.5), #00f) => rgba(63, 0, 191, 0.75)
924
+ # @overload mix(color1, color2, weight: 50%)
925
+ # @param color1 [Color]
926
+ # @param color2 [Color]
927
+ # @param weight [Number] between 0% and 100%
928
+ # @return [Color]
929
+ # @raise [ArgumentError] if `color1` or `color2` aren't colors,
930
+ # or `weight` isn't a number between 0% and 100%
931
+ def mix(color1, color2, weight = Number.new(50))
932
+ assert_type color1, :Color
933
+ assert_type color2, :Color
934
+ assert_type weight, :Number
935
+
936
+ Sass::Util.check_range("Weight", 0..100, weight, '%')
937
+
938
+ # This algorithm factors in both the user-provided weight
939
+ # and the difference between the alpha values of the two colors
940
+ # to decide how to perform the weighted average of the two RGB values.
941
+ #
942
+ # It works by first normalizing both parameters to be within [-1, 1],
943
+ # where 1 indicates "only use color1", -1 indicates "only use color 0",
944
+ # and all values in between indicated a proportionately weighted average.
945
+ #
946
+ # Once we have the normalized variables w and a,
947
+ # we apply the formula (w + a)/(1 + w*a)
948
+ # to get the combined weight (in [-1, 1]) of color1.
949
+ # This formula has two especially nice properties:
950
+ #
951
+ # * When either w or a are -1 or 1, the combined weight is also that number
952
+ # (cases where w * a == -1 are undefined, and handled as a special case).
953
+ #
954
+ # * When a is 0, the combined weight is w, and vice versa
955
+ #
956
+ # Finally, the weight of color1 is renormalized to be within [0, 1]
957
+ # and the weight of color2 is given by 1 minus the weight of color1.
958
+ p = (weight.value/100.0).to_f
959
+ w = p*2 - 1
960
+ a = color1.alpha - color2.alpha
961
+
962
+ w1 = (((w * a == -1) ? w : (w + a)/(1 + w*a)) + 1)/2.0
963
+ w2 = 1 - w1
964
+
965
+ rgb = color1.rgb.zip(color2.rgb).map {|v1, v2| v1*w1 + v2*w2}
966
+ alpha = color1.alpha*p + color2.alpha*(1-p)
967
+ Color.new(rgb + [alpha])
968
+ end
969
+ declare :mix, [:color_1, :color_2]
970
+ declare :mix, [:color_1, :color_2, :weight]
971
+
972
+ # @overload grayscale(color)
973
+ # Converts a color to grayscale.
974
+ # This is identical to `desaturate(color, 100%)`.
975
+ #
976
+ # @param color [Color]
977
+ # @return [Color]
978
+ # @raise [ArgumentError] if `color` isn't a color
979
+ # @see #desaturate
980
+ # @overload grayscale(number)
981
+ # Returns an unquoted string `grayscale(number)`, as though the function
982
+ # were not defined. This is for the `grayscale` function used in
983
+ # `-webkit-filter`.
984
+ #
985
+ # @param number [Number]
986
+ # @return [Sass::Script::String]
987
+ def grayscale(color)
988
+ return Sass::Script::String.new("grayscale(#{color})") if color.is_a?(Sass::Script::Number)
989
+ desaturate color, Number.new(100)
990
+ end
991
+ declare :grayscale, [:color]
992
+
993
+ # Returns the complement of a color.
994
+ # This is identical to `adjust-hue(color, 180deg)`.
995
+ #
996
+ # @param color [Color]
997
+ # @return [Color]
998
+ # @raise [ArgumentError] if `color` isn't a color
999
+ # @see #adjust_hue #adjust-hue
1000
+ def complement(color)
1001
+ adjust_hue color, Number.new(180)
1002
+ end
1003
+ declare :complement, [:color]
1004
+
1005
+ # Returns the inverse (negative) of a color.
1006
+ # The red, green, and blue values are inverted, while the opacity is left alone.
1007
+ #
1008
+ # @param color [Color]
1009
+ # @return [Color]
1010
+ # @raise [ArgumentError] if `color` isn't a color
1011
+ def invert(color)
1012
+ assert_type color, :Color
1013
+ color.with(
1014
+ :red => (255 - color.red),
1015
+ :green => (255 - color.green),
1016
+ :blue => (255 - color.blue))
1017
+ end
1018
+ declare :invert, [:color]
1019
+
1020
+ # Removes quotes from a string if the string is quoted,
1021
+ # or returns the same string if it's not.
1022
+ #
1023
+ # @param string [String]
1024
+ # @return [String]
1025
+ # @raise [ArgumentError] if `string` isn't a string
1026
+ # @see #quote
1027
+ # @example
1028
+ # unquote("foo") => foo
1029
+ # unquote(foo) => foo
1030
+ def unquote(string)
1031
+ if string.is_a?(Sass::Script::String)
1032
+ Sass::Script::String.new(string.value, :identifier)
1033
+ else
1034
+ string
1035
+ end
1036
+ end
1037
+ declare :unquote, [:string]
1038
+
1039
+ # Add quotes to a string if the string isn't quoted,
1040
+ # or returns the same string if it is.
1041
+ #
1042
+ # @param string [String]
1043
+ # @return [String]
1044
+ # @raise [ArgumentError] if `string` isn't a string
1045
+ # @see #unquote
1046
+ # @example
1047
+ # quote("foo") => "foo"
1048
+ # quote(foo) => "foo"
1049
+ def quote(string)
1050
+ assert_type string, :String
1051
+ Sass::Script::String.new(string.value, :string)
1052
+ end
1053
+ declare :quote, [:string]
1054
+
1055
+ # Inspects the type of the argument, returning it as an unquoted string.
1056
+ #
1057
+ # @example
1058
+ # type-of(100px) => number
1059
+ # type-of(asdf) => string
1060
+ # type-of("asdf") => string
1061
+ # type-of(true) => bool
1062
+ # type-of(#fff) => color
1063
+ # type-of(blue) => color
1064
+ # @param value [Literal] The object to inspect
1065
+ # @return [String] The unquoted string name of the literal's type
1066
+ def type_of(value)
1067
+ Sass::Script::String.new(value.class.name.gsub(/Sass::Script::/,'').downcase)
1068
+ end
1069
+ declare :type_of, [:value]
1070
+
1071
+ # Inspects the unit of the number, returning it as a quoted string.
1072
+ # Complex units are sorted in alphabetical order by numerator and denominator.
1073
+ #
1074
+ # @example
1075
+ # unit(100) => ""
1076
+ # unit(100px) => "px"
1077
+ # unit(3em) => "em"
1078
+ # unit(10px * 5em) => "em*px"
1079
+ # unit(10px * 5em / 30cm / 1rem) => "em*px/cm*rem"
1080
+ # @param number [Literal] The number to inspect
1081
+ # @return [String] The unit(s) of the number
1082
+ # @raise [ArgumentError] if `number` isn't a number
1083
+ def unit(number)
1084
+ assert_type number, :Number
1085
+ Sass::Script::String.new(number.unit_str, :string)
1086
+ end
1087
+ declare :unit, [:number]
1088
+
1089
+ # Inspects the unit of the number, returning a boolean indicating if it is unitless.
1090
+ #
1091
+ # @example
1092
+ # unitless(100) => true
1093
+ # unitless(100px) => false
1094
+ # @param number [Literal] The number to inspect
1095
+ # @return [Bool] Whether or not the number is unitless
1096
+ # @raise [ArgumentError] if `number` isn't a number
1097
+ def unitless(number)
1098
+ assert_type number, :Number
1099
+ Sass::Script::Bool.new(number.unitless?)
1100
+ end
1101
+ declare :unitless, [:number]
1102
+
1103
+ # Returns true if two numbers are similar enough to be added, subtracted, or compared.
1104
+ #
1105
+ # @example
1106
+ # comparable(2px, 1px) => true
1107
+ # comparable(100px, 3em) => false
1108
+ # comparable(10cm, 3mm) => true
1109
+ # @param number_1 [Number]
1110
+ # @param number_2 [Number]
1111
+ # @return [Bool] indicating if the numbers can be compared.
1112
+ # @raise [ArgumentError] if `number_1` or `number_2` aren't numbers
1113
+ def comparable(number_1, number_2)
1114
+ assert_type number_1, :Number
1115
+ assert_type number_2, :Number
1116
+ Sass::Script::Bool.new(number_1.comparable_to?(number_2))
1117
+ end
1118
+ declare :comparable, [:number_1, :number_2]
1119
+
1120
+ # Converts a decimal number to a percentage.
1121
+ #
1122
+ # @example
1123
+ # percentage(100px / 50px) => 200%
1124
+ # @param value [Number] The decimal number to convert to a percentage
1125
+ # @return [Number] The percentage
1126
+ # @raise [ArgumentError] If `value` isn't a unitless number
1127
+ def percentage(value)
1128
+ unless value.is_a?(Sass::Script::Number) && value.unitless?
1129
+ raise ArgumentError.new("#{value.inspect} is not a unitless number")
1130
+ end
1131
+ Sass::Script::Number.new(value.value * 100, ['%'])
1132
+ end
1133
+ declare :percentage, [:value]
1134
+
1135
+ # Rounds a number to the nearest whole number.
1136
+ #
1137
+ # @example
1138
+ # round(10.4px) => 10px
1139
+ # round(10.6px) => 11px
1140
+ # @param value [Number] The number
1141
+ # @return [Number] The rounded number
1142
+ # @raise [ArgumentError] if `value` isn't a number
1143
+ def round(value)
1144
+ numeric_transformation(value) {|n| n.round}
1145
+ end
1146
+ declare :round, [:value]
1147
+
1148
+ # Rounds a number up to the nearest whole number.
1149
+ #
1150
+ # @example
1151
+ # ceil(10.4px) => 11px
1152
+ # ceil(10.6px) => 11px
1153
+ # @param value [Number] The number
1154
+ # @return [Number] The rounded number
1155
+ # @raise [ArgumentError] if `value` isn't a number
1156
+ def ceil(value)
1157
+ numeric_transformation(value) {|n| n.ceil}
1158
+ end
1159
+ declare :ceil, [:value]
1160
+
1161
+ # Rounds down to the nearest whole number.
1162
+ #
1163
+ # @example
1164
+ # floor(10.4px) => 10px
1165
+ # floor(10.6px) => 10px
1166
+ # @param value [Number] The number
1167
+ # @return [Number] The rounded number
1168
+ # @raise [ArgumentError] if `value` isn't a number
1169
+ def floor(value)
1170
+ numeric_transformation(value) {|n| n.floor}
1171
+ end
1172
+ declare :floor, [:value]
1173
+
1174
+ # Finds the absolute value of a number.
1175
+ #
1176
+ # @example
1177
+ # abs(10px) => 10px
1178
+ # abs(-10px) => 10px
1179
+ # @param value [Number] The number
1180
+ # @return [Number] The absolute value
1181
+ # @raise [ArgumentError] if `value` isn't a number
1182
+ def abs(value)
1183
+ numeric_transformation(value) {|n| n.abs}
1184
+ end
1185
+ declare :abs, [:value]
1186
+
1187
+ # Return the length of a list.
1188
+ #
1189
+ # @example
1190
+ # length(10px) => 1
1191
+ # length(10px 20px 30px) => 3
1192
+ # @param list [Literal] The list
1193
+ # @return [Number] The length
1194
+ def length(list)
1195
+ Sass::Script::Number.new(list.to_a.size)
1196
+ end
1197
+ declare :length, [:list]
1198
+
1199
+ # Gets the nth item in a list.
1200
+ #
1201
+ # Note that unlike some languages, the first item in a Sass list is number 1,
1202
+ # the second number 2, and so forth.
1203
+ #
1204
+ # @example
1205
+ # nth(10px 20px 30px, 1) => 10px
1206
+ # nth((Helvetica, Arial, sans-serif), 3) => sans-serif
1207
+ # @param list [Literal] The list
1208
+ # @param n [Number] The index into the list
1209
+ # @return [Literal] The nth item in the list
1210
+ # @raise [ArgumentError] If `n` isn't an integer between 1 and the list's length.
1211
+ def nth(list, n)
1212
+ assert_type n, :Number
1213
+ if !n.int?
1214
+ raise ArgumentError.new("List index #{n} must be an integer")
1215
+ elsif n.to_i < 1
1216
+ raise ArgumentError.new("List index #{n} must be greater than or equal to 1")
1217
+ elsif list.to_a.size == 0
1218
+ raise ArgumentError.new("List index is #{n} but list has no items")
1219
+ elsif n.to_i > (size = list.to_a.size)
1220
+ raise ArgumentError.new("List index is #{n} but list is only #{size} item#{'s' if size != 1} long")
1221
+ end
1222
+
1223
+ list.to_a[n.to_i - 1]
1224
+ end
1225
+ declare :nth, [:list, :n]
1226
+
1227
+ # Joins together two lists into a new list.
1228
+ #
1229
+ # Unless the `$separator` argument is passed,
1230
+ # if one list is comma-separated and one is space-separated,
1231
+ # the first parameter's separator is used for the resulting list.
1232
+ # If the lists have only one item each, spaces are used for the resulting list.
1233
+ #
1234
+ # @example
1235
+ # join(10px 20px, 30px 40px) => 10px 20px 30px 40px
1236
+ # join((blue, red), (#abc, #def)) => blue, red, #abc, #def
1237
+ # join(10px, 20px) => 10px 20px
1238
+ # join(10px, 20px, comma) => 10px, 20px
1239
+ # join((blue, red), (#abc, #def), space) => blue red #abc #def
1240
+ # @overload join(list1, list2, separator: auto)
1241
+ # @param list1 [Literal] The first list to join
1242
+ # @param list2 [Literal] The second list to join
1243
+ # @param separator [String] How the list separator (comma or space) should be determined.
1244
+ # If this is `comma` or `space`, that is always the separator;
1245
+ # if this is `auto` (the default), the separator is determined as explained above.
1246
+ def join(list1, list2, separator = Sass::Script::String.new("auto"))
1247
+ assert_type separator, :String
1248
+ unless %w[auto space comma].include?(separator.value)
1249
+ raise ArgumentError.new("Separator name must be space, comma, or auto")
1250
+ end
1251
+ sep1 = list1.separator if list1.is_a?(Sass::Script::List) && !list1.value.empty?
1252
+ sep2 = list2.separator if list2.is_a?(Sass::Script::List) && !list2.value.empty?
1253
+ Sass::Script::List.new(
1254
+ list1.to_a + list2.to_a,
1255
+ if separator.value == 'auto'
1256
+ sep1 || sep2 || :space
1257
+ else
1258
+ separator.value.to_sym
1259
+ end)
1260
+ end
1261
+ declare :join, [:list1, :list2]
1262
+ declare :join, [:list1, :list2, :separator]
1263
+
1264
+ # Appends a single value onto the end of a list.
1265
+ #
1266
+ # Unless the `$separator` argument is passed,
1267
+ # if the list has only one item,
1268
+ # the resulting list will be space-separated.
1269
+ #
1270
+ # @example
1271
+ # append(10px 20px, 30px) => 10px 20px 30px
1272
+ # append((blue, red), green) => blue, red, green
1273
+ # append(10px 20px, 30px 40px) => 10px 20px (30px 40px)
1274
+ # join(10px, 20px, comma) => 10px, 20px
1275
+ # join((blue, red), green, space) => blue red green
1276
+ # @overload join(list, val, separator: auto)
1277
+ # @param list1 [Literal] The first list to join
1278
+ # @param list2 [Literal] The second list to join
1279
+ # @param separator [String] How the list separator (comma or space) should be determined.
1280
+ # If this is `comma` or `space`, that is always the separator;
1281
+ # if this is `auto` (the default), the separator is determined as explained above.
1282
+ def append(list, val, separator = Sass::Script::String.new("auto"))
1283
+ assert_type separator, :String
1284
+ unless %w[auto space comma].include?(separator.value)
1285
+ raise ArgumentError.new("Separator name must be space, comma, or auto")
1286
+ end
1287
+ sep = list.separator if list.is_a?(Sass::Script::List)
1288
+ Sass::Script::List.new(
1289
+ list.to_a + [val],
1290
+ if separator.value == 'auto'
1291
+ sep || :space
1292
+ else
1293
+ separator.value.to_sym
1294
+ end)
1295
+ end
1296
+ declare :append, [:list, :val]
1297
+ declare :append, [:list, :val, :separator]
1298
+
1299
+ # Combines several lists into a single comma separated list
1300
+ # space separated lists.
1301
+ #
1302
+ # The length of the resulting list is the length of the
1303
+ # shortest list.
1304
+ #
1305
+ # @example
1306
+ # zip(1px 1px 3px, solid dashed solid, red green blue)
1307
+ # => 1px solid red, 1px dashed green, 3px solid blue
1308
+ def zip(*lists)
1309
+ length = nil
1310
+ values = []
1311
+ lists.each do |list|
1312
+ assert_type list, :List
1313
+ values << list.value.dup
1314
+ length = length.nil? ? list.value.length : [length, list.value.length].min
1315
+ end
1316
+ values.each do |value|
1317
+ value.slice!(length)
1318
+ end
1319
+ new_list_value = values.first.zip(*values[1..-1])
1320
+ List.new(new_list_value.map{|list| List.new(list, :space)}, :comma)
1321
+ end
1322
+ declare :zip, [], :var_args => true
1323
+
1324
+
1325
+ # Returns the position of the given value within the given
1326
+ # list. If not found, returns false.
1327
+ #
1328
+ # @example
1329
+ # index(1px solid red, solid) => 2
1330
+ # index(1px solid red, dashed) => false
1331
+ def index(list, value)
1332
+ assert_type list, :List
1333
+ index = list.value.index {|e| e.eq(value).to_bool }
1334
+ if index
1335
+ Number.new(index + 1)
1336
+ else
1337
+ Bool.new(false)
1338
+ end
1339
+ end
1340
+ declare :index, [:list, :value]
1341
+
1342
+ # Returns one of two values based on the truth value of the first argument.
1343
+ #
1344
+ # @example
1345
+ # if(true, 1px, 2px) => 1px
1346
+ # if(false, 1px, 2px) => 2px
1347
+ # @param condition [Bool] Whether the first or second value will be returned.
1348
+ # @param if_true [Literal] The value that will be returned if `$condition` is true.
1349
+ # @param if_false [Literal] The value that will be returned if `$condition` is false.
1350
+ def if(condition, if_true, if_false)
1351
+ if condition.to_bool
1352
+ if_true
1353
+ else
1354
+ if_false
1355
+ end
1356
+ end
1357
+ declare :if, [:condition, :if_true, :if_false]
1358
+
1359
+ private
1360
+
1361
+ # This method implements the pattern of transforming a numeric value into
1362
+ # another numeric value with the same units.
1363
+ # It yields a number to a block to perform the operation and return a number
1364
+ def numeric_transformation(value)
1365
+ assert_type value, :Number
1366
+ Sass::Script::Number.new(yield(value.value), value.numerator_units, value.denominator_units)
1367
+ end
1368
+
1369
+ def _adjust(color, amount, attr, range, op, units = "")
1370
+ assert_type color, :Color
1371
+ assert_type amount, :Number
1372
+ Sass::Util.check_range('Amount', range, amount, units)
1373
+
1374
+ # TODO: is it worth restricting here,
1375
+ # or should we do so in the Color constructor itself,
1376
+ # and allow clipping in rgb() et al?
1377
+ color.with(attr => Sass::Util.restrict(
1378
+ color.send(attr).send(op, amount.value), range))
1379
+ end
1380
+ end
1381
+ end