svg_sprite 1.0.0 → 1.0.1
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/.github/CODEOWNERS +4 -0
- data/.github/FUNDING.yml +4 -0
- data/.github/ISSUE_TEMPLATE/bug_report.md +41 -0
- data/.github/ISSUE_TEMPLATE/feature_request.md +23 -0
- data/.github/PULL_REQUEST_TEMPLATE.md +38 -0
- data/.github/dependabot.yml +15 -0
- data/.github/workflows/ruby-tests.yml +54 -0
- data/.gitignore +1 -0
- data/.rubocop.yml +2 -14
- data/CHANGELOG.md +18 -0
- data/CODE_OF_CONDUCT.md +55 -30
- data/CONTRIBUTING.md +79 -0
- data/{LICENSE.txt → LICENSE.md} +0 -0
- data/README.md +64 -17
- data/Rakefile +4 -1
- data/lib/svg_sprite/cli.rb +3 -2
- data/lib/svg_sprite/svg.rb +4 -3
- data/lib/svg_sprite/version.rb +1 -1
- data/lib/svg_sprite.rb +35 -22
- data/svg_sprite.gemspec +4 -1
- metadata +35 -12
- data/.travis.yml +0 -4
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: dad974718ab6a4417495499e8aa788e041663a5f11819611e651a2c05bd378da
|
|
4
|
+
data.tar.gz: e77c32dce5a61f03ddc881f9a3e01895ee79fa7447a3ad2dd770cb39be468a6f
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 37b27b2ab2af3ec6a728eee52e636e446eae3a38b1672e853bb72d70c631a6f52bccdf10c94a70a85f0bc6bb15a266a8c0818bcc240c2b6a56037d9443684c71
|
|
7
|
+
data.tar.gz: 44b8b4bc240067b9e5ee979ecd27f320c83bfbf9a3539e67c2ecee6d3593a6560bed125968118295a6f7cbd7d37762e302af180fe990d0fe7775ae686e65d0b7
|
data/.github/CODEOWNERS
ADDED
data/.github/FUNDING.yml
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: "🐛 Bug Report"
|
|
3
|
+
about: Report a reproducible bug or regression.
|
|
4
|
+
title: 'Bug: '
|
|
5
|
+
labels: 'Status: Unconfirmed'
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
<!--
|
|
10
|
+
- Please provide a clear and concise description of what the bug is.
|
|
11
|
+
- If possible, add an example reproducing your issue.
|
|
12
|
+
- Please test using the latest version of svg_sprite
|
|
13
|
+
to make sure your issue has not already been fixed.
|
|
14
|
+
-->
|
|
15
|
+
|
|
16
|
+
## Description
|
|
17
|
+
|
|
18
|
+
[Add bug description here]
|
|
19
|
+
|
|
20
|
+
## How to reproduce
|
|
21
|
+
|
|
22
|
+
[Add steps on how to reproduce this issue]
|
|
23
|
+
|
|
24
|
+
## What do you expect
|
|
25
|
+
|
|
26
|
+
[Describe what do you expect to happen]
|
|
27
|
+
|
|
28
|
+
## What happened instead
|
|
29
|
+
|
|
30
|
+
[Describe the actual results]
|
|
31
|
+
|
|
32
|
+
## Software:
|
|
33
|
+
|
|
34
|
+
- Gem version: [Add gem version here]
|
|
35
|
+
- Ruby version: [Add version here]
|
|
36
|
+
|
|
37
|
+
## Full backtrace
|
|
38
|
+
|
|
39
|
+
```text
|
|
40
|
+
[Paste full backtrace here]
|
|
41
|
+
```
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: "💡 Feature request"
|
|
3
|
+
about: Have an idea that may be useful? Make a suggestion!
|
|
4
|
+
title: 'Feature Request: '
|
|
5
|
+
labels: 'Feature request'
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## Description
|
|
10
|
+
|
|
11
|
+
_A clear and concise description of what the problem is._
|
|
12
|
+
|
|
13
|
+
## Describe the solution
|
|
14
|
+
|
|
15
|
+
_A clear and concise description of what you want to happen._
|
|
16
|
+
|
|
17
|
+
## Alternatives you considered
|
|
18
|
+
|
|
19
|
+
_A clear and concise description of any alternative solutions or features you've considered._
|
|
20
|
+
|
|
21
|
+
## Additional context
|
|
22
|
+
|
|
23
|
+
_Add any other context, screenshots, links, etc about the feature request here._
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
If you're making a doc PR or something tiny where the below is irrelevant,
|
|
3
|
+
delete this template and use a short description, but in your description aim to
|
|
4
|
+
include both what the change is, and why it is being made, with enough context
|
|
5
|
+
for anyone to understand.
|
|
6
|
+
-->
|
|
7
|
+
|
|
8
|
+
<details>
|
|
9
|
+
<summary>PR Checklist</summary>
|
|
10
|
+
|
|
11
|
+
### PR Structure
|
|
12
|
+
|
|
13
|
+
- [ ] This PR has reasonably narrow scope (if not, break it down into smaller
|
|
14
|
+
PRs).
|
|
15
|
+
- [ ] This PR avoids mixing refactoring changes with feature changes (split into
|
|
16
|
+
two PRs otherwise).
|
|
17
|
+
- [ ] This PR's title starts is concise and descriptive.
|
|
18
|
+
|
|
19
|
+
### Thoroughness
|
|
20
|
+
|
|
21
|
+
- [ ] This PR adds tests for the most critical parts of the new functionality or
|
|
22
|
+
fixes.
|
|
23
|
+
- [ ] I've updated any docs, `.md` files, etc… affected by this change.
|
|
24
|
+
|
|
25
|
+
</details>
|
|
26
|
+
|
|
27
|
+
### What
|
|
28
|
+
|
|
29
|
+
[TODO: Short statement about what is changing.]
|
|
30
|
+
|
|
31
|
+
### Why
|
|
32
|
+
|
|
33
|
+
[TODO: Why this change is being made. Include any context required to understand
|
|
34
|
+
the why.]
|
|
35
|
+
|
|
36
|
+
### Known limitations
|
|
37
|
+
|
|
38
|
+
[TODO or N/A]
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
---
|
|
2
|
+
# Documentation:
|
|
3
|
+
# https://help.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
|
|
4
|
+
|
|
5
|
+
version: 2
|
|
6
|
+
updates:
|
|
7
|
+
- package-ecosystem: "github-actions"
|
|
8
|
+
directory: "/"
|
|
9
|
+
schedule:
|
|
10
|
+
interval: "daily"
|
|
11
|
+
|
|
12
|
+
- package-ecosystem: bundler
|
|
13
|
+
directory: "/"
|
|
14
|
+
schedule:
|
|
15
|
+
interval: "daily"
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: ruby-tests
|
|
3
|
+
|
|
4
|
+
on:
|
|
5
|
+
pull_request_target:
|
|
6
|
+
push:
|
|
7
|
+
branches:
|
|
8
|
+
- main
|
|
9
|
+
workflow_dispatch:
|
|
10
|
+
inputs: {}
|
|
11
|
+
|
|
12
|
+
jobs:
|
|
13
|
+
build:
|
|
14
|
+
name: Tests with Ruby ${{ matrix.ruby }} and ${{ matrix.gemfile }}
|
|
15
|
+
runs-on: "ubuntu-latest"
|
|
16
|
+
if: |
|
|
17
|
+
github.actor == 'dependabot[bot]' && github.event_name == 'pull_request_target' ||
|
|
18
|
+
github.actor != 'dependabot[bot]'
|
|
19
|
+
strategy:
|
|
20
|
+
fail-fast: false
|
|
21
|
+
matrix:
|
|
22
|
+
ruby: ["2.7", "3.0", "3.1"]
|
|
23
|
+
gemfile:
|
|
24
|
+
- Gemfile
|
|
25
|
+
|
|
26
|
+
steps:
|
|
27
|
+
- uses: actions/checkout@v2.4.0
|
|
28
|
+
|
|
29
|
+
- uses: actions/cache@v2
|
|
30
|
+
with:
|
|
31
|
+
path: vendor/bundle
|
|
32
|
+
key: >
|
|
33
|
+
${{ runner.os }}-${{ matrix.ruby }}-gems-${{ hashFiles(matrix.gemfile) }}
|
|
34
|
+
|
|
35
|
+
- name: Set up Ruby
|
|
36
|
+
uses: ruby/setup-ruby@v1
|
|
37
|
+
with:
|
|
38
|
+
ruby-version: ${{ matrix.ruby }}
|
|
39
|
+
|
|
40
|
+
- name: Install gem dependencies
|
|
41
|
+
env:
|
|
42
|
+
BUNDLE_GEMFILE: ${{ matrix.gemfile }}
|
|
43
|
+
run: |
|
|
44
|
+
gem install bundler
|
|
45
|
+
bundle config path vendor/bundle
|
|
46
|
+
bundle update --jobs 4 --retry 3
|
|
47
|
+
|
|
48
|
+
- name: Run Tests
|
|
49
|
+
env:
|
|
50
|
+
PGHOST: localhost
|
|
51
|
+
PGUSER: postgres
|
|
52
|
+
BUNDLE_GEMFILE: ${{ matrix.gemfile }}
|
|
53
|
+
run: |
|
|
54
|
+
bundle exec rake
|
data/.gitignore
CHANGED
data/.rubocop.yml
CHANGED
|
@@ -4,19 +4,7 @@ inherit_gem:
|
|
|
4
4
|
|
|
5
5
|
AllCops:
|
|
6
6
|
TargetRubyVersion: 2.7
|
|
7
|
+
NewCops: enable
|
|
7
8
|
|
|
8
|
-
|
|
9
|
-
Exclude:
|
|
10
|
-
- lib/svg_sprite/cli.rb
|
|
11
|
-
|
|
12
|
-
Metrics/ParameterLists:
|
|
13
|
-
Enabled: false
|
|
14
|
-
|
|
15
|
-
Metrics/AbcSize:
|
|
16
|
-
Enabled: false
|
|
17
|
-
|
|
18
|
-
Metrics/MethodLength:
|
|
19
|
-
Enabled: false
|
|
20
|
-
|
|
21
|
-
Metrics/ClassLength:
|
|
9
|
+
Metrics:
|
|
22
10
|
Enabled: false
|
data/CHANGELOG.md
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
<!--
|
|
4
|
+
Prefix your message with one of the following:
|
|
5
|
+
|
|
6
|
+
- [Added] for new features.
|
|
7
|
+
- [Changed] for changes in existing functionality.
|
|
8
|
+
- [Deprecated] for soon-to-be removed features.
|
|
9
|
+
- [Removed] for now removed features.
|
|
10
|
+
- [Fixed] for any bug fixes.
|
|
11
|
+
- [Security] in case of vulnerabilities.
|
|
12
|
+
-->
|
|
13
|
+
|
|
14
|
+
## v1.0.1
|
|
15
|
+
|
|
16
|
+
- [Changed] SVG sprite now includes the sprite name as the id. It means you'll
|
|
17
|
+
to use a link href like `#icons--trash` (previously the sprite name wasn't
|
|
18
|
+
included).
|
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,24 +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 me@fnando.com. 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.
|
|
67
|
+
|
|
68
|
+
## Attribution
|
|
43
69
|
|
|
44
|
-
This Code of Conduct is adapted from the [Contributor Covenant][homepage],
|
|
45
|
-
|
|
46
|
-
[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 [https://contributor-covenant.org/version/1/4][version]
|
|
47
72
|
|
|
48
|
-
[homepage]:
|
|
49
|
-
[version]:
|
|
73
|
+
[homepage]: https://contributor-covenant.org
|
|
74
|
+
[version]: https://contributor-covenant.org/version/1/4/
|
data/CONTRIBUTING.md
ADDED
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
# Contributing to svg_sprite
|
|
2
|
+
|
|
3
|
+
👍🎉 First off, thanks for taking the time to contribute! 🎉👍
|
|
4
|
+
|
|
5
|
+
The following is a set of guidelines for contributing to this project. These are
|
|
6
|
+
mostly guidelines, not rules. Use your best judgment, and feel free to propose
|
|
7
|
+
changes to this document in a pull request.
|
|
8
|
+
|
|
9
|
+
## Code of Conduct
|
|
10
|
+
|
|
11
|
+
Everyone interacting in this project's codebases, issue trackers, chat rooms and
|
|
12
|
+
mailing lists is expected to follow the [code of conduct](https://github.com/fnando/svg_sprite/blob/main/CODE_OF_CONDUCT.md).
|
|
13
|
+
|
|
14
|
+
## Reporting bugs
|
|
15
|
+
|
|
16
|
+
This section guides you through submitting a bug report. Following these
|
|
17
|
+
guidelines helps maintainers and the community understand your report, reproduce
|
|
18
|
+
the behavior, and find related reports.
|
|
19
|
+
|
|
20
|
+
- Before creating bug reports, please check the open issues; somebody may
|
|
21
|
+
already have submitted something similar, and you may not need to create a new
|
|
22
|
+
one.
|
|
23
|
+
- When you are creating a bug report, please include as many details as
|
|
24
|
+
possible, with an example reproducing the issue.
|
|
25
|
+
|
|
26
|
+
## Contributing with code
|
|
27
|
+
|
|
28
|
+
Before making any radicals changes, please make sure you discuss your intention
|
|
29
|
+
by [opening an issue on Github](https://github.com/fnando/svg_sprite/issues).
|
|
30
|
+
|
|
31
|
+
When you're ready to make your pull request, follow checklist below to make sure
|
|
32
|
+
your contribution is according to how this project works.
|
|
33
|
+
|
|
34
|
+
1. [Fork](https://help.github.com/forking/) svg_sprite
|
|
35
|
+
2. Create a topic branch - `git checkout -b my_branch`
|
|
36
|
+
3. Make your changes using [descriptive commit messages](#commit-messages)
|
|
37
|
+
4. Update CHANGELOG.md describing your changes by adding an entry to the
|
|
38
|
+
"Unreleased" section. If this section is not available, create one right
|
|
39
|
+
before the last version.
|
|
40
|
+
5. Push to your branch - `git push origin my_branch`
|
|
41
|
+
6. [Create a pull request](https://help.github.com/articles/creating-a-pull-request)
|
|
42
|
+
7. That's it!
|
|
43
|
+
|
|
44
|
+
## Styleguides
|
|
45
|
+
|
|
46
|
+
### Commit messages
|
|
47
|
+
|
|
48
|
+
- Use the present tense ("Add feature" not "Added feature")
|
|
49
|
+
- Use the imperative mood ("Move cursor to..." not "Moves cursor to...")
|
|
50
|
+
- Limit the first line to 72 characters or less
|
|
51
|
+
- Reference issues and pull requests liberally after the first line
|
|
52
|
+
|
|
53
|
+
### Changelog
|
|
54
|
+
|
|
55
|
+
- Add a message describing your changes to the "Unreleased" section. The
|
|
56
|
+
changelog message should follow the same style as the commit message.
|
|
57
|
+
- Prefix your message with one of the following:
|
|
58
|
+
- `[Added]` for new features.
|
|
59
|
+
- `[Changed]` for changes in existing functionality.
|
|
60
|
+
- `[Deprecated]` for soon-to-be removed features.
|
|
61
|
+
- `[Removed]` for now removed features.
|
|
62
|
+
- `[Fixed]` for any bug fixes.
|
|
63
|
+
- `[Security]` in case of vulnerabilities.
|
|
64
|
+
|
|
65
|
+
### Ruby code
|
|
66
|
+
|
|
67
|
+
- This project uses [Rubocop](https://rubocop.org) to enforce code style. Before
|
|
68
|
+
submitting your changes, make sure your tests are passing and code conforms to
|
|
69
|
+
the expected style by running `rake`.
|
|
70
|
+
- Do not change the library version. This will be done by the maintainer
|
|
71
|
+
whenever a new version is about to be released.
|
|
72
|
+
|
|
73
|
+
### JavaScript code
|
|
74
|
+
|
|
75
|
+
- This project uses [ESLint](https://eslint.org) to enforce code style. Before
|
|
76
|
+
submitting your changes, make sure your tests are passing and code conforms to
|
|
77
|
+
the expected style by running `yarn test:ci`.
|
|
78
|
+
- Do not change the library version. This will be done by the maintainer
|
|
79
|
+
whenever a new version is about to be released.
|
data/{LICENSE.txt → LICENSE.md}
RENAMED
|
File without changes
|
data/README.md
CHANGED
|
@@ -1,11 +1,24 @@
|
|
|
1
|
-
#
|
|
1
|
+
# svg_sprite
|
|
2
|
+
|
|
3
|
+
[](https://github.com/fnando/svg_sprite)
|
|
4
|
+
[](https://codeclimate.com/github/fnando/svg_sprite)
|
|
5
|
+
[](https://rubygems.org/gems/svg_sprite)
|
|
6
|
+
[](https://rubygems.org/gems/svg_sprite)
|
|
2
7
|
|
|
3
8
|
Create SVG sprites by embedding images into CSS using data URIs. The SVGs are
|
|
4
9
|
optimized using [svg_optimizer](https://github.com/fnando/svg_optimizer).
|
|
5
10
|
|
|
6
11
|
## Installation
|
|
7
12
|
|
|
8
|
-
|
|
13
|
+
```bash
|
|
14
|
+
gem install svg_sprite
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
Or add the following line to your project's Gemfile:
|
|
18
|
+
|
|
19
|
+
```ruby
|
|
20
|
+
gem "svg_sprite"
|
|
21
|
+
```
|
|
9
22
|
|
|
10
23
|
## Usage
|
|
11
24
|
|
|
@@ -50,7 +63,7 @@ together with the file name. This is an example:
|
|
|
50
63
|
This file was generated by https://rubygems.org/gems/svg_sprite with the
|
|
51
64
|
following command:
|
|
52
65
|
|
|
53
|
-
svg_sprite generate --input images --sprite-path sprite/icons.svg --css-path sprite/icons.css --optimize
|
|
66
|
+
svg_sprite generate --input images --sprite-path sprite/icons.svg --css-path sprite/icons.css --optimize --name icon
|
|
54
67
|
*/
|
|
55
68
|
|
|
56
69
|
.icon--doc-fill {
|
|
@@ -81,12 +94,14 @@ By default, SVGs will keep their stroke and fill colors. You can remove or use
|
|
|
81
94
|
$ svg_sprite generate --input images \
|
|
82
95
|
--sprite-path sprite/icons.svg \
|
|
83
96
|
--css-path sprite/icons.css \
|
|
97
|
+
--name icon \
|
|
84
98
|
--stroke current-color \
|
|
85
99
|
--fill current-color
|
|
86
100
|
|
|
87
101
|
$ svg_sprite generate --input images \
|
|
88
102
|
--sprite-path sprite/icons.svg \
|
|
89
103
|
--css-path sprite/icons.css \
|
|
104
|
+
--name icon \
|
|
90
105
|
--stroke remove \
|
|
91
106
|
--fill remove
|
|
92
107
|
```
|
|
@@ -95,6 +110,37 @@ Finally, all SVGs will be optimized using
|
|
|
95
110
|
[svg_optimizer](https://github.com/fnando/svg_optimizer). To disable it, use
|
|
96
111
|
`--no-optimize`.
|
|
97
112
|
|
|
113
|
+
### Using sprites in practice
|
|
114
|
+
|
|
115
|
+
You need to embed the final SVG sprite on your HTML page. With Rails, you can
|
|
116
|
+
use a helper like this:
|
|
117
|
+
|
|
118
|
+
```ruby
|
|
119
|
+
module ApplicationHelper
|
|
120
|
+
def svg_tag(file)
|
|
121
|
+
File.open(Rails.root.join("app/assets/images", "#{file}.svg")).html_safe
|
|
122
|
+
end
|
|
123
|
+
end
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
Then, on your layout file (e.g. `application.html.erb`), you can render it as
|
|
127
|
+
`<%= svg_tag(:icons) %>`.
|
|
128
|
+
|
|
129
|
+
Now, you need to reference those SVG links by adding `<use href="#id">`. You can
|
|
130
|
+
create a helper method like this to make things easy.
|
|
131
|
+
|
|
132
|
+
```ruby
|
|
133
|
+
module ApplicationHelper
|
|
134
|
+
def icon(name)
|
|
135
|
+
content_tag :svg, class: "icon icon--#{name}" do
|
|
136
|
+
content_tag :use, nil, href: "##{name}", role: :presentation
|
|
137
|
+
end
|
|
138
|
+
end
|
|
139
|
+
end
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
You can render icons by using `<%= icon(:trash) %>`.
|
|
143
|
+
|
|
98
144
|
### Programming API
|
|
99
145
|
|
|
100
146
|
To export both the CSS and SVG files:
|
|
@@ -113,26 +159,27 @@ SvgSprite.call(
|
|
|
113
159
|
)
|
|
114
160
|
```
|
|
115
161
|
|
|
116
|
-
##
|
|
162
|
+
## Maintainer
|
|
163
|
+
|
|
164
|
+
- [Nando Vieira](https://github.com/fnando)
|
|
117
165
|
|
|
118
|
-
|
|
119
|
-
`rake test` to run the tests. You can also run `bin/console` for an interactive
|
|
120
|
-
prompt that will allow you to experiment.
|
|
166
|
+
## Contributors
|
|
121
167
|
|
|
122
|
-
|
|
123
|
-
release a new version, update the version number in `version.rb`, and then run
|
|
124
|
-
`bundle exec rake release`, which will create a git tag for the version, push
|
|
125
|
-
git commits and tags, and push the `.gem` file to
|
|
126
|
-
[rubygems.org](https://rubygems.org).
|
|
168
|
+
- https://github.com/fnando/svg_sprite/contributors
|
|
127
169
|
|
|
128
170
|
## Contributing
|
|
129
171
|
|
|
130
|
-
|
|
131
|
-
https://github.com/fnando/svg_sprite.
|
|
132
|
-
welcoming space for collaboration, and contributors are expected to adhere to
|
|
133
|
-
the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
|
172
|
+
For more details about how to contribute, please read
|
|
173
|
+
https://github.com/fnando/svg_sprite/blob/main/CONTRIBUTING.md.
|
|
134
174
|
|
|
135
175
|
## License
|
|
136
176
|
|
|
137
177
|
The gem is available as open source under the terms of the
|
|
138
|
-
[MIT License](
|
|
178
|
+
[MIT License](https://opensource.org/licenses/MIT). A copy of the license can be
|
|
179
|
+
found at https://github.com/fnando/svg_sprite/blob/main/LICENSE.md.
|
|
180
|
+
|
|
181
|
+
## Code of Conduct
|
|
182
|
+
|
|
183
|
+
Everyone interacting in the svg_sprite project's codebases, issue trackers, chat
|
|
184
|
+
rooms and mailing lists is expected to follow the
|
|
185
|
+
[code of conduct](https://github.com/fnando/svg_sprite/blob/main/CODE_OF_CONDUCT.md).
|
data/Rakefile
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
require "bundler/gem_tasks"
|
|
4
4
|
require "rake/testtask"
|
|
5
|
+
require "rubocop/rake_task"
|
|
5
6
|
|
|
6
7
|
Rake::TestTask.new(:test) do |t|
|
|
7
8
|
t.libs << "test"
|
|
@@ -9,4 +10,6 @@ Rake::TestTask.new(:test) do |t|
|
|
|
9
10
|
t.test_files = FileList["test/**/*_test.rb"]
|
|
10
11
|
end
|
|
11
12
|
|
|
12
|
-
|
|
13
|
+
RuboCop::RakeTask.new
|
|
14
|
+
|
|
15
|
+
task default: %i[test rubocop]
|
data/lib/svg_sprite/cli.rb
CHANGED
|
@@ -31,8 +31,9 @@ class SvgSprite
|
|
|
31
31
|
desc: "The SVG output file path."
|
|
32
32
|
option :name,
|
|
33
33
|
aliases: %w[-n],
|
|
34
|
-
default:
|
|
35
|
-
desc: "The sprite name. This will be used as the variable for
|
|
34
|
+
default: DEFAULT_SPRITE_NAME,
|
|
35
|
+
desc: "The sprite name. This will be used as the variable for " \
|
|
36
|
+
"dynamic files."
|
|
36
37
|
option :optimize,
|
|
37
38
|
aliases: %w[-o],
|
|
38
39
|
default: true,
|
data/lib/svg_sprite/svg.rb
CHANGED
|
@@ -2,9 +2,10 @@
|
|
|
2
2
|
|
|
3
3
|
class SvgSprite
|
|
4
4
|
class SVG
|
|
5
|
-
attr_reader :filepath, :optimize, :stroke, :fill
|
|
5
|
+
attr_reader :filepath, :name, :optimize, :stroke, :fill
|
|
6
6
|
|
|
7
|
-
def initialize(filepath, optimize:, stroke:, fill:)
|
|
7
|
+
def initialize(filepath, name:, optimize:, stroke:, fill:)
|
|
8
|
+
@name = name
|
|
8
9
|
@filepath = filepath
|
|
9
10
|
@optimize = optimize
|
|
10
11
|
@stroke = stroke
|
|
@@ -30,7 +31,7 @@ class SvgSprite
|
|
|
30
31
|
end
|
|
31
32
|
|
|
32
33
|
def id
|
|
33
|
-
File.basename(filepath, ".*")
|
|
34
|
+
@id ||= [name, File.basename(filepath, ".*")].join("--")
|
|
34
35
|
end
|
|
35
36
|
|
|
36
37
|
private def xml
|
data/lib/svg_sprite/version.rb
CHANGED
data/lib/svg_sprite.rb
CHANGED
|
@@ -1,24 +1,31 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
require "pathname"
|
|
9
|
-
|
|
10
|
-
require "svg_sprite/version"
|
|
11
|
-
require "svg_sprite/cli"
|
|
12
|
-
require "svg_sprite/svg"
|
|
3
|
+
require "svg_optimizer"
|
|
4
|
+
require "thor"
|
|
5
|
+
require "fileutils"
|
|
6
|
+
require "shellwords"
|
|
7
|
+
require "pathname"
|
|
13
8
|
|
|
9
|
+
class SvgSprite
|
|
14
10
|
NOKOGIRI_SAVE_OPTIONS = {
|
|
15
11
|
save_with: Nokogiri::XML::Node::SaveOptions::DEFAULT_XML |
|
|
16
12
|
Nokogiri::XML::Node::SaveOptions::NO_DECLARATION
|
|
17
13
|
}.freeze
|
|
18
14
|
|
|
15
|
+
DEFAULT_SPRITE_NAME = "sprite"
|
|
16
|
+
|
|
17
|
+
require "svg_sprite/version"
|
|
18
|
+
require "svg_sprite/cli"
|
|
19
|
+
require "svg_sprite/svg"
|
|
20
|
+
|
|
19
21
|
def self.call(
|
|
20
|
-
|
|
21
|
-
|
|
22
|
+
input:,
|
|
23
|
+
sprite_path:,
|
|
24
|
+
css_path:,
|
|
25
|
+
name: DEFAULT_SPRITE_NAME,
|
|
26
|
+
optimize: true,
|
|
27
|
+
stroke: nil,
|
|
28
|
+
fill: nil
|
|
22
29
|
)
|
|
23
30
|
new(
|
|
24
31
|
name: name,
|
|
@@ -28,7 +35,7 @@ class SvgSprite
|
|
|
28
35
|
optimize: optimize,
|
|
29
36
|
stroke: stroke,
|
|
30
37
|
fill: fill
|
|
31
|
-
).call
|
|
38
|
+
).tap(&:call)
|
|
32
39
|
end
|
|
33
40
|
|
|
34
41
|
attr_reader :name, :sprite_path, :input, :css_path, :optimize, :stroke, :fill,
|
|
@@ -50,6 +57,7 @@ class SvgSprite
|
|
|
50
57
|
def call
|
|
51
58
|
save_file sprite_path, svg_sprite
|
|
52
59
|
save_file css_path, manifest(css_definitions.chomp)
|
|
60
|
+
self
|
|
53
61
|
end
|
|
54
62
|
|
|
55
63
|
private def manifest(css)
|
|
@@ -79,7 +87,8 @@ class SvgSprite
|
|
|
79
87
|
Pathname.new(css_path).relative_path_from(cwd).to_s
|
|
80
88
|
]
|
|
81
89
|
|
|
82
|
-
cmd.push("--
|
|
90
|
+
cmd.push("--name", name) if name != DEFAULT_SPRITE_NAME
|
|
91
|
+
cmd.push("--no-optimize") unless optimize
|
|
83
92
|
cmd.push("--stroke", stroke) if stroke
|
|
84
93
|
cmd.push("--fill", fill) if fill
|
|
85
94
|
|
|
@@ -87,16 +96,20 @@ class SvgSprite
|
|
|
87
96
|
end
|
|
88
97
|
|
|
89
98
|
private def svgs
|
|
90
|
-
@svgs ||= input_files
|
|
91
|
-
|
|
92
|
-
|
|
99
|
+
@svgs ||= input_files
|
|
100
|
+
.map {|file| build_svg(file) }
|
|
101
|
+
.sort_by(&:id)
|
|
102
|
+
end
|
|
103
|
+
|
|
104
|
+
private def build_svg(file)
|
|
105
|
+
SVG.new(file, name: name, optimize: optimize, stroke: stroke, fill: fill)
|
|
93
106
|
end
|
|
94
107
|
|
|
95
108
|
private def css_definitions
|
|
96
|
-
svgs.each_with_object(StringIO.new) do |
|
|
97
|
-
io << ".#{
|
|
98
|
-
io << " width: #{
|
|
99
|
-
io << " height: #{
|
|
109
|
+
svgs.each_with_object(StringIO.new) do |svg, io|
|
|
110
|
+
io << ".#{svg.id} {\n"
|
|
111
|
+
io << " width: #{svg.width};\n"
|
|
112
|
+
io << " height: #{svg.height};\n"
|
|
100
113
|
io << "}\n\n"
|
|
101
114
|
end.tap(&:rewind).read.chomp
|
|
102
115
|
end
|
|
@@ -123,7 +136,7 @@ class SvgSprite
|
|
|
123
136
|
xmlns: "http://www.w3.org/2000/svg",
|
|
124
137
|
style: "display: none"
|
|
125
138
|
) do |svg|
|
|
126
|
-
svg.defs { }
|
|
139
|
+
svg.defs { } # rubocop:disable Lint/EmptyBlock
|
|
127
140
|
end
|
|
128
141
|
end
|
|
129
142
|
end
|
data/svg_sprite.gemspec
CHANGED
|
@@ -7,8 +7,10 @@ Gem::Specification.new do |spec|
|
|
|
7
7
|
spec.version = SvgSprite::VERSION
|
|
8
8
|
spec.authors = ["Nando Vieira"]
|
|
9
9
|
spec.email = ["fnando.vieira@gmail.com"]
|
|
10
|
+
spec.required_ruby_version = ">= 2.7"
|
|
11
|
+
spec.metadata = {"rubygems_mfa_required" => "true"}
|
|
10
12
|
|
|
11
|
-
spec.summary = "Create SVG sprites using
|
|
13
|
+
spec.summary = "Create SVG sprites using SVG links."
|
|
12
14
|
spec.description = spec.summary
|
|
13
15
|
spec.homepage = "https://github.com/fnando/svg_sprite"
|
|
14
16
|
spec.license = "MIT"
|
|
@@ -25,6 +27,7 @@ Gem::Specification.new do |spec|
|
|
|
25
27
|
spec.add_dependency "thor"
|
|
26
28
|
|
|
27
29
|
spec.add_development_dependency "bundler"
|
|
30
|
+
spec.add_development_dependency "css_parser"
|
|
28
31
|
spec.add_development_dependency "minitest"
|
|
29
32
|
spec.add_development_dependency "minitest-utils"
|
|
30
33
|
spec.add_development_dependency "pry-meta"
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: svg_sprite
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.0.
|
|
4
|
+
version: 1.0.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Nando Vieira
|
|
8
|
-
autorequire:
|
|
8
|
+
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2022-01-05 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: nokogiri
|
|
@@ -66,6 +66,20 @@ dependencies:
|
|
|
66
66
|
- - ">="
|
|
67
67
|
- !ruby/object:Gem::Version
|
|
68
68
|
version: '0'
|
|
69
|
+
- !ruby/object:Gem::Dependency
|
|
70
|
+
name: css_parser
|
|
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'
|
|
69
83
|
- !ruby/object:Gem::Dependency
|
|
70
84
|
name: minitest
|
|
71
85
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -150,7 +164,7 @@ dependencies:
|
|
|
150
164
|
- - ">="
|
|
151
165
|
- !ruby/object:Gem::Version
|
|
152
166
|
version: '0'
|
|
153
|
-
description: Create SVG sprites using
|
|
167
|
+
description: Create SVG sprites using SVG links.
|
|
154
168
|
email:
|
|
155
169
|
- fnando.vieira@gmail.com
|
|
156
170
|
executables:
|
|
@@ -158,12 +172,20 @@ executables:
|
|
|
158
172
|
extensions: []
|
|
159
173
|
extra_rdoc_files: []
|
|
160
174
|
files:
|
|
175
|
+
- ".github/CODEOWNERS"
|
|
176
|
+
- ".github/FUNDING.yml"
|
|
177
|
+
- ".github/ISSUE_TEMPLATE/bug_report.md"
|
|
178
|
+
- ".github/ISSUE_TEMPLATE/feature_request.md"
|
|
179
|
+
- ".github/PULL_REQUEST_TEMPLATE.md"
|
|
180
|
+
- ".github/dependabot.yml"
|
|
181
|
+
- ".github/workflows/ruby-tests.yml"
|
|
161
182
|
- ".gitignore"
|
|
162
183
|
- ".rubocop.yml"
|
|
163
|
-
-
|
|
184
|
+
- CHANGELOG.md
|
|
164
185
|
- CODE_OF_CONDUCT.md
|
|
186
|
+
- CONTRIBUTING.md
|
|
165
187
|
- Gemfile
|
|
166
|
-
- LICENSE.
|
|
188
|
+
- LICENSE.md
|
|
167
189
|
- README.md
|
|
168
190
|
- Rakefile
|
|
169
191
|
- bin/console
|
|
@@ -188,8 +210,9 @@ files:
|
|
|
188
210
|
homepage: https://github.com/fnando/svg_sprite
|
|
189
211
|
licenses:
|
|
190
212
|
- MIT
|
|
191
|
-
metadata:
|
|
192
|
-
|
|
213
|
+
metadata:
|
|
214
|
+
rubygems_mfa_required: 'true'
|
|
215
|
+
post_install_message:
|
|
193
216
|
rdoc_options: []
|
|
194
217
|
require_paths:
|
|
195
218
|
- lib
|
|
@@ -197,15 +220,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
197
220
|
requirements:
|
|
198
221
|
- - ">="
|
|
199
222
|
- !ruby/object:Gem::Version
|
|
200
|
-
version: '
|
|
223
|
+
version: '2.7'
|
|
201
224
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
202
225
|
requirements:
|
|
203
226
|
- - ">="
|
|
204
227
|
- !ruby/object:Gem::Version
|
|
205
228
|
version: '0'
|
|
206
229
|
requirements: []
|
|
207
|
-
rubygems_version: 3.
|
|
208
|
-
signing_key:
|
|
230
|
+
rubygems_version: 3.3.3
|
|
231
|
+
signing_key:
|
|
209
232
|
specification_version: 4
|
|
210
|
-
summary: Create SVG sprites using
|
|
233
|
+
summary: Create SVG sprites using SVG links.
|
|
211
234
|
test_files: []
|
data/.travis.yml
DELETED