svgeez 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.editorconfig +13 -0
- data/.gitignore +9 -0
- data/.rspec +2 -0
- data/.ruby-version +1 -0
- data/.travis.yml +4 -0
- data/CODE_OF_CONDUCT.md +50 -0
- data/Gemfile +6 -0
- data/LICENSE +21 -0
- data/README.md +167 -0
- data/Rakefile +6 -0
- data/bin/svgeez +21 -0
- data/lib/svgeez/command.rb +20 -0
- data/lib/svgeez/commands/build.rb +22 -0
- data/lib/svgeez/commands/watch.rb +33 -0
- data/lib/svgeez/sprite_builder.rb +76 -0
- data/lib/svgeez/version.rb +3 -0
- data/lib/svgeez.rb +22 -0
- data/svgeez.gemspec +27 -0
- metadata +133 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 563813efa4871b6fa125c35a124918baad701d29
|
4
|
+
data.tar.gz: 9841c3d7f577d03364aa7ceac0309b740d278710
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: f59c9a8dafdc8eb977f494dd95fd53179bed4e28b0df83272f7853e3f2f8aac7485a6cd6a57dfafa8072478abad0dc26eb8c47acadb7dc39d2942cee94c27dca
|
7
|
+
data.tar.gz: 426edfc2169c9e2566a33affeec95c1bcdb60f02cce1c8420a65cb1d484ffbb2aace021dbab32f7cb8ea499df6c101eb5944ae5a1eba5ec311e52ce78f1bb84a
|
data/.editorconfig
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
# EditorConfig is awesome: http://EditorConfig.org
|
2
|
+
root = true
|
3
|
+
|
4
|
+
[*]
|
5
|
+
charset = utf-8
|
6
|
+
end_of_line = lf
|
7
|
+
insert_final_newline = true
|
8
|
+
indent_size = 2
|
9
|
+
indent_style = space
|
10
|
+
trim_trailing_whitespace = true
|
11
|
+
|
12
|
+
[*.svg]
|
13
|
+
insert_final_newline = false
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
2.2.3
|
data/.travis.yml
ADDED
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,50 @@
|
|
1
|
+
# Contributor Code of Conduct
|
2
|
+
|
3
|
+
As contributors and maintainers of this project, and in the interest of
|
4
|
+
fostering an open and welcoming community, we pledge to respect all people who
|
5
|
+
contribute through reporting issues, posting feature requests, updating
|
6
|
+
documentation, submitting pull requests or patches, and other activities.
|
7
|
+
|
8
|
+
We are committed to making participation in this project a harassment-free
|
9
|
+
experience for everyone, regardless of level of experience, gender, gender
|
10
|
+
identity and expression, sexual orientation, disability, personal appearance,
|
11
|
+
body size, race, ethnicity, age, religion, or nationality.
|
12
|
+
|
13
|
+
Examples of unacceptable behavior by participants include:
|
14
|
+
|
15
|
+
* The use of sexualized language or imagery
|
16
|
+
* Personal attacks
|
17
|
+
* Trolling or insulting/derogatory comments
|
18
|
+
* Public or private harassment
|
19
|
+
* Publishing other's private information, such as physical or electronic
|
20
|
+
addresses, without explicit permission
|
21
|
+
* Other unethical or unprofessional conduct
|
22
|
+
|
23
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
24
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
25
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
26
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
27
|
+
threatening, offensive, or harmful.
|
28
|
+
|
29
|
+
By adopting this Code of Conduct, project maintainers commit themselves to
|
30
|
+
fairly and consistently applying these principles to every aspect of managing
|
31
|
+
this project. Project maintainers who do not follow or enforce the Code of
|
32
|
+
Conduct may be permanently removed from the project team.
|
33
|
+
|
34
|
+
This code of conduct applies both within project spaces and in public spaces
|
35
|
+
when an individual is representing the project or its community.
|
36
|
+
|
37
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
38
|
+
reported by contacting a project maintainer at [INSERT EMAIL ADDRESS]. All
|
39
|
+
complaints will be reviewed and investigated and will result in a response that
|
40
|
+
is deemed necessary and appropriate to the circumstances. Maintainers are
|
41
|
+
obligated to maintain confidentiality with regard to the reporter of an
|
42
|
+
incident.
|
43
|
+
|
44
|
+
|
45
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage],
|
46
|
+
version 1.3.0, available at
|
47
|
+
[http://contributor-covenant.org/version/1/3/0/][version]
|
48
|
+
|
49
|
+
[homepage]: http://contributor-covenant.org
|
50
|
+
[version]: http://contributor-covenant.org/version/1/3/0/
|
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2015 Jason Garber
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,167 @@
|
|
1
|
+
# svgeez
|
2
|
+
|
3
|
+
**A Ruby gem for automatically generating an SVG sprite from a folder of SVG icons.**
|
4
|
+
|
5
|
+
[![Build Status](https://travis-ci.org/jgarber623/svgeez.svg?branch=master)](https://travis-ci.org/jgarber623/svgeez)
|
6
|
+
|
7
|
+
If you're using an [SVG](https://en.wikipedia.org/wiki/Scalable_Vector_Graphics) icon system in your Web projects, svgeez can help speed up your workflow by automating the SVG sprite generation process. Simply run svgeez alongside your existing project (or integrate it into your current build system); add, edit, or delete SVG files from a directory; and marvel as svgeez generates a single SVG sprite file ready for inclusion in your user interface.
|
8
|
+
|
9
|
+
_For more on why SVG sprites are the bee's knees as far as icon systems go, give Chris Coyier's original post, [Icon System with SVG Sprites](https://css-tricks.com/svg-sprites-use-better-icon-fonts/), and his follow-up article, [SVG \`symbol\` a Good Choice for Icons](https://css-tricks.com/svg-symbol-good-choice-icons/) a read-through._
|
10
|
+
|
11
|
+
## Key Features
|
12
|
+
|
13
|
+
- Provides a simple [CLI](https://en.wikipedia.org/wiki/Command-line_interface) for generating SVG sprite files.
|
14
|
+
- Easily integrates with existing projects (e.g. alongside a Rails application using [Foreman](https://github.com/ddollar/foreman)).
|
15
|
+
- Optionally optimizes SVG files with [SVGO](https://github.com/svg/svgo/).
|
16
|
+
|
17
|
+
## Getting Started
|
18
|
+
|
19
|
+
Before installing and using svgeez, you'll want to have Ruby 2.2.3 installed on your computer. There are plenty of ways to go about this, but my preference is [rbenv](https://github.com/sstephenson/rbenv). If you're developing on a Mac and using [Homebrew](http://brew.sh/), installing rbenv is [super easy](https://github.com/sstephenson/rbenv#homebrew-on-mac-os-x).
|
20
|
+
|
21
|
+
svgeez _might_ work with other versions of Ruby, but it's tested against 2.2.3.
|
22
|
+
|
23
|
+
## Installation
|
24
|
+
|
25
|
+
If you're using Bundler, add svgeez to your project's Gemfile:
|
26
|
+
|
27
|
+
```rb
|
28
|
+
ruby '2.2.3'
|
29
|
+
|
30
|
+
source 'https://rubygems.org' do
|
31
|
+
gem 'svgeez'
|
32
|
+
end
|
33
|
+
```
|
34
|
+
|
35
|
+
…and hop over to your command prompt and run…
|
36
|
+
|
37
|
+
`$ bundle`
|
38
|
+
|
39
|
+
You may also install svgeez directly by issuing the following command:
|
40
|
+
|
41
|
+
`$ gem install svgeez`
|
42
|
+
|
43
|
+
## Usage
|
44
|
+
|
45
|
+
svgeez is a command line program with several useful subcommands. From the root of your project, run `svgeez -h` for a complete list of commands.
|
46
|
+
|
47
|
+
### The `build` command
|
48
|
+
|
49
|
+
You can manually generate an SVG sprite from a folder of SVGs with the `build` command which takes two options, a path to your folder of individual SVGs and a path to the desired output folder. _These paths must be different!_
|
50
|
+
|
51
|
+
A basic example:
|
52
|
+
|
53
|
+
```sh
|
54
|
+
$ svgeez build --source ~/Sites/sixtwothree.org/images/icons --destination ~/Sites/sixtwothree.org/images
|
55
|
+
```
|
56
|
+
|
57
|
+
The above example will combine all SVG files in `~/Sites/sixtwothree.org/images/icons` into a single SVG sprite in `~/Sites/sixtwothree.org/images`. The resulting sprite file will be named `icons.svg` (this file name is derived from the name of the provided source folder).
|
58
|
+
|
59
|
+
### The `watch` command
|
60
|
+
|
61
|
+
The `watch` command takes the same arguments as the `build` command but uses the [Listen gem](https://github.com/guard/listen) to observe changes in the source folder.
|
62
|
+
|
63
|
+
Tweaking the example from above:
|
64
|
+
|
65
|
+
```sh
|
66
|
+
$ svgeez watch --source ~/Sites/sixtwothree.org/images/icons --destination ~/Sites/sixtwothree.org/images
|
67
|
+
```
|
68
|
+
|
69
|
+
svgeez will remaing running, watching for new, removed, or updated SVG files in the provided source folder. As SVG files are added, deleted, or modified in the source folder, svgeez will keep pumping out updated SVG sprite files to the destination folder.
|
70
|
+
|
71
|
+
### Optimizing generated files with SVGO
|
72
|
+
|
73
|
+
If you have the excellent [SVGO](https://github.com/svg/svgo/) utility installed on your system (and the `svgo` command is available in your PATH), you can use the `--with-svgo` option and optimize source SVGs before generating the sprite file.
|
74
|
+
|
75
|
+
```sh
|
76
|
+
$ svgeez build --source ~/Sites/sixtwothree.org/images/icons --destination ~/Sites/sixtwothree.org/images --with-svgo
|
77
|
+
```
|
78
|
+
|
79
|
+
Optimizing source SVG files with SVGO is done on-the-fly and the original files are left intact. Depending on the number of individual SVG files in the source directory, using the `--with-svgo` option can add considerable time to SVG sprite generation.
|
80
|
+
|
81
|
+
## Working with SVG sprites
|
82
|
+
|
83
|
+
Within generated SVG sprite files, each icon is wrapped in a `<symbol>` element and assigned an `id` attribute with a value combining the SVG sprite's file name and the original, individual icon's file name.
|
84
|
+
|
85
|
+
For example, a file named `menu.svg` in `~/Sites/sixtwothree.org/images/icons` will be assigned an `id` value of `icons-menu`.
|
86
|
+
|
87
|
+
```svg
|
88
|
+
<symbol fill="currentcolor" id="icons-menu" viewBox="0 0 32 32">
|
89
|
+
<path d="…"/>
|
90
|
+
</symbol>
|
91
|
+
```
|
92
|
+
|
93
|
+
### Markup
|
94
|
+
|
95
|
+
To use an svgeez-generated SVG sprite file, first include the file's contents at the top of your HTML page, just after open `<body>` element.
|
96
|
+
|
97
|
+
In a Rails 4 application:
|
98
|
+
|
99
|
+
```erb
|
100
|
+
<body>
|
101
|
+
<%= raw assets.find_asset('icons.svg') %>
|
102
|
+
</body>
|
103
|
+
```
|
104
|
+
|
105
|
+
Or, with PHP:
|
106
|
+
|
107
|
+
```php
|
108
|
+
<body>
|
109
|
+
<?php include_once('path/to/icons.svg'); ?>
|
110
|
+
</body>
|
111
|
+
```
|
112
|
+
|
113
|
+
Next, wherever you want to include an icon in your user interface, use HTML similar to the following, replacing the identifier `#icons-menu` with a value corresponding to the ID of the `<symbol>` in the relevant SVG sprite file:
|
114
|
+
|
115
|
+
```html
|
116
|
+
<svg><use xlink:href="#icons-menu"></svg>
|
117
|
+
```
|
118
|
+
|
119
|
+
A more complete example from a Rails 4 application's layout file:
|
120
|
+
|
121
|
+
```erb
|
122
|
+
<body>
|
123
|
+
<%= raw assets.find_asset('icons.svg') %>
|
124
|
+
|
125
|
+
<button>
|
126
|
+
<svg><use xlink:href="#icons-menu"></svg>
|
127
|
+
Menu
|
128
|
+
</button>
|
129
|
+
</body>
|
130
|
+
```
|
131
|
+
|
132
|
+
In this example, the contents of the svgeez-generated SVG sprite file is included on every page and isn't terribly cacheable. How onerous this is depends on the size of your icon system.
|
133
|
+
|
134
|
+
For smaller icon sets, this may be an acceptable balance of user and developer needs. For larger icon sets, you may want to investigate more advanced techniques for loading and caching an SVG sprite file (perhaps with [localStorage](https://developer.mozilla.org/en-US/docs/Web/API/Storage/LocalStorage)…?)
|
135
|
+
|
136
|
+
### Styling embedded icons
|
137
|
+
|
138
|
+
Icons embedded with the inline `<use>` technique will inherit their fill color from the nearest parent's `color` value (thanks to each `<symbol>`'s `fill="currentcolor"` attribute), but this can be overriden with CSS:
|
139
|
+
|
140
|
+
```css
|
141
|
+
button {
|
142
|
+
color: #333;
|
143
|
+
}
|
144
|
+
|
145
|
+
button svg {
|
146
|
+
fill: #c00; // Absent this declaration, the icon's fill color would be #333
|
147
|
+
}
|
148
|
+
```
|
149
|
+
|
150
|
+
## Acknowledgements
|
151
|
+
|
152
|
+
svgeez benefited greatly from the hard work done by the folks working on the following projects:
|
153
|
+
|
154
|
+
- [Jekyll](https://github.com/jekyll/jekyll)
|
155
|
+
- [jekyll-watch](https://github.com/jekyll/jekyll-watch)
|
156
|
+
- [Mercenary](https://github.com/jekyll/mercenary)
|
157
|
+
- [Listen](https://github.com/guard/listen)
|
158
|
+
|
159
|
+
Additionally, Chris Coyier's [CSS Tricks](https://css-tricks.com/) posts linked above got me interested in SVG sprites.
|
160
|
+
|
161
|
+
Lastly, the sample icons in `spec/fixtures/icons` are from [@jxnblk](https://github.com/jxnblk)'s [Geomicons Open](https://github.com/jxnblk/geomicons-open) icon set.
|
162
|
+
|
163
|
+
svgeez is written and maintained by [@jgarber623](https://github.com/jgarber623).
|
164
|
+
|
165
|
+
## License
|
166
|
+
|
167
|
+
svgeez is freely available under the [MIT License](http://opensource.org/licenses/MIT). Use it, learn from it, fork it, improve it, change it, tailor it to your needs.
|
data/Rakefile
ADDED
data/bin/svgeez
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
$:.unshift File.join(File.dirname(__FILE__), *%w{ .. lib })
|
4
|
+
|
5
|
+
require 'svgeez'
|
6
|
+
require 'mercenary'
|
7
|
+
|
8
|
+
Mercenary.program(:svgeez) do |p|
|
9
|
+
p.version Svgeez::VERSION
|
10
|
+
p.description 'Generate an SVG sprite from a folder of SVG icons.'
|
11
|
+
p.syntax 'svgeez <subcommand> [options]'
|
12
|
+
|
13
|
+
Svgeez::Command.subclasses.each { |c| c.init_with_program(p) }
|
14
|
+
|
15
|
+
p.action do |args, options|
|
16
|
+
if args.empty?
|
17
|
+
puts p
|
18
|
+
abort
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module Svgeez
|
2
|
+
class Command
|
3
|
+
class << self
|
4
|
+
def subclasses
|
5
|
+
@subclasses ||= []
|
6
|
+
end
|
7
|
+
|
8
|
+
def inherited(base)
|
9
|
+
subclasses << base
|
10
|
+
super(base)
|
11
|
+
end
|
12
|
+
|
13
|
+
def add_build_options(c)
|
14
|
+
c.option 'source', '-s', '--source [DIR]', 'Source directory (defaults to ./)'
|
15
|
+
c.option 'destination', '-d', '--destination [DIR]', 'Destination directory (defaults to ./_svgeez)'
|
16
|
+
c.option 'svgo', '--with-svgo', 'Optimize source SVGs with SVGO before sprite generation (non-destructive)'
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
module Svgeez
|
2
|
+
module Commands
|
3
|
+
class Build < Command
|
4
|
+
def self.init_with_program(p)
|
5
|
+
p.command(:build) do |c|
|
6
|
+
c.description 'Builds an SVG sprite from a folder of SVG icons'
|
7
|
+
c.syntax 'build [options]'
|
8
|
+
|
9
|
+
add_build_options(c)
|
10
|
+
|
11
|
+
c.action do |_, options|
|
12
|
+
Svgeez::Commands::Build.process(options)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
def self.process(options)
|
18
|
+
Svgeez::SpriteBuilder.new(options).build
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
module Svgeez
|
2
|
+
module Commands
|
3
|
+
class Watch < Command
|
4
|
+
class << self
|
5
|
+
def init_with_program(p)
|
6
|
+
p.command(:watch) do |c|
|
7
|
+
c.description 'Watches a folder of SVG icons for changes'
|
8
|
+
c.syntax 'watch [options]'
|
9
|
+
|
10
|
+
add_build_options(c)
|
11
|
+
|
12
|
+
c.action do |_, options|
|
13
|
+
Svgeez::Commands::Build.process(options)
|
14
|
+
Svgeez::Commands::Watch.process(options)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
def process(options)
|
20
|
+
Svgeez.logger.info %{Watching `#{File.expand_path(options['source'])}` for changes... Press ctrl-c to stop.}
|
21
|
+
|
22
|
+
listener = Listen.to(options['source'], only: /\.svg$/) do |modified, added, removed|
|
23
|
+
Svgeez::Commands::Build.process(options)
|
24
|
+
end
|
25
|
+
|
26
|
+
listener.start
|
27
|
+
sleep
|
28
|
+
rescue Interrupt => e
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,76 @@
|
|
1
|
+
module Svgeez
|
2
|
+
class SpriteBuilder
|
3
|
+
def initialize(options)
|
4
|
+
@source = File.expand_path(options.fetch('source', './'))
|
5
|
+
@destination = File.expand_path(options.fetch('destination', './_svgeez'))
|
6
|
+
@with_svgo = options['svgo']
|
7
|
+
end
|
8
|
+
|
9
|
+
def build
|
10
|
+
unless source_is_destination?
|
11
|
+
if input_file_paths.any?
|
12
|
+
Svgeez.logger.info %{Generating sprite at `#{output_file_path}` from #{input_file_paths.length} SVG#{'s' if input_file_paths.length > 1}...}
|
13
|
+
|
14
|
+
# Make destination directory
|
15
|
+
FileUtils.mkdir_p(@destination)
|
16
|
+
|
17
|
+
# Notify if SVGO requested but not found
|
18
|
+
if @with_svgo && !svgo_installed?
|
19
|
+
Svgeez.logger.warn %{Unable to find `svgo` in your PATH. Continuing with standard sprite generation...}
|
20
|
+
end
|
21
|
+
|
22
|
+
# Write the file
|
23
|
+
File.open(output_file_path, 'w') do |f|
|
24
|
+
f.write build_output_file_contents
|
25
|
+
end
|
26
|
+
|
27
|
+
Svgeez.logger.info %{Successfully generated sprite at `#{output_file_path}`.}
|
28
|
+
else
|
29
|
+
Svgeez.logger.warn %{No SVGs were found in `#{@source}`.}
|
30
|
+
end
|
31
|
+
else
|
32
|
+
Svgeez.logger.error %{Setting `source` and `destination` to the same path isn't allowed!}
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
def build_output_file_contents
|
37
|
+
'<svg xmlns="http://www.w3.org/2000/svg" style="display: none;">'.tap do |output_file_contents|
|
38
|
+
# Loop over all input files, grabbing their content, and appending to `output_file_contents`
|
39
|
+
input_file_paths.each do |file_path|
|
40
|
+
file_contents = use_svgo? ? `svgo -i #{file_path} -o -` : IO.read(file_path)
|
41
|
+
pattern = /^<svg.*?(?<viewbox>viewBox=".*?").*?>(?<content>.*?)<\/svg>$/m
|
42
|
+
|
43
|
+
file_contents.match(pattern) do |matches|
|
44
|
+
output_file_contents << %{<symbol fill="currentcolor" id="#{source_basename}-#{File.basename(file_path, '.svg').downcase}" #{matches[:viewbox]}>#{matches[:content]}</symbol>}
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
output_file_contents << '</svg>'
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
def input_file_paths
|
53
|
+
Dir.glob(File.join(@source, '*.svg'))
|
54
|
+
end
|
55
|
+
|
56
|
+
def output_file_path
|
57
|
+
File.join(@destination, %{#{source_basename}.svg})
|
58
|
+
end
|
59
|
+
|
60
|
+
def source_basename
|
61
|
+
@source_basename ||= File.basename(@source)
|
62
|
+
end
|
63
|
+
|
64
|
+
def source_is_destination?
|
65
|
+
@source == @destination
|
66
|
+
end
|
67
|
+
|
68
|
+
def svgo_installed?
|
69
|
+
@svgo_installed ||= find_executable0('svgo')
|
70
|
+
end
|
71
|
+
|
72
|
+
def use_svgo?
|
73
|
+
@use_svgo ||= @with_svgo && svgo_installed?
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
data/lib/svgeez.rb
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'fileutils'
|
2
|
+
require 'listen'
|
3
|
+
require 'logger'
|
4
|
+
require 'mkmf'
|
5
|
+
|
6
|
+
require 'svgeez/version'
|
7
|
+
require 'svgeez/command'
|
8
|
+
require 'svgeez/commands/build'
|
9
|
+
require 'svgeez/commands/watch'
|
10
|
+
require 'svgeez/sprite_builder'
|
11
|
+
|
12
|
+
module Svgeez
|
13
|
+
class << self
|
14
|
+
def logger
|
15
|
+
@logger ||= Logger.new(STDOUT)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
self.logger.formatter = proc do |severity, datetime, progname, msg|
|
20
|
+
%{#{msg}\n}
|
21
|
+
end
|
22
|
+
end
|
data/svgeez.gemspec
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'svgeez/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = 'svgeez'
|
8
|
+
spec.version = Svgeez::VERSION
|
9
|
+
spec.authors = ['Jason Garber']
|
10
|
+
spec.email = ['jason@sixtwothree.org']
|
11
|
+
|
12
|
+
spec.summary = %{Automatically generate an SVG sprite from a folder of SVG icons.}
|
13
|
+
spec.description = %{Automatically generate an SVG sprite from a folder of SVG icons.}
|
14
|
+
spec.homepage = 'https://github.com/jgarber623/svgeez'
|
15
|
+
spec.license = 'MIT'
|
16
|
+
|
17
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
18
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
19
|
+
spec.require_paths = ['lib']
|
20
|
+
|
21
|
+
spec.add_runtime_dependency 'listen', '~> 3.0'
|
22
|
+
spec.add_runtime_dependency 'mercenary', '~> 0.3'
|
23
|
+
|
24
|
+
spec.add_development_dependency 'bundler', '~> 1.10'
|
25
|
+
spec.add_development_dependency 'rake', '~> 10.0'
|
26
|
+
spec.add_development_dependency 'rspec'
|
27
|
+
end
|
metadata
ADDED
@@ -0,0 +1,133 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: svgeez
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Jason Garber
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-11-04 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: listen
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '3.0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '3.0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: mercenary
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0.3'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0.3'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: bundler
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '1.10'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '1.10'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rake
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '10.0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '10.0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rspec
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
description: Automatically generate an SVG sprite from a folder of SVG icons.
|
84
|
+
email:
|
85
|
+
- jason@sixtwothree.org
|
86
|
+
executables:
|
87
|
+
- svgeez
|
88
|
+
extensions: []
|
89
|
+
extra_rdoc_files: []
|
90
|
+
files:
|
91
|
+
- ".editorconfig"
|
92
|
+
- ".gitignore"
|
93
|
+
- ".rspec"
|
94
|
+
- ".ruby-version"
|
95
|
+
- ".travis.yml"
|
96
|
+
- CODE_OF_CONDUCT.md
|
97
|
+
- Gemfile
|
98
|
+
- LICENSE
|
99
|
+
- README.md
|
100
|
+
- Rakefile
|
101
|
+
- bin/svgeez
|
102
|
+
- lib/svgeez.rb
|
103
|
+
- lib/svgeez/command.rb
|
104
|
+
- lib/svgeez/commands/build.rb
|
105
|
+
- lib/svgeez/commands/watch.rb
|
106
|
+
- lib/svgeez/sprite_builder.rb
|
107
|
+
- lib/svgeez/version.rb
|
108
|
+
- svgeez.gemspec
|
109
|
+
homepage: https://github.com/jgarber623/svgeez
|
110
|
+
licenses:
|
111
|
+
- MIT
|
112
|
+
metadata: {}
|
113
|
+
post_install_message:
|
114
|
+
rdoc_options: []
|
115
|
+
require_paths:
|
116
|
+
- lib
|
117
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
118
|
+
requirements:
|
119
|
+
- - ">="
|
120
|
+
- !ruby/object:Gem::Version
|
121
|
+
version: '0'
|
122
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
123
|
+
requirements:
|
124
|
+
- - ">="
|
125
|
+
- !ruby/object:Gem::Version
|
126
|
+
version: '0'
|
127
|
+
requirements: []
|
128
|
+
rubyforge_project:
|
129
|
+
rubygems_version: 2.4.5.1
|
130
|
+
signing_key:
|
131
|
+
specification_version: 4
|
132
|
+
summary: Automatically generate an SVG sprite from a folder of SVG icons.
|
133
|
+
test_files: []
|