alphasights-compass 0.8.12

Sign up to get free protection for your applications and to get access to all the features.
Files changed (264) hide show
  1. data/CHANGELOG.markdown +528 -0
  2. data/LICENSE.markdown +29 -0
  3. data/README.markdown +44 -0
  4. data/REVISION +1 -0
  5. data/Rakefile +127 -0
  6. data/VERSION.yml +4 -0
  7. data/bin/compass +8 -0
  8. data/deps.rip +1 -0
  9. data/examples/README.markdown +4 -0
  10. data/examples/blueprint_default/config.rb +7 -0
  11. data/examples/blueprint_default/images/grid.png +0 -0
  12. data/examples/blueprint_default/index.html.haml +85 -0
  13. data/examples/blueprint_default/parts/elements.html.haml +282 -0
  14. data/examples/blueprint_default/parts/forms.html.haml +190 -0
  15. data/examples/blueprint_default/parts/grid.html.haml +274 -0
  16. data/examples/blueprint_default/parts/test-small.jpg +0 -0
  17. data/examples/blueprint_default/parts/test.jpg +0 -0
  18. data/examples/blueprint_default/parts/valid.png +0 -0
  19. data/examples/blueprint_default/src/ie.sass +3 -0
  20. data/examples/blueprint_default/src/images/grid.png +0 -0
  21. data/examples/blueprint_default/src/print.sass +3 -0
  22. data/examples/blueprint_default/src/screen.sass +8 -0
  23. data/examples/blueprint_plugins/config.rb +8 -0
  24. data/examples/blueprint_plugins/images/buttons/cross.png +0 -0
  25. data/examples/blueprint_plugins/images/buttons/key.png +0 -0
  26. data/examples/blueprint_plugins/images/buttons/tick.png +0 -0
  27. data/examples/blueprint_plugins/images/grid.png +0 -0
  28. data/examples/blueprint_plugins/images/link_icons/doc.png +0 -0
  29. data/examples/blueprint_plugins/images/link_icons/email.png +0 -0
  30. data/examples/blueprint_plugins/images/link_icons/external.png +0 -0
  31. data/examples/blueprint_plugins/images/link_icons/feed.png +0 -0
  32. data/examples/blueprint_plugins/images/link_icons/im.png +0 -0
  33. data/examples/blueprint_plugins/images/link_icons/pdf.png +0 -0
  34. data/examples/blueprint_plugins/images/link_icons/visited.png +0 -0
  35. data/examples/blueprint_plugins/images/link_icons/xls.png +0 -0
  36. data/examples/blueprint_plugins/images/test-small.jpg +0 -0
  37. data/examples/blueprint_plugins/images/test.jpg +0 -0
  38. data/examples/blueprint_plugins/images/valid.png +0 -0
  39. data/examples/blueprint_plugins/index.html.haml +96 -0
  40. data/examples/blueprint_plugins/plugins/buttons.html.haml +67 -0
  41. data/examples/blueprint_plugins/plugins/fancy_type.html.haml +100 -0
  42. data/examples/blueprint_plugins/plugins/link_icons.html.haml +61 -0
  43. data/examples/blueprint_plugins/plugins/rtl.html.haml +100 -0
  44. data/examples/blueprint_plugins/src/buttons.sass +49 -0
  45. data/examples/blueprint_plugins/src/ie.sass +3 -0
  46. data/examples/blueprint_plugins/src/images/grid.png +0 -0
  47. data/examples/blueprint_plugins/src/link_icons.sass +13 -0
  48. data/examples/blueprint_plugins/src/print.sass +3 -0
  49. data/examples/blueprint_plugins/src/rtl_screen.sass +13 -0
  50. data/examples/blueprint_plugins/src/screen.sass +11 -0
  51. data/examples/blueprint_scoped/images/grid.png +0 -0
  52. data/examples/blueprint_scoped/src/ie.sass +3 -0
  53. data/examples/blueprint_scoped/src/print.sass +3 -0
  54. data/examples/blueprint_scoped/src/screen.sass +4 -0
  55. data/examples/blueprint_scoped_form/images/grid.png +0 -0
  56. data/examples/blueprint_scoped_form/src/ie.sass +3 -0
  57. data/examples/blueprint_scoped_form/src/print.sass +3 -0
  58. data/examples/blueprint_scoped_form/src/screen.sass +10 -0
  59. data/examples/blueprint_semantic/config.rb +7 -0
  60. data/examples/blueprint_semantic/images/grid.png +0 -0
  61. data/examples/blueprint_semantic/index.html.haml +86 -0
  62. data/examples/blueprint_semantic/parts/fancy_type.html.haml +100 -0
  63. data/examples/blueprint_semantic/parts/liquid.html.haml +100 -0
  64. data/examples/blueprint_semantic/parts/test-small.jpg +0 -0
  65. data/examples/blueprint_semantic/parts/test.jpg +0 -0
  66. data/examples/blueprint_semantic/parts/valid.png +0 -0
  67. data/examples/blueprint_semantic/src/ie.sass +3 -0
  68. data/examples/blueprint_semantic/src/images/grid.png +0 -0
  69. data/examples/blueprint_semantic/src/liquid.sass +70 -0
  70. data/examples/blueprint_semantic/src/print.sass +3 -0
  71. data/examples/blueprint_semantic/src/screen.sass +71 -0
  72. data/examples/compass/compass.html.haml +39 -0
  73. data/examples/compass/config.rb +7 -0
  74. data/examples/compass/images/blue_arrow.gif +0 -0
  75. data/examples/compass/src/compass.sass +47 -0
  76. data/examples/compass/src/images/blue_arrow.gif +0 -0
  77. data/examples/compass/src/sticky_footer.sass +11 -0
  78. data/examples/compass/src/utilities.sass +108 -0
  79. data/examples/compass/sticky_footer.html.haml +14 -0
  80. data/examples/compass/utilities.html.haml +189 -0
  81. data/examples/logo/logo.html.haml +40 -0
  82. data/examples/logo/src/ie.sass +6 -0
  83. data/examples/logo/src/print.sass +6 -0
  84. data/examples/logo/src/screen.sass +29 -0
  85. data/examples/yui/divisions.html.haml +179 -0
  86. data/examples/yui/index.html.haml +19 -0
  87. data/examples/yui/src/screen.sass +13 -0
  88. data/examples/yui/sub_divisions.html.haml +169 -0
  89. data/examples/yui/templates.html.haml +54 -0
  90. data/examples/yui/test.jpg +0 -0
  91. data/examples/yui/typography.html.haml +132 -0
  92. data/frameworks/blueprint.rb +2 -0
  93. data/frameworks/blueprint/stylesheets/_blueprint.sass +3 -0
  94. data/frameworks/blueprint/stylesheets/blueprint/_ie.sass +93 -0
  95. data/frameworks/blueprint/stylesheets/blueprint/_print.sass +83 -0
  96. data/frameworks/blueprint/stylesheets/blueprint/_reset.sass +3 -0
  97. data/frameworks/blueprint/stylesheets/blueprint/_screen.sass +15 -0
  98. data/frameworks/blueprint/stylesheets/blueprint/modules/_buttons.sass +84 -0
  99. data/frameworks/blueprint/stylesheets/blueprint/modules/_colors.sass +33 -0
  100. data/frameworks/blueprint/stylesheets/blueprint/modules/_debug.sass +9 -0
  101. data/frameworks/blueprint/stylesheets/blueprint/modules/_fancy_type.sass +82 -0
  102. data/frameworks/blueprint/stylesheets/blueprint/modules/_form.sass +55 -0
  103. data/frameworks/blueprint/stylesheets/blueprint/modules/_grid.sass +168 -0
  104. data/frameworks/blueprint/stylesheets/blueprint/modules/_interaction.sass +58 -0
  105. data/frameworks/blueprint/stylesheets/blueprint/modules/_link_icons.sass +44 -0
  106. data/frameworks/blueprint/stylesheets/blueprint/modules/_liquid.sass +141 -0
  107. data/frameworks/blueprint/stylesheets/blueprint/modules/_reset.sass +56 -0
  108. data/frameworks/blueprint/stylesheets/blueprint/modules/_rtl.sass +104 -0
  109. data/frameworks/blueprint/stylesheets/blueprint/modules/_scaffolding.sass +47 -0
  110. data/frameworks/blueprint/stylesheets/blueprint/modules/_typography.sass +155 -0
  111. data/frameworks/blueprint/stylesheets/blueprint/modules/_utilities.sass +37 -0
  112. data/frameworks/blueprint/templates/buttons/buttons.sass +49 -0
  113. data/frameworks/blueprint/templates/buttons/buttons/cross.png +0 -0
  114. data/frameworks/blueprint/templates/buttons/buttons/key.png +0 -0
  115. data/frameworks/blueprint/templates/buttons/buttons/tick.png +0 -0
  116. data/frameworks/blueprint/templates/buttons/manifest.rb +5 -0
  117. data/frameworks/blueprint/templates/link_icons/link_icons.sass +13 -0
  118. data/frameworks/blueprint/templates/link_icons/link_icons/doc.png +0 -0
  119. data/frameworks/blueprint/templates/link_icons/link_icons/email.png +0 -0
  120. data/frameworks/blueprint/templates/link_icons/link_icons/external.png +0 -0
  121. data/frameworks/blueprint/templates/link_icons/link_icons/feed.png +0 -0
  122. data/frameworks/blueprint/templates/link_icons/link_icons/im.png +0 -0
  123. data/frameworks/blueprint/templates/link_icons/link_icons/pdf.png +0 -0
  124. data/frameworks/blueprint/templates/link_icons/link_icons/visited.png +0 -0
  125. data/frameworks/blueprint/templates/link_icons/link_icons/xls.png +0 -0
  126. data/frameworks/blueprint/templates/link_icons/manifest.rb +10 -0
  127. data/frameworks/blueprint/templates/project/grid.png +0 -0
  128. data/frameworks/blueprint/templates/project/ie.sass +15 -0
  129. data/frameworks/blueprint/templates/project/manifest.rb +6 -0
  130. data/frameworks/blueprint/templates/project/partials/_base.sass +11 -0
  131. data/frameworks/blueprint/templates/project/print.sass +3 -0
  132. data/frameworks/blueprint/templates/project/screen.sass +40 -0
  133. data/frameworks/compass.rb +2 -0
  134. data/frameworks/compass/stylesheets/_compass.sass +1 -0
  135. data/frameworks/compass/stylesheets/compass/_layout.sass +1 -0
  136. data/frameworks/compass/stylesheets/compass/_misc.sass +24 -0
  137. data/frameworks/compass/stylesheets/compass/_reset.sass +3 -0
  138. data/frameworks/compass/stylesheets/compass/_utilities.sass +6 -0
  139. data/frameworks/compass/stylesheets/compass/layout/_sticky_footer.sass +17 -0
  140. data/frameworks/compass/stylesheets/compass/utilities/_general.sass +6 -0
  141. data/frameworks/compass/stylesheets/compass/utilities/_links.sass +3 -0
  142. data/frameworks/compass/stylesheets/compass/utilities/_lists.sass +3 -0
  143. data/frameworks/compass/stylesheets/compass/utilities/_print.sass +24 -0
  144. data/frameworks/compass/stylesheets/compass/utilities/_sprites.sass +1 -0
  145. data/frameworks/compass/stylesheets/compass/utilities/_tables.sass +3 -0
  146. data/frameworks/compass/stylesheets/compass/utilities/_text.sass +2 -0
  147. data/frameworks/compass/stylesheets/compass/utilities/general/_clearfix.sass +24 -0
  148. data/frameworks/compass/stylesheets/compass/utilities/general/_float.sass +17 -0
  149. data/frameworks/compass/stylesheets/compass/utilities/general/_hacks.sass +6 -0
  150. data/frameworks/compass/stylesheets/compass/utilities/general/_inline_block.sass +6 -0
  151. data/frameworks/compass/stylesheets/compass/utilities/general/_reset.sass +134 -0
  152. data/frameworks/compass/stylesheets/compass/utilities/general/_tabs.sass +0 -0
  153. data/frameworks/compass/stylesheets/compass/utilities/general/_tag_cloud.sass +19 -0
  154. data/frameworks/compass/stylesheets/compass/utilities/links/_hover_link.sass +5 -0
  155. data/frameworks/compass/stylesheets/compass/utilities/links/_link_colors.sass +24 -0
  156. data/frameworks/compass/stylesheets/compass/utilities/links/_unstyled_link.sass +5 -0
  157. data/frameworks/compass/stylesheets/compass/utilities/lists/_bullets.sass +21 -0
  158. data/frameworks/compass/stylesheets/compass/utilities/lists/_horizontal_list.sass +52 -0
  159. data/frameworks/compass/stylesheets/compass/utilities/lists/_inline_list.sass +29 -0
  160. data/frameworks/compass/stylesheets/compass/utilities/sprites/_sprite_img.sass +12 -0
  161. data/frameworks/compass/stylesheets/compass/utilities/tables/_alternating_rows_and_columns.sass +20 -0
  162. data/frameworks/compass/stylesheets/compass/utilities/tables/_borders.sass +27 -0
  163. data/frameworks/compass/stylesheets/compass/utilities/tables/_scaffolding.sass +9 -0
  164. data/frameworks/compass/stylesheets/compass/utilities/text/_ellipsis.sass +13 -0
  165. data/frameworks/compass/stylesheets/compass/utilities/text/_nowrap.sass +3 -0
  166. data/frameworks/compass/stylesheets/compass/utilities/text/_replacement.sass +17 -0
  167. data/frameworks/compass/templates/ellipsis/ellipsis.sass +6 -0
  168. data/frameworks/compass/templates/ellipsis/manifest.rb +2 -0
  169. data/frameworks/compass/templates/ellipsis/xml/ellipsis.xml +14 -0
  170. data/frameworks/compass/templates/project/ie.sass +6 -0
  171. data/frameworks/compass/templates/project/manifest.rb +3 -0
  172. data/frameworks/compass/templates/project/print.sass +6 -0
  173. data/frameworks/compass/templates/project/screen.sass +13 -0
  174. data/frameworks/yui.rb +2 -0
  175. data/frameworks/yui/stylesheets/_yui.sass +7 -0
  176. data/frameworks/yui/stylesheets/yui/modules/_base.sass +60 -0
  177. data/frameworks/yui/stylesheets/yui/modules/_fonts.sass +38 -0
  178. data/frameworks/yui/stylesheets/yui/modules/_grids.sass +341 -0
  179. data/frameworks/yui/stylesheets/yui/modules/_reset.sass +61 -0
  180. data/frameworks/yui/templates/project/manifest.rb +1 -0
  181. data/frameworks/yui/templates/project/screen.sass +4 -0
  182. data/lib/compass.rb +23 -0
  183. data/lib/compass/actions.rb +110 -0
  184. data/lib/compass/app_integration.rb +5 -0
  185. data/lib/compass/app_integration/merb.rb +43 -0
  186. data/lib/compass/app_integration/rails.rb +12 -0
  187. data/lib/compass/app_integration/rails/action_controller.rb +15 -0
  188. data/lib/compass/app_integration/rails/sass_plugin.rb +5 -0
  189. data/lib/compass/app_integration/rails/templates/compass-install-rails.rb +80 -0
  190. data/lib/compass/app_integration/rails/urls.rb +14 -0
  191. data/lib/compass/commands/base.rb +33 -0
  192. data/lib/compass/commands/create_project.rb +19 -0
  193. data/lib/compass/commands/generate_grid_background.rb +24 -0
  194. data/lib/compass/commands/installer_command.rb +31 -0
  195. data/lib/compass/commands/list_frameworks.rb +16 -0
  196. data/lib/compass/commands/print_version.rb +23 -0
  197. data/lib/compass/commands/project_base.rb +112 -0
  198. data/lib/compass/commands/stamp_pattern.rb +33 -0
  199. data/lib/compass/commands/update_project.rb +34 -0
  200. data/lib/compass/commands/validate_project.rb +21 -0
  201. data/lib/compass/commands/watch_project.rb +50 -0
  202. data/lib/compass/commands/write_configuration.rb +28 -0
  203. data/lib/compass/compiler.rb +54 -0
  204. data/lib/compass/configuration.rb +324 -0
  205. data/lib/compass/core_ext.rb +14 -0
  206. data/lib/compass/dependencies.rb +10 -0
  207. data/lib/compass/errors.rb +7 -0
  208. data/lib/compass/exec.rb +251 -0
  209. data/lib/compass/frameworks.rb +29 -0
  210. data/lib/compass/grid_builder.rb +72 -0
  211. data/lib/compass/installers.rb +5 -0
  212. data/lib/compass/installers/base.rb +158 -0
  213. data/lib/compass/installers/manifest.rb +58 -0
  214. data/lib/compass/installers/rails.rb +135 -0
  215. data/lib/compass/installers/stand_alone.rb +60 -0
  216. data/lib/compass/logger.rb +42 -0
  217. data/lib/compass/sass_extensions.rb +5 -0
  218. data/lib/compass/sass_extensions/functions.rb +19 -0
  219. data/lib/compass/sass_extensions/functions/display.rb +22 -0
  220. data/lib/compass/sass_extensions/functions/enumerate.rb +6 -0
  221. data/lib/compass/sass_extensions/functions/inline_image.rb +35 -0
  222. data/lib/compass/sass_extensions/functions/selectors.rb +39 -0
  223. data/lib/compass/sass_extensions/functions/urls.rb +105 -0
  224. data/lib/compass/sass_extensions/monkey_patches.rb +3 -0
  225. data/lib/compass/sass_extensions/monkey_patches/stylesheet_updating.rb +23 -0
  226. data/lib/compass/test_case.rb +38 -0
  227. data/lib/compass/validator.rb +10 -0
  228. data/lib/compass/version.rb +57 -0
  229. data/test/command_line_helper.rb +102 -0
  230. data/test/command_line_test.rb +66 -0
  231. data/test/compass_test.rb +141 -0
  232. data/test/configuration_test.rb +118 -0
  233. data/test/fixtures/stylesheets/blueprint/config.rb +9 -0
  234. data/test/fixtures/stylesheets/blueprint/css/typography.css +158 -0
  235. data/test/fixtures/stylesheets/blueprint/images/grid.png +0 -0
  236. data/test/fixtures/stylesheets/blueprint/sass/ie.sass +3 -0
  237. data/test/fixtures/stylesheets/blueprint/sass/print.sass +3 -0
  238. data/test/fixtures/stylesheets/blueprint/sass/screen.sass +17 -0
  239. data/test/fixtures/stylesheets/blueprint/sass/typography.sass +3 -0
  240. data/test/fixtures/stylesheets/compass/config.rb +9 -0
  241. data/test/fixtures/stylesheets/compass/css/layout.css +13 -0
  242. data/test/fixtures/stylesheets/compass/css/print.css +18 -0
  243. data/test/fixtures/stylesheets/compass/css/reset.css +60 -0
  244. data/test/fixtures/stylesheets/compass/css/utilities.css +17 -0
  245. data/test/fixtures/stylesheets/compass/sass/layout.sass +3 -0
  246. data/test/fixtures/stylesheets/compass/sass/print.sass +5 -0
  247. data/test/fixtures/stylesheets/compass/sass/reset.sass +10 -0
  248. data/test/fixtures/stylesheets/compass/sass/utilities.sass +6 -0
  249. data/test/fixtures/stylesheets/image_urls/config.rb +17 -0
  250. data/test/fixtures/stylesheets/image_urls/css/screen.css +3 -0
  251. data/test/fixtures/stylesheets/image_urls/images/grid.png +0 -0
  252. data/test/fixtures/stylesheets/image_urls/sass/screen.sass +6 -0
  253. data/test/fixtures/stylesheets/yui/config.rb +9 -0
  254. data/test/fixtures/stylesheets/yui/css/mixins.css +13 -0
  255. data/test/fixtures/stylesheets/yui/sass/base.sass +3 -0
  256. data/test/fixtures/stylesheets/yui/sass/fonts.sass +3 -0
  257. data/test/fixtures/stylesheets/yui/sass/grids.sass +3 -0
  258. data/test/fixtures/stylesheets/yui/sass/mixins.sass +16 -0
  259. data/test/rails_integration_test.rb +83 -0
  260. data/test/sass_extensions_test.rb +31 -0
  261. data/test/test_case_helper.rb +13 -0
  262. data/test/test_helper.rb +21 -0
  263. data/test/test_rails_helper.rb +20 -0
  264. metadata +359 -0
