compass 0.12.alpha.4 → 0.12.rc.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (53) hide show
  1. data/VERSION.yml +2 -2
  2. data/bin/compass +4 -0
  3. data/features/command_line.feature +0 -10
  4. data/features/extensions.feature +0 -10
  5. data/features/step_definitions/command_line_steps.rb +0 -12
  6. data/frameworks/compass/stylesheets/compass/css3/_background-clip.scss +2 -2
  7. data/frameworks/compass/stylesheets/compass/css3/_font-face.scss +1 -1
  8. data/lib/compass/app_integration.rb +26 -11
  9. data/lib/compass/commands/project_structure.rb +93 -0
  10. data/lib/compass/commands/update_project.rb +0 -1
  11. data/lib/compass/commands/watch_project.rb +6 -1
  12. data/lib/compass/compiler.rb +2 -1
  13. data/lib/compass/configuration.rb +6 -1
  14. data/lib/compass/configuration/data.rb +9 -3
  15. data/lib/compass/configuration/helpers.rb +7 -21
  16. data/lib/compass/configuration/inheritance.rb +101 -0
  17. data/lib/compass/configuration/serialization.rb +17 -7
  18. data/lib/compass/errors.rb +1 -0
  19. data/lib/compass/installers/manifest.rb +10 -5
  20. data/lib/compass/sass_extensions/functions/display.rb +1 -0
  21. data/lib/compass/sass_extensions/functions/trig.rb +1 -1
  22. data/lib/compass/sass_extensions/sprites.rb +0 -1
  23. data/lib/compass/sass_extensions/sprites/image.rb +1 -1
  24. data/lib/compass/sprite_importer.rb +4 -1
  25. data/test/fixtures/stylesheets/compass/css/background-clip.css +10 -0
  26. data/test/fixtures/stylesheets/compass/css/fonts.css +1 -1
  27. data/test/fixtures/stylesheets/compass/sass/background-clip.scss +8 -0
  28. data/test/test_helper.rb +2 -2
  29. data/test/units/compiler_test.rb +11 -0
  30. data/test/units/configuration_test.rb +144 -0
  31. data/test/units/sprites/sprite_command_test.rb +4 -3
  32. metadata +12 -30
  33. data/examples/compass/compass_app_log.txt +0 -6
  34. data/features/rails_integration.feature +0 -32
  35. data/lib/compass/app_integration/merb.rb +0 -1
  36. data/lib/compass/app_integration/merb/runtime.rb +0 -63
  37. data/lib/compass/app_integration/rails.rb +0 -83
  38. data/lib/compass/app_integration/rails/actionpack2x.rb +0 -10
  39. data/lib/compass/app_integration/rails/actionpack2x/action_controller.rb +0 -15
  40. data/lib/compass/app_integration/rails/actionpack2x/sass_plugin.rb +0 -5
  41. data/lib/compass/app_integration/rails/actionpack2x/urls.rb +0 -18
  42. data/lib/compass/app_integration/rails/actionpack30.rb +0 -11
  43. data/lib/compass/app_integration/rails/actionpack30/railtie.rb +0 -46
  44. data/lib/compass/app_integration/rails/actionpack31.rb +0 -5
  45. data/lib/compass/app_integration/rails/actionpack31/helpers.rb +0 -28
  46. data/lib/compass/app_integration/rails/actionpack31/railtie.rb +0 -87
  47. data/lib/compass/app_integration/rails/configuration_defaults.rb +0 -123
  48. data/lib/compass/app_integration/rails/installer.rb +0 -182
  49. data/lib/compass/app_integration/rails/runtime.rb +0 -17
  50. data/lib/compass/app_integration/rails/templates/compass-install-rails.rb +0 -78
  51. data/test/integrations/rails_integration_test.rb +0 -51
  52. data/test/integrations/test_rails_helper.rb +0 -20
  53. data/test/units/rails_configuration_test.rb +0 -50
