svg_sprite 0.2.3 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.rubocop.yml +22 -0
- data/Gemfile +3 -1
- data/README.md +91 -90
- data/Rakefile +3 -1
- data/bin/console +1 -0
- data/examples/images/doc-fill.svg +3 -0
- data/examples/images/doc.svg +3 -0
- data/examples/images/trash-fill.svg +3 -0
- data/examples/images/trash.svg +3 -0
- data/examples/index.html +94 -15
- data/examples/sprite/current-color.css +26 -0
- data/examples/sprite/current-color.svg +16 -0
- data/examples/sprite/original.css +26 -0
- data/examples/sprite/original.svg +16 -0
- data/examples/sprite/remove.css +26 -0
- data/examples/sprite/remove.svg +16 -0
- data/exe/svg_sprite +2 -0
- data/lib/svg_sprite.rb +122 -22
- data/lib/svg_sprite/cli.rb +44 -28
- data/lib/svg_sprite/svg.rb +40 -52
- data/lib/svg_sprite/version.rb +4 -2
- data/svg_sprite.gemspec +11 -5
- metadata +60 -35
- data/examples/README.md +0 -19
- data/examples/source/a/blue-square.svg +0 -10
- data/examples/source/a/orange-square.svg +0 -10
- data/examples/source/b/green-square.svg +0 -10
- data/examples/source/b/yellow-square.svg +0 -10
- data/examples/source/scss.scss +0 -13
- data/lib/svg_sprite/source.rb +0 -17
- data/lib/svg_sprite/sprite.rb +0 -13
- data/lib/svg_sprite/template.rb +0 -6
- data/lib/svg_sprite/template/css.erb +0 -12
- data/lib/svg_sprite/template/css.rb +0 -13
- data/lib/svg_sprite/template/scss.erb +0 -33
- data/lib/svg_sprite/template/scss.rb +0 -19
data/lib/svg_sprite/version.rb
CHANGED
data/svg_sprite.gemspec
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require "./lib/svg_sprite/version"
|
2
4
|
|
3
5
|
Gem::Specification.new do |spec|
|
@@ -11,18 +13,22 @@ Gem::Specification.new do |spec|
|
|
11
13
|
spec.homepage = "https://github.com/fnando/svg_sprite"
|
12
14
|
spec.license = "MIT"
|
13
15
|
|
14
|
-
spec.files = `git ls-files -z
|
16
|
+
spec.files = `git ls-files -z`
|
17
|
+
.split("\x0")
|
18
|
+
.reject {|f| f.match(%r{^(test|spec|features)/}) }
|
15
19
|
spec.bindir = "exe"
|
16
20
|
spec.executables = spec.files.grep(%r{^exe/}) {|f| File.basename(f) }
|
17
21
|
spec.require_paths = ["lib"]
|
18
22
|
|
19
|
-
spec.add_dependency "svg_optimizer"
|
20
23
|
spec.add_dependency "nokogiri"
|
24
|
+
spec.add_dependency "svg_optimizer"
|
21
25
|
spec.add_dependency "thor"
|
22
26
|
|
23
|
-
spec.add_development_dependency "bundler"
|
24
|
-
spec.add_development_dependency "
|
25
|
-
spec.add_development_dependency "minitest", "~> 5.0"
|
27
|
+
spec.add_development_dependency "bundler"
|
28
|
+
spec.add_development_dependency "minitest"
|
26
29
|
spec.add_development_dependency "minitest-utils"
|
27
30
|
spec.add_development_dependency "pry-meta"
|
31
|
+
spec.add_development_dependency "rake"
|
32
|
+
spec.add_development_dependency "rubocop"
|
33
|
+
spec.add_development_dependency "rubocop-fnando"
|
28
34
|
end
|
metadata
CHANGED
@@ -1,17 +1,17 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: svg_sprite
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nando Vieira
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-03-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
name:
|
14
|
+
name: nokogiri
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
@@ -25,7 +25,7 @@ dependencies:
|
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
|
-
name:
|
28
|
+
name: svg_optimizer
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - ">="
|
@@ -56,46 +56,46 @@ dependencies:
|
|
56
56
|
name: bundler
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- - "
|
59
|
+
- - ">="
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: '
|
61
|
+
version: '0'
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
|
-
- - "
|
66
|
+
- - ">="
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version: '
|
68
|
+
version: '0'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
|
-
name:
|
70
|
+
name: minitest
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
|
-
- - "
|
73
|
+
- - ">="
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version: '
|
75
|
+
version: '0'
|
76
76
|
type: :development
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
|
-
- - "
|
80
|
+
- - ">="
|
81
81
|
- !ruby/object:Gem::Version
|
82
|
-
version: '
|
82
|
+
version: '0'
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
|
-
name: minitest
|
84
|
+
name: minitest-utils
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
86
86
|
requirements:
|
87
|
-
- - "
|
87
|
+
- - ">="
|
88
88
|
- !ruby/object:Gem::Version
|
89
|
-
version: '
|
89
|
+
version: '0'
|
90
90
|
type: :development
|
91
91
|
prerelease: false
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
|
-
- - "
|
94
|
+
- - ">="
|
95
95
|
- !ruby/object:Gem::Version
|
96
|
-
version: '
|
96
|
+
version: '0'
|
97
97
|
- !ruby/object:Gem::Dependency
|
98
|
-
name:
|
98
|
+
name: pry-meta
|
99
99
|
requirement: !ruby/object:Gem::Requirement
|
100
100
|
requirements:
|
101
101
|
- - ">="
|
@@ -109,7 +109,35 @@ dependencies:
|
|
109
109
|
- !ruby/object:Gem::Version
|
110
110
|
version: '0'
|
111
111
|
- !ruby/object:Gem::Dependency
|
112
|
-
name:
|
112
|
+
name: rake
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - ">="
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - ">="
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '0'
|
125
|
+
- !ruby/object:Gem::Dependency
|
126
|
+
name: rubocop
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - ">="
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: '0'
|
132
|
+
type: :development
|
133
|
+
prerelease: false
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - ">="
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: '0'
|
139
|
+
- !ruby/object:Gem::Dependency
|
140
|
+
name: rubocop-fnando
|
113
141
|
requirement: !ruby/object:Gem::Requirement
|
114
142
|
requirements:
|
115
143
|
- - ">="
|
@@ -131,6 +159,7 @@ extensions: []
|
|
131
159
|
extra_rdoc_files: []
|
132
160
|
files:
|
133
161
|
- ".gitignore"
|
162
|
+
- ".rubocop.yml"
|
134
163
|
- ".travis.yml"
|
135
164
|
- CODE_OF_CONDUCT.md
|
136
165
|
- Gemfile
|
@@ -139,24 +168,21 @@ files:
|
|
139
168
|
- Rakefile
|
140
169
|
- bin/console
|
141
170
|
- bin/setup
|
142
|
-
- examples/
|
171
|
+
- examples/images/doc-fill.svg
|
172
|
+
- examples/images/doc.svg
|
173
|
+
- examples/images/trash-fill.svg
|
174
|
+
- examples/images/trash.svg
|
143
175
|
- examples/index.html
|
144
|
-
- examples/
|
145
|
-
- examples/
|
146
|
-
- examples/
|
147
|
-
- examples/
|
148
|
-
- examples/
|
176
|
+
- examples/sprite/current-color.css
|
177
|
+
- examples/sprite/current-color.svg
|
178
|
+
- examples/sprite/original.css
|
179
|
+
- examples/sprite/original.svg
|
180
|
+
- examples/sprite/remove.css
|
181
|
+
- examples/sprite/remove.svg
|
149
182
|
- exe/svg_sprite
|
150
183
|
- lib/svg_sprite.rb
|
151
184
|
- lib/svg_sprite/cli.rb
|
152
|
-
- lib/svg_sprite/source.rb
|
153
|
-
- lib/svg_sprite/sprite.rb
|
154
185
|
- lib/svg_sprite/svg.rb
|
155
|
-
- lib/svg_sprite/template.rb
|
156
|
-
- lib/svg_sprite/template/css.erb
|
157
|
-
- lib/svg_sprite/template/css.rb
|
158
|
-
- lib/svg_sprite/template/scss.erb
|
159
|
-
- lib/svg_sprite/template/scss.rb
|
160
186
|
- lib/svg_sprite/version.rb
|
161
187
|
- svg_sprite.gemspec
|
162
188
|
homepage: https://github.com/fnando/svg_sprite
|
@@ -178,8 +204,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
178
204
|
- !ruby/object:Gem::Version
|
179
205
|
version: '0'
|
180
206
|
requirements: []
|
181
|
-
|
182
|
-
rubygems_version: 2.6.13
|
207
|
+
rubygems_version: 3.1.2
|
183
208
|
signing_key:
|
184
209
|
specification_version: 4
|
185
210
|
summary: Create SVG sprites using data URIs.
|
data/examples/README.md
DELETED
@@ -1,19 +0,0 @@
|
|
1
|
-
# Exporting Sass files
|
2
|
-
|
3
|
-
Run this command to export the sprite:
|
4
|
-
|
5
|
-
```
|
6
|
-
RUBYOPT="-I./lib" ./exe/svg_sprite generate -s examples/source -o examples/source/_icons.scss
|
7
|
-
```
|
8
|
-
|
9
|
-
Then run this command to export the styles:
|
10
|
-
|
11
|
-
````
|
12
|
-
scss examples/source/scss.scss examples/dist/scss.css
|
13
|
-
````
|
14
|
-
|
15
|
-
# Exporting vanilla CSS
|
16
|
-
|
17
|
-
```
|
18
|
-
RUBYOPT="-I./lib" ./exe/svg_sprite generate -s examples/source -o examples/dist/css.css
|
19
|
-
```
|
@@ -1,10 +0,0 @@
|
|
1
|
-
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
2
|
-
<svg width="25px" height="25px" viewBox="0 0 25 25" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:sketch="http://www.bohemiancoding.com/sketch/ns">
|
3
|
-
<!-- Generator: Sketch 3.4.4 (17248) - http://www.bohemiancoding.com/sketch -->
|
4
|
-
<title>Rectangle 1</title>
|
5
|
-
<desc>Created with Sketch.</desc>
|
6
|
-
<defs></defs>
|
7
|
-
<g id="Page-1" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd" sketch:type="MSPage">
|
8
|
-
<rect id="Rectangle-1" fill="#4990E2" sketch:type="MSShapeGroup" x="0" y="0" width="25" height="25"></rect>
|
9
|
-
</g>
|
10
|
-
</svg>
|
@@ -1,10 +0,0 @@
|
|
1
|
-
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
2
|
-
<svg width="25px" height="25px" viewBox="0 0 25 25" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:sketch="http://www.bohemiancoding.com/sketch/ns">
|
3
|
-
<!-- Generator: Sketch 3.4.4 (17248) - http://www.bohemiancoding.com/sketch -->
|
4
|
-
<title>Rectangle 1</title>
|
5
|
-
<desc>Created with Sketch.</desc>
|
6
|
-
<defs></defs>
|
7
|
-
<g id="Page-1" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd" sketch:type="MSPage">
|
8
|
-
<rect id="Rectangle-1" fill="#F6A623" sketch:type="MSShapeGroup" x="0" y="0" width="25" height="25"></rect>
|
9
|
-
</g>
|
10
|
-
</svg>
|
@@ -1,10 +0,0 @@
|
|
1
|
-
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
2
|
-
<svg width="25px" height="25px" viewBox="0 0 25 25" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:sketch="http://www.bohemiancoding.com/sketch/ns">
|
3
|
-
<!-- Generator: Sketch 3.4.4 (17248) - http://www.bohemiancoding.com/sketch -->
|
4
|
-
<title>Rectangle 1</title>
|
5
|
-
<desc>Created with Sketch.</desc>
|
6
|
-
<defs></defs>
|
7
|
-
<g id="Page-1" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd" sketch:type="MSPage">
|
8
|
-
<rect id="Rectangle-1" fill="#7ED321" sketch:type="MSShapeGroup" x="0" y="0" width="25" height="25"></rect>
|
9
|
-
</g>
|
10
|
-
</svg>
|
@@ -1,10 +0,0 @@
|
|
1
|
-
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
2
|
-
<svg width="25px" height="25px" viewBox="0 0 25 25" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:sketch="http://www.bohemiancoding.com/sketch/ns">
|
3
|
-
<!-- Generator: Sketch 3.4.4 (17248) - http://www.bohemiancoding.com/sketch -->
|
4
|
-
<title>Rectangle 1</title>
|
5
|
-
<desc>Created with Sketch.</desc>
|
6
|
-
<defs></defs>
|
7
|
-
<g id="Page-1" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd" sketch:type="MSPage">
|
8
|
-
<rect id="Rectangle-1" fill="#F8E81C" sketch:type="MSShapeGroup" x="0" y="0" width="25" height="25"></rect>
|
9
|
-
</g>
|
10
|
-
</svg>
|
data/examples/source/scss.scss
DELETED
data/lib/svg_sprite/source.rb
DELETED
data/lib/svg_sprite/sprite.rb
DELETED
data/lib/svg_sprite/template.rb
DELETED
@@ -1,12 +0,0 @@
|
|
1
|
-
/* Generated by sprite_svg v<%= SvgSprite::VERSION %> at <%= Time.now %> */
|
2
|
-
<% for svg in source %>
|
3
|
-
.<%= options[:name] %>-<%= svg.name %>,
|
4
|
-
.<%= options[:name] %>-<%= svg.name %>-before:before,
|
5
|
-
.<%= options[:name] %>-<%= svg.name %>-after:after {
|
6
|
-
background-image: url(<%= svg.data_uri %>);
|
7
|
-
<%- if svg.has_dimensions? -%>
|
8
|
-
width: <%= svg.width %>;
|
9
|
-
height: <%= svg.height %>;
|
10
|
-
<%- end -%>
|
11
|
-
}
|
12
|
-
<% end %>
|
@@ -1,33 +0,0 @@
|
|
1
|
-
// Generated by sprite_svg v<%= SvgSprite::VERSION %> at <%= Time.now %>
|
2
|
-
$<%= options[:name] %>-names: (<%= names(source) %>);
|
3
|
-
$<%= options[:name] %>-urls: (
|
4
|
-
<%- for svg in source -%>
|
5
|
-
<%= svg.name %>: "<%= svg.data_uri %>",
|
6
|
-
<%- end -%>
|
7
|
-
);
|
8
|
-
|
9
|
-
@function <%= options[:name] %>-url($name) {
|
10
|
-
@return map-get($<%= options[:name] %>-urls, $name);
|
11
|
-
}
|
12
|
-
|
13
|
-
@mixin <%= options[:name] %>-before($name) {
|
14
|
-
&:before {
|
15
|
-
@extend %<%= options[:name] %>-#{$name};
|
16
|
-
}
|
17
|
-
}
|
18
|
-
|
19
|
-
@mixin <%= options[:name] %>-after($name) {
|
20
|
-
&:after {
|
21
|
-
@extend %<%= options[:name] %>-#{$name};
|
22
|
-
}
|
23
|
-
}
|
24
|
-
|
25
|
-
<% for svg in source %>
|
26
|
-
%<%= options[:name] %>-<%= svg.name %> {
|
27
|
-
background-image: url(<%= options[:name] %>-url("<%= svg.name %>"));
|
28
|
-
<%- if svg.has_dimensions? -%>
|
29
|
-
width: <%= svg.width %>;
|
30
|
-
height: <%= svg.height %>;
|
31
|
-
<%- end -%>
|
32
|
-
}
|
33
|
-
<%- end -%>
|
@@ -1,19 +0,0 @@
|
|
1
|
-
module SvgSprite
|
2
|
-
module Template
|
3
|
-
class SCSS
|
4
|
-
def template
|
5
|
-
@template ||= File.read("#{__dir__}/scss.erb")
|
6
|
-
end
|
7
|
-
|
8
|
-
def call(source, options)
|
9
|
-
ERB.new(template, nil, "-").result binding
|
10
|
-
end
|
11
|
-
|
12
|
-
private
|
13
|
-
|
14
|
-
def names(source)
|
15
|
-
source.to_a.map(&:name).join(", ")
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|