@@ -0,0 +1,3 @@
1
+ ['stylesheet_updating'].each do |patch|
2
+ require File.join(File.dirname(__FILE__), 'monkey_patches', patch)
3
+ end
@@ -0,0 +1,23 @@
1
+ require 'sass/plugin'
2
+
3
+ # XXX: We can remove this monkeypatch once Sass 2.2 is released.
4
+ module Sass::Plugin
5
+ class << self
6
+ unless method_defined?(:exact_stylesheet_needs_update?)
7
+ def stylesheet_needs_update?(name, template_path, css_path)
8
+ css_file = css_filename(name, css_path)
9
+ template_file = template_filename(name, template_path)
10
+ exact_stylesheet_needs_update?(css_file, template_file)
11
+ end
12
+ def exact_stylesheet_needs_update?(css_file, template_file)
13
+ if !File.exists?(css_file)
14
+ return true
15
+ else
16
+ css_mtime = File.mtime(css_file)
17
+ File.mtime(template_file) > css_mtime ||
18
+ dependencies(template_file).any?(&dependency_updated?(css_mtime))
19
+ end
20
+ end
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,38 @@
1
+ module Compass
2
+ # Write your unit test like this if you want to make sure all your stylesheets compile.
3
+ #
4
+ # require 'compass/test_case'
5
+ # class StylesheetsTest < Compass::TestCase
6
+ # def test_stylesheets
7
+ # my_sass_files.each do |sass_file|
8
+ # assert_compiles(sass_file) do |result|
9
+ # assert_not_blank result
10
+ # end
11
+ # end
12
+ # end
13
+ # protected
14
+ # def my_sass_files
15
+ # Dir.glob(File.expand_path(File.join(File.dirname(__FILE__), "../..", "app/stylesheets/**/[^_]*.sass")))
16
+ # end
17
+ # end
18
+ class TestCase < (defined?(ActiveSupport::TestCase) ? ActiveSupport::TestCase : Test::Unit::TestCase)
19
+
20
+ def setup
21
+ super
22
+ @last_compile = nil
23
+ end
24
+
25
+ def compile(stylesheet)
26
+ input = open(stylesheet)
27
+ template = input.read()
28
+ input.close()
29
+ @last_compile = ::Sass::Engine.new(template, ::Sass::Plugin.engine_options(:filename => stylesheet)).render
30
+ yield @last_compile if block_given?
31
+ end
32
+
33
+ def assert_compiles(stylesheet, &block)
34
+ compile(stylesheet, &block)
35
+ end
36
+
37
+ end
38
+ end
@@ -0,0 +1,10 @@
1
+ begin
2
+ require 'rubygems'
3
+ require 'compass-validator'
4
+ rescue LoadError
5
+ puts %Q{The Compass CSS Validator could not be loaded. Please install it:
6
+
7
+ sudo gem install chriseppstein-compass-validator --source http://gems.github.com/
8
+ }
9
+ exit(1)
10
+ end
@@ -0,0 +1,57 @@
1
+ module Compass
2
+ module Version
3
+ # Returns a hash representing the version.
4
+ # The :major, :minor, and :teeny keys have their respective numbers.
5
+ # The :string key contains a human-readable string representation of the version.
6
+ # The :rev key will have the current revision hash.
7
+ #
8
+ # This method swiped from Haml and then modified, some credit goes to Nathan Weizenbaum
9
+ attr_writer :version
10
+ def version
11
+ return @version if defined?(@version)
12
+
13
+ read_version_file
14
+
15
+ if r = revision
16
+ @version[:rev] = r
17
+ @version[:string] << " [#{r[0...7]}]"
18
+ end
19
+
20
+ @version
21
+ end
22
+
23
+ protected
24
+
25
+ def scope(file) # :nodoc:
26
+ File.join(File.dirname(__FILE__), '..', '..', file)
27
+ end
28
+
29
+ def read_version_file
30
+ require 'yaml'
31
+ @version = YAML::load(File.read(scope('VERSION.yml')))
32
+ @version[:string] = "#{@version[:major]}.#{@version[:minor]}.#{@version[:patch]}"
33
+ @version[:teeny] = @version[:patch]
34
+ end
35
+
36
+ def revision
37
+ revision_from_git || revision_from_file
38
+ end
39
+
40
+ def revision_from_file
41
+ if File.exists?(scope('REVISION'))
42
+ rev = File.read(scope('REVISION')).strip
43
+ rev if rev =~ /[a-f0-9]+/
44
+ end
45
+ end
46
+
47
+ def revision_from_git
48
+ if File.exists?(scope('.git/HEAD'))
49
+ rev = File.read(scope('.git/HEAD')).strip
50
+ if rev =~ /^ref: (.*)$/
51
+ rev = File.read(scope(".git/#{$1}")).strip
52
+ end
53
+ end
54
+ end
55
+
56
+ end
57
+ end
@@ -0,0 +1,102 @@
1
+ module Compass::CommandLineHelper
2
+ def compass(*arguments)
3
+ options = arguments.last.is_a?(Hash) ? arguments.pop : {}
4
+ options[:wait] = 0.25
5
+ if block_given?
6
+ responder = Responder.new
7
+ yield responder
8
+ IO.popen("-", "w+") do |io|
9
+ if io
10
+ #parent process
11
+ output = ""
12
+ eof_at = nil
13
+ while !eof_at || (Time.now - eof_at < options[:wait])
14
+ if io.eof?
15
+ eof_at ||= Time.now
16
+ sleep 0.1
17
+ else
18
+ eof_at = nil
19
+ timeout(1) do
20
+ output << io.readpartial(1024)
21
+ end
22
+ prompt = output.split("\n").last
23
+ if response = responder.response_for(prompt)
24
+ io.puts response
25
+ end
26
+ end
27
+ end
28
+ responder.assert_required_responses!
29
+ @last_result = output
30
+ else
31
+ #child process
32
+ execute *arguments
33
+ end
34
+ end
35
+ else
36
+ @last_result = capture_output do
37
+ execute *arguments
38
+ end
39
+ end
40
+ rescue Timeout::Error
41
+ fail "Read from child process timed out"
42
+ end
43
+
44
+ class Responder
45
+ Response = Struct.new(:prompt, :text, :required, :responded)
46
+ def initialize
47
+ @responses = []
48
+ end
49
+ def respond_to(prompt, options = {})
50
+ @responses << Response.new(prompt, options[:with], options[:required])
51
+ end
52
+ def response_for(prompt)
53
+ response = @responses.detect{|r| r.prompt == prompt}
54
+ if response
55
+ response.responded = true
56
+ response.text
57
+ end
58
+ end
59
+ def assert_required_responses!
60
+ @responses.each do |response|
61
+ if response.required && !response.responded
62
+ raise "Prompt not encountered: \"#{response.prompt}\""
63
+ end
64
+ end
65
+ end
66
+ end
67
+
68
+ def assert_action_performed(action, path)
69
+ actions_found = []
70
+ @last_result.split("\n").each do |line|
71
+ line = line.split
72
+ return if line.first == action.to_s && line.last == path
73
+ actions_found << line.first if line.last == path
74
+ end
75
+ message = "Action #{action.inspect} was not performed on: #{path}."
76
+ message += "The following actions were performed: #{actions_found.join(", ")}" if actions_found.any?
77
+ puts @last_result
78
+ fail message
79
+ end
80
+
81
+ def within_tmp_directory(dir = "tmp")
82
+ d = absolutize(dir)
83
+ FileUtils.mkdir_p(d)
84
+ Dir.chdir(d) do
85
+ yield
86
+ end
87
+ ensure
88
+ FileUtils.rm_rf(d)
89
+ end
90
+
91
+ def capture_output
92
+ real_stdout, $stdout = $stdout, StringIO.new
93
+ yield
94
+ $stdout.string
95
+ ensure
96
+ $stdout = real_stdout
97
+ end
98
+
99
+ def execute(*arguments)
100
+ Compass::Exec::Compass.new(arguments).run!
101
+ end
102
+ end
@@ -0,0 +1,66 @@
1
+ require File.dirname(__FILE__)+'/test_helper'
2
+ require 'fileutils'
3
+ require 'compass'
4
+ require 'compass/exec'
5
+ require 'timeout'
6
+
7
+ class CommandLineTest < Test::Unit::TestCase
8
+ include Compass::TestCaseHelper
9
+ include Compass::CommandLineHelper
10
+
11
+ def teardown
12
+ Compass.configuration.reset!
13
+ end
14
+
15
+ def test_print_version
16
+ compass "-vq"
17
+ assert_match /\d+\.\d+\.\d+( [0-9a-f]+)?/, @last_result
18
+ end
19
+
20
+ def test_list_frameworks
21
+ compass "--list-frameworks"
22
+ assert_equal(%w(blueprint compass yui), @last_result.split.sort)
23
+ end
24
+
25
+ def test_basic_install
26
+ within_tmp_directory do
27
+ compass "basic"
28
+ assert File.exists?("basic/src/screen.sass")
29
+ assert File.exists?("basic/stylesheets/screen.css")
30
+ assert_action_performed :directory, "basic/"
31
+ assert_action_performed :create, "basic/src/screen.sass"
32
+ assert_action_performed :compile, "basic/src/screen.sass"
33
+ assert_action_performed :create, "basic/stylesheets/screen.css"
34
+ end
35
+ end
36
+
37
+ def test_framework_installs
38
+ Compass::Frameworks::ALL.each do |framework|
39
+ within_tmp_directory do
40
+ compass *%W(--framework #{framework.name} #{framework.name}_project)
41
+ assert File.exists?("#{framework.name}_project/src/screen.sass")
42
+ assert File.exists?("#{framework.name}_project/stylesheets/screen.css")
43
+ assert_action_performed :directory, "#{framework.name}_project/"
44
+ assert_action_performed :create, "#{framework.name}_project/src/screen.sass"
45
+ assert_action_performed :compile, "#{framework.name}_project/src/screen.sass"
46
+ assert_action_performed :create, "#{framework.name}_project/stylesheets/screen.css"
47
+ end
48
+ end
49
+ end
50
+
51
+ def test_basic_update
52
+ within_tmp_directory do
53
+ compass "basic"
54
+ Dir.chdir "basic" do
55
+ # basic update with timestamp caching
56
+ compass
57
+ assert_action_performed :unchanged, "src/screen.sass"
58
+ # basic update with force option set
59
+ compass "--force"
60
+ assert_action_performed :compile, "src/screen.sass"
61
+ assert_action_performed :identical, "stylesheets/screen.css"
62
+ end
63
+ end
64
+ end
65
+
66
+ end
@@ -0,0 +1,141 @@
1
+ require File.dirname(__FILE__)+'/test_helper'
2
+ require 'fileutils'
3
+ require 'compass'
4
+
5
+ class CompassTest < Test::Unit::TestCase
6
+ include Compass::TestCaseHelper
7
+ def setup
8
+ Compass.configuration.reset!
9
+ end
10
+
11
+ def teardown
12
+ teardown_fixtures :blueprint, :yui, :empty, :compass, :image_urls
13
+ end
14
+
15
+ def teardown_fixtures(*project_names)
16
+ project_names.each do |project_name|
17
+ FileUtils.rm_rf tempfile_path(project_name)
18
+ end
19
+ end
20
+
21
+ def test_empty_project
22
+ # With no sass files, we should have no css files.
23
+ within_project(:empty) do |proj|
24
+ return unless proj.css_path && File.exists?(proj.css_path)
25
+ Dir.new(proj.css_path).each do |f|
26
+ fail "This file should not have been generated: #{f}" unless f == "." || f == ".."
27
+ end
28
+ end
29
+ end
30
+
31
+ def test_blueprint
32
+ within_project(:blueprint) do |proj|
33
+ each_css_file(proj.css_path) do |css_file|
34
+ assert_no_errors css_file, :blueprint
35
+ end
36
+ assert_renders_correctly :typography
37
+ end
38
+ end
39
+
40
+ def test_yui
41
+ within_project('yui') do |proj|
42
+ each_css_file(proj.css_path) do |css_file|
43
+ assert_no_errors css_file, 'yui'
44
+ end
45
+ assert_renders_correctly :mixins
46
+ end
47
+ end
48
+
49
+ def test_compass
50
+ within_project('compass') do |proj|
51
+ each_css_file(proj.css_path) do |css_file|
52
+ assert_no_errors css_file, 'compass'
53
+ end
54
+ assert_renders_correctly :reset, :layout, :utilities
55
+ end
56
+ end
57
+
58
+ def test_image_urls
59
+ within_project('image_urls') do |proj|
60
+ each_css_file(proj.css_path) do |css_file|
61
+ assert_no_errors css_file, 'image_urls'
62
+ end
63
+ assert_renders_correctly :screen
64
+ end
65
+ end
66
+
67
+ private
68
+ def assert_no_errors(css_file, project_name)
69
+ file = css_file[(tempfile_path(project_name).size+1)..-1]
70
+ msg = "Syntax Error found in #{file}. Results saved into #{save_path(project_name)}/#{file}"
71
+ assert_equal 0, open(css_file).readlines.grep(/Sass::SyntaxError/).size, msg
72
+ end
73
+
74
+ def assert_renders_correctly(*arguments)
75
+ options = arguments.last.is_a?(Hash) ? arguments.pop : {}
76
+ for name in arguments
77
+ actual_result_file = "#{tempfile_path(@current_project)}/#{name}.css"
78
+ expected_result_file = "#{result_path(@current_project)}/#{name}.css"
79
+ actual_lines = File.read(actual_result_file).split("\n")
80
+ expected_lines = File.read(expected_result_file).split("\n")
81
+ expected_lines.zip(actual_lines).each_with_index do |pair, line|
82
+ message = "template: #{name}\nline: #{line + 1}"
83
+ assert_equal(pair.first, pair.last, message)
84
+ end
85
+ if expected_lines.size < actual_lines.size
86
+ assert(false, "#{actual_lines.size - expected_lines.size} Trailing lines found in #{actual_result_file}.css: #{actual_lines[expected_lines.size..-1].join('\n')}")
87
+ end
88
+ end
89
+ end
90
+
91
+ def within_project(project_name)
92
+ @current_project = project_name
93
+ Compass.configuration.parse(configuration_file(project_name)) if File.exists?(configuration_file(project_name))
94
+ Compass.configuration.project_path = project_path(project_name)
95
+ args = Compass.configuration.to_compiler_arguments(:logger => Compass::NullLogger.new)
96
+ if Compass.configuration.sass_path && File.exists?(Compass.configuration.sass_path)
97
+ compiler = Compass::Compiler.new *args
98
+ compiler.run
99
+ end
100
+ yield Compass.configuration
101
+ rescue
102
+ save_output(project_name)
103
+ raise
104
+ end
105
+
106
+ def each_css_file(dir)
107
+ Dir.glob("#{dir}/**/*.css").each do |css_file|
108
+ yield css_file
109
+ end
110
+ end
111
+
112
+ def save_output(dir)
113
+ FileUtils.rm_rf(save_path(dir))
114
+ FileUtils.cp_r(tempfile_path(dir), save_path(dir)) if File.exists?(tempfile_path(dir))
115
+ end
116
+
117
+ def project_path(project_name)
118
+ absolutize("fixtures/stylesheets/#{project_name}")
119
+ end
120
+
121
+ def configuration_file(project_name)
122
+ File.join(project_path(project_name), "config.rb")
123
+ end
124
+
125
+ def tempfile_path(project_name)
126
+ File.join(project_path(project_name), "tmp")
127
+ end
128
+
129
+ def template_path(project_name)
130
+ File.join(project_path(project_name), "sass")
131
+ end
132
+
133
+ def result_path(project_name)
134
+ File.join(project_path(project_name), "css")
135
+ end
136
+
137
+ def save_path(project_name)
138
+ File.join(project_path(project_name), "saved")
139
+ end
140
+
141
+ end