svgeez 1.0.0 → 1.0.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: b7a16a5496376f424cb08140cb1cb571ce05712b
4
- data.tar.gz: faab6c83f1ef364d46aa80d35cf42b22803ec9f6
3
+ metadata.gz: ea565ea4e30cd6c39b4527c93b97be473c65c5f3
4
+ data.tar.gz: 94cf2839e99ab3d83eba4a4ef5149bcd9202488f
5
5
  SHA512:
6
- metadata.gz: 066d0cb89dab9fe20161352cd11973f87622fd0c6f02b4f9037d1a8ac335792209ebb27b643855e76221910eb5ca4834f8a0a208aa78bf0ab7098657597d3459
7
- data.tar.gz: 2364c7f693d12fab3e9f2849cd0ddc9172fa6f4c74ce29479932fd51d8a90d1753cbbadad90f66d10854d574193851bb2165b4d023eeae5496b47d7114697500
6
+ metadata.gz: f127e80f1d452b638e9342c0bb47109f53325bb9fe727ac1b48ce70c358776850bff4ee844f4b5a44973663d11d710ef72bd6d29e7e36be9223620b8d91c740b
7
+ data.tar.gz: 2fa385b708e00500453cbf0a59938dcb9b39d0f5a09ab888c8938bd4beaf587d11beae6f119dcd753e4a1ff6877ccd05ecf7245708f6174867f06b0dcb3811db
data/.gitignore CHANGED
@@ -1,9 +1,10 @@
1
1
  /.bundle/
2
- /.yardoc
3
- /Gemfile.lock
2
+ /.yardoc/
4
3
  /_yardoc/
5
4
  /coverage/
6
5
  /doc/
7
6
  /pkg/
8
7
  /spec/reports/
9
8
  /tmp/
9
+ *.DS_Store
10
+ Gemfile.lock
data/.travis.yml CHANGED
@@ -1,6 +1,8 @@
1
1
  language: ruby
2
2
  rvm:
3
3
  - 2.2.5
4
+ before_install:
5
+ - npm install -g svgo
4
6
  notifications:
5
7
  email: false
6
8
  slack: sixtwothree:yATLmjTW15443qR7jbCWr3RO
