svgeez 3.1.0 → 3.2.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8facbc1352cb5385bccddccaebc6fc1b8957d69bc65fd1834799660969245e3c
4
- data.tar.gz: 865945a5ec2c47c8f82929052ea026752bf10adc8a5bf3266a6d091fdfc9710c
3
+ metadata.gz: 9ec517999af227f154d38ca7c1a785fb061e292601e181213c83a108ffc1ac38
4
+ data.tar.gz: 389bedd716f094b97b1899afbf1c290a44393d7234ee44d328e5cfd512037cbc
5
5
  SHA512:
6
- metadata.gz: 7d185bbe236c5fe4e2de87d9bbf30ad9522d5eaf790616cdc2891884d23ac353af92e8df99bebe0d79f192fa3ab8444c1cdc892cec8103ea9ab368bb14f1e581
7
- data.tar.gz: 59f69679b6e4b500b2fd2d9972aac40f67ca40009fe9f6a06707ebfdeb8229a02b362ebe99a0f1b3049e816202781d84a994d0c15494fd78d4d21d087ff3c992
6
+ metadata.gz: bb5f93fde2f014659bf678b4da09866864e84a57d251a04464c03df739055ef09e9a0b5c24f35094a8b147f5c4ad4dbf47a6e6482d27af7e60ab2d38a6f39a6a
7
+ data.tar.gz: ca874151e7beb400e0819f3ea9ca74ca3489556ee29523d9eada5f3fefabd7eb8ab6374b6cc84b9ac67dd582db633a55e384fbaaa68ae1a657c484e0063d7d82
@@ -2,9 +2,8 @@ require:
2
2
  - rubocop-performance
3
3
  - rubocop-rspec
4
4
 
5
- Layout/HashAlignment:
6
- Exclude:
7
- - svgeez.gemspec
5
+ AllCops:
6
+ NewCops: disable
8
7
 
9
8
  Layout/LineLength:
10
9
  Enabled: false
@@ -12,7 +11,6 @@ Layout/LineLength:
12
11
  Metrics/BlockLength:
13
12
  Exclude:
14
13
  - spec/**/*
15
- - svgeez.gemspec
16
14
 
17
15
  Naming/RescuedExceptionsVariableName:
18
16
  PreferredName: exception
@@ -1 +1 @@
1
- 2.4.9
1
+ 2.4.10
data/.simplecov CHANGED
@@ -2,9 +2,11 @@ require 'simplecov-console'
2
2
 
3
3
  formatters = [SimpleCov::Formatter::HTMLFormatter]
4
4
 
5
+ # rubocop:disable Style/IfUnlessModifier
5
6
  if RSpec.configuration.files_to_run.length > 1
6
7
  formatters << SimpleCov::Formatter::Console
7
8
  end
9
+ # rubocop:enable Style/IfUnlessModifier
8
10
 
9
11
  SimpleCov.start do
10
12
  formatter SimpleCov::Formatter::MultiFormatter.new(formatters)
@@ -1,31 +1,36 @@
1
1
  # Changelog
2
2
 
