archetype 0.0.1.pre.13 → 1.0.0.alpha.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 (253) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +97 -24
  3. data/README.md +11 -5
  4. data/VERSION +1 -0
  5. data/lib/archetype.rb +30 -18
  6. data/lib/archetype/actions/migrate.rb +152 -0
  7. data/lib/archetype/actions/theme.rb +6 -7
  8. data/lib/archetype/executor.rb +21 -7
  9. data/lib/archetype/extensions.rb +57 -0
  10. data/lib/archetype/functions.rb +2 -3
  11. data/lib/archetype/functions/css.rb +70 -0
  12. data/lib/archetype/functions/css/constants.rb +247 -0
  13. data/lib/archetype/functions/css/helpers.rb +265 -0
  14. data/lib/archetype/functions/css/routers.rb +28 -0
  15. data/lib/archetype/functions/css/routers/animation.rb +55 -0
  16. data/lib/archetype/functions/css/routers/background.rb +38 -0
  17. data/lib/archetype/functions/css/routers/border.rb +151 -0
  18. data/lib/archetype/functions/css/routers/list.rb +63 -0
  19. data/lib/archetype/functions/css/routers/margin_padding.rb +40 -0
  20. data/lib/archetype/functions/css/routers/outline.rb +56 -0
  21. data/lib/archetype/functions/css/routers/overflow.rb +11 -0
  22. data/lib/archetype/functions/css/routers/target.rb +38 -0
  23. data/lib/archetype/functions/css/routers/transition.rb +48 -0
  24. data/lib/archetype/functions/css/shorthands.rb +43 -0
  25. data/lib/archetype/functions/css/shorthands/animation.rb +18 -0
  26. data/lib/archetype/functions/css/shorthands/background.rb +68 -0
  27. data/lib/archetype/functions/css/shorthands/border.rb +102 -0
  28. data/lib/archetype/functions/hash.rb +3 -149
  29. data/lib/archetype/functions/hash/extend.rb +74 -0
  30. data/lib/archetype/functions/hash/shim.rb +48 -0
  31. data/lib/archetype/functions/helpers.rb +231 -22
  32. data/lib/archetype/functions/styleguide_memoizer.rb +18 -1
  33. data/lib/archetype/sass_extensions.rb +1 -3
  34. data/lib/archetype/sass_extensions/functions.rb +15 -1
  35. data/lib/archetype/sass_extensions/functions/environment.rb +152 -1
  36. data/lib/archetype/sass_extensions/functions/lists.rb +95 -45
  37. data/lib/archetype/sass_extensions/functions/locale.rb +107 -28
  38. data/lib/archetype/sass_extensions/functions/numbers.rb +118 -4
  39. data/lib/archetype/sass_extensions/functions/strings.rb +53 -0
  40. data/lib/archetype/sass_extensions/functions/styleguide.rb +43 -375
  41. data/lib/archetype/sass_extensions/functions/styleguide/components.rb +25 -0
  42. data/lib/archetype/sass_extensions/functions/styleguide/constants.rb +27 -0
  43. data/lib/archetype/sass_extensions/functions/styleguide/grammar.rb +80 -0
  44. data/lib/archetype/sass_extensions/functions/styleguide/helpers.rb +36 -0
  45. data/lib/archetype/sass_extensions/functions/styleguide/resolve.rb +159 -0
  46. data/lib/archetype/sass_extensions/functions/styleguide/styles.rb +146 -0
  47. data/lib/archetype/sass_extensions/functions/styleguide/themes.rb +40 -0
  48. data/lib/archetype/sass_extensions/functions/ui.rb +7 -57
  49. data/lib/archetype/sass_extensions/functions/ui/glyphs.rb +118 -0
  50. data/lib/archetype/sass_extensions/functions/ui/scopes.rb +96 -0
  51. data/lib/archetype/sass_extensions/functions/util.rb +14 -0
  52. data/lib/archetype/sass_extensions/functions/util/debug.rb +22 -0
  53. data/lib/archetype/sass_extensions/functions/util/hacks.rb +44 -0
  54. data/lib/archetype/sass_extensions/functions/util/images.rb +132 -0
  55. data/lib/archetype/sass_extensions/functions/util/misc.rb +220 -0
  56. data/lib/archetype/sass_extensions/functions/util/spacing.rb +83 -0
  57. data/lib/archetype/sass_extensions/functions/version.rb +12 -17
  58. data/lib/archetype/version.rb +1 -1
  59. data/stylesheets/archetype/_config.scss +1 -389
  60. data/stylesheets/archetype/_core.scss +15 -0
  61. data/stylesheets/archetype/_hacks.scss +4 -120
  62. data/stylesheets/archetype/_init.scss +4 -22
  63. data/stylesheets/archetype/_required.scss +3 -0
  64. data/stylesheets/archetype/_reset.scss +3 -0
  65. data/stylesheets/archetype/_styleguide.scss +2 -6
  66. data/stylesheets/archetype/_ui.scss +2 -358
  67. data/stylesheets/archetype/_util.scss +3 -10
  68. data/stylesheets/archetype/config/_core.scss +14 -0
  69. data/stylesheets/archetype/config/_environment.scss +19 -0
  70. data/stylesheets/archetype/config/_formatting.scss +63 -0
  71. data/stylesheets/archetype/config/_glyphs.scss +252 -0
  72. data/stylesheets/archetype/config/_resets.scss +7 -0
  73. data/stylesheets/archetype/config/_resolution.scss +3 -0
  74. data/stylesheets/archetype/config/_spacing.scss +5 -0
  75. data/stylesheets/archetype/config/_targeting.scss +18 -0
  76. data/stylesheets/archetype/config/_theme.scss +3 -0
  77. data/stylesheets/archetype/config/_typography.scss +56 -0
  78. data/stylesheets/archetype/config/_units.scss +2 -0
  79. data/stylesheets/archetype/config/_vars.scss +10 -0
  80. data/stylesheets/archetype/hacks/_core.scss +4 -0
  81. data/stylesheets/archetype/hacks/_hacks.scss +160 -0
  82. data/stylesheets/archetype/hacks/_init.scss +2 -0
  83. data/stylesheets/archetype/styleguide/_core.scss +4 -0
  84. data/stylesheets/archetype/styleguide/_init.scss +1 -0
  85. data/stylesheets/archetype/styleguide/_styleguide.scss +41 -18
  86. data/stylesheets/archetype/ui/_accessibility.scss +41 -0
  87. data/stylesheets/archetype/ui/_breakpoints.scss +19 -0
  88. data/stylesheets/archetype/ui/_core.scss +10 -0
  89. data/stylesheets/archetype/ui/_elements.scss +98 -0
  90. data/stylesheets/archetype/ui/_glyphs.scss +244 -0
  91. data/stylesheets/archetype/ui/_init.scss +5 -0
  92. data/stylesheets/archetype/ui/_layout.scss +37 -0
  93. data/stylesheets/archetype/ui/_locale.scss +12 -0
  94. data/stylesheets/archetype/ui/_scopes.scss +42 -0
  95. data/stylesheets/archetype/util/_core.scss +8 -0
  96. data/stylesheets/archetype/util/_debug.scss +9 -21
  97. data/stylesheets/archetype/util/_init.scss +1 -0
  98. data/stylesheets/archetype/util/_misc.scss +21 -86
  99. data/stylesheets/archetype/util/_spacing.scss +9 -40
  100. data/stylesheets/archetype/util/_styles.scss +189 -178
  101. data/stylesheets/archetype/util/_targeting.scss +51 -68
  102. data/templates/example/manifest.rb +2 -2
  103. data/templates/example/screen.scss +0 -1
  104. data/templates/project/manifest.rb +3 -8
  105. metadata +93 -263
  106. data/bin/archetype +0 -3
  107. data/lib/archetype/sass_extensions/monkey_patches.rb +0 -3
  108. data/lib/archetype/sass_extensions/monkey_patches/handle_include_loop.rb +0 -13
  109. data/stylesheets/archetype/_base.scss +0 -54
  110. data/stylesheets/archetype/_grid.scss +0 -3
  111. data/stylesheets/archetype/base/_h5bp.scss +0 -307
  112. data/stylesheets/archetype/base/_hybrid.scss +0 -25
  113. data/stylesheets/archetype/base/_normalize.scss +0 -634
  114. data/stylesheets/archetype/base/_reset.scss +0 -72
  115. data/stylesheets/archetype/grid/_config.scss +0 -14
  116. data/stylesheets/archetype/grid/_grid.scss +0 -391
  117. data/stylesheets/archetype/styleguide/_components.scss +0 -25
  118. data/stylesheets/archetype/styleguide/_helpers.scss +0 -215
  119. data/stylesheets/archetype/styleguide/_primitives.scss +0 -10
  120. data/stylesheets/archetype/styleguide/components/_alerts.scss +0 -59
  121. data/stylesheets/archetype/styleguide/components/_annotations.scss +0 -27
  122. data/stylesheets/archetype/styleguide/components/_bristol.scss +0 -15
  123. data/stylesheets/archetype/styleguide/components/_button_groups.scss +0 -47
  124. data/stylesheets/archetype/styleguide/components/_button_toolbars.scss +0 -17
  125. data/stylesheets/archetype/styleguide/components/_buttons.scss +0 -339
  126. data/stylesheets/archetype/styleguide/components/_canvas.scss +0 -15
  127. data/stylesheets/archetype/styleguide/components/_carets.scss +0 -336
  128. data/stylesheets/archetype/styleguide/components/_closes.scss +0 -63
  129. data/stylesheets/archetype/styleguide/components/_container.scss +0 -27
  130. data/stylesheets/archetype/styleguide/components/_copy.scss +0 -85
  131. data/stylesheets/archetype/styleguide/components/_flyouts.scss +0 -52
  132. data/stylesheets/archetype/styleguide/components/_headings.scss +0 -33
  133. data/stylesheets/archetype/styleguide/components/_headlines.scss +0 -64
  134. data/stylesheets/archetype/styleguide/components/_hovercards.scss +0 -27
  135. data/stylesheets/archetype/styleguide/components/_icons.scss +0 -17
  136. data/stylesheets/archetype/styleguide/components/_identities.scss +0 -34
  137. data/stylesheets/archetype/styleguide/components/_links.scss +0 -68
  138. data/stylesheets/archetype/styleguide/components/_loaders.scss +0 -154
  139. data/stylesheets/archetype/styleguide/components/_menu_items.scss +0 -31
  140. data/stylesheets/archetype/styleguide/components/_module.scss +0 -15
  141. data/stylesheets/archetype/styleguide/components/_pullquotes.scss +0 -29
  142. data/stylesheets/archetype/styleguide/components/_punchcut.scss +0 -18
  143. data/stylesheets/archetype/styleguide/components/_tooltips.scss +0 -28
  144. data/stylesheets/archetype/styleguide/primitives/_animations.scss +0 -17
  145. data/stylesheets/archetype/styleguide/primitives/_dimensions.scss +0 -50
  146. data/stylesheets/archetype/styleguide/primitives/_glyphs.scss +0 -11
  147. data/stylesheets/archetype/styleguide/primitives/_misc.scss +0 -8
  148. data/stylesheets/archetype/styleguide/primitives/_palettes.scss +0 -94
  149. data/stylesheets/archetype/styleguide/primitives/_shadows.scss +0 -23
  150. data/stylesheets/archetype/styleguide/primitives/_sprites.scss +0 -46
  151. data/stylesheets/archetype/styleguide/primitives/_textures.scss +0 -10
  152. data/stylesheets/archetype/styleguide/primitives/_typography.scss +0 -56
  153. data/stylesheets/archetype/util/_lists.scss +0 -57
  154. data/stylesheets/archetype/util/_rtl.scss +0 -279
  155. data/stylesheets/archetype/util/_units.scss +0 -18
  156. data/templates/project/screen.scss +0 -1
  157. data/templates/project/vendor/archetype/animations/loaders/large/large.png +0 -0
  158. data/templates/project/vendor/archetype/animations/loaders/large/large_dark.png +0 -0
  159. data/templates/project/vendor/archetype/animations/loaders/large/large_dark_static.png +0 -0
  160. data/templates/project/vendor/archetype/animations/loaders/large/large_static.png +0 -0
  161. data/templates/project/vendor/archetype/animations/loaders/medium/medium.png +0 -0
  162. data/templates/project/vendor/archetype/animations/loaders/medium/medium_dark.png +0 -0
  163. data/templates/project/vendor/archetype/animations/loaders/medium/medium_dark_static.png +0 -0
  164. data/templates/project/vendor/archetype/animations/loaders/medium/medium_static.png +0 -0
  165. data/templates/project/vendor/archetype/animations/loaders/small/small.png +0 -0
  166. data/templates/project/vendor/archetype/animations/loaders/small/small_dark.png +0 -0
  167. data/templates/project/vendor/archetype/animations/loaders/small/small_dark_static.png +0 -0
  168. data/templates/project/vendor/archetype/animations/loaders/small/small_static.png +0 -0
  169. data/templates/project/vendor/archetype/fontawesome-webfont.eot +0 -0
  170. data/templates/project/vendor/archetype/fontawesome-webfont.svg +0 -255
  171. data/templates/project/vendor/archetype/fontawesome-webfont.ttf +0 -0
  172. data/templates/project/vendor/archetype/fontawesome-webfont.woff +0 -0
  173. data/test/fixtures/stylesheets/archetype/assets/fonts/fontawesome-webfont.eot +0 -0
  174. data/test/fixtures/stylesheets/archetype/assets/fonts/fontawesome-webfont.svg +0 -255
  175. data/test/fixtures/stylesheets/archetype/assets/fonts/fontawesome-webfont.ttf +0 -0
  176. data/test/fixtures/stylesheets/archetype/assets/fonts/fontawesome-webfont.woff +0 -0
  177. data/test/fixtures/stylesheets/archetype/assets/images/vendor/archetype/animations/loaders-s7889ccc8c1.png +0 -0
  178. data/test/fixtures/stylesheets/archetype/assets/images/vendor/archetype/animations/loaders/large/large.png +0 -0
  179. data/test/fixtures/stylesheets/archetype/assets/images/vendor/archetype/animations/loaders/large/large_dark.png +0 -0
  180. data/test/fixtures/stylesheets/archetype/assets/images/vendor/archetype/animations/loaders/large/large_dark_static.png +0 -0
  181. data/test/fixtures/stylesheets/archetype/assets/images/vendor/archetype/animations/loaders/large/large_static.png +0 -0
  182. data/test/fixtures/stylesheets/archetype/assets/images/vendor/archetype/animations/loaders/medium/medium.png +0 -0
  183. data/test/fixtures/stylesheets/archetype/assets/images/vendor/archetype/animations/loaders/medium/medium_dark.png +0 -0
  184. data/test/fixtures/stylesheets/archetype/assets/images/vendor/archetype/animations/loaders/medium/medium_dark_static.png +0 -0
  185. data/test/fixtures/stylesheets/archetype/assets/images/vendor/archetype/animations/loaders/medium/medium_static.png +0 -0
  186. data/test/fixtures/stylesheets/archetype/assets/images/vendor/archetype/animations/loaders/small/small.png +0 -0
  187. data/test/fixtures/stylesheets/archetype/assets/images/vendor/archetype/animations/loaders/small/small_dark.png +0 -0
  188. data/test/fixtures/stylesheets/archetype/assets/images/vendor/archetype/animations/loaders/small/small_dark_static.png +0 -0
  189. data/test/fixtures/stylesheets/archetype/assets/images/vendor/archetype/animations/loaders/small/small_static.png +0 -0
  190. data/test/fixtures/stylesheets/archetype/assets/images/vendor/archetype/sprites/hovercard_tip.png +0 -0
  191. data/test/fixtures/stylesheets/archetype/config.rb +0 -21
  192. data/test/fixtures/stylesheets/archetype/source/b.scss +0 -9
  193. data/test/fixtures/stylesheets/archetype/source/base.scss +0 -3
  194. data/test/fixtures/stylesheets/archetype/source/hacks/ie_pseudo.scss +0 -13
  195. data/test/fixtures/stylesheets/archetype/source/hacks/transparent_focusable.scss +0 -5
  196. data/test/fixtures/stylesheets/archetype/source/locale.scss +0 -43
  197. data/test/fixtures/stylesheets/archetype/source/styleguide/alerts.scss +0 -21
  198. data/test/fixtures/stylesheets/archetype/source/styleguide/buttons.scss +0 -18
  199. data/test/fixtures/stylesheets/archetype/source/styleguide/drop.scss +0 -101
  200. data/test/fixtures/stylesheets/archetype/source/styleguide/extend.scss +0 -24
  201. data/test/fixtures/stylesheets/archetype/source/styleguide/fallback_styles.scss +0 -23
  202. data/test/fixtures/stylesheets/archetype/source/styleguide/invalid_structures.scss +0 -85
  203. data/test/fixtures/stylesheets/archetype/source/styleguide/multi_value.scss +0 -18
  204. data/test/fixtures/stylesheets/archetype/source/styleguide/nested_styleguides.scss +0 -40
  205. data/test/fixtures/stylesheets/archetype/source/styleguide/selective_state.scss +0 -22
  206. data/test/fixtures/stylesheets/archetype/source/ui/glyph_icon.scss +0 -35
  207. data/test/fixtures/stylesheets/archetype/source/ui/hide_element.scss +0 -5
  208. data/test/fixtures/stylesheets/archetype/source/ui/stroke.scss +0 -13
  209. data/test/fixtures/stylesheets/archetype/source/ui/triangle.scss +0 -13
  210. data/test/fixtures/stylesheets/archetype/source/utilities/associative.scss +0 -24
  211. data/test/fixtures/stylesheets/archetype/source/utilities/custom_output_styler.scss +0 -22
  212. data/test/fixtures/stylesheets/archetype/source/utilities/if-set.scss +0 -16
  213. data/test/fixtures/stylesheets/archetype/source/utilities/spacing/horizontal-spacing.scss +0 -27
  214. data/test/fixtures/stylesheets/archetype/source/utilities/spacing/vertical-spacing.scss +0 -27
  215. data/test/fixtures/stylesheets/archetype/source/utilities/styles/filter.scss +0 -9
  216. data/test/fixtures/stylesheets/archetype/source/utilities/styles/font-family.scss +0 -9
  217. data/test/fixtures/stylesheets/archetype/source/utilities/styles/z-index.scss +0 -18
  218. data/test/fixtures/stylesheets/archetype/source/utilities/targeting/target-browser.scss +0 -77
  219. data/test/fixtures/stylesheets/archetype/source/utilities/targeting/target-os.scss +0 -42
  220. data/test/fixtures/stylesheets/archetype/tmp/b.css +0 -14
  221. data/test/fixtures/stylesheets/archetype/tmp/base.css +0 -349
  222. data/test/fixtures/stylesheets/archetype/tmp/hacks/ie_pseudo.css +0 -11
  223. data/test/fixtures/stylesheets/archetype/tmp/hacks/transparent_focusable.css +0 -4
  224. data/test/fixtures/stylesheets/archetype/tmp/locale.css +0 -23
  225. data/test/fixtures/stylesheets/archetype/tmp/styleguide/alerts.css +0 -711
  226. data/test/fixtures/stylesheets/archetype/tmp/styleguide/buttons.css +0 -2119
  227. data/test/fixtures/stylesheets/archetype/tmp/styleguide/drop.css +0 -63
  228. data/test/fixtures/stylesheets/archetype/tmp/styleguide/extend.css +0 -11
  229. data/test/fixtures/stylesheets/archetype/tmp/styleguide/fallback_styles.css +0 -10
  230. data/test/fixtures/stylesheets/archetype/tmp/styleguide/invalid_structures.css +0 -21
  231. data/test/fixtures/stylesheets/archetype/tmp/styleguide/multi_value.css +0 -13
  232. data/test/fixtures/stylesheets/archetype/tmp/styleguide/nested_styleguides.css +0 -28
  233. data/test/fixtures/stylesheets/archetype/tmp/styleguide/selective_state.css +0 -177
  234. data/test/fixtures/stylesheets/archetype/tmp/ui/glyph_icon.css +0 -127
  235. data/test/fixtures/stylesheets/archetype/tmp/ui/hide_element.css +0 -8
  236. data/test/fixtures/stylesheets/archetype/tmp/ui/stroke.css +0 -17
  237. data/test/fixtures/stylesheets/archetype/tmp/ui/triangle.css +0 -35
  238. data/test/fixtures/stylesheets/archetype/tmp/utilities/associative.css +0 -9
  239. data/test/fixtures/stylesheets/archetype/tmp/utilities/custom_output_styler.css +0 -8
  240. data/test/fixtures/stylesheets/archetype/tmp/utilities/if-set.css +0 -9
  241. data/test/fixtures/stylesheets/archetype/tmp/utilities/spacing/horizontal-spacing.css +0 -29
  242. data/test/fixtures/stylesheets/archetype/tmp/utilities/spacing/vertical-spacing.css +0 -29
  243. data/test/fixtures/stylesheets/archetype/tmp/utilities/styles/filter.css +0 -11
  244. data/test/fixtures/stylesheets/archetype/tmp/utilities/styles/font-family.css +0 -16
  245. data/test/fixtures/stylesheets/archetype/tmp/utilities/styles/z-index.css +0 -15
  246. data/test/fixtures/stylesheets/archetype/tmp/utilities/targeting/target-browser.css +0 -105
  247. data/test/fixtures/stylesheets/archetype/tmp/utilities/targeting/target-os.css +0 -55
  248. data/test/helpers/diff.rb +0 -49
  249. data/test/helpers/io.rb +0 -36
  250. data/test/helpers/test_case.rb +0 -62
  251. data/test/integrations/archetype_test.rb +0 -126
  252. data/test/test_helper.rb +0 -26
  253. data/test/units/sass_extensions_test.rb +0 -200
