arnebrasseur-compass 0.3.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (161) hide show
  1. data/Manifest +160 -0
  2. data/README.markdown +18 -0
  3. data/Rakefile +112 -0
  4. data/VERSION +1 -0
  5. data/bin/compass +8 -0
  6. data/compass.gemspec +37 -0
  7. data/examples/blueprint_default/index.html +73 -0
  8. data/examples/blueprint_default/parts/elements.html +246 -0
  9. data/examples/blueprint_default/parts/forms.html +100 -0
  10. data/examples/blueprint_default/parts/grid.html +206 -0
  11. data/examples/blueprint_default/parts/test-small.jpg +0 -0
  12. data/examples/blueprint_default/parts/test.jpg +0 -0
  13. data/examples/blueprint_default/parts/valid.png +0 -0
  14. data/examples/blueprint_default/stylesheets/ie.sass +3 -0
  15. data/examples/blueprint_default/stylesheets/images/grid.png +0 -0
  16. data/examples/blueprint_default/stylesheets/print.sass +3 -0
  17. data/examples/blueprint_default/stylesheets/screen.sass +8 -0
  18. data/examples/blueprint_plugins/index.html +60 -0
  19. data/examples/blueprint_plugins/parts/fancy_type.html +84 -0
  20. data/examples/blueprint_plugins/parts/test-small.jpg +0 -0
  21. data/examples/blueprint_plugins/parts/test.jpg +0 -0
  22. data/examples/blueprint_plugins/parts/valid.png +0 -0
  23. data/examples/blueprint_plugins/stylesheets/ie.sass +3 -0
  24. data/examples/blueprint_plugins/stylesheets/images/grid.png +0 -0
  25. data/examples/blueprint_plugins/stylesheets/print.sass +3 -0
  26. data/examples/blueprint_plugins/stylesheets/screen.sass +11 -0
  27. data/examples/blueprint_scoped/stylesheets/ie.sass +3 -0
  28. data/examples/blueprint_scoped/stylesheets/print.sass +3 -0
  29. data/examples/blueprint_scoped/stylesheets/screen.sass +4 -0
  30. data/examples/blueprint_scoped_form/stylesheets/ie.sass +3 -0
  31. data/examples/blueprint_scoped_form/stylesheets/print.sass +3 -0
  32. data/examples/blueprint_scoped_form/stylesheets/screen.sass +10 -0
  33. data/examples/blueprint_semantic/index.html +68 -0
  34. data/examples/blueprint_semantic/parts/fancy_type.html +84 -0
  35. data/examples/blueprint_semantic/parts/liquid.html +84 -0
  36. data/examples/blueprint_semantic/parts/test-small.jpg +0 -0
  37. data/examples/blueprint_semantic/parts/test.jpg +0 -0
  38. data/examples/blueprint_semantic/parts/valid.png +0 -0
  39. data/examples/blueprint_semantic/stylesheets/ie.sass +3 -0
  40. data/examples/blueprint_semantic/stylesheets/images/grid.png +0 -0
  41. data/examples/blueprint_semantic/stylesheets/liquid.sass +70 -0
  42. data/examples/blueprint_semantic/stylesheets/print.sass +3 -0
  43. data/examples/blueprint_semantic/stylesheets/screen.sass +69 -0
  44. data/examples/compass/compass.html +19 -0
  45. data/examples/compass/sticky_footer.html.haml +14 -0
  46. data/examples/compass/stylesheets/compass.sass +47 -0
  47. data/examples/compass/stylesheets/images/blue_arrow.gif +0 -0
  48. data/examples/compass/stylesheets/sticky_footer.sass +11 -0
  49. data/examples/compass/stylesheets/utilities.sass +65 -0
  50. data/examples/compass/utilities.html.haml +136 -0
  51. data/examples/yui/divisions.html.haml +179 -0
  52. data/examples/yui/index.html.haml +19 -0
  53. data/examples/yui/stylesheets/screen.sass +13 -0
  54. data/examples/yui/sub_divisions.html.haml +169 -0
  55. data/examples/yui/templates.html.haml +54 -0
  56. data/examples/yui/test.jpg +0 -0
  57. data/examples/yui/typography.html.haml +132 -0
  58. data/frameworks/blueprint/lib/blueprint/constants.rb +17 -0
  59. data/frameworks/blueprint/lib/blueprint/grid_builder.rb +54 -0
  60. data/frameworks/blueprint/stylesheets/_blueprint.sass +3 -0
  61. data/frameworks/blueprint/stylesheets/blueprint/_ie.sass +49 -0
  62. data/frameworks/blueprint/stylesheets/blueprint/_print.sass +82 -0
  63. data/frameworks/blueprint/stylesheets/blueprint/_screen.sass +15 -0
  64. data/frameworks/blueprint/stylesheets/blueprint/modules/_colors.sass +30 -0
  65. data/frameworks/blueprint/stylesheets/blueprint/modules/_debug.sass +9 -0
  66. data/frameworks/blueprint/stylesheets/blueprint/modules/_fancy_type.sass +81 -0
  67. data/frameworks/blueprint/stylesheets/blueprint/modules/_form.sass +43 -0
  68. data/frameworks/blueprint/stylesheets/blueprint/modules/_grid.sass +141 -0
  69. data/frameworks/blueprint/stylesheets/blueprint/modules/_interaction.sass +58 -0
  70. data/frameworks/blueprint/stylesheets/blueprint/modules/_liquid.sass +137 -0
  71. data/frameworks/blueprint/stylesheets/blueprint/modules/_scaffolding.sass +46 -0
  72. data/frameworks/blueprint/stylesheets/blueprint/modules/_typography.sass +153 -0
  73. data/frameworks/blueprint/stylesheets/blueprint/modules/_utilities.sass +37 -0
  74. data/frameworks/blueprint/templates/project/grid.png +0 -0
  75. data/frameworks/blueprint/templates/project/ie.sass +3 -0
  76. data/frameworks/blueprint/templates/project/print.sass +3 -0
  77. data/frameworks/blueprint/templates/project/screen.sass +8 -0
  78. data/frameworks/compass/stylesheets/_compass.sass +1 -0
  79. data/frameworks/compass/stylesheets/compass/_layout.sass +1 -0
  80. data/frameworks/compass/stylesheets/compass/_reset.sass +3 -0
  81. data/frameworks/compass/stylesheets/compass/_utilities.sass +5 -0
  82. data/frameworks/compass/stylesheets/compass/layout/_sticky_footer.sass +17 -0
  83. data/frameworks/compass/stylesheets/compass/utilities/_general.sass +4 -0
  84. data/frameworks/compass/stylesheets/compass/utilities/_links.sass +3 -0
  85. data/frameworks/compass/stylesheets/compass/utilities/_lists.sass +3 -0
  86. data/frameworks/compass/stylesheets/compass/utilities/_print.sass +24 -0
  87. data/frameworks/compass/stylesheets/compass/utilities/_tables.sass +1 -0
  88. data/frameworks/compass/stylesheets/compass/utilities/_text.sass +2 -0
  89. data/frameworks/compass/stylesheets/compass/utilities/general/_clearfix.sass +11 -0
  90. data/frameworks/compass/stylesheets/compass/utilities/general/_inline_block.sass +6 -0
  91. data/frameworks/compass/stylesheets/compass/utilities/general/_reset.sass +58 -0
  92. data/frameworks/compass/stylesheets/compass/utilities/general/_tabs.sass +0 -0
  93. data/frameworks/compass/stylesheets/compass/utilities/general/_tag_cloud.sass +19 -0
  94. data/frameworks/compass/stylesheets/compass/utilities/links/_hover_link.sass +5 -0
  95. data/frameworks/compass/stylesheets/compass/utilities/links/_link_colors.sass +24 -0
  96. data/frameworks/compass/stylesheets/compass/utilities/links/_unstyled_link.sass +5 -0
  97. data/frameworks/compass/stylesheets/compass/utilities/lists/_bullets.sass +21 -0
  98. data/frameworks/compass/stylesheets/compass/utilities/lists/_horizontal_list.sass +20 -0
  99. data/frameworks/compass/stylesheets/compass/utilities/lists/_inline_list.sass +29 -0
  100. data/frameworks/compass/stylesheets/compass/utilities/tables/_alternating_rows_and_columns.sass +25 -0
  101. data/frameworks/compass/stylesheets/compass/utilities/text/_nowrap.sass +3 -0
  102. data/frameworks/compass/stylesheets/compass/utilities/text/_replacement.sass +10 -0
  103. data/frameworks/compass/templates/project/grid.png +0 -0
  104. data/frameworks/compass/templates/project/ie.sass +3 -0
  105. data/frameworks/compass/templates/project/print.sass +4 -0
  106. data/frameworks/compass/templates/project/screen.sass +4 -0
  107. data/frameworks/yui/COPYRIGHT +15 -0
  108. data/frameworks/yui/stylesheets/_yui.sass +7 -0
  109. data/frameworks/yui/stylesheets/yui/modules/_base.sass +60 -0
  110. data/frameworks/yui/stylesheets/yui/modules/_fonts.sass +38 -0
  111. data/frameworks/yui/stylesheets/yui/modules/_grids.sass +341 -0
  112. data/frameworks/yui/templates/project/screen.sass +4 -0
  113. data/lib/compass/commands/base.rb +94 -0
  114. data/lib/compass/commands/create_project.rb +32 -0
  115. data/lib/compass/commands/install_rails.rb +115 -0
  116. data/lib/compass/commands/print_version.rb +23 -0
  117. data/lib/compass/commands/update_project.rb +101 -0
  118. data/lib/compass/commands/watch_project.rb +42 -0
  119. data/lib/compass/core_ext.rb +39 -0
  120. data/lib/compass/exec.rb +164 -0
  121. data/lib/compass/frameworks/blueprint.rb +2 -0
  122. data/lib/compass/frameworks/compass.rb +2 -0
  123. data/lib/compass/frameworks/yui.rb +2 -0
  124. data/lib/compass/frameworks.rb +27 -0
  125. data/lib/compass/merb.rb +43 -0
  126. data/lib/compass/test_case.rb +37 -0
  127. data/lib/compass/validate/COPYRIGHT.html +93 -0
  128. data/lib/compass/validate/JIGSAW_COPYRIGHT +64 -0
  129. data/lib/compass/validate/README.html +83 -0
  130. data/lib/compass/validate/XERCES_COPYING.txt +56 -0
  131. data/lib/compass/validate/css-validator-javadoc.jar +0 -0
  132. data/lib/compass/validate/css-validator.jar +0 -0
  133. data/lib/compass/validate/jigsaw.jar +0 -0
  134. data/lib/compass/validate/xerces.jar +0 -0
  135. data/lib/compass/validate.rb +13 -0
  136. data/lib/compass/validator.rb +59 -0
  137. data/lib/compass/version.rb +48 -0
  138. data/lib/compass.rb +20 -0
  139. data/lib/sass_extensions.rb +13 -0
  140. data/test/compass_test.rb +152 -0
  141. data/test/fixtures/stylesheets/blueprint/css/typography.css +158 -0
  142. data/test/fixtures/stylesheets/blueprint/sass/ie.sass +3 -0
  143. data/test/fixtures/stylesheets/blueprint/sass/print.sass +3 -0
  144. data/test/fixtures/stylesheets/blueprint/sass/screen.sass +17 -0
  145. data/test/fixtures/stylesheets/blueprint/sass/typography.sass +3 -0
  146. data/test/fixtures/stylesheets/compass/css/layout.css +14 -0
  147. data/test/fixtures/stylesheets/compass/css/print.css +19 -0
  148. data/test/fixtures/stylesheets/compass/css/reset.css +69 -0
  149. data/test/fixtures/stylesheets/compass/css/utilities.css +21 -0
  150. data/test/fixtures/stylesheets/compass/sass/layout.sass +3 -0
  151. data/test/fixtures/stylesheets/compass/sass/print.sass +5 -0
  152. data/test/fixtures/stylesheets/compass/sass/reset.sass +1 -0
  153. data/test/fixtures/stylesheets/compass/sass/utilities.sass +5 -0
  154. data/test/fixtures/stylesheets/yui/css/mixins.css +16 -0
  155. data/test/fixtures/stylesheets/yui/sass/base.sass +3 -0
  156. data/test/fixtures/stylesheets/yui/sass/fonts.sass +3 -0
  157. data/test/fixtures/stylesheets/yui/sass/grids.sass +3 -0
  158. data/test/fixtures/stylesheets/yui/sass/mixins.sass +16 -0
  159. data/test/sass_extensions_test.rb +26 -0
  160. data/test/test_helper.rb +37 -0
  161. metadata +264 -0
