archetype 0.0.1.pre.1 → 0.0.1.pre.3.00dfd9a

Sign up to get free protection for your applications and to get access to all the features.
Files changed (185) hide show
  1. checksums.yaml +7 -0
  2. data/CHANGELOG.md +88 -0
  3. data/LICENSE +16 -0
  4. data/README.md +87 -1
  5. data/VERSION.yml +6 -0
  6. data/lib/README.rdoc +4 -0
  7. data/lib/archetype.rb +45 -0
  8. data/lib/archetype/functions.rb +9 -0
  9. data/lib/archetype/functions/hash.rb +149 -0
  10. data/lib/archetype/functions/helpers.rb +125 -0
  11. data/lib/archetype/functions/styleguide_memoizer.rb +61 -0
  12. data/lib/archetype/sass_extensions.rb +6 -0
  13. data/lib/archetype/sass_extensions/functions.rb +14 -0
  14. data/lib/archetype/sass_extensions/functions/environment.rb +14 -0
  15. data/lib/archetype/sass_extensions/functions/lists.rb +284 -0
  16. data/lib/archetype/sass_extensions/functions/locale.rb +77 -0
  17. data/lib/archetype/sass_extensions/functions/numbers.rb +19 -0
  18. data/lib/archetype/sass_extensions/functions/styleguide.rb +406 -0
  19. data/lib/archetype/sass_extensions/functions/ui.rb +59 -0
  20. data/lib/archetype/sass_extensions/functions/version.rb +95 -0
  21. data/lib/archetype/version.rb +75 -0
  22. data/stylesheets/_archetype.scss +2 -0
  23. data/stylesheets/archetype/_base.scss +46 -0
  24. data/stylesheets/archetype/_config.scss +366 -0
  25. data/stylesheets/archetype/_grid.scss +3 -0
  26. data/stylesheets/archetype/_hacks.scss +72 -0
  27. data/stylesheets/archetype/_init.scss +23 -0
  28. data/stylesheets/archetype/_styleguide.scss +6 -0
  29. data/stylesheets/archetype/_ui.scss +326 -0
  30. data/stylesheets/archetype/_util.scss +12 -0
  31. data/stylesheets/archetype/base/_h5bp.scss +307 -0
  32. data/stylesheets/archetype/base/_hybrid.scss +25 -0
  33. data/stylesheets/archetype/base/_normalize.scss +595 -0
  34. data/stylesheets/archetype/base/_reset.scss +72 -0
  35. data/stylesheets/archetype/grid/_config.scss +14 -0
  36. data/stylesheets/archetype/grid/_grid.scss +391 -0
  37. data/stylesheets/archetype/styleguide/_components.scss +25 -0
  38. data/stylesheets/archetype/styleguide/_helpers.scss +215 -0
  39. data/stylesheets/archetype/styleguide/_primitives.scss +10 -0
  40. data/stylesheets/archetype/styleguide/_styleguide.scss +41 -0
  41. data/stylesheets/archetype/styleguide/components/_alerts.scss +59 -0
  42. data/stylesheets/archetype/styleguide/components/_annotations.scss +27 -0
  43. data/stylesheets/archetype/styleguide/components/_bristol.scss +15 -0
  44. data/stylesheets/archetype/styleguide/components/_button_groups.scss +47 -0
  45. data/stylesheets/archetype/styleguide/components/_button_toolbars.scss +17 -0
  46. data/stylesheets/archetype/styleguide/components/_buttons.scss +338 -0
  47. data/stylesheets/archetype/styleguide/components/_canvas.scss +15 -0
  48. data/stylesheets/archetype/styleguide/components/_carets.scss +336 -0
  49. data/stylesheets/archetype/styleguide/components/_closes.scss +63 -0
  50. data/stylesheets/archetype/styleguide/components/_container.scss +27 -0
  51. data/stylesheets/archetype/styleguide/components/_copy.scss +85 -0
  52. data/stylesheets/archetype/styleguide/components/_flyouts.scss +52 -0
  53. data/stylesheets/archetype/styleguide/components/_headings.scss +33 -0
  54. data/stylesheets/archetype/styleguide/components/_headlines.scss +63 -0
  55. data/stylesheets/archetype/styleguide/components/_hovercards.scss +27 -0
  56. data/stylesheets/archetype/styleguide/components/_icons.scss +17 -0
  57. data/stylesheets/archetype/styleguide/components/_identities.scss +34 -0
  58. data/stylesheets/archetype/styleguide/components/_links.scss +66 -0
  59. data/stylesheets/archetype/styleguide/components/_loaders.scss +154 -0
  60. data/stylesheets/archetype/styleguide/components/_menu_items.scss +31 -0
  61. data/stylesheets/archetype/styleguide/components/_module.scss +15 -0
  62. data/stylesheets/archetype/styleguide/components/_pullquotes.scss +29 -0
  63. data/stylesheets/archetype/styleguide/components/_punchcut.scss +18 -0
  64. data/stylesheets/archetype/styleguide/components/_tooltips.scss +28 -0
  65. data/stylesheets/archetype/styleguide/primitives/_animations.scss +17 -0
  66. data/stylesheets/archetype/styleguide/primitives/_dimensions.scss +50 -0
  67. data/stylesheets/archetype/styleguide/primitives/_glyphs.scss +11 -0
  68. data/stylesheets/archetype/styleguide/primitives/_misc.scss +8 -0
  69. data/stylesheets/archetype/styleguide/primitives/_palettes.scss +94 -0
  70. data/stylesheets/archetype/styleguide/primitives/_shadows.scss +23 -0
  71. data/stylesheets/archetype/styleguide/primitives/_sprites.scss +46 -0
  72. data/stylesheets/archetype/styleguide/primitives/_textures.scss +10 -0
  73. data/stylesheets/archetype/styleguide/primitives/_typography.scss +56 -0
  74. data/stylesheets/archetype/util/_debug.scss +40 -0
  75. data/stylesheets/archetype/util/_lists.scss +57 -0
  76. data/stylesheets/archetype/util/_misc.scss +108 -0
  77. data/stylesheets/archetype/util/_rtl.scss +279 -0
  78. data/stylesheets/archetype/util/_spacing.scss +78 -0
  79. data/stylesheets/archetype/util/_styles.scss +466 -0
  80. data/stylesheets/archetype/util/_targeting.scss +210 -0
  81. data/stylesheets/archetype/util/_units.scss +18 -0
  82. data/templates/example/index.html +40 -0
  83. data/templates/example/manifest.rb +13 -0
  84. data/templates/example/screen.scss +99 -0
  85. data/templates/example/vendor/archetype/animations/loaders/large/large.png +0 -0
  86. data/templates/example/vendor/archetype/animations/loaders/large/large_dark.png +0 -0
  87. data/templates/example/vendor/archetype/animations/loaders/large/large_dark_static.png +0 -0
  88. data/templates/example/vendor/archetype/animations/loaders/large/large_static.png +0 -0
  89. data/templates/example/vendor/archetype/animations/loaders/medium/medium.png +0 -0
  90. data/templates/example/vendor/archetype/animations/loaders/medium/medium_dark.png +0 -0
  91. data/templates/example/vendor/archetype/animations/loaders/medium/medium_dark_static.png +0 -0
  92. data/templates/example/vendor/archetype/animations/loaders/medium/medium_static.png +0 -0
  93. data/templates/example/vendor/archetype/animations/loaders/small/small.png +0 -0
  94. data/templates/example/vendor/archetype/animations/loaders/small/small_dark.png +0 -0
  95. data/templates/example/vendor/archetype/animations/loaders/small/small_dark_static.png +0 -0
  96. data/templates/example/vendor/archetype/animations/loaders/small/small_static.png +0 -0
  97. data/templates/example/vendor/archetype/fontawesome-webfont.eot +0 -0
  98. data/templates/example/vendor/archetype/fontawesome-webfont.svg +255 -0
  99. data/templates/example/vendor/archetype/fontawesome-webfont.ttf +0 -0
  100. data/templates/example/vendor/archetype/fontawesome-webfont.woff +0 -0
  101. data/templates/project/manifest.rb +9 -0
  102. data/templates/project/screen.scss +1 -0
  103. data/templates/project/vendor/archetype/animations/loaders/large/large.png +0 -0
  104. data/templates/project/vendor/archetype/animations/loaders/large/large_dark.png +0 -0
  105. data/templates/project/vendor/archetype/animations/loaders/large/large_dark_static.png +0 -0
  106. data/templates/project/vendor/archetype/animations/loaders/large/large_static.png +0 -0
  107. data/templates/project/vendor/archetype/animations/loaders/medium/medium.png +0 -0
  108. data/templates/project/vendor/archetype/animations/loaders/medium/medium_dark.png +0 -0
  109. data/templates/project/vendor/archetype/animations/loaders/medium/medium_dark_static.png +0 -0
  110. data/templates/project/vendor/archetype/animations/loaders/medium/medium_static.png +0 -0
  111. data/templates/project/vendor/archetype/animations/loaders/small/small.png +0 -0
  112. data/templates/project/vendor/archetype/animations/loaders/small/small_dark.png +0 -0
  113. data/templates/project/vendor/archetype/animations/loaders/small/small_dark_static.png +0 -0
  114. data/templates/project/vendor/archetype/animations/loaders/small/small_static.png +0 -0
  115. data/templates/project/vendor/archetype/fontawesome-webfont.eot +0 -0
  116. data/templates/project/vendor/archetype/fontawesome-webfont.svg +255 -0
  117. data/templates/project/vendor/archetype/fontawesome-webfont.ttf +0 -0
  118. data/templates/project/vendor/archetype/fontawesome-webfont.woff +0 -0
  119. data/test/fixtures/stylesheets/archetype/assets/fonts/fontawesome-webfont.eot +0 -0
  120. data/test/fixtures/stylesheets/archetype/assets/fonts/fontawesome-webfont.svg +255 -0
  121. data/test/fixtures/stylesheets/archetype/assets/fonts/fontawesome-webfont.ttf +0 -0
  122. data/test/fixtures/stylesheets/archetype/assets/fonts/fontawesome-webfont.woff +0 -0
  123. data/test/fixtures/stylesheets/archetype/assets/images/vendor/archetype/animations/loaders/large/large.png +0 -0
  124. data/test/fixtures/stylesheets/archetype/assets/images/vendor/archetype/animations/loaders/large/large_dark.png +0 -0
  125. data/test/fixtures/stylesheets/archetype/assets/images/vendor/archetype/animations/loaders/large/large_dark_static.png +0 -0
  126. data/test/fixtures/stylesheets/archetype/assets/images/vendor/archetype/animations/loaders/large/large_static.png +0 -0
  127. data/test/fixtures/stylesheets/archetype/assets/images/vendor/archetype/animations/loaders/medium/medium.png +0 -0
  128. data/test/fixtures/stylesheets/archetype/assets/images/vendor/archetype/animations/loaders/medium/medium_dark.png +0 -0
  129. data/test/fixtures/stylesheets/archetype/assets/images/vendor/archetype/animations/loaders/medium/medium_dark_static.png +0 -0
  130. data/test/fixtures/stylesheets/archetype/assets/images/vendor/archetype/animations/loaders/medium/medium_static.png +0 -0
  131. data/test/fixtures/stylesheets/archetype/assets/images/vendor/archetype/animations/loaders/small/small.png +0 -0
  132. data/test/fixtures/stylesheets/archetype/assets/images/vendor/archetype/animations/loaders/small/small_dark.png +0 -0
  133. data/test/fixtures/stylesheets/archetype/assets/images/vendor/archetype/animations/loaders/small/small_dark_static.png +0 -0
  134. data/test/fixtures/stylesheets/archetype/assets/images/vendor/archetype/animations/loaders/small/small_static.png +0 -0
  135. data/test/fixtures/stylesheets/archetype/assets/images/vendor/archetype/sprites/hovercard_tip.png +0 -0
  136. data/test/fixtures/stylesheets/archetype/config.rb +19 -0
  137. data/test/fixtures/stylesheets/archetype/expected/b.css +14 -0
  138. data/test/fixtures/stylesheets/archetype/expected/base.css +349 -0
  139. data/test/fixtures/stylesheets/archetype/expected/hacks/ie_pseudo.css +11 -0
  140. data/test/fixtures/stylesheets/archetype/expected/locale.css +23 -0
  141. data/test/fixtures/stylesheets/archetype/expected/styleguide/buttons.css +2091 -0
  142. data/test/fixtures/stylesheets/archetype/expected/styleguide/fallback_styles.css +9 -0
  143. data/test/fixtures/stylesheets/archetype/expected/styleguide/nested_styleguides.css +24 -0
  144. data/test/fixtures/stylesheets/archetype/expected/styleguide/selective_state.css +174 -0
  145. data/test/fixtures/stylesheets/archetype/expected/ui/glyph_icon.css +37 -0
  146. data/test/fixtures/stylesheets/archetype/expected/ui/hide_element.css +8 -0
  147. data/test/fixtures/stylesheets/archetype/expected/ui/stroke.css +17 -0
  148. data/test/fixtures/stylesheets/archetype/expected/ui/triangle.css +35 -0
  149. data/test/fixtures/stylesheets/archetype/expected/utilities/associative.css +9 -0
  150. data/test/fixtures/stylesheets/archetype/expected/utilities/if-set.css +9 -0
  151. data/test/fixtures/stylesheets/archetype/expected/utilities/spacing/horizontal-spacing.css +29 -0
  152. data/test/fixtures/stylesheets/archetype/expected/utilities/spacing/vertical-spacing.css +29 -0
  153. data/test/fixtures/stylesheets/archetype/expected/utilities/styles/filter.css +11 -0
  154. data/test/fixtures/stylesheets/archetype/expected/utilities/styles/font-family.css +16 -0
  155. data/test/fixtures/stylesheets/archetype/expected/utilities/styles/z-index.css +15 -0
  156. data/test/fixtures/stylesheets/archetype/expected/utilities/targeting/target-browser.css +100 -0
  157. data/test/fixtures/stylesheets/archetype/expected/utilities/targeting/target-os.css +55 -0
  158. data/test/fixtures/stylesheets/archetype/source/b.scss +9 -0
  159. data/test/fixtures/stylesheets/archetype/source/base.scss +3 -0
  160. data/test/fixtures/stylesheets/archetype/source/hacks/ie_pseudo.scss +13 -0
  161. data/test/fixtures/stylesheets/archetype/source/locale.scss +43 -0
  162. data/test/fixtures/stylesheets/archetype/source/styleguide/buttons.scss +18 -0
  163. data/test/fixtures/stylesheets/archetype/source/styleguide/fallback_styles.scss +22 -0
  164. data/test/fixtures/stylesheets/archetype/source/styleguide/nested_styleguides.scss +40 -0
  165. data/test/fixtures/stylesheets/archetype/source/styleguide/selective_state.scss +22 -0
  166. data/test/fixtures/stylesheets/archetype/source/ui/glyph_icon.scss +13 -0
  167. data/test/fixtures/stylesheets/archetype/source/ui/hide_element.scss +5 -0
  168. data/test/fixtures/stylesheets/archetype/source/ui/stroke.scss +13 -0
  169. data/test/fixtures/stylesheets/archetype/source/ui/triangle.scss +13 -0
  170. data/test/fixtures/stylesheets/archetype/source/utilities/associative.scss +24 -0
  171. data/test/fixtures/stylesheets/archetype/source/utilities/if-set.scss +16 -0
  172. data/test/fixtures/stylesheets/archetype/source/utilities/spacing/horizontal-spacing.scss +27 -0
  173. data/test/fixtures/stylesheets/archetype/source/utilities/spacing/vertical-spacing.scss +27 -0
  174. data/test/fixtures/stylesheets/archetype/source/utilities/styles/filter.scss +9 -0
  175. data/test/fixtures/stylesheets/archetype/source/utilities/styles/font-family.scss +9 -0
  176. data/test/fixtures/stylesheets/archetype/source/utilities/styles/z-index.scss +18 -0
  177. data/test/fixtures/stylesheets/archetype/source/utilities/targeting/target-browser.scss +70 -0
  178. data/test/fixtures/stylesheets/archetype/source/utilities/targeting/target-os.scss +42 -0
  179. data/test/helpers/diff.rb +49 -0
  180. data/test/helpers/io.rb +36 -0
  181. data/test/helpers/test_case.rb +62 -0
  182. data/test/integrations/archetype_test.rb +126 -0
  183. data/test/test_helper.rb +26 -0
  184. data/test/units/sass_extensions_test.rb +207 -0
  185. metadata +303 -15