@@ -1,182 +0,0 @@
1
- module Compass
2
- module Installers
3
- class Base
4
- end
5
- class ManifestInstaller < Base
6
- end
7
- end
8
-
9
- module AppIntegration
10
- module Rails
11
- class Installer < Compass::Installers::ManifestInstaller
12
-
13
- def completed_configuration
14
- config = {}
15
- config[:sass_dir] = prompt_sass_dir unless sass_dir_without_default
16
- config[:css_dir] = prompt_css_dir unless css_dir_without_default
17
- config unless config.empty?
18
- end
19
-
20
- def write_configuration_files(config_file = nil)
21
- config_file ||= targetize('config/compass.rb')
22
- unless File.exists?(config_file)
23
- directory File.dirname(config_file)
24
- write_file config_file, config_contents
25
- end
26
- unless rails3?
27
- directory File.dirname(targetize('config/initializers/compass.rb'))
28
- write_file targetize('config/initializers/compass.rb'), initializer_contents
29
- end
30
- end
31
-
32
- def rails3?
33
- File.exists?(targetize('config/application.rb'))
34
- end
35
-
36
- def prepare
37
- write_configuration_files
38
- end
39
-
40
- def gem_config_instructions
41
- if rails3?
42
- %Q{Add the following to your Gemfile:\n\n gem "compass", ">= #{Compass::VERSION}"}
43
- else
44
- %Q{Add the following to your environment.rb:\n\n config.gem "compass", :version => ">= #{Compass::VERSION}"}
45
- end
46
- end
47
-
48
- def finalize(options = {})
49
- if options[:create]
50
- puts <<-NEXTSTEPS
51
-
52
- Congratulations! Your rails project has been configured to use Compass.
53
- Just a couple more things left to do.
54
-
55
- #{gem_config_instructions}
56
-
57
- Then, make sure you restart your server.
58
-
59
- Sass will automatically compile your stylesheets during the next
60
- page request and keep them up to date when they change.
61
- NEXTSTEPS
62
- end
63
- unless options[:prepare]
64
- if manifest.has_stylesheet?
65
- puts "\nNow add these lines to the head of your layout(s):\n\n"
66
- puts stylesheet_links
67
- end
68
- end
69
- end
70
-
71
- def hamlize?
72
- # XXX Is there a better way to detect haml in a particular rails project?
73
- require 'haml'
74
- true
75
- rescue LoadError
76
- false
77
- end
78
-
79
- def install_location_for_html(to, options)
80
- separate("public/#{pattern_name_as_dir}#{to}")
81
- end
82
-
83
- def prompt_sass_dir
84
- if rails3?
85
- nil
86
- else
87
- recommended_location = separate('app/stylesheets')
88
- default_location = separate('public/stylesheets/sass')
89
- print %Q{Compass recommends that you keep your stylesheets in #{recommended_location}
90
- instead of the Sass default location of #{default_location}.
91
- Is this OK? (Y/n) }
92
- answer = $stdin.gets.downcase[0]
93
- answer == ?n ? default_location : recommended_location
94
- end
95
- end
96
-
97
- def prompt_css_dir
98
- if rails3?
99
- nil
100
- else
101
- recommended_location = separate("public/stylesheets/compiled")
102
- default_location = separate("public/stylesheets")
103
- puts
104
- print %Q{Compass recommends that you keep your compiled css in #{recommended_location}/
105
- instead the Sass default of #{default_location}/.
106
- However, if you're exclusively using Sass, then #{default_location}/ is recommended.
107
- Emit compiled stylesheets to #{recommended_location}/? (Y/n) }
108
- answer = $stdin.gets
109
- answer = answer.downcase[0]
110
- answer == ?n ? default_location : recommended_location
111
- end
112
- end
113
-
114
- def config_contents
115
- project_path, Compass.configuration.project_path = Compass.configuration.project_path, nil
116
- ("# This configuration file works with both the Compass command line tool and within Rails.\n" +
117
- Compass.configuration.serialize)
118
- ensure
119
- Compass.configuration.project_path = project_path
120
- end
121
-
122
- def initializer_contents
123
- %Q{require 'compass'
124
- |require 'compass/app_integration/rails'
125
- |Compass::AppIntegration::Rails.initialize!
126
- |}.gsub(/^\s+\|/,'')
127
- end
128
-
129
- def stylesheet_prefix
130
- if css_dir.length >= 19
131
- "#{css_dir[19..-1]}/"
132
- else
133
- nil
134
- end
135
- end
136
-
137
- def stylesheet_links
138
- if hamlize?
139
- haml_stylesheet_links
140
- else
141
- html_stylesheet_links
142
- end
143
- end
144
-
145
- def haml_stylesheet_links
146
- html = "%head\n"
147
- manifest.each_stylesheet do |stylesheet|
148
- # Skip partials.
149
- next if File.basename(stylesheet.from)[0..0] == "_"
150
- ss_line = " = stylesheet_link_tag '#{stylesheet_prefix}#{stylesheet.to.sub(/\.s[ac]ss$/,'.css')}'"
151
- if stylesheet.options[:media]
152
- ss_line += ", :media => '#{stylesheet.options[:media]}'"
153
- end
154
- if stylesheet.options[:condition]
155
- ss_line = " /[if #{stylesheet.options[:condition]}]\n " + ss_line
156
- end
157
- html << ss_line + "\n"
158
- end
159
- html
160
- end
161
- def html_stylesheet_links
162
- html = "<head>\n"
163
- manifest.each_stylesheet do |stylesheet|
164
- # Skip partials.
165
- next if File.basename(stylesheet.from)[0..0] == "_"
166
- ss_line = "<%= stylesheet_link_tag '#{stylesheet_prefix}#{stylesheet.to.sub(/\.s[ac]ss$/,'.css')}'"
167
- if stylesheet.options[:media]
168
- ss_line += ", :media => '#{stylesheet.options[:media]}'"
169
- end
170
- ss_line += " %>"
171
- if stylesheet.options[:condition]
172
- ss_line = "<!--[if #{stylesheet.options[:condition]}]>" + ss_line + "<![endif]-->"
173
- end
174
- html << " #{ss_line}\n"
175
- end
176
- html << "</head>"
177
- html
178
- end
179
- end
180
- end
181
- end
182
- end
@@ -1,17 +0,0 @@
1
- unless defined?(Compass::RAILS_LOADED)
2
- Compass::RAILS_LOADED = true
3
- begin
4
- require 'action_pack/version'
5
- if ActionPack::VERSION::MAJOR >= 3
6
- if ActionPack::VERSION::MINOR < 1
7
- require 'compass/app_integration/rails/actionpack30'
8
- else
9
- require 'compass/app_integration/rails/actionpack31'
10
- end
11
- else
12
- require 'compass/app_integration/rails/actionpack2x'
13
- end
14
- rescue LoadError, NameError => e
15
- $stderr.puts "Compass could not access the rails environment: #{e}"
16
- end
17
- end
@@ -1,78 +0,0 @@
1
- # =================================================================
2
- # Compass Ruby on Rails Installer (template) v.1.0
3
- # written by Derek Perez (derek@derekperez.com)
4
- # -----------------------------------------------------------------
5
- # NOTE: This installer is designed to work as a Rails template,
6
- # and can only be used with Rails 2.3+.
7
- # -----------------------------------------------------------------
8
- # Copyright (c) 2009 Derek Perez
9
- #
10
- # Permission is hereby granted, free of charge, to any person
11
- # obtaining a copy of this software and associated documentation
12
- # files (the "Software"), to deal in the Software without
13
- # restriction, including without limitation the rights to use,
14
- # copy, modify, merge, publish, distribute, sublicense, and/or sell
15
- # copies of the Software, and to permit persons to whom the
16
- # Software is furnished to do so, subject to the following
17
- # conditions:
18
- #
19
- # The above copyright notice and this permission notice shall be
20
- # included in all copies or substantial portions of the Software.
21
- #
22
- # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
23
- # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
24
- # OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
25
- # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
26
- # HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
27
- # WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
28
- # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
29
- # OTHER DEALINGS IN THE SOFTWARE.
30
- # =================================================================
31
-
32
- # Determine if we use sudo, defaults to true unless we are
33
- # on win32, cygwin, or mingw32 or they ask us not to
34
- def sudo_is_an_option?
35
- return false if RUBY_PLATFORM =~ /(win|w)32$/ # true if win32, cygwin or mingw32
36
- return false if ENV['NO_SUDO'] =~ /true/i
37
- return true
38
- end
39
-
40
- puts "==================================================="
41
- puts "Welcome to the Compass Installer for Ruby on Rails!"
42
- puts "==================================================="
43
- puts
44
-
45
- # css framework prompt
46
- css_framework = ask("What CSS Framework install do you want to use with Compass?")
47
-
48
- # sass storage prompt
49
- sass_dir = ask("Where would you like to keep your sass files within your project? (default: 'app/stylesheets')")
50
- sass_dir = "app/stylesheets" if Compass::Util.blank?(sass_dir)
51
-
52
- # compiled css storage prompt
53
- css_dir = ask("Where would you like Compass to store your compiled css files? (default: 'public/stylesheets/compiled')")
54
- css_dir = "public/stylesheets/compiled" if Compass::Util.blank?(css_dir)
55
-
56
- # use sudo for gem commands?
57
- use_sudo = nil
58
- if sudo_is_an_option? # dont give them the option if they are on a system that can't use sudo (aka windows)
59
- use_sudo = yes?("Use sudo for the gem commands? (the default for your system is #{sudo_is_an_option? ? 'yes' : 'no'})")
60
- end
61
- use_sudo = sudo_is_an_option? if Compass::Util.blank?(use_sudo)
62
-
63
- # define dependencies
64
- gem "haml", :version => ">=3.0.0"
65
- gem "compass", :version => ">= 0.10.0"
66
-
67
- # install and unpack
68
- rake "gems:install GEM=haml --trace", :sudo => use_sudo
69
- rake "gems:install GEM=compass --trace", :sudo => use_sudo
70
- rake "gems:unpack GEM=compass --trace"
71
-
72
- # build out compass command
73
- compass_command = "compass init rails . --css-dir=#{css_dir} --sass-dir=#{sass_dir} "
74
- compass_command << "--using #{css_framework} " unless Compass::Util.blank?(css_framework)
75
-
76
- # integrate it!
77
- run "haml --rails ."
78
- run compass_command
@@ -1,51 +0,0 @@
1
- require 'test_helper'
2
- require 'fileutils'
3
- require 'compass'
4
- require 'compass/exec'
5
- require 'timeout'
6
-
7
- class RailsIntegrationTest < Test::Unit::TestCase
8
- include Compass::CommandLineHelper
9
- include Compass::IoHelper
10
- include Compass::RailsHelper
11
-
12
- def setup
13
- Compass.reset_configuration!
14
- end
15
-
16
- def test_rails_install
17
- within_tmp_directory do
18
- begin
19
- generate_rails_app_directories("compass_rails")
20
- Dir.chdir "compass_rails" do
21
- compass(*%w(init rails --trace --boring .)) do |responder|
22
- responder.respond_to %r{^\s*Is this OK\? \(Y/n\)\s*$}, :with => "Y"
23
- responder.respond_to %r{^\s*Emit compiled stylesheets to public/stylesheets/compiled/\? \(Y/n\)\s*$}, :with => "Y"
24
- end
25
- # puts ">>>#{@last_result}<<<"
26
- assert_action_performed :create, "./app/stylesheets/screen.scss"
27
- assert_action_performed :create, "./config/initializers/compass.rb"
28
- end
29
- ensure
30
- FileUtils.rm_rf "compass_rails"
31
- end
32
- end
33
- rescue LoadError
34
- puts "Skipping rails test. Couldn't Load rails"
35
- rescue NotImplementedError => e
36
- puts "Skipping rails test: #{e}"
37
- end
38
-
39
- def test_rails_install_with_no_dialog
40
- within_tmp_directory do
41
- generate_rails_app_directories("compass_rails")
42
- Dir.chdir "compass_rails" do
43
- compass(*%w(init rails --trace --boring --sass-dir app/stylesheets --css-dir public/stylesheets/compiled .))
44
- assert_action_performed :create, "./app/stylesheets/screen.scss"
45
- assert_action_performed :create, "./config/initializers/compass.rb"
46
- end
47
- end
48
- rescue LoadError
49
- puts "Skipping rails test. Couldn't Load rails"
50
- end
51
- end
@@ -1,20 +0,0 @@
1
- # XXX This file isn't in use at the moment, but will be used to help test
2
- # XXX deep rails integration of compass features.
3
- need_gems = false
4
-
5
- # allows testing with edge Rails by creating a test/rails symlink
6
- RAILS_ROOT = linked_rails = File.dirname(__FILE__) + '/rails'
7
- RAILS_ENV = 'test'
8
-
9
- if File.exists?(linked_rails) && !$:.include?(linked_rails + '/activesupport/lib')
10
- puts "[ using linked Rails ]"
11
- $:.unshift linked_rails + '/activesupport/lib'
12
- $:.unshift linked_rails + '/actionpack/lib'
13
- else
14
- need_gems = true
15
- end
16
-
17
- require 'rubygems' if need_gems
18
-
19
- require 'action_controller'
20
- require 'action_view'
@@ -1,50 +0,0 @@
1
- require 'test_helper'
2
- require 'compass'
3
- require 'stringio'
4
-
5
- class ConfigurationTest < Test::Unit::TestCase
6
-
7
- setup do
8
- Compass.reset_configuration!
9
- end
10
-
11
- after do
12
- Compass.reset_configuration!
13
- end
14
-
15
- def test_defaults
16
- contents = StringIO.new(<<-CONFIG)
17
- project_type = :rails
18
- CONFIG
19
- config = Compass.configuration_for(contents, "config/compass.rb")
20
-
21
- Compass.add_project_configuration(config, :project_type => "rails")
22
-
23
- assert_equal 'public/images', Compass.configuration.images_dir
24
- assert_equal 'public/stylesheets', Compass.configuration.css_dir
25
- assert_equal 'public/fonts', Compass.configuration.fonts_dir
26
-
27
- assert_equal '/', Compass.configuration.http_path
28
- assert_equal '/images', Compass.configuration.http_images_path
29
- assert_equal '/stylesheets', Compass.configuration.http_stylesheets_path
30
- assert_equal '/fonts', Compass.configuration.http_fonts_path
31
-
32
- # Other default values must wait until I have a better idea of how to mock Sass::Util.app_geq
33
- end
34
-
35
- def test_http_path_change
36
- contents = StringIO.new(<<-CONFIG)
37
- project_type = :rails
38
-
39
- http_path = "/test/alternative_path"
40
- CONFIG
41
- config = Compass.configuration_for(contents, "config/compass.rb")
42
-
43
- Compass.add_project_configuration(config, :project_type => "rails")
44
-
45
- assert_equal '/test/alternative_path', Compass.configuration.http_path
46
- assert_equal '/test/alternative_path/images', Compass.configuration.http_images_path
47
- assert_equal '/test/alternative_path/stylesheets', Compass.configuration.http_stylesheets_path
48
- assert_equal '/test/alternative_path/fonts', Compass.configuration.http_fonts_path
49
- end
50
- end