polymer 1.0.0.beta.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (47) hide show
  1. data/Gemfile +8 -0
  2. data/History.md +126 -0
  3. data/LICENSE +28 -0
  4. data/README.md +229 -0
  5. data/Rakefile +186 -0
  6. data/bin/polymer +10 -0
  7. data/lib/polymer/cache.rb +106 -0
  8. data/lib/polymer/cli.rb +340 -0
  9. data/lib/polymer/core_ext.rb +78 -0
  10. data/lib/polymer/css_generator.rb +32 -0
  11. data/lib/polymer/deviant_finder.rb +76 -0
  12. data/lib/polymer/dsl.rb +283 -0
  13. data/lib/polymer/man/polymer-bond.1 +60 -0
  14. data/lib/polymer/man/polymer-bond.1.txt +66 -0
  15. data/lib/polymer/man/polymer-init.1 +33 -0
  16. data/lib/polymer/man/polymer-init.1.txt +42 -0
  17. data/lib/polymer/man/polymer-optimise.1 +23 -0
  18. data/lib/polymer/man/polymer-optimise.1.txt +25 -0
  19. data/lib/polymer/man/polymer-position.1 +39 -0
  20. data/lib/polymer/man/polymer-position.1.txt +42 -0
  21. data/lib/polymer/man/polymer.1 +50 -0
  22. data/lib/polymer/man/polymer.1.txt +60 -0
  23. data/lib/polymer/man/polymer.5 +130 -0
  24. data/lib/polymer/man/polymer.5.txt +145 -0
  25. data/lib/polymer/optimisation.rb +130 -0
  26. data/lib/polymer/project.rb +164 -0
  27. data/lib/polymer/sass_generator.rb +38 -0
  28. data/lib/polymer/source.rb +55 -0
  29. data/lib/polymer/sprite.rb +130 -0
  30. data/lib/polymer/templates/polymer.tt +28 -0
  31. data/lib/polymer/templates/sass_mixins.erb +29 -0
  32. data/lib/polymer/templates/sources/one/book.png +0 -0
  33. data/lib/polymer/templates/sources/one/box-label.png +0 -0
  34. data/lib/polymer/templates/sources/one/calculator.png +0 -0
  35. data/lib/polymer/templates/sources/one/calendar-month.png +0 -0
  36. data/lib/polymer/templates/sources/one/camera.png +0 -0
  37. data/lib/polymer/templates/sources/one/eraser.png +0 -0
  38. data/lib/polymer/templates/sources/two/inbox-image.png +0 -0
  39. data/lib/polymer/templates/sources/two/magnet.png +0 -0
  40. data/lib/polymer/templates/sources/two/newspaper.png +0 -0
  41. data/lib/polymer/templates/sources/two/television.png +0 -0
  42. data/lib/polymer/templates/sources/two/wand-hat.png +0 -0
  43. data/lib/polymer/templates/sources/two/wooden-box-label.png +0 -0
  44. data/lib/polymer/version.rb +4 -0
  45. data/lib/polymer.rb +49 -0
  46. data/polymer.gemspec +94 -0
  47. metadata +206 -0
