dashy 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (214) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/stylesheets/_dashy.scss +1 -14
  3. data/app/assets/stylesheets/dashy/_select.scss +3 -121
  4. data/app/assets/stylesheets/dashy/_set.scss +3 -76
  5. data/app/assets/stylesheets/dashy/all/_clears.scss +1 -0
  6. data/app/assets/stylesheets/dashy/all/_corners.scss +1 -0
  7. data/app/assets/stylesheets/dashy/all/_dimensions.scss +1 -0
  8. data/app/assets/stylesheets/dashy/all/_directions.scss +1 -0
  9. data/app/assets/stylesheets/dashy/all/_displays.scss +1 -0
  10. data/app/assets/stylesheets/dashy/all/_orientations.scss +1 -0
  11. data/app/assets/stylesheets/dashy/all/_overflows.scss +1 -0
  12. data/app/assets/stylesheets/dashy/all/_positions.scss +1 -0
  13. data/app/assets/stylesheets/dashy/all/_sides.scss +2 -0
  14. data/app/assets/stylesheets/dashy/all/font/_styles.scss +1 -0
  15. data/app/assets/stylesheets/dashy/all/font/_weights.scss +1 -0
  16. data/app/assets/stylesheets/dashy/all/horizontal/_dimensions.scss +1 -0
  17. data/app/assets/stylesheets/dashy/all/horizontal/_directions.scss +1 -0
  18. data/app/assets/stylesheets/dashy/all/horizontal/_sides.scss +1 -0
  19. data/app/assets/stylesheets/dashy/all/text/_aligns.scss +1 -0
  20. data/app/assets/stylesheets/dashy/all/text/_decorations.scss +1 -0
  21. data/app/assets/stylesheets/dashy/all/text/_inputs.scss +1 -0
  22. data/app/assets/stylesheets/dashy/all/text/_transforms.scss +1 -0
  23. data/app/assets/stylesheets/dashy/all/vertical/_aligns.scss +1 -0
  24. data/app/assets/stylesheets/dashy/all/vertical/_dimensions.scss +1 -0
  25. data/app/assets/stylesheets/dashy/all/vertical/_directions.scss +1 -0
  26. data/app/assets/stylesheets/dashy/all/vertical/_sides.scss +1 -0
  27. data/app/assets/stylesheets/dashy/default/font/_size.scss +1 -0
  28. data/app/assets/stylesheets/dashy/default/line/_height.scss +1 -0
  29. data/app/assets/stylesheets/dashy/default/page/_width.scss +1 -0
  30. data/app/assets/stylesheets/dashy/default/text/_align.scss +1 -0
  31. data/app/assets/stylesheets/dashy/default/vertical/_align.scss +1 -0
  32. data/app/assets/stylesheets/dashy/define/_append.scss +53 -0
  33. data/app/assets/stylesheets/dashy/define/_backspace.scss +15 -0
  34. data/app/assets/stylesheets/dashy/define/_clear.scss +15 -0
  35. data/app/assets/stylesheets/dashy/define/_display.scss +15 -0
  36. data/app/assets/stylesheets/dashy/define/_float.scss +15 -0
  37. data/app/assets/stylesheets/dashy/define/_gutter.scss +21 -0
  38. data/app/assets/stylesheets/dashy/define/_height.scss +15 -0
  39. data/app/assets/stylesheets/dashy/define/_inner.scss +15 -0
  40. data/app/assets/stylesheets/dashy/define/_opacity.scss +53 -0
  41. data/app/assets/stylesheets/dashy/define/_outer.scss +15 -0
  42. data/app/assets/stylesheets/dashy/define/_overflow.scss +15 -0
  43. data/app/assets/stylesheets/dashy/define/_pad.scss +15 -0
  44. data/app/assets/stylesheets/dashy/define/_position.scss +15 -0
  45. data/app/assets/stylesheets/dashy/define/_prepend.scss +53 -0
  46. data/app/assets/stylesheets/dashy/define/_pull.scss +17 -0
  47. data/app/assets/stylesheets/dashy/define/_push.scss +22 -0
  48. data/app/assets/stylesheets/dashy/define/_space.scss +15 -0
  49. data/app/assets/stylesheets/dashy/define/_width.scss +53 -0
  50. data/app/assets/stylesheets/dashy/define/column/_count.scss +15 -0
  51. data/app/assets/stylesheets/dashy/define/column/_fill.scss +15 -0
  52. data/app/assets/stylesheets/dashy/define/column/_gap.scss +15 -0
  53. data/app/assets/stylesheets/dashy/define/column/break/_inside.scss +15 -0
  54. data/app/assets/stylesheets/dashy/define/font/_size.scss +15 -0
  55. data/app/assets/stylesheets/dashy/define/font/_style.scss +15 -0
  56. data/app/assets/stylesheets/dashy/define/font/_weight.scss +15 -0
  57. data/app/assets/stylesheets/dashy/define/line/_height.scss +17 -0
  58. data/app/assets/stylesheets/dashy/define/max/_height.scss +15 -0
  59. data/app/assets/stylesheets/dashy/define/max/_width.scss +15 -0
  60. data/app/assets/stylesheets/dashy/define/min/_height.scss +15 -0
  61. data/app/assets/stylesheets/dashy/define/min/_width.scss +15 -0
  62. data/app/assets/stylesheets/dashy/define/text/_align.scss +15 -0
  63. data/app/assets/stylesheets/dashy/define/text/_color.scss +15 -0
  64. data/app/assets/stylesheets/dashy/define/text/_decoration.scss +15 -0
  65. data/app/assets/stylesheets/dashy/define/text/_transform.scss +15 -0
  66. data/app/assets/stylesheets/dashy/define/vertical/_align.scss +15 -0
  67. data/app/assets/stylesheets/dashy/get/_direction.scss +6 -0
  68. data/app/assets/stylesheets/dashy/get/_side.scss +11 -0
  69. data/app/assets/stylesheets/dashy/get/opposite/_corner.scss +6 -0
  70. data/app/assets/stylesheets/dashy/get/opposite/_direction.scss +6 -0
  71. data/app/assets/stylesheets/dashy/get/opposite/_side.scss +6 -0
  72. data/app/assets/stylesheets/dashy/initialize/_pull.scss +14 -0
  73. data/app/assets/stylesheets/dashy/initialize/_push.scss +14 -0
  74. data/app/assets/stylesheets/dashy/is/_blank.scss +5 -0
  75. data/app/assets/stylesheets/dashy/is/_boolean.scss +4 -0
  76. data/app/assets/stylesheets/dashy/is/_color.scss +4 -0
  77. data/app/assets/stylesheets/dashy/is/_em.scss +4 -0
  78. data/app/assets/stylesheets/dashy/is/_empty.scss +5 -0
  79. data/app/assets/stylesheets/dashy/is/_ex.scss +4 -0
  80. data/app/assets/stylesheets/dashy/is/_list.scss +4 -0
  81. data/app/assets/stylesheets/dashy/is/_nothing.scss +4 -0
  82. data/app/assets/stylesheets/dashy/is/_null.scss +4 -0
  83. data/app/assets/stylesheets/dashy/is/_number.scss +4 -0
  84. data/app/assets/stylesheets/dashy/is/_percentage.scss +4 -0
  85. data/app/assets/stylesheets/dashy/is/_px.scss +4 -0
  86. data/app/assets/stylesheets/dashy/is/_rem.scss +4 -0
  87. data/app/assets/stylesheets/dashy/is/_round.scss +4 -0
  88. data/app/assets/stylesheets/dashy/is/_something.scss +4 -0
  89. data/app/assets/stylesheets/dashy/is/_string.scss +4 -0
  90. data/app/assets/stylesheets/dashy/is/_unit.scss +4 -0
  91. data/app/assets/stylesheets/dashy/is/_unitful.scss +4 -0
  92. data/app/assets/stylesheets/dashy/is/_unitless.scss +4 -0
  93. data/app/assets/stylesheets/dashy/list/_append.scss +4 -0
  94. data/app/assets/stylesheets/dashy/list/_first.scss +4 -0
  95. data/app/assets/stylesheets/dashy/list/_last.scss +4 -0
  96. data/app/assets/stylesheets/dashy/list/_length.scss +4 -0
  97. data/app/assets/stylesheets/dashy/list/_nth.scss +5 -0
  98. data/app/assets/stylesheets/dashy/list/_second.scss +4 -0
  99. data/app/assets/stylesheets/dashy/number/_approximate.scss +14 -0
  100. data/app/assets/stylesheets/dashy/number/_ceiling.scss +4 -0
  101. data/app/assets/stylesheets/dashy/number/_decimal.scss +7 -0
  102. data/app/assets/stylesheets/dashy/number/_floor.scss +4 -0
  103. data/app/assets/stylesheets/dashy/number/_fractional.scss +4 -0
  104. data/app/assets/stylesheets/dashy/number/_integral.scss +4 -0
  105. data/app/assets/stylesheets/dashy/number/_of.scss +4 -0
  106. data/app/assets/stylesheets/dashy/number/_one.scss +4 -0
  107. data/app/assets/stylesheets/dashy/number/_round.scss +4 -0
  108. data/app/assets/stylesheets/dashy/number/_squared.scss +4 -0
  109. data/app/assets/stylesheets/dashy/number/_unit.scss +4 -0
  110. data/app/assets/stylesheets/dashy/select/_as.scss +0 -0
  111. data/app/assets/stylesheets/dashy/select/_attribute.scss +11 -0
  112. data/app/assets/stylesheets/dashy/select/_buttons.scss +14 -0
  113. data/app/assets/stylesheets/dashy/select/_children.scss +4 -0
  114. data/app/assets/stylesheets/dashy/select/_class.scss +9 -0
  115. data/app/assets/stylesheets/dashy/select/_descendants.scss +4 -0
  116. data/app/assets/stylesheets/dashy/select/_either.scss +0 -0
  117. data/app/assets/stylesheets/dashy/select/_following.scss +4 -0
  118. data/app/assets/stylesheets/dashy/select/_inputs.scss +9 -0
  119. data/app/assets/stylesheets/dashy/select/_lists.scss +9 -0
  120. data/app/assets/stylesheets/dashy/select/_next.scss +4 -0
  121. data/app/assets/stylesheets/dashy/select/_pseudoclass.scss +0 -0
  122. data/app/assets/stylesheets/dashy/select/_tables.scss +9 -0
  123. data/app/assets/stylesheets/dashy/select/_tabloids.scss +9 -0
  124. data/app/assets/stylesheets/dashy/select/as/_children.scss +4 -0
  125. data/app/assets/stylesheets/dashy/select/as/_descendants.scss +4 -0
  126. data/app/assets/stylesheets/dashy/select/as/_following.scss +4 -0
  127. data/app/assets/stylesheets/dashy/select/as/_next.scss +4 -0
  128. data/app/assets/stylesheets/dashy/select/attribute/_prefix.scss +9 -0
  129. data/app/assets/stylesheets/dashy/select/attribute/_suffix.scss +9 -0
  130. data/app/assets/stylesheets/dashy/select/class/_prefix.scss +9 -0
  131. data/app/assets/stylesheets/dashy/select/class/_suffix.scss +4 -0
  132. data/app/assets/stylesheets/dashy/select/list/_items.scss +9 -0
  133. data/app/assets/stylesheets/dashy/select/lists/_items.scss +9 -0
  134. data/app/assets/stylesheets/dashy/select/table/_cells.scss +9 -0
  135. data/app/assets/stylesheets/dashy/select/table/_groups.scss +4 -0
  136. data/app/assets/stylesheets/dashy/select/table/_rows.scss +4 -0
  137. data/app/assets/stylesheets/dashy/select/table/groups/_rows.scss +4 -0
  138. data/app/assets/stylesheets/dashy/select/table/groups/rows/_cells.scss +4 -0
  139. data/app/assets/stylesheets/dashy/select/tabloids/_rows.scss +10 -0
  140. data/app/assets/stylesheets/dashy/select/tabloids/rows/_cells.scss +9 -0
  141. data/app/assets/stylesheets/dashy/select/text/_inputs.scss +11 -0
  142. data/app/assets/stylesheets/dashy/set/_animation.scss +10 -0
  143. data/app/assets/stylesheets/dashy/set/_append.scss +4 -0
  144. data/app/assets/stylesheets/dashy/set/_backspace.scss +4 -0
  145. data/app/assets/stylesheets/dashy/set/_clear.scss +13 -0
  146. data/app/assets/stylesheets/dashy/set/_display.scss +11 -0
  147. data/app/assets/stylesheets/dashy/set/_float.scss +4 -0
  148. data/app/assets/stylesheets/dashy/set/_height.scss +4 -0
  149. data/app/assets/stylesheets/dashy/set/_inner.scss +4 -0
  150. data/app/assets/stylesheets/dashy/set/_keyframes.scss +7 -0
  151. data/app/assets/stylesheets/dashy/set/_margin.scss +5 -0
  152. data/app/assets/stylesheets/dashy/set/_opacity.scss +9 -0
  153. data/app/assets/stylesheets/dashy/set/_outer.scss +4 -0
  154. data/app/assets/stylesheets/dashy/set/_overflow.scss +4 -0
  155. data/app/assets/stylesheets/dashy/set/_pad.scss +4 -0
  156. data/app/assets/stylesheets/dashy/set/_padding.scss +5 -0
  157. data/app/assets/stylesheets/dashy/set/_position.scss +11 -0
  158. data/app/assets/stylesheets/dashy/set/_prepend.scss +4 -0
  159. data/app/assets/stylesheets/dashy/set/_pull.scss +4 -0
  160. data/app/assets/stylesheets/dashy/set/_push.scss +4 -0
  161. data/app/assets/stylesheets/dashy/set/_rem.scss +5 -0
  162. data/app/assets/stylesheets/dashy/set/_rgb.scss +4 -0
  163. data/app/assets/stylesheets/dashy/set/_rgba.scss +8 -0
  164. data/app/assets/stylesheets/dashy/set/_space.scss +4 -0
  165. data/app/assets/stylesheets/dashy/set/_transition.scss +7 -0
  166. data/app/assets/stylesheets/dashy/set/_tweening.scss +5 -0
  167. data/app/assets/stylesheets/dashy/set/_width.scss +4 -0
  168. data/app/assets/stylesheets/dashy/set/background/gradient.scss +37 -0
  169. data/app/assets/stylesheets/dashy/set/border/_radius.scss +6 -0
  170. data/app/assets/stylesheets/dashy/set/box/_shadow.scss +6 -0
  171. data/app/assets/stylesheets/dashy/set/box/_sizing.scss +6 -0
  172. data/app/assets/stylesheets/dashy/set/column/_count.scss +6 -0
  173. data/app/assets/stylesheets/dashy/set/column/_fill.scss +6 -0
  174. data/app/assets/stylesheets/dashy/set/column/_gap.scss +6 -0
  175. data/app/assets/stylesheets/dashy/set/column/break/_inside.scss +6 -0
  176. data/app/assets/stylesheets/dashy/set/font/_size.scss +4 -0
  177. data/app/assets/stylesheets/dashy/set/font/_style.scss +4 -0
  178. data/app/assets/stylesheets/dashy/set/font/_weight.scss +4 -0
  179. data/app/assets/stylesheets/dashy/set/line/_height.scss +4 -0
  180. data/app/assets/stylesheets/dashy/set/max/_height.scss +4 -0
  181. data/app/assets/stylesheets/dashy/set/max/_width.scss +4 -0
  182. data/app/assets/stylesheets/dashy/set/min/_height.scss +7 -0
  183. data/app/assets/stylesheets/dashy/set/min/_width.scss +4 -0
  184. data/app/assets/stylesheets/dashy/set/text/_align.scss +4 -0
  185. data/app/assets/stylesheets/dashy/set/text/_color.scss +4 -0
  186. data/app/assets/stylesheets/dashy/set/text/_decoration.scss +4 -0
  187. data/app/assets/stylesheets/dashy/set/text/_transform.scss +4 -0
  188. data/app/assets/stylesheets/dashy/set/vertical/_align.scss +4 -0
  189. data/app/assets/stylesheets/dashy/string/_hyphenate.scss +4 -0
  190. data/app/assets/stylesheets/dashy/string/_join.scss +0 -0
  191. data/app/assets/stylesheets/dashy/to/_dimension.scss +11 -0
  192. data/app/assets/stylesheets/dashy/to/_fraction.scss +12 -0
  193. data/app/assets/stylesheets/dashy/to/_number.scss +9 -0
  194. data/app/assets/stylesheets/dashy/to/_orientation.scss +11 -0
  195. data/app/assets/stylesheets/dashy/to/_percentage.scss +9 -0
  196. data/app/assets/stylesheets/dashy/to/_px.scss +9 -0
  197. data/app/assets/stylesheets/dashy/to/_unitless.scss +4 -0
  198. data/lib/dashy/version.rb +1 -1
  199. data/lib/dashy.rb +1 -0
  200. data/lib/sass/script/functions/dashy.rb +80 -271
  201. data/lib/sass/script/value/string/dashy.rb +25 -0
  202. metadata +197 -15
  203. data/app/assets/stylesheets/dashy/_color.scss +0 -5
  204. data/app/assets/stylesheets/dashy/_corner.scss +0 -15
  205. data/app/assets/stylesheets/dashy/_default.scss +0 -14
  206. data/app/assets/stylesheets/dashy/_define.scss +0 -158
  207. data/app/assets/stylesheets/dashy/_direction.scss +0 -36
  208. data/app/assets/stylesheets/dashy/_font-family.scss +0 -36
  209. data/app/assets/stylesheets/dashy/_is.scss +0 -81
  210. data/app/assets/stylesheets/dashy/_line-height.scss +0 -10
  211. data/app/assets/stylesheets/dashy/_list.scss +0 -161
  212. data/app/assets/stylesheets/dashy/_number.scss +0 -79
  213. data/app/assets/stylesheets/dashy/_opposite.scss +0 -36
  214. data/app/assets/stylesheets/dashy/_side.scss +0 -23
