compass 0.12.2 → 0.13.alpha.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.markdown +5 -5
- data/Rakefile +14 -9
- data/VERSION.yml +5 -4
- data/features/command_line.feature +8 -50
- data/features/step_definitions/command_line_steps.rb +3 -2
- data/frameworks/compass/stylesheets/compass/_css3.scss +3 -0
- data/frameworks/compass/stylesheets/compass/_support.scss +4 -4
- data/frameworks/compass/stylesheets/compass/css3/_animation.scss +121 -0
- data/frameworks/compass/stylesheets/compass/css3/_appearance.scss +14 -9
- data/frameworks/compass/stylesheets/compass/css3/_background-clip.scss +32 -36
- data/frameworks/compass/stylesheets/compass/css3/_background-origin.scss +32 -35
- data/frameworks/compass/stylesheets/compass/css3/_background-size.scss +12 -15
- data/frameworks/compass/stylesheets/compass/css3/_border-radius.scss +27 -48
- data/frameworks/compass/stylesheets/compass/css3/_box-shadow.scss +22 -35
- data/frameworks/compass/stylesheets/compass/css3/_box-sizing.scss +12 -8
- data/frameworks/compass/stylesheets/compass/css3/_box.scss +58 -83
- data/frameworks/compass/stylesheets/compass/css3/_columns.scss +113 -71
- data/frameworks/compass/stylesheets/compass/css3/_filter.scss +38 -18
- data/frameworks/compass/stylesheets/compass/css3/_flexbox.scss +294 -0
- data/frameworks/compass/stylesheets/compass/css3/_hyphenation.scss +13 -22
- data/frameworks/compass/stylesheets/compass/css3/_images.scss +45 -48
- data/frameworks/compass/stylesheets/compass/css3/_inline-block.scss +1 -1
- data/frameworks/compass/stylesheets/compass/css3/_regions.scss +12 -8
- data/frameworks/compass/stylesheets/compass/css3/_selection.scss +31 -0
- data/frameworks/compass/stylesheets/compass/css3/_shared.scss +226 -2
- data/frameworks/compass/stylesheets/compass/css3/_text-shadow.scss +21 -26
- data/frameworks/compass/stylesheets/compass/css3/_transform-legacy.scss +3 -3
- data/frameworks/compass/stylesheets/compass/css3/_transform.scss +8 -8
- data/frameworks/compass/stylesheets/compass/css3/_transition.scss +3 -3
- data/frameworks/compass/stylesheets/compass/css3/_user-interface.scss +43 -4
- data/frameworks/compass/stylesheets/compass/typography/_units.scss +152 -0
- data/frameworks/compass/stylesheets/compass/typography/_vertical_rhythm.scss +180 -102
- data/frameworks/compass/stylesheets/compass/typography/lists/_horizontal-list.scss +5 -3
- data/frameworks/compass/stylesheets/compass/typography/lists/_inline-list.scss +6 -3
- data/frameworks/compass/stylesheets/compass/typography/text/_ellipsis.scss +1 -1
- data/frameworks/compass/stylesheets/compass/utilities/general/_float.scss +7 -3
- data/frameworks/compass/stylesheets/compass/utilities/general/_hacks.scss +2 -2
- data/frameworks/compass/stylesheets/compass/utilities/sprites/_base.scss +32 -13
- data/frameworks/compass/stylesheets/compass/utilities/tables/_borders.scss +14 -9
- data/lib/compass/actions.rb +5 -1
- data/lib/compass/commands/project_base.rb +7 -1
- data/lib/compass/commands/update_project.rb +2 -3
- data/lib/compass/commands/watch_project.rb +11 -113
- data/lib/compass/commands.rb +1 -1
- data/lib/compass/compiler.rb +6 -0
- data/lib/compass/configuration/data.rb +1 -1
- data/lib/compass/configuration/helpers.rb +2 -0
- data/lib/compass/exec/global_options_parser.rb +1 -1
- data/lib/compass/exec/project_options_parser.rb +13 -1
- data/lib/compass/logger.rb +2 -0
- data/lib/compass/sass_extensions/functions/cross_browser_support.rb +1 -1
- data/lib/compass/sass_extensions/functions/env.rb +18 -0
- data/lib/compass/sass_extensions/functions/gradient_support.rb +101 -29
- data/lib/compass/sass_extensions/functions/image_size.rb +2 -1
- data/lib/compass/sass_extensions/functions/math.rb +14 -2
- data/lib/compass/sass_extensions/functions/sprites.rb +82 -22
- data/lib/compass/sass_extensions/functions/urls.rb +37 -6
- data/lib/compass/sass_extensions/functions/utility.rb +10 -0
- data/lib/compass/sass_extensions/sprites/engines/chunky_png_engine.rb +5 -1
- data/lib/compass/sass_extensions/sprites/engines.rb +3 -3
- data/lib/compass/sass_extensions/sprites/image.rb +7 -2
- data/lib/compass/sass_extensions/sprites/image_methods.rb +5 -1
- data/lib/compass/sass_extensions/sprites/images.rb +29 -0
- data/lib/compass/sass_extensions/sprites/layout/diagonal.rb +42 -0
- data/lib/compass/sass_extensions/sprites/layout/horizontal.rb +66 -0
- data/lib/compass/sass_extensions/sprites/layout/smart.rb +33 -0
- data/lib/compass/sass_extensions/sprites/layout/vertical.rb +68 -0
- data/lib/compass/sass_extensions/sprites/layout.rb +39 -0
- data/lib/compass/sass_extensions/sprites/layout_methods.rb +9 -115
- data/lib/compass/sass_extensions/sprites/sprite_map.rb +5 -1
- data/lib/compass/sass_extensions/sprites/sprite_methods.rb +9 -14
- data/lib/compass/sass_extensions/sprites.rb +2 -0
- data/lib/compass/sprite_importer/content.erb +29 -24
- data/lib/compass/sprite_importer.rb +7 -11
- data/lib/compass/watcher/compiler.rb +59 -0
- data/lib/compass/watcher/project_watcher.rb +111 -0
- data/lib/compass/watcher/watch.rb +33 -0
- data/lib/compass/watcher.rb +11 -0
- data/lib/compass.rb +2 -2
- data/test/fixtures/sprites/public/images/numeric/200.png +0 -0
- data/test/fixtures/stylesheets/busted_font_urls/config.rb +32 -0
- data/test/fixtures/stylesheets/busted_font_urls/css/screen.css +7 -0
- data/test/fixtures/stylesheets/busted_font_urls/fonts/grid.ttf +0 -0
- data/test/fixtures/stylesheets/busted_font_urls/fonts/sub/dk.ttf +0 -0
- data/test/fixtures/stylesheets/busted_font_urls/sass/screen.sass +11 -0
- data/test/fixtures/stylesheets/busted_font_urls/tmp/screen.css +7 -0
- data/test/fixtures/stylesheets/compass/css/animation-with-legacy-ie.css +33 -0
- data/test/fixtures/stylesheets/compass/css/animation.css +33 -0
- data/test/fixtures/stylesheets/compass/css/background-clip.css +5 -0
- data/test/fixtures/stylesheets/compass/css/background-origin.css +15 -0
- data/test/fixtures/stylesheets/compass/css/background-size.css +24 -0
- data/test/fixtures/stylesheets/compass/css/columns.css +32 -61
- data/test/fixtures/stylesheets/compass/css/flexbox.css +121 -0
- data/test/fixtures/stylesheets/compass/css/gradients.css +65 -37
- data/test/fixtures/stylesheets/compass/css/grid_background.css +10 -17
- data/test/fixtures/stylesheets/compass/css/hyphenation.css +4 -2
- data/test/fixtures/stylesheets/compass/css/lists.css +5 -5
- data/test/fixtures/stylesheets/compass/css/pie.css +0 -3
- data/test/fixtures/stylesheets/compass/css/regions.css +4 -2
- data/test/fixtures/stylesheets/compass/css/selection.css +13 -0
- data/test/fixtures/stylesheets/compass/css/sprites.css +251 -250
- data/test/fixtures/stylesheets/compass/css/text_shadow.css +6 -6
- data/test/fixtures/stylesheets/compass/css/transition.css +6 -0
- data/test/fixtures/stylesheets/compass/css/units.css +30 -0
- data/test/fixtures/stylesheets/compass/css/user-interface.css +22 -1
- data/test/fixtures/stylesheets/compass/css/utilities.css +15 -0
- data/test/fixtures/stylesheets/compass/css/vertical_rhythm.css +196 -27
- data/test/fixtures/stylesheets/compass/images/flag-s5b4f509715.png +0 -0
- data/test/fixtures/stylesheets/compass/sass/animation-with-legacy-ie.scss +19 -0
- data/test/fixtures/stylesheets/compass/sass/animation.scss +13 -0
- data/test/fixtures/stylesheets/compass/sass/background-clip.scss +4 -2
- data/test/fixtures/stylesheets/compass/sass/background-origin.scss +10 -0
- data/test/fixtures/stylesheets/compass/sass/background-size.scss +12 -0
- data/test/fixtures/stylesheets/compass/sass/columns.scss +10 -9
- data/test/fixtures/stylesheets/compass/sass/flexbox.scss +44 -0
- data/test/fixtures/stylesheets/compass/sass/gradients.sass +32 -3
- data/test/fixtures/stylesheets/compass/sass/selection.scss +13 -0
- data/test/fixtures/stylesheets/compass/sass/transition.scss +1 -1
- data/test/fixtures/stylesheets/compass/sass/units.scss +45 -0
- data/test/fixtures/stylesheets/compass/sass/user-interface.scss +13 -1
- data/test/fixtures/stylesheets/compass/sass/utilities.scss +10 -0
- data/test/fixtures/stylesheets/compass/sass/vertical_rhythm.scss +208 -7
- data/test/fixtures/stylesheets/envtest/css/env.css +8 -0
- data/test/fixtures/stylesheets/envtest/sass/env.scss +16 -0
- data/test/fixtures/stylesheets/envtest/tmp/env.css +4 -4
- data/test/fixtures/stylesheets/valid/css/simple.css +4 -0
- data/test/helpers/diff.rb +1 -1
- data/test/integrations/compass_test.rb +23 -14
- data/test/integrations/sprites_test.rb +305 -63
- data/test/test_helper.rb +4 -13
- data/test/units/command_line_test.rb +0 -2
- data/test/units/compass_module_test.rb +1 -1
- data/test/units/configuration_test.rb +12 -0
- data/test/units/regressions_test.rb +8 -8
- data/test/units/sass_extensions_test.rb +13 -11
- data/test/units/sass_extenstions/gradients_test.rb +33 -0
- data/test/units/sprites/image_test.rb +5 -0
- data/test/units/sprites/images_test.rb +46 -0
- data/test/units/sprites/layout_test.rb +29 -4
- data/test/units/watcher/compiler_test.rb +39 -0
- data/test/units/watcher/project_watcher_test.rb +73 -0
- data/test/units/watcher/watch_test.rb +42 -0
- metadata +137 -241
- data/examples/compass/images/emblem-a043c4f148.png +0 -0
- data/examples/compass/images/flag-03c3b29b35.png +0 -0
- data/examples/compass/images/flag-21cfbfbfc8.png +0 -0
- data/examples/css3/extensions/fancy-fonts/templates/project/Prociono.otf +0 -0
- data/examples/css3/extensions/fancy-fonts/templates/project/bgrove.otf +0 -0
- data/frameworks/blueprint/stylesheets/_blueprint.scss +0 -37
- data/frameworks/blueprint/stylesheets/blueprint/_buttons.scss +0 -101
- data/frameworks/blueprint/stylesheets/blueprint/_colors.scss +0 -36
- data/frameworks/blueprint/stylesheets/blueprint/_debug.scss +0 -28
- data/frameworks/blueprint/stylesheets/blueprint/_fancy-type.scss +0 -88
- data/frameworks/blueprint/stylesheets/blueprint/_form.scss +0 -66
- data/frameworks/blueprint/stylesheets/blueprint/_grid.scss +0 -258
- data/frameworks/blueprint/stylesheets/blueprint/_ie.scss +0 -111
- data/frameworks/blueprint/stylesheets/blueprint/_interaction.scss +0 -66
- data/frameworks/blueprint/stylesheets/blueprint/_link-icons.scss +0 -37
- data/frameworks/blueprint/stylesheets/blueprint/_liquid.scss +0 -152
- data/frameworks/blueprint/stylesheets/blueprint/_print.scss +0 -86
- data/frameworks/blueprint/stylesheets/blueprint/_reset.scss +0 -3
- data/frameworks/blueprint/stylesheets/blueprint/_rtl.scss +0 -121
- data/frameworks/blueprint/stylesheets/blueprint/_scaffolding.scss +0 -52
- data/frameworks/blueprint/stylesheets/blueprint/_typography.scss +0 -90
- data/frameworks/blueprint/stylesheets/blueprint/_utilities.scss +0 -37
- data/frameworks/blueprint/stylesheets/blueprint/reset/_utilities.scss +0 -83
- data/frameworks/blueprint/templates/basic/grid.png +0 -0
- data/frameworks/blueprint/templates/basic/ie.sass +0 -4
- data/frameworks/blueprint/templates/basic/manifest.rb +0 -30
- data/frameworks/blueprint/templates/basic/partials/_base.sass +0 -10
- data/frameworks/blueprint/templates/basic/print.sass +0 -4
- data/frameworks/blueprint/templates/basic/screen.sass +0 -12
- 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/buttons.sass +0 -49
- data/frameworks/blueprint/templates/buttons/manifest.rb +0 -17
- 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/link_icons.sass +0 -13
- data/frameworks/blueprint/templates/link_icons/manifest.rb +0 -23
- data/frameworks/blueprint/templates/project/grid.png +0 -0
- data/frameworks/blueprint/templates/project/ie.sass +0 -16
- data/frameworks/blueprint/templates/project/manifest.rb +0 -30
- data/frameworks/blueprint/templates/project/partials/_base.sass +0 -11
- data/frameworks/blueprint/templates/project/print.sass +0 -8
- data/frameworks/blueprint/templates/project/screen.sass +0 -46
- data/frameworks/blueprint/templates/semantic/grid.png +0 -0
- data/frameworks/blueprint/templates/semantic/ie.sass +0 -16
- data/frameworks/blueprint/templates/semantic/manifest.rb +0 -33
- data/frameworks/blueprint/templates/semantic/partials/_base.sass +0 -10
- data/frameworks/blueprint/templates/semantic/partials/_form.sass +0 -6
- data/frameworks/blueprint/templates/semantic/partials/_page.sass +0 -17
- data/frameworks/blueprint/templates/semantic/partials/_two_col.sass +0 -38
- data/frameworks/blueprint/templates/semantic/print.sass +0 -5
- data/frameworks/blueprint/templates/semantic/screen.sass +0 -14
- data/lib/compass/commands/generate_grid_background.rb +0 -96
- data/lib/compass/grid_builder.rb +0 -102
- data/test/fixtures/stylesheets/blueprint/config.rb +0 -14
- data/test/fixtures/stylesheets/blueprint/css/ie.css +0 -76
- data/test/fixtures/stylesheets/blueprint/css/print.css +0 -56
- data/test/fixtures/stylesheets/blueprint/css/screen.css +0 -815
- data/test/fixtures/stylesheets/blueprint/css/single-imports/buttons.css +0 -56
- data/test/fixtures/stylesheets/blueprint/css/single-imports/colors.css +0 -80
- data/test/fixtures/stylesheets/blueprint/css/single-imports/debug.css +0 -11
- data/test/fixtures/stylesheets/blueprint/css/single-imports/fancy-type.css +0 -30
- data/test/fixtures/stylesheets/blueprint/css/single-imports/form.css +0 -42
- data/test/fixtures/stylesheets/blueprint/css/single-imports/grid.css +0 -435
- data/test/fixtures/stylesheets/blueprint/css/single-imports/ie.css +0 -76
- data/test/fixtures/stylesheets/blueprint/css/single-imports/interaction.css +0 -46
- data/test/fixtures/stylesheets/blueprint/css/single-imports/link-icons.css +0 -40
- data/test/fixtures/stylesheets/blueprint/css/single-imports/liquid.css +0 -651
- data/test/fixtures/stylesheets/blueprint/css/single-imports/print.css +0 -60
- data/test/fixtures/stylesheets/blueprint/css/single-imports/reset-utilities.css +0 -69
- data/test/fixtures/stylesheets/blueprint/css/single-imports/reset.css +0 -42
- data/test/fixtures/stylesheets/blueprint/css/single-imports/rtl.css +0 -437
- data/test/fixtures/stylesheets/blueprint/css/single-imports/scaffolding.css +0 -45
- data/test/fixtures/stylesheets/blueprint/css/single-imports/typography.css +0 -146
- data/test/fixtures/stylesheets/blueprint/css/single-imports/utilities.css +0 -35
- data/test/fixtures/stylesheets/blueprint/images/grid.png +0 -0
- data/test/fixtures/stylesheets/blueprint/images/link_icons/doc.png +0 -0
- data/test/fixtures/stylesheets/blueprint/images/link_icons/email.png +0 -0
- data/test/fixtures/stylesheets/blueprint/images/link_icons/external.png +0 -0
- data/test/fixtures/stylesheets/blueprint/images/link_icons/feed.png +0 -0
- data/test/fixtures/stylesheets/blueprint/images/link_icons/im.png +0 -0
- data/test/fixtures/stylesheets/blueprint/images/link_icons/pdf.png +0 -0
- data/test/fixtures/stylesheets/blueprint/images/link_icons/visited.png +0 -0
- data/test/fixtures/stylesheets/blueprint/images/link_icons/xls.png +0 -0
- data/test/fixtures/stylesheets/blueprint/sass/ie.sass +0 -3
- data/test/fixtures/stylesheets/blueprint/sass/print.sass +0 -3
- data/test/fixtures/stylesheets/blueprint/sass/screen.sass +0 -18
- data/test/fixtures/stylesheets/blueprint/sass/single-imports/buttons.scss +0 -4
- data/test/fixtures/stylesheets/blueprint/sass/single-imports/colors.scss +0 -34
- data/test/fixtures/stylesheets/blueprint/sass/single-imports/debug.scss +0 -3
- data/test/fixtures/stylesheets/blueprint/sass/single-imports/fancy-type.scss +0 -3
- data/test/fixtures/stylesheets/blueprint/sass/single-imports/form.scss +0 -5
- data/test/fixtures/stylesheets/blueprint/sass/single-imports/grid.scss +0 -3
- data/test/fixtures/stylesheets/blueprint/sass/single-imports/ie.scss +0 -3
- data/test/fixtures/stylesheets/blueprint/sass/single-imports/interaction.scss +0 -3
- data/test/fixtures/stylesheets/blueprint/sass/single-imports/link-icons.scss +0 -13
- data/test/fixtures/stylesheets/blueprint/sass/single-imports/liquid.scss +0 -3
- data/test/fixtures/stylesheets/blueprint/sass/single-imports/print.scss +0 -5
- data/test/fixtures/stylesheets/blueprint/sass/single-imports/reset-utilities.scss +0 -5
- data/test/fixtures/stylesheets/blueprint/sass/single-imports/reset.scss +0 -1
- data/test/fixtures/stylesheets/blueprint/sass/single-imports/rtl.scss +0 -3
- data/test/fixtures/stylesheets/blueprint/sass/single-imports/scaffolding.scss +0 -5
- data/test/fixtures/stylesheets/blueprint/sass/single-imports/typography.scss +0 -3
- data/test/fixtures/stylesheets/blueprint/sass/single-imports/utilities.scss +0 -3
- data/test/fixtures/stylesheets/compass/images/flag-s4798b5a210.png +0 -0
- data/test/units/compass_png_test.rb +0 -46
- /data/{examples/css3/extensions/fancy-fonts/templates/project/bgrove.ttf → test/fixtures/stylesheets/busted_font_urls/fonts/feed.ttf} +0 -0
|
@@ -32,128 +32,22 @@ module Compass
|
|
|
32
32
|
def compute_image_positions!
|
|
33
33
|
case layout
|
|
34
34
|
when SMART
|
|
35
|
-
|
|
35
|
+
require 'compass/sass_extensions/sprites/layout/smart'
|
|
36
|
+
@images, @width, @height = Layout::Smart.new(@images, @kwargs).properties
|
|
36
37
|
when DIAGONAL
|
|
37
|
-
|
|
38
|
-
|
|
38
|
+
require 'compass/sass_extensions/sprites/layout/diagonal'
|
|
39
|
+
@images, @width, @height = Layout::Diagonal.new(@images, @kwargs).properties
|
|
39
40
|
when HORIZONTAL
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
@width = width_for_horizontal_layout
|
|
41
|
+
require 'compass/sass_extensions/sprites/layout/horizontal'
|
|
42
|
+
@images, @width, @height = Layout::Horizontal.new(@images, @kwargs).properties
|
|
43
43
|
else
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
a.name <=> b.name
|
|
47
|
-
else
|
|
48
|
-
b.size <=> a.size
|
|
49
|
-
end
|
|
50
|
-
end
|
|
51
|
-
|
|
52
|
-
@width = width_for_vertical_layout
|
|
53
|
-
calulate_vertical_postions
|
|
54
|
-
@height = height_for_vertical_layout
|
|
55
|
-
if @images.any?(&:repeat_x?)
|
|
56
|
-
calculate_repeat_extra_width!
|
|
57
|
-
tile_images_that_repeat
|
|
58
|
-
end
|
|
59
|
-
end
|
|
60
|
-
end
|
|
61
|
-
|
|
62
|
-
def tile_images_that_repeat
|
|
63
|
-
@images.map {|img| img if img.repeat_x?}.compact.each do |image|
|
|
64
|
-
x = image.left - (image.left / image.width).ceil * image.width
|
|
65
|
-
while x < @width do
|
|
66
|
-
begin
|
|
67
|
-
img = image.dup
|
|
68
|
-
img.top = image.top
|
|
69
|
-
img.left = x.to_i
|
|
70
|
-
@images << img
|
|
71
|
-
x += image.width
|
|
72
|
-
end
|
|
73
|
-
end
|
|
74
|
-
end
|
|
75
|
-
end
|
|
76
|
-
|
|
77
|
-
def calculate_repeat_extra_width!
|
|
78
|
-
require 'rational' #for ruby 1.8.7
|
|
79
|
-
m = @images.inject(1) {|m,img| img.repeat_x? ? m.lcm(img.width) : m}
|
|
80
|
-
remainder = @width % m
|
|
81
|
-
@width += (m - remainder) unless remainder.zero?
|
|
82
|
-
end
|
|
83
|
-
|
|
84
|
-
def calculate_smart_positions
|
|
85
|
-
fitter = ::Compass::SassExtensions::Sprites::RowFitter.new(@images)
|
|
86
|
-
current_y = 0
|
|
87
|
-
fitter.fit!.each do |row|
|
|
88
|
-
current_x = 0
|
|
89
|
-
row.images.each_with_index do |image, index|
|
|
90
|
-
image.left = current_x
|
|
91
|
-
image.top = current_y
|
|
92
|
-
current_x += image.width
|
|
93
|
-
end
|
|
94
|
-
current_y += row.height
|
|
95
|
-
end
|
|
96
|
-
@width = fitter.width
|
|
97
|
-
@height = fitter.height
|
|
98
|
-
end
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
def calculate_diagonal_dimensions
|
|
102
|
-
@width = @images.inject(0) {|sum, img| sum + img.width}
|
|
103
|
-
@height = @images.inject(0) {|sum, img| sum + img.height}
|
|
104
|
-
end
|
|
105
|
-
|
|
106
|
-
def calculate_diagonal_positions
|
|
107
|
-
previous = nil
|
|
108
|
-
@images.each_with_index do |image, index|
|
|
109
|
-
if previous.nil?
|
|
110
|
-
previous = image
|
|
111
|
-
image.top = @height - image.height
|
|
112
|
-
image.left = 0
|
|
113
|
-
next
|
|
114
|
-
end
|
|
115
|
-
image.top = previous.top - image.height
|
|
116
|
-
image.left = previous.left + previous.width
|
|
117
|
-
previous = image
|
|
44
|
+
require 'compass/sass_extensions/sprites/layout/vertical'
|
|
45
|
+
@images, @width, @height = Layout::Vertical.new(@images, @kwargs).properties
|
|
118
46
|
end
|
|
119
47
|
end
|
|
120
48
|
|
|
121
|
-
def calculate_horizontal_positions
|
|
122
|
-
@images.each_with_index do |image, index|
|
|
123
|
-
image.top = image.position.unit_str == '%' ? (@height - image.height) * (image.position.value / 100.0) : image.position.value
|
|
124
|
-
next if index == 0
|
|
125
|
-
last_image = @images[index-1]
|
|
126
|
-
image.left = last_image.left + last_image.width + [image.spacing, last_image.spacing].max
|
|
127
|
-
end
|
|
128
|
-
end
|
|
129
|
-
|
|
130
|
-
def calulate_vertical_postions
|
|
131
|
-
@images.each_with_index do |image, index|
|
|
132
|
-
image.left = (image.position.unit_str == "%" ? (@width - image.width) * (image.position.value / 100.0) : image.position.value).to_i
|
|
133
|
-
next if index == 0
|
|
134
|
-
last_image = @images[index-1]
|
|
135
|
-
image.top = last_image.top + last_image.height + [image.spacing, last_image.spacing].max
|
|
136
|
-
end
|
|
137
|
-
end
|
|
138
|
-
|
|
139
|
-
def height_for_vertical_layout
|
|
140
|
-
last = @images.last
|
|
141
|
-
last.top + last.height
|
|
142
|
-
end
|
|
143
|
-
|
|
144
|
-
def height_for_horizontal_layout
|
|
145
|
-
@height = @images.map {|image| image.height + image.offset}.max
|
|
146
|
-
end
|
|
147
|
-
|
|
148
|
-
def width_for_horizontal_layout
|
|
149
|
-
@images.inject(0) { |sum, image| sum += (image.width + image.spacing) }
|
|
150
|
-
end
|
|
151
|
-
|
|
152
|
-
def width_for_vertical_layout
|
|
153
|
-
@images.map { |image| image.width + image.offset }.max
|
|
154
|
-
end
|
|
155
49
|
end
|
|
156
50
|
end
|
|
157
51
|
end
|
|
158
52
|
end
|
|
159
|
-
|
|
53
|
+
|
|
@@ -39,15 +39,19 @@ module Compass
|
|
|
39
39
|
@kwargs = kwargs
|
|
40
40
|
@kwargs['cleanup'] ||= Sass::Script::Bool.new(true)
|
|
41
41
|
@kwargs['layout'] ||= Sass::Script::String.new('vertical')
|
|
42
|
+
@kwargs['sort_by'] ||= Sass::Script::String.new('none')
|
|
42
43
|
@images = nil
|
|
43
44
|
@width = nil
|
|
44
45
|
@height = nil
|
|
45
46
|
@engine = nil
|
|
46
47
|
@evaluation_context = context
|
|
47
|
-
validate!
|
|
48
48
|
compute_image_metadata!
|
|
49
49
|
end
|
|
50
50
|
|
|
51
|
+
def sort_method
|
|
52
|
+
@kwargs['sort_by'].value
|
|
53
|
+
end
|
|
54
|
+
|
|
51
55
|
def inspect
|
|
52
56
|
puts 'images'
|
|
53
57
|
@images.each do |img|
|
|
@@ -26,20 +26,15 @@ module Compass
|
|
|
26
26
|
|
|
27
27
|
# Creates the Sprite::Image objects for each image and calculates the width
|
|
28
28
|
def init_images
|
|
29
|
-
@images =
|
|
30
|
-
|
|
29
|
+
@images = Images.new
|
|
30
|
+
image_names.each do |relative_file|
|
|
31
|
+
@images << Image.new(self, relative_file, kwargs)
|
|
31
32
|
end
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
# Validates that the sprite_names are valid sass
|
|
35
|
-
def validate!
|
|
36
|
-
for sprite_name in sprite_names
|
|
37
|
-
unless sprite_name =~ /\A#{Sass::SCSS::RX::IDENT}\Z/
|
|
38
|
-
raise Sass::SyntaxError, "#{sprite_name} must be a legal css identifier"
|
|
39
|
-
end
|
|
33
|
+
unless sort_method == 'none'
|
|
34
|
+
@images.sort_by! sort_method
|
|
40
35
|
end
|
|
41
36
|
end
|
|
42
|
-
|
|
37
|
+
|
|
43
38
|
def name_and_hash
|
|
44
39
|
"#{path}-s#{uniqueness_hash}.png"
|
|
45
40
|
end
|
|
@@ -68,7 +63,7 @@ module Compass
|
|
|
68
63
|
end
|
|
69
64
|
|
|
70
65
|
def cleanup_old_sprites
|
|
71
|
-
|
|
66
|
+
Sass::Util.glob(File.join(Compass.configuration.generated_images_path, "#{path}-s*.png")).each do |file|
|
|
72
67
|
log :remove, file
|
|
73
68
|
FileUtils.rm file
|
|
74
69
|
Compass.configuration.run_sprite_removed(file)
|
|
@@ -77,7 +72,7 @@ module Compass
|
|
|
77
72
|
|
|
78
73
|
# Does this sprite need to be generated
|
|
79
74
|
def generation_required?
|
|
80
|
-
!File.exists?(filename) || outdated? ||
|
|
75
|
+
!File.exists?(filename) || outdated? || options[:force]
|
|
81
76
|
end
|
|
82
77
|
|
|
83
78
|
# Returns the uniqueness hash for this sprite object
|
|
@@ -138,4 +133,4 @@ module Compass
|
|
|
138
133
|
end
|
|
139
134
|
end
|
|
140
135
|
end
|
|
141
|
-
end
|
|
136
|
+
end
|
|
@@ -8,6 +8,8 @@ module Compass
|
|
|
8
8
|
end
|
|
9
9
|
end
|
|
10
10
|
|
|
11
|
+
require 'compass/sass_extensions/sprites/images'
|
|
12
|
+
require 'compass/sass_extensions/sprites/layout'
|
|
11
13
|
require 'compass/sass_extensions/sprites/image_row'
|
|
12
14
|
require 'compass/sass_extensions/sprites/row_fitter'
|
|
13
15
|
require 'compass/sass_extensions/sprites/image'
|
|
@@ -2,18 +2,20 @@
|
|
|
2
2
|
|
|
3
3
|
// General Sprite Defaults
|
|
4
4
|
// You can override them before you import this file.
|
|
5
|
-
$<%= name %>-sprite-base-class: ".<%= name %>-sprite" !default;
|
|
6
|
-
$<%= name %>-sprite-dimensions: false !default;
|
|
7
|
-
$<%= name %>-
|
|
8
|
-
$<%= name %>-
|
|
9
|
-
$<%= name %>-
|
|
10
|
-
$<%= name %>-
|
|
11
|
-
$<%= name %>-
|
|
12
|
-
$<%= name %>-
|
|
13
|
-
$<%= name %>-
|
|
5
|
+
$<%= name %>-sprite-base-class : ".<%= name %>-sprite" !default;
|
|
6
|
+
$<%= name %>-sprite-dimensions : false !default;
|
|
7
|
+
$<%= name %>-use-percentages : false !default;
|
|
8
|
+
$<%= name %>-position : 0% !default;
|
|
9
|
+
$<%= name %>-spacing : 0 !default;
|
|
10
|
+
$<%= name %>-repeat : no-repeat !default;
|
|
11
|
+
$<%= name %>-prefix : '' !default;
|
|
12
|
+
$<%= name %>-clean-up : true !default;
|
|
13
|
+
$<%= name %>-layout : vertical !default;
|
|
14
|
+
$<%= name %>-inline : false !default;
|
|
15
|
+
$<%= name %>-sort-by : 'none' !default;
|
|
14
16
|
|
|
15
17
|
<% if skip_overrides %>
|
|
16
|
-
$<%= name %>-sprites: sprite-map("<%= uri %>", $layout: $<%= name %>-layout, $cleanup: $<%= name %>-clean-up);
|
|
18
|
+
$<%= name %>-sprites: sprite-map("<%= uri %>", $layout: $<%= name %>-layout, $cleanup: $<%= name %>-clean-up, $spacing: $<%= name %>-spacing, $position : $<%= name %>-position);
|
|
17
19
|
<% else %>
|
|
18
20
|
// These variables control the generated sprite output
|
|
19
21
|
// You can override them selectively before you import this file.
|
|
@@ -29,8 +31,11 @@ $<%= name %>-inline: false !default;
|
|
|
29
31
|
$<%= name %>-<%= sprite_name %>-spacing: $<%= name %>-<%= sprite_name %>-spacing,
|
|
30
32
|
$<%= name %>-<%= sprite_name %>-repeat: $<%= name %>-<%= sprite_name %>-repeat,
|
|
31
33
|
<% end %>
|
|
32
|
-
$layout: $<%= name %>-layout,
|
|
33
|
-
$cleanup: $<%= name %>-clean-up
|
|
34
|
+
$layout : $<%= name %>-layout,
|
|
35
|
+
$cleanup : $<%= name %>-clean-up,
|
|
36
|
+
$spacing : $<%= name %>-spacing,
|
|
37
|
+
$position : $<%= name %>-position,
|
|
38
|
+
$sort-by : $<%= name %>-sort-by
|
|
34
39
|
);
|
|
35
40
|
<% end %>
|
|
36
41
|
|
|
@@ -42,14 +47,14 @@ $<%= name %>-inline: false !default;
|
|
|
42
47
|
}
|
|
43
48
|
} @else {
|
|
44
49
|
#{$<%= name %>-sprite-base-class} {
|
|
45
|
-
background: $<%= name %>-sprites
|
|
50
|
+
background-image: $<%= name %>-sprites;
|
|
51
|
+
background-repeat: no-repeat;
|
|
46
52
|
}
|
|
47
53
|
}
|
|
48
54
|
//sass functions to return the dimensions of a sprite image as units
|
|
49
55
|
<% [:width, :height].each do |dimension| %>
|
|
50
56
|
@function <%= name %>-sprite-<%= dimension %>($name) {
|
|
51
|
-
|
|
52
|
-
@return image-<%= dimension %>($file);
|
|
57
|
+
@return sprite-<%= dimension %>($<%= name %>-sprites, $name);
|
|
53
58
|
}
|
|
54
59
|
<% end %>
|
|
55
60
|
|
|
@@ -60,22 +65,22 @@ $<%= name %>-inline: false !default;
|
|
|
60
65
|
}
|
|
61
66
|
|
|
62
67
|
// Move the background position to display the sprite.
|
|
63
|
-
@mixin <%= name %>-sprite-position($name, $offset-x: 0, $offset-y: 0) {
|
|
64
|
-
@include sprite-background-position($<%= name %>-sprites, $name, $offset-x, $offset-y)
|
|
68
|
+
@mixin <%= name %>-sprite-position($name, $offset-x: 0, $offset-y: 0, $use-percentages: $<%= name %>-use-percentages) {
|
|
69
|
+
@include sprite-background-position($<%= name %>-sprites, $name, $offset-x, $offset-y, $use-percentages)
|
|
65
70
|
}
|
|
66
71
|
|
|
67
72
|
// Extends the sprite base class and set the background position for the desired sprite.
|
|
68
73
|
// It will also apply the image dimensions if $dimensions is true.
|
|
69
|
-
@mixin <%= name %>-sprite($name, $dimensions: $<%= name %>-sprite-dimensions, $offset-x: 0, $offset-y: 0) {
|
|
74
|
+
@mixin <%= name %>-sprite($name, $dimensions: $<%= name %>-sprite-dimensions, $offset-x: 0, $offset-y: 0, $use-percentages: $<%= name %>-use-percentages) {
|
|
70
75
|
@extend #{$<%= name %>-sprite-base-class};
|
|
71
|
-
@include sprite($<%= name %>-sprites, $name, $dimensions, $offset-x, $offset-y)
|
|
76
|
+
@include sprite($<%= name %>-sprites, $name, $dimensions, $offset-x, $offset-y, $use-percentages);
|
|
72
77
|
}
|
|
73
78
|
|
|
74
|
-
@mixin <%= name %>-sprites($sprite-names, $dimensions: $<%= name %>-sprite-dimensions, $prefix: sprite-map-name($<%= name %>-sprites), $offset-x: 0, $offset-y: 0) {
|
|
75
|
-
@include sprites($<%= name %>-sprites, $sprite-names, $<%= name %>-sprite-base-class, $dimensions, $prefix, $offset-x, $offset-y)
|
|
79
|
+
@mixin <%= name %>-sprites($sprite-names, $dimensions: $<%= name %>-sprite-dimensions, $prefix: sprite-map-name($<%= name %>-sprites), $offset-x: 0, $offset-y: 0, $use-percentages: $<%= name %>-use-percentages) {
|
|
80
|
+
@include sprites($<%= name %>-sprites, $sprite-names, $<%= name %>-sprite-base-class, $dimensions, $prefix, $offset-x, $offset-y, $use-percentages)
|
|
76
81
|
}
|
|
77
82
|
|
|
78
83
|
// Generates a class for each sprited image.
|
|
79
|
-
@mixin all-<%= name %>-sprites($dimensions: $<%= name %>-sprite-dimensions, $prefix: sprite-map-name($<%= name %>-sprites), $offset-x: 0, $offset-y: 0) {
|
|
80
|
-
@include <%= name %>-sprites(<%= sprite_names.join(" ") %>, $dimensions, $prefix, $offset-x, $offset-y);
|
|
81
|
-
}
|
|
84
|
+
@mixin all-<%= name %>-sprites($dimensions: $<%= name %>-sprite-dimensions, $prefix: sprite-map-name($<%= name %>-sprites), $offset-x: 0, $offset-y: 0, $use-percentages: $<%= name %>-use-percentages) {
|
|
85
|
+
@include <%= name %>-sprites(<%= sprite_names.join(" ") %>, $dimensions, $prefix, $offset-x, $offset-y, $use-percentages);
|
|
86
|
+
}
|
|
@@ -2,13 +2,13 @@ require 'erb'
|
|
|
2
2
|
require 'compass/sprite_importer/binding'
|
|
3
3
|
module Compass
|
|
4
4
|
class SpriteImporter < Sass::Importers::Base
|
|
5
|
-
VAILD_FILE_NAME
|
|
5
|
+
VAILD_FILE_NAME = /\A#{Sass::SCSS::RX::IDENT}\Z/
|
|
6
6
|
SPRITE_IMPORTER_REGEX = %r{((.+/)?([^\*.]+))/(.+?)\.png}
|
|
7
|
-
VALID_EXTENSIONS
|
|
7
|
+
VALID_EXTENSIONS = ['.png']
|
|
8
8
|
|
|
9
|
-
TEMPLATE_FOLDER
|
|
9
|
+
TEMPLATE_FOLDER = File.join(File.expand_path('../', __FILE__), 'sprite_importer')
|
|
10
10
|
CONTENT_TEMPLATE_FILE = File.join(TEMPLATE_FOLDER, 'content.erb')
|
|
11
|
-
CONTENT_TEMPLATE
|
|
11
|
+
CONTENT_TEMPLATE = ERB.new(File.read(CONTENT_TEMPLATE_FILE))
|
|
12
12
|
|
|
13
13
|
|
|
14
14
|
|
|
@@ -16,7 +16,7 @@ module Compass
|
|
|
16
16
|
def self.find_all_sprite_map_files(path)
|
|
17
17
|
hex = "[0-9a-f]"
|
|
18
18
|
glob = "*-s#{hex*10}{#{VALID_EXTENSIONS.join(",")}}"
|
|
19
|
-
|
|
19
|
+
Sass::Util.glob(File.join(path, "**", glob))
|
|
20
20
|
end
|
|
21
21
|
|
|
22
22
|
def find(uri, options)
|
|
@@ -75,7 +75,7 @@ module Compass
|
|
|
75
75
|
# Returns the Glob of image files for the uri
|
|
76
76
|
def self.files(uri)
|
|
77
77
|
Compass.configuration.sprite_load_path.compact.each do |folder|
|
|
78
|
-
files =
|
|
78
|
+
files = Sass::Util.glob(File.join(folder, uri)).sort
|
|
79
79
|
next if files.empty?
|
|
80
80
|
return files
|
|
81
81
|
end
|
|
@@ -87,11 +87,7 @@ module Compass
|
|
|
87
87
|
# Returns an Array of image names without the file extension
|
|
88
88
|
def self.sprite_names(uri)
|
|
89
89
|
files(uri).collect do |file|
|
|
90
|
-
|
|
91
|
-
unless VAILD_FILE_NAME =~ filename
|
|
92
|
-
raise Compass::Error, "Sprite file names must be legal css identifiers. Please rename #{File.basename(file)}"
|
|
93
|
-
end
|
|
94
|
-
filename
|
|
90
|
+
File.basename(file, '.png')
|
|
95
91
|
end
|
|
96
92
|
end
|
|
97
93
|
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
module Compass
|
|
2
|
+
module Watcher
|
|
3
|
+
class Compiler
|
|
4
|
+
include Compass::Actions
|
|
5
|
+
attr_reader :working_path, :memory_store, :backing_store, :cache_store, :compiler_options, :compiler
|
|
6
|
+
|
|
7
|
+
def initialize(working_path, additional_options={})
|
|
8
|
+
@working_path = working_path
|
|
9
|
+
@compiler_options = create_compiler_options(additional_options)
|
|
10
|
+
@memory_store ||= Sass::CacheStores::Memory.new
|
|
11
|
+
@backing_store ||= compiler_options[:cache_store]
|
|
12
|
+
@backing_store ||= Sass::CacheStores::Filesystem.new(determine_cache_location)
|
|
13
|
+
@cache_store ||= Sass::CacheStores::Chain.new(@memory_store, @backing_store)
|
|
14
|
+
@compiler ||= create_compiler
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def compile
|
|
18
|
+
@memory_cache.reset! if @memory_cache
|
|
19
|
+
compiler.reset_staleness_checker!
|
|
20
|
+
if file = compiler.out_of_date?
|
|
21
|
+
begin
|
|
22
|
+
time = Time.now.strftime("%T")
|
|
23
|
+
log_action(:info, "Change detected at #{time} to: #{compiler.relative_stylesheet_name(file)}", compiler_options)
|
|
24
|
+
compiler.run
|
|
25
|
+
GC.start
|
|
26
|
+
rescue StandardError => e
|
|
27
|
+
::Compass::Exec::Helpers.report_error(e, compiler_options)
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
private #=========================================================================================>
|
|
33
|
+
|
|
34
|
+
def create_compiler_options(additional_options)
|
|
35
|
+
compiler_opts = {:sass => Compass.sass_engine_options, :cache_store => @cache_store, :quiet => true, :loud => [:identical, :overwrite, :create]}.merge(additional_options)
|
|
36
|
+
compiler_opts[:cache_location] ||= determine_cache_location
|
|
37
|
+
if compiler_opts.include?(:debug_info)
|
|
38
|
+
compiler_opts[:sass][:debug_info] = compiler_opts.delete(:debug_info)
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
compiler_opts
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
def create_compiler
|
|
45
|
+
@memory_store.reset!
|
|
46
|
+
Compass::Compiler.new(
|
|
47
|
+
working_path,
|
|
48
|
+
Compass.configuration.sass_path,
|
|
49
|
+
Compass.configuration.css_path,
|
|
50
|
+
compiler_options.dup
|
|
51
|
+
)
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
def determine_cache_location
|
|
55
|
+
Compass.configuration.cache_path || Sass::Plugin.options[:cache_location] || File.join(working_path, ".sass-cache")
|
|
56
|
+
end
|
|
57
|
+
end
|
|
58
|
+
end
|
|
59
|
+
end
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
require 'listen'
|
|
2
|
+
require 'forwardable'
|
|
3
|
+
module Compass
|
|
4
|
+
module Watcher
|
|
5
|
+
class ProjectWatcher
|
|
6
|
+
include Compass::Actions
|
|
7
|
+
SASS_FILTER = '*.s[ac]ss'
|
|
8
|
+
ALL_CHILDREN_SASS_FILTER = File.join('**', SASS_FILTER)
|
|
9
|
+
POLLING_MESSAGE = 'Compass is polling for changes'
|
|
10
|
+
|
|
11
|
+
attr_reader :options, :project_path, :watcher_compiler, :listener, :poll, :css_dir, :sass_watchers
|
|
12
|
+
|
|
13
|
+
alias :working_path :project_path
|
|
14
|
+
|
|
15
|
+
extend Forwardable
|
|
16
|
+
|
|
17
|
+
def_delegators :@watcher_compiler, :compiler, :compiler
|
|
18
|
+
def_delegators :@watcher_compiler, :compile, :compile
|
|
19
|
+
|
|
20
|
+
def initialize(project_path, watches=[], options={}, poll=false)
|
|
21
|
+
@poll = poll
|
|
22
|
+
@options = options
|
|
23
|
+
@project_path = project_path
|
|
24
|
+
@css_dir = Compass.configuration.css_dir
|
|
25
|
+
@sass_watchers = create_sass_watchers + watches
|
|
26
|
+
@watcher_compiler = Compass::Watcher::Compiler.new(project_path, options)
|
|
27
|
+
setup_listener
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def watch!
|
|
31
|
+
listener.start
|
|
32
|
+
rescue Interrupt
|
|
33
|
+
log_action(:info, "Good bye!", options)
|
|
34
|
+
listener.stop
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
private #============================================================================>
|
|
38
|
+
|
|
39
|
+
def setup_listener
|
|
40
|
+
@listener = Listen.to(@project_path, :relative_paths => true)
|
|
41
|
+
if poll
|
|
42
|
+
@listener = listener.force_polling(true)
|
|
43
|
+
end
|
|
44
|
+
@listener = listener.polling_fallback_message(POLLING_MESSAGE)
|
|
45
|
+
@listener = listener.ignore(/\.css$/)
|
|
46
|
+
@listener = listener.change(&method(:listen_callback))
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
def create_sass_watchers
|
|
50
|
+
watches = []
|
|
51
|
+
Compass.configuration.sass_load_paths.map do |load_path|
|
|
52
|
+
load_path = load_path.root if load_path.respond_to?(:root)
|
|
53
|
+
next unless load_path.is_a? String
|
|
54
|
+
next unless load_path.include? project_path
|
|
55
|
+
load_path = Pathname.new(load_path).relative_path_from(Pathname.new(project_path))
|
|
56
|
+
filter = File.join(load_path, SASS_FILTER)
|
|
57
|
+
children = File.join(load_path, ALL_CHILDREN_SASS_FILTER)
|
|
58
|
+
if filter.match(%r{^./})
|
|
59
|
+
watches << Watcher::Watch.new(SASS_FILTER, &method(:sass_callback))
|
|
60
|
+
end
|
|
61
|
+
watches << Watcher::Watch.new(filter, &method(:sass_callback))
|
|
62
|
+
watches << Watcher::Watch.new(children, &method(:sass_callback))
|
|
63
|
+
end
|
|
64
|
+
watches.compact
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
def listen_callback(modified_file, added_file, removed_file)
|
|
68
|
+
#log_action(:info, ">>> Listen Callback fired added: #{added_file}, mod: #{modified_file}, rem: #{removed_file}", {})
|
|
69
|
+
action = nil
|
|
70
|
+
action ||= :modified unless modified_file.empty?
|
|
71
|
+
action ||= :added unless added_file.empty?
|
|
72
|
+
action ||= :removed unless removed_file.empty?
|
|
73
|
+
|
|
74
|
+
files = modified_file + added_file + removed_file
|
|
75
|
+
# run watchers
|
|
76
|
+
sass_watchers.each do |watcher|
|
|
77
|
+
files.each do |file|
|
|
78
|
+
watcher.run_callback(project_path, file, action) if watcher.match?(file)
|
|
79
|
+
end
|
|
80
|
+
end
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
def sass_callback(base, file, action)
|
|
84
|
+
#log_action(:info, ">>> Sass Callback fired #{action}, #{file}", {})
|
|
85
|
+
sass_modified(file) if action == :modified
|
|
86
|
+
sass_added(file) if action == :added
|
|
87
|
+
sass_removed(file) if action == :removed
|
|
88
|
+
end
|
|
89
|
+
|
|
90
|
+
def sass_modified(file)
|
|
91
|
+
log_action(:info, "#{file} was modified", options)
|
|
92
|
+
compile
|
|
93
|
+
end
|
|
94
|
+
|
|
95
|
+
def sass_added(file)
|
|
96
|
+
log_action(:info, "#{file} was added", options)
|
|
97
|
+
compile
|
|
98
|
+
end
|
|
99
|
+
|
|
100
|
+
def sass_removed(file)
|
|
101
|
+
log_action(:info, "#{file} was removed", options)
|
|
102
|
+
css_file = compiler.corresponding_css_file(File.join(project_path, file))
|
|
103
|
+
compile
|
|
104
|
+
if File.exists?(css_file)
|
|
105
|
+
remove(css_file)
|
|
106
|
+
end
|
|
107
|
+
end
|
|
108
|
+
|
|
109
|
+
end
|
|
110
|
+
end
|
|
111
|
+
end
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
module Compass
|
|
2
|
+
module Watcher
|
|
3
|
+
class Watch
|
|
4
|
+
attr_reader :callback, :glob
|
|
5
|
+
|
|
6
|
+
def initialize(glob, &block)
|
|
7
|
+
@callback = block
|
|
8
|
+
@glob = glob
|
|
9
|
+
verify!
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def match?(changed_path)
|
|
13
|
+
File.fnmatch(glob, changed_path)
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def run_callback(base, relative, action)
|
|
17
|
+
callback.call(base, relative, action)
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
private
|
|
21
|
+
|
|
22
|
+
def verify!
|
|
23
|
+
if Pathname.new(glob).absolute?
|
|
24
|
+
raise AbsolutePathError, "Only paths relative to the project can be watched"
|
|
25
|
+
end
|
|
26
|
+
if callback.nil?
|
|
27
|
+
raise NoCallbackError, "A Block must be supplied in order to be watched"
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
end
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
require 'compass/watcher/watch'
|
|
2
|
+
require 'compass/watcher/compiler'
|
|
3
|
+
require 'compass/watcher/project_watcher'
|
|
4
|
+
|
|
5
|
+
module Compass
|
|
6
|
+
module Watcher
|
|
7
|
+
class WatcherException < Compass::Error; end
|
|
8
|
+
class NoCallbackError < WatcherException; end
|
|
9
|
+
class AbsolutePathError < WatcherException; end
|
|
10
|
+
end
|
|
11
|
+
end
|
data/lib/compass.rb
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
module Compass
|
|
2
2
|
end
|
|
3
3
|
|
|
4
|
-
%w(dependencies util browser_support sass_extensions version errors quick_cache logger).each do |lib|
|
|
4
|
+
%w(dependencies util browser_support sass_extensions version errors quick_cache logger actions).each do |lib|
|
|
5
5
|
require "compass/#{lib}"
|
|
6
6
|
end
|
|
7
7
|
|
|
@@ -29,7 +29,7 @@ module Compass
|
|
|
29
29
|
extend QuickCache
|
|
30
30
|
end
|
|
31
31
|
|
|
32
|
-
%w(configuration frameworks app_integration
|
|
32
|
+
%w(watcher configuration frameworks app_integration compiler).each do |lib|
|
|
33
33
|
require "compass/#{lib}"
|
|
34
34
|
end
|
|
35
35
|
|
|
Binary file
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
# Require any additional compass plugins here.
|
|
2
|
+
project_type = :stand_alone
|
|
3
|
+
css_dir = "tmp"
|
|
4
|
+
sass_dir = "sass"
|
|
5
|
+
fonts_dir = "fonts"
|
|
6
|
+
output_style = :compact
|
|
7
|
+
# To enable relative image paths using the images_url() function:
|
|
8
|
+
# http_images_path = :relative
|
|
9
|
+
http_fonts_path = "/fonts"
|
|
10
|
+
line_comments = false
|
|
11
|
+
|
|
12
|
+
asset_cache_buster do |path, file|
|
|
13
|
+
pathname = Pathname.new(path)
|
|
14
|
+
dirname = pathname.dirname
|
|
15
|
+
basename = pathname.basename(pathname.extname)
|
|
16
|
+
extname = pathname.extname
|
|
17
|
+
|
|
18
|
+
case pathname.basename(pathname.extname).to_s
|
|
19
|
+
when "grid"
|
|
20
|
+
new_path = "#{dirname}/#{basename}-BUSTED#{extname}"
|
|
21
|
+
{:path => new_path, :query => nil}
|
|
22
|
+
when "feed"
|
|
23
|
+
"query_string"
|
|
24
|
+
when "dk"
|
|
25
|
+
{:query => "query_string"}
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
asset_host do |path|
|
|
31
|
+
"http://assets%d.example.com" % (path.size % 4)
|
|
32
|
+
end
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
.showgrid { font-family: url('http://assets3.example.com/fonts/grid-BUSTED.ttf'); }
|
|
2
|
+
|
|
3
|
+
.no-buster { font-family: url('http://assets3.example.com/fonts/grid.ttf'); }
|
|
4
|
+
|
|
5
|
+
.feed { font-family: url('http://assets3.example.com/fonts/feed.ttf?query_string'); }
|
|
6
|
+
|
|
7
|
+
.dk { font-family: url('http://assets1.example.com/fonts/sub/dk.ttf?query_string'); }
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
.showgrid
|
|
2
|
+
font-family: font-url("grid.ttf", $only-path: false, $cache-buster: true)
|
|
3
|
+
|
|
4
|
+
.no-buster
|
|
5
|
+
font-family: font-url("grid.ttf")
|
|
6
|
+
|
|
7
|
+
.feed
|
|
8
|
+
font-family: font-url("feed.ttf", $only-path: false, $cache-buster: true)
|
|
9
|
+
|
|
10
|
+
.dk
|
|
11
|
+
font-family: font-url("sub/dk.ttf", $only-path: false, $cache-buster: true)
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
.showgrid { font-family: url('http://assets3.example.com/fonts/grid-BUSTED.ttf'); }
|
|
2
|
+
|
|
3
|
+
.no-buster { font-family: url('http://assets3.example.com/fonts/grid.ttf'); }
|
|
4
|
+
|
|
5
|
+
.feed { font-family: url('http://assets3.example.com/fonts/feed.ttf?query_string'); }
|
|
6
|
+
|
|
7
|
+
.dk { font-family: url('http://assets1.example.com/fonts/sub/dk.ttf?query_string'); }
|