svgeez 0.2.0 → 0.2.1

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: 5457b1190e893a9dfac8629a5c06463147685837
4
- data.tar.gz: 6c0998ebc8e795b5b5aa2a1953b8824d18c300c0
3
+ metadata.gz: a3c37bab4033eb6499bc4d2bdfbdfd11c882de9d
4
+ data.tar.gz: a527d2cdf19b23775367fd9395941dd80d3ca1c4
5
5
  SHA512:
6
- metadata.gz: 70edd657348bc0d4b44add8f3516b20fcc715e56e9f99601f944f067adee1856a4ae2e4f4b0c16e33dcd5b9242c8449c03c7d1c7b8d0f9e141e3e53cc0facce4
7
- data.tar.gz: 6472cae9a52960be99f3349db60283c42cc342b3aad1027c60b58639be049c48a8a08530b010699b991ffb02d648de1d28186c92a762a48a6faaf53595881031
6
+ metadata.gz: 7b7c8277a22af454dda0b22827b370e1abbf6cb5324a4ddee1e1544b3338237a3eb00c01b7fb0bba6b350109548089c6f92431404a5e5204b3bc8e66676a8439
7
+ data.tar.gz: b21f4895462d5662266b7f22df1e8a673db0641f031fe6dd50cfce77b458497d6b4bd8cb398c06cd67d4fcaacaec70a1e62b580fc7120777201bd01d1b776f03
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- 2.2.3
1
+ 2.2.4
data/.travis.yml CHANGED
@@ -1,4 +1,7 @@
1
1
  language: ruby
2
2
  rvm:
3
3
  - 2.2.3
4
- before_install: gem install bundler -v 1.10.6
4
+ - 2.2.4
5
+ notifications:
6
+ email: false
7
+ slack: sixtwothree:yATLmjTW15443qR7jbCWr3RO
data/CONTRIBUTING.md CHANGED
@@ -11,9 +11,9 @@ I definitely appreciate your interest in (and help improving) svgeez. Thanks!
11
11
 
12
12
  ## Installation
13
13
 