@@ -0,0 +1,101 @@
1
+ require 'rubygems'
2
+ require 'sass'
3
+ require 'fileutils'
4
+ require 'pathname'
5
+ require File.join(File.dirname(__FILE__), 'base')
6
+
7
+ module Compass
8
+ module Commands
9
+ class UpdateProject < Base
10
+
11
+ Base::ACTIONS << :compile
12
+ Base::ACTIONS << :overwrite
13
+
14
+ attr_accessor :project_directory, :project_name, :options, :project_src_subdirectory, :project_css_subdirectory
15
+
16
+ def initialize(working_directory, options = {})
17
+ super(working_directory, options)
18
+ if options[:project_name]
19
+ options[:project_name] = options[:project_name][0..-2] if options[:project_name][-1..-1] == File::SEPARATOR
20
+ self.project_name = File.basename(options[:project_name])
21
+ if options[:project_name][0] == File::SEPARATOR
22
+ self.project_directory = options[:project_name]
23
+ elsif File.directory?(File.join(working_directory, options[:project_name]))
24
+ self.project_directory = File.expand_path(File.join(working_directory, options[:project_name]))
25
+ else
26
+ if File.exists?(options[:project_name]) or File.exists?(File.join(working_directory, options[:project_name]))
27
+ raise ::Compass::Exec::ExecError.new("#{options[:project_name]} is not a directory.")
28
+ elsif !(options[:force] || options[:dry_run])
29
+ raise ::Compass::Exec::ExecError.new("#{options[:project_name]} does not exist.")
30
+ end
31
+ end
32
+ else
33
+ self.project_name = File.basename(working_directory)
34
+ self.project_directory = working_directory
35
+ end
36
+ end
37
+
38
+ def perform
39
+ Dir.glob(separate("#{project_src_directory}/**/[^_]*.sass")).each do |sass_file|
40
+ stylesheet_name = sass_file[("#{project_src_directory}/".length)..-6]
41
+ compile "#{project_src_subdirectory}/#{stylesheet_name}.sass", "#{project_css_subdirectory}/#{stylesheet_name}.css", options
42
+ end
43
+ end
44
+
45
+ # Compile one Sass file
46
+ def compile(sass_filename, css_filename, options)
47
+ sass_filename = projectize(sass_filename)
48
+ css_filename = projectize(css_filename)
49
+ if !File.directory?(File.dirname(css_filename))
50
+ directory basename(File.dirname(css_filename)), options.merge(:force => true) unless options[:dry_run]
51
+ end
52
+ print_action :compile, basename(sass_filename)
53
+ if File.exists?(css_filename)
54
+ print_action :overwrite, basename(css_filename)
55
+ else
56
+ print_action :create, basename(css_filename)
57
+ end
58
+ unless options[:dry_run]
59
+ engine = ::Sass::Engine.new(open(sass_filename).read,
60
+ :filename => sass_filename,
61
+ :line_comments => options[:environment] == :development,
62
+ :style => output_style,
63
+ :css_filename => css_filename,
64
+ :load_paths => sass_load_paths)
65
+ output = open(css_filename,'w')
66
+ output.write(engine.render)
67
+ output.close
68
+ end
69
+ end
70
+
71
+ def output_style
72
+ @output_style ||= options[:style] || if options[:environment] == :development
73
+ :expanded
74
+ else
75
+ :compact
76
+ end
77
+ end
78
+
79
+ # where to load sass files from
80
+ def sass_load_paths
81
+ @sass_load_paths ||= [project_src_directory] + Compass::Frameworks::ALL.map{|f| f.stylesheets_directory}
82
+ end
83
+
84
+ # The subdirectory where the sass source is kept.
85
+ def project_src_subdirectory
86
+ @project_src_subdirectory ||= options[:src_dir] || "src"
87
+ end
88
+
89
+ # The subdirectory where the css output is kept.
90
+ def project_css_subdirectory
91
+ @project_css_subdirectory ||= options[:css_dir] || "stylesheets"
92
+ end
93
+
94
+ # The directory where the project source files are located.
95
+ def project_src_directory
96
+ @project_src_directory ||= separate("#{project_directory}/#{project_src_subdirectory}")
97
+ end
98
+
99
+ end
100
+ end
101
+ end
@@ -0,0 +1,42 @@
1
+ require 'rubygems'
2
+ require 'sass'
3
+ require 'fileutils'
4
+ require 'pathname'
5
+ require File.join(File.dirname(__FILE__), 'base')
6
+ require File.join(File.dirname(__FILE__), 'update_project')
7
+
8
+ module Compass
9
+ module Commands
10
+ class WatchProject < UpdateProject
11
+ attr_accessor :last_update_time
12
+ def perform
13
+ super
14
+ self.last_update_time = most_recent_update_time
15
+ loop do
16
+ # TODO: Make this efficient by using filesystem monitoring.
17
+ sleep 1
18
+ file, t = should_update?
19
+ if t
20
+ begin
21
+ puts ">>> Change detected to #{file} <<<"
22
+ super
23
+ rescue StandardError => e
24
+ ::Compass::Exec.report_error(e, options)
25
+ end
26
+ self.last_update_time = t
27
+ end
28
+ end
29
+ end
30
+ def most_recent_update_time
31
+ Dir.glob(separate("#{project_src_directory}/**/*.sass")).map {|sass_file| File.stat(sass_file).mtime}.max
32
+ end
33
+ def should_update?
34
+ t = most_recent_update_time
35
+ if t > last_update_time
36
+ file = Dir.glob(separate("#{project_src_directory}/**/*.sass")).detect {|sass_file| File.stat(sass_file).mtime >= t}
37
+ [file, t]
38
+ end
39
+ end
40
+ end
41
+ end
42
+ end
@@ -0,0 +1,39 @@
1
+ class String
2
+ # see if string has any content
3
+ def blank?; self.length.zero?; end
4
+
5
+ # strip space after :, remove newlines, replace multiple spaces with only one space, remove comments
6
+ def strip_space!
7
+ replace self.gsub(/:\s*/, ':').gsub(/\n/, '').gsub(/\s+/, ' ').gsub(/(\/\*).*?(\*\/)/, '')
8
+ end
9
+
10
+ # remove newlines, insert space after comma, replace two spaces with one space after comma
11
+ def strip_selector_space!
12
+ replace self.gsub(/(\n)/, '').gsub(',', ', ').gsub(', ', ', ')
13
+ end
14
+
15
+ # remove leading whitespace, remove end whitespace
16
+ def strip_side_space!
17
+ replace self.gsub(/^\s+/, '').gsub(/\s+$/, $/)
18
+ end
19
+ end
20
+
21
+ class NilClass
22
+ def blank?
23
+ true
24
+ end
25
+ end
26
+
27
+ class File
28
+ # string output from file
29
+ def self.path_to_string(path)
30
+ File.new(path).read
31
+ end
32
+
33
+ # saves a string to a specified file path
34
+ def self.string_to_file(string, path)
35
+ directory = File.dirname(path)
36
+ FileUtils.mkdir_p directory unless File.directory?(directory)
37
+ File.open(path, 'w') { |f| f << string }
38
+ end
39
+ end
@@ -0,0 +1,164 @@
1
+ require 'optparse'
2
+ require 'rubygems'
3
+ require 'haml'
4
+
5
+ module Compass
6
+ module Exec
7
+ class ExecError < StandardError
8
+ end
9
+
10
+
11
+ def report_error(e, options)
12
+ $stderr.puts "#{e.class} on line #{get_line e} of #{get_file e}: #{e.message}"
13
+ if options[:trace]
14
+ e.backtrace[1..-1].each { |t| $stderr.puts " #{t}" }
15
+ else
16
+ $stderr.puts "Run with --trace to see the full backtrace"
17
+ end
18
+ end
19
+
20
+ def get_file(exception)
21
+ exception.backtrace[0].split(/:/, 2)[0]
22
+ end
23
+
24
+ def get_line(exception)
25
+ # SyntaxErrors have weird line reporting
26
+ # when there's trailing whitespace,
27
+ # which there is for Haml documents.
28
+ return exception.message.scan(/:(\d+)/)[0] if exception.is_a?(::Haml::SyntaxError)
29
+ exception.backtrace[0].scan(/:(\d+)/)[0]
30
+ end
31
+ module_function :report_error, :get_file, :get_line
32
+
33
+ class Compass
34
+
35
+ attr_accessor :args, :options, :opts
36
+
37
+ def initialize(args)
38
+ self.args = args
39
+ self.options = {}
40
+ end
41
+
42
+ def run!
43
+ begin
44
+ parse!
45
+ perform!
46
+ rescue Exception => e
47
+ raise e if e.is_a? SystemExit
48
+ if e.is_a?(ExecError) || e.is_a?(OptionParser::ParseError)
49
+ $stderr.puts e.message
50
+ else
51
+ ::Compass::Exec.report_error(e, @options)
52
+ end
53
+ exit 1
54
+ end
55
+ exit 0
56
+ end
57
+
58
+ protected
59
+
60
+ def perform!
61
+ if options[:command]
62
+ do_command(options[:command])
63
+ else
64
+ puts self.opts
65
+ end
66
+ end
67
+
68
+ def parse!
69
+ self.opts = OptionParser.new(&method(:set_opts))
70
+ self.opts.parse!(self.args)
71
+ if ARGV.size > 0
72
+ self.options[:project_name] = ARGV.shift
73
+ end
74
+ self.options[:command] ||= self.options[:project_name] ? :create_project : :update_project
75
+ self.options[:environment] ||= :production
76
+ self.options[:framework] ||= :compass
77
+ end
78
+
79
+ def set_opts(opts)
80
+ opts.banner = <<END
81
+ Usage: compass [options] [project]
82
+
83
+ Description:
84
+ When project is given, generates a new project of that name as a subdirectory of
85
+ the current directory.
86
+
87
+ If you change any source files, you can update your project using --update.
88
+
89
+ Options:
90
+ END
91
+ opts.on('-u', '--update', :NONE, 'Update the current project') do
92
+ self.options[:command] = :update_project
93
+ end
94
+
95
+ opts.on('-w', '--watch', :NONE, 'Monitor the current project for changes and update') do
96
+ self.options[:command] = :watch_project
97
+ end
98
+
99
+ opts.on('--source SRC_DIR', "The source directory (where you keep your sass stylesheets).") do |src_dir|
100
+ self.options[:src_dir] = src_dir
101
+ end
102
+
103
+ opts.on('--target CSS_DIR', "The target directory (where you keep your css stylesheets).") do |css_dir|
104
+ self.options[:css_dir] = css_dir
105
+ end
106
+
107
+ opts.on('-f FRAMEWORK', '--framework FRAMEWORK', [:compass, :blueprint], 'Set up a new project using the selected framework. Legal values: compass (default), blueprint') do |framework|
108
+ self.options[:framework] = framework
109
+ end
110
+
111
+ opts.on('-e ENV', '--environment ENV', [:development, :production], 'Use sensible defaults for your current environment: development, production (default)') do |env|
112
+ self.options[:environment] = env
113
+ end
114
+
115
+ opts.on('-s STYLE', '--output-style STYLE', [:nested, :expanded, :compact, :compressed], 'Select a CSS output mode (nested, expanded, compact, compressed)') do |style|
116
+ self.options[:style] = style
117
+ end
118
+
119
+ opts.on('--rails', "Install compass into your Ruby on Rails project found in the current directory.") do
120
+ self.options[:command] = :install_rails
121
+ end
122
+
123
+ opts.on('-q', '--quiet', :NONE, 'Quiet mode.') do
124
+ self.options[:quiet] = true
125
+ end
126
+
127
+ opts.on('--dry-run', :NONE, 'Dry Run. Tells you what it plans to do.') do
128
+ self.options[:dry_run] = true
129
+ end
130
+
131
+ opts.on('--trace', :NONE, 'Show a full traceback on error') do
132
+ self.options[:trace] = true
133
+ end
134
+
135
+ opts.on('--force', :NONE, 'Force. Allows some commands to succeed when they would otherwise fail.') do
136
+ self.options[:force] = true
137
+ end
138
+
139
+ opts.on('--imports', :NONE, 'Emit an import path suitable for use with the Sass command-line tool.') do
140
+ #XXX cross platform support?
141
+ print ::Compass::Frameworks::ALL.map{|f| "-I #{f.stylesheets_directory}"}.join(' ')
142
+ exit
143
+ end
144
+
145
+ opts.on_tail("-?", "-h", "--help", "Show this message") do
146
+ puts opts
147
+ exit
148
+ end
149
+
150
+ opts.on_tail("-v", "--version", "Print version") do
151
+ self.options[:command] = :print_version
152
+ end
153
+ end
154
+
155
+ def do_command(command)
156
+ require File.join(File.dirname(__FILE__), 'commands', command.to_s)
157
+ command_class_name = command.to_s.split(/_/).map{|p| p.capitalize}.join('')
158
+ command_class = eval("::Compass::Commands::#{command_class_name}")
159
+ command_class.new(Dir.getwd, options).perform
160
+ end
161
+
162
+ end
163
+ end
164
+ end
@@ -0,0 +1,2 @@
1
+ blueprint_dir = File.join(Compass.base_directory, 'frameworks', 'blueprint')
2
+ Compass::Frameworks.register('compass', blueprint_dir)
@@ -0,0 +1,2 @@
1
+ compass_dir = File.join(Compass.base_directory, 'frameworks', 'compass')
2
+ Compass::Frameworks.register('compass', compass_dir)
@@ -0,0 +1,2 @@
1
+ yui_dir = File.join(Compass.base_directory, 'frameworks', 'yui')
2
+ Compass::Frameworks.register('yui', yui_dir)
@@ -0,0 +1,27 @@
1
+ module Compass
2
+ module Frameworks
3
+ ALL = []
4
+ class Framework
5
+ attr_accessor :name
6
+ attr_accessor :path
7
+ def initialize(name, path)
8
+ self.name = name
9
+ self.path = path
10
+ end
11
+ def template_directory
12
+ File.join(self.path, 'templates')
13
+ end
14
+ def stylesheets_directory
15
+ File.join(self.path, 'stylesheets')
16
+ end
17
+ end
18
+ def register(name, path)
19
+ ALL << Framework.new(name, path)
20
+ end
21
+ module_function :register
22
+ end
23
+ end
24
+
25
+ require File.join(File.dirname(__FILE__), 'frameworks', 'compass')
26
+ require File.join(File.dirname(__FILE__), 'frameworks', 'blueprint')
27
+ require File.join(File.dirname(__FILE__), 'frameworks', 'yui')
@@ -0,0 +1,43 @@
1
+ # To configure Merb to use compass do the following:
2
+ # Merb::BootLoader.after_app_loads do
3
+ # require 'merb-haml'
4
+ # require 'compass'
5
+ # end
6
+ #
7
+ # To use a different sass stylesheets locations as is recommended by compass
8
+ # add this configuration to your configuration block:
9
+ #
10
+ # Merb::Config.use do |c|
11
+ # c[:compass] = {
12
+ # :stylesheets => 'app/stylesheets',
13
+ # :compiled_stylesheets => 'public/stylesheets/compiled'
14
+ # }
15
+ # end
16
+
17
+ Merb::BootLoader.after_app_loads do
18
+ #set up sass if haml load didn't do it -- this happens when using a non-default stylesheet location.
19
+ unless defined?(Sass::Plugin)
20
+ require "sass/plugin"
21
+ Sass::Plugin.options = Merb::Config[:sass] if Merb::Config[:sass]
22
+ end
23
+
24
+ # default the compass configuration if they didn't set it up yet.
25
+ Merb::Config[:compass] ||= {}
26
+
27
+ # default sass stylesheet location unless configured to something else
28
+ Merb::Config[:compass][:stylesheets] ||= Merb.dir_for(:stylesheet) / "sass"
29
+
30
+ # default sass css location unless configured to something else
31
+ Merb::Config[:compass][:compiled_stylesheets] ||= Merb.dir_for(:stylesheet)
32
+
33
+ #define the template hash for the project stylesheets as well as the framework stylesheets.
34
+ template_location = {
35
+ Merb::Config[:compass][:stylesheets] => Merb::Config[:compass][:compiled_stylesheets]
36
+ }
37
+ Compass::Frameworks::ALL.each do |framework|
38
+ template_location[framework.stylesheets_directory] = Merb::Config[:compass][:compiled_stylesheets]
39
+ end
40
+
41
+ #configure Sass to know about all these sass locations.
42
+ Sass::Plugin.options[:template_location] = template_location
43
+ end
@@ -0,0 +1,37 @@
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 < Test::Unit::TestCase
19
+ def setup
20
+ @last_compile = nil
21
+ end
22
+
23
+ def compile(stylesheet)
24
+ input = open(stylesheet)
25
+ template = input.read()
26
+ input.close()
27
+ @last_compile = ::Sass::Engine.new(template,
28
+ ::Sass::Plugin.engine_options(:style => :compact, :filename => stylesheet)).render
29
+ yield @last_compile if block_given?
30
+ end
31
+
32
+ def assert_compiles(stylesheet, &block)
33
+ compile(stylesheet, &block)
34
+ end
35
+
36
+ end
37
+ end
@@ -0,0 +1,93 @@
1
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
2
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang='en' lang='en'>
4
+ <head>
5
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
6
+ <link rel="stylesheet" type="text/css" href="http://www.w3.org/StyleSheets/base.css" />
7
+ <title>W3C IPR SOFTWARE NOTICE</title>
8
+ </head>
9
+ <body>
10
+ <h1>W3C<sup>&reg;</sup> SOFTWARE NOTICE AND LICENSE</h1>
11
+
12
+ <h3>Copyright &copy; 1997-2002 <a href="http://www.w3.org/">World
13
+ Wide Web Consortium</a>, (<a
14
+ href="http://www.lcs.mit.edu/">Massachusetts Institute of
15
+ Technology</a>, <a href="http://www.inria.fr/">Institut National de
16
+ Recherche en Informatique et en Automatique</a>, <a
17
+ href="http://www.keio.ac.jp/">Keio University</a>). All Rights
18
+ Reserved. http://www.w3.org/Consortium/Legal/</h3>
19
+
20
+ <p>This W3C work (including software, documents, or other related
21
+ items) is being provided by the copyright holders under the
22
+ following license. By obtaining, using and/or copying this work,
23
+ you (the licensee) agree that you have read, understood, and will
24
+ comply with the following terms and conditions:</p>
25
+
26
+ <p>Permission to use, copy, modify, and distribute this software
27
+ and its documentation, with or without modification,&nbsp; for any
28
+ purpose and without fee or royalty is hereby granted, provided that
29
+ you include the following on ALL copies of the software and
30
+ documentation or portions thereof, including modifications, that
31
+ you make:</p>
32
+
33
+ <ol>
34
+ <li>The full text of this NOTICE in a location viewable to users of
35
+ the redistributed or derivative work.</li>
36
+
37
+ <li>Any pre-existing intellectual property disclaimers, notices, or
38
+ terms and conditions. If none exist, a short notice of the
39
+ following form (hypertext is preferred, text is permitted) should
40
+ be used within the body of any redistributed or derivative code:
41
+ "Copyright &copy; [$date-of-software] <a
42
+ href="http://www.w3.org/">World Wide Web Consortium</a>, (<a
43
+ href="http://www.lcs.mit.edu/">Massachusetts Institute of
44
+ Technology</a>, <a href="http://www.inria.fr/">Institut National de
45
+ Recherche en Informatique et en Automatique</a>, <a
46
+ href="http://www.keio.ac.jp/">Keio University</a>). All Rights
47
+ Reserved. http://www.w3.org/Consortium/Legal/"</li>
48
+
49
+ <li>Notice of any changes or modifications to the W3C files,
50
+ including the date changes were made. (We recommend you provide
51
+ URIs to the location from which the code is derived.)</li>
52
+ </ol>
53
+
54
+ <p>THIS SOFTWARE AND DOCUMENTATION IS PROVIDED "AS IS," AND
55
+ COPYRIGHT HOLDERS MAKE NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR
56
+ IMPLIED, INCLUDING BUT NOT LIMITED TO, WARRANTIES OF
57
+ MERCHANTABILITY OR FITNESS FOR ANY PARTICULAR PURPOSE OR THAT THE
58
+ USE OF THE SOFTWARE OR DOCUMENTATION WILL NOT INFRINGE ANY THIRD
59
+ PARTY PATENTS, COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS.</p>
60
+
61
+ <p>COPYRIGHT HOLDERS WILL NOT BE LIABLE FOR ANY DIRECT, INDIRECT,
62
+ SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF ANY USE OF THE
63
+ SOFTWARE OR DOCUMENTATION.</p>
64
+
65
+ <p>The name and trademarks of copyright holders may NOT be used in
66
+ advertising or publicity pertaining to the software without
67
+ specific, written prior permission. Title to copyright in this
68
+ software and any associated documentation will at all times remain
69
+ with copyright holders.</p>
70
+
71
+ <p>____________________________________</p>
72
+
73
+ <p>This formulation of W3C's notice and license became active on
74
+ August 14 1998 so as to improve compatibility with GPL. This
75
+ version ensures that W3C software licensing terms are no more
76
+ restrictive than GPL and consequently W3C software may be
77
+ distributed in GPL packages. See the <a
78
+ href="copyright-software-19980519.html">older formulation</a> for
79
+ the policy prior to this date. Please see our <a
80
+ href="IPR-FAQ.html">Copyright FAQ</a> for common questions about
81
+ using materials from our site, including specific terms and
82
+ conditions for packages like libwww, Amaya, and Jigsaw. Other
83
+ questions about this notice can be directed to <a
84
+ href="mailto:site-policy@w3.org">site-policy@w3.org</a>.<br />
85
+ &nbsp;</p>
86
+
87
+ <p>&nbsp;</p>
88
+
89
+ <address><a href="http://www.w3.org/Help/Webmaster.html">webmaster</a><br />
90
+ (last updated $Date: 2004/05/29 04:04:36 $)</address>
91
+
92
+ </body>
93
+ </html>
@@ -0,0 +1,64 @@
1
+ W3C IPR SOFTWARE NOTICE
2
+
3
+ Copyright � 1995-1998 World Wide Web Consortium, (Massachusetts Institute of
4
+ Technology, Institut National de Recherche en Informatique et en
5
+ Automatique, Keio University). All Rights Reserved.
6
+ http://www.w3.org/Consortium/Legal/
7
+
8
+ This W3C work (including software, documents, or other related items) is
9
+ being provided by the copyright holders under the following license. By
10
+ obtaining, using and/or copying this work, you (the licensee) agree that you
11
+ have read, understood, and will comply with the following terms and
12
+ conditions:
13
+
14
+ Permission to use, copy, and modify this software and its documentation,
15
+ with or without modification, for any purpose and without fee or royalty is
16
+ hereby granted, provided that you include the following on ALL copies of the
17
+ software and documentation or portions thereof, including modifications,
18
+ that you make:
19
+
20
+ 1. The full text of this NOTICE in a location viewable to users of the
21
+ redistributed or derivative work.
22
+ 2. Any pre-existing intellectual property disclaimers, notices, or terms
23
+ and conditions. If none exist, a short notice of the following form
24
+ (hypertext is preferred, text is permitted) should be used within the
25
+ body of any redistributed or derivative code: "Copyright � World Wide
26
+ Web Consortium, (Massachusetts Institute of Technology, Institut
27
+ National de Recherche en Informatique et en Automatique, Keio
28
+ University). All Rights Reserved. http://www.w3.org/Consortium/Legal/"
29
+ 3. Notice of any changes or modifications to the W3C files, including the
30
+ date changes were made. (We recommend you provide URIs to the location
31
+ from which the code is derived).
32
+
33
+ In addition, creators of derivitive works must include the full text of this
34
+ NOTICE in a location viewable to users of the derivitive work.
35
+
36
+ THIS SOFTWARE AND DOCUMENTATION IS PROVIDED "AS IS," AND COPYRIGHT HOLDERS
37
+ MAKE NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT NOT
38
+ LIMITED TO, WARRANTIES OF MERCHANTABILITY OR FITNESS FOR ANY PARTICULAR
39
+ PURPOSE OR THAT THE USE OF THE SOFTWARE OR DOCUMENTATION WILL NOT INFRINGE
40
+ ANY THIRD PARTY PATENTS, COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS.
41
+
42
+ COPYRIGHT HOLDERS WILL NOT BE LIABLE FOR ANY DIRECT, INDIRECT, SPECIAL OR
43
+ CONSEQUENTIAL DAMAGES ARISING OUT OF ANY USE OF THE SOFTWARE OR
44
+ DOCUMENTATION.
45
+
46
+ The name and trademarks of copyright holders may NOT be used in advertising
47
+ or publicity pertaining to the software without specific, written prior
48
+ permission. Title to copyright in this software and any associated
49
+ documentation will at all times remain with copyright holders.
50
+
51
+ ____________________________________
52
+
53
+ This formulation of W3C's notice and license became active on August 14
54
+ 1998. See the older formulation for the policy prior to this date. Please
55
+ see our Copyright FAQ for common questions about using materials from our
56
+ site, including specific terms and conditions for packages like libwww,
57
+ Amaya, and Jigsaw. Other questions about this notice can be directed to
58
+ site-policy@w3.org .
59
+
60
+
61
+
62
+
63
+ webmaster
64
+ (last updated 14-Aug-1998)