spritesh 1.0.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/bin/spritesh +6 -0
- data/bin/spritesh.sh +96 -0
- metadata +46 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 6fbc89068155820dac2b8313175be28ba109909b
|
4
|
+
data.tar.gz: b16862302099cfd7b993846538f821b59d414e47
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 64580beaf1fb74e741a135c478b0c2f1e5a019345315dfbe08a08ba7db9248e48225a7f2727a9fbfba1b403c1d2c39ec439212c9ba87ec1f7594c0735c9ccdab
|
7
|
+
data.tar.gz: af577cd88ca58d398f9668899b3290d597aafe0d9bf24b97f9c08b4d9fc550b9309ec9d34b09c4c851710400f5789777ef029b22eeaeba3d9cb3a6c44182ca5a
|
data/bin/spritesh
ADDED
data/bin/spritesh.sh
ADDED
@@ -0,0 +1,96 @@
|
|
1
|
+
#!/bin/bash
|
2
|
+
|
3
|
+
PROGNAME=${0##*/}
|
4
|
+
SRC_FOLDER=.
|
5
|
+
DEST_FILE=sprite.svg
|
6
|
+
ID_PREFIX=""
|
7
|
+
QUIET="0"
|
8
|
+
|
9
|
+
usage()
|
10
|
+
{
|
11
|
+
cat <<EO
|
12
|
+
Usage: $PROGNAME [options]
|
13
|
+
Script to build a SVG sprite from a folder of SVG files.
|
14
|
+
Options:
|
15
|
+
EO
|
16
|
+
cat <<EO | column -s\& -t
|
17
|
+
-h, --help & Shows this help
|
18
|
+
-q, --quiet & Disables informative output
|
19
|
+
-i, --input [dir] & Specifies input dir (current dir by default)
|
20
|
+
-o, --output [file] & Specifies output file ("./sprite.svg" by default)
|
21
|
+
-v, --viewbox [str] & Specifies viewBox attribute (parsed by default)
|
22
|
+
-p, --prefix [str] & Specifies prefix for id attribute (none by default)
|
23
|
+
EO
|
24
|
+
}
|
25
|
+
|
26
|
+
echo_verbose ()
|
27
|
+
{
|
28
|
+
if [ $QUIET == "0" ]; then
|
29
|
+
echo $1
|
30
|
+
fi
|
31
|
+
}
|
32
|
+
|
33
|
+
clean ()
|
34
|
+
{
|
35
|
+
rm -rf $DEST_FILE
|
36
|
+
}
|
37
|
+
|
38
|
+
main ()
|
39
|
+
{
|
40
|
+
for f in $SRC_FOLDER/*.svg; do
|
41
|
+
if [ -f $f ]; then
|
42
|
+
NAME=$(basename $f .svg)
|
43
|
+
VIEWBOX=${VIEWBOX_SIZE:-$(sed -n -E 's/.*viewBox="([^"]+)".*/\1/p' $f)}
|
44
|
+
|
45
|
+
echo_verbose "Processing \`$f\` (viewBox \`$VIEWBOX\`)…"
|
46
|
+
echo "<symbol id='$ID_PREFIX$NAME' viewBox='$VIEWBOX'>$(cat $f)</symbol>" >> $DEST_FILE
|
47
|
+
fi
|
48
|
+
done
|
49
|
+
|
50
|
+
if [ -f ${DEST_FILE} ]; then
|
51
|
+
awk 'BEGIN{print "<svg xmlns=\"http://www.w3.org/2000/svg\" style=\"display:none\">"}{print}END{print "</svg>"}' $DEST_FILE > .spritesh && mv .spritesh $DEST_FILE
|
52
|
+
fi
|
53
|
+
|
54
|
+
}
|
55
|
+
|
56
|
+
# Grabbing options
|
57
|
+
while [[ $# > 0 ]]; do
|
58
|
+
key="$1"
|
59
|
+
case $key in
|
60
|
+
-h|--help)
|
61
|
+
usage
|
62
|
+
exit 0
|
63
|
+
;;
|
64
|
+
-i|--input)
|
65
|
+
SRC_FOLDER="$2"
|
66
|
+
shift
|
67
|
+
;;
|
68
|
+
-o|--output)
|
69
|
+
DEST_FILE="$2"
|
70
|
+
shift
|
71
|
+
;;
|
72
|
+
-v|--viewbox)
|
73
|
+
VIEWBOX_SIZE="$2"
|
74
|
+
shift
|
75
|
+
;;
|
76
|
+
-p|--prefix)
|
77
|
+
ID_PREFIX="$2"
|
78
|
+
shift
|
79
|
+
;;
|
80
|
+
-q|--quiet)
|
81
|
+
QUIET="1"
|
82
|
+
;;
|
83
|
+
*)
|
84
|
+
;;
|
85
|
+
esac
|
86
|
+
shift
|
87
|
+
done
|
88
|
+
|
89
|
+
clean
|
90
|
+
main
|
91
|
+
|
92
|
+
if [ -f $DEST_FILE ]; then
|
93
|
+
echo_verbose "File \`$DEST_FILE\` successfully generated."
|
94
|
+
else
|
95
|
+
echo_verbose "Could not generated \`$DEST_FILE\`. Are there any SVG file in \`$SRC_FOLDER\` folder?"
|
96
|
+
fi
|
metadata
ADDED
@@ -0,0 +1,46 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: spritesh
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.6
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Cade Scroggins
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-02-17 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description: A shell script to build an SVG sprite from a folder of SVG files.
|
14
|
+
email: hello@cadejs.com
|
15
|
+
executables:
|
16
|
+
- spritesh
|
17
|
+
extensions: []
|
18
|
+
extra_rdoc_files: []
|
19
|
+
files:
|
20
|
+
- bin/spritesh
|
21
|
+
- bin/spritesh.sh
|
22
|
+
homepage: https://github.com/cadejscroggins/sprite.sh
|
23
|
+
licenses:
|
24
|
+
- MIT
|
25
|
+
metadata: {}
|
26
|
+
post_install_message:
|
27
|
+
rdoc_options: []
|
28
|
+
require_paths:
|
29
|
+
- lib
|
30
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
31
|
+
requirements:
|
32
|
+
- - ">="
|
33
|
+
- !ruby/object:Gem::Version
|
34
|
+
version: '0'
|
35
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
36
|
+
requirements:
|
37
|
+
- - ">="
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
version: '0'
|
40
|
+
requirements: []
|
41
|
+
rubyforge_project:
|
42
|
+
rubygems_version: 2.4.5.1
|
43
|
+
signing_key:
|
44
|
+
specification_version: 4
|
45
|
+
summary: Build an SVG sprite from a folder of SVG files.
|
46
|
+
test_files: []
|