data/CONTRIBUTING.md CHANGED
@@ -11,7 +11,7 @@ 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.5) and development dependencies are managed using the [Bundler](http://bundler.io/) gem.
14
+ svgeez is written in [Ruby](https://www.ruby-lang.org/en/) (version 2.2.5) and development dependencies are managed using the [Bundler](http://bundler.io/) gem.
15
15
 
16
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.5 using your method of choice, install the project's gems by running:
17
17
 
@@ -21,12 +21,18 @@ bundle install
21
21
 
22
22
  …from the root of the project.
23
23
 
24
+ In order for the test suite to run properly, [SVGO](https://github.com/svg/svgo/) must be installed (and the `svgo` command must be available in your PATH). This is most easily achieved by installing [Node.js](https://nodejs.org/) and running:
25
+
26
+ ```sh
27
+ npm install -g svgo
28
+ ```
29
+
24
30
  ## Get set up to contribute
25
31
 
26
32
  Contributing to svgeez is pretty straightforward:
27
33
 
28
34
  1. Fork the svgeez repo and clone it.
29
- 1. Install development dependencies by running `bundle install` from the root of the project.
35
+ 1. Install development dependencies as outlined [above](#installation).
30
36
  1. Create a feature branch for the issue or new feature you're looking to tackle: `git checkout -b your-descriptive-branch-name`.
31
37
  1. _Write some code!_
32
38
  1. Build (`bundle exec rake build`) and install (`bundle exec rake install`) your updated code.
data/README.md CHANGED
@@ -107,7 +107,7 @@ For example, a file named `menu.svg` in `~/Sites/sixtwothree.org/images/icons` w
107
107
 
108
108
  To use an svgeez-generated SVG sprite file, first include the file's contents at the bottom of your HTML page.
109
109
 
110
- In a Rails 4 application:
110
+ In a Rails 4.1.x or lower application:
111
111
 
112
112
  ```erb
113
113
  <body>
@@ -117,6 +117,16 @@ In a Rails 4 application:
117
117
  </body>
118
118
  ```
119
119
 
120
+ In a Rails 4.2.x or 5 application:
121
+
122
+ ```erb
123
+ <body>
124
+ <!-- Your page’s awesome content goes here! -->
125
+
126
+ <%= raw Rails.application.assets_manifest.find_sources('icons.svg').first %>
127
+ </body>
128
+ ```
129
+
120
130
  Or, with PHP:
121
131
 
122
132
  ```html
@@ -133,7 +143,7 @@ Next, wherever you want to include an icon in your user interface, use HTML simi
133
143
  <svg><use xlink:href="#icons-menu"></svg>
134
144
  ```
135
145
 
136
- A more complete example from a Rails 4 application's layout file:
146
+ A more complete example from a Rails 4.1.x or lower application's layout file:
137
147
 
138
148
  ```erb
139
149
  <body>
@@ -146,6 +156,19 @@ A more complete example from a Rails 4 application's layout file:
146
156
  </body>
147
157
  ```
148
158
 
159
+ A more complete example from a Rails 4.2.x or 5 application's layout file:
160
+
161
+ ```erb
162
+ <body>
163
+ <button>
164
+ <svg><use xlink:href="#icons-menu"></svg>
165
+ Menu
166
+ </button>
167
+
168
+ <%= raw Rails.application.assets_manifest.find_sources('icons.svg').first %>
169
+ </body>
170
+ ```
171
+
149
172
  In this example, the contents of the svgeez-generated SVG sprite file is included on every page and isn't terribly cacheable. How onerous this is depends on the size of your icon system.
150
173
 
151
174
  For smaller icon sets, this may be an acceptable balance of user and developer needs. For larger icon sets, you may want to investigate more advanced techniques for loading and caching an SVG sprite file (perhaps with [localStorage](https://developer.mozilla.org/en-US/docs/Web/API/Storage/LocalStorage)…?)
@@ -193,6 +216,7 @@ svgeez is written and maintained by [Jason Garber](https://github.com/jgarber623
193
216
  ### Additional Contributors
194
217
 
195
218
  - [Brett Wilkins](https://github.com/bwilkins)
219
+ - [danny](https://github.com/f96q)
196
220
 
197
221
  ## License
198
222
 
@@ -1,5 +1,7 @@
1
1
  module Svgeez
2
2
  class SpriteBuilder
3
+ DEFAULT_DESTINATION_FILE_NAME = 'svgeez.svg'.freeze
4
+
3
5
  def initialize(options = {})
4
6
  @options = options
5
7
  end
@@ -15,11 +17,6 @@ module Svgeez
15
17
  # Make destination folder
16
18
  FileUtils.mkdir_p(destination_folder_path)
17
19
 
18
- # Notify if SVGO requested but not found
19
- if svgo_use? && !svgo_installed?
20
- Svgeez.logger.warn 'Unable to find `svgo` in your PATH. Continuing with standard sprite generation...'
21
- end
22
-
23
20
  # Write the file
24
21
  File.open(destination_file_path, 'w') do |f|
25
22
  f.write build_destination_file_contents
@@ -30,7 +27,7 @@ module Svgeez
30
27
  end
31
28
 
32
29
  def destination
33
- @destination ||= File.expand_path(@options.fetch('destination', './svgeez.svg'))
30
+ @destination ||= File.expand_path(@options.fetch('destination', "./#{DEFAULT_DESTINATION_FILE_NAME}"))
34
31
  end
35
32
 
36
33
  def source
@@ -42,11 +39,15 @@ module Svgeez
42
39
  def build_destination_file_contents
43
40
  destination_file_contents = "<svg>#{collect_source_files_contents.join}</svg>"
44
41
 
45
- if svgo_use? && svgo_installed?
46
- destination_file_contents = `cat <<EOF | svgo --disable=cleanupIDs -i - -o -\n#{destination_file_contents}\nEOF`
42
+ if svgo_use?
43
+ if svgo_installed?
44
+ destination_file_contents = `cat <<EOF | svgo --disable=cleanupIDs -i - -o -\n#{destination_file_contents}\nEOF`
45
+ else
46
+ Svgeez.logger.warn 'Unable to find `svgo` in your PATH. Continuing with standard sprite generation...'
47
+ end
47
48
  end
48
49
 
49
- destination_file_contents.insert(4, %( id="#{destination_file_id}" style="display: none;" version="1.1"))
50
+ destination_file_contents.insert(4, %( id="#{destination_file_id}" style="display: none;" version="1.1" xmlns="http://www.w3.org/2000/svg"))
50
51
  end
51
52
 
52
53
  def collect_source_files_contents
@@ -65,7 +66,7 @@ module Svgeez
65
66
  if destination.end_with?('.svg')
66
67
  File.split(destination)[1]
67
68
  else
68
- 'svgeez.svg'
69
+ DEFAULT_DESTINATION_FILE_NAME
69
70
  end
70
71
  end
71
72
 
@@ -1,3 +1,3 @@
1
1
  module Svgeez
2
- VERSION = '1.0.0'.freeze
2
+ VERSION = '1.0.1'.freeze
3
3
  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: 1.0.0
4
+ version: 1.0.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: 2016-08-29 00:00:00.000000000 Z
11
+ date: 2016-11-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler