From 9888efdbc22f67c9ed6d54cd09a10a7c7d094f73 Mon Sep 17 00:00:00 2001 From: Chris Eppstein Date: Fri, 4 Nov 2011 16:16:22 -0700 Subject: [PATCH 1/3] We actually count css selectors, not rules in compass stats --- features/command_line.feature | 30 +++++++++++++-------------- lib/compass/commands/project_stats.rb | 14 ++++++------- 2 files changed, 22 insertions(+), 22 deletions(-) diff --git a/features/command_line.feature b/features/command_line.feature index 56d52abb..52aff150 100644 --- a/features/command_line.feature +++ b/features/command_line.feature @@ -277,21 +277,21 @@ Feature: Command Line Given I am using the existing project in test/fixtures/stylesheets/compass When I run: compass stats Then I am told statistics for each file: - | Filename | Rules | Properties | Mixins Defs | Mixins Used | CSS Rules | CSS Properties | - | sass/border_radius.scss | \d+ | \d+ | \d+ | \d+ | \d+ | \d+ | - | sass/box.sass | \d+ | \d+ | \d+ | \d+ | \d+ | \d+ | - | sass/fonts.sass | \d+ | \d+ | \d+ | \d+ | \d+ | \d+ | - | sass/gradients.sass | \d+ | \d+ | \d+ | \d+ | \d+ | \d+ | - | sass/image_size.sass | \d+ | \d+ | \d+ | \d+ | \d+ | \d+ | - | sass/images.scss | \d+ | \d+ | \d+ | \d+ | \d+ | \d+ | - | sass/layout.sass | \d+ | \d+ | \d+ | \d+ | \d+ | \d+ | - | sass/legacy_clearfix.scss | \d+ | \d+ | \d+ | \d+ | \d+ | \d+ | - | sass/lists.scss | \d+ | \d+ | \d+ | \d+ | \d+ | \d+ | - | sass/print.sass | \d+ | \d+ | \d+ | \d+ | \d+ | \d+ | - | sass/reset.sass | \d+ | \d+ | \d+ | \d+ | \d+ | \d+ | - | sass/utilities.scss | \d+ | \d+ | \d+ | \d+ | \d+ | \d+ | - | ------------------------- | ----- | ---------- | -------------- | ----------- | --------- | -------------- | - | Total.* | \d+ | \d+ | \d+ | \d+ | \d+ | \d+ | + | Filename | Rules | Properties | Mixins Defs | Mixins Used | CSS Selectors | CSS Properties | + | sass/border_radius.scss | \d+ | \d+ | \d+ | \d+ | \d+ | \d+ | + | sass/box.sass | \d+ | \d+ | \d+ | \d+ | \d+ | \d+ | + | sass/fonts.sass | \d+ | \d+ | \d+ | \d+ | \d+ | \d+ | + | sass/gradients.sass | \d+ | \d+ | \d+ | \d+ | \d+ | \d+ | + | sass/image_size.sass | \d+ | \d+ | \d+ | \d+ | \d+ | \d+ | + | sass/images.scss | \d+ | \d+ | \d+ | \d+ | \d+ | \d+ | + | sass/layout.sass | \d+ | \d+ | \d+ | \d+ | \d+ | \d+ | + | sass/legacy_clearfix.scss | \d+ | \d+ | \d+ | \d+ | \d+ | \d+ | + | sass/lists.scss | \d+ | \d+ | \d+ | \d+ | \d+ | \d+ | + | sass/print.sass | \d+ | \d+ | \d+ | \d+ | \d+ | \d+ | + | sass/reset.sass | \d+ | \d+ | \d+ | \d+ | \d+ | \d+ | + | sass/utilities.scss | \d+ | \d+ | \d+ | \d+ | \d+ | \d+ | + | ------------------------- | ----- | ---------- | -------------- | ----------- | ------------- | -------------- | + | Total.* | \d+ | \d+ | \d+ | \d+ | \d+ | \d+ | @listframeworks Scenario: List frameworks registered with compass diff --git a/lib/compass/commands/project_stats.rb b/lib/compass/commands/project_stats.rb index 7e7987a0..42ab579e 100644 --- a/lib/compass/commands/project_stats.rb +++ b/lib/compass/commands/project_stats.rb @@ -34,13 +34,13 @@ module Compass compiler = new_compiler_instance sass_files = sorted_sass_files(compiler) total_label = "Total (#{sass_files.size} files):" - rows = [[ :-, :-, :-, :-, :-, :-, :- ], - [ 'Filename', 'Rules', 'Properties', 'Mixins Defs', 'Mixins Used', 'CSS Rules', 'CSS Properties' ], - [ :-, :-, :-, :-, :-, :-, :- ]] - maximums = [ total_label.length, 5, 10, 14, 11, 9, 14 ] - alignments = [ :left, :right, :right, :right, :right, :right, :right ] - delimiters = [ ['| ', ' |'], [' ', ' |'], [' ', ' |'], [' ', ' |'], [' ', ' |'], [' ', ' |'], [' ', ' |'] ] - totals = [ total_label, 0, 0, 0, 0, 0, 0 ] + rows = [[ :-, :-, :-, :-, :-, :-, :- ], + [ 'Filename', 'Rules', 'Properties', 'Mixins Defs', 'Mixins Used', 'CSS Selectors', 'CSS Properties' ], + [ :-, :-, :-, :-, :-, :-, :- ]] + maximums = [ total_label.length, 5, 10, 14, 11, 13, 14 ] + alignments = [ :left, :right, :right, :right, :right, :right, :right ] + delimiters = [ ['| ', ' |'], [' ', ' |'], [' ', ' |'], [' ', ' |'], [' ', ' |'], [' ', ' |'], [' ', ' |'] ] + totals = [ total_label, 0, 0, 0, 0, 0, 0 ] sass_files.each do |sass_file| css_file = compiler.corresponding_css_file(sass_file) unless sass_file[0..0] == '_' From 720cc891ae627dc98dfcaa487559f25b2bf75a22 Mon Sep 17 00:00:00 2001 From: Chris Eppstein Date: Sun, 6 Nov 2011 17:59:11 -0800 Subject: [PATCH 2/3] Return an error exit code if no exit code is provided by the command. --- bin/compass | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/bin/compass b/bin/compass index c174ce02..00996203 100755 --- a/bin/compass +++ b/bin/compass @@ -36,5 +36,9 @@ if ARGV.delete("--profile") printer.print(STDERR, 0) exit exit_code else - exit runner.call + if exit_code = runner.call + exit exit_code + else + exit 1 + end end From 4183a60e311586caba087207de4820269eaefdca Mon Sep 17 00:00:00 2001 From: Chris Eppstein Date: Sun, 6 Nov 2011 18:01:07 -0800 Subject: [PATCH 3/3] Handle frameworks without a templates directory. --- features/extensions.feature | 6 ++ .../step_definitions/command_line_steps.rb | 2 + lib/compass/frameworks.rb | 14 ++-- .../only_stylesheets/compass_init.rb | 1 + .../scss/only_stylesheets/foo.scss | 3 + .../uses_only_stylesheets_ext/config.rb | 25 +++++++ .../uses_only_stylesheets_ext/sass/ie.scss | 5 ++ .../uses_only_stylesheets_ext/sass/print.scss | 3 + .../sass/screen.scss | 6 ++ .../stylesheets/ie.css | 5 ++ .../stylesheets/print.css | 3 + .../stylesheets/screen.css | 68 +++++++++++++++++++ 12 files changed, 137 insertions(+), 4 deletions(-) create mode 100644 test/fixtures/extensions/only_stylesheets/compass_init.rb create mode 100644 test/fixtures/extensions/only_stylesheets/scss/only_stylesheets/foo.scss create mode 100644 test/fixtures/stylesheets/uses_only_stylesheets_ext/config.rb create mode 100644 test/fixtures/stylesheets/uses_only_stylesheets_ext/sass/ie.scss create mode 100644 test/fixtures/stylesheets/uses_only_stylesheets_ext/sass/print.scss create mode 100644 test/fixtures/stylesheets/uses_only_stylesheets_ext/sass/screen.scss create mode 100644 test/fixtures/stylesheets/uses_only_stylesheets_ext/stylesheets/ie.css create mode 100644 test/fixtures/stylesheets/uses_only_stylesheets_ext/stylesheets/print.css create mode 100644 test/fixtures/stylesheets/uses_only_stylesheets_ext/stylesheets/screen.css diff --git a/features/extensions.feature b/features/extensions.feature index 5a31a902..89b3857c 100644 --- a/features/extensions.feature +++ b/features/extensions.feature @@ -28,3 +28,9 @@ Feature: Extensions And and I have a fake extension at ~/.compass/extensions/testing When I run: compass frameworks Then the list of frameworks includes "testing" + + @listframeworks + Scenario: Frameworks without templates + Given I am using the existing project in test/fixtures/stylesheets/uses_only_stylesheets_ext + When I run: compass frameworks + Then the list of frameworks includes "only_stylesheets" diff --git a/features/step_definitions/command_line_steps.rb b/features/step_definitions/command_line_steps.rb index fd45fdc9..d8abc970 100644 --- a/features/step_definitions/command_line_steps.rb +++ b/features/step_definitions/command_line_steps.rb @@ -10,6 +10,8 @@ include Compass::RailsHelper Before do Compass.reset_configuration! + Compass::Frameworks::ALL.clear + Compass::Frameworks.discover :defaults @cleanup_directories = [] @original_working_directory = Dir.pwd end diff --git a/lib/compass/frameworks.rb b/lib/compass/frameworks.rb index 734c31be..e22e21f6 100644 --- a/lib/compass/frameworks.rb +++ b/lib/compass/frameworks.rb @@ -13,11 +13,17 @@ module Compass options = arguments.last.is_a?(Hash) ? arguments.pop : {} self.path = path = options[:path] || arguments.shift @name = name - @templates_directory = options[:templates_directory] || File.join(path, 'templates') - @stylesheets_directory = options[:stylesheets_directory] || File.join(path, 'stylesheets') + @templates_directory = options[:templates_directory] + @templates_directory ||= File.join(path, 'templates') if path + @stylesheets_directory = options[:stylesheets_directory] + @stylesheets_directory ||= File.join(path, 'stylesheets') if path end def template_directories - Dir.glob(File.join(templates_directory, "*")).map{|f| File.basename(f)} + if templates_directory + Dir.glob(File.join(templates_directory, "*")).map{|f| File.basename(f)} + else + [] + end end def manifest_file(pattern) File.join(templates_directory, pattern.to_s, "manifest.rb") @@ -76,7 +82,7 @@ module Compass def template_exists?(template) framework_name, template = template.split(%r{/}, 2) template ||= "project" - if framework = self[framework_name] + if (framework = self[framework_name]) && framework.templates_directory return File.directory?(File.join(framework.templates_directory, template)) end false diff --git a/test/fixtures/extensions/only_stylesheets/compass_init.rb b/test/fixtures/extensions/only_stylesheets/compass_init.rb new file mode 100644 index 00000000..21728f74 --- /dev/null +++ b/test/fixtures/extensions/only_stylesheets/compass_init.rb @@ -0,0 +1 @@ +Compass::Frameworks.register("only-stylesheets", :stylesheets_dir => File.join(File.dirname(__FILE__),"scss")) diff --git a/test/fixtures/extensions/only_stylesheets/scss/only_stylesheets/foo.scss b/test/fixtures/extensions/only_stylesheets/scss/only_stylesheets/foo.scss new file mode 100644 index 00000000..f1cf0267 --- /dev/null +++ b/test/fixtures/extensions/only_stylesheets/scss/only_stylesheets/foo.scss @@ -0,0 +1,3 @@ +@mixin only-stylesheets { + color: red; +} diff --git a/test/fixtures/stylesheets/uses_only_stylesheets_ext/config.rb b/test/fixtures/stylesheets/uses_only_stylesheets_ext/config.rb new file mode 100644 index 00000000..95c72a59 --- /dev/null +++ b/test/fixtures/stylesheets/uses_only_stylesheets_ext/config.rb @@ -0,0 +1,25 @@ +# Require any additional compass plugins here. +load '../../extensions/only_stylesheets/' + +# Set this to the root of your project when deployed: +http_path = "/" +css_dir = "stylesheets" +sass_dir = "sass" +images_dir = "images" +javascripts_dir = "javascripts" + +# You can select your preferred output style here (can be overridden via the command line): +# output_style = :expanded or :nested or :compact or :compressed + +# To enable relative paths to assets via compass helper functions. Uncomment: +# relative_assets = true + +# To disable debugging comments that display the original location of your selectors. Uncomment: +# line_comments = false + + +# If you prefer the indented syntax, you might want to regenerate this +# project again passing --syntax sass, or you can uncomment this: +# preferred_syntax = :sass +# and then run: +# sass-convert -R --from scss --to sass sass scss && rm -rf sass && mv scss sass diff --git a/test/fixtures/stylesheets/uses_only_stylesheets_ext/sass/ie.scss b/test/fixtures/stylesheets/uses_only_stylesheets_ext/sass/ie.scss new file mode 100644 index 00000000..5cd5b6c5 --- /dev/null +++ b/test/fixtures/stylesheets/uses_only_stylesheets_ext/sass/ie.scss @@ -0,0 +1,5 @@ +/* Welcome to Compass. Use this file to write IE specific override styles. + * Import this file using the following HTML or equivalent: + * */ diff --git a/test/fixtures/stylesheets/uses_only_stylesheets_ext/sass/print.scss b/test/fixtures/stylesheets/uses_only_stylesheets_ext/sass/print.scss new file mode 100644 index 00000000..b0e9e456 --- /dev/null +++ b/test/fixtures/stylesheets/uses_only_stylesheets_ext/sass/print.scss @@ -0,0 +1,3 @@ +/* Welcome to Compass. Use this file to define print styles. + * Import this file using the following HTML or equivalent: + * */ diff --git a/test/fixtures/stylesheets/uses_only_stylesheets_ext/sass/screen.scss b/test/fixtures/stylesheets/uses_only_stylesheets_ext/sass/screen.scss new file mode 100644 index 00000000..81de8470 --- /dev/null +++ b/test/fixtures/stylesheets/uses_only_stylesheets_ext/sass/screen.scss @@ -0,0 +1,6 @@ +/* Welcome to Compass. + * In this file you should write your main styles. (or centralize your imports) + * Import this file using the following HTML or equivalent: + * */ + +@import "compass/reset"; diff --git a/test/fixtures/stylesheets/uses_only_stylesheets_ext/stylesheets/ie.css b/test/fixtures/stylesheets/uses_only_stylesheets_ext/stylesheets/ie.css new file mode 100644 index 00000000..5cd5b6c5 --- /dev/null +++ b/test/fixtures/stylesheets/uses_only_stylesheets_ext/stylesheets/ie.css @@ -0,0 +1,5 @@ +/* Welcome to Compass. Use this file to write IE specific override styles. + * Import this file using the following HTML or equivalent: + * */ diff --git a/test/fixtures/stylesheets/uses_only_stylesheets_ext/stylesheets/print.css b/test/fixtures/stylesheets/uses_only_stylesheets_ext/stylesheets/print.css new file mode 100644 index 00000000..b0e9e456 --- /dev/null +++ b/test/fixtures/stylesheets/uses_only_stylesheets_ext/stylesheets/print.css @@ -0,0 +1,3 @@ +/* Welcome to Compass. Use this file to define print styles. + * Import this file using the following HTML or equivalent: + * */ diff --git a/test/fixtures/stylesheets/uses_only_stylesheets_ext/stylesheets/screen.css b/test/fixtures/stylesheets/uses_only_stylesheets_ext/stylesheets/screen.css new file mode 100644 index 00000000..83e33536 --- /dev/null +++ b/test/fixtures/stylesheets/uses_only_stylesheets_ext/stylesheets/screen.css @@ -0,0 +1,68 @@ +/* Welcome to Compass. + * In this file you should write your main styles. (or centralize your imports) + * Import this file using the following HTML or equivalent: + * */ +/* line 17, ../../../../../../../.rbenv/versions/1.9.2-p290/lib/ruby/gems/1.9.1/gems/compass-0.12.alpha.0/frameworks/compass/stylesheets/compass/reset/_utilities.scss */ +html, body, div, span, applet, object, iframe, +h1, h2, h3, h4, h5, h6, p, blockquote, pre, +a, abbr, acronym, address, big, cite, code, +del, dfn, em, img, ins, kbd, q, s, samp, +small, strike, strong, sub, sup, tt, var, +b, u, i, center, +dl, dt, dd, ol, ul, li, +fieldset, form, label, legend, +table, caption, tbody, tfoot, thead, tr, th, td, +article, aside, canvas, details, embed, +figure, figcaption, footer, header, hgroup, +menu, nav, output, ruby, section, summary, +time, mark, audio, video { + margin: 0; + padding: 0; + border: 0; + font-size: 100%; + font: inherit; + vertical-align: baseline; +} + +/* line 20, ../../../../../../../.rbenv/versions/1.9.2-p290/lib/ruby/gems/1.9.1/gems/compass-0.12.alpha.0/frameworks/compass/stylesheets/compass/reset/_utilities.scss */ +body { + line-height: 1; +} + +/* line 22, ../../../../../../../.rbenv/versions/1.9.2-p290/lib/ruby/gems/1.9.1/gems/compass-0.12.alpha.0/frameworks/compass/stylesheets/compass/reset/_utilities.scss */ +ol, ul { + list-style: none; +} + +/* line 24, ../../../../../../../.rbenv/versions/1.9.2-p290/lib/ruby/gems/1.9.1/gems/compass-0.12.alpha.0/frameworks/compass/stylesheets/compass/reset/_utilities.scss */ +table { + border-collapse: collapse; + border-spacing: 0; +} + +/* line 26, ../../../../../../../.rbenv/versions/1.9.2-p290/lib/ruby/gems/1.9.1/gems/compass-0.12.alpha.0/frameworks/compass/stylesheets/compass/reset/_utilities.scss */ +caption, th, td { + text-align: left; + font-weight: normal; + vertical-align: middle; +} + +/* line 28, ../../../../../../../.rbenv/versions/1.9.2-p290/lib/ruby/gems/1.9.1/gems/compass-0.12.alpha.0/frameworks/compass/stylesheets/compass/reset/_utilities.scss */ +q, blockquote { + quotes: none; +} +/* line 101, ../../../../../../../.rbenv/versions/1.9.2-p290/lib/ruby/gems/1.9.1/gems/compass-0.12.alpha.0/frameworks/compass/stylesheets/compass/reset/_utilities.scss */ +q:before, q:after, blockquote:before, blockquote:after { + content: ""; + content: none; +} + +/* line 30, ../../../../../../../.rbenv/versions/1.9.2-p290/lib/ruby/gems/1.9.1/gems/compass-0.12.alpha.0/frameworks/compass/stylesheets/compass/reset/_utilities.scss */ +a img { + border: none; +} + +/* line 114, ../../../../../../../.rbenv/versions/1.9.2-p290/lib/ruby/gems/1.9.1/gems/compass-0.12.alpha.0/frameworks/compass/stylesheets/compass/reset/_utilities.scss */ +article, aside, details, figcaption, figure, footer, header, hgroup, menu, nav, section, summary { + display: block; +}