@@ -1,62 +0,0 @@
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
@@ -1,126 +0,0 @@
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
@@ -1,26 +0,0 @@
1
- # borrowed from Compass
2
- lib_dir = File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib'))
3
- $:.unshift(lib_dir) unless $:.include?(lib_dir)
4
- test_dir = File.dirname(__FILE__)
5
- $:.unshift(test_dir) unless $:.include?(test_dir)
6
-
7
- require 'rubygems'
8
- require 'compass'
9
- require 'test/unit'
10
-
11
- class String
12
- def name
13
- to_s
14
- end
15
- end
16
-
17
- %w(diff io test_case).each do |helper|
18
- require "helpers/#{helper}"
19
- end
20
-
21
- class Test::Unit::TestCase
22
- include Compass::Diff
23
- include Compass::TestCaseHelper
24
- include Compass::IoHelper
25
- extend Compass::TestCaseHelper::ClassMethods
26
- end
@@ -1,200 +0,0 @@
1
- require 'test_helper'
2
- require 'archetype'
3
-
4
- class SassExtensionsTest < Test::Unit::TestCase
5
- setup do
6
- Compass.reset_configuration!
7
- Compass.configuration.testing = true
8
- end
9
-
10
- ## VERSION
11
- # test that archetype-version() is working correctly
12
- def test_version
13
- version_pattern = /\d+(\.\d+)*(\.[x|\*])?/
14
- assert_equal Archetype::VERSION.match(version_pattern)[0], evaluate("archetype-version()")
15
- assert_equal Compass::VERSION.match(version_pattern)[0], evaluate("archetype-version(compass)")
16
- assert_equal Sass::VERSION.match(version_pattern)[0], evaluate("archetype-version(sass)")
17
- assert_equal "true", evaluate("archetype-version('Compass >= 0.12')")
18
- assert_equal "false", evaluate("archetype-version('Sass >= 99.0.0')")
19
- assert_equal "true", evaluate("archetype-version('Sass gt 3.0')")
20
- assert_equal "true", evaluate("archetype-version(Archetype ne 99)")
21
- end
22
-
23
-
24
- ## ENVIRONMENT
25
- # test that archetype-env() is working correctly
26
- def test_env
27
- reset
28
- assert_equal "development", evaluate("archetype-env()")
29
- Compass.configuration.environment = :production
30
- assert_equal "production", evaluate("archetype-env()")
31
- Compass.configuration.environment = :staging
32
- assert_equal "staging", evaluate("archetype-env()")
33
- reset
34
- end
35
-
36
-
37
- ## LISTS
38
- # list-replace
39
- def test_list_replace
40
- # TODO
41
- end
42
-
43
- # list-remove
44
- def test_list_remove
45
- # TODO
46
- end
47
-
48
- # list-insert
49
- def test_list_insert
50
- # TODO
51
- end
52
-
53
- # list-add
54
- def test_list_add
55
- assert_equal "2 3 4", evaluate("list-add(1 2 3, 1)")
56
- assert_equal "5 6 7", evaluate("list-add(1 2 3, 4)")
57
- assert_equal "5 7 9", evaluate("list-add(1 2 3, 4 5 6)")
58
- end
59
-
60
- # list-subtract
61
- def test_list_subtract
62
- assert_equal "0 1 2", evaluate("list-subtract(1 2 3, 1)")
63
- assert_equal "1 2 3", evaluate("list-subtract(5 6 7, 4)")
64
- assert_equal "1 2 3", evaluate("list-subtract(5 7 9, 4 5 6)")
65
- end
66
-
67
- # list-multiply
68
- def test_list_multiply
69
- assert_equal "2 4 6", evaluate("list-multiply(1 2 3, 2)")
70
- assert_equal "20 24 28", evaluate("list-multiply(5 6 7, 4)")
71
- assert_equal "20 35 54", evaluate("list-multiply(5 7 9, 4 5 6)")
72
- end
73
-
74
- # list-divide
75
- def test_list_divide
76
- assert_equal "2/2 4/2 6/2", evaluate("list-divide(2 4 6, 2)")
77
- assert_equal "20/4 24/4 28/4", evaluate("list-divide(20 24 28, 4)")
78
- assert_equal "20/4 35/5 54/6", evaluate("list-divide(20 35 54, 4 5 6)")
79
- end
80
-
81
- # list-mod
82
- def test_list_mod
83
- assert_equal "1 0 1", evaluate("list-mod(1 2 3, 2)")
84
- assert_equal "0 1 2", evaluate("list-mod(4 5 6, 4)")
85
- assert_equal "3 2 1", evaluate("list-mod(15 17 19, 4 5 6)")
86
- end
87
-
88
- # index2
89
- def test_index2
90
- assert_equal "1", evaluate("index2(a b c, a)")
91
- assert_equal "4", evaluate("index2(a b c f, d e f)")
92
- assert_equal "false", evaluate("index2(a b c, d)")
93
- assert_equal "false", evaluate("index2(a b c, d e f)")
94
- end
95
-
96
- # nth-cyclic
97
- def test_nth_cyclic
98
- assert_equal "a", evaluate("nth-cyclic(a b c, 1)")
99
- assert_equal "b", evaluate("nth-cyclic(a b c, 2)")
100
- assert_equal "b", evaluate("nth-cyclic(a b c, 5)")
101
- assert_equal "c", evaluate("nth-cyclic(a b c, 24)")
102
- end
103
-
104
- # associative
105
- def test_associative
106
- # TODO
107
- end
108
-
109
- # associative-merge
110
- def test_list_associative_merge
111
- # TODO
112
- end
113
-
114
-
115
- ## LOCALE
116
- # locale
117
- def test_locale
118
- reset
119
- assert_equal "en_US", evaluate("locale()")
120
- Compass.configuration.locale = "ja_JP"
121
- assert_equal "ja_JP", evaluate("locale()")
122
- reset
123
- end
124
-
125
- # lang
126
- def test_lang
127
- reset
128
- assert_equal "true", evaluate("lang(en_US)")
129
- assert_equal "true", evaluate("lang(fr_FR en_US)")
130
- assert_equal "false", evaluate("lang(fr_FR)")
131
- Compass.configuration.locale = "ja_JP"
132
- assert_equal "false", evaluate("lang(en_US)")
133
- assert_equal "true", evaluate("lang(ja_JP)")
134
- assert_equal "true", evaluate("lang(CJK)")
135
- assert_equal "true", evaluate("lang(CJK en_US)")
136
- reset
137
- end
138
-
139
-
140
- ## NUMBERS
141
- def test_strip_units
142
- assert_equal "12", evaluate("strip-units(12px)")
143
- assert_equal "0.5", evaluate("strip-units(0.5em)")
144
- assert_equal "20", evaluate("strip-units('20rem')")
145
- assert_equal "0", evaluate("strip-units(10 somethings)") # this is a failure, so returns 0
146
- end
147
-
148
-
149
- ## STYLEGUIDE
150
- # styleguide-add-component
151
- def test_styleguide_add_component
152
- # TODO - this is a more complex test
153
- end
154
-
155
- # styleguide-extend-component
156
- def test_styleguide_extend_component
157
- # TODO - this is a more complex test
158
- end
159
-
160
- # styleguide
161
- def test_styleguide
162
- # TODO - this is a more complex test
163
- end
164
-
165
- # styleguide-diff
166
- def test_styleguide_diff
167
- # TODO - this is a more complex test
168
- end
169
-
170
-
171
- ## UI
172
- # test generating unique tokens
173
- def test_unique
174
- assert_equal ".archetype-uid-RANDOM_UID", evaluate("unique(class)")
175
- assert_equal ".archetype-uid-RANDOM_UID", evaluate("unique(class)")
176
- assert_equal "\#archetype-uid-RANDOM_UID", evaluate("unique(id)")
177
- assert_equal "my-prefix-archetype-uid-RANDOM_UID", evaluate("unique(my-prefix-)")
178
- assert_equal ".testing-archetype-uid-RANDOM_UID", evaluate("unique('.testing-')")
179
- end
180
-
181
- # test pseudo content escaping and formatting for innerHTML
182
- def test_ie_pseudo_content
183
- assert_equal "this is a test", evaluate("-ie-pseudo-content(this is a test)")
184
- assert_equal "this is &gt; awesome", evaluate("-ie-pseudo-content('this is > awesome')")
185
- assert_equal "tests &amp; more tests", evaluate("-ie-pseudo-content('tests & more tests')")
186
- assert_equal "testing unicode &\#x2079;", evaluate("-ie-pseudo-content('testing unicode \\2079')")
187
- assert_equal "a character &\#x2079; mid-sentence", evaluate("-ie-pseudo-content('a character \\2079 mid-sentence')")
188
- assert_equal "&\#x2079;", evaluate("-ie-pseudo-content('\\2079')")
189
- end
190
-
191
- protected
192
- def evaluate(value)
193
- Sass::Script::Parser.parse(value, 0, 0).perform(Sass::Environment.new).to_s
194
- end
195
-
196
- def reset
197
- Compass.reset_configuration!
198
- Compass.configuration.testing = true
199
- end
200
- end