alphasights-compass 0.8.12
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.markdown +528 -0
- data/LICENSE.markdown +29 -0
- data/README.markdown +44 -0
- data/REVISION +1 -0
- data/Rakefile +127 -0
- data/VERSION.yml +4 -0
- data/bin/compass +8 -0
- data/deps.rip +1 -0
- data/examples/README.markdown +4 -0
- data/examples/blueprint_default/config.rb +7 -0
- data/examples/blueprint_default/images/grid.png +0 -0
- data/examples/blueprint_default/index.html.haml +85 -0
- data/examples/blueprint_default/parts/elements.html.haml +282 -0
- data/examples/blueprint_default/parts/forms.html.haml +190 -0
- data/examples/blueprint_default/parts/grid.html.haml +274 -0
- data/examples/blueprint_default/parts/test-small.jpg +0 -0
- data/examples/blueprint_default/parts/test.jpg +0 -0
- data/examples/blueprint_default/parts/valid.png +0 -0
- data/examples/blueprint_default/src/ie.sass +3 -0
- data/examples/blueprint_default/src/images/grid.png +0 -0
- data/examples/blueprint_default/src/print.sass +3 -0
- data/examples/blueprint_default/src/screen.sass +8 -0
- data/examples/blueprint_plugins/config.rb +8 -0
- data/examples/blueprint_plugins/images/buttons/cross.png +0 -0
- data/examples/blueprint_plugins/images/buttons/key.png +0 -0
- data/examples/blueprint_plugins/images/buttons/tick.png +0 -0
- data/examples/blueprint_plugins/images/grid.png +0 -0
- data/examples/blueprint_plugins/images/link_icons/doc.png +0 -0
- data/examples/blueprint_plugins/images/link_icons/email.png +0 -0
- data/examples/blueprint_plugins/images/link_icons/external.png +0 -0
- data/examples/blueprint_plugins/images/link_icons/feed.png +0 -0
- data/examples/blueprint_plugins/images/link_icons/im.png +0 -0
- data/examples/blueprint_plugins/images/link_icons/pdf.png +0 -0
- data/examples/blueprint_plugins/images/link_icons/visited.png +0 -0
- data/examples/blueprint_plugins/images/link_icons/xls.png +0 -0
- data/examples/blueprint_plugins/images/test-small.jpg +0 -0
- data/examples/blueprint_plugins/images/test.jpg +0 -0
- data/examples/blueprint_plugins/images/valid.png +0 -0
- data/examples/blueprint_plugins/index.html.haml +96 -0
- data/examples/blueprint_plugins/plugins/buttons.html.haml +67 -0
- data/examples/blueprint_plugins/plugins/fancy_type.html.haml +100 -0
- data/examples/blueprint_plugins/plugins/link_icons.html.haml +61 -0
- data/examples/blueprint_plugins/plugins/rtl.html.haml +100 -0
- data/examples/blueprint_plugins/src/buttons.sass +49 -0
- data/examples/blueprint_plugins/src/ie.sass +3 -0
- data/examples/blueprint_plugins/src/images/grid.png +0 -0
- data/examples/blueprint_plugins/src/link_icons.sass +13 -0
- data/examples/blueprint_plugins/src/print.sass +3 -0
- data/examples/blueprint_plugins/src/rtl_screen.sass +13 -0
- data/examples/blueprint_plugins/src/screen.sass +11 -0
- data/examples/blueprint_scoped/images/grid.png +0 -0
- data/examples/blueprint_scoped/src/ie.sass +3 -0
- data/examples/blueprint_scoped/src/print.sass +3 -0
- data/examples/blueprint_scoped/src/screen.sass +4 -0
- data/examples/blueprint_scoped_form/images/grid.png +0 -0
- data/examples/blueprint_scoped_form/src/ie.sass +3 -0
- data/examples/blueprint_scoped_form/src/print.sass +3 -0
- data/examples/blueprint_scoped_form/src/screen.sass +10 -0
- data/examples/blueprint_semantic/config.rb +7 -0
- data/examples/blueprint_semantic/images/grid.png +0 -0
- data/examples/blueprint_semantic/index.html.haml +86 -0
- data/examples/blueprint_semantic/parts/fancy_type.html.haml +100 -0
- data/examples/blueprint_semantic/parts/liquid.html.haml +100 -0
- data/examples/blueprint_semantic/parts/test-small.jpg +0 -0
- data/examples/blueprint_semantic/parts/test.jpg +0 -0
- data/examples/blueprint_semantic/parts/valid.png +0 -0
- data/examples/blueprint_semantic/src/ie.sass +3 -0
- data/examples/blueprint_semantic/src/images/grid.png +0 -0
- data/examples/blueprint_semantic/src/liquid.sass +70 -0
- data/examples/blueprint_semantic/src/print.sass +3 -0
- data/examples/blueprint_semantic/src/screen.sass +71 -0
- data/examples/compass/compass.html.haml +39 -0
- data/examples/compass/config.rb +7 -0
- data/examples/compass/images/blue_arrow.gif +0 -0
- data/examples/compass/src/compass.sass +47 -0
- data/examples/compass/src/images/blue_arrow.gif +0 -0
- data/examples/compass/src/sticky_footer.sass +11 -0
- data/examples/compass/src/utilities.sass +108 -0
- data/examples/compass/sticky_footer.html.haml +14 -0
- data/examples/compass/utilities.html.haml +189 -0
- data/examples/logo/logo.html.haml +40 -0
- data/examples/logo/src/ie.sass +6 -0
- data/examples/logo/src/print.sass +6 -0
- data/examples/logo/src/screen.sass +29 -0
- data/examples/yui/divisions.html.haml +179 -0
- data/examples/yui/index.html.haml +19 -0
- data/examples/yui/src/screen.sass +13 -0
- data/examples/yui/sub_divisions.html.haml +169 -0
- data/examples/yui/templates.html.haml +54 -0
- data/examples/yui/test.jpg +0 -0
- data/examples/yui/typography.html.haml +132 -0
- data/frameworks/blueprint.rb +2 -0
- data/frameworks/blueprint/stylesheets/_blueprint.sass +3 -0
- data/frameworks/blueprint/stylesheets/blueprint/_ie.sass +93 -0
- data/frameworks/blueprint/stylesheets/blueprint/_print.sass +83 -0
- data/frameworks/blueprint/stylesheets/blueprint/_reset.sass +3 -0
- data/frameworks/blueprint/stylesheets/blueprint/_screen.sass +15 -0
- data/frameworks/blueprint/stylesheets/blueprint/modules/_buttons.sass +84 -0
- data/frameworks/blueprint/stylesheets/blueprint/modules/_colors.sass +33 -0
- data/frameworks/blueprint/stylesheets/blueprint/modules/_debug.sass +9 -0
- data/frameworks/blueprint/stylesheets/blueprint/modules/_fancy_type.sass +82 -0
- data/frameworks/blueprint/stylesheets/blueprint/modules/_form.sass +55 -0
- data/frameworks/blueprint/stylesheets/blueprint/modules/_grid.sass +168 -0
- data/frameworks/blueprint/stylesheets/blueprint/modules/_interaction.sass +58 -0
- data/frameworks/blueprint/stylesheets/blueprint/modules/_link_icons.sass +44 -0
- data/frameworks/blueprint/stylesheets/blueprint/modules/_liquid.sass +141 -0
- data/frameworks/blueprint/stylesheets/blueprint/modules/_reset.sass +56 -0
- data/frameworks/blueprint/stylesheets/blueprint/modules/_rtl.sass +104 -0
- data/frameworks/blueprint/stylesheets/blueprint/modules/_scaffolding.sass +47 -0
- data/frameworks/blueprint/stylesheets/blueprint/modules/_typography.sass +155 -0
- data/frameworks/blueprint/stylesheets/blueprint/modules/_utilities.sass +37 -0
- data/frameworks/blueprint/templates/buttons/buttons.sass +49 -0
- data/frameworks/blueprint/templates/buttons/buttons/cross.png +0 -0
- data/frameworks/blueprint/templates/buttons/buttons/key.png +0 -0
- data/frameworks/blueprint/templates/buttons/buttons/tick.png +0 -0
- data/frameworks/blueprint/templates/buttons/manifest.rb +5 -0
- data/frameworks/blueprint/templates/link_icons/link_icons.sass +13 -0
- data/frameworks/blueprint/templates/link_icons/link_icons/doc.png +0 -0
- data/frameworks/blueprint/templates/link_icons/link_icons/email.png +0 -0
- data/frameworks/blueprint/templates/link_icons/link_icons/external.png +0 -0
- data/frameworks/blueprint/templates/link_icons/link_icons/feed.png +0 -0
- data/frameworks/blueprint/templates/link_icons/link_icons/im.png +0 -0
- data/frameworks/blueprint/templates/link_icons/link_icons/pdf.png +0 -0
- data/frameworks/blueprint/templates/link_icons/link_icons/visited.png +0 -0
- data/frameworks/blueprint/templates/link_icons/link_icons/xls.png +0 -0
- data/frameworks/blueprint/templates/link_icons/manifest.rb +10 -0
- data/frameworks/blueprint/templates/project/grid.png +0 -0
- data/frameworks/blueprint/templates/project/ie.sass +15 -0
- data/frameworks/blueprint/templates/project/manifest.rb +6 -0
- data/frameworks/blueprint/templates/project/partials/_base.sass +11 -0
- data/frameworks/blueprint/templates/project/print.sass +3 -0
- data/frameworks/blueprint/templates/project/screen.sass +40 -0
- data/frameworks/compass.rb +2 -0
- data/frameworks/compass/stylesheets/_compass.sass +1 -0
- data/frameworks/compass/stylesheets/compass/_layout.sass +1 -0
- data/frameworks/compass/stylesheets/compass/_misc.sass +24 -0
- data/frameworks/compass/stylesheets/compass/_reset.sass +3 -0
- data/frameworks/compass/stylesheets/compass/_utilities.sass +6 -0
- data/frameworks/compass/stylesheets/compass/layout/_sticky_footer.sass +17 -0
- data/frameworks/compass/stylesheets/compass/utilities/_general.sass +6 -0
- data/frameworks/compass/stylesheets/compass/utilities/_links.sass +3 -0
- data/frameworks/compass/stylesheets/compass/utilities/_lists.sass +3 -0
- data/frameworks/compass/stylesheets/compass/utilities/_print.sass +24 -0
- data/frameworks/compass/stylesheets/compass/utilities/_sprites.sass +1 -0
- data/frameworks/compass/stylesheets/compass/utilities/_tables.sass +3 -0
- data/frameworks/compass/stylesheets/compass/utilities/_text.sass +2 -0
- data/frameworks/compass/stylesheets/compass/utilities/general/_clearfix.sass +24 -0
- data/frameworks/compass/stylesheets/compass/utilities/general/_float.sass +17 -0
- data/frameworks/compass/stylesheets/compass/utilities/general/_hacks.sass +6 -0
- data/frameworks/compass/stylesheets/compass/utilities/general/_inline_block.sass +6 -0
- data/frameworks/compass/stylesheets/compass/utilities/general/_reset.sass +134 -0
- data/frameworks/compass/stylesheets/compass/utilities/general/_tabs.sass +0 -0
- data/frameworks/compass/stylesheets/compass/utilities/general/_tag_cloud.sass +19 -0
- data/frameworks/compass/stylesheets/compass/utilities/links/_hover_link.sass +5 -0
- data/frameworks/compass/stylesheets/compass/utilities/links/_link_colors.sass +24 -0
- data/frameworks/compass/stylesheets/compass/utilities/links/_unstyled_link.sass +5 -0
- data/frameworks/compass/stylesheets/compass/utilities/lists/_bullets.sass +21 -0
- data/frameworks/compass/stylesheets/compass/utilities/lists/_horizontal_list.sass +52 -0
- data/frameworks/compass/stylesheets/compass/utilities/lists/_inline_list.sass +29 -0
- data/frameworks/compass/stylesheets/compass/utilities/sprites/_sprite_img.sass +12 -0
- data/frameworks/compass/stylesheets/compass/utilities/tables/_alternating_rows_and_columns.sass +20 -0
- data/frameworks/compass/stylesheets/compass/utilities/tables/_borders.sass +27 -0
- data/frameworks/compass/stylesheets/compass/utilities/tables/_scaffolding.sass +9 -0
- data/frameworks/compass/stylesheets/compass/utilities/text/_ellipsis.sass +13 -0
- data/frameworks/compass/stylesheets/compass/utilities/text/_nowrap.sass +3 -0
- data/frameworks/compass/stylesheets/compass/utilities/text/_replacement.sass +17 -0
- data/frameworks/compass/templates/ellipsis/ellipsis.sass +6 -0
- data/frameworks/compass/templates/ellipsis/manifest.rb +2 -0
- data/frameworks/compass/templates/ellipsis/xml/ellipsis.xml +14 -0
- data/frameworks/compass/templates/project/ie.sass +6 -0
- data/frameworks/compass/templates/project/manifest.rb +3 -0
- data/frameworks/compass/templates/project/print.sass +6 -0
- data/frameworks/compass/templates/project/screen.sass +13 -0
- data/frameworks/yui.rb +2 -0
- data/frameworks/yui/stylesheets/_yui.sass +7 -0
- data/frameworks/yui/stylesheets/yui/modules/_base.sass +60 -0
- data/frameworks/yui/stylesheets/yui/modules/_fonts.sass +38 -0
- data/frameworks/yui/stylesheets/yui/modules/_grids.sass +341 -0
- data/frameworks/yui/stylesheets/yui/modules/_reset.sass +61 -0
- data/frameworks/yui/templates/project/manifest.rb +1 -0
- data/frameworks/yui/templates/project/screen.sass +4 -0
- data/lib/compass.rb +23 -0
- data/lib/compass/actions.rb +110 -0
- data/lib/compass/app_integration.rb +5 -0
- data/lib/compass/app_integration/merb.rb +43 -0
- data/lib/compass/app_integration/rails.rb +12 -0
- data/lib/compass/app_integration/rails/action_controller.rb +15 -0
- data/lib/compass/app_integration/rails/sass_plugin.rb +5 -0
- data/lib/compass/app_integration/rails/templates/compass-install-rails.rb +80 -0
- data/lib/compass/app_integration/rails/urls.rb +14 -0
- data/lib/compass/commands/base.rb +33 -0
- data/lib/compass/commands/create_project.rb +19 -0
- data/lib/compass/commands/generate_grid_background.rb +24 -0
- data/lib/compass/commands/installer_command.rb +31 -0
- data/lib/compass/commands/list_frameworks.rb +16 -0
- data/lib/compass/commands/print_version.rb +23 -0
- data/lib/compass/commands/project_base.rb +112 -0
- data/lib/compass/commands/stamp_pattern.rb +33 -0
- data/lib/compass/commands/update_project.rb +34 -0
- data/lib/compass/commands/validate_project.rb +21 -0
- data/lib/compass/commands/watch_project.rb +50 -0
- data/lib/compass/commands/write_configuration.rb +28 -0
- data/lib/compass/compiler.rb +54 -0
- data/lib/compass/configuration.rb +324 -0
- data/lib/compass/core_ext.rb +14 -0
- data/lib/compass/dependencies.rb +10 -0
- data/lib/compass/errors.rb +7 -0
- data/lib/compass/exec.rb +251 -0
- data/lib/compass/frameworks.rb +29 -0
- data/lib/compass/grid_builder.rb +72 -0
- data/lib/compass/installers.rb +5 -0
- data/lib/compass/installers/base.rb +158 -0
- data/lib/compass/installers/manifest.rb +58 -0
- data/lib/compass/installers/rails.rb +135 -0
- data/lib/compass/installers/stand_alone.rb +60 -0
- data/lib/compass/logger.rb +42 -0
- data/lib/compass/sass_extensions.rb +5 -0
- data/lib/compass/sass_extensions/functions.rb +19 -0
- data/lib/compass/sass_extensions/functions/display.rb +22 -0
- data/lib/compass/sass_extensions/functions/enumerate.rb +6 -0
- data/lib/compass/sass_extensions/functions/inline_image.rb +35 -0
- data/lib/compass/sass_extensions/functions/selectors.rb +39 -0
- data/lib/compass/sass_extensions/functions/urls.rb +105 -0
- data/lib/compass/sass_extensions/monkey_patches.rb +3 -0
- data/lib/compass/sass_extensions/monkey_patches/stylesheet_updating.rb +23 -0
- data/lib/compass/test_case.rb +38 -0
- data/lib/compass/validator.rb +10 -0
- data/lib/compass/version.rb +57 -0
- data/test/command_line_helper.rb +102 -0
- data/test/command_line_test.rb +66 -0
- data/test/compass_test.rb +141 -0
- data/test/configuration_test.rb +118 -0
- data/test/fixtures/stylesheets/blueprint/config.rb +9 -0
- data/test/fixtures/stylesheets/blueprint/css/typography.css +158 -0
- data/test/fixtures/stylesheets/blueprint/images/grid.png +0 -0
- data/test/fixtures/stylesheets/blueprint/sass/ie.sass +3 -0
- data/test/fixtures/stylesheets/blueprint/sass/print.sass +3 -0
- data/test/fixtures/stylesheets/blueprint/sass/screen.sass +17 -0
- data/test/fixtures/stylesheets/blueprint/sass/typography.sass +3 -0
- data/test/fixtures/stylesheets/compass/config.rb +9 -0
- data/test/fixtures/stylesheets/compass/css/layout.css +13 -0
- data/test/fixtures/stylesheets/compass/css/print.css +18 -0
- data/test/fixtures/stylesheets/compass/css/reset.css +60 -0
- data/test/fixtures/stylesheets/compass/css/utilities.css +17 -0
- data/test/fixtures/stylesheets/compass/sass/layout.sass +3 -0
- data/test/fixtures/stylesheets/compass/sass/print.sass +5 -0
- data/test/fixtures/stylesheets/compass/sass/reset.sass +10 -0
- data/test/fixtures/stylesheets/compass/sass/utilities.sass +6 -0
- data/test/fixtures/stylesheets/image_urls/config.rb +17 -0
- data/test/fixtures/stylesheets/image_urls/css/screen.css +3 -0
- data/test/fixtures/stylesheets/image_urls/images/grid.png +0 -0
- data/test/fixtures/stylesheets/image_urls/sass/screen.sass +6 -0
- data/test/fixtures/stylesheets/yui/config.rb +9 -0
- data/test/fixtures/stylesheets/yui/css/mixins.css +13 -0
- data/test/fixtures/stylesheets/yui/sass/base.sass +3 -0
- data/test/fixtures/stylesheets/yui/sass/fonts.sass +3 -0
- data/test/fixtures/stylesheets/yui/sass/grids.sass +3 -0
- data/test/fixtures/stylesheets/yui/sass/mixins.sass +16 -0
- data/test/rails_integration_test.rb +83 -0
- data/test/sass_extensions_test.rb +31 -0
- data/test/test_case_helper.rb +13 -0
- data/test/test_helper.rb +21 -0
- data/test/test_rails_helper.rb +20 -0
- metadata +359 -0
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'sass/plugin'
|
2
|
+
|
3
|
+
# XXX: We can remove this monkeypatch once Sass 2.2 is released.
|
4
|
+
module Sass::Plugin
|
5
|
+
class << self
|
6
|
+
unless method_defined?(:exact_stylesheet_needs_update?)
|
7
|
+
def stylesheet_needs_update?(name, template_path, css_path)
|
8
|
+
css_file = css_filename(name, css_path)
|
9
|
+
template_file = template_filename(name, template_path)
|
10
|
+
exact_stylesheet_needs_update?(css_file, template_file)
|
11
|
+
end
|
12
|
+
def exact_stylesheet_needs_update?(css_file, template_file)
|
13
|
+
if !File.exists?(css_file)
|
14
|
+
return true
|
15
|
+
else
|
16
|
+
css_mtime = File.mtime(css_file)
|
17
|
+
File.mtime(template_file) > css_mtime ||
|
18
|
+
dependencies(template_file).any?(&dependency_updated?(css_mtime))
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,38 @@
|
|
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 < (defined?(ActiveSupport::TestCase) ? ActiveSupport::TestCase : Test::Unit::TestCase)
|
19
|
+
|
20
|
+
def setup
|
21
|
+
super
|
22
|
+
@last_compile = nil
|
23
|
+
end
|
24
|
+
|
25
|
+
def compile(stylesheet)
|
26
|
+
input = open(stylesheet)
|
27
|
+
template = input.read()
|
28
|
+
input.close()
|
29
|
+
@last_compile = ::Sass::Engine.new(template, ::Sass::Plugin.engine_options(:filename => stylesheet)).render
|
30
|
+
yield @last_compile if block_given?
|
31
|
+
end
|
32
|
+
|
33
|
+
def assert_compiles(stylesheet, &block)
|
34
|
+
compile(stylesheet, &block)
|
35
|
+
end
|
36
|
+
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,57 @@
|
|
1
|
+
module Compass
|
2
|
+
module Version
|
3
|
+
# Returns a hash representing the version.
|
4
|
+
# The :major, :minor, and :teeny keys have their respective numbers.
|
5
|
+
# The :string key contains a human-readable string representation of the version.
|
6
|
+
# The :rev key will have the current revision hash.
|
7
|
+
#
|
8
|
+
# This method swiped from Haml and then modified, some credit goes to Nathan Weizenbaum
|
9
|
+
attr_writer :version
|
10
|
+
def version
|
11
|
+
return @version if defined?(@version)
|
12
|
+
|
13
|
+
read_version_file
|
14
|
+
|
15
|
+
if r = revision
|
16
|
+
@version[:rev] = r
|
17
|
+
@version[:string] << " [#{r[0...7]}]"
|
18
|
+
end
|
19
|
+
|
20
|
+
@version
|
21
|
+
end
|
22
|
+
|
23
|
+
protected
|
24
|
+
|
25
|
+
def scope(file) # :nodoc:
|
26
|
+
File.join(File.dirname(__FILE__), '..', '..', file)
|
27
|
+
end
|
28
|
+
|
29
|
+
def read_version_file
|
30
|
+
require 'yaml'
|
31
|
+
@version = YAML::load(File.read(scope('VERSION.yml')))
|
32
|
+
@version[:string] = "#{@version[:major]}.#{@version[:minor]}.#{@version[:patch]}"
|
33
|
+
@version[:teeny] = @version[:patch]
|
34
|
+
end
|
35
|
+
|
36
|
+
def revision
|
37
|
+
revision_from_git || revision_from_file
|
38
|
+
end
|
39
|
+
|
40
|
+
def revision_from_file
|
41
|
+
if File.exists?(scope('REVISION'))
|
42
|
+
rev = File.read(scope('REVISION')).strip
|
43
|
+
rev if rev =~ /[a-f0-9]+/
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
def revision_from_git
|
48
|
+
if File.exists?(scope('.git/HEAD'))
|
49
|
+
rev = File.read(scope('.git/HEAD')).strip
|
50
|
+
if rev =~ /^ref: (.*)$/
|
51
|
+
rev = File.read(scope(".git/#{$1}")).strip
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
end
|
57
|
+
end
|
@@ -0,0 +1,102 @@
|
|
1
|
+
module Compass::CommandLineHelper
|
2
|
+
def compass(*arguments)
|
3
|
+
options = arguments.last.is_a?(Hash) ? arguments.pop : {}
|
4
|
+
options[:wait] = 0.25
|
5
|
+
if block_given?
|
6
|
+
responder = Responder.new
|
7
|
+
yield responder
|
8
|
+
IO.popen("-", "w+") do |io|
|
9
|
+
if io
|
10
|
+
#parent process
|
11
|
+
output = ""
|
12
|
+
eof_at = nil
|
13
|
+
while !eof_at || (Time.now - eof_at < options[:wait])
|
14
|
+
if io.eof?
|
15
|
+
eof_at ||= Time.now
|
16
|
+
sleep 0.1
|
17
|
+
else
|
18
|
+
eof_at = nil
|
19
|
+
timeout(1) do
|
20
|
+
output << io.readpartial(1024)
|
21
|
+
end
|
22
|
+
prompt = output.split("\n").last
|
23
|
+
if response = responder.response_for(prompt)
|
24
|
+
io.puts response
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
responder.assert_required_responses!
|
29
|
+
@last_result = output
|
30
|
+
else
|
31
|
+
#child process
|
32
|
+
execute *arguments
|
33
|
+
end
|
34
|
+
end
|
35
|
+
else
|
36
|
+
@last_result = capture_output do
|
37
|
+
execute *arguments
|
38
|
+
end
|
39
|
+
end
|
40
|
+
rescue Timeout::Error
|
41
|
+
fail "Read from child process timed out"
|
42
|
+
end
|
43
|
+
|
44
|
+
class Responder
|
45
|
+
Response = Struct.new(:prompt, :text, :required, :responded)
|
46
|
+
def initialize
|
47
|
+
@responses = []
|
48
|
+
end
|
49
|
+
def respond_to(prompt, options = {})
|
50
|
+
@responses << Response.new(prompt, options[:with], options[:required])
|
51
|
+
end
|
52
|
+
def response_for(prompt)
|
53
|
+
response = @responses.detect{|r| r.prompt == prompt}
|
54
|
+
if response
|
55
|
+
response.responded = true
|
56
|
+
response.text
|
57
|
+
end
|
58
|
+
end
|
59
|
+
def assert_required_responses!
|
60
|
+
@responses.each do |response|
|
61
|
+
if response.required && !response.responded
|
62
|
+
raise "Prompt not encountered: \"#{response.prompt}\""
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
def assert_action_performed(action, path)
|
69
|
+
actions_found = []
|
70
|
+
@last_result.split("\n").each do |line|
|
71
|
+
line = line.split
|
72
|
+
return if line.first == action.to_s && line.last == path
|
73
|
+
actions_found << line.first if line.last == path
|
74
|
+
end
|
75
|
+
message = "Action #{action.inspect} was not performed on: #{path}."
|
76
|
+
message += "The following actions were performed: #{actions_found.join(", ")}" if actions_found.any?
|
77
|
+
puts @last_result
|
78
|
+
fail message
|
79
|
+
end
|
80
|
+
|
81
|
+
def within_tmp_directory(dir = "tmp")
|
82
|
+
d = absolutize(dir)
|
83
|
+
FileUtils.mkdir_p(d)
|
84
|
+
Dir.chdir(d) do
|
85
|
+
yield
|
86
|
+
end
|
87
|
+
ensure
|
88
|
+
FileUtils.rm_rf(d)
|
89
|
+
end
|
90
|
+
|
91
|
+
def capture_output
|
92
|
+
real_stdout, $stdout = $stdout, StringIO.new
|
93
|
+
yield
|
94
|
+
$stdout.string
|
95
|
+
ensure
|
96
|
+
$stdout = real_stdout
|
97
|
+
end
|
98
|
+
|
99
|
+
def execute(*arguments)
|
100
|
+
Compass::Exec::Compass.new(arguments).run!
|
101
|
+
end
|
102
|
+
end
|
@@ -0,0 +1,66 @@
|
|
1
|
+
require File.dirname(__FILE__)+'/test_helper'
|
2
|
+
require 'fileutils'
|
3
|
+
require 'compass'
|
4
|
+
require 'compass/exec'
|
5
|
+
require 'timeout'
|
6
|
+
|
7
|
+
class CommandLineTest < Test::Unit::TestCase
|
8
|
+
include Compass::TestCaseHelper
|
9
|
+
include Compass::CommandLineHelper
|
10
|
+
|
11
|
+
def teardown
|
12
|
+
Compass.configuration.reset!
|
13
|
+
end
|
14
|
+
|
15
|
+
def test_print_version
|
16
|
+
compass "-vq"
|
17
|
+
assert_match /\d+\.\d+\.\d+( [0-9a-f]+)?/, @last_result
|
18
|
+
end
|
19
|
+
|
20
|
+
def test_list_frameworks
|
21
|
+
compass "--list-frameworks"
|
22
|
+
assert_equal(%w(blueprint compass yui), @last_result.split.sort)
|
23
|
+
end
|
24
|
+
|
25
|
+
def test_basic_install
|
26
|
+
within_tmp_directory do
|
27
|
+
compass "basic"
|
28
|
+
assert File.exists?("basic/src/screen.sass")
|
29
|
+
assert File.exists?("basic/stylesheets/screen.css")
|
30
|
+
assert_action_performed :directory, "basic/"
|
31
|
+
assert_action_performed :create, "basic/src/screen.sass"
|
32
|
+
assert_action_performed :compile, "basic/src/screen.sass"
|
33
|
+
assert_action_performed :create, "basic/stylesheets/screen.css"
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
def test_framework_installs
|
38
|
+
Compass::Frameworks::ALL.each do |framework|
|
39
|
+
within_tmp_directory do
|
40
|
+
compass *%W(--framework #{framework.name} #{framework.name}_project)
|
41
|
+
assert File.exists?("#{framework.name}_project/src/screen.sass")
|
42
|
+
assert File.exists?("#{framework.name}_project/stylesheets/screen.css")
|
43
|
+
assert_action_performed :directory, "#{framework.name}_project/"
|
44
|
+
assert_action_performed :create, "#{framework.name}_project/src/screen.sass"
|
45
|
+
assert_action_performed :compile, "#{framework.name}_project/src/screen.sass"
|
46
|
+
assert_action_performed :create, "#{framework.name}_project/stylesheets/screen.css"
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
def test_basic_update
|
52
|
+
within_tmp_directory do
|
53
|
+
compass "basic"
|
54
|
+
Dir.chdir "basic" do
|
55
|
+
# basic update with timestamp caching
|
56
|
+
compass
|
57
|
+
assert_action_performed :unchanged, "src/screen.sass"
|
58
|
+
# basic update with force option set
|
59
|
+
compass "--force"
|
60
|
+
assert_action_performed :compile, "src/screen.sass"
|
61
|
+
assert_action_performed :identical, "stylesheets/screen.css"
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
end
|
@@ -0,0 +1,141 @@
|
|
1
|
+
require File.dirname(__FILE__)+'/test_helper'
|
2
|
+
require 'fileutils'
|
3
|
+
require 'compass'
|
4
|
+
|
5
|
+
class CompassTest < Test::Unit::TestCase
|
6
|
+
include Compass::TestCaseHelper
|
7
|
+
def setup
|
8
|
+
Compass.configuration.reset!
|
9
|
+
end
|
10
|
+
|
11
|
+
def teardown
|
12
|
+
teardown_fixtures :blueprint, :yui, :empty, :compass, :image_urls
|
13
|
+
end
|
14
|
+
|
15
|
+
def teardown_fixtures(*project_names)
|
16
|
+
project_names.each do |project_name|
|
17
|
+
FileUtils.rm_rf tempfile_path(project_name)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def test_empty_project
|
22
|
+
# With no sass files, we should have no css files.
|
23
|
+
within_project(:empty) do |proj|
|
24
|
+
return unless proj.css_path && File.exists?(proj.css_path)
|
25
|
+
Dir.new(proj.css_path).each do |f|
|
26
|
+
fail "This file should not have been generated: #{f}" unless f == "." || f == ".."
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
def test_blueprint
|
32
|
+
within_project(:blueprint) do |proj|
|
33
|
+
each_css_file(proj.css_path) do |css_file|
|
34
|
+
assert_no_errors css_file, :blueprint
|
35
|
+
end
|
36
|
+
assert_renders_correctly :typography
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
def test_yui
|
41
|
+
within_project('yui') do |proj|
|
42
|
+
each_css_file(proj.css_path) do |css_file|
|
43
|
+
assert_no_errors css_file, 'yui'
|
44
|
+
end
|
45
|
+
assert_renders_correctly :mixins
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
def test_compass
|
50
|
+
within_project('compass') do |proj|
|
51
|
+
each_css_file(proj.css_path) do |css_file|
|
52
|
+
assert_no_errors css_file, 'compass'
|
53
|
+
end
|
54
|
+
assert_renders_correctly :reset, :layout, :utilities
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
def test_image_urls
|
59
|
+
within_project('image_urls') do |proj|
|
60
|
+
each_css_file(proj.css_path) do |css_file|
|
61
|
+
assert_no_errors css_file, 'image_urls'
|
62
|
+
end
|
63
|
+
assert_renders_correctly :screen
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
private
|
68
|
+
def assert_no_errors(css_file, project_name)
|
69
|
+
file = css_file[(tempfile_path(project_name).size+1)..-1]
|
70
|
+
msg = "Syntax Error found in #{file}. Results saved into #{save_path(project_name)}/#{file}"
|
71
|
+
assert_equal 0, open(css_file).readlines.grep(/Sass::SyntaxError/).size, msg
|
72
|
+
end
|
73
|
+
|
74
|
+
def assert_renders_correctly(*arguments)
|
75
|
+
options = arguments.last.is_a?(Hash) ? arguments.pop : {}
|
76
|
+
for name in arguments
|
77
|
+
actual_result_file = "#{tempfile_path(@current_project)}/#{name}.css"
|
78
|
+
expected_result_file = "#{result_path(@current_project)}/#{name}.css"
|
79
|
+
actual_lines = File.read(actual_result_file).split("\n")
|
80
|
+
expected_lines = File.read(expected_result_file).split("\n")
|
81
|
+
expected_lines.zip(actual_lines).each_with_index do |pair, line|
|
82
|
+
message = "template: #{name}\nline: #{line + 1}"
|
83
|
+
assert_equal(pair.first, pair.last, message)
|
84
|
+
end
|
85
|
+
if expected_lines.size < actual_lines.size
|
86
|
+
assert(false, "#{actual_lines.size - expected_lines.size} Trailing lines found in #{actual_result_file}.css: #{actual_lines[expected_lines.size..-1].join('\n')}")
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
def within_project(project_name)
|
92
|
+
@current_project = project_name
|
93
|
+
Compass.configuration.parse(configuration_file(project_name)) if File.exists?(configuration_file(project_name))
|
94
|
+
Compass.configuration.project_path = project_path(project_name)
|
95
|
+
args = Compass.configuration.to_compiler_arguments(:logger => Compass::NullLogger.new)
|
96
|
+
if Compass.configuration.sass_path && File.exists?(Compass.configuration.sass_path)
|
97
|
+
compiler = Compass::Compiler.new *args
|
98
|
+
compiler.run
|
99
|
+
end
|
100
|
+
yield Compass.configuration
|
101
|
+
rescue
|
102
|
+
save_output(project_name)
|
103
|
+
raise
|
104
|
+
end
|
105
|
+
|
106
|
+
def each_css_file(dir)
|
107
|
+
Dir.glob("#{dir}/**/*.css").each do |css_file|
|
108
|
+
yield css_file
|
109
|
+
end
|
110
|
+
end
|
111
|
+
|
112
|
+
def save_output(dir)
|
113
|
+
FileUtils.rm_rf(save_path(dir))
|
114
|
+
FileUtils.cp_r(tempfile_path(dir), save_path(dir)) if File.exists?(tempfile_path(dir))
|
115
|
+
end
|
116
|
+
|
117
|
+
def project_path(project_name)
|
118
|
+
absolutize("fixtures/stylesheets/#{project_name}")
|
119
|
+
end
|
120
|
+
|
121
|
+
def configuration_file(project_name)
|
122
|
+
File.join(project_path(project_name), "config.rb")
|
123
|
+
end
|
124
|
+
|
125
|
+
def tempfile_path(project_name)
|
126
|
+
File.join(project_path(project_name), "tmp")
|
127
|
+
end
|
128
|
+
|
129
|
+
def template_path(project_name)
|
130
|
+
File.join(project_path(project_name), "sass")
|
131
|
+
end
|
132
|
+
|
133
|
+
def result_path(project_name)
|
134
|
+
File.join(project_path(project_name), "css")
|
135
|
+
end
|
136
|
+
|
137
|
+
def save_path(project_name)
|
138
|
+
File.join(project_path(project_name), "saved")
|
139
|
+
end
|
140
|
+
|
141
|
+
end
|