compass 0.8.16

Sign up to get free protection for your applications and to get access to all the features.
Files changed (275) hide show
  1. data/CHANGELOG.markdown +551 -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 +178 -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 +64 -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/lib/vendor/fssm.rb +41 -0
  230. data/lib/vendor/fssm/backends/fsevents.rb +37 -0
  231. data/lib/vendor/fssm/backends/polling.rb +26 -0
  232. data/lib/vendor/fssm/cache.rb +193 -0
  233. data/lib/vendor/fssm/ext.rb +37 -0
  234. data/lib/vendor/fssm/fsevents.rb +129 -0
  235. data/lib/vendor/fssm/monitor.rb +25 -0
  236. data/lib/vendor/fssm/path.rb +91 -0
  237. data/lib/vendor/fssm/state.rb +54 -0
  238. data/lib/vendor/fssm/support.rb +22 -0
  239. data/lib/vendor/fssm/tree.rb +176 -0
  240. data/test/command_line_helper.rb +102 -0
  241. data/test/command_line_test.rb +66 -0
  242. data/test/compass_test.rb +141 -0
  243. data/test/configuration_test.rb +118 -0
  244. data/test/fixtures/stylesheets/blueprint/config.rb +9 -0
  245. data/test/fixtures/stylesheets/blueprint/css/typography.css +158 -0
  246. data/test/fixtures/stylesheets/blueprint/images/grid.png +0 -0
  247. data/test/fixtures/stylesheets/blueprint/sass/ie.sass +3 -0
  248. data/test/fixtures/stylesheets/blueprint/sass/print.sass +3 -0
  249. data/test/fixtures/stylesheets/blueprint/sass/screen.sass +17 -0
  250. data/test/fixtures/stylesheets/blueprint/sass/typography.sass +3 -0
  251. data/test/fixtures/stylesheets/compass/config.rb +9 -0
  252. data/test/fixtures/stylesheets/compass/css/layout.css +13 -0
  253. data/test/fixtures/stylesheets/compass/css/print.css +18 -0
  254. data/test/fixtures/stylesheets/compass/css/reset.css +60 -0
  255. data/test/fixtures/stylesheets/compass/css/utilities.css +17 -0
  256. data/test/fixtures/stylesheets/compass/sass/layout.sass +3 -0
  257. data/test/fixtures/stylesheets/compass/sass/print.sass +5 -0
  258. data/test/fixtures/stylesheets/compass/sass/reset.sass +10 -0
  259. data/test/fixtures/stylesheets/compass/sass/utilities.sass +6 -0
  260. data/test/fixtures/stylesheets/image_urls/config.rb +17 -0
  261. data/test/fixtures/stylesheets/image_urls/css/screen.css +3 -0
  262. data/test/fixtures/stylesheets/image_urls/images/grid.png +0 -0
  263. data/test/fixtures/stylesheets/image_urls/sass/screen.sass +6 -0
  264. data/test/fixtures/stylesheets/yui/config.rb +9 -0
  265. data/test/fixtures/stylesheets/yui/css/mixins.css +13 -0
  266. data/test/fixtures/stylesheets/yui/sass/base.sass +3 -0
  267. data/test/fixtures/stylesheets/yui/sass/fonts.sass +3 -0
  268. data/test/fixtures/stylesheets/yui/sass/grids.sass +3 -0
  269. data/test/fixtures/stylesheets/yui/sass/mixins.sass +16 -0
  270. data/test/rails_integration_test.rb +83 -0
  271. data/test/sass_extensions_test.rb +31 -0
  272. data/test/test_case_helper.rb +13 -0
  273. data/test/test_helper.rb +21 -0
  274. data/test/test_rails_helper.rb +20 -0
  275. metadata +372 -0