14
- svgeez is a written in [Ruby](https://www.ruby-lang.org/en/) (version 2.2.3) and development dependencies are managed using the [Bundler](http://bundler.io/) gem.
14
+ svgeez is a written in [Ruby](https://www.ruby-lang.org/en/) (version 2.2.4) and development dependencies are managed using the [Bundler](http://bundler.io/) gem.
15
15
 
16
- I manage Ruby versions with [rbenv](https://github.com/rbenv/rbenv). I'd recommend you do the same or use a similar Ruby version manager ([chruby](https://github.com/postmodern/chruby/) or [RVM](https://rvm.io/) come to mind). Once you've installed Ruby 2.2.3 using your method of choice, install the project's gems by running:
16
+ I manage Ruby versions with [rbenv](https://github.com/rbenv/rbenv). I'd recommend you do the same or use a similar Ruby version manager ([chruby](https://github.com/postmodern/chruby/) or [RVM](https://rvm.io/) come to mind). Once you've installed Ruby 2.2.4 using your method of choice, install the project's gems by running:
17
17
 
18
18
  ```sh
19
19
  bundle install
data/Gemfile CHANGED
@@ -1,5 +1,3 @@
1
- ruby '2.2.3'
2
-
3
1
  source 'https://rubygems.org'
4
2
 
5
3
  # Specify your gem's dependencies in svgeez.gemspec
data/README.md CHANGED
@@ -5,6 +5,7 @@
5
5
  [![Gem Version](https://badge.fury.io/rb/svgeez.svg)](https://badge.fury.io/rb/svgeez)
6
6
  [![Build Status](https://travis-ci.org/jgarber623/svgeez.svg?branch=master)](https://travis-ci.org/jgarber623/svgeez)
7
7
  [![Code Climate](https://codeclimate.com/github/jgarber623/svgeez/badges/gpa.svg)](https://codeclimate.com/github/jgarber623/svgeez)
8
+ [![Test Coverage](https://codeclimate.com/github/jgarber623/svgeez/badges/coverage.svg)](https://codeclimate.com/github/jgarber623/svgeez/coverage)
8
9
 
9
10
  If you're using an [SVG](https://en.wikipedia.org/wiki/Scalable_Vector_Graphics) icon system in your Web projects, svgeez can help speed up your workflow by automating the SVG sprite generation process. Simply run svgeez alongside your existing project (or integrate it into your current build system); add, edit, or delete SVG files from a folder; and marvel as svgeez generates a single SVG sprite file ready for inclusion in your user interface.
10
11
 
@@ -18,16 +19,16 @@ _For more on why SVG sprites are the bee's knees as far as icon systems go, give
18
19
 
19
20
  ## Getting Started
20
21
 
21
- Before installing and using svgeez, you'll want to have Ruby 2.2.3 installed on your computer. There are plenty of ways to go about this, but my preference is [rbenv](https://github.com/sstephenson/rbenv). If you're developing on a Mac and using [Homebrew](http://brew.sh/), installing rbenv is [super easy](https://github.com/sstephenson/rbenv#homebrew-on-mac-os-x).
22
+ Before installing and using svgeez, you'll want to have Ruby 2.2.4 installed on your computer. There are plenty of ways to go about this, but my preference is [rbenv](https://github.com/sstephenson/rbenv). If you're developing on a Mac and using [Homebrew](http://brew.sh/), installing rbenv is [super easy](https://github.com/sstephenson/rbenv#homebrew-on-mac-os-x).
22
23
 
23
- svgeez _might_ work with other versions of Ruby, but it's tested against 2.2.3.
24
+ svgeez _might_ work with other versions of Ruby, but it's developed in 2.2.4.
24
25
 
25
26
  ## Installation
26
27
 
27
28
  If you're using Bundler, add svgeez to your project's Gemfile:
28
29
 
29
30
  ```rb
30
- ruby '2.2.3'
31
+ ruby '2.2.4'
31
32
 
32
33
  source 'https://rubygems.org' do
33
34
  gem 'svgeez'
@@ -100,22 +101,28 @@ For example, a file named `menu.svg` in `~/Sites/sixtwothree.org/images/icons` w
100
101
  </symbol>
101
102
  ```
102
103
 
104
+ **Note:** Single quotes, double quotes, and spaces in individual icon file names will be replaced with dashes. This _could_ result in two `<symbol>`s with the same `id` attribute value. Keep this in mind when naming your source icon files.
105
+
103
106
  ### Markup
104
107
 
105
- To use an svgeez-generated SVG sprite file, first include the file's contents at the top of your HTML page, just after the opening `<body>` element.
108
+ To use an svgeez-generated SVG sprite file, first include the file's contents at the bottom of your HTML page.
106
109
 
107
110
  In a Rails 4 application:
108
111
 
109
112
  ```erb
110
113
  <body>
111
- <%= raw assets.find_asset('icons.svg') %>
114
+ <!-- Your page’s awesome content goes here! -->
115
+
116
+ <%= raw Rails.application.assets.find_asset('icons.svg') %>
112
117
  </body>
113
118
  ```
114
119
 
115
120
  Or, with PHP:
116
121
 
117
- ```php
122
+ ```html
118
123
  <body>
124
+ <!-- Your page’s awesome content goes here! -->
125
+
119
126
  <?php include_once('path/to/icons.svg'); ?>
120
127
  </body>
121
128
  ```
@@ -130,12 +137,12 @@ A more complete example from a Rails 4 application's layout file:
130
137
 
131
138
  ```erb
132
139
  <body>
133
- <%= raw assets.find_asset('icons.svg') %>
134
-
135
140
  <button>
136
141
  <svg><use xlink:href="#icons-menu"></svg>
137
142
  Menu
138
143
  </button>
144
+
145
+ <%= raw Rails.application.assets.find_asset('icons.svg') %>
139
146
  </body>
140
147
  ```
141
148
 
@@ -153,7 +160,7 @@ button {
153
160
  }
154
161
 
155
162
  button svg {
156
- fill: #c00; // Absent this declaration, the icon's fill color would be #333
163
+ fill: #c00; // Absent this declaration, the icons fill color would be #333
157
164
  }
158
165
  ```
159
166
 
data/bin/svgeez CHANGED
@@ -12,7 +12,7 @@ Mercenary.program(:svgeez) do |p|
12
12
 
13
13
  Svgeez::Command.subclasses.each { |c| c.init_with_program(p) }
14
14
 
15
- p.action do |args, options|
15
+ p.action do |args, _|
16
16
  if args.empty?
17
17
  puts p
18
18
  abort
@@ -19,13 +19,13 @@ module Svgeez
19
19
  def process(options)
20
20
  Svgeez.logger.info %{Watching `#{File.expand_path(options['source'])}` for changes... Press ctrl-c to stop.}
21
21
 
22
- listener = Listen.to(options['source'], only: /\.svg$/) do |modified, added, removed|
22
+ listener = Listen.to(options['source'], only: /\.svg$/) do
23
23
  Svgeez::Commands::Build.process(options)
24
24
  end
25
25
 
26
26
  listener.start
27
27
  sleep
28
- rescue Interrupt => e
28
+ rescue Interrupt
29
29
  end
30
30
  end
31
31
  end
@@ -37,11 +37,15 @@ module Svgeez
37
37
  %{<svg id="#{destination_file_id}" style="display: none;" version="1.1">}.tap do |destination_file_contents|
38
38
  # Loop over all source files, grabbing their content, and appending to `destination_file_contents`
39
39
  source_file_paths.each do |file_path|
40
- file_contents = use_svgo? ? `svgo -i #{file_path} -o -` : IO.read(file_path)
40
+ file_contents = IO.read(file_path)
41
41
  pattern = /^<svg.*?(?<viewbox>viewBox=".*?").*?>(?<content>.*?)<\/svg>/m
42
42
 
43
+ if use_svgo?
44
+ file_contents = `cat <<EOF | svgo -i - -o -\n#{file_contents}\nEOF`
45
+ end
46
+
43
47
  file_contents.match(pattern) do |matches|
44
- destination_file_contents << %{<symbol id="#{destination_file_id}-#{File.basename(file_path, '.svg').downcase}" #{matches[:viewbox]}>#{matches[:content]}</symbol>}
48
+ destination_file_contents << %{<symbol id="#{destination_file_id}-#{File.basename(file_path, '.svg').gsub(/['"\s]/, '-').downcase}" #{matches[:viewbox]}>#{matches[:content]}</symbol>}
45
49
  end
46
50
  end
47
51
 
@@ -78,7 +82,7 @@ module Svgeez
78
82
  end
79
83
 
80
84
  def source_is_destination?
81
- @source == destination_folder_path
85
+ %r{^#{@source}} =~ destination_folder_path
82
86
  end
83
87
 
84
88
  def svgo_installed?
@@ -1,3 +1,3 @@
1
1
  module Svgeez
2
- VERSION = '0.2.0'
2
+ VERSION = '0.2.1'
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 |severity, datetime, progname, msg|
19
+ self.logger.formatter = proc do |_, _, _, msg|
20
20
  %{#{msg}\n}
21
21
  end
22
22
  end
data/svgeez.gemspec CHANGED
@@ -18,10 +18,11 @@ Gem::Specification.new do |spec|
18
18
  spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
19
19
  spec.require_paths = ['lib']
20
20
 
21
- spec.add_runtime_dependency 'listen', '~> 3.0'
22
- spec.add_runtime_dependency 'mercenary', '~> 0.3'
23
-
24
21
  spec.add_development_dependency 'bundler', '~> 1.10'
22
+ spec.add_development_dependency 'codeclimate-test-reporter'
25
23
  spec.add_development_dependency 'rake', '~> 10.0'
26
24
  spec.add_development_dependency 'rspec'
25
+
26
+ spec.add_runtime_dependency 'listen', '~> 3.0'
27
+ spec.add_runtime_dependency 'mercenary', '~> 0.3'
27
28
  end
metadata CHANGED
@@ -1,57 +1,43 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: svgeez
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jason Garber
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-12-11 00:00:00.000000000 Z
11
+ date: 2016-01-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: listen
15
- requirement: !ruby/object:Gem::Requirement
16
- requirements:
17
- - - "~>"
18
- - !ruby/object:Gem::Version
19
- version: '3.0'
20
- type: :runtime
21
- prerelease: false
22
- version_requirements: !ruby/object:Gem::Requirement
23
- requirements:
24
- - - "~>"
25
- - !ruby/object:Gem::Version
26
- version: '3.0'
27
- - !ruby/object:Gem::Dependency
28
- name: mercenary
14
+ name: bundler
29
15
  requirement: !ruby/object:Gem::Requirement
30
16
  requirements:
31
17
  - - "~>"
32
18
  - !ruby/object:Gem::Version
33
- version: '0.3'
34
- type: :runtime
19
+ version: '1.10'
20
+ type: :development
35
21
  prerelease: false
36
22
  version_requirements: !ruby/object:Gem::Requirement
37
23
  requirements:
38
24
  - - "~>"
39
25
  - !ruby/object:Gem::Version
40
- version: '0.3'
26
+ version: '1.10'
41
27
  - !ruby/object:Gem::Dependency
42
- name: bundler
28
+ name: codeclimate-test-reporter
43
29
  requirement: !ruby/object:Gem::Requirement
44
30
  requirements:
45
- - - "~>"
31
+ - - ">="
46
32
  - !ruby/object:Gem::Version
47
- version: '1.10'
33
+ version: '0'
48
34
  type: :development
49
35
  prerelease: false
50
36
  version_requirements: !ruby/object:Gem::Requirement
51
37
  requirements:
52
- - - "~>"
38
+ - - ">="
53
39
  - !ruby/object:Gem::Version
54
- version: '1.10'
40
+ version: '0'
55
41
  - !ruby/object:Gem::Dependency
56
42
  name: rake
57
43
  requirement: !ruby/object:Gem::Requirement
@@ -80,6 +66,34 @@ dependencies:
80
66
  - - ">="
81
67
  - !ruby/object:Gem::Version
82
68
  version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: listen
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '3.0'
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '3.0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: mercenary
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '0.3'
90
+ type: :runtime
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '0.3'
83
97
  description: Automatically generate an SVG sprite from a folder of SVG icons.
84
98
  email:
85
99
  - jason@sixtwothree.org