@@ -0,0 +1,283 @@
1
+ module Polymer
2
+ # Provides the DSL used in .polymer files.
3
+ #
4
+ # In order to account for situations where global configuration may
5
+ # appear after some sprites are defined, the DSL instance keeps track
6
+ # of each defined sprite, but only resolves the settings for each
7
+ # one once +to_project+ is called.
8
+ #
9
+ class DSL
10
+
11
+ # Given a path to a file, reads and evaluates the contents as a DSL
12
+ # definition.
13
+ #
14
+ # @param [Pathname] path
15
+ # Path to a .polymer file to be evaluated.
16
+ #
17
+ # @return [Polymer::Project]
18
+ # The project represented by the config file.
19
+ #
20
+ def self.load(path)
21
+ dsl = new(path.dirname)
22
+ dsl.instance_eval path.read.split('__END__').first, path.to_s, 1
23
+ dsl.to_project
24
+ end
25
+
26
+ # Builds a project using the given block.
27
+ #
28
+ # The given DSL block will be run using +instance_eval+, thus no
29
+ # parameters are given to the block.
30
+ #
31
+ # @param [Pathname] root
32
+ # When building a project using the DSL, rather than a .polymer file,
33
+ # you need to provide a path to the directory you want to serve as the
34
+ # Polymer root.
35
+ #
36
+ # @return [Polymer::Project]
37
+ # The project represented by the DSL.
38
+ #
39
+ # @example
40
+ #
41
+ # Polymer::DSL.build do
42
+ # sprite 'sources/lurrr/*' => 'sprites/lurrr.png'
43
+ # end
44
+ #
45
+ def self.build(root, &block)
46
+ file, line = caller.first.split(':')
47
+
48
+ dsl = new(root)
49
+ dsl.instance_eval &block
50
+ dsl.to_project
51
+ end
52
+
53
+ # Creates a new DSL instance.
54
+ #
55
+ # @param [Pathname] root_path
56
+ # Path to the root of the Polymer project. The .polymer config should
57
+ # reside in this directory.
58
+ #
59
+ def initialize(root_path)
60
+ @root = root_path
61
+ @sprites = []
62
+ @config = ProjectConfig.new
63
+ end
64
+
65
+ # Returns the configuration object. Used to set global options which
66
+ # should either affect the whole project (css, sass), or used as a default
67
+ # value for sprite settings (padding, url).
68
+ #
69
+ # @return [Polymer::DSL::Config]
70
+ #
71
+ attr_reader :config
72
+
73
+ # Defines a sprite.
74
+ #
75
+ # Expects a single Hash as the parameter, where the hash should include
76
+ # precisely one String key mapped to a String value, and any extra options
77
+ # to be used when creating the sprite passed with Symbol keys.
78
+ #
79
+ # The String key should be a path -- relative to the .polymer file -- to
80
+ # the source files to be used for the sprite, while the value is a path
81
+ # indicating where the sprite should be saved (including filename).
82
+ #
83
+ # See the DEFINING SPRITES section of polymer(5) for more information.
84
+ #
85
+ # @param [Hash] definition
86
+ # A { String => String } pair, plus any additional options.
87
+ #
88
+ # @option definition [Integer] :padding (20)
89
+ # Sets the size of the transparent space to be inserted between each
90
+ # source image. Measured in pixels.
91
+ # @option definition [String] :url ("/images/:filename")
92
+ # The URL at which the sprite can be requested by a browser. Used when
93
+ # generating stylesheets.
94
+ #
95
+ # @example
96
+ #
97
+ # # Creates a sprite where the sources are in "path/to/sources" with the
98
+ # # generated sprite saved to "path/to/sprite.png", using 50px vertical
99
+ # # padding between each source image.
100
+ #
101
+ # sprite "path/to/sources" => "path/to_sprite", :padding => 50
102
+ #
103
+ def sprite(definition)
104
+ definition[:padding] = 0 if definition[:padding] == false
105
+
106
+ # Find the source => sprite mapping.
107
+ source, sprite = _extract_mapping(definition)
108
+
109
+ # If the source contains a :name segment, it may define multiple sprites
110
+ # depending on the directory structure.
111
+ if source.to_s =~ /:name/
112
+ if definition.has_key?(:name)
113
+ # Can't have a :name segment and an explicit name option.
114
+ raise Polymer::DslError,
115
+ "Sprite '#{source} => #{sprite}' has both a :name path segment " \
116
+ "and a :name option; please use only one."
117
+ elsif sprite !~ /:name/
118
+ raise Polymer::MissingName,
119
+ "Sprite '#{source} => #{sprite}' requires a :name segment in " \
120
+ "the sprite path."
121
+ else
122
+ _define_multiple_sprites(source, sprite, definition)
123
+ end
124
+ else
125
+ _define_sprite(source, sprite, definition)
126
+ end
127
+
128
+ nil
129
+ end
130
+
131
+ alias_method :sprites, :sprite
132
+
133
+ # Transforms the configuration -- and defined sprites -- into a Project.
134
+ #
135
+ # @return [Polymer::Project]
136
+ #
137
+ def to_project
138
+ project_config = @config.to_h
139
+
140
+ Project.new(@root, @sprites.map do |definition|
141
+ definition = _create_sprite(definition, project_config)
142
+ end, project_config)
143
+ end
144
+
145
+ #######
146
+ private
147
+ #######
148
+
149
+ # Given a sprite as defined in the config file, extracts the source path,
150
+ # the sprite path, _destructively removes them from the Hash_, and returns
151
+ # a two-element array with their values.
152
+ #
153
+ # @return [Array<String, String>] The source and sprite path.
154
+ #
155
+ def _extract_mapping(definition)
156
+ unless source = definition.detect { |key, value| key.is_a?(String) }
157
+ raise Polymer::MissingMap,
158
+ 'Sprite definition is missing a { source => sprite } pair.'
159
+ end
160
+
161
+ source
162
+ end
163
+
164
+ # Defines a single sprite.
165
+ #
166
+ # @param [String] sources
167
+ # The path at which Polymer should look for source images. If the path
168
+ # is a directory, Polymer will assume that any images within it are to
169
+ # be used as sources. Relative to +@root+.
170
+ # @param [String] sprite
171
+ # The path, relative to +@root+ at which the generated sprite is to
172
+ # be saved.
173
+ # @param [Hash] options
174
+ # Other options.
175
+ #
176
+ # @raise [Polymer::DuplicateName]
177
+ # Raised when the sprite uses a name which has been taken by an
178
+ # existing sprite.
179
+ #
180
+ def _define_sprite(sources, sprite, options)
181
+ sources, sprite = @root + sources, @root + sprite
182
+ name = options[:name] || sprite.basename(sprite.extname).to_s
183
+
184
+ if @sprites.detect { |definition| definition[:name] == name }
185
+ raise DuplicateName,
186
+ "You tried to create a sprite whose name is `#{name}', but a " \
187
+ "sprite with this name has already been defined."
188
+ end
189
+
190
+ # Handle when a directory is given without a file-matcher.
191
+ sources = sources + '*' if sources.directory?
192
+
193
+ @sprites << options.merge(
194
+ :name => name,
195
+ :sources => Pathname.glob(sources),
196
+ :save_path => @root + sprite
197
+ )
198
+ end
199
+
200
+ # Defines multiple sprites with a :name segment.
201
+ #
202
+ # @param [String] sources
203
+ # The path at which we can find sources.
204
+ # @param [String] sprite
205
+ # The path at which the sprite is to be saved.
206
+ # @param [Hash] options
207
+ # Other options.
208
+ #
209
+ def _define_multiple_sprites(sources, sprite, options)
210
+ leading, trailing = sources.split(':name')
211
+
212
+ Pathname.glob(@root + leading + '*').each do |entry|
213
+ next unless entry.directory?
214
+
215
+ sprite_opts = options.dup # Create a copy for each sprite.
216
+ sprite_opts[:name] = entry.basename.to_s # Use directory as the name
217
+
218
+ source_path = "#{leading}#{sprite_opts[:name]}#{trailing}"
219
+ sprite_path = sprite.gsub(/:name/, sprite_opts[:name])
220
+
221
+ _define_sprite(source_path, sprite_path, sprite_opts)
222
+ end
223
+ end
224
+
225
+ # Given a sprite definition, creates a final Sprite instance.
226
+ #
227
+ # @param [Hash] definition
228
+ # The sprite as defined; with options parsed by _define_sprites.
229
+ # @param [Hash] project_config
230
+ # The global project configuration.
231
+ #
232
+ # @return [Polymer::Sprite]
233
+ #
234
+ def _create_sprite(definition, project_config)
235
+ url = definition.fetch(:url, project_config[:url]).dup
236
+ url.gsub!(/:name/, definition[:name])
237
+ url.gsub!(/:filename/, definition[:save_path].basename.to_s)
238
+
239
+ Polymer::Sprite.new \
240
+ definition[:name],
241
+ definition[:sources],
242
+ definition[:save_path],
243
+ definition.fetch(:padding, project_config[:padding]),
244
+ url
245
+ end
246
+
247
+ # Provides the DSL for the global configuration options.
248
+ #
249
+ # @private
250
+ #
251
+ class ProjectConfig
252
+ ATTRIBUTES = %w( cache css padding url sass ).map(&:to_sym).freeze
253
+
254
+ # Define the setter methods for each attribute. The setters are
255
+ # sans-equals to provide a slightly more concise syntax.
256
+ #
257
+ ATTRIBUTES.each do |method|
258
+ class_eval <<-RUBY
259
+ def #{method}(value) # def padding(value)
260
+ @config[:#{method}] = value # @config[:padding] = value
261
+ end # end
262
+ RUBY
263
+ end
264
+
265
+ # Creates a new ProjectConfig. Sets the default values which are used in
266
+ # the event that the user doesn't specify them.
267
+ #
268
+ def initialize
269
+ @config = ATTRIBUTES.inject({}) do |memo, attribute|
270
+ memo[attribute] = Polymer::Project::DEFAULTS[attribute]
271
+ memo
272
+ end
273
+ end
274
+
275
+ # Returns a hash containing each of the attribute values.
276
+ #
277
+ def to_h
278
+ @config
279
+ end
280
+ end # ProjectConfig
281
+
282
+ end # DSL
283
+ end # Polymer
@@ -0,0 +1,60 @@
1
+ .\" generated with Ronn/v0.7.3
2
+ .\" http://github.com/rtomayko/ronn/tree/0.7.3
3
+ .ad l
4
+ .
5
+ .TH "POLYMER\-BOND" "1" "September 2010" "POLYMER 1.0.0.BETA.3" "Polymer Manual"
6
+ .
7
+ .SH "NAME"
8
+ \fBpolymer\-bond\fR \- Create sprite images defined in your \.polymer file
9
+ .
10
+ .SH "SYNOPSIS"
11
+ \fBpolymer bond\fR [\-\-force] [\-\-fast] [\-\-config=POLYMER_CONFIG]
12
+ .
13
+ .SH "DESCRIPTION"
14
+ Generate the sprites defined in your polymer(5) file\. After each sprite is generated, the sprites are optimised using whichever available PNG optimisers you have installed (PNGOUT, OptiPNG, and PNGCrush) in order to reduce the filesize as much as possible\.
15
+ .
16
+ .P
17
+ Sass and CSS is then generated according to the settings defined in your polymer(5) configuration\.
18
+ .
19
+ .P
20
+ Polymer keeps track of the contents of each sprite with a \fB\.polymer\-cache\fR file so that subsequent runs of \fBpolymer bond\fR will only re\-generate (and re\-optimise) those sprites whose sources have changed\. See the \fIPOLYMER CACHE\fR section \-\- below \-\- for more information\.
21
+ .
22
+ .SH "OPTIONS"
23
+ .
24
+ .TP
25
+ \fB\-\-force\fR
26
+ Something something something dark side: re\-generate sprites even if the sources have not changed since last time\.
27
+ .
28
+ .TP
29
+ \fB\-\-fast\fR
30
+ Skips optimisation of generated sprites\. Useful when you want to quickly preview changes without waiting for the optimisers to run\.
31
+ .
32
+ .TP
33
+ \fB\-\-config=<path>\fR
34
+ In order to perform some tasks \-\- such as generating sprites \-\- Polymer needs to locate your \fB\.polymer\fR project file\. The default behaviour is to look for one in the current working directory, and to keep ascending the directory structure until it finds one\.
35
+ .
36
+ .IP
37
+ To disable this behaviour, you may supply a path to the config file by using the \fB\-\-config\fR option\.
38
+ .
39
+ .SH "POLYMER CACHE"
40
+ Since optimising sprites can be a lengthy process (very large sprites may take minutes), Polymer keeps track of the contents of each sprite with a \fB\.polymer\-cache\fR file\.
41
+ .
42
+ .P
43
+ Polymer will re\-generate an existing sprite in the following cases:
44
+ .
45
+ .IP "1." 4
46
+ the contents of a source file is changed; or,
47
+ .
48
+ .IP "2." 4
49
+ a new source file is added, or an existing one deleted; or,
50
+ .
51
+ .IP "3." 4
52
+ the generated sprite file is missing; or,
53
+ .
54
+ .IP "4." 4
55
+ you pass the \fB\-\-force\fR option\.
56
+ .
57
+ .IP "" 0
58
+ .
59
+ .SH "SEE ALSO"
60
+ polymer(5)
@@ -0,0 +1,66 @@
1
+ POLYMER-BOND(1) Polymer Manual POLYMER-BOND(1)
2
+
3
+
4
+
5
+ NAME
6
+ polymer-bond - Create sprite images defined in your .polymer file
7
+
8
+ SYNOPSIS
9
+ polymer bond [--force] [--fast] [--config=POLYMER_CONFIG]
10
+
11
+ DESCRIPTION
12
+ Generate the sprites defined in your polymer(5) file. After each sprite
13
+ is generated, the sprites are optimised using whichever available PNG
14
+ optimisers you have installed (PNGOUT, OptiPNG, and PNGCrush) in order
15
+ to reduce the filesize as much as possible.
16
+
17
+ Sass and CSS is then generated according to the settings defined in
18
+ your polymer(5) configuration.
19
+
20
+ Polymer keeps track of the contents of each sprite with a .poly-
21
+ mer-cache file so that subsequent runs of polymer bond will only
22
+ re-generate (and re-optimise) those sprites whose sources have changed.
23
+ See the POLYMER CACHE section -- below -- for more information.
24
+
25
+ OPTIONS
26
+ --force
27
+ Something something something dark side: re-generate sprites
28
+ even if the sources have not changed since last time.
29
+
30
+ --fast Skips optimisation of generated sprites. Useful when you want to
31
+ quickly preview changes without waiting for the optimisers to
32
+ run.
33
+
34
+ --config=<path>
35
+ In order to perform some tasks -- such as generating sprites --
36
+ Polymer needs to locate your .polymer project file. The default
37
+ behaviour is to look for one in the current working directory,
38
+ and to keep ascending the directory structure until it finds
39
+ one.
40
+
41
+ To disable this behaviour, you may supply a path to the config
42
+ file by using the --config option.
43
+
44
+ POLYMER CACHE
45
+ Since optimising sprites can be a lengthy process (very large sprites
46
+ may take minutes), Polymer keeps track of the contents of each sprite
47
+ with a .polymer-cache file.
48
+
49
+ Polymer will re-generate an existing sprite in the following cases:
50
+
51
+ 1. the contents of a source file is changed; or,
52
+
53
+ 2. a new source file is added, or an existing one deleted; or,
54
+
55
+ 3. the generated sprite file is missing; or,
56
+
57
+ 4. you pass the --force option.
58
+
59
+
60
+
61
+ SEE ALSO
62
+ polymer(5)
63
+
64
+
65
+
66
+ POLYMER 1.0.0.BETA.3 September 2010 POLYMER-BOND(1)
@@ -0,0 +1,33 @@
1
+ .\" generated with Ronn/v0.7.3
2
+ .\" http://github.com/rtomayko/ronn/tree/0.7.3
3
+ .ad l
4
+ .
5
+ .TH "POLYMER\-INIT" "1" "September 2010" "POLYMER 1.0.0.BETA.3" "Polymer Manual"
6
+ .
7
+ .SH "NAME"
8
+ \fBpolymer\-init\fR \- Create a new Polymer project in the current directory
9
+ .
10
+ .SH "SYNOPSIS"
11
+ \fBpolymer init\fR [\-\-sprites=SPRITES] [\-\-sources=SOURCES] [\-\-no\-examples] [\-\-windows]
12
+ .
13
+ .SH "DESCRIPTION"
14
+ Create a \fB\.polymer\fR file in the current directory with some sensible default settings\. By default, the \fBinit\fR command also copies some sample sources to provide a working example of how to create your own sprites\.
15
+ .
16
+ .SH "OPTIONS"
17
+ .
18
+ .TP
19
+ \fB\-\-sprites=<path>\fR
20
+ Path to a directory, relative to the current directory, in which sprites should be saved by default\. This can be customised later by in your polymer(5) file\. Default: public/images
21
+ .
22
+ .TP
23
+ \fB\-\-sources=<path>\fR
24
+ Path to a directory, relative to the current directory, in which Polymer should find the sources for your sprites\. This can be customised later in your polymer(5) file\. Default public/images/sprites
25
+ .
26
+ .TP
27
+ \fB\-\-no\-examples\fR
28
+ The \fBinit\fR command copies some sample sources into your \fBsources\fR directory to provide an example of how Polymer works\. The \fB\-\-no\-examples\fR option disabled this\.
29
+ .
30
+ .TP
31
+ \fB\-\-windows\fR
32
+ To provide better support for systems where files beginning with a "\." are troublesome, the \fB\-\-windows\fR option tells Polymer to create a \fBpolymer\.rb\fR file instead of \fB\.polymer\fR\.
33
+
@@ -0,0 +1,42 @@
1
+ POLYMER-INIT(1) Polymer Manual POLYMER-INIT(1)
2
+
3
+
4
+
5
+ NAME
6
+ polymer-init - Create a new Polymer project in the current directory
7
+
8
+ SYNOPSIS
9
+ polymer init [--sprites=SPRITES] [--sources=SOURCES] [--no-examples]
10
+ [--windows]
11
+
12
+ DESCRIPTION
13
+ Create a .polymer file in the current directory with some sensible
14
+ default settings. By default, the init command also copies some sample
15
+ sources to provide a working example of how to create your own sprites.
16
+
17
+ OPTIONS
18
+ --sprites=<path>
19
+ Path to a directory, relative to the current directory, in which
20
+ sprites should be saved by default. This can be customised later
21
+ by in your polymer(5) file. Default: public/images
22
+
23
+ --sources=<path>
24
+ Path to a directory, relative to the current directory, in which
25
+ Polymer should find the sources for your sprites. This can be
26
+ customised later in your polymer(5) file. Default pub-
27
+ lic/images/sprites
28
+
29
+ --no-examples
30
+ The init command copies some sample sources into your sources
31
+ directory to provide an example of how Polymer works. The
32
+ --no-examples option disabled this.
33
+
34
+ --windows
35
+ To provide better support for systems where files beginning with
36
+ a "." are troublesome, the --windows option tells Polymer to
37
+ create a polymer.rb file instead of .polymer.
38
+
39
+
40
+
41
+
42
+ POLYMER 1.0.0.BETA.3 September 2010 POLYMER-INIT(1)
@@ -0,0 +1,23 @@
1
+ .\" generated with Ronn/v0.7.3
2
+ .\" http://github.com/rtomayko/ronn/tree/0.7.3
3
+ .ad l
4
+ .
5
+ .TH "POLYMER\-OPTIMISE" "1" "September 2010" "POLYMER 1.0.0.BETA.3" "Polymer Manual"
6
+ .
7
+ .SH "NAME"
8
+ \fBpolymer\-optimise\fR \- Optimise PNG images
9
+ .
10
+ .SH "SYNOPSIS"
11
+ \fBpolymer optimise\fR PATH [PATH [PATH \.\.\.]]
12
+ .
13
+ .SH "DESCRIPTION"
14
+ Optimises the PNG images at \fIPATH\fR\. Does not require you to be in a Polymer project directory\.
15
+ .
16
+ .P
17
+ The \fBoptimise\fR command permits you to use the optimisers supported by Polymer on any PNG image\. This is useful for optimising non\-sprite image, or sprites which were generated with the \fB\-\-fast\fR option\.
18
+ .
19
+ .P
20
+ All \fIPATH\fRs are relative to the current working directory\.
21
+ .
22
+ .P
23
+ This command may also be run as \fBpolymer optimize\fR\.
@@ -0,0 +1,25 @@
1
+ POLYMER-OPTIMISE(1) Polymer Manual POLYMER-OPTIMISE(1)
2
+
3
+
4
+
5
+ NAME
6
+ polymer-optimise - Optimise PNG images
7
+
8
+ SYNOPSIS
9
+ polymer optimise PATH [PATH [PATH ...]]
10
+
11
+ DESCRIPTION
12
+ Optimises the PNG images at PATH. Does not require you to be in a Poly-
13
+ mer project directory.
14
+
15
+ The optimise command permits you to use the optimisers supported by
16
+ Polymer on any PNG image. This is useful for optimising non-sprite
17
+ image, or sprites which were generated with the --fast option.
18
+
19
+ All PATHs are relative to the current working directory.
20
+
21
+ This command may also be run as polymer optimize.
22
+
23
+
24
+
25
+ POLYMER 1.0.0.BETA.3 September 2010 POLYMER-OPTIMISE(1)
@@ -0,0 +1,39 @@
1
+ .\" generated with Ronn/v0.7.3
2
+ .\" http://github.com/rtomayko/ronn/tree/0.7.3
3
+ .ad l
4
+ .
5
+ .TH "POLYMER\-POSITION" "1" "September 2010" "POLYMER 1.0.0.BETA.3" "Polymer Manual"
6
+ .
7
+ .SH "NAME"
8
+ \fBpolymer\-position\fR \- Information about your sprite sources
9
+ .
10
+ .SH "SYNOPSIS"
11
+ \fBpolymer position\fR SOURCE
12
+ .
13
+ .SH "DESCRIPTION"
14
+ Shows the position of a \fISOURCE\fR image with a sprite\. This is useful should you wish to manually create your own CSS files, without having to calculate the position of each source yourself\. Also provides you with the basic CSS needed to show the source image\.
15
+ .
16
+ .P
17
+ The \fISOURCE\fR may be the name of a source image in any of your sprites, or a \fISPRITE\fR/\fISOURCE\fR pair\.
18
+ .
19
+ .P
20
+ For example, assuming the following sources\.\.\.
21
+ .
22
+ .IP "" 4
23
+ .
24
+ .nf
25
+
26
+ sources/
27
+ one/
28
+ book\.png
29
+ television\.png
30
+ two/
31
+ magnet\.png
32
+ television\.png
33
+ .
34
+ .fi
35
+ .
36
+ .IP "" 0
37
+ .
38
+ .P
39
+ \&\.\.\. \fBpolymer position book\fR will show the position of the book source in the "one" sprite\. \fBpolymer position television\fR will output the position of the television source in both the "one" and "two" sprites\. Finally, \fBpolymer position two/television\fR shows the position of the television source in only the "two" sprite\.
@@ -0,0 +1,42 @@
1
+ POLYMER-POSITION(1) Polymer Manual POLYMER-POSITION(1)
2
+
3
+
4
+
5
+ NAME
6
+ polymer-position - Information about your sprite sources
7
+
8
+ SYNOPSIS
9
+ polymer position SOURCE
10
+
11
+ DESCRIPTION
12
+ Shows the position of a SOURCE image with a sprite. This is useful
13
+ should you wish to manually create your own CSS files, without having
14
+ to calculate the position of each source yourself. Also provides you
15
+ with the basic CSS needed to show the source image.
16
+
17
+ The SOURCE may be the name of a source image in any of your sprites, or
18
+ a SPRITE/SOURCE pair.
19
+
20
+ For example, assuming the following sources...
21
+
22
+
23
+
24
+ sources/
25
+ one/
26
+ book.png
27
+ television.png
28
+ two/
29
+ magnet.png
30
+ television.png
31
+
32
+
33
+
34
+ ... polymer position book will show the position of the book source in
35
+ the "one" sprite. polymer position television will output the position
36
+ of the television source in both the "one" and "two" sprites. Finally,
37
+ polymer position two/television shows the position of the television
38
+ source in only the "two" sprite.
39
+
40
+
41
+
42
+ POLYMER 1.0.0.BETA.3 September 2010 POLYMER-POSITION(1)
@@ -0,0 +1,50 @@
1
+ .\" generated with Ronn/v0.7.3
2
+ .\" http://github.com/rtomayko/ronn/tree/0.7.3
3
+ .ad l
4
+ .
5
+ .TH "POLYMER" "1" "September 2010" "POLYMER 1.0.0.BETA.3" "Polymer Manual"
6
+ .
7
+ .SH "NAME"
8
+ \fBpolymer\fR \- Image spriting for web applications
9
+ .
10
+ .SH "SYNOPSIS"
11
+ \fBpolymer\fR [\-\-no\-colour] COMMAND [ARGUMENTS]
12
+ .
13
+ .SH "DESCRIPTION"
14
+ \fBPolymer\fR is a tool for creating sprite images which combine many smaller sources into a single larger image\. Spriting allows you to reduce the number of HTTP requests required to load a web page, and as such can result in reduced load times\.
15
+ .
16
+ .P
17
+ Polymer also creates the necessary CSS to position the sprite within an HTML element so that only the desired source appears\. Those writing their website or application in Ruby can make use of Polymer\'s Sass builder which creates a Sass mixin, further simplifying the use of your sprites\.
18
+ .
19
+ .P
20
+ In order to reduce the amount of data transferred to clients loading your pages, Polymer optimises the sprites it generates using PNGOUT, OptiPNG, and PNGCrush\.
21
+ .
22
+ .SH "OPTIONS"
23
+ .
24
+ .TP
25
+ \fB\-\-no\-colour\fR
26
+ Disables the use of colour in output\. This option is also available as \fB\-\-no\-color\fR\.
27
+ .
28
+ .SH "COMMANDS"
29
+ .
30
+ .TP
31
+ polymer init(1) \fIpolymer\-init\.1\.html\fR
32
+ Creates a new Polymer project in the current directory\.
33
+ .
34
+ .TP
35
+ polymer bond(1) \fIpolymer\-bond\.1\.html\fR
36
+ Creates the sprites specified by your \fB\.polymer\fR or \fBpolymer\.rb\fR file, optimises the images, and creates any requested CSS or Sass files\.
37
+ .
38
+ .TP
39
+ polymer optimise(1) \fIpolymer\-optimise\.1\.html\fR
40
+ Given paths to PNG files as arguments, optimises them to reduce the filesize as much as possible without compromising quality\. Also available as \fBpolymer optimize\fR\.
41
+ .
42
+ .TP
43
+ polymer position(1) \fIpolymer\-position\.1\.html\fR
44
+ Shows the position of a source within a sprite, and provides CSS which you can use in your own stylesheets\.
45
+ .
46
+ .P
47
+ Detailed documentation for each of Polymer\'s commands can be viewed with the \fBpolymer help\fR command\. For example, to view the documentation for the \fBbond\fR command, run \fBpolymer help bond\fR\.
48
+ .
49
+ .SH "SEE ALSO"
50
+ polymer(5) (\fBpolymer help \.polymer\fR) provides a description of the \fB\.polymer\fR configuration file format\.