@@ -0,0 +1,27 @@
1
+ @import "archetype";
2
+
3
+ a {
4
+ @include vertical-spacing(2);
5
+ @include vertical-spacing(2, $method: margin);
6
+ }
7
+
8
+ b {
9
+ @include vertical-spacing(nil 2);
10
+ @include vertical-spacing(nil 2, $method: margin);
11
+ }
12
+
13
+ c {
14
+ @include vertical-spacing(2 nil);
15
+ @include vertical-spacing(2 nil, $method: margin);
16
+ }
17
+
18
+ d {
19
+ @include vertical-spacing(nil 2.6);
20
+ @include vertical-spacing(nil 2.6, $abuse: true);
21
+ @include vertical-spacing(nil 2.6, $abuse: true, $method: margin);
22
+ }
23
+
24
+ e {
25
+ @include vertical-spacing($top: 0, $bottom: 0);
26
+ @include vertical-spacing($top: 0, $bottom: 0, $method: margin);
27
+ }
@@ -0,0 +1,9 @@
1
+ @import "archetype";
2
+
3
+ a {
4
+ @include filter(Shadow(Strength=2, Direction=135, Color='#CCCCCC'));
5
+ }
6
+
7
+ b {
8
+ @include filter(gradient(enabled=false));
9
+ }
@@ -0,0 +1,9 @@
1
+ @import "archetype";
2
+
3
+ a {
4
+ @include font-family(serif);
5
+ }
6
+
7
+ b {
8
+ @include font-family(sans-serif);
9
+ }
@@ -0,0 +1,18 @@
1
+ @import "archetype";
2
+
3
+ a {
4
+ @include z-index(-1);
5
+
6
+ }
7
+
8
+ b {
9
+ @include z-index(1, default);
10
+ }
11
+
12
+ c {
13
+ @include z-index(1, dialog);
14
+ }
15
+
16
+ d {
17
+ @include z-index(20, 10001);
18
+ }
@@ -0,0 +1,70 @@
1
+ @import "archetype";
2
+
3
+ .target-ie-6 {
4
+ @include target-browser(ie 6, vertical-align, -5px);
5
+ @include target-browser(ie 6, background-position, 6px -2170px);
6
+ @include target-browser(ie 6,overflow,hidden);
7
+ }
8
+
9
+ .target-ie-lte-7 {
10
+ @include target-browser(ie lte 7, margin-top, 1px);
11
+ @include target-browser(ie lte 7, padding, 0);
12
+ @include target-browser(ie lte 7, width, 195px);
13
+ @include target-browser(ie lte 7, font-size, .01em);
14
+ @include target-browser(ie lte 7, height, 18px);
15
+ }
16
+
17
+ .target-ie-6-7 {
18
+ @include target-browser(ie 6 7, display, inline);
19
+ @include target-browser(ie 6 7, zoom, 1);
20
+ @include target-browser(ie 6 7, margin-left, 0);
21
+ }
22
+
23
+ .target-ie-7 {
24
+ @include target-browser(ie 7, vertical-align, -5px);
25
+ @include target-browser(ie 7, background-position, 6px -2170px);
26
+ @include target-browser(ie 7,overflow,hidden);
27
+ }
28
+
29
+ .target-ie-7-8 {
30
+ @include target-browser(ie 7 8, min-height, 250px !important);
31
+ }
32
+
33
+ .target-ie-lte-8 {
34
+ @include target-browser(ie lte 8, filter, BasicImage(rotation=3));
35
+ @include target-browser(ie lte 8, padding-bottom, 8px);
36
+ @include target-browser(ie lte 8, line-height, 1.6);
37
+ }
38
+
39
+ .target-ie-8 {
40
+ @include target-browser(ie 8, margin-top, 2px);
41
+ @include target-browser(ie 8, min-height, 170px);
42
+ }
43
+
44
+ .target-ie-lte-9 {
45
+ @include target-browser(ie lte 9, border-color, #111);
46
+ @include target-browser(ie lte 9, background, #2c2c2b);
47
+ }
48
+
49
+ .target-ie-7-8-9 {
50
+ @include target-browser(ie 7 8 9, width, 250px);
51
+ }
52
+
53
+ .target-ie-9 {
54
+ @include target-browser(ie 9, right, -83px);
55
+ @include target-browser(ie 9,top, 17px);
56
+ }
57
+
58
+ .target-webkit {
59
+ @include target-browser(webkit, line-height, 16px);
60
+ @include target-browser(webkit, padding-top, 10px);
61
+ @include target-browser(webkit, width, 151px);
62
+ }
63
+
64
+ .target-firefox {
65
+ @include target-browser(firefox, margin-top, 16px);
66
+ }
67
+
68
+ .target-opera {
69
+ @include target-browser(opera, width, 82%);
70
+ }
@@ -0,0 +1,42 @@
1
+ @import "archetype";
2
+
3
+ .target-linux {
4
+ @include target-os(linux, top, -3px);
5
+ @include target-os(linux, width, 300px);
6
+ }
7
+
8
+ .target-apple {
9
+ @include target-os(apple, top, -3px);
10
+ @include target-os(apple, width, 300px);
11
+ }
12
+
13
+ .target-mac {
14
+ @include target-os(mac, top, -3px);
15
+ @include target-os(mac, width, 300px);
16
+ }
17
+
18
+ .target-osx {
19
+ @include target-os(osx, top, -3px);
20
+ @include target-os(osx, width, 300px);
21
+ }
22
+
23
+ .target-windows {
24
+ @include target-os(windows, top, -3px);
25
+ @include target-os(windows, width, 300px);
26
+ }
27
+
28
+ .target-win {
29
+ @include target-os(win, top, -3px);
30
+ @include target-os(win, width, 300px);
31
+ }
32
+
33
+ .target-winxp {
34
+ @include target-os(winxp, top, -3px);
35
+ @include target-os(winxp, width, 300px);
36
+ }
37
+
38
+ .target-win7 {
39
+ @include target-os(win7, top, -3px);
40
+ @include target-os(win7, width, 300px);
41
+ }
42
+
@@ -0,0 +1,49 @@
1
+ require 'diff/lcs'
2
+ require 'diff/lcs/hunk'
3
+ module Compass
4
+ module Diff
5
+ #stole this from rspec who stole this from the gem
6
+ def diff_as_string(data_new, data_old)
7
+ data_old = data_old.split(/\n/).map! { |e| e.chomp }
8
+ data_new = data_new.split(/\n/).map! { |e| e.chomp }
9
+ output = ""
10
+ diffs = ::Diff::LCS.diff(data_old, data_new)
11
+ return output if diffs.empty?
12
+ oldhunk = hunk = nil
13
+ file_length_difference = 0
14
+ diffs.each do |piece|
15
+ begin
16
+ hunk = ::Diff::LCS::Hunk.new(
17
+ data_old, data_new, piece, context_lines, file_length_difference
18
+ )
19
+ file_length_difference = hunk.file_length_difference
20
+ next unless oldhunk
21
+ # Hunks may overlap, which is why we need to be careful when our
22
+ # diff includes lines of context. Otherwise, we might print
23
+ # redundant lines.
24
+ if (context_lines > 0) and hunk.overlaps?(oldhunk)
25
+ hunk.unshift(oldhunk)
26
+ else
27
+ output << oldhunk.diff(format)
28
+ end
29
+ ensure
30
+ oldhunk = hunk
31
+ output << "\n"
32
+ end
33
+ end
34
+ #Handle the last remaining hunk
35
+ output << oldhunk.diff(format) << "\n"
36
+ end
37
+
38
+ protected
39
+
40
+ def format
41
+ :unified
42
+ end
43
+
44
+ def context_lines
45
+ 3
46
+ end
47
+
48
+ end
49
+ end
@@ -0,0 +1,36 @@
1
+ module Compass
2
+ module IoHelper
3
+ def capture_output
4
+ real_stdout, $stdout = $stdout, StringIO.new
5
+ yield
6
+ $stdout.string
7
+ ensure
8
+ $stdout = real_stdout
9
+ end
10
+
11
+ def capture_warning
12
+ real_stderr, $stderr = $stderr, StringIO.new
13
+ yield
14
+ $stderr.string
15
+ ensure
16
+ $stderr = real_stderr
17
+ end
18
+
19
+ def capture_pipe(io, options = {})
20
+ options[:wait] = 0.25
21
+ options[:timeout] = 1.0
22
+ output = ""
23
+ eof_at = nil
24
+ while !eof_at || (Time.now - eof_at < options[:wait])
25
+ if io.eof?
26
+ eof_at ||= Time.now
27
+ sleep 0.1
28
+ else
29
+ eof_at = nil
30
+ timeout(options[:timeout]) { output << io.readpartial(1024) }
31
+ end
32
+ end
33
+ output
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,62 @@
1
+ module Compass
2
+ module TestCaseHelper
3
+ def absolutize(path)
4
+ if Compass::Util.blank?(path)
5
+ File.expand_path('../../', __FILE__)
6
+ elsif path[0] == ?/
7
+ File.join(File.expand_path('../', __FILE__), path)
8
+ else
9
+ File.join(File.expand_path('../../', __FILE__), path)
10
+ end
11
+ end
12
+
13
+ # compile a Sass string in the context of a project in the current working directory.
14
+ def compile_for_project(contents, options = {})
15
+ Compass.add_project_configuration
16
+ options[:syntax] ||= :scss
17
+ Sass::Engine.new(contents, Compass.configuration.to_sass_engine_options.merge(options)).render
18
+ end
19
+
20
+ def assert_correct(before, after)
21
+ if before == after
22
+ assert(true)
23
+ else
24
+ assert false, diff_as_string(before.inspect, after.inspect)
25
+ end
26
+ end
27
+
28
+ module ClassMethods
29
+
30
+ def let(method, &block)
31
+ define_method method, &block
32
+ end
33
+
34
+ def it(name, &block)
35
+ test(name, &block)
36
+ end
37
+
38
+ def test(name, &block)
39
+ define_method "test_#{underscore(name)}".to_sym, &block
40
+ end
41
+
42
+ def setup(&block)
43
+ define_method :setup do
44
+ yield
45
+ end
46
+ end
47
+
48
+ def after(&block)
49
+ define_method :teardown do
50
+ yield
51
+ end
52
+ end
53
+
54
+ private
55
+
56
+ def underscore(string)
57
+ string.gsub(' ', '_')
58
+ end
59
+
60
+ end
61
+ end
62
+ end
@@ -0,0 +1,126 @@
1
+ # this is all take from Compass because they already did the awesome testing framework
2
+ require 'test_helper'
3
+ require 'compass'
4
+ require 'compass/logger'
5
+ require 'sass/plugin'
6
+ unless ENV['CI']
7
+ require 'fileutils'
8
+ end
9
+
10
+ class ArchetypeTest < Test::Unit::TestCase
11
+
12
+ def setup
13
+ Compass.reset_configuration!
14
+ end
15
+
16
+ def teardown
17
+ [:archetype].each do |project_name|
18
+ ::FileUtils.rm_rf tempfile_path(project_name)
19
+ end
20
+ end
21
+
22
+ def test_archetype
23
+ within_project('archetype') do |proj|
24
+ each_css_file(proj.css_path) do |css_file|
25
+ assert_no_errors css_file, 'archetype'
26
+ end
27
+ each_sass_file do |sass_file|
28
+ assert_renders_correctly sass_file, :ignore_charset => true
29
+ end
30
+ end
31
+ end
32
+
33
+ private
34
+ def assert_no_errors(css_file, project_name)
35
+ file = css_file[(tempfile_path(project_name).size+1)..-1]
36
+ msg = "Syntax Error found in #{file}. Results saved into #{save_path(project_name)}/#{file}"
37
+ assert_equal 0, open(css_file).readlines.grep(/Sass::SyntaxError/).size, msg
38
+ end
39
+
40
+ def assert_renders_correctly(*arguments)
41
+ options = arguments.last.is_a?(Hash) ? arguments.pop : {}
42
+ for name in arguments
43
+ actual_result_file = "#{tempfile_path(@current_project)}/#{name}.css"
44
+ expected_result_file = "#{result_path(@current_project)}/#{name}.css"
45
+ actual_lines = File.read(actual_result_file)
46
+ actual_lines.gsub!(/^@charset[^;]+;/,'') if options[:ignore_charset]
47
+ actual_lines = actual_lines.split("\n").reject{|l| l=~/\A\Z/}
48
+ expected_lines = ERB.new(File.read(expected_result_file)).result(binding)
49
+ expected_lines.gsub!(/^@charset[^;]+;/,'') if options[:ignore_charset]
50
+ expected_lines = expected_lines.split("\n").reject{|l| l=~/\A\Z/}
51
+ expected_lines.zip(actual_lines).each_with_index do |pair, line|
52
+ if pair.first == pair.last
53
+ assert(true)
54
+ else
55
+ assert false, "Error in #{result_path(@current_project)}/#{name}.css:#{line + 1}\n"+diff_as_string(pair.first.inspect, pair.last.inspect)
56
+ end
57
+ end
58
+ if expected_lines.size < actual_lines.size
59
+ assert(false, "#{actual_lines.size - expected_lines.size} Trailing lines found in #{actual_result_file}.css: #{actual_lines[expected_lines.size..-1].join('\n')}")
60
+ end
61
+ end
62
+ end
63
+
64
+ def within_project(project_name, config_block = nil)
65
+ @current_project = project_name
66
+ Compass.add_configuration(configuration_file(project_name)) if File.exists?(configuration_file(project_name))
67
+ Compass.configuration.project_path = project_path(project_name)
68
+ Compass.configuration.environment = :production
69
+ args = Compass.configuration.to_compiler_arguments(:logger => Compass::NullLogger.new)
70
+
71
+ if config_block
72
+ config_block.call(Compass.configuration)
73
+ end
74
+
75
+ if Compass.configuration.sass_path && File.exists?(Compass.configuration.sass_path)
76
+ compiler = Compass::Compiler.new *args
77
+ compiler.clean!
78
+ compiler.run
79
+ end
80
+ yield Compass.configuration if block_given?
81
+ rescue
82
+ save_output(project_name)
83
+ raise
84
+ end
85
+
86
+ def each_css_file(dir, &block)
87
+ Dir.glob("#{dir}/**/*.css").each(&block)
88
+ end
89
+
90
+ def each_sass_file(sass_dir = nil)
91
+ sass_dir ||= template_path(@current_project)
92
+ Dir.glob("#{sass_dir}/**/*.s[ac]ss").each do |sass_file|
93
+ yield sass_file[(sass_dir.length+1)..-6]
94
+ end
95
+ end
96
+
97
+ def save_output(dir)
98
+ FileUtils.rm_rf(save_path(dir))
99
+ FileUtils.cp_r(tempfile_path(dir), save_path(dir)) if File.exists?(tempfile_path(dir))
100
+ end
101
+
102
+ def project_path(project_name)
103
+ absolutize("fixtures/stylesheets/#{project_name}")
104
+ end
105
+
106
+ def configuration_file(project_name)
107
+ File.join(project_path(project_name), "config.rb")
108
+ end
109
+
110
+ def tempfile_path(project_name)
111
+ File.join(project_path(project_name), "tmp")
112
+ end
113
+
114
+ def template_path(project_name)
115
+ File.join(project_path(project_name), "source")
116
+ end
117
+
118
+ def result_path(project_name)
119
+ File.join(project_path(project_name), "expected")
120
+ end
121
+
122
+ def save_path(project_name)
123
+ File.join(project_path(project_name), "saved")
124
+ end
125
+
126
+ end