Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Allow custom environments #1322

Open
wants to merge 5 commits into from

3 participants

@raphaeleidus

Some usecases require environments like staging or qa

The restriction to just development or production for environment makes it difficult to do certain things.

raphaeleidus Allow custom environments
Some usecases require environments like `staging` or `qa`
fe65dcd
@chriseppstein

I'm ok with this. but we need to do the following:

  1. Update the configuration documentation and provide some help on how to use custom environments.
  2. Change default_output_style and default_line_comments in lib/compass/configuration/defaults.rb to be based on not being the production environment. Ditto for show_full_exception? in lib/compass/compiler.rb.
  3. add tests
@raphaeleidus

@chriseppstein I added a test, some docs and altered the default configurations. Let me know what you think.

@raphaeleidus

Also as a note I was having a bunch of trouble getting the tests to run because of some mocha deprecation.
I had to replace require 'mocha' with require 'mocha/setup' in /test/units/sprites/image_test.rb and I had to comment out the setup method in /test/helpers/test_case.rb entirely.

@raphaeleidus

@chriseppstein could you help me figure out why this test is failing in my fork? https://travis-ci.org/chriseppstein/compass/jobs/8321742#L125

@raphaeleidus

@chriseppstein hey any chance you could help me get this merged in?

@raphaeleidus

@scottdavis could you help me get this ready to be merged?

@lolmaus

Looking forward to having this implemented.

@chriseppstein

I'd like to wait on this until after 1.0 ships.

@raphaeleidus

@chriseppstein do you have a rough timeline on this?

@chriseppstein

1.0 shipped. Can you rebase this and make sure it's working now?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Jun 21, 2013
  1. Allow custom environments

    raphaeleidus authored
    Some usecases require environments like `staging` or `qa`
  2. Update defaults with custom environments in mind

    raphaeleidus authored
  3. Doc the custom environments feature

    raphaeleidus authored
  4. @raphaeleidus

    fix typo

    raphaeleidus authored
  5. @raphaeleidus

    custom environment test

    raphaeleidus authored
This page is out of date. Refresh to see the latest.
View
6 doc-src/content/help/tutorials/configuration-reference.markdown
@@ -102,7 +102,9 @@ later on.
<td style="vertical-align:top;"><code>environment</code> </td>
<td style="vertical-align:top;">Symbol </td>
<td style="vertical-align:top;">The environment mode.
- Defaults to <code>:production</code>, can also be <code>:development</code>
+ Defaults to <code>:development</code>, traditionally one of <code>:development</code> or <code>:production</code>
+ but any environment string can be provided. Custom environments will use the defaults of the
+ <code>:development</code> environment unless overridden.
</td>
</tr>
<tr>
@@ -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
+ end
View
4 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
View
6 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.',
View
11 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|
Something went wrong with that request. Please try again.