svgeez 0.2.4 → 0.2.7

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c1bce20ebd93334034c81f289bc0afbccafa602f
4
- data.tar.gz: 00257096f8f4c43218dcfe2cc40324bd545a26f9
3
+ metadata.gz: 8d3afb52b2f6c2e729e45e0424973b27b55915af
4
+ data.tar.gz: 985940a3598cc19bcc6204e67874717154179f86
5
5
  SHA512:
6
- metadata.gz: bed9d3d9ecb1e777a2f7cbb9b2141d9bd28e13993b63981fee1af710f5447746bcc601f59197b3c339beddadb540aabe611eb41f397835269a1ca85848abf16d
7
- data.tar.gz: 631d6f71da3b8f25169ddf41ec68041827cdac54b8a8ace6a22c59f967d7004817a6ddff05cdf2f44e8a8a09ce53f331517dca849b0c7cd3c5336b64fcb2df5b
6
+ metadata.gz: 6500f825534a6f87d21cb1eda1f0eebe7654c1ff5c313486a7686fb6d07ba1ab86d5a24abb60bef7ace4c35ad6a1ec78d29c0471afd0ec49b5f4052b9a42d4dc
7
+ data.tar.gz: 382fa4b98557b1343c087b32e11e9194f9f23bca8855f34ec2b4ab75cafd604945bb3ef464e6da51c8394fd73c6211285d2eeea3029ea5400b9779d5df743f05
data/.codeclimate.yml CHANGED
@@ -1,8 +1,17 @@
1
+ ---
1
2
  engines:
2
3
  duplication:
3
4
  enabled: true
4
5
  config:
5
6
  languages:
6
7
  - ruby
8
+ fixme:
9
+ enabled: true
7
10
  rubocop:
8
11
  enabled: true
12
+ ratings:
13
+ paths:
14
+ - bin/
15
+ - lib/
16
+ exclude_paths:
17
+ - spec/
data/Rakefile CHANGED
@@ -5,4 +5,4 @@ require 'rubocop/rake_task'
5
5
  RSpec::Core::RakeTask.new
6
6
  RuboCop::RakeTask.new
7
7
 
8
- task :default => :spec
8
+ task default: :spec
data/bin/svgeez CHANGED
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- $:.unshift File.join(File.dirname(__FILE__), *%w{ .. lib })
3
+ $LOAD_PATH.unshift File.join(File.dirname(__FILE__), *%w(.. lib))
4
4
 
5
5
  require 'svgeez'
6
6
  require 'mercenary'
@@ -17,7 +17,7 @@ module Svgeez
17
17
  end
18
18
 
19
19
  def process(options)
20
- Svgeez.logger.info %{Watching `#{File.expand_path(options['source'])}` for changes... Press ctrl-c to stop.}
20
+ Svgeez.logger.info %(Watching `#{File.expand_path(options['source'])}` for changes... Press ctrl-c to stop.)
21
21
 
22
22
  listener = Listen.to(options['source'], only: /\.svg$/) do
23
23
  Svgeez::Commands::Build.process(options)
@@ -3,56 +3,56 @@ module Svgeez
3
3
  def initialize(options)
4
4
  @source = File.expand_path(options.fetch('source', './'))
5
5
  @destination = File.expand_path(options.fetch('destination', './_svgeez/svgeez.svg'))
6
- @with_svgo = options['svgo']
6
+ @svgo = options['svgo']
7
7
  end
8
8
 
9
9
  def build
