css_sprite 1.4.7 → 1.4.8

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.4.7
1
+ 1.4.8
data/css_sprite.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{css_sprite}
8
- s.version = "1.4.7"
8
+ s.version = "1.4.8"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Richard Huang"]
12
- s.date = %q{2010-04-27}
12
+ s.date = %q{2010-07-11}
13
13
  s.description = %q{css_sprite is a rails plugin/gem to generate css sprite image automatically.}
14
14
  s.email = %q{flyerhzm@gmail.com}
15
15
  s.extra_rdoc_files = [
@@ -25,6 +25,7 @@ Gem::Specification.new do |s|
25
25
  "lib/css_sprite.rb",
26
26
  "lib/css_sprite/sprite.rb",
27
27
  "spec/app/stylesheets/css_sprite.css",
28
+ "spec/app/stylesheets/scss/css_sprite.scss",
28
29
  "spec/css_sprite/sprite_spec.rb",
29
30
  "spec/public/images/another_css_sprite/no_image",
30
31
  "spec/public/images/css_sprite/gmail_logo.png",
@@ -45,11 +46,11 @@ Gem::Specification.new do |s|
45
46
  s.homepage = %q{http://github.com/flyerhzm/css_sprite}
46
47
  s.rdoc_options = ["--charset=UTF-8"]
47
48
  s.require_paths = ["lib"]
48
- s.rubygems_version = %q{1.3.5}
49
+ s.rubygems_version = %q{1.3.6}
49
50
  s.summary = %q{css_sprite is a rails plugin/gem to generate css sprite image automatically.}
50
51
  s.test_files = [
51
- "spec/css_sprite/sprite_spec.rb",
52
- "spec/spec_helper.rb"
52
+ "spec/spec_helper.rb",
53
+ "spec/css_sprite/sprite_spec.rb"
53
54
  ]
54
55
 
55
56
  if s.respond_to? :specification_version then
@@ -41,6 +41,8 @@ class Sprite
41
41
  def expire?(directory)
42
42
  if sass?
43
43
  stylesheet_path = dest_sass_path(directory)
44
+ elsif scss?
45
+ stylesheet_path = dest_scss_path(directory)
44
46
  else
45
47
  stylesheet_path = dest_css_path(directory)
46
48
  end
@@ -52,19 +54,26 @@ class Sprite
52
54
  return false
53
55
  end
54
56
 
55
- # output stylesheet, sass or css
57
+ # output stylesheet, sass, scss or css
56
58
  def output_stylesheet(directory, results)
57
59
  if sass?
58
60
  output_sass(directory, results)
61
+ elsif scss?
62
+ output_scss(directory, results)
59
63
  else
60
64
  output_css(directory, results)
61
65
  end
62
66
  end
63
67
 
64
- # use sass or css?
68
+ # use sass
65
69
  def sass?
66
70
  @config['engine'] == 'sass'
67
71
  end
72
+
73
+ # use scss
74
+ def scss?
75
+ @config['engine'] == 'scss'
76
+ end
68
77
 
69
78
  # detect all the css sprite directories. e.g. public/images/css_sprite, public/images/widget_css_sprite
70
79
  def css_sprite_directories
@@ -171,6 +180,39 @@ class Sprite
171
180
  end
172
181
  end
173
182
 
183
+ # output the css sprite scss file
184
+ def output_scss(directory, results)
185
+ unless results.empty?
186
+ dest_image_name = dest_image_name(directory)
187
+ dest_scss_path = dest_scss_path(directory)
188
+ dest_image_time = File.new(dest_image_path(directory)).mtime
189
+ File.open(dest_scss_path, 'w') do |f|
190
+ if @config['suffix']
191
+ @config['suffix'].each do |key, value|
192
+ cns = class_names(results, :suffix => key)
193
+ unless cns.empty?
194
+ f.print cns.join(",\n")
195
+ f.print "\{\n"
196
+ f.print value.split("\n").collect { |text| " " + text }.join("\n")
197
+ f.print "\}\n"
198
+ end
199
+ end
200
+ end
201
+
202
+ f.print class_names(results).join(",\n")
203
+ f.print " \{\n background: url('/images/#{dest_image_name}?#{dest_image_time.to_i}') no-repeat;\n\}\n"
204
+
205
+ results.each do |result|
206
+ f.print "#{class_name(result[:name])} \{\n"
207
+ f.print " background-position: #{-result[:x]}px #{-result[:y]}px;\n"
208
+ f.print " width: #{result[:width]}px;\n" if result[:width]
209
+ f.print " height: #{result[:height]}px;\n" if result[:height]
210
+ f.print " \}\n"
211
+ end
212
+ end
213
+ end
214
+ end
215
+
174
216
  # get all the class names within the same css sprite image
175
217
  def class_names(results, options={})
176
218
  options = {:count_per_line => 5}.merge(options)
@@ -217,6 +259,11 @@ class Sprite
217
259
  def dest_sass_path(directory)
218
260
  File.join(@stylesheet_path, 'sass', File.basename(directory) + '.sass')
219
261
  end
262
+
263
+ # destination scss file path
264
+ def dest_scss_path(directory)
265
+ File.join(@stylesheet_path, 'scss', File.basename(directory) + '.scss')
266
+ end
220
267
 
221
268
  # append src_image to the dest_image with position (x, y)
222
269
  def composite_images(dest_image, src_image, x, y)
@@ -1,14 +1,14 @@
1
- .logos:hover .gmail_logo, .logos .gmail_logo.active, .logos .gmail_logo, .icons .twitter_icon:hover, .icons .twitter_icon,
2
- .icons .facebook_icon:hover, .icons .facebook_icon, .hotmail_logo, .gmail_logo.active, .gmail_logo {
3
- background: url('/images/css_sprite.png?1272247421') no-repeat;
1
+ .logos:hover .gmail_logo, .gmail_logo, .hotmail_logo, .icons .twitter_icon:hover, .icons .facebook_icon:hover,
2
+ .icons .twitter_icon, .icons .facebook_icon, .gmail_logo.active, .logos .gmail_logo, .logos .gmail_logo.active {
3
+ background: url('/images/css_sprite.png?1278833054') no-repeat;
4
4
  }
5
5
  .logos:hover .gmail_logo { background-position: 0px 0px; }
6
- .logos .gmail_logo.active { background-position: 0px -41px; width: 52px; height: 18px; }
7
- .logos .gmail_logo { background-position: 0px -64px; width: 103px; height: 36px; }
8
- .icons .twitter_icon:hover { background-position: 0px -105px; }
9
- .icons .twitter_icon { background-position: 0px -124px; width: 14px; height: 14px; }
10
- .icons .facebook_icon:hover { background-position: 0px -143px; width: 21px; height: 21px; }
11
- .icons .facebook_icon { background-position: 0px -169px; width: 14px; height: 14px; }
12
- .hotmail_logo { background-position: 0px -188px; width: 103px; height: 36px; }
13
- .gmail_logo.active { background-position: 0px -229px; }
14
- .gmail_logo { background-position: 0px -270px; width: 103px; height: 36px; }
6
+ .gmail_logo { background-position: 0px -41px; width: 103px; height: 36px; }
7
+ .hotmail_logo { background-position: 0px -82px; width: 103px; height: 36px; }
8
+ .icons .twitter_icon:hover { background-position: 0px -123px; }
9
+ .icons .facebook_icon:hover { background-position: 0px -142px; width: 21px; height: 21px; }
10
+ .icons .twitter_icon { background-position: 0px -168px; width: 14px; height: 14px; }
11
+ .icons .facebook_icon { background-position: 0px -187px; width: 14px; height: 14px; }
12
+ .gmail_logo.active { background-position: 0px -206px; }
13
+ .logos .gmail_logo { background-position: 0px -247px; width: 103px; height: 36px; }
14
+ .logos .gmail_logo.active { background-position: 0px -288px; width: 52px; height: 18px; }
@@ -0,0 +1,48 @@
1
+ .logos:hover .gmail_logo, .gmail_logo, .hotmail_logo, .icons .twitter_icon:hover, .icons .facebook_icon:hover,
2
+ .icons .twitter_icon, .icons .facebook_icon, .gmail_logo.active, .logos .gmail_logo, .logos .gmail_logo.active {
3
+ background: url('/images/css_sprite.png?1278833054') no-repeat;
4
+ }
5
+ .logos:hover .gmail_logo {
6
+ background-position: 0px 0px;
7
+ }
8
+ .gmail_logo {
9
+ background-position: 0px -41px;
10
+ width: 103px;
11
+ height: 36px;
12
+ }
13
+ .hotmail_logo {
14
+ background-position: 0px -82px;
15
+ width: 103px;
16
+ height: 36px;
17
+ }
18
+ .icons .twitter_icon:hover {
19
+ background-position: 0px -123px;
20
+ }
21
+ .icons .facebook_icon:hover {
22
+ background-position: 0px -142px;
23
+ width: 21px;
24
+ height: 21px;
25
+ }
26
+ .icons .twitter_icon {
27
+ background-position: 0px -168px;
28
+ width: 14px;
29
+ height: 14px;
30
+ }
31
+ .icons .facebook_icon {
32
+ background-position: 0px -187px;
33
+ width: 14px;
34
+ height: 14px;
35
+ }
36
+ .gmail_logo.active {
37
+ background-position: 0px -206px;
38
+ }
39
+ .logos .gmail_logo {
40
+ background-position: 0px -247px;
41
+ width: 103px;
42
+ height: 36px;
43
+ }
44
+ .logos .gmail_logo.active {
45
+ background-position: 0px -288px;
46
+ width: 52px;
47
+ height: 18px;
48
+ }
@@ -35,6 +35,11 @@ describe Sprite do
35
35
  Sprite.any_instance.expects(:system).with("optipng -quiet #{IMAGE_PATH}/css_sprite.png").returns(true)
36
36
  Sprite.new('stylesheet_path' => 'app/stylesheets').build
37
37
  end
38
+
39
+ it "should build css_sprite image and scss" do
40
+ Sprite.any_instance.expects(:system).with("optipng -quiet #{IMAGE_PATH}/css_sprite.png").returns(true)
41
+ Sprite.new('engine' => 'scss', 'stylesheet_path' => 'app/stylesheets').build
42
+ end
38
43
  end
39
44
 
40
45
  describe "css_sprite_directories" do
metadata CHANGED
@@ -1,7 +1,12 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: css_sprite
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.7
4
+ prerelease: false
5
+ segments:
6
+ - 1
7
+ - 4
8
+ - 8
9
+ version: 1.4.8
5
10
  platform: ruby
6
11
  authors:
7
12
  - Richard Huang
@@ -9,19 +14,21 @@ autorequire:
9
14
  bindir: bin
10
15
  cert_chain: []
11
16
 
12
- date: 2010-04-27 00:00:00 -06:00
17
+ date: 2010-07-11 00:00:00 +08:00
13
18
  default_executable:
14
19
  dependencies:
15
20
  - !ruby/object:Gem::Dependency
16
21
  name: rmagick
17
- type: :runtime
18
- version_requirement:
19
- version_requirements: !ruby/object:Gem::Requirement
22
+ prerelease: false
23
+ requirement: &id001 !ruby/object:Gem::Requirement
20
24
  requirements:
21
25
  - - ">="
22
26
  - !ruby/object:Gem::Version
27
+ segments:
28
+ - 0
23
29
  version: "0"
24
- version:
30
+ type: :runtime
31
+ version_requirements: *id001
25
32
  description: css_sprite is a rails plugin/gem to generate css sprite image automatically.
26
33
  email: flyerhzm@gmail.com
27
34
  executables: []
@@ -40,6 +47,7 @@ files:
40
47
  - lib/css_sprite.rb
41
48
  - lib/css_sprite/sprite.rb
42
49
  - spec/app/stylesheets/css_sprite.css
50
+ - spec/app/stylesheets/scss/css_sprite.scss
43
51
  - spec/css_sprite/sprite_spec.rb
44
52
  - spec/public/images/another_css_sprite/no_image
45
53
  - spec/public/images/css_sprite/gmail_logo.png
@@ -69,21 +77,23 @@ required_ruby_version: !ruby/object:Gem::Requirement
69
77
  requirements:
70
78
  - - ">="
71
79
  - !ruby/object:Gem::Version
80
+ segments:
81
+ - 0
72
82
  version: "0"
73
- version:
74
83
  required_rubygems_version: !ruby/object:Gem::Requirement
75
84
  requirements:
76
85
  - - ">="
77
86
  - !ruby/object:Gem::Version
87
+ segments:
88
+ - 0
78
89
  version: "0"
79
- version:
80
90
  requirements: []
81
91
 
82
92
  rubyforge_project:
83
- rubygems_version: 1.3.5
93
+ rubygems_version: 1.3.6
84
94
  signing_key:
85
95
  specification_version: 3
86
96
  summary: css_sprite is a rails plugin/gem to generate css sprite image automatically.
87
97
  test_files:
88
- - spec/css_sprite/sprite_spec.rb
89
98
  - spec/spec_helper.rb
99
+ - spec/css_sprite/sprite_spec.rb