@@ -0,0 +1,6 @@
1
+ @mixin set-column-gap($gap)
2
+ {
3
+ -webkit-column-gap: $gap;
4
+ -moz-column-gap: $gap;
5
+ column-gap: $gap;
6
+ }
@@ -0,0 +1,6 @@
1
+ @mixin set-column-break-inside($break)
2
+ {
3
+ -webkit-column-break-inside: $break;
4
+ -moz-column-break-inside: $break;
5
+ column-break-inside: $break;
6
+ }
@@ -0,0 +1,4 @@
1
+ @mixin set-font-size($size)
2
+ {
3
+ @include set-rem(font-size, $size);
4
+ }
@@ -0,0 +1,4 @@
1
+ @mixin set-font-style($style)
2
+ {
3
+ @include set(font-style, $style);
4
+ }
@@ -0,0 +1,4 @@
1
+ @mixin set-font-weight($weight)
2
+ {
3
+ @include set(font-weight, $weight);
4
+ }
@@ -0,0 +1,4 @@
1
+ @mixin set-line-height($line-height)
2
+ {
3
+ @include set-rem(line-height, $line-height);
4
+ }
@@ -0,0 +1,4 @@
1
+ @mixin set-max-height($height)
2
+ {
3
+ @include set-rem(max-height, $height);
4
+ }
@@ -0,0 +1,4 @@
1
+ @mixin set-max-width($width)
2
+ {
3
+ @include set-rem(max-width, $width);
4
+ }
@@ -0,0 +1,7 @@
1
+ @mixin set-min-height($min-height)
2
+ {
3
+ @if is-rem($min-height) { @include set-min-height(to-px($min-height)) }
4
+ min-height: #{ $min-height };
5
+ height:auto !important;
6
+ height: #{ $min-height };
7
+ }
@@ -0,0 +1,4 @@
1
+ @mixin set-min-width($min-width)
2
+ {
3
+ @include set-rem(min-width, $min-width);
4
+ }
@@ -0,0 +1,4 @@
1
+ @mixin set-text-align($align)
2
+ {
3
+ @include set(text-align, $align);
4
+ }
@@ -0,0 +1,4 @@
1
+ @mixin set-text-color($color)
2
+ {
3
+ @include set(color, $color);
4
+ }
@@ -0,0 +1,4 @@
1
+ @mixin set-text-decoration($decoration)
2
+ {
3
+ @include set(text-decoration, $decoration);
4
+ }
@@ -0,0 +1,4 @@
1
+ @mixin set-text-transform($transform)
2
+ {
3
+ @include set(text-transform, $transform);
4
+ }
@@ -0,0 +1,4 @@
1
+ @mixin set-vertical-align($align)
2
+ {
3
+ @include set(vertical-align, $align);
4
+ }
@@ -0,0 +1,4 @@
1
+ @function string-hyphenate($strs)
2
+ {
3
+ @return string-join($strs, "-");
4
+ }
File without changes
@@ -0,0 +1,11 @@
1
+ $to-dimension-from-orientation: (horizontal width) (vertical height);
2
+
3
+ @function to-dimension-from-orientation($orientation)
4
+ {
5
+ @return map-get($to-dimension-from-orientation, $orientation);
6
+ }
7
+
8
+ @function to-dimension($arg)
9
+ {
10
+ @if is-orientation($arg) { @return to-dimension-from-orientation($arg); }
11
+ }
@@ -0,0 +1,12 @@
1
+ // @function to-fraction-from-number defined in Sass::Script::Functions::Dashy
2
+
3
+ @function to-fraction-from-percentage($per)
4
+ {
5
+ @return to-fraction-from-number(to-number-from-percentage($per));
6
+ }
7
+
8
+ @function to-fraction($arg)
9
+ {
10
+ @if is-number($arg) { @return to-fraction-from-number($arg); }
11
+ @if is-percentage($arg) { @return to-fraction-from-percentage($arg); }
12
+ }
@@ -0,0 +1,9 @@
1
+ @function to-number-from-percentage($per)
2
+ {
3
+ @return $per / 100%;
4
+ }
5
+
6
+ @function to-number($arg)
7
+ {
8
+ @if is-percentage($arg) { @return to-number-from-percentage(arg / 100%); }
9
+ }
@@ -0,0 +1,11 @@
1
+ $to-orientation-from-dimension: (width: horizontal, height: vertical);
2
+
3
+ @function to-orientation-from-dimension($dimension)
4
+ {
5
+ @return map-get($to-orientation-from-dimension, $dimension);
6
+ }
7
+
8
+ @function to-orientation($arg)
9
+ {
10
+ @if is-dimension($arg) { @return to-orientation-from-dimension($arg); }
11
+ }
@@ -0,0 +1,9 @@
1
+ @function to-percentage-from-unitless($num)
2
+ {
3
+ @return $num * 100%;
4
+ }
5
+
6
+ @function to-percentage($arg)
7
+ {
8
+ @if is-unitless($arg) { @return to-percentage-from-unitless($arg); }
9
+ }
@@ -0,0 +1,9 @@
1
+ @function to-px-from-rem($rem)
2
+ {
3
+ @return $font-size-default * $rem / 1rem;
4
+ }
5
+
6
+ @function to-px($num)
7
+ {
8
+ @if is-rem($num) { @return to-px-from-rem($num); }
9
+ }
@@ -0,0 +1,4 @@
1
+ @function to-unitless($amt)
2
+ {
3
+ @return $amt / number-one($amt); // remove the units by dividing them out...
4
+ }
data/lib/dashy/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  module Dashy
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
4
4
 
