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,14 @@
1
+ class String
2
+ unless method_defined?(:blank?)
3
+ # see if string has any content
4
+ def blank?; self.length.zero?; end
5
+ end
6
+ end
7
+
8
+ class NilClass
9
+ unless method_defined?(:blank?)
10
+ def blank?
11
+ true
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,10 @@
1
+ unless defined?(Sass)
2
+ require 'rubygems'
3
+ begin
4
+ gem 'haml-edge', '>= 2.3.0'
5
+ $stderr.puts "Loading haml-edge gem."
6
+ rescue Exception
7
+ #pass
8
+ end
9
+ require 'sass'
10
+ end
@@ -0,0 +1,7 @@
1
+ module Compass
2
+ class Error < StandardError
3
+ end
4
+
5
+ class FilesystemConflict < Error
6
+ end
7
+ end
@@ -0,0 +1,251 @@
1
+ require File.join(Compass.lib_directory, 'compass', 'dependencies')
2
+ require 'optparse'
3
+ require File.join(Compass.lib_directory, 'compass', 'logger')
4
+ require File.join(Compass.lib_directory, 'compass', 'errors')
5
+ require File.join(Compass.lib_directory, 'compass', 'actions')
6
+
7
+ module Compass
8
+ module Exec
9
+
10
+ def report_error(e, options)
11
+ $stderr.puts "#{e.class} on line #{get_line e} of #{get_file e}: #{e.message}"
12
+ if options[:trace]
13
+ e.backtrace[1..-1].each { |t| $stderr.puts " #{t}" }
14
+ else
15
+ $stderr.puts "Run with --trace to see the full backtrace"
16
+ end
17
+ end
18
+
19
+ def get_file(exception)
20
+ exception.backtrace[0].split(/:/, 2)[0]
21
+ end
22
+
23
+ def get_line(exception)
24
+ exception.backtrace[0].scan(/:(\d+)/)[0]
25
+ end
26
+ module_function :report_error, :get_file, :get_line
27
+
28
+ class Compass
29
+
30
+ attr_accessor :args, :options, :opts
31
+
32
+ def initialize(args)
33
+ self.args = args
34
+ self.options = {}
35
+ parse!
36
+ end
37
+
38
+ def run!
39
+ begin
40
+ perform!
41
+ rescue Exception => e
42
+ raise e if e.is_a? SystemExit
43
+ if e.is_a?(::Compass::Error) || e.is_a?(OptionParser::ParseError)
44
+ $stderr.puts e.message
45
+ else
46
+ ::Compass::Exec.report_error(e, @options)
47
+ end
48
+ return 1
49
+ end
50
+ return 0
51
+ end
52
+
53
+ protected
54
+
55
+ def perform!
56
+ if options[:command]
57
+ do_command(options[:command])
58
+ else
59
+ puts self.opts
60
+ end
61
+ end
62
+
63
+ def parse!
64
+ self.opts = OptionParser.new(&method(:set_opts))
65
+ self.opts.parse!(self.args)
66
+ if self.args.size > 0
67
+ self.options[:project_name] = trim_trailing_separator(self.args.shift)
68
+ end
69
+ self.options[:command] ||= self.options[:project_name] ? :create_project : :update_project
70
+ self.options[:framework] ||= :compass
71
+ self.options[:project_type] ||= :stand_alone
72
+ end
73
+
74
+ def trim_trailing_separator(path)
75
+ path[-1..-1] == File::SEPARATOR ? path[0..-2] : path
76
+ end
77
+
78
+ def set_opts(opts)
79
+ opts.banner = <<END
80
+ Usage: compass [options] [project]
81
+
82
+ Description:
83
+ The compass command line tool will help you create and manage the stylesheets for your project.
84
+
85
+ To get started on a stand-alone project based on blueprint:
86
+
87
+ compass -f blueprint my_compass_project
88
+
89
+ When you change any sass files, you must recompile your project using --update or --watch.
90
+ END
91
+ opts.separator ''
92
+ opts.separator 'Mode Options(only specify one):'
93
+
94
+ opts.on('-i', '--install', :NONE, "Create a new compass project.",
95
+ " The default mode when a project is provided.") do
96
+ self.options[:command] = :create_project
97
+ end
98
+
99
+ opts.on('-u', '--update', :NONE, 'Update the current project.',
100
+ ' This is the default when no project is provided.') do
101
+ self.options[:command] = :update_project
102
+ end
103
+
104
+ opts.on('-w', '--watch', :NONE, 'Monitor the current project for changes and update') do
105
+ self.options[:command] = :watch_project
106
+ self.options[:quiet] = true
107
+ end
108
+
109
+ opts.on('-p', '--pattern PATTERN', 'Stamp out a pattern into the current project.',
110
+ ' Must be used with -f.') do |pattern|
111
+ self.options[:command] = :stamp_pattern
112
+ self.options[:pattern] = pattern
113
+ end
114
+
115
+ opts.on('--write-configuration', "Write the current configuration to the configuration file.") do
116
+ self.options[:command] = :write_configuration
117
+ end
118
+
119
+ opts.on('--list-frameworks', "List compass frameworks available to use.") do
120
+ self.options[:command] = :list_frameworks
121
+ end
122
+
123
+ opts.on('--validate', :NONE, 'Validate your project\'s compiled css. Requires Java.') do
124
+ self.options[:command] = :validate_project
125
+ end
126
+
127
+ opts.on('--grid-img [DIMENSIONS]', 'Generate a background image to test grid alignment.',
128
+ ' Dimension is given as <column_width>+<gutter_width>.',
129
+ ' Defaults to 30+10.') do |dimensions|
130
+ self.options[:grid_dimensions] = dimensions || "30+10"
131
+ unless self.options[:grid_dimensions] =~ /^\d+\+\d+$/
132
+ puts "Please enter your dimensions as <column_width>+<gutter_width>. E.g. 20+5 or 30+10."
133
+ exit
134
+ end
135
+ self.options[:command] = :generate_grid_background
136
+ end
137
+
138
+ opts.separator ''
139
+ opts.separator 'Install/Pattern Options:'
140
+
141
+ opts.on('-f FRAMEWORK', '--framework FRAMEWORK', 'Use the specified framework. Only one may be specified.') do |framework|
142
+ self.options[:framework] = framework
143
+ end
144
+
145
+ opts.on('-n', '--pattern-name NAME', 'The name to use when stamping a pattern.',
146
+ ' Must be used in combination with -p.') do |name|
147
+ self.options[:pattern_name] = name
148
+ end
149
+
150
+ opts.on('--rails', "Sets the project type to a rails project.") do
151
+ self.options[:project_type] = :rails
152
+ end
153
+
154
+ opts.separator ''
155
+ opts.separator 'Configuration Options:'
156
+
157
+ opts.on('-c', '--config CONFIG_FILE', 'Specify the location of the configuration file explicitly.') do |configuration_file|
158
+ self.options[:configuration_file] = configuration_file
159
+ end
160
+
161
+ opts.on('--sass-dir SRC_DIR', "The source directory where you keep your sass stylesheets.") do |sass_dir|
162
+ self.options[:sass_dir] = sass_dir
163
+ end
164
+
165
+ opts.on('--css-dir CSS_DIR', "The target directory where you keep your css stylesheets.") do |css_dir|
166
+ self.options[:css_dir] = css_dir
167
+ end
168
+
169
+ opts.on('--images-dir IMAGES_DIR', "The directory where you keep your images.") do |images_dir|
170
+ self.options[:images_dir] = images_dir
171
+ end
172
+
173
+ opts.on('--javascripts-dir JS_DIR', "The directory where you keep your javascripts.") do |javascripts_dir|
174
+ self.options[:javascripts_dir] = javascripts_dir
175
+ end
176
+
177
+ opts.on('-e ENV', '--environment ENV', [:development, :production], 'Use sensible defaults for your current environment.',
178
+ ' One of: development, production (default)') do |env|
179
+ self.options[:environment] = env
180
+ end
181
+
182
+ opts.on('-s STYLE', '--output-style STYLE', [:nested, :expanded, :compact, :compressed], 'Select a CSS output mode.',
183
+ ' One of: nested, expanded, compact, compressed') do |style|
184
+ self.options[:output_style] = style
185
+ end
186
+
187
+ opts.on('--relative-assets', :NONE, 'Make compass asset helpers generate relative urls to assets.') do
188
+ self.options[:relative_assets] = true
189
+ end
190
+
191
+ opts.separator ''
192
+ opts.separator 'General Options:'
193
+
194
+ opts.on('-r LIBRARY', '--require LIBRARY', "Require the given ruby LIBRARY before running commands.",
195
+ " This is used to access compass plugins without having a",
196
+ " project configuration file.") do |library|
197
+ ::Compass.configuration.require library
198
+ end
199
+
200
+ opts.on('-q', '--quiet', :NONE, 'Quiet mode.') do
201
+ self.options[:quiet] = true
202
+ end
203
+
204
+ opts.on('--dry-run', :NONE, 'Dry Run. Tells you what it plans to do.') do
205
+ self.options[:dry_run] = true
206
+ end
207
+
208
+ opts.on('--trace', :NONE, 'Show a full stacktrace on error') do
209
+ self.options[:trace] = true
210
+ end
211
+
212
+ opts.on('--force', :NONE, 'Force. Allows some failing commands to succeed instead.') do
213
+ self.options[:force] = true
214
+ end
215
+
216
+ opts.on('--imports', :NONE, 'Emit an imports suitable for passing to the sass command-line.',
217
+ ' Example: sass `compass --imports`',
218
+ ' Note: Compass\'s Sass extensions will not be available.') do
219
+ print ::Compass::Frameworks::ALL.map{|f| "-I #{f.stylesheets_directory}"}.join(' ')
220
+ exit
221
+ end
222
+
223
+ opts.on('--install-dir', :NONE, 'Emit the location where compass is installed.') do
224
+ puts ::Compass.base_directory
225
+ exit
226
+ end
227
+
228
+ opts.on_tail("-?", "-h", "--help", "Show this message") do
229
+ puts opts
230
+ exit
231
+ end
232
+
233
+ opts.on_tail("-v", "--version", "Print version") do
234
+ self.options[:command] = :print_version
235
+ end
236
+
237
+ end
238
+
239
+ def do_command(command)
240
+ command_class_name = command.to_s.split(/_/).map{|p| p.capitalize}.join('')
241
+ command_class = eval("::Compass::Commands::#{command_class_name}")
242
+ command_class.new(Dir.getwd, options).execute
243
+ end
244
+
245
+ end
246
+ end
247
+ end
248
+
249
+ Dir.glob(File.join(File.dirname(__FILE__), 'commands', "*.rb")).each do |file|
250
+ require file
251
+ end
@@ -0,0 +1,29 @@
1
+ module Compass
2
+ module Frameworks
3
+ ALL = []
4
+ class Framework
5
+ attr_accessor :name
6
+ attr_accessor :templates_directory, :stylesheets_directory
7
+ def initialize(name, *arguments)
8
+ options = arguments.last.is_a?(Hash) ? arguments.pop : {}
9
+ path = options[:path] || arguments.shift
10
+ @name = name
11
+ @templates_directory = options[:templates_directory] || File.join(path, 'templates')
12
+ @stylesheets_directory = options[:stylesheets_directory] || File.join(path, 'stylesheets')
13
+ end
14
+ end
15
+ def register(name, *arguments)
16
+ ALL << Framework.new(name, *arguments)
17
+ end
18
+ def [](name)
19
+ ALL.detect{|f| f.name.to_s == name.to_s}
20
+ end
21
+ module_function :register, :[]
22
+ end
23
+ end
24
+
25
+ # Import all of the default frameworks.
26
+ default_frameworks_directory = File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'frameworks'))
27
+ Dir.glob(File.join(default_frameworks_directory, "*.rb")).each do |framework|
28
+ require framework
29
+ end
@@ -0,0 +1,72 @@
1
+ # This file came from the Blueprint Project
2
+ begin
3
+ require 'rubygems'
4
+ gem 'rmagick'
5
+ require 'rvg/rvg'
6
+ rescue Exception => e
7
+ end
8
+
9
+ module Compass
10
+ # Uses ImageMagick and RMagick to generate grid.png file
11
+ class GridBuilder
12
+ include Actions
13
+
14
+ begin
15
+ include Magick
16
+ rescue Exception => e
17
+ end
18
+
19
+ attr_reader :column_width, :gutter_width, :output_path, :able_to_generate, :options
20
+
21
+ # ==== Options
22
+ # * <tt>options</tt>
23
+ # * <tt>:column_width</tt> -- Width (in pixels) of current grid column
24
+ # * <tt>:gutter_width</tt> -- Width (in pixels) of current grid gutter
25
+ # * <tt>:output_path</tt> -- Output path of grid.png file
26
+ def initialize(options={})
27
+ @able_to_generate = Magick::Long_version rescue false
28
+ return unless @able_to_generate
29
+ @column_width = options[:column_width]
30
+ @gutter_width = options[:gutter_width]
31
+ @output_path = options[:output_path]
32
+ @options = options
33
+ end
34
+
35
+ def working_path
36
+ options[:working_path]
37
+ end
38
+
39
+ # generates (overwriting if necessary) grid.png image to be tiled in background
40
+ def generate!
41
+ return false unless self.able_to_generate
42
+ total_width = self.column_width + self.gutter_width
43
+ height = 20
44
+ RVG::dpi = 100
45
+
46
+ rvg = RVG.new((total_width.to_f/RVG::dpi).in, (height.to_f/RVG::dpi).in).viewbox(0, 0, total_width, height) do |canvas|
47
+ canvas.background_fill = 'white'
48
+
49
+ canvas.g do |column|
50
+ column.rect(self.column_width, height).styles(:fill => "#e8effb")
51
+ end
52
+
53
+ canvas.g do |baseline|
54
+ baseline.line(0, (height - 1), total_width, (height- 1)).styles(:fill => "#e9e9e9")
55
+ end
56
+ end
57
+
58
+ filename = File.join(self.output_path, "grid.png")
59
+ if File.exists?(filename)
60
+ if options[:force]
61
+ overwrite = true
62
+ else
63
+ msg = "#{filename} already exists. Overwrite with --force."
64
+ raise Compass::FilesystemConflict.new(msg)
65
+ end
66
+ end
67
+ directory self.output_path
68
+ logger.record((overwrite ? :overwrite : :create), basename(filename))
69
+ rvg.draw.write(filename)
70
+ end
71
+ end
72
+ end
@@ -0,0 +1,5 @@
1
+ require File.join(File.dirname(__FILE__), 'installers', 'manifest')
2
+ require File.join(File.dirname(__FILE__), 'installers', 'base')
3
+ require File.join(File.dirname(__FILE__), 'installers', 'stand_alone')
4
+ require File.join(File.dirname(__FILE__), 'installers', 'rails')
5
+
@@ -0,0 +1,158 @@
1
+ module Compass
2
+ module Installers
3
+
4
+ class Base
5
+
6
+ include Actions
7
+
8
+ attr_accessor :template_path, :target_path, :working_path
9
+ attr_accessor :options
10
+ attr_accessor :manifest
11
+
12
+ def initialize(template_path, target_path, options = {})
13
+ @template_path = template_path
14
+ @target_path = target_path
15
+ @working_path = Dir.getwd
16
+ @options = options
17
+ @manifest = Manifest.new(manifest_file) if template_path
18
+ self.logger = options[:logger]
19
+ end
20
+
21
+ def manifest_file
22
+ @manifest_file ||= File.join(template_path, "manifest.rb")
23
+ end
24
+
25
+ [:css_dir, :sass_dir, :images_dir, :javascripts_dir].each do |dir|
26
+ define_method dir do
27
+ Compass.configuration.send(dir)
28
+ end
29
+ end
30
+
31
+ # Initializes the project to work with compass
32
+ def init
33
+ dirs = manifest.map do |entry|
34
+ File.dirname(send("install_location_for_#{entry.type}", entry.to, entry.options))
35
+ end
36
+
37
+ if manifest.has_stylesheet?
38
+ dirs << sass_dir
39
+ dirs << css_dir
40
+ end
41
+
42
+ dirs.uniq.sort.each do |dir|
43
+ directory targetize(dir)
44
+ end
45
+ end
46
+
47
+ # Runs the installer.
48
+ # Every installer must conform to the installation strategy of prepare, install, and then finalize.
49
+ # A default implementation is provided for each step.
50
+ def run(options = {})
51
+ prepare
52
+ install
53
+ finalize unless options[:skip_finalization]
54
+ end
55
+
56
+ # The default prepare method -- it is a no-op.
57
+ # Generally you would create required directories, etc.
58
+ def prepare
59
+ end
60
+
61
+ def configure_option_with_default(opt)
62
+ value = options[opt]
63
+ value ||= begin
64
+ default_method = "default_#{opt}".to_sym
65
+ send(default_method) if respond_to?(default_method)
66
+ end
67
+ send("#{opt}=", value)
68
+ end
69
+
70
+ # The default install method. Calls install_<type> methods in the order specified by the manifest.
71
+ def install
72
+ manifest.each do |entry|
73
+ send("install_#{entry.type}", entry.from, entry.to, entry.options)
74
+ end
75
+ end
76
+
77
+ # The default finalize method -- it is a no-op.
78
+ # This could print out a message or something.
79
+ def finalize
80
+ end
81
+
82
+ def compilation_required?
83
+ false
84
+ end
85
+
86
+ def pattern_name_as_dir
87
+ "#{options[:pattern_name]}/" if options[:pattern_name]
88
+ end
89
+
90
+ def self.installer(type, installer_opts = {}, &locator)
91
+ locator ||= lambda{|to| to}
92
+ loc_method = "install_location_for_#{type}".to_sym
93
+ define_method("simple_#{loc_method}", locator)
94
+ define_method(loc_method) do |to, options|
95
+ if options[:like] && options[:like] != type
96
+ send("install_location_for_#{options[:like]}", to, options)
97
+ else
98
+ send("simple_#{loc_method}", to)
99
+ end
100
+ end
101
+ define_method "install_#{type}" do |from, to, options|
102
+ from = templatize(from)
103
+ to = targetize(send(loc_method, to, options))
104
+ copy from, to, nil, (installer_opts[:binary] || options[:binary])
105
+ end
106
+ end
107
+
108
+ installer :stylesheet do |to|
109
+ "#{sass_dir}/#{pattern_name_as_dir}#{to}"
110
+ end
111
+
112
+ installer :css do |to|
113
+ "#{css_dir}/#{to}"
114
+ end
115
+
116
+ installer :image, :binary => true do |to|
117
+ "#{images_dir}/#{to}"
118
+ end
119
+
120
+ installer :javascript do |to|
121
+ "#{javascripts_dir}/#{to}"
122
+ end
123
+
124
+ installer :file do |to|
125
+ "#{pattern_name_as_dir}#{to}"
126
+ end
127
+
128
+ # returns an absolute path given a path relative to the current installation target.
129
+ # Paths can use unix style "/" and will be corrected for the current platform.
130
+ def targetize(path)
131
+ strip_trailing_separator File.join(target_path, separate(path))
132
+ end
133
+
134
+ # returns an absolute path given a path relative to the current template.
135
+ # Paths can use unix style "/" and will be corrected for the current platform.
136
+ def templatize(path)
137
+ strip_trailing_separator File.join(template_path, separate(path))
138
+ end
139
+
140
+ def stylesheet_links
141
+ html = "<head>\n"
142
+ manifest.each_stylesheet do |stylesheet|
143
+ # Skip partials.
144
+ next if File.basename(stylesheet.from)[0..0] == "_"
145
+ media = if stylesheet.options[:media]
146
+ %Q{ media="#{stylesheet.options[:media]}"}
147
+ end
148
+ ss_line = %Q{ <link href="/stylesheets/#{stylesheet.to.sub(/\.sass$/,'.css')}"#{media} rel="stylesheet" type="text/css" />}
149
+ if stylesheet.options[:condition]
150
+ ss_line = " <!--[if #{stylesheet.options[:condition]}]>\n #{ss_line}\n <![endif]-->"
151
+ end
152
+ html << ss_line + "\n"
153
+ end
154
+ html << "</head>"
155
+ end
156
+ end
157
+ end
158
+ end