svgeez 0.2.7 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.editorconfig +4 -0
- data/.rspec +2 -1
- data/CODE_OF_CONDUCT.md +53 -29
- data/CONTRIBUTING.md +5 -3
- data/README.md +8 -4
- data/bin/svgeez +1 -1
- data/lib/svgeez/command.rb +11 -13
- data/lib/svgeez/commands/watch.rb +20 -19
- data/lib/svgeez/sprite_builder.rb +39 -29
- data/lib/svgeez/version.rb +1 -1
- data/lib/svgeez.rb +3 -7
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b7a16a5496376f424cb08140cb1cb571ce05712b
|
4
|
+
data.tar.gz: faab6c83f1ef364d46aa80d35cf42b22803ec9f6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 066d0cb89dab9fe20161352cd11973f87622fd0c6f02b4f9037d1a8ac335792209ebb27b643855e76221910eb5ca4834f8a0a208aa78bf0ab7098657597d3459
|
7
|
+
data.tar.gz: 2364c7f693d12fab3e9f2849cd0ddc9172fa6f4c74ce29479932fd51d8a90d1753cbbadad90f66d10854d574193851bb2165b4d023eeae5496b47d7114697500
|
data/.editorconfig
CHANGED
data/.rspec
CHANGED
data/CODE_OF_CONDUCT.md
CHANGED
@@ -1,24 +1,41 @@
|
|
1
|
-
# Contributor Code of Conduct
|
1
|
+
# Contributor Covenant Code of Conduct
|
2
2
|
|
3
|
-
|
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.
|
3
|
+
## Our Pledge
|
7
4
|
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
5
|
+
In the interest of fostering an open and welcoming environment, we as
|
6
|
+
contributors and maintainers pledge to making participation in our project and
|
7
|
+
our community a harassment-free experience for everyone, regardless of age, body
|
8
|
+
size, disability, ethnicity, gender identity and expression, level of experience,
|
9
|
+
nationality, personal appearance, race, religion, or sexual identity and
|
10
|
+
orientation.
|
11
|
+
|
12
|
+
## Our Standards
|
13
|
+
|
14
|
+
Examples of behavior that contributes to creating a positive environment
|
15
|
+
include:
|
16
|
+
|
17
|
+
* Using welcoming and inclusive language
|
18
|
+
* Being respectful of differing viewpoints and experiences
|
19
|
+
* Gracefully accepting constructive criticism
|
20
|
+
* Focusing on what is best for the community
|
21
|
+
* Showing empathy towards other community members
|
12
22
|
|
13
23
|
Examples of unacceptable behavior by participants include:
|
14
24
|
|
15
|
-
* The use of sexualized language or imagery
|
16
|
-
|
17
|
-
* Trolling
|
25
|
+
* The use of sexualized language or imagery and unwelcome sexual attention or
|
26
|
+
advances
|
27
|
+
* Trolling, insulting/derogatory comments, and personal or political attacks
|
18
28
|
* Public or private harassment
|
19
|
-
* Publishing
|
20
|
-
|
21
|
-
* Other
|
29
|
+
* Publishing others' private information, such as a physical or electronic
|
30
|
+
address, without explicit permission
|
31
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
32
|
+
professional setting
|
33
|
+
|
34
|
+
## Our Responsibilities
|
35
|
+
|
36
|
+
Project maintainers are responsible for clarifying the standards of acceptable
|
37
|
+
behavior and are expected to take appropriate and fair corrective action in
|
38
|
+
response to any instances of unacceptable behavior.
|
22
39
|
|
23
40
|
Project maintainers have the right and responsibility to remove, edit, or
|
24
41
|
reject comments, commits, code, wiki edits, issues, and other contributions
|
@@ -26,25 +43,32 @@ that are not aligned to this Code of Conduct, or to ban temporarily or
|
|
26
43
|
permanently any contributor for other behaviors that they deem inappropriate,
|
27
44
|
threatening, offensive, or harmful.
|
28
45
|
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
46
|
+
## Scope
|
47
|
+
|
48
|
+
This Code of Conduct applies both within project spaces and in public spaces
|
49
|
+
when an individual is representing the project or its community. Examples of
|
50
|
+
representing a project or community include using an official project e-mail
|
51
|
+
address, posting via an official social media account, or acting as an appointed
|
52
|
+
representative at an online or offline event. Representation of a project may be
|
53
|
+
further defined and clarified by project maintainers.
|
33
54
|
|
34
|
-
|
35
|
-
when an individual is representing the project or its community.
|
55
|
+
## Enforcement
|
36
56
|
|
37
57
|
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
38
|
-
reported by contacting
|
58
|
+
reported by contacting the project team at [INSERT EMAIL ADDRESS]. All
|
39
59
|
complaints will be reviewed and investigated and will result in a response that
|
40
|
-
is deemed necessary and appropriate to the circumstances.
|
41
|
-
obligated to maintain confidentiality with regard to the reporter of an
|
42
|
-
|
60
|
+
is deemed necessary and appropriate to the circumstances. The project team is
|
61
|
+
obligated to maintain confidentiality with regard to the reporter of an incident.
|
62
|
+
Further details of specific enforcement policies may be posted separately.
|
63
|
+
|
64
|
+
Project maintainers who do not follow or enforce the Code of Conduct in good
|
65
|
+
faith may face temporary or permanent repercussions as determined by other
|
66
|
+
members of the project's leadership.
|
43
67
|
|
68
|
+
## Attribution
|
44
69
|
|
45
|
-
This Code of Conduct is adapted from the [Contributor Covenant][homepage],
|
46
|
-
|
47
|
-
[http://contributor-covenant.org/version/1/3/0/][version]
|
70
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
71
|
+
available at [http://contributor-covenant.org/version/1/4][version]
|
48
72
|
|
49
73
|
[homepage]: http://contributor-covenant.org
|
50
|
-
[version]: http://contributor-covenant.org/version/1/
|
74
|
+
[version]: http://contributor-covenant.org/version/1/4/
|
data/CONTRIBUTING.md
CHANGED
@@ -29,8 +29,8 @@ Contributing to svgeez is pretty straightforward:
|
|
29
29
|
1. Install development dependencies by running `bundle install` from the root of the project.
|
30
30
|
1. Create a feature branch for the issue or new feature you're looking to tackle: `git checkout -b your-descriptive-branch-name`.
|
31
31
|
1. _Write some code!_
|
32
|
-
1. Build (`rake build`) and install (`rake install`) your updated code.
|
33
|
-
1. If your changes would benefit from testing, add the necessary tests and verify everything passes by running `rake`.
|
32
|
+
1. Build (`bundle exec rake build`) and install (`bundle exec rake install`) your updated code.
|
33
|
+
1. If your changes would benefit from testing, add the necessary tests and verify everything passes by running `bundle exec rake`.
|
34
34
|
1. Commit your changes: `git commit -am 'Add some new feature or fix some issue'`.
|
35
35
|
1. Push the branch to your fork of svgeez: `git push origin your-descriptive-branch-name`.
|
36
36
|
1. Create a new Pull Request and I'll give it a look!
|
@@ -44,6 +44,8 @@ Code styles are like opinions: Everyone's got one and yours is better than mine.
|
|
44
44
|
- Prefer single quotes over double quotes unless interpolating.
|
45
45
|
- Follow the conventions you see in the existing source code as best as you can.
|
46
46
|
|
47
|
-
svgeez's formatting guidelines are defined in the `.editorconfig` file which uses the [EditorConfig](http://editorconfig.org/) syntax. There are [a number of great plugins for a variety of editors](http://editorconfig.org/#download) that utilize the settings in the `.editorconfig` file.
|
47
|
+
svgeez's formatting guidelines are defined in the `.editorconfig` file which uses the [EditorConfig](http://editorconfig.org/) syntax. There are [a number of great plugins for a variety of editors](http://editorconfig.org/#download) that utilize the settings in the `.editorconfig` file. EditorConfig takes the hassle out of syntax-specific formatting.
|
48
|
+
|
49
|
+
Additionally, [Rubocop](https://github.com/bbatsov/rubocop) can be used to help identify possible trouble areas in your code. Run `bundle exec rake rubocop` to generate Rubocop's static code analysis report.
|
48
50
|
|
49
51
|
Your bug fix or feature addition won't be rejected if it runs afoul of any (or all) of these guidelines, but following the guidelines will definitely make everyone's lives a little easier.
|
data/README.md
CHANGED
@@ -63,8 +63,8 @@ The above example will combine all SVG files in `~/Sites/sixtwothree.org/images/
|
|
63
63
|
|
64
64
|
|Option|Description|
|
65
65
|
|---|---|
|
66
|
-
|`-s`<br>`--source`|Path to the folder of source SVGs (defaults to
|
67
|
-
|`-d`<br>`--destination`|Path to the destination file or folder (defaults to `./
|
66
|
+
|`-s`<br>`--source`|Path to the folder of source SVGs (defaults to `./_svgeez`).|
|
67
|
+
|`-d`<br>`--destination`|Path to the destination file or folder (defaults to `./svgeez.svg`)|
|
68
68
|
|`--with-svgo`|Optimize source SVGs with [SVGO](https://github.com/svg/svgo/) before sprite generation (non-destructive)|
|
69
69
|
|
70
70
|
### The `watch` command
|
@@ -186,9 +186,13 @@ svgeez benefited greatly from the hard work done by the folks working on the fol
|
|
186
186
|
|
187
187
|
Additionally, Chris Coyier's [CSS Tricks](https://css-tricks.com/) posts linked above got me interested in SVG sprites.
|
188
188
|
|
189
|
-
Lastly, the sample icons in `spec/fixtures/icons` are from [
|
189
|
+
Lastly, the sample icons in `spec/fixtures/icons` are from [Brent Jackson](https://github.com/jxnblk)'s [Geomicons Open](https://github.com/jxnblk/geomicons-open) icon set.
|
190
190
|
|
191
|
-
svgeez is written and maintained by [
|
191
|
+
svgeez is written and maintained by [Jason Garber](https://github.com/jgarber623).
|
192
|
+
|
193
|
+
### Additional Contributors
|
194
|
+
|
195
|
+
- [Brett Wilkins](https://github.com/bwilkins)
|
192
196
|
|
193
197
|
## License
|
194
198
|
|
data/bin/svgeez
CHANGED
data/lib/svgeez/command.rb
CHANGED
@@ -1,20 +1,18 @@
|
|
1
1
|
module Svgeez
|
2
2
|
class Command
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
end
|
3
|
+
def self.subclasses
|
4
|
+
@subclasses ||= []
|
5
|
+
end
|
7
6
|
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
7
|
+
def self.inherited(base)
|
8
|
+
subclasses << base
|
9
|
+
super(base)
|
10
|
+
end
|
12
11
|
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
end
|
12
|
+
def self.add_build_options(c)
|
13
|
+
c.option 'source', '-s', '--source [FOLDER]', 'Source folder (defaults to ./_svgeez)'
|
14
|
+
c.option 'destination', '-d', '--destination [OUTPUT]', 'Destination file or folder (defaults to ./svgeez.svg)'
|
15
|
+
c.option 'svgo', '--with-svgo', 'Optimize source SVGs with SVGO before sprite generation (non-destructive)'
|
18
16
|
end
|
19
17
|
end
|
20
18
|
end
|
@@ -1,32 +1,33 @@
|
|
1
1
|
module Svgeez
|
2
2
|
module Commands
|
3
3
|
class Watch < Command
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
c.syntax 'watch [options]'
|
4
|
+
def self.init_with_program(p)
|
5
|
+
p.command(:watch) do |c|
|
6
|
+
c.description 'Watches a folder of SVG icons for changes'
|
7
|
+
c.syntax 'watch [options]'
|
9
8
|
|
10
|
-
|
9
|
+
add_build_options(c)
|
11
10
|
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
end
|
11
|
+
c.action do |_, options|
|
12
|
+
Svgeez::Commands::Build.process(options)
|
13
|
+
Svgeez::Commands::Watch.process(options)
|
16
14
|
end
|
17
15
|
end
|
16
|
+
end
|
18
17
|
|
19
|
-
|
20
|
-
|
18
|
+
def self.process(options)
|
19
|
+
sprite_builder = Svgeez::SpriteBuilder.new(options)
|
21
20
|
|
22
|
-
|
23
|
-
|
24
|
-
end
|
25
|
-
|
26
|
-
listener.start
|
27
|
-
sleep
|
28
|
-
rescue Interrupt
|
21
|
+
listener = Listen.to(sprite_builder.source, only: /\.svg\z/) do
|
22
|
+
sprite_builder.build
|
29
23
|
end
|
24
|
+
|
25
|
+
Svgeez.logger.info "Watching `#{sprite_builder.source}` for changes... Press ctrl-c to stop."
|
26
|
+
|
27
|
+
listener.start
|
28
|
+
sleep
|
29
|
+
rescue Interrupt
|
30
|
+
Svgeez.logger.info 'Quitting svgeez...'
|
30
31
|
end
|
31
32
|
end
|
32
33
|
end
|
@@ -1,23 +1,23 @@
|
|
1
1
|
module Svgeez
|
2
2
|
class SpriteBuilder
|
3
|
-
def initialize(options)
|
4
|
-
@
|
5
|
-
@destination = File.expand_path(options.fetch('destination', './_svgeez/svgeez.svg'))
|
6
|
-
@svgo = options['svgo']
|
3
|
+
def initialize(options = {})
|
4
|
+
@options = options
|
7
5
|
end
|
8
6
|
|
9
7
|
def build
|
10
8
|
if source_is_destination?
|
11
|
-
Svgeez.logger.error
|
12
|
-
elsif source_file_paths.
|
13
|
-
Svgeez.logger.
|
9
|
+
Svgeez.logger.error "Setting `source` and `destination` to the same path isn't allowed!"
|
10
|
+
elsif source_file_paths.empty?
|
11
|
+
Svgeez.logger.warn "No SVGs were found in `#{source}`."
|
12
|
+
else
|
13
|
+
Svgeez.logger.info "Generating sprite at `#{destination_file_path}` from #{source_file_paths.length} SVG#{'s' if source_file_paths.length > 1}..."
|
14
14
|
|
15
15
|
# Make destination folder
|
16
16
|
FileUtils.mkdir_p(destination_folder_path)
|
17
17
|
|
18
18
|
# Notify if SVGO requested but not found
|
19
|
-
if
|
20
|
-
Svgeez.logger.warn
|
19
|
+
if svgo_use? && !svgo_installed?
|
20
|
+
Svgeez.logger.warn 'Unable to find `svgo` in your PATH. Continuing with standard sprite generation...'
|
21
21
|
end
|
22
22
|
|
23
23
|
# Write the file
|
@@ -25,39 +25,45 @@ module Svgeez
|
|
25
25
|
f.write build_destination_file_contents
|
26
26
|
end
|
27
27
|
|
28
|
-
Svgeez.logger.info
|
29
|
-
else
|
30
|
-
Svgeez.logger.warn %(No SVGs were found in `#{@source}`.)
|
28
|
+
Svgeez.logger.info "Successfully generated sprite at `#{destination_file_path}`."
|
31
29
|
end
|
32
30
|
end
|
33
31
|
|
34
|
-
|
32
|
+
def destination
|
33
|
+
@destination ||= File.expand_path(@options.fetch('destination', './svgeez.svg'))
|
34
|
+
end
|
35
35
|
|
36
|
-
def
|
37
|
-
|
36
|
+
def source
|
37
|
+
@source ||= File.expand_path(@options.fetch('source', './_svgeez'))
|
38
|
+
end
|
38
39
|
|
39
|
-
|
40
|
-
IO.read(file_path).match(%r{^<svg.*?(?<viewbox>viewBox=".*?").*?>(?<content>.*?)</svg>}m) do |matches|
|
41
|
-
destination_file_contents << %(<symbol id="#{destination_file_id}-#{File.basename(file_path, '.svg').gsub(/['"\s]/, '-')}" #{matches[:viewbox]}>#{matches[:content]}</symbol>)
|
42
|
-
end
|
43
|
-
end
|
40
|
+
private
|
44
41
|
|
45
|
-
|
42
|
+
def build_destination_file_contents
|
43
|
+
destination_file_contents = "<svg>#{collect_source_files_contents.join}</svg>"
|
46
44
|
|
47
|
-
if
|
45
|
+
if svgo_use? && svgo_installed?
|
48
46
|
destination_file_contents = `cat <<EOF | svgo --disable=cleanupIDs -i - -o -\n#{destination_file_contents}\nEOF`
|
49
47
|
end
|
50
48
|
|
51
49
|
destination_file_contents.insert(4, %( id="#{destination_file_id}" style="display: none;" version="1.1"))
|
52
50
|
end
|
53
51
|
|
52
|
+
def collect_source_files_contents
|
53
|
+
source_file_paths.collect do |file_path|
|
54
|
+
IO.read(file_path).match(%r{^<svg.*?(?<viewbox>viewBox=".*?").*?>(?<content>.*?)</svg>}m) do |matches|
|
55
|
+
%(<symbol id="#{destination_file_id}-#{File.basename(file_path, '.svg').gsub(/['"\s]/, '-')}" #{matches[:viewbox]}>#{matches[:content]}</symbol>)
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
54
60
|
def destination_file_id
|
55
61
|
@destination_file_id ||= File.basename(destination_file_name, '.svg').tr(' ', '-')
|
56
62
|
end
|
57
63
|
|
58
64
|
def destination_file_name
|
59
|
-
if
|
60
|
-
File.split(
|
65
|
+
if destination.end_with?('.svg')
|
66
|
+
File.split(destination)[1]
|
61
67
|
else
|
62
68
|
'svgeez.svg'
|
63
69
|
end
|
@@ -68,19 +74,23 @@ module Svgeez
|
|
68
74
|
end
|
69
75
|
|
70
76
|
def destination_folder_path
|
71
|
-
if
|
72
|
-
File.split(
|
77
|
+
if destination.end_with?('.svg')
|
78
|
+
File.split(destination)[0]
|
73
79
|
else
|
74
|
-
|
80
|
+
destination
|
75
81
|
end
|
76
82
|
end
|
77
83
|
|
78
84
|
def source_file_paths
|
79
|
-
@source_file_paths ||= Dir.glob(File.join(
|
85
|
+
@source_file_paths ||= Dir.glob(File.join(source, '*.svg'))
|
80
86
|
end
|
81
87
|
|
82
88
|
def source_is_destination?
|
83
|
-
|
89
|
+
/\A#{source}/ =~ destination_folder_path
|
90
|
+
end
|
91
|
+
|
92
|
+
def svgo_use?
|
93
|
+
@svgo_use ||= @options['svgo']
|
84
94
|
end
|
85
95
|
|
86
96
|
def svgo_installed?
|
data/lib/svgeez/version.rb
CHANGED
data/lib/svgeez.rb
CHANGED
@@ -10,13 +10,9 @@ require 'svgeez/commands/watch'
|
|
10
10
|
require 'svgeez/sprite_builder'
|
11
11
|
|
12
12
|
module Svgeez
|
13
|
-
|
14
|
-
|
15
|
-
@logger ||= Logger.new(STDOUT)
|
16
|
-
end
|
13
|
+
def self.logger
|
14
|
+
@logger ||= Logger.new(STDOUT)
|
17
15
|
end
|
18
16
|
|
19
|
-
logger.formatter = proc
|
20
|
-
"#{msg}\n"
|
21
|
-
end
|
17
|
+
logger.formatter = proc { |_, _, _, msg| "#{msg}\n" }
|
22
18
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: svgeez
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jason Garber
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-08-
|
11
|
+
date: 2016-08-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|