5
5
  # Gem structure adapted from thoughtbot/bourbon...
data/lib/dashy.rb CHANGED
@@ -8,6 +8,7 @@ unless defined?(Sass)
8
8
  require 'sass'
9
9
  end
10
10
 
11
+ require "sass/script/value/string/dashy"
11
12
  require "sass/script/functions/dashy"
12
13
 
13
14
  module Dashy
@@ -1,287 +1,96 @@
1
- require 'sass/script/functions'
1
+ module Sass::Script::Functions
2
+ module Dashy
2
3
 
3
- class Sass::Script::Value::String
4
-
5
- prepend Module.new {
6
-
7
- def to_s opt = {}
8
- return @value.gsub(/(?<!\\)(?=[\$\%\/\?\!])/, "\\") if :selector == @type
9
- return super
10
- end
11
-
12
- }
13
-
14
- end
15
-
16
- module Sass
17
- module Script
18
- module Functions
19
-
20
- # Defined directly on `Functions` so we can use `declare`.
21
-
22
- def is_wildcard value
23
- '*' == value.to_s
24
- end
25
-
26
- def select *selectors
27
- this = select_identifier ""
28
- select_as this, *selectors
29
- end
30
- declare :select, [], :var_args => true
31
-
32
- def select_as separator, *selectors
33
- unquote = method :unquote
34
- separator = separator.value
35
- selectors = selectors.first if 1 == selectors.length
36
- selectors = selectors.to_a.map { |selector| selector.to_a.map &unquote }
37
- selectors = selectors.shift.product *selectors
38
- Sass::Script::Value::List.new selectors.map! { |selector|
39
- # selector = selector.reject &method(:is_wildcard) unless 1 == selector.length && is_wildcard(selector.first)
40
- selector = selector.join separator
41
- selector.gsub! /(?<=[\w\-\]])\*/, '' # Remove any wildcards after any words or attributes.
42
- selector.gsub! /\*(?=[\w\.\#\[])/, '' # Remove any wildcards before any tags, classes, ids or attributes.
43
- select_identifier selector
44
- }, :comma
45
- end
46
- declare :select_with, [:string], :var_args => true
47
-
48
- def select_as_descendants *selectors
49
- descendants = select_identifier " "
50
- select_as descendants, *selectors
51
- end
52
- declare :select_as_descendants, [], :var_args => true
53
-
54
- def select_as_children *selectors
55
- children = select_identifier ">"
56
- select_as children, *selectors
57
- end
58
- declare :select_as_children, [], :var_args => true
59
-
60
- def select_as_adjacent_siblings *selectors
61
- adjacent_siblings = select_identifier "+"
62
- select_as adjacent_siblings, *selectors
63
- end
64
- declare :select_as_adjacent_siblings, [], :var_args => true
65
-
66
- def select_as_general_siblings *selectors
67
- general_siblings = select_identifier "~"
68
- select_as general_siblings, *selectors
69
- end
70
- declare :select_as_general_siblings, [], :var_args => true
71
-
72
- def select_descendants selector = select_any
73
- descendants = select_identifier " "
74
- select descendants, selector
75
- end
76
- declare :select_descendants, [:string], :var_args => true
77
-
78
- def select_children selector = select_any
79
- children = select_identifier ">"
80
- select children, selector
81
- end
82
- declare :select_children, [:string], :var_args => true
83
-
84
- def select_adjacent_siblings selector = select_any
85
- adjacent_siblings = select_identifier "+"
86
- select adjacent_siblings, selector
87
- end
88
- declare :select_adjacent_siblings, [:string], :var_args => true
89
-
90
- def select_general_siblings selector = select_any
91
- general_siblings = select_identifier "~"
92
- select general_siblings, selector
93
- end
94
- declare :select_general_siblings, [:string], :var_args => true
95
-
96
- def select_either *selectors
97
- selectors = selectors.first if 1 == selectors.length
98
- selectors = selectors.map &:to_a
99
- Sass::Script::Value::List.new selectors.flatten, :comma
100
- end
101
- declare :select_either, [], :var_args => true
102
-
103
- def select_attribute attribute, *selectors
104
- selectors = selectors.first if 1 == selectors.length
105
- selectors = selectors.to_a.map { |selector| select_string "[#{ attribute }=\'#{ select_escaped! selector }\']" }
106
- Sass::Script::Value::List.new selectors, :comma
107
- end
108
-
109
- def select_attribute_prefix attribute, *selectors
110
- selectors = selectors.first if 1 == selectors.length
111
- selectors = selectors.to_a.map { |selector|
112
- [
113
- (select_string "[#{ attribute }^=\'#{ select_escaped! selector }\']"),
114
- (select_string "[#{ attribute }*=\' #{ select_escaped! selector }\']")
115
- ]
116
- }
117
- Sass::Script::Value::List.new selectors.flatten, :comma
118
- end
119
-
120
- def select_attribute_suffix attribute, *selectors
121
- selectors = selectors.first if 1 == selectors.length
122
- selectors = selectors.to_a.map { |selector|
123
- [
124
- (select_string "[#{ attribute }$=\'#{ select_escaped! selector }\']"),
125
- (select_string "[#{ attribute }*=\'#{ select_escaped! selector } \']")
126
- ]
127
- }
128
- Sass::Script::Value::List.new selectors.flatten, :comma
129
- end
130
-
131
- def select_class_prefix *selectors
132
- attribute = select_identifier "class"
133
- select_attribute_prefix attribute, *selectors
134
- end
135
-
136
- def select_class_suffix *selectors
137
- attribute = select_identifier "class"
138
- select_attribute_suffix attribute, *selectors
139
- end
140
-
141
- def select_class selector
142
- selectors = selector.to_a.map &:to_a
143
- selectors = selectors.shift.product *selectors
144
- selectors.map! { |selector| select_identifier "." + select_escaped!(selector.to_a.map { |s| s.to_s(quote: :none).gsub(/(?<!\\)(?=[.\$\%\/\?\!])/, "\\") }.join "-") }
145
- Sass::Script::Value::List.new selectors, :comma
146
- end
147
-
148
- def select_classes *selectors
149
- select_either *(selectors.map! &(method :select_class))
150
- end
151
-
152
- def select_pseudoclass selector
153
- select_identifier ":" + (selector.to_a.join "-")
154
- end
155
-
156
- def select_pseudoclasses *selectors
157
- select_either *(selectors.map! &(method :select_pseudoclass))
158
- end
159
-
160
- def select_quasiclass selector
161
- select_either select_class(selector), select_pseudoclass(selector)
162
- end
163
-
164
- def select_quasiclasses *selectors
165
- select_either *(selectors.map! &(method :select_quasiclass))
166
- end
167
-
168
- def select_adjacent_odd_siblings limit, *selectors
169
- selectors.push select_identifier '*' if selectors.empty?
170
- selectors = selectors.first if 1 == selectors.length
171
- selectors = (0 .. limit.value).select { |i| 1 == i % 2 }.map { |i| select select_identifier(" + * " * i + " + "), *selectors }
172
- select_either *selectors
173
- end
174
-
175
- def select_odd_siblings limit, *selectors
176
- select_either select_first_sibling, select(select_first_sibling, select_adjacent_odd_siblings(limit, *selectors))
177
- end
178
-
179
- def select_odd_children limit, *selectors
180
- select_children select_odd_siblings(limit, *selectors)
181
- end
182
-
183
- def select_adjacent_even_siblings limit, *selectors
184
- selectors.push select_identifier '*' if selectors.empty?
185
- selectors = selectors.first if 1 == selectors.length
186
- selectors = (0 .. limit.value).select { |i| 0 == i % 2 }.map { |i| select select_identifier(" + * " * i + " + "), *selectors }
187
- select_either *selectors
188
- end
189
-
190
- def select_even_siblings limit, *selectors
191
- select select_first_sibling, select_adjacent_even_siblings(limit, *selectors)
192
- end
193
-
194
- def select_even_children limit, *selectors
195
- select_children select_even_siblings(limit, *selectors)
196
- end
197
-
198
- def select_first_child
199
- select_children select_first_sibling
200
- end
201
-
202
- def select_first_sibling
203
- select_identifier ":first_child"
204
- end
205
-
206
- def select_any
207
- select_identifier "*"
208
- end
209
-
210
- def select_string selector
211
- Sass::Script::Value::String.new selector.to_s, :string
212
- end
213
-
214
- def select_identifier selector
215
- Sass::Script::Value::String.new selector.to_s, :selector
216
- end
217
-
218
- def select_escaped! thing
219
- thing.tap { |t|
220
- case thing
221
-
222
- when Sass::Script::Value::String
223
- select_escaped! t.value
224
-
225
- when String
226
- t.gsub! /(?<!\\)(?=[\=\$\%\/\?\!\.])/, "\\"
4
+ def select *selectors
5
+ select_as unquoted_string(""), *selectors
6
+ end
227
7
 
228
- end
229
- }
230
- end
8
+ def select_new selector
9
+ string_new selector, :selector
10
+ end
231
11
 
232
- def select_escaped_string selector
233
- select_escaped! select_string selector
234
- end
12
+ private :select_new
13
+
14
+ def select_as separator, *selectors
15
+ unquote = method :unquote
16
+ separator = separator.value
17
+ selectors = selectors.first if 1 == selectors.length
18
+ selectors = selectors.to_a.map { |selector| selector.to_a.map &unquote }
19
+
20
+ selectors = selectors.shift.product *selectors
21
+ selectors.map! do |selector|
22
+ selector = selector.join separator
23
+
24
+ selector.gsub! %r{ [*] (?=[\\\w\-\.\#\[]) }x, '' # Remove any wildcards before any tags, classes, ids or attributes.
25
+ selector.gsub! %r{ (?<=[\\\w\-\]]) [*] }x, '' # Remove any wildcards after any words or attributes.
26
+
27
+ select_new selector
28
+ end
29
+
30
+ list_new selectors
31
+ end
235
32
 
236
- def select_escaped_identifier selector
237
- select_escaped! select_identifier selector
238
- end
33
+ def select_either *selectors
34
+ list_new selectors.map(&:to_a).flatten
35
+ end
239
36
 
240
- def select_arguments namespace, *name_value_pairs
241
- inputs = name_value_pairs.map { |name_value_pair|
242
- name, value = name_value_pair.to_a
243
- select select_identifier('input:checked'), select_attribute('form', namespace),
244
- select_attribute('name', name),
245
- select_attribute('value', value)
246
- }
247
- select_as_general_siblings *inputs
37
+ def string_new string, type = :string
38
+ Sass::Script::Value::String.new string, type
39
+ end
248
40
 
249
- # $form: select-class($form);
41
+ private :string_new
250
42
 
251
- # $left: select($input select-general-siblings($form));
252
- # $right: select($form select-class($name $value));
43
+ def string_join strings, separator
44
+ strings = strings.to_a
45
+ type = strings.first.type
46
+ strings = strings.map { |string| string.to_s quote: :none }
47
+ separator = separator.to_s quote: :none
48
+ string_new strings.join(separator), type
49
+ end
253
50
 
254
- # @return select-either($left, $right);
255
- end
51
+ def number_new number, numerator_units = nil, denominator_units = nil
52
+ Sass::Script::Value::Number.new number, numerator_units, denominator_units
53
+ end
256
54
 
257
- def select_lists *selectors
258
- select_either select_ordered_lists(*selectors), select_unordered_lists(*selectors)
259
- end
55
+ private :number_new
260
56
 
261
- def select_ordered_lists *selectors
262
- select select_identifier('ol'), *selectors
263
- end
57
+ def list_new list, separator = :comma
58
+ Sass::Script::Value::List.new list, :comma
59
+ end
264
60
 
265
- def select_unordered_lists *selectors
266
- select select_identifier('ul'), *selectors
267
- end
61
+ private :list_new
62
+
63
+ def list_series *lists
64
+ lists.map! do |list|
65
+ list = list.to_a
66
+ sentinel = list.first
67
+
68
+ first, second, operator, *rest, last = list.map &:value
69
+ next list unless Numeric === last &&
70
+ Numeric === first &&
71
+ Numeric === second &&
72
+ /^_+$/ === operator &&
73
+ rest.all?(&Numeric.method(:===))
74
+
75
+ delta = second - first
76
+ case operator
77
+ when "_" then (first.. last)
78
+ when "__" then (first... last)
79
+ end.step(delta).map do |value|
80
+ number_new value, sentinel.numerator_units, sentinel.denominator_units
81
+ end
82
+ end
83
+ list_new lists.flatten, :comma
84
+ end
268
85
 
269
- def list_of *lists
270
- Sass::Script::Value::List.new lists.map { |list|
271
- list = list.to_a
272
- number = list.first
273
- first, second, operator, *rest, last = list.map &:value
274
- this = first
275
- delta = second - first
276
- case operator
277
- when "_" then [].tap { |list| while this <= last; list << this; this += delta; end }
278
- when "__" then [].tap { |list| while this < last; list << this; this += delta; end }
279
- else list
280
- end.map { |value| Sass::Script::Value::Number.new value, number.numerator_units, number.denominator_units }
281
- }.flatten, :comma
282
- end
283
- declare :list_of, [:list], :var_args => true
86
+ def to_number_from_fraction str
87
+ number_new eval "1.0 * #{ str.value }" if %r{ ^ [0-9]+ / [0-9]+ $ }x === str.value
88
+ end
284
89
 
90
+ def to_fraction_from_number num
91
+ string_new Rational(num.value).rationalize(0.0001).to_s, :identifier
285
92
  end
93
+
286
94
  end
95
+ prepend Dashy
287
96
  end
@@ -0,0 +1,25 @@
1
+ class Sass::Script::Value::String
2
+ module Dashy
3
+
4
+ def to_s *sig
5
+ return super unless :selector === type
6
+ selector = self.value.dup
7
+
8
+ # Escape...
9
+ #
10
+ # ...decimals:
11
+ #
12
+ selector.gsub! %r{ (?<=[0-9]) (?=[.][0-9]) }x, '\\' # Escape any unescaped decimal points...
13
+ selector.gsub! %r{ (?<=[0-9]) ( [\\][.] [0-9]{2} ) [0-9]+ }x, '\1' # Remove extra precision (> 2).
14
+ selector.gsub! %r{ (?<=[0-9]) ( [\\][.] [0-9]*? ) [0]+ (?=[^0-9]) }x, '\1' # Remove trailing zeroes.
15
+ selector.gsub! %r{ (?<=[0-9]) ( [\\][.] ) (?=[^0-9]) }x, '' # Remove trailing dot.
16
+ #
17
+ # ...punctuation:
18
+ #
19
+ selector.gsub! %r{ (?<!\\) (?=[/%$?!]) }x, "\\" # Escape any unescaped punctuation...
20
+ selector
21
+ end
22
+
23
+ end
24
+ prepend Dashy
25
+ end