From fe65dcd81613c2c1647e5cd246d600a257c6b03b Mon Sep 17 00:00:00 2001 From: raphaeleidus Date: Fri, 21 Jun 2013 14:15:59 -0300 Subject: [PATCH 1/5] Allow custom environments Some usecases require environments like `staging` or `qa` --- lib/compass/exec/project_options_parser.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/compass/exec/project_options_parser.rb b/lib/compass/exec/project_options_parser.rb index 301c5d7f90..cccdfd3b6d 100644 --- a/lib/compass/exec/project_options_parser.rb +++ b/lib/compass/exec/project_options_parser.rb @@ -44,9 +44,9 @@ def set_project_options(opts) set_dir_or_path(:fonts, fonts_dir) end - opts.on('-e ENV', '--environment ENV', [:development, :production], 'Use sensible defaults for your current environment.', - ' One of: development (default), production') do |env| - self.options[:environment] = env + opts.on('-e ENV', '--environment ENV', 'Use sensible defaults for your current environment.', + ' defaults to development') do |env| + self.options[:environment] = env || :development end opts.on('-s STYLE', '--output-style STYLE', [:nested, :expanded, :compact, :compressed], 'Select a CSS output mode.', From f4424276cd7d1363f904bd23014b5bdf14d5658b Mon Sep 17 00:00:00 2001 From: raphaeleidus Date: Fri, 21 Jun 2013 16:00:27 -0300 Subject: [PATCH 2/5] Update defaults with custom environments in mind --- lib/compass/configuration/defaults.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/compass/configuration/defaults.rb b/lib/compass/configuration/defaults.rb index 2d6046c139..5f2bb4ab58 100644 --- a/lib/compass/configuration/defaults.rb +++ b/lib/compass/configuration/defaults.rb @@ -27,7 +27,7 @@ def default_environment end def default_output_style - if top_level.environment == :development + if top_level.environment != :production :expanded else :compressed @@ -35,7 +35,7 @@ def default_output_style end def default_line_comments - top_level.environment == :development + top_level.environment != :production end def default_color_output From 3a19fb491ffdf713abb08aebd82295a8986db00d Mon Sep 17 00:00:00 2001 From: raphaeleidus Date: Fri, 21 Jun 2013 16:06:19 -0300 Subject: [PATCH 3/5] Doc the custom environments feature --- .../content/help/tutorials/configuration-reference.markdown | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/doc-src/content/help/tutorials/configuration-reference.markdown b/doc-src/content/help/tutorials/configuration-reference.markdown index b6c49a3f58..aa9fb45354 100644 --- a/doc-src/content/help/tutorials/configuration-reference.markdown +++ b/doc-src/content/help/tutorials/configuration-reference.markdown @@ -102,7 +102,9 @@ later on. environment Symbol The environment mode. - Defaults to :production, can also be :development + Defaults to :development, traditionally one of :development or :production + but any environment string can be provided. Custom environments will use the defaults of the + :development environment unless overwridden. @@ -425,4 +427,4 @@ to avoid crashing the watcher in the case where the file has been removed. self.icon = '/path/to/fail.jpg' sticky! } - end \ No newline at end of file + end From a584273e885953228288b856cc754373c6209b89 Mon Sep 17 00:00:00 2001 From: RaphaelEidus Date: Fri, 21 Jun 2013 15:16:43 -0400 Subject: [PATCH 4/5] fix typo --- .../content/help/tutorials/configuration-reference.markdown | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/doc-src/content/help/tutorials/configuration-reference.markdown b/doc-src/content/help/tutorials/configuration-reference.markdown index aa9fb45354..f64c98c863 100644 --- a/doc-src/content/help/tutorials/configuration-reference.markdown +++ b/doc-src/content/help/tutorials/configuration-reference.markdown @@ -103,8 +103,8 @@ later on. Symbol The environment mode. Defaults to :development, traditionally one of :development or :production - but any environment string can be provided. Custom environments will use the defaults of the - :development environment unless overwridden. + but any environment string can be provided. Custom environments will use the defaults of the + :development environment unless overridden. From d63e81d3a177469dc989e00f9ab4c4ea262ebc6d Mon Sep 17 00:00:00 2001 From: RaphaelEidus Date: Fri, 21 Jun 2013 15:32:21 -0400 Subject: [PATCH 5/5] custom environment test --- test/integrations/compass_test.rb | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/test/integrations/compass_test.rb b/test/integrations/compass_test.rb index b06f128347..a323c0f522 100644 --- a/test/integrations/compass_test.rb +++ b/test/integrations/compass_test.rb @@ -95,6 +95,17 @@ def test_env_in_production end end + def test_env_in_custom_env + within_project('envtest', lambda {|c| c.environment = :staging }) do |proj| + each_css_file(proj.css_path) do |css_file| + assert_no_errors css_file, 'envtest' + end + each_sass_file do |sass_file| + assert_renders_correctly sass_file, :ignore_charset => true, :environment => "staging" + end + end + end + def test_busted_image_urls within_project('busted_image_urls') do |proj| each_css_file(proj.css_path) do |css_file|