compass-rmagick-engine 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
data/Readme.md CHANGED
@@ -6,15 +6,16 @@ Compass Rmagick Engine is a drop in replacement for creating sprites using chunk
6
6
 
7
7
  ### Rails
8
8
 
9
- In your gem file add
10
-
11
- 1. `gem 'compass-rmagick-engine'`
9
+ 1. In your gem file add `gem 'compass-rmagick-engine', '~> 0.0.1'`
12
10
  2. Add `sprite_engine = :rmagick` to your compass config
13
11
 
14
12
  Standalone
15
13
 
16
- 1. run `gem install compass-rmagick-engine`
17
- 2. open your compass config file and add `require 'compass-rmagick-engine'`
18
- 3. and also add `sprite_engine = :rmagick`
14
+ First run `gem install compass-rmagick-engine`
15
+
16
+ Then open your compass config file and add
17
+
18
+ require 'compass-rmagick-engine'
19
+ sprite_engine = :rmagick
19
20
 
20
21
 
@@ -14,7 +14,7 @@ Gem::Specification.new do |s|
14
14
 
15
15
  s.rubyforge_project = "compass-rmagick-engine"
16
16
 
17
- s.add_dependency "compass", '~> 0.11.beta.5'
17
+ s.add_dependency "compass", '~> 0.11.3'
18
18
  s.add_dependency "rmagick", '~> 2.13.1'
19
19
 
20
20
 
@@ -1,33 +1,39 @@
1
1
  require 'rmagick'
2
+
2
3
  module Compass
3
4
  module SassExtensions
4
5
  module Sprites
5
- module RmagickEngine
6
- class ::Magick::Image
7
- alias :save :write
8
- end
9
-
6
+ class RmagickEngine < Compass::SassExtensions::Sprites::Engine
7
+
10
8
  def construct_sprite
11
- output_png = Magick::Image.new(width, height)
12
- output_png.background_color = 'none'
13
- output_png.format = 'PNG24'
9
+ @canvas = Magick::Image.new(width, height)
10
+ @canvas.background_color = 'none'
11
+ @canvas.format = 'PNG24'
14
12
  images.each do |image|
15
13
  input_png = Magick::Image.read(image.file).first
16
14
  if image.repeat == "no-repeat"
17
- output_png = composite_images(output_png, input_png, image.left, image.top)
15
+ @canvas = composite_images(@canvas, input_png, image.left, image.top)
18
16
  else
19
17
  x = image.left - (image.left / image.width).ceil * image.width
20
18
  while x < width do
21
- output_png = composite_images(output_png, input_png, x, image.top)
19
+ @canvas = composite_images(@canvas, input_png, x, image.top)
22
20
  x += image.width
23
21
  end
24
22
  end
25
23
  end
26
- output_png
24
+ @canvas
25
+ end
26
+
27
+ def save(filename)
28
+ if canvas.nil?
29
+ construct_sprite
30
+ end
31
+
32
+ canvas.write(filename)
27
33
  end
28
34
 
29
35
  private #===============================================================================>
30
-
36
+
31
37
  def composite_images(dest_image, src_image, x, y)
32
38
  width = [src_image.columns + x, dest_image.columns].max
33
39
  height = [src_image.rows + y, dest_image.rows].max
@@ -36,6 +42,7 @@ module Compass
36
42
  image.composite!(src_image, x, y, Magick::CopyCompositeOp)
37
43
  image
38
44
  end
45
+
39
46
  end
40
47
  end
41
48
  end
@@ -1,5 +1,5 @@
1
1
  module Compass
2
2
  module Rmagick
3
- VERSION = "0.0.1"
3
+ VERSION = "0.0.2"
4
4
  end
5
5
  end
data/spec/rmagick_spec.rb CHANGED
@@ -2,7 +2,7 @@ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
2
  require 'compass-rmagick-engine'
3
3
  require 'digest/md5'
4
4
 
5
- describe Compass::Sprites do
5
+ describe Compass::SassExtensions::Sprites::RmagickEngine do
6
6
 
7
7
  before :each do
8
8
  @images_src_path = File.join(File.dirname(__FILE__), 'test_project', 'public', 'images')
@@ -59,7 +59,7 @@ describe Compass::Sprites do
59
59
  SCSS
60
60
  css.should == <<-CSS
61
61
  .squares-sprite, .squares-ten-by-ten, .squares-twenty-by-twenty {
62
- background: url('/squares-1cd84c9068.png') no-repeat;
62
+ background: url('/squares-s1cd84c9068.png') no-repeat;
63
63
  }
64
64
 
65
65
  .squares-ten-by-ten {
metadata CHANGED
@@ -1,8 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: compass-rmagick-engine
3
3
  version: !ruby/object:Gem::Version
4
+ hash: 27
4
5
  prerelease:
5
- version: 0.0.1
6
+ segments:
7
+ - 0
8
+ - 0
9
+ - 2
10
+ version: 0.0.2
6
11
  platform: ruby
7
12
  authors:
8
13
  - Scott Davis
@@ -10,7 +15,7 @@ autorequire:
10
15
  bindir: bin
11
16
  cert_chain: []
12
17
 
13
- date: 2011-03-29 00:00:00 -04:00
18
+ date: 2011-06-21 00:00:00 -04:00
14
19
  default_executable:
15
20
  dependencies:
16
21
  - !ruby/object:Gem::Dependency
@@ -21,7 +26,12 @@ dependencies:
21
26
  requirements:
22
27
  - - ~>
23
28
  - !ruby/object:Gem::Version
24
- version: 0.11.beta.5
29
+ hash: 53
30
+ segments:
31
+ - 0
32
+ - 11
33
+ - 3
34
+ version: 0.11.3
25
35
  type: :runtime
26
36
  version_requirements: *id001
27
37
  - !ruby/object:Gem::Dependency
@@ -32,6 +42,11 @@ dependencies:
32
42
  requirements:
33
43
  - - ~>
34
44
  - !ruby/object:Gem::Version
45
+ hash: 57
46
+ segments:
47
+ - 2
48
+ - 13
49
+ - 1
35
50
  version: 2.13.1
36
51
  type: :runtime
37
52
  version_requirements: *id002
@@ -74,12 +89,18 @@ required_ruby_version: !ruby/object:Gem::Requirement
74
89
  requirements:
75
90
  - - ">="
76
91
  - !ruby/object:Gem::Version
92
+ hash: 3
93
+ segments:
94
+ - 0
77
95
  version: "0"
78
96
  required_rubygems_version: !ruby/object:Gem::Requirement
79
97
  none: false
80
98
  requirements:
81
99
  - - ">="
82
100
  - !ruby/object:Gem::Version
101
+ hash: 3
102
+ segments:
103
+ - 0
83
104
  version: "0"
84
105
  requirements: []
85
106