sprite 0.2.2 → 0.2.4
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +1 -1
- data/lib/sprite/styles.rb +4 -1
- data/lib/sprite/styles/sass_mixin_generator.rb +1 -6
- data/lib/sprite/styles/stylus_generator.rb +45 -0
- data/sprite.gemspec +1 -2
- metadata +32 -42
data/README.md
CHANGED
@@ -69,7 +69,7 @@ these files. Just add a link to `sprites.css` into your html <head> and you're r
|
|
69
69
|
Configuration of `sprite` is done via `config/sprite.yml`. It allows you to set sprite configuration options, and fine tune exactly which sprites get generated where.
|
70
70
|
|
71
71
|
* `config:` section defines all the global properties for sprite generation. Such as how it generates the styles, where it looks for images, where it writes it output file to, and what image file format it uses by default
|
72
|
-
- `style:` defines how the style rules are outputted. built in options are `css`, `sass`, and `sass_mixin`. (defaults to `css`)
|
72
|
+
- `style:` defines how the style rules are outputted. built in options are `css`, `sass`, `stylus`, and `sass_mixin`. (defaults to `css`)
|
73
73
|
- `style_output_path:` defines the file path where your style settings get written (defaults to `stylesheets/sprites`). the file extension not needed as it will be set based on the `style:` setting
|
74
74
|
- `image_output_path:` defines the folder path where the combined sprite images files are written (defaults to `images/sprites/`)
|
75
75
|
- `css_image_path:` defines the path used in css to find sprite image files (defaults to `/images/sprites/`)
|
data/lib/sprite/styles.rb
CHANGED
@@ -2,15 +2,18 @@ require 'sprite/styles/sass_generator'
|
|
2
2
|
require 'sprite/styles/css_generator'
|
3
3
|
require 'sprite/styles/sass_yml_generator'
|
4
4
|
require 'sprite/styles/sass_mixin_generator'
|
5
|
+
require 'sprite/styles/stylus_generator'
|
5
6
|
require 'sprite/styles/templated_css_generator'
|
6
7
|
|
7
8
|
module Sprite::Styles
|
9
|
+
|
8
10
|
GENERATORS = {
|
9
11
|
"css" => "CssGenerator",
|
10
12
|
"templated_css" => "TemplatedCssGenerator",
|
11
13
|
"sass" => "SassGenerator",
|
12
14
|
"sass_mixin" => "SassMixinGenerator",
|
13
|
-
"sass_yml" => "SassYmlGenerator"
|
15
|
+
"sass_yml" => "SassYmlGenerator",
|
16
|
+
"stylus" => "StylusGenerator",
|
14
17
|
}
|
15
18
|
|
16
19
|
def self.get(config)
|
@@ -9,17 +9,12 @@ module Sprite
|
|
9
9
|
def write(path, sprite_files)
|
10
10
|
# write the sass mixins to disk
|
11
11
|
File.open(File.join(Sprite.root, path), 'w') do |f|
|
12
|
-
add_else = false
|
13
12
|
|
14
13
|
f.puts "= sprite($group_name, $image_name, $offset: 0)"
|
15
14
|
sprite_files.each do |sprite_file, sprites|
|
16
15
|
background_url = @builder.background_url(sprite_file)
|
17
16
|
sprites.each do |sprite|
|
18
17
|
f << " @"
|
19
|
-
if add_else
|
20
|
-
f << "else "
|
21
|
-
end
|
22
|
-
add_else = true
|
23
18
|
#{sprite[:x]}px #{sprite[:y]}px
|
24
19
|
|
25
20
|
if sprite[:align] == 'horizontal'
|
@@ -43,4 +38,4 @@ module Sprite
|
|
43
38
|
|
44
39
|
end
|
45
40
|
end
|
46
|
-
end
|
41
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
module Sprite
|
2
|
+
module Styles
|
3
|
+
# renders a yml file that is later used by stylus when generating mixins
|
4
|
+
class StylusGenerator
|
5
|
+
def initialize(builder)
|
6
|
+
@builder = builder
|
7
|
+
end
|
8
|
+
|
9
|
+
def write(path, sprite_files)
|
10
|
+
# write the stylus mixins to disk
|
11
|
+
File.open(File.join(Sprite.root, path), 'w') do |f|
|
12
|
+
add_else = false
|
13
|
+
|
14
|
+
f.puts "sprite(group_name, image_name, offset = 0)"
|
15
|
+
sprite_files.each do |sprite_file, sprites|
|
16
|
+
background_url = @builder.background_url(sprite_file)
|
17
|
+
sprites.each do |sprite|
|
18
|
+
f << " "
|
19
|
+
if add_else
|
20
|
+
f << "else "
|
21
|
+
end
|
22
|
+
add_else = true
|
23
|
+
|
24
|
+
if sprite[:align] == 'horizontal'
|
25
|
+
background_offset = "{#{sprite[:x]}+offset}px #{sprite[:y]}px"
|
26
|
+
else
|
27
|
+
background_offset = "#{sprite[:x]}px {#{sprite[:y]}+offset}px"
|
28
|
+
end
|
29
|
+
|
30
|
+
f.puts %{if group_name == "#{sprite[:group]}" and image_name == "#{sprite[:name]}"}
|
31
|
+
f.puts " background: #{background_url} repeat #{background_offset}"
|
32
|
+
f.puts " width: #{sprite[:width]}px"
|
33
|
+
f.puts " height: #{sprite[:height]}px"
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
def extension
|
40
|
+
"styl"
|
41
|
+
end
|
42
|
+
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
data/sprite.gemspec
CHANGED
metadata
CHANGED
@@ -1,40 +1,38 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: sprite
|
3
|
-
version: !ruby/object:Gem::Version
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.2.4
|
4
5
|
prerelease:
|
5
|
-
version: 0.2.2
|
6
6
|
platform: ruby
|
7
|
-
authors:
|
7
|
+
authors:
|
8
8
|
- Jacques Crocker
|
9
9
|
- Alf Mikula
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
dependencies:
|
17
|
-
- !ruby/object:Gem::Dependency
|
13
|
+
date: 2011-09-25 00:00:00.000000000Z
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
18
16
|
name: rspec
|
19
|
-
requirement: &
|
17
|
+
requirement: &2153148720 !ruby/object:Gem::Requirement
|
20
18
|
none: false
|
21
|
-
requirements:
|
19
|
+
requirements:
|
22
20
|
- - ~>
|
23
|
-
- !ruby/object:Gem::Version
|
24
|
-
version:
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: '2.0'
|
25
23
|
type: :development
|
26
24
|
prerelease: false
|
27
|
-
version_requirements: *
|
28
|
-
description: sprite is a ruby executable that to easily generate sprites along with
|
25
|
+
version_requirements: *2153148720
|
26
|
+
description: sprite is a ruby executable that to easily generate sprites along with
|
27
|
+
css, sass
|
29
28
|
email: railsjedi@gmail.com
|
30
|
-
executables:
|
29
|
+
executables:
|
31
30
|
- sprite
|
32
31
|
extensions: []
|
33
|
-
|
34
|
-
extra_rdoc_files:
|
32
|
+
extra_rdoc_files:
|
35
33
|
- MIT-LICENSE
|
36
34
|
- README.md
|
37
|
-
files:
|
35
|
+
files:
|
38
36
|
- bin/sprite
|
39
37
|
- lib/sprite/builder.rb
|
40
38
|
- lib/sprite/config.rb
|
@@ -49,6 +47,7 @@ files:
|
|
49
47
|
- lib/sprite/styles/sass_generator.rb
|
50
48
|
- lib/sprite/styles/sass_mixin_generator.rb
|
51
49
|
- lib/sprite/styles/sass_yml_generator.rb
|
50
|
+
- lib/sprite/styles/stylus_generator.rb
|
52
51
|
- lib/sprite/styles/templated_css_generator.rb
|
53
52
|
- lib/sprite/styles.rb
|
54
53
|
- lib/sprite.rb
|
@@ -108,41 +107,32 @@ files:
|
|
108
107
|
- sprite.gemspec
|
109
108
|
- Gemfile
|
110
109
|
- Gemfile.lock
|
111
|
-
has_rdoc: true
|
112
110
|
homepage: http://github.com/railsjedi/sprite
|
113
111
|
licenses: []
|
114
|
-
|
115
112
|
post_install_message:
|
116
|
-
rdoc_options:
|
113
|
+
rdoc_options:
|
117
114
|
- --charset=UTF-8
|
118
|
-
require_paths:
|
115
|
+
require_paths:
|
119
116
|
- lib
|
120
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
117
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
121
118
|
none: false
|
122
|
-
requirements:
|
123
|
-
- -
|
124
|
-
- !ruby/object:Gem::Version
|
125
|
-
|
126
|
-
|
127
|
-
- 0
|
128
|
-
version: "0"
|
129
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
119
|
+
requirements:
|
120
|
+
- - ! '>='
|
121
|
+
- !ruby/object:Gem::Version
|
122
|
+
version: '0'
|
123
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
130
124
|
none: false
|
131
|
-
requirements:
|
132
|
-
- -
|
133
|
-
- !ruby/object:Gem::Version
|
134
|
-
|
135
|
-
segments:
|
136
|
-
- 0
|
137
|
-
version: "0"
|
125
|
+
requirements:
|
126
|
+
- - ! '>='
|
127
|
+
- !ruby/object:Gem::Version
|
128
|
+
version: '0'
|
138
129
|
requirements: []
|
139
|
-
|
140
130
|
rubyforge_project: none
|
141
|
-
rubygems_version: 1.6
|
131
|
+
rubygems_version: 1.8.6
|
142
132
|
signing_key:
|
143
133
|
specification_version: 3
|
144
134
|
summary: generate your css and sass sprites automagically
|
145
|
-
test_files:
|
135
|
+
test_files:
|
146
136
|
- spec/output/android_horizontal/images/sprites/android-icons.png
|
147
137
|
- spec/output/android_horizontal/stylesheets/android-icons.css
|
148
138
|
- spec/output/android_vertical/images/sprites/android-icons.png
|