3
+ ## 3.2.0 / 2020-08-11
4
+
5
+ - Add `--prefix` option (#79 and #80)
6
+ - Update development Ruby version to 2.4.10 (8d517c1)
7
+
3
8
  ## 3.1.0 / 2020-01-20
4
9
 
5
- - Expand supported Ruby versions to include 2.7 ([bcc23b5](https://github.com/jgarber623/svgeez/commit/bcc23b5)).
10
+ - Expand supported Ruby versions to include 2.7 (bcc23b5)
6
11
 
7
12
  ## 3.0.0 / 2019-08-02
8
13
 
9
14
  ### Breaking Changes
10
15
 
11
- - Bump required minimum SVGO version to 1.3.0 ([afa24c6](https://github.com/jgarber623/svgeez/commit/afa24c6)).
16
+ - Bump required minimum SVGO version to 1.3.0 (afa24c6)
12
17
 
13
18
  ### Additional Enhancements
14
19
 
15
- - Refactor command classes ([02f420c](https://github.com/jgarber623/svgeez/commit/02f420c)).
16
- - Refactor specs ([995f950](https://github.com/jgarber623/svgeez/commit/)).
17
- - Update development dependencies.
20
+ - Refactor command classes (02f420c)
21
+ - Refactor specs ()
22
+ - Update development dependencies
18
23
 
19
24
  ## 2.0.1 / 2019-01-03
20
25
 
21
- - Expand supported Ruby versions to include 2.6 ([0facfd0](https://github.com/jgarber623/svgeez/commit/0facfd0)).
26
+ - Expand supported Ruby versions to include 2.6 (0facfd0)
22
27
 
23
28
  ## 2.0.0 / 2018-12-04
24
29
 
25
- - Refactor classes to use `attr_reader`s ([c62780f](https://github.com/jgarber623/svgeez/commit/c62780f))
26
- - Change required Ruby versions and liberalize dependency constraints ([35fcadb](https://github.com/jgarber623/svgeez/commit/35fcadb))
27
- - Change project Ruby version to 2.4.9 ([301d341](https://github.com/jgarber623/svgeez/commit/301d341))
28
- - Bump required SVGO version to 1.1.1 ([28741fc](https://github.com/jgarber623/svgeez/commit/28741fc))
30
+ - Refactor classes to use `attr_reader`s (c62780f)
31
+ - Change required Ruby versions and liberalize dependency constraints (35fcadb)
32
+ - Change project Ruby version to 2.4.9 (301d341)
33
+ - Bump required SVGO version to 1.1.1 (28741fc)
29
34
 
30
35
  ## Previous Releases
31
36
 
@@ -8,9 +8,9 @@ There are a couple ways you can help improve svgeez:
8
8
 
9
9
  ## Getting Started
10
10
 
11
- svgeez is developed using Ruby 2.4.9 and is additionally tested against Ruby 2.5, 2.6, and 2.7 using [Travis CI](https://travis-ci.org/jgarber623/svgeez).
11
+ svgeez is developed using Ruby 2.4.10 and is additionally tested against Ruby 2.5, 2.6, and 2.7 using [Travis CI](https://travis-ci.org/jgarber623/svgeez).
12
12
 
13
- Before making changes to svgeez, you'll want to install Ruby 2.4.9. It's recommended that you use a Ruby version managment tool like [rbenv](https://github.com/rbenv/rbenv), [chruby](https://github.com/postmodern/chruby), or [rvm](https://github.com/rvm/rvm). Once you've installed Ruby 2.4.9 using your method of choice, install the project's gems by running:
13
+ Before making changes to svgeez, you'll want to install Ruby 2.4.10. It's recommended that you use a Ruby version managment tool like [rbenv](https://github.com/rbenv/rbenv), [chruby](https://github.com/postmodern/chruby), or [rvm](https://github.com/rvm/rvm). Once you've installed Ruby 2.4.10 using your method of choice, install the project's gems by running:
14
14
 
15
15
  ```sh
16
16
  bundle install
data/Gemfile CHANGED
@@ -2,3 +2,13 @@ source 'https://rubygems.org'
2
2
 
3
3
  # Specify your gem's dependencies in svgeez.gemspec
4
4
  gemspec
5
+
6
+ gem 'pry-byebug', '~> 3.9'
7
+ gem 'rake', '~> 13.0'
8
+ gem 'reek', '~> 6.0'
9
+ gem 'rspec', '~> 3.9'
10
+ gem 'rubocop', '~> 0.89.0'
11
+ gem 'rubocop-performance', '~> 1.7'
12
+ gem 'rubocop-rspec', '~> 1.42'
13
+ gem 'simplecov', '~> 0.18.5'
14
+ gem 'simplecov-console', '~> 0.7.2'
data/README.md CHANGED
@@ -4,7 +4,7 @@
4
4
 
5
5
  [![Gem](https://img.shields.io/gem/v/svgeez.svg?style=for-the-badge)](https://rubygems.org/gems/svgeez)
6
6
  [![Downloads](https://img.shields.io/gem/dt/svgeez.svg?style=for-the-badge)](https://rubygems.org/gems/svgeez)
7
- [![Build](https://img.shields.io/travis/jgarber623/svgeez/master.svg?style=for-the-badge)](https://travis-ci.org/jgarber623/svgeez)
7
+ [![Build](https://img.shields.io/travis/jgarber623/svgeez/main.svg?style=for-the-badge)](https://travis-ci.org/jgarber623/svgeez)
8
8
  [![Dependencies](https://img.shields.io/depfu/jgarber623/svgeez.svg?style=for-the-badge)](https://depfu.com/github/jgarber623/svgeez)
9
9
  [![Maintainability](https://img.shields.io/codeclimate/maintainability/jgarber623/svgeez.svg?style=for-the-badge)](https://codeclimate.com/github/jgarber623/svgeez)
10
10
  [![Coverage](https://img.shields.io/codeclimate/c/jgarber623/svgeez.svg?style=for-the-badge)](https://codeclimate.com/github/jgarber623/svgeez/code)
@@ -21,7 +21,7 @@ _For more on why SVG sprites are the bee's knees as far as icon systems go, give
21
21
 
22
22
  ## Getting Started
23
23
 
24
- Before installing and using svgeez, you'll want to have Ruby 2.4 (or newer) installed on your computer. There are plenty of ways to go about this, but my preference is [rbenv](https://github.com/sstephenson/rbenv). svgeez is developed using Ruby 2.4.9 and is additionally tested against Ruby 2.5, 2.6, and 2.7 using [Travis CI](https://travis-ci.org/jgarber623/svgeez).
24
+ Before installing and using svgeez, you'll want to have Ruby 2.4 (or newer) installed on your computer. There are plenty of ways to go about this, but my preference is [rbenv](https://github.com/sstephenson/rbenv). svgeez is developed using Ruby 2.4.10 and is additionally tested against Ruby 2.5, 2.6, and 2.7 using [Travis CI](https://travis-ci.org/jgarber623/svgeez).
25
25
 
26
26
  ## Installation
27
27
 
@@ -67,6 +67,7 @@ The above example will combine all SVG files in `~/Sites/sixtwothree.org/images/
67
67
  |:----------------------|:------------------------------------------------------------------|
68
68
  | `-s`, `--source` | Path to folder of source SVGs (defaults to `./_svgeez`). |
69
69
  | `-d`, `--destination` | Path to destination file or folder (defaults to `./svgeez.svg`) |
70
+ | `-p`, `--prefix` | Optional prefix to append to generated `id` attribute values |
70
71
  | `--with-svgo` | Optimize SVG sprite file with [SVGO](https://github.com/svg/svgo) |
71
72
 
72
73
  ### The `watch` command
@@ -197,7 +198,7 @@ button svg {
197
198
 
198
199
  ## Improving svgeez
199
200
 
200
- You want to help make svgeez better? Hell yeah! I like your enthusiasm. For more on how you can help, check out [CONTRIBUTING.md](https://github.com/jgarber623/svgeez/blob/master/CONTRIBUTING.md).
201
+ You want to help make svgeez better? Hell yeah! I like your enthusiasm. For more on how you can help, check out [CONTRIBUTING.md](https://github.com/jgarber623/svgeez/blob/main/CONTRIBUTING.md).
201
202
 
202
203
  ### Donations
203
204
 
@@ -223,6 +224,7 @@ svgeez is written and maintained by [Jason Garber](https://sixtwothree.org).
223
224
 
224
225
  ### Additional Contributors
225
226
 
227
+ - [Abhinav Mishra](https://github.com/abhinavmsra)
226
228
  - [Brett Wilkins](https://github.com/bwilkins)
227
229
  - [danny](https://github.com/f96q)
228
230
  - [Denis Hovart](https://github.com/dhovart)
@@ -4,12 +4,13 @@ module Svgeez
4
4
  SOURCE_DOES_NOT_EXIST = 'Provided `source` folder does not exist.'.freeze
5
5
  NO_SVGS_IN_SOURCE_MESSAGE = 'No SVGs were found in `source` folder.'.freeze
6
6
 
7
- attr_reader :source, :destination
7
+ attr_reader :source, :destination, :prefix
8
8
 
9
9
  def initialize(options = {})
10
10
  @source = Source.new(options)
11
11
  @destination = Destination.new(options)
12
12
  @svgo = options.fetch('svgo', false)
13
+ @prefix = options.fetch('prefix', @destination.file_id)
13
14
 
14
15
  raise SOURCE_IS_DESTINATION_MESSAGE if source_is_destination?
15
16
  raise SOURCE_DOES_NOT_EXIST unless source_exists?
@@ -41,7 +42,7 @@ module Svgeez
41
42
  private
42
43
 
43
44
  def destination_file_contents
44
- file_contents = Elements::SvgElement.new(source, destination).build
45
+ file_contents = Elements::SvgElement.new(source, destination, prefix).build
45
46
  file_contents = Optimizer.new.optimize(file_contents) if @svgo
46
47
 
47
48
  file_contents.insert(4, ' style="display: none;"')
@@ -31,6 +31,7 @@ module Svgeez
31
31
  def add_options(command)
32
32
  command.option 'source', '-s', '--source [FOLDER]', 'Source folder (defaults to ./_svgeez)'
33
33
  command.option 'destination', '-d', '--destination [OUTPUT]', 'Destination file or folder (defaults to ./svgeez.svg)'
34
+ command.option 'prefix', '-p', '--prefix [PREFIX]', 'Custom Prefix for icon id (defaults to destination filename)'
34
35
  command.option 'svgo', '--with-svgo', 'Optimize source SVGs with SVGO before sprite generation (non-destructive)'
35
36
  end
36
37
  end
@@ -1,9 +1,10 @@
1
1
  module Svgeez
2
2
  module Elements
3
3
  class SvgElement
4
- def initialize(source, destination)
4
+ def initialize(source, destination, prefix)
5
5
  @source = source
6
6
  @destination = destination
7
+ @prefix = prefix
7
8
  end
8
9
 
9
10
  def build
@@ -14,7 +15,7 @@ module Svgeez
14
15
 
15
16
  def symbol_elements
16
17
  @source.file_paths.map do |file_path|
17
- SymbolElement.new(file_path, @destination.file_id).build
18
+ SymbolElement.new(file_path, @prefix).build
18
19
  end
19
20
  end
20
21
  end
@@ -16,8 +16,11 @@ module Svgeez
16
16
 
17
17
  def element_attributes(attributes)
18
18
  attrs = attributes.scan(/(?:viewBox|xmlns:.+?)=".*?"/m)
19
+ id_prefix = @file_id
20
+ id_suffix = File.basename(@file_path, '.svg').gsub(/['"\s]/, '-')
21
+ id_attribute = [id_prefix, id_suffix].reject(&:empty?).join('-')
19
22
 
20
- attrs << %(id="#{@file_id}-#{File.basename(@file_path, '.svg').gsub(/['"\s]/, '-')}")
23
+ attrs << %(id="#{id_attribute}")
21
24
  end
22
25
 
23
26
  def element_contents(content)
@@ -1,3 +1,3 @@
1
1
  module Svgeez
2
- VERSION = '3.1.0'.freeze
2
+ VERSION = '3.2.0'.freeze
3
3
  end
@@ -1,10 +1,7 @@
1
- lib = File.expand_path('lib', __dir__)
2
- $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
-
4
- require 'svgeez/version'
1
+ require_relative 'lib/svgeez/version'
5
2
 
6
3
  Gem::Specification.new do |spec|
7
- spec.required_ruby_version = ['>= 2.4', '< 2.8']
4
+ spec.required_ruby_version = Gem::Requirement.new('>= 2.4', '< 2.8')
8
5
 
9
6
  spec.name = 'svgeez'
10
7
  spec.version = Svgeez::VERSION
@@ -16,25 +13,16 @@ Gem::Specification.new do |spec|
16
13
  spec.homepage = 'https://github.com/jgarber623/svgeez'
17
14
  spec.license = 'MIT'
18
15
 
19
- spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(bin|spec)/}) }
16
+ spec.files = Dir.chdir(File.expand_path(__dir__)) do
17
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(bin|spec)/}) }
18
+ end
20
19
 
21
20
  spec.bindir = 'exe'
22
21
  spec.executables = ['svgeez']
23
22
  spec.require_paths = ['lib']
24
23
 
25
- spec.metadata = {
26
- 'bug_tracker_uri' => "#{spec.homepage}/issues",
27
- 'changelog_uri' => "#{spec.homepage}/blob/v#{spec.version}/CHANGELOG.md"
28
- }
29
-
30
- spec.add_development_dependency 'rake', '~> 13.0'
31
- spec.add_development_dependency 'reek', '~> 5.6'
32
- spec.add_development_dependency 'rspec', '~> 3.9'
33
- spec.add_development_dependency 'rubocop', '~> 0.79.0'
34
- spec.add_development_dependency 'rubocop-performance', '~> 1.5'
35
- spec.add_development_dependency 'rubocop-rspec', '~> 1.37'
36
- spec.add_development_dependency 'simplecov', '~> 0.17.1'
37
- spec.add_development_dependency 'simplecov-console', '~> 0.6.0'
24
+ spec.metadata['bug_tracker_uri'] = "#{spec.homepage}/issues"
25
+ spec.metadata['changelog_uri'] = "#{spec.homepage}/blob/v#{spec.version}/CHANGELOG.md"
38
26
 
39
27
  spec.add_runtime_dependency 'listen', '~> 3.2'
40
28
  spec.add_runtime_dependency 'mercenary', '~> 0.4.0'
metadata CHANGED
@@ -1,127 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: svgeez
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.1.0
4
+ version: 3.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jason Garber
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-01-20 00:00:00.000000000 Z
11
+ date: 2020-08-12 00:00:00.000000000 Z
12
12
  dependencies:
13
- - !ruby/object:Gem::Dependency
14
- name: rake
15
- requirement: !ruby/object:Gem::Requirement
16
- requirements:
17
- - - "~>"
18
- - !ruby/object:Gem::Version
19
- version: '13.0'
20
- type: :development
21
- prerelease: false
22
- version_requirements: !ruby/object:Gem::Requirement
23
- requirements:
24
- - - "~>"
25
- - !ruby/object:Gem::Version
26
- version: '13.0'
27
- - !ruby/object:Gem::Dependency
28
- name: reek
29
- requirement: !ruby/object:Gem::Requirement
30
- requirements:
31
- - - "~>"
32
- - !ruby/object:Gem::Version
33
- version: '5.6'
34
- type: :development
35
- prerelease: false
36
- version_requirements: !ruby/object:Gem::Requirement
37
- requirements:
38
- - - "~>"
39
- - !ruby/object:Gem::Version
40
- version: '5.6'
41
- - !ruby/object:Gem::Dependency
42
- name: rspec
43
- requirement: !ruby/object:Gem::Requirement
44
- requirements:
45
- - - "~>"
46
- - !ruby/object:Gem::Version
47
- version: '3.9'
48
- type: :development
49
- prerelease: false
50
- version_requirements: !ruby/object:Gem::Requirement
51
- requirements:
52
- - - "~>"
53
- - !ruby/object:Gem::Version
54
- version: '3.9'
55
- - !ruby/object:Gem::Dependency
56
- name: rubocop
57
- requirement: !ruby/object:Gem::Requirement
58
- requirements:
59
- - - "~>"
60
- - !ruby/object:Gem::Version
61
- version: 0.79.0
62
- type: :development
63
- prerelease: false
64
- version_requirements: !ruby/object:Gem::Requirement
65
- requirements:
66
- - - "~>"
67
- - !ruby/object:Gem::Version
68
- version: 0.79.0
69
- - !ruby/object:Gem::Dependency
70
- name: rubocop-performance
71
- requirement: !ruby/object:Gem::Requirement
72
- requirements:
73
- - - "~>"
74
- - !ruby/object:Gem::Version
75
- version: '1.5'
76
- type: :development
77
- prerelease: false
78
- version_requirements: !ruby/object:Gem::Requirement
79
- requirements:
80
- - - "~>"
81
- - !ruby/object:Gem::Version
82
- version: '1.5'
83
- - !ruby/object:Gem::Dependency
84
- name: rubocop-rspec
85
- requirement: !ruby/object:Gem::Requirement
86
- requirements:
87
- - - "~>"
88
- - !ruby/object:Gem::Version
89
- version: '1.37'
90
- type: :development
91
- prerelease: false
92
- version_requirements: !ruby/object:Gem::Requirement
93
- requirements:
94
- - - "~>"
95
- - !ruby/object:Gem::Version
96
- version: '1.37'
97
- - !ruby/object:Gem::Dependency
98
- name: simplecov
99
- requirement: !ruby/object:Gem::Requirement
100
- requirements:
101
- - - "~>"
102
- - !ruby/object:Gem::Version
103
- version: 0.17.1
104
- type: :development
105
- prerelease: false
106
- version_requirements: !ruby/object:Gem::Requirement
107
- requirements:
108
- - - "~>"
109
- - !ruby/object:Gem::Version
110
- version: 0.17.1
111
- - !ruby/object:Gem::Dependency
112
- name: simplecov-console
113
- requirement: !ruby/object:Gem::Requirement
114
- requirements:
115
- - - "~>"
116
- - !ruby/object:Gem::Version
117
- version: 0.6.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.6.0
125
13
  - !ruby/object:Gem::Dependency
126
14
  name: listen
127
15
  requirement: !ruby/object:Gem::Requirement
@@ -192,7 +80,7 @@ licenses:
192
80
  - MIT
193
81
  metadata:
194
82
  bug_tracker_uri: https://github.com/jgarber623/svgeez/issues
195
- changelog_uri: https://github.com/jgarber623/svgeez/blob/v3.1.0/CHANGELOG.md
83
+ changelog_uri: https://github.com/jgarber623/svgeez/blob/v3.2.0/CHANGELOG.md
196
84
  post_install_message:
197
85
  rdoc_options: []
198
86
  require_paths:
@@ -211,7 +99,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
211
99
  - !ruby/object:Gem::Version
212
100
  version: '0'
213
101
  requirements: []
214
- rubygems_version: 3.0.6
102
+ rubygems_version: 3.1.3
215
103
  signing_key:
216
104
  specification_version: 4
217
105
  summary: Automatically generate an SVG sprite from a folder of SVG icons.