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.
@@ -1,3 +1,5 @@
1
- module SvgSprite
2
- VERSION = "0.2.3"
1
+ # frozen_string_literal: true
2
+
3
+ class SvgSprite
4
+ VERSION = "1.0.0"
3
5
  end
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`.split("\x0").reject {|f| f.match(%r{^(test|spec|features)/}) }
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", "~> 1.11"
24
- spec.add_development_dependency "rake", "~> 10.0"
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.2.3
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: 2017-10-15 00:00:00.000000000 Z
11
+ date: 2020-03-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: svg_optimizer
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: nokogiri
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: '1.11'
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: '1.11'
68
+ version: '0'
69
69
  - !ruby/object:Gem::Dependency
70
- name: rake
70
+ name: minitest
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - "~>"
73
+ - - ">="
74
74
  - !ruby/object:Gem::Version
75
- version: '10.0'
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: '10.0'
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: '5.0'
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: '5.0'
96
+ version: '0'
97
97
  - !ruby/object:Gem::Dependency
98
- name: minitest-utils
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: pry-meta
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/README.md
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/source/a/blue-square.svg
145
- - examples/source/a/orange-square.svg
146
- - examples/source/b/green-square.svg
147
- - examples/source/b/yellow-square.svg
148
- - examples/source/scss.scss
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
- rubyforge_project:
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>
@@ -1,13 +0,0 @@
1
- @import "./icons";
2
-
3
- .sass-after {
4
- @include sprite-after("blue-square");
5
- }
6
-
7
- .sass-before {
8
- @include sprite-before("orange-square");
9
- }
10
-
11
- .sass-inner {
12
- @extend %sprite-green-square;
13
- }
@@ -1,17 +0,0 @@
1
- module SvgSprite
2
- class Source
3
- def initialize(directory)
4
- @directory = directory
5
- end
6
-
7
- def each(&block)
8
- to_a.each(&block)
9
- end
10
-
11
- def to_a
12
- Dir["#{@directory}/**/*.svg"].map do |file|
13
- SVG.new(file)
14
- end
15
- end
16
- end
17
- end
@@ -1,13 +0,0 @@
1
- module SvgSprite
2
- class Sprite
3
- def initialize(source, template, options)
4
- @source = source
5
- @template = template
6
- @options = options
7
- end
8
-
9
- def render
10
- @template.call(@source, @options)
11
- end
12
- end
13
- end
@@ -1,6 +0,0 @@
1
- module SvgSprite
2
- TEMPLATES = {
3
- "scss" => Template::SCSS.new,
4
- "css" => Template::CSS.new
5
- }
6
- end
@@ -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,13 +0,0 @@
1
- module SvgSprite
2
- module Template
3
- class CSS
4
- def template
5
- @template ||= File.read("#{__dir__}/css.erb")
6
- end
7
-
8
- def call(source, options)
9
- ERB.new(template, nil, "-").result binding
10
- end
11
- end
12
- end
13
- 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