@@ -0,0 +1,33 @@
1
+ require 'fileutils'
2
+ require File.join(File.dirname(__FILE__), 'base')
3
+ require File.join(File.dirname(__FILE__), 'update_project')
4
+
5
+ module Compass
6
+ module Commands
7
+ class StampPattern < ProjectBase
8
+
9
+ include InstallerCommand
10
+
11
+ def initialize(working_path, options)
12
+ super(working_path, options)
13
+ end
14
+
15
+ # all commands must implement perform
16
+ def perform
17
+ installer.init
18
+ installer.run(:skip_finalization => true)
19
+ UpdateProject.new(working_path, options).perform if installer.compilation_required?
20
+ installer.finalize(:create => is_project_creation?)
21
+ end
22
+
23
+ def is_project_creation?
24
+ false
25
+ end
26
+
27
+ def template_directory(pattern)
28
+ File.join(framework.templates_directory, pattern)
29
+ end
30
+
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,34 @@
1
+ require File.join(File.dirname(__FILE__), 'project_base')
2
+ require File.join(Compass.lib_directory, 'compass', 'compiler')
3
+
4
+ module Compass
5
+ module Commands
6
+ class UpdateProject < ProjectBase
7
+
8
+ def initialize(working_path, options)
9
+ super
10
+ assert_project_directory_exists!
11
+ end
12
+
13
+ def perform
14
+ compiler = new_compiler_instance
15
+ if compiler.sass_files.empty?
16
+ message = "Nothing to compile. If you're trying to start a new project, you have left off the directory argument.\n"
17
+ message << "Run \"compass -h\" to get help."
18
+ raise Compass::Error, message
19
+ else
20
+ compiler.run
21
+ end
22
+ end
23
+
24
+ def new_compiler_instance(additional_options = {})
25
+ Compass::Compiler.new(working_path,
26
+ projectize(Compass.configuration.sass_dir),
27
+ projectize(Compass.configuration.css_dir),
28
+ Compass.sass_engine_options.merge(:quiet => options[:quiet],
29
+ :force => options[:force]).merge(additional_options))
30
+ end
31
+
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,21 @@
1
+ require File.join(File.dirname(__FILE__), 'project_base')
2
+ require File.join(File.dirname(__FILE__), 'update_project')
3
+
4
+ module Compass
5
+ module Commands
6
+ class ValidateProject < ProjectBase
7
+
8
+ def initialize(working_path, options)
9
+ super
10
+ assert_project_directory_exists!
11
+ end
12
+
13
+ def perform
14
+ require File.join(File.dirname(__FILE__), '..', 'validator')
15
+ UpdateProject.new(working_path, options).perform
16
+ Validator.new(project_css_subdirectory).validate()
17
+ end
18
+
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,64 @@
1
+ require 'fileutils'
2
+ require 'pathname'
3
+ require File.join(File.dirname(__FILE__), 'base')
4
+ require File.join(File.dirname(__FILE__), 'update_project')
5
+
6
+ module Compass
7
+ module Commands
8
+ class WatchProject < UpdateProject
9
+
10
+ attr_accessor :last_update_time, :last_sass_files
11
+
12
+ def perform
13
+ Signal.trap("INT") do
14
+ puts ""
15
+ exit 0
16
+ end
17
+
18
+ recompile
19
+
20
+ puts ">>> Compass is watching for changes. Press Ctrl-C to Stop."
21
+
22
+ require File.join(Compass.lib_directory, 'vendor', 'fssm')
23
+
24
+ FSSM.monitor do |monitor|
25
+ Compass.configuration.sass_load_paths.each do |load_path|
26
+ monitor.path load_path do |path|
27
+ path.glob '**/*.sass'
28
+
29
+ path.update &method(:recompile)
30
+ path.delete {|base, relative| remove_obsolete_css(base,relative); recompile(base, relative)}
31
+ path.create &method(:recompile)
32
+ end
33
+ end
34
+
35
+ end
36
+
37
+ end
38
+
39
+ def remove_obsolete_css(base = nil, relative = nil)
40
+ compiler = new_compiler_instance(:quiet => true)
41
+ sass_files = compiler.sass_files
42
+ deleted_sass_files = (last_sass_files || []) - sass_files
43
+ deleted_sass_files.each do |deleted_sass_file|
44
+ css_file = compiler.corresponding_css_file(deleted_sass_file)
45
+ remove(css_file) if File.exists?(css_file)
46
+ end
47
+ self.last_sass_files = sass_files
48
+ end
49
+
50
+ def recompile(base = nil, relative = nil)
51
+ compiler = new_compiler_instance(:quiet => true)
52
+ if file = compiler.out_of_date?
53
+ begin
54
+ puts ">>> Change detected to: #{file}"
55
+ compiler.run
56
+ rescue StandardError => e
57
+ ::Compass::Exec.report_error(e, options)
58
+ end
59
+ end
60
+ end
61
+
62
+ end
63
+ end
64
+ end
@@ -0,0 +1,28 @@
1
+ require File.join(File.dirname(__FILE__), 'project_base')
2
+
3
+ module Compass
4
+ module Commands
5
+ class WriteConfiguration < ProjectBase
6
+
7
+ include InstallerCommand
8
+
9
+ def initialize(working_path, options)
10
+ super
11
+ assert_project_directory_exists!
12
+ end
13
+
14
+ def perform
15
+ installer.write_configuration_files(options[:configuration_file])
16
+ end
17
+
18
+ def installer_args
19
+ [nil, project_directory, options]
20
+ end
21
+
22
+ def explicit_config_file_must_be_readable?
23
+ false
24
+ end
25
+
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,54 @@
1
+ module Compass
2
+ class Compiler
3
+
4
+ include Actions
5
+
6
+ attr_accessor :working_path, :from, :to, :options
7
+
8
+ def initialize(working_path, from, to, options)
9
+ self.working_path = working_path
10
+ self.from, self.to = from, to
11
+ self.logger = options.delete(:logger)
12
+ self.options = options
13
+ self.options[:cache_location] ||= File.join(from, ".sass-cache")
14
+ end
15
+
16
+ def sass_files
17
+ @sass_files || Dir.glob(separate("#{from}/**/[^_]*.sass"))
18
+ end
19
+
20
+ def stylesheet_name(sass_file)
21
+ sass_file[("#{from}/".length)..-6]
22
+ end
23
+
24
+ def css_files
25
+ @css_files ||= sass_files.map{|sass_file| corresponding_css_file(sass_file)}
26
+ end
27
+
28
+ def corresponding_css_file(sass_file)
29
+ "#{to}/#{stylesheet_name(sass_file)}.css"
30
+ end
31
+
32
+ def target_directories
33
+ css_files.map{|css_file| File.dirname(css_file)}.uniq.sort.sort_by{|d| d.length }
34
+ end
35
+
36
+ def out_of_date?
37
+ Compass.configure_sass_plugin! unless Compass.sass_plugin_configured?
38
+ sass_files.zip(css_files).each do |sass_filename, css_filename|
39
+ return sass_filename if Sass::Plugin.exact_stylesheet_needs_update?(css_filename, sass_filename)
40
+ end
41
+ false
42
+ end
43
+
44
+ def run
45
+ Compass.configure_sass_plugin! unless Compass.sass_plugin_configured?
46
+ target_directories.each do |dir|
47
+ directory dir
48
+ end
49
+ sass_files.zip(css_files).each do |sass_filename, css_filename|
50
+ compile sass_filename, css_filename, options
51
+ end
52
+ end
53
+ end
54
+ end
@@ -0,0 +1,324 @@
1
+ require 'singleton'
2
+
3
+ module Compass
4
+ class Configuration
5
+ include Singleton
6
+
7
+ ATTRIBUTES = [
8
+ :project_type,
9
+ :project_path,
10
+ :http_path,
11
+ :css_dir,
12
+ :sass_dir,
13
+ :images_dir,
14
+ :javascripts_dir,
15
+ :output_style,
16
+ :environment,
17
+ :relative_assets,
18
+ :http_images_path,
19
+ :http_stylesheets_path,
20
+ :http_javascripts_path,
21
+ :additional_import_paths,
22
+ :sass_options
23
+ ]
24
+
25
+ attr_accessor *ATTRIBUTES
26
+
27
+ attr_accessor :required_libraries
28
+
29
+ def initialize
30
+ self.required_libraries = []
31
+ end
32
+
33
+ # parses a manifest file which is a ruby script
34
+ # evaluated in a Manifest instance context
35
+ def parse(config_file)
36
+ open(config_file) do |f|
37
+ parse_string(f.read, config_file)
38
+ end
39
+ end
40
+
41
+ def parse_string(contents, filename)
42
+ bind = binding
43
+ eval(contents, bind, filename)
44
+ ATTRIBUTES.each do |prop|
45
+ value = eval(prop.to_s, bind) rescue nil
46
+ self.send("#{prop}=", value) if value
47
+ end
48
+ if @added_import_paths
49
+ self.additional_import_paths ||= []
50
+ self.additional_import_paths += @added_import_paths
51
+ end
52
+ issue_deprecation_warnings
53
+ end
54
+
55
+ def set_all(options)
56
+ ATTRIBUTES.each do |a|
57
+ self.send("#{a}=", options[a]) if options.has_key?(a)
58
+ end
59
+ end
60
+
61
+ def set_maybe(options)
62
+ ATTRIBUTES.each do |a|
63
+ self.send("#{a}=", options[a]) if options[a]
64
+ end
65
+ end
66
+
67
+ def default_all(options)
68
+ ATTRIBUTES.each do |a|
69
+ set_default_unless_set(a, options[a])
70
+ end
71
+ end
72
+
73
+ def set_default_unless_set(attribute, value)
74
+ self.send("#{attribute}=", value) unless self.send(attribute)
75
+ end
76
+
77
+ def set_defaults!
78
+ ATTRIBUTES.each do |a|
79
+ set_default_unless_set(a, default_for(a))
80
+ end
81
+ end
82
+
83
+ def default_for(attribute)
84
+ method = "default_#{attribute}".to_sym
85
+ self.send(method) if respond_to?(method)
86
+ end
87
+
88
+ def default_sass_dir
89
+ "src"
90
+ end
91
+
92
+ def default_css_dir
93
+ "stylesheets"
94
+ end
95
+
96
+ def default_images_dir
97
+ "images"
98
+ end
99
+
100
+ def default_http_path
101
+ "/"
102
+ end
103
+
104
+ def comment_for_http_path
105
+ "# Set this to the root of your project when deployed:\n"
106
+ end
107
+
108
+ def relative_assets?
109
+ # the http_images_path is deprecated, but here for backwards compatibility.
110
+ relative_assets || http_images_path == :relative
111
+ end
112
+
113
+ def comment_for_relative_assets
114
+ unless relative_assets
115
+ %q{# To enable relative paths to assets via compass helper functions. Uncomment:
116
+ # relative_assets = true
117
+ }
118
+ else
119
+ ""
120
+ end
121
+ end
122
+
123
+ def default_output_style
124
+ if environment == :development
125
+ :expanded
126
+ else
127
+ :compact
128
+ end
129
+ end
130
+
131
+ def default_line_comments
132
+ environment == :development
133
+ end
134
+
135
+ def sass_path
136
+ if project_path && sass_dir
137
+ File.join(project_path, sass_dir)
138
+ end
139
+ end
140
+
141
+ def css_path
142
+ if project_path && css_dir
143
+ File.join(project_path, css_dir)
144
+ end
145
+ end
146
+
147
+ def root_relative(path)
148
+ hp = http_path || default_http_path
149
+ hp = hp[0..-2] if hp[-1..-1] == "/"
150
+ "#{hp}/#{path}"
151
+ end
152
+
153
+ def add_import_path(*paths)
154
+ # The @added_import_paths variable works around an issue where
155
+ # the additional_import_paths gets overwritten during parse
156
+ @added_import_paths ||= []
157
+ @added_import_paths += paths
158
+ self.additional_import_paths ||= []
159
+ self.additional_import_paths += paths
160
+ end
161
+
162
+ # When called with a block, defines the asset host url to be used.
163
+ # The block must return a string that starts with a protocol (E.g. http).
164
+ # The block will be passed the root-relative url of the asset.
165
+ # When called without a block, returns the block that was previously set.
166
+ def asset_host(&block)
167
+ if block_given?
168
+ @asset_host = block
169
+ else
170
+ @asset_host
171
+ end
172
+ end
173
+
174
+ # When called with a block, defines the cache buster strategy to be used.
175
+ # The block must return nil or a string that can be appended to a url as a query parameter.
176
+ # The returned string must not include the starting '?'.
177
+ # The block will be passed the root-relative url of the asset.
178
+ # If the block accepts two arguments, it will also be passed a File object
179
+ # that points to the asset on disk -- which may or may not exist.
180
+ # When called without a block, returns the block that was previously set.
181
+ def asset_cache_buster(&block)
182
+ if block_given?
183
+ @asset_cache_buster = block
184
+ else
185
+ @asset_cache_buster
186
+ end
187
+ end
188
+
189
+
190
+ def serialize
191
+ if asset_cache_buster
192
+ raise Compass::Error, "Cannot serialize a configuration with asset_cache_buster set."
193
+ end
194
+ if asset_host
195
+ raise Compass::Error, "Cannot serialize a configuration with asset_host set."
196
+ end
197
+ contents = ""
198
+ required_libraries.each do |lib|
199
+ contents << %Q{require '#{lib}'\n}
200
+ end
201
+ contents << "# Require any additional compass plugins here.\n"
202
+ contents << "\n" if required_libraries.any?
203
+ ATTRIBUTES.each do |prop|
204
+ value = send(prop)
205
+ if respond_to?("comment_for_#{prop}")
206
+ contents << send("comment_for_#{prop}")
207
+ end
208
+ if block_given? && (to_emit = yield(prop, value))
209
+ contents << to_emit
210
+ else
211
+ contents << Configuration.serialize_property(prop, value) unless value.nil?
212
+ end
213
+ end
214
+ contents
215
+ end
216
+
217
+ def self.serialize_property(prop, value)
218
+ %Q(#{prop} = #{value.inspect}\n)
219
+ end
220
+
221
+ def to_compiler_arguments(additional_options)
222
+ [project_path, sass_path, css_path, to_sass_engine_options.merge(additional_options)]
223
+ end
224
+
225
+ def to_sass_plugin_options
226
+ locations = {}
227
+ locations[sass_path] = css_path if sass_path && css_path
228
+ Compass::Frameworks::ALL.each do |framework|
229
+ locations[framework.stylesheets_directory] = css_path || css_dir || "."
230
+ end
231
+ resolve_additional_import_paths.each do |additional_path|
232
+ locations[additional_path] = File.join(css_path || css_dir || ".", File.basename(additional_path))
233
+ end
234
+ plugin_opts = {:template_location => locations}
235
+ plugin_opts[:style] = output_style if output_style
236
+ plugin_opts[:line_comments] = default_line_comments if environment
237
+ plugin_opts.merge!(sass_options || {})
238
+ plugin_opts
239
+ end
240
+
241
+ def resolve_additional_import_paths
242
+ (additional_import_paths || []).map do |path|
243
+ if project_path && !absolute_path?(path)
244
+ File.join(project_path, path)
245
+ else
246
+ path
247
+ end
248
+ end
249
+ end
250
+
251
+ def to_sass_engine_options
252
+ engine_opts = {:load_paths => sass_load_paths}
253
+ engine_opts[:style] = output_style if output_style
254
+ engine_opts[:line_comments] = default_line_comments if environment
255
+ engine_opts.merge!(sass_options || {})
256
+ end
257
+
258
+ def sass_load_paths
259
+ load_paths = []
260
+ load_paths << sass_path if sass_path
261
+ Compass::Frameworks::ALL.each do |framework|
262
+ load_paths << framework.stylesheets_directory if File.exists?(framework.stylesheets_directory)
263
+ end
264
+ load_paths += resolve_additional_import_paths
265
+ load_paths
266
+ end
267
+
268
+ # Support for testing.
269
+ def reset!
270
+ ATTRIBUTES.each do |attr|
271
+ send("#{attr}=", nil)
272
+ end
273
+ @asset_cache_buster = nil
274
+ @asset_host = nil
275
+ @added_import_paths = nil
276
+ self.required_libraries = []
277
+ end
278
+
279
+ def issue_deprecation_warnings
280
+ if http_images_path == :relative
281
+ puts "DEPRECATION WARNING: Please set relative_assets = true to enable relative paths."
282
+ end
283
+ end
284
+
285
+ def require(lib)
286
+ required_libraries << lib
287
+ super
288
+ end
289
+
290
+ def absolute_path?(path)
291
+ # This is only going to work on unix, gonna need a better implementation.
292
+ path.index(File::SEPARATOR) == 0
293
+ end
294
+ end
295
+
296
+ module ConfigHelpers
297
+ def configuration
298
+ if block_given?
299
+ yield Configuration.instance
300
+ end
301
+ Configuration.instance
302
+ end
303
+
304
+ def sass_plugin_configuration
305
+ configuration.to_sass_plugin_options
306
+ end
307
+
308
+ def configure_sass_plugin!
309
+ @sass_plugin_configured = true
310
+ Sass::Plugin.options.merge!(sass_plugin_configuration)
311
+ end
312
+
313
+ def sass_plugin_configured?
314
+ @sass_plugin_configured
315
+ end
316
+
317
+ def sass_engine_options
318
+ configuration.to_sass_engine_options
319
+ end
320
+ end
321
+
322
+ extend ConfigHelpers
323
+
324
+ end