compass 0.11.7 → 0.12.alpha.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +10 -0
- data/VERSION.yml +4 -3
- data/bin/compass +1 -5
- data/features/command_line.feature +17 -17
- data/features/extensions.feature +0 -6
- data/features/step_definitions/command_line_steps.rb +1 -2
- data/frameworks/compass/stylesheets/compass/css3/_font-face.scss +35 -5
- data/frameworks/compass/stylesheets/compass/css3/_images.scss +6 -6
- data/frameworks/compass/stylesheets/compass/typography/_vertical_rhythm.scss +3 -12
- data/frameworks/compass/stylesheets/compass/typography/lists/_bullets.scss +1 -1
- data/frameworks/compass/stylesheets/compass/typography/lists/_inline-block-list.scss +11 -14
- data/frameworks/compass/stylesheets/compass/utilities/sprites/_base.scss +5 -5
- data/frameworks/compass/templates/pie/PIE.htc +64 -83
- data/lib/compass.rbc +36 -42
- data/lib/compass/actions.rb +1 -0
- data/lib/compass/actions.rbc +85 -244
- data/lib/compass/app_integration.rbc +20 -28
- data/lib/compass/app_integration/merb.rbc +4 -8
- data/lib/compass/app_integration/rails.rb +22 -5
- data/lib/compass/app_integration/rails.rbc +142 -658
- data/lib/compass/app_integration/rails/actionpack2x.rb +10 -0
- data/lib/compass/app_integration/rails/{actionpack2 → actionpack2x}/action_controller.rb +0 -0
- data/lib/compass/app_integration/rails/{actionpack2 → actionpack2x}/sass_plugin.rb +0 -0
- data/lib/compass/app_integration/rails/{actionpack2 → actionpack2x}/urls.rb +0 -0
- data/lib/compass/app_integration/rails/actionpack30.rb +11 -0
- data/lib/compass/app_integration/rails/{actionpack3 → actionpack30}/railtie.rb +0 -0
- data/lib/compass/app_integration/rails/actionpack31.rb +5 -0
- data/lib/compass/app_integration/rails/actionpack31/helpers.rb +5 -0
- data/lib/compass/app_integration/rails/actionpack31/railtie.rb +89 -0
- data/lib/compass/app_integration/rails/configuration_defaults.rb +54 -14
- data/lib/compass/app_integration/rails/configuration_defaults.rbc +324 -1081
- data/lib/compass/app_integration/rails/installer.rbc +61 -145
- data/lib/compass/app_integration/rails/runtime.rb +6 -16
- data/lib/compass/app_integration/stand_alone.rbc +15 -15
- data/lib/compass/app_integration/stand_alone/configuration_defaults.rbc +23 -23
- data/lib/compass/app_integration/stand_alone/installer.rbc +32 -52
- data/lib/compass/browser_support.rbc +23 -35
- data/lib/compass/commands/clean_project.rb +1 -1
- data/lib/compass/commands/project_stats.rb +7 -7
- data/lib/compass/commands/sprite.rb +4 -3
- data/lib/compass/compiler.rb +2 -2
- data/lib/compass/compiler.rbc +398 -591
- data/lib/compass/configuration.rb +2 -0
- data/lib/compass/configuration.rbc +78 -134
- data/lib/compass/configuration/adapters.rbc +40 -98
- data/lib/compass/configuration/comments.rb +5 -1
- data/lib/compass/configuration/comments.rbc +51 -132
- data/lib/compass/configuration/data.rb +26 -10
- data/lib/compass/configuration/data.rbc +536 -526
- data/lib/compass/configuration/defaults.rb +24 -1
- data/lib/compass/configuration/defaults.rbc +187 -762
- data/lib/compass/configuration/file_data.rb +0 -22
- data/lib/compass/configuration/file_data.rbc +125 -37
- data/lib/compass/configuration/helpers.rb +9 -8
- data/lib/compass/configuration/helpers.rbc +153 -433
- data/lib/compass/configuration/inheritance.rb +13 -0
- data/lib/compass/configuration/inheritance.rbc +165 -412
- data/lib/compass/configuration/paths.rbc +9 -9
- data/lib/compass/configuration/serialization.rb +1 -0
- data/lib/compass/configuration/serialization.rbc +84 -151
- data/lib/compass/dependencies.rbc +4 -16
- data/lib/compass/errors.rbc +5 -5
- data/lib/compass/frameworks.rb +4 -10
- data/lib/compass/frameworks.rbc +66 -118
- data/lib/compass/quick_cache.rbc +8 -12
- data/lib/compass/sass_extensions.rbc +4 -8
- data/lib/compass/sass_extensions/functions.rbc +57 -90
- data/lib/compass/sass_extensions/functions/colors.rbc +18 -22
- data/lib/compass/sass_extensions/functions/constants.rbc +25 -45
- data/lib/compass/sass_extensions/functions/cross_browser_support.rbc +36 -48
- data/lib/compass/sass_extensions/functions/display.rbc +107 -341
- data/lib/compass/sass_extensions/functions/enumerate.rbc +9 -9
- data/lib/compass/sass_extensions/functions/font_files.rbc +125 -542
- data/lib/compass/sass_extensions/functions/gradient_support.rbc +167 -379
- data/lib/compass/sass_extensions/functions/image_size.rb +10 -2
- data/lib/compass/sass_extensions/functions/image_size.rbc +400 -715
- data/lib/compass/sass_extensions/functions/inline_image.rbc +98 -152
- data/lib/compass/sass_extensions/functions/lists.rb +0 -5
- data/lib/compass/sass_extensions/functions/lists.rbc +39 -75
- data/lib/compass/sass_extensions/functions/selectors.rbc +28 -36
- data/lib/compass/sass_extensions/functions/sprites.rb +5 -7
- data/lib/compass/sass_extensions/functions/sprites.rbc +233 -255
- data/lib/compass/sass_extensions/functions/trig.rb +2 -1
- data/lib/compass/sass_extensions/functions/trig.rbc +51 -53
- data/lib/compass/sass_extensions/functions/urls.rb +171 -80
- data/lib/compass/sass_extensions/functions/urls.rbc +1051 -3158
- data/lib/compass/sass_extensions/monkey_patches.rbc +5 -5
- data/lib/compass/sass_extensions/monkey_patches/browser_support.rbc +47 -63
- data/lib/compass/sass_extensions/monkey_patches/traversal.rbc +16 -36
- data/lib/compass/sass_extensions/sprites.rb +3 -1
- data/lib/compass/sass_extensions/sprites.rbc +13 -93
- data/lib/compass/sass_extensions/sprites/engines.rbc +6 -615
- data/lib/compass/sass_extensions/sprites/engines/chunky_png_engine.rbc +94 -260
- data/lib/compass/sass_extensions/sprites/image.rb +23 -11
- data/lib/compass/sass_extensions/sprites/image.rbc +313 -691
- data/lib/compass/sass_extensions/sprites/image_row.rb +47 -0
- data/lib/compass/sass_extensions/sprites/layout_methods.rb +117 -0
- data/lib/compass/sass_extensions/sprites/row_fitter.rb +86 -0
- data/lib/compass/sass_extensions/sprites/sprite_map.rb +18 -4
- data/lib/compass/sass_extensions/sprites/sprite_map.rbc +3635 -708
- data/lib/compass/sass_extensions/sprites/sprite_methods.rb +5 -17
- data/lib/compass/sprite_importer.rb +38 -62
- data/lib/compass/sprite_importer.rbc +1495 -1125
- data/lib/compass/util.rbc +11 -19
- data/lib/compass/version.rbc +25 -53
- data/test/fixtures/sprites/public/images/image_row/large.png +0 -0
- data/test/fixtures/sprites/public/images/image_row/large_square.png +0 -0
- data/test/fixtures/sprites/public/images/image_row/medium.png +0 -0
- data/test/fixtures/sprites/public/images/image_row/small.png +0 -0
- data/test/fixtures/sprites/public/images/image_row/tall.png +0 -0
- data/test/fixtures/stylesheets/compass/css/lists.css +7 -7
- data/test/fixtures/stylesheets/compass/css/reset.css +1 -0
- data/test/fixtures/stylesheets/compass/css/sprites.css +248 -248
- data/test/fixtures/stylesheets/compass/images/flag-s8c3c755a68.png +0 -0
- data/test/integrations/sprites_test.rb +115 -3
- data/test/test_helper.rb +29 -1
- data/test/tmp/compass_rails/public/images/selectors-sef52c5c63a.png +0 -0
- data/test/units/configuration_test.rb +2 -5
- data/test/units/rails_configuration_test.rb +50 -0
- data/test/units/sass_extensions_test.rb +17 -5
- data/test/units/sprites/image_row_test.rb +57 -0
- data/test/units/sprites/image_test.rb +53 -45
- data/test/units/sprites/importer_test.rb +31 -12
- data/test/units/sprites/row_fitter_test.rb +66 -0
- data/test/units/sprites/sprite_command_test.rb +1 -11
- data/test/units/sprites/sprite_map_test.rb +122 -16
- metadata +38 -149
- data/bin/compass.compiled.rbc +0 -707
- data/examples/compass/compass_app_log.txt +0 -6
- data/frameworks/compass/stylesheets/compass/css3/_user-interface.scss +0 -19
- data/lib/compass/commands.rbc +0 -307
- data/lib/compass/commands/base.rbc +0 -1044
- data/lib/compass/commands/clean_project.rbc +0 -1856
- data/lib/compass/commands/create_project.rbc +0 -2691
- data/lib/compass/commands/default.rbc +0 -1677
- data/lib/compass/commands/generate_grid_background.rbc +0 -1939
- data/lib/compass/commands/help.rbc +0 -1921
- data/lib/compass/commands/imports.rbc +0 -969
- data/lib/compass/commands/installer_command.rbc +0 -807
- data/lib/compass/commands/interactive.rbc +0 -1341
- data/lib/compass/commands/list_frameworks.rbc +0 -1111
- data/lib/compass/commands/print_version.rbc +0 -2478
- data/lib/compass/commands/project_base.rbc +0 -2085
- data/lib/compass/commands/project_stats.rbc +0 -4202
- data/lib/compass/commands/registry.rbc +0 -1350
- data/lib/compass/commands/sprite.rbc +0 -2212
- data/lib/compass/commands/stamp_pattern.rbc +0 -2011
- data/lib/compass/commands/unpack_extension.rbc +0 -2348
- data/lib/compass/commands/update_project.rbc +0 -3002
- data/lib/compass/commands/validate_project.rbc +0 -1686
- data/lib/compass/commands/watch_project.rbc +0 -4155
- data/lib/compass/commands/write_configuration.rbc +0 -2896
- data/lib/compass/exec.rbc +0 -500
- data/lib/compass/exec/command_option_parser.rbc +0 -676
- data/lib/compass/exec/global_options_parser.rbc +0 -1306
- data/lib/compass/exec/helpers.rbc +0 -758
- data/lib/compass/exec/project_options_parser.rbc +0 -1515
- data/lib/compass/exec/sub_command_ui.rbc +0 -1191
- data/lib/compass/grid_builder.rbc +0 -0
- data/lib/compass/installers.rbc +0 -152
- data/lib/compass/installers/bare_installer.rbc +0 -939
- data/lib/compass/installers/base.rbc +0 -4427
- data/lib/compass/installers/manifest.rbc +0 -3335
- data/lib/compass/installers/manifest_installer.rbc +0 -1591
- data/lib/compass/installers/template_context.rbc +0 -1030
- data/lib/compass/logger.rbc +0 -2317
- data/lib/compass/sass_extensions/functions/env.rbc +0 -299
- data/lib/compass/sass_extensions/sprites/image_methods.rbc +0 -900
- data/lib/compass/sass_extensions/sprites/image_row.rbc +0 -1168
- data/lib/compass/sass_extensions/sprites/layout_methods.rbc +0 -3236
- data/lib/compass/sass_extensions/sprites/row_fitter.rbc +0 -2067
- data/lib/compass/sass_extensions/sprites/sprite_methods.rbc +0 -3190
- data/test/fixtures/extensions/only_stylesheets/compass_init.rb +0 -1
- data/test/fixtures/extensions/only_stylesheets/scss/only_stylesheets/foo.scss +0 -3
- data/test/fixtures/stylesheets/compass/css/user-interface.css +0 -5
- data/test/fixtures/stylesheets/compass/images/flag-s03c3b29b35.png +0 -0
- data/test/fixtures/stylesheets/compass/sass/user-interface.scss +0 -5
- data/test/fixtures/stylesheets/envtest/tmp/env.css +0 -2
- data/test/fixtures/stylesheets/uses_only_stylesheets_ext/config.rb +0 -25
- data/test/fixtures/stylesheets/uses_only_stylesheets_ext/sass/ie.scss +0 -5
- data/test/fixtures/stylesheets/uses_only_stylesheets_ext/sass/print.scss +0 -3
- data/test/fixtures/stylesheets/uses_only_stylesheets_ext/sass/screen.scss +0 -6
- data/test/fixtures/stylesheets/uses_only_stylesheets_ext/stylesheets/ie.css +0 -5
- data/test/fixtures/stylesheets/uses_only_stylesheets_ext/stylesheets/print.css +0 -3
- data/test/fixtures/stylesheets/uses_only_stylesheets_ext/stylesheets/screen.css +0 -68
- data/test/helpers/command_line.rbc +0 -2820
- data/test/helpers/diff.rbc +0 -1104
- data/test/helpers/io.rbc +0 -962
- data/test/helpers/rails.rbc +0 -1116
- data/test/helpers/test_case.rbc +0 -1255
- data/test/integrations/compass_test.rbc +0 -6589
- data/test/integrations/rails_integration_test.rbc +0 -1342
- data/test/integrations/sprites_test.rbc +0 -6192
- data/test/test_helper.rbc +0 -1694
- data/test/units/actions_test.rbc +0 -644
- data/test/units/command_line_test.rbc +0 -1532
- data/test/units/compass_png_test.rbc +0 -0
- data/test/units/configuration_test.rbc +0 -3833
- data/test/units/rails_configuration_test.rbc +0 -1032
- data/test/units/sass_extensions_test.rbc +0 -3586
- data/test/units/sprites/engine_test.rbc +0 -962
- data/test/units/sprites/image_row_test.rbc +0 -1578
- data/test/units/sprites/image_test.rbc +0 -2836
- data/test/units/sprites/importer_test.rbc +0 -2620
- data/test/units/sprites/row_fitter_test.rbc +0 -1479
- data/test/units/sprites/sprite_command_test.rbc +0 -1147
- data/test/units/sprites/sprite_map_test.rbc +0 -6515
Binary file
|
@@ -11,6 +11,7 @@ class SpritesTest < Test::Unit::TestCase
|
|
11
11
|
Compass.reset_configuration!
|
12
12
|
@images_src_path = File.join(File.dirname(__FILE__), '..', 'fixtures', 'sprites', 'public', 'images')
|
13
13
|
@images_tmp_path = File.join(File.dirname(__FILE__), '..', 'fixtures', 'sprites', 'public', 'images-tmp')
|
14
|
+
@generated_images_tmp_path = File.join(File.dirname(__FILE__), '..', 'fixtures', 'sprites', 'public', 'generated-images-tmp')
|
14
15
|
::FileUtils.cp_r @images_src_path, @images_tmp_path
|
15
16
|
file = StringIO.new("images_path = #{@images_tmp_path.inspect}\n")
|
16
17
|
Compass.add_configuration(file, "sprite_config")
|
@@ -20,6 +21,7 @@ class SpritesTest < Test::Unit::TestCase
|
|
20
21
|
def teardown
|
21
22
|
Compass.reset_configuration!
|
22
23
|
::FileUtils.rm_r @images_tmp_path
|
24
|
+
::FileUtils.rm_rf @generated_images_tmp_path
|
23
25
|
end
|
24
26
|
|
25
27
|
|
@@ -74,6 +76,35 @@ class SpritesTest < Test::Unit::TestCase
|
|
74
76
|
assert_equal image_md5('squares-s*.png'), '7349a0f4e88ea80abddcf6ac2486abe3'
|
75
77
|
end
|
76
78
|
|
79
|
+
it "should output and serve sprite files using the generated images directory" do
|
80
|
+
Compass.reset_configuration!
|
81
|
+
file = StringIO.new(<<-CONFIG)
|
82
|
+
images_path = #{@images_tmp_path.inspect}
|
83
|
+
generated_images_path = #{@generated_images_tmp_path.inspect}
|
84
|
+
http_generated_images_path = "/images/generated"
|
85
|
+
CONFIG
|
86
|
+
Compass.add_configuration(file, "sprite_config")
|
87
|
+
Compass.configure_sass_plugin!
|
88
|
+
css = render <<-SCSS
|
89
|
+
@import "squares/*.png";
|
90
|
+
@include all-squares-sprites;
|
91
|
+
SCSS
|
92
|
+
assert_not_nil Dir.glob("#{@generated_images_tmp_path}/squares-s*.png").first
|
93
|
+
assert_correct <<-CSS, css
|
94
|
+
.squares-sprite, .squares-ten-by-ten, .squares-twenty-by-twenty {
|
95
|
+
background: url('/images/generated/squares-s161c60ad78.png') no-repeat;
|
96
|
+
}
|
97
|
+
|
98
|
+
.squares-ten-by-ten {
|
99
|
+
background-position: 0 0;
|
100
|
+
}
|
101
|
+
|
102
|
+
.squares-twenty-by-twenty {
|
103
|
+
background-position: 0 -10px;
|
104
|
+
}
|
105
|
+
CSS
|
106
|
+
end
|
107
|
+
|
77
108
|
it "should generate sprite classes with dimensions" do
|
78
109
|
css = render <<-SCSS
|
79
110
|
$squares-sprite-dimensions: true;
|
@@ -448,7 +479,7 @@ class SpritesTest < Test::Unit::TestCase
|
|
448
479
|
CSS
|
449
480
|
end
|
450
481
|
|
451
|
-
it "should render
|
482
|
+
it "should render correct sprite with css selectors via issue#248" do
|
452
483
|
css = render <<-SCSS
|
453
484
|
@import "selectors/*.png";
|
454
485
|
@include all-selectors-sprites;
|
@@ -472,8 +503,33 @@ class SpritesTest < Test::Unit::TestCase
|
|
472
503
|
}
|
473
504
|
CSS
|
474
505
|
end
|
506
|
+
|
507
|
+
it "should honor offsets when rendering selectors via issue#449" do
|
508
|
+
css = render <<-SCSS
|
509
|
+
@import "selectors/*.png";
|
510
|
+
@include all-selectors-sprites($offset-x: 20px, $offset-y: 20px);
|
511
|
+
SCSS
|
512
|
+
assert_correct css, <<-CSS
|
513
|
+
.selectors-sprite, .selectors-ten-by-ten {
|
514
|
+
background: url('/selectors-sedfef809e2.png') no-repeat;
|
515
|
+
}
|
516
|
+
|
517
|
+
.selectors-ten-by-ten {
|
518
|
+
background-position: 20px 20px;
|
519
|
+
}
|
520
|
+
.selectors-ten-by-ten:hover, .selectors-ten-by-ten.ten-by-ten_hover, .selectors-ten-by-ten.ten-by-ten-hover {
|
521
|
+
background-position: 20px 0;
|
522
|
+
}
|
523
|
+
.selectors-ten-by-ten:target, .selectors-ten-by-ten.ten-by-ten_target, .selectors-ten-by-ten.ten-by-ten-target {
|
524
|
+
background-position: 20px -10px;
|
525
|
+
}
|
526
|
+
.selectors-ten-by-ten:active, .selectors-ten-by-ten.ten-by-ten_active, .selectors-ten-by-ten.ten-by-ten-active {
|
527
|
+
background-position: 20px 10px;
|
528
|
+
}
|
529
|
+
CSS
|
530
|
+
end
|
475
531
|
|
476
|
-
it "should render
|
532
|
+
it "should render correct sprite with css selectors via magic mixin" do
|
477
533
|
css = render <<-SCSS
|
478
534
|
@import "selectors/*.png";
|
479
535
|
a {
|
@@ -499,6 +555,7 @@ class SpritesTest < Test::Unit::TestCase
|
|
499
555
|
}
|
500
556
|
CSS
|
501
557
|
end
|
558
|
+
|
502
559
|
|
503
560
|
it "should not render corret sprite with css selectors via magic mixin" do
|
504
561
|
css = render <<-SCSS
|
@@ -518,6 +575,33 @@ class SpritesTest < Test::Unit::TestCase
|
|
518
575
|
}
|
519
576
|
CSS
|
520
577
|
end
|
578
|
+
|
579
|
+
it "should render corret sprite with css selectors via magic mixin with the correct offsets" do
|
580
|
+
css = render <<-SCSS
|
581
|
+
@import "selectors/*.png";
|
582
|
+
a {
|
583
|
+
@include selectors-sprite(ten-by-ten, false, 5, -5)
|
584
|
+
}
|
585
|
+
SCSS
|
586
|
+
assert_correct css, <<-CSS
|
587
|
+
.selectors-sprite, a {
|
588
|
+
background: url('/selectors-sedfef809e2.png') no-repeat;
|
589
|
+
}
|
590
|
+
|
591
|
+
a {
|
592
|
+
background-position: 5px -5px;
|
593
|
+
}
|
594
|
+
a:hover, a.ten-by-ten_hover, a.ten-by-ten-hover {
|
595
|
+
background-position: 5px -25px;
|
596
|
+
}
|
597
|
+
a:target, a.ten-by-ten_target, a.ten-by-ten-target {
|
598
|
+
background-position: 5px -35px;
|
599
|
+
}
|
600
|
+
a:active, a.ten-by-ten_active, a.ten-by-ten-active {
|
601
|
+
background-position: 5px -15px;
|
602
|
+
}
|
603
|
+
CSS
|
604
|
+
end
|
521
605
|
|
522
606
|
it "should raise error on filenames that are not valid sass syntax" do
|
523
607
|
assert_raise(Compass::Error) do
|
@@ -603,5 +687,33 @@ class SpritesTest < Test::Unit::TestCase
|
|
603
687
|
}
|
604
688
|
CSS
|
605
689
|
end
|
690
|
+
|
691
|
+
it "should create horizontal sprite" do
|
692
|
+
css = render <<-SCSS
|
693
|
+
$squares-layout:horizontal;
|
694
|
+
@import "squares/*.png";
|
695
|
+
.foo {
|
696
|
+
@include sprite-background-position($squares-sprites, "twenty-by-twenty");
|
697
|
+
}
|
698
|
+
.bar {
|
699
|
+
@include sprite-background-position($squares-sprites, "ten-by-ten");
|
700
|
+
}
|
701
|
+
SCSS
|
702
|
+
assert_equal [30, 20], image_size('squares-s*.png')
|
703
|
+
other_css = <<-CSS
|
704
|
+
.squares-sprite {
|
705
|
+
background: url('/squares-s161c60ad78.png') no-repeat;
|
706
|
+
}
|
707
|
+
|
708
|
+
.foo {
|
709
|
+
background-position: -10px 0;
|
710
|
+
}
|
711
|
+
|
712
|
+
.bar {
|
713
|
+
background-position: 0 0;
|
714
|
+
}
|
715
|
+
CSS
|
716
|
+
assert_correct css.gsub("\n", '').gsub(' ', ''), other_css.gsub("\n", '').gsub(' ', '')
|
717
|
+
end
|
606
718
|
|
607
|
-
end
|
719
|
+
end
|
data/test/test_helper.rb
CHANGED
@@ -34,4 +34,32 @@ class Test::Unit::TestCase
|
|
34
34
|
include Compass::IoHelper
|
35
35
|
extend Compass::TestCaseHelper::ClassMethods
|
36
36
|
|
37
|
-
end
|
37
|
+
end
|
38
|
+
|
39
|
+
module SpriteHelper
|
40
|
+
URI = "selectors/*.png"
|
41
|
+
|
42
|
+
def init_sprite_helper
|
43
|
+
@images_src_path = File.join(File.dirname(__FILE__), 'fixtures', 'sprites', 'public', 'images')
|
44
|
+
@images_tmp_path = File.join(File.dirname(__FILE__), 'fixtures', 'sprites', 'public', 'images-tmp')
|
45
|
+
end
|
46
|
+
|
47
|
+
def sprite_map_test(options)
|
48
|
+
importer = Compass::SpriteImporter.new
|
49
|
+
path, name = Compass::SpriteImporter.path_and_name(URI)
|
50
|
+
sprite_names = Compass::SpriteImporter.sprite_names(URI)
|
51
|
+
sass_engine = Compass::SpriteImporter.sass_engine(URI, name, importer, options)
|
52
|
+
Compass::SassExtensions::Sprites::SpriteMap.new(sprite_names.map{|n| "selectors/#{n}.png"}, path, name, sass_engine, options)
|
53
|
+
end
|
54
|
+
|
55
|
+
def create_sprite_temp
|
56
|
+
init_sprite_helper
|
57
|
+
::FileUtils.cp_r @images_src_path, @images_tmp_path
|
58
|
+
end
|
59
|
+
|
60
|
+
def clean_up_sprites
|
61
|
+
init_sprite_helper
|
62
|
+
::FileUtils.rm_r @images_tmp_path
|
63
|
+
end
|
64
|
+
|
65
|
+
end
|
Binary file
|
@@ -19,7 +19,6 @@ class ConfigurationTest < Test::Unit::TestCase
|
|
19
19
|
|
20
20
|
project_type = :stand_alone
|
21
21
|
|
22
|
-
# Set this to the root of your project when deployed:
|
23
22
|
http_path = "/"
|
24
23
|
css_dir = "css"
|
25
24
|
sass_dir = "sass"
|
@@ -101,7 +100,7 @@ class ConfigurationTest < Test::Unit::TestCase
|
|
101
100
|
|
102
101
|
plugin_opts = Compass.configuration.to_sass_plugin_options
|
103
102
|
|
104
|
-
assert load_paths.include?("/home/chris/foo")
|
103
|
+
assert load_paths.include?("/home/chris/foo"), "Expected to find /home/chris/foo in #{load_paths.inspect}"
|
105
104
|
assert load_paths.include?("/path/to/my/framework"), load_paths.inspect
|
106
105
|
assert_equal "/home/chris/my_compass_project/css/framework", plugin_opts[:template_location].find{|s,c| s == "/path/to/my/framework"}[1]
|
107
106
|
assert_equal "/home/chris/my_compass_project/css/foo", plugin_opts[:template_location].find{|s,c| s == "/home/chris/my_compass_project/../foo"}[1]
|
@@ -110,7 +109,6 @@ class ConfigurationTest < Test::Unit::TestCase
|
|
110
109
|
# Require any additional compass plugins here.
|
111
110
|
project_path = "/home/chris/my_compass_project"
|
112
111
|
|
113
|
-
# Set this to the root of your project when deployed:
|
114
112
|
http_path = "/"
|
115
113
|
css_dir = "css"
|
116
114
|
|
@@ -141,7 +139,7 @@ EXPECTED
|
|
141
139
|
|
142
140
|
load_paths = load_paths_as_strings(Compass.configuration.to_sass_engine_options[:load_paths])
|
143
141
|
|
144
|
-
assert load_paths.include?("/home/chris/foo")
|
142
|
+
assert load_paths.include?("/home/chris/foo"), "Expected to find /home/chris/foo in #{load_paths.inspect}"
|
145
143
|
assert load_paths.include?("/path/to/my/framework"), load_paths.inspect
|
146
144
|
assert_equal "/home/chris/my_compass_project/css/framework", Compass.configuration.to_sass_plugin_options[:template_location].find{|s,c| s == "/path/to/my/framework"}[1]
|
147
145
|
assert_equal "/home/chris/my_compass_project/css/foo", Compass.configuration.to_sass_plugin_options[:template_location].find{|s,c| s == "/home/chris/my_compass_project/../foo"}[1]
|
@@ -150,7 +148,6 @@ EXPECTED
|
|
150
148
|
# Require any additional compass plugins here.
|
151
149
|
project_path = "/home/chris/my_compass_project"
|
152
150
|
|
153
|
-
# Set this to the root of your project when deployed:
|
154
151
|
http_path = "/"
|
155
152
|
css_dir = "css"
|
156
153
|
|
@@ -0,0 +1,50 @@
|
|
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
|
@@ -65,18 +65,21 @@ class SassExtensionsTest < Test::Unit::TestCase
|
|
65
65
|
end
|
66
66
|
|
67
67
|
def test_trig_functions
|
68
|
+
assert_equal "0.841", evaluate("sin(1)")
|
68
69
|
assert_equal "0.841px", evaluate("sin(1px)")
|
69
70
|
assert_equal "0.0", evaluate("sin(pi())")
|
70
71
|
assert_equal "1", evaluate("sin(pi() / 2)")
|
71
|
-
assert_equal "
|
72
|
+
assert_equal "0.0", evaluate("sin(180deg)")
|
72
73
|
assert_equal "-1", evaluate("sin(3* pi() / 2)")
|
73
74
|
assert_equal "-1", evaluate("cos(pi())")
|
74
|
-
assert_equal "
|
75
|
+
assert_equal "1", evaluate("cos(360deg)")
|
76
|
+
assert_equal "-0.176", evaluate("sin(270)")
|
75
77
|
assert_equal "1", evaluate("cos(2*pi())")
|
76
78
|
assert_equal "0.0", evaluate("cos(pi() / 2)")
|
77
79
|
assert_equal "0.0", evaluate("cos(3* pi() / 2)")
|
78
80
|
assert_equal "0.0", evaluate("tan(pi())")
|
79
81
|
assert_equal "0.0", evaluate("tan(360deg)")
|
82
|
+
assert_equal "0.959", evaluate("sin(360)")
|
80
83
|
assert evaluate("tan(pi()/2 - 0.0001)").to_f > 1000, evaluate("tan(pi()/2 - 0.0001)")
|
81
84
|
assert evaluate("tan(pi()/2 + 0.0001)").to_f < -1000, evaluate("tan(pi()/2 - 0.0001)")
|
82
85
|
end
|
@@ -95,9 +98,18 @@ class SassExtensionsTest < Test::Unit::TestCase
|
|
95
98
|
assert_equal "true", evaluate("prefixed(-css2, css2-fallback(css3, css2))")
|
96
99
|
end
|
97
100
|
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
+
%w(stylesheet_url font_url image_url generated_image_url).each do |helper|
|
102
|
+
class_eval %Q{
|
103
|
+
def test_#{helper}_helper_defers_to_existing_helper
|
104
|
+
c = Class.new do
|
105
|
+
def #{helper}(*args)
|
106
|
+
:original
|
107
|
+
end
|
108
|
+
end
|
109
|
+
c.send(:include, Compass::SassExtensions::Functions::Urls)
|
110
|
+
assert_equal :original, c.new.#{helper}("logo.png")
|
111
|
+
end
|
112
|
+
}
|
101
113
|
end
|
102
114
|
|
103
115
|
protected
|
@@ -0,0 +1,57 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class ImageRowTest < Test::Unit::TestCase
|
4
|
+
include SpriteHelper
|
5
|
+
def setup
|
6
|
+
create_sprite_temp
|
7
|
+
file = StringIO.new("images_path = #{@images_src_path.inspect}\n")
|
8
|
+
Compass.add_configuration(file, "sprite_config")
|
9
|
+
@filenames = %w(large.png large_square.png medium.png tall.png small.png)
|
10
|
+
@image_files = Dir["#{@images_src_path}/image_row/*.png"].sort
|
11
|
+
@images = @image_files.map do |img|
|
12
|
+
img.gsub!("#{@images_src_path}/", '')
|
13
|
+
Compass::SassExtensions::Sprites::Image.new(nil, img, {})
|
14
|
+
end
|
15
|
+
image_row(1000)
|
16
|
+
end
|
17
|
+
|
18
|
+
def teardown
|
19
|
+
clean_up_sprites
|
20
|
+
end
|
21
|
+
|
22
|
+
def image_row(max)
|
23
|
+
@image_row = Compass::SassExtensions::Sprites::ImageRow.new(max)
|
24
|
+
end
|
25
|
+
|
26
|
+
def populate_row
|
27
|
+
@images.each do |image|
|
28
|
+
assert @image_row.add(image)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
it "should return false if image will not fit in row" do
|
33
|
+
image_row(100)
|
34
|
+
img = Compass::SassExtensions::Sprites::Image.new(nil, File.join('image_row', 'large.png'), {})
|
35
|
+
assert !@image_row.add(img)
|
36
|
+
end
|
37
|
+
|
38
|
+
it "should have 5 images" do
|
39
|
+
populate_row
|
40
|
+
assert_equal 5, @image_row.images.size
|
41
|
+
end
|
42
|
+
|
43
|
+
it "should return max image width" do
|
44
|
+
populate_row
|
45
|
+
assert_equal 400, @image_row.width
|
46
|
+
end
|
47
|
+
|
48
|
+
it "should return max image height" do
|
49
|
+
populate_row
|
50
|
+
assert_equal 40, @image_row.height
|
51
|
+
end
|
52
|
+
|
53
|
+
it "should have an efficiency rating" do
|
54
|
+
populate_row
|
55
|
+
assert_equal 1 - (580.0 / 1000.0), @image_row.efficiency
|
56
|
+
end
|
57
|
+
end
|
@@ -1,49 +1,41 @@
|
|
1
1
|
require 'test_helper'
|
2
2
|
require 'mocha'
|
3
3
|
require 'ostruct'
|
4
|
-
class SpritesImageTest < Test::Unit::TestCase
|
5
|
-
|
6
4
|
|
5
|
+
class SpritesImageTest < Test::Unit::TestCase
|
6
|
+
include SpriteHelper
|
7
7
|
def setup
|
8
|
-
|
9
|
-
file = StringIO.new("images_path = #{@images_src_path.inspect}\n")
|
10
|
-
Compass.add_configuration(file, "sprite_config")
|
11
|
-
@repeat = 'no-repeat'
|
12
|
-
@spacing = 0
|
13
|
-
@position = 100
|
14
|
-
@offset = 100
|
8
|
+
create_sprite_temp
|
15
9
|
end
|
16
10
|
|
17
|
-
|
18
|
-
let(:sprite_path) { File.join(@images_src_path, sprite_filename) }
|
19
|
-
let(:sprite_name) { File.basename(sprite_filename, '.png') }
|
11
|
+
SPRITE_FILENAME = 'selectors/ten-by-ten.png'
|
20
12
|
|
21
|
-
def
|
22
|
-
|
23
|
-
@parent ||= Compass::SassExtensions::Sprites::SpriteMap.new(importer.sprite_names.map{|n| "selectors/#{n}.png"}, importer.path, importer.name, importer.sass_engine, importer.options)
|
13
|
+
def sprite_path
|
14
|
+
File.join(@images_tmp_path, SPRITE_FILENAME)
|
24
15
|
end
|
25
16
|
|
26
|
-
|
27
|
-
|
28
|
-
options.stubs(:get_var).with(anything).returns(nil)
|
29
|
-
::OpenStruct.any_instance.stubs(:unitless?).returns(true)
|
30
|
-
options.stubs(:get_var).with("#{sprite_name}-repeat").returns(::OpenStruct.new(:value => @repeat))
|
31
|
-
options.stubs(:get_var).with("#{sprite_name}-spacing").returns(::OpenStruct.new(:value => @spacing))
|
32
|
-
options.stubs(:get_var).with("#{sprite_name}-position").returns(::OpenStruct.new(:value => @position))
|
33
|
-
options
|
17
|
+
def sprite_name
|
18
|
+
File.basename(SPRITE_FILENAME, '.png')
|
34
19
|
end
|
35
20
|
|
36
|
-
|
21
|
+
def digest
|
22
|
+
Digest::MD5.file(sprite_path).hexdigest
|
23
|
+
end
|
37
24
|
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
25
|
+
def test_map(options ={})
|
26
|
+
options = {'cleanup' => Sass::Script::Bool.new(true), 'layout' => Sass::Script::String.new('vertical')}.merge(options)
|
27
|
+
map = sprite_map_test(options)
|
28
|
+
end
|
29
|
+
|
30
|
+
def test_image(options ={})
|
31
|
+
test_map(options).images.first
|
32
|
+
end
|
42
33
|
|
43
34
|
test 'initialize' do
|
35
|
+
image = test_image
|
44
36
|
assert_equal sprite_name, image.name
|
45
37
|
assert_equal sprite_path, image.file
|
46
|
-
assert_equal
|
38
|
+
assert_equal SPRITE_FILENAME, image.relative_file
|
47
39
|
assert_equal 10, image.width
|
48
40
|
assert_equal 10, image.height
|
49
41
|
assert_equal digest, image.digest
|
@@ -52,46 +44,62 @@ class SpritesImageTest < Test::Unit::TestCase
|
|
52
44
|
end
|
53
45
|
|
54
46
|
test 'hover' do
|
55
|
-
assert_equal 'ten-by-ten_hover',
|
47
|
+
assert_equal 'ten-by-ten_hover', test_image.hover.name
|
56
48
|
end
|
57
49
|
|
58
50
|
test 'no parent' do
|
59
|
-
assert_nil
|
60
|
-
end
|
61
|
-
|
62
|
-
test 'image type is nil' do
|
63
|
-
@repeat = nil
|
64
|
-
assert_nil image.repeat
|
51
|
+
assert_nil test_image.parent
|
65
52
|
end
|
66
|
-
|
67
53
|
|
68
54
|
test 'image type is "global"' do
|
69
|
-
|
70
|
-
assert_equal
|
55
|
+
image = test_image "ten_by_ten_repeat" => Sass::Script::String.new('global')
|
56
|
+
assert_equal 'global', image.repeat
|
71
57
|
end
|
72
58
|
|
73
59
|
test 'image type is "no-repeat"' do
|
74
|
-
assert_equal 'no-repeat',
|
60
|
+
assert_equal 'no-repeat', test_image.repeat
|
75
61
|
end
|
76
62
|
|
77
63
|
test 'image position' do
|
78
|
-
|
64
|
+
image = test_image "ten_by_ten_position" => Sass::Script::Number.new(100, ["px"])
|
65
|
+
assert_equal 100, image.position.value
|
79
66
|
end
|
80
67
|
|
81
68
|
test 'image spacing' do
|
82
69
|
@spacing = 10
|
83
|
-
|
70
|
+
image = test_image "spacing" => Sass::Script::Number.new(100, ["px"])
|
71
|
+
assert_equal 100, image.spacing
|
84
72
|
end
|
85
73
|
|
86
74
|
test 'offset' do
|
87
|
-
|
75
|
+
image = test_image "ten_by_ten_position" => Sass::Script::Number.new(100, ["px"])
|
76
|
+
assert_equal 100, image.offset
|
88
77
|
end
|
89
78
|
|
90
79
|
test 'neither, uses 0' do
|
91
|
-
|
92
|
-
img = image
|
80
|
+
img = test_image
|
93
81
|
img.position.stubs(:unitless?).returns(false)
|
94
82
|
assert_equal 0, img.offset
|
95
83
|
end
|
96
84
|
|
85
|
+
|
86
|
+
test 'gets name for sprite in search path' do
|
87
|
+
Compass.reset_configuration!
|
88
|
+
uri = 'foo/*.png'
|
89
|
+
other_folder = File.join(@images_tmp_path, '../other-temp')
|
90
|
+
FileUtils.mkdir_p other_folder
|
91
|
+
FileUtils.mkdir_p File.join(other_folder, 'foo')
|
92
|
+
%w(my bar).each do |file|
|
93
|
+
FileUtils.touch(File.join(other_folder, "foo/#{file}.png"))
|
94
|
+
end
|
95
|
+
config = Compass::Configuration::Data.new('config')
|
96
|
+
config.images_path = @images_tmp_path
|
97
|
+
config.sprite_load_path = [@images_tmp_path, other_folder]
|
98
|
+
Compass.add_configuration(config, "sprite_config")
|
99
|
+
image = Compass::SassExtensions::Sprites::Image.new(test_map, "foo/my.png", {})
|
100
|
+
assert_equal File.join(other_folder, 'foo/my.png'), image.file
|
101
|
+
assert_equal 0, image.size
|
102
|
+
FileUtils.rm_rf other_folder
|
103
|
+
end
|
104
|
+
|
97
105
|
end
|