10
- unless source_is_destination?
11
- if source_file_paths.any?
12
- Svgeez.logger.info %{Generating sprite at `#{destination_file_path}` from #{source_file_paths.length} SVG#{'s' if source_file_paths.length > 1}...}
13
-
14
- # Make destination folder
15
- FileUtils.mkdir_p(destination_folder_path)
16
-
17
- # Notify if SVGO requested but not found
18
- if @with_svgo && !svgo_installed?
19
- Svgeez.logger.warn %{Unable to find `svgo` in your PATH. Continuing with standard sprite generation...}
20
- end
21
-
22
- # Write the file
23
- File.open(destination_file_path, 'w') do |f|
24
- f.write build_destination_file_contents
25
- end
26
-
27
- Svgeez.logger.info %{Successfully generated sprite at `#{destination_file_path}`.}
28
- else
29
- Svgeez.logger.warn %{No SVGs were found in `#{@source}`.}
10
+ if source_is_destination?
11
+ Svgeez.logger.error %(Setting `source` and `destination` to the same path isn't allowed!)
12
+ elsif source_file_paths.any?
13
+ Svgeez.logger.info %(Generating sprite at `#{destination_file_path}` from #{source_file_paths.length} SVG#{'s' if source_file_paths.length > 1}...)
14
+
15
+ # Make destination folder
16
+ FileUtils.mkdir_p(destination_folder_path)
17
+
18
+ # Notify if SVGO requested but not found
19
+ if @svgo && !svgo_installed?
20
+ Svgeez.logger.warn %(Unable to find `svgo` in your PATH. Continuing with standard sprite generation...)
21
+ end
22
+
23
+ # Write the file
24
+ File.open(destination_file_path, 'w') do |f|
25
+ f.write build_destination_file_contents
30
26
  end
27
+
28
+ Svgeez.logger.info %(Successfully generated sprite at `#{destination_file_path}`.)
31
29
  else
32
- Svgeez.logger.error %{Setting `source` and `destination` to the same path isn't allowed!}
30
+ Svgeez.logger.warn %(No SVGs were found in `#{@source}`.)
33
31
  end
34
32
  end
35
33
 
34
+ private
35
+
36
36
  def build_destination_file_contents
37
- destination_file_contents = '<svg>'.tap do |file_contents|
38
- source_file_paths.each do |file_path|
39
- IO.read(file_path).match(/^<svg.*?(?<viewbox>viewBox=".*?").*?>(?<content>.*?)<\/svg>/m) do |matches|
40
- file_contents << %{<symbol id="#{destination_file_id}-#{File.basename(file_path, '.svg').gsub(/['"\s]/, '-')}" #{matches[:viewbox]}>#{matches[:content]}</symbol>}
41
- end
42
- end
37
+ destination_file_contents = '<svg>'
43
38
 
44
- file_contents << '</svg>'
39
+ source_file_paths.each do |file_path|
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
45
43
  end
46
44
 
47
- if use_svgo?
45
+ destination_file_contents << '</svg>'
46
+
47
+ if @svgo && svgo_installed?
48
48
  destination_file_contents = `cat <<EOF | svgo --disable=cleanupIDs -i - -o -\n#{destination_file_contents}\nEOF`
49
49
  end
50
50
 
51
- destination_file_contents.insert(4, %{ id="#{destination_file_id}" style="display: none;" version="1.1"})
51
+ destination_file_contents.insert(4, %( id="#{destination_file_id}" style="display: none;" version="1.1"))
52
52
  end
53
53
 
54
54
  def destination_file_id
55
- @destination_file_id ||= File.basename(destination_file_name, '.svg').gsub(' ', '-')
55
+ @destination_file_id ||= File.basename(destination_file_name, '.svg').tr(' ', '-')
56
56
  end
57
57
 
58
58
  def destination_file_name
@@ -80,15 +80,11 @@ module Svgeez
80
80
  end
81
81
 
82
82
  def source_is_destination?
83
- %r{^#{@source}} =~ destination_folder_path
83
+ /^#{@source}/ =~ destination_folder_path
84
84
  end
85
85
 
86
86
  def svgo_installed?
87
87
  @svgo_installed ||= find_executable0('svgo')
88
88
  end
89
-
90
- def use_svgo?
91
- @use_svgo ||= @with_svgo && svgo_installed?
92
- end
93
89
  end
94
90
  end
@@ -1,3 +1,3 @@
1
1
  module Svgeez
2
- VERSION = '0.2.4'
2
+ VERSION = '0.2.7'
3
3
  end
data/lib/svgeez.rb CHANGED
@@ -16,7 +16,7 @@ module Svgeez
16
16
  end
17
17
  end
18
18
 
19
- self.logger.formatter = proc do |_, _, _, msg|
20
- %{#{msg}\n}
19
+ logger.formatter = proc do |_, _, _, msg|
20
+ "#{msg}\n"
21
21
  end
22
22
  end
data/svgeez.gemspec CHANGED
@@ -4,13 +4,15 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
4
  require 'svgeez/version'
5
5
 
6
6
  Gem::Specification.new do |spec|
7
+ spec.required_ruby_version = '>= 2.2.5'
8
+
7
9
  spec.name = 'svgeez'
8
10
  spec.version = Svgeez::VERSION
9
11
  spec.authors = ['Jason Garber']
10
12
  spec.email = ['jason@sixtwothree.org']
11
13
 
12
- spec.summary = %{Automatically generate an SVG sprite from a folder of SVG icons.}
13
- spec.description = %{Automatically generate an SVG sprite from a folder of SVG icons.}
14
+ spec.summary = 'Automatically generate an SVG sprite from a folder of SVG icons.'
15
+ spec.description = spec.summary
14
16
  spec.homepage = 'https://github.com/jgarber623/svgeez'
15
17
  spec.license = 'MIT'
16
18
 
@@ -19,9 +21,9 @@ Gem::Specification.new do |spec|
19
21
  spec.require_paths = ['lib']
20
22
 
21
23
  spec.add_development_dependency 'bundler', '~> 1.10'
22
- spec.add_development_dependency 'codeclimate-test-reporter'
24
+ spec.add_development_dependency 'codeclimate-test-reporter', '~> 0.6.0'
23
25
  spec.add_development_dependency 'rake', '~> 10.0'
24
- spec.add_development_dependency 'rspec'
26
+ spec.add_development_dependency 'rspec', '~> 3.5'
25
27
  spec.add_development_dependency 'rubocop', '~> 0.42.0'
26
28
 
27
29
  spec.add_runtime_dependency 'listen', '~> 3.0'
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.2.4
4
+ version: 0.2.7
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-07 00:00:00.000000000 Z
11
+ date: 2016-08-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -28,16 +28,16 @@ dependencies:
28
28
  name: codeclimate-test-reporter
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ">="
31
+ - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '0'
33
+ version: 0.6.0
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - ">="
38
+ - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: '0'
40
+ version: 0.6.0
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rake
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -56,16 +56,16 @@ dependencies:
56
56
  name: rspec
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - ">="
59
+ - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: '0'
61
+ version: '3.5'
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: '0'
68
+ version: '3.5'
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: rubocop
71
71
  requirement: !ruby/object:Gem::Requirement
@@ -149,7 +149,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
149
149
  requirements:
150
150
  - - ">="
151
151
  - !ruby/object:Gem::Version
152
- version: '0'
152
+ version: 2.2.5
153
153
  required_rubygems_version: !ruby/object:Gem::Requirement
154
154
  requirements:
155
155
  - - ">="