svgo 0.1.4 → 0.1.5

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.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/README.MD +50 -27
  3. data/lib/version.rb +1 -1
  4. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 69aa20fc6ef552269887d38fe4ad6cd429da359b
4
- data.tar.gz: 40edf320ee468e97411eb0745e9e7203b1ad26fc
3
+ metadata.gz: d4ebb97bdbb38bc262905561697cc70dbd987f05
4
+ data.tar.gz: ca37304d4ae0d0a198975973e593cb7f01699217
5
5
  SHA512:
6
- metadata.gz: e4280a0c55fee05b3e1de8ae8b8eb820675229a99345d12d1fc9d869a304f9d7b2576ef454ec4af26c846f6f2aba2b20ee0716414b2ca2f760be105b8c50100d
7
- data.tar.gz: 1ad11e63e2e996fed0fd373f9a48a216a812fe4135519b3e80624e7139065a5b397463009f451be3783bf0c2411f4695b22da41f891ccc67118b4200d146d21b
6
+ metadata.gz: b01c23153d8b84c3ae155af2f5e280f7f639257901005b25bdbb880e0d1af286d3b36db10fde6e66ee5c3446b0a29860e252cf93a89f63afe6204082d09086a4
7
+ data.tar.gz: 969b510081ba20a319e5930d5653f0062d4d6b145ab23939359d75a84fefd6713d807f817035da6310c668eaad929f2a4719eb92df516a702a6f38f1acbf3b34
data/README.MD CHANGED
@@ -4,29 +4,6 @@ Removes metadata and editor data elements and attributes that are redundant
4
4
  from SVG files. Can strip files so they are optimised for web use. Go to
5
5
  [SVGO](https://github.com/svg/svgo) for more documentation on features.
6
6
 
7
- ## How this works
8
-
9
- [`execjs`](https://github.com/rails/execjs) is used to run the Node SVGO as a
10
- library. The SVGO library returns a JavaScript Promise, which is currently not
11
- supported by `execjs` and probably never will be. `setTimeout` and sleep-like
12
- functions are also disabled in `execjs` so we can't wait for the Promise to get
13
- fulfilled. Therefore there is a small wrapper JavaScript in this repository
14
- that calls all the components that SVGO is made up of, but without the
15
- `Promise`. It also wraps up the configuration of plugins the way it is expected
16
- by SVGO's components. Lastly `require` is not supported by `execjs` so all of
17
- this is transpiled to one monolithic JavaScript file - that is completely
18
- self-contained, using [browserify](http://browserify.org/).
19
-
20
- __NOTE:__ `execjs` supports a variety of JavaSript runtimes, notably
21
- [`therubyracer`](https://github.com/cowboyd/therubyracer), but `therubyracer`
22
- depends on an ancient [`libv8`](https://github.com/cowboyd/libv8), which
23
- doesn't support some of the modern syntax used in SVGO. Therefore `mini_racer`
24
- (a drop in replacement for `therubyracer`) is a dependency, which uses a much
25
- more recent `libv8`.
26
-
27
- If you have [Node](https://nodejs.org/) installed you could also use that as a
28
- runtime.
29
-
30
7
  ## How to use?
31
8
 
32
9
  ### As a library
@@ -75,7 +52,8 @@ svgo.optimize_file(svg_file)
75
52
  # => <svg xmlns="http://www.w3.org/2000/svg" ...
76
53
  ```
77
54
 
78
- You can also choose the plugins to use, you can either pass the exact plugins you want with their configuration, or you can modify the default plugin list.
55
+ You can also choose the plugins to use, you can either pass the exact plugins
56
+ you want with their configuration, or you can modify the default plugin list.
79
57
 
80
58
  ```ruby
81
59
  require('svgo')
@@ -98,7 +76,9 @@ svgo = SvgOptimizer.new(options)
98
76
 
99
77
  ### As a CLI tool
100
78
 
101
- Strictly speaking this mode is for testing only. But if you can't install NodeJS, and you do have a Ruby environment and you really need a CLI tool, you might be able to squeeze out some optimised files from this utility.
79
+ Strictly speaking this mode is for testing only. But if you can't install
80
+ NodeJS, and you do have a Ruby environment and you really need a CLI tool, you
81
+ might be able to squeeze out some optimised files from this utility.
102
82
 
103
83
  ``` bash
104
84
  gem install svgo-ruby
@@ -124,6 +104,49 @@ docker run -i svgo < test/fixtures/ruby.svg > test/fixtures/ruby.optim.svg
124
104
  -rw-r--r-- 1 user staff 23K Nov 5 22:12 ruby.svg
125
105
  ```
126
106
 
127
- ## Building Node SVGO from source
107
+ ## How this works
108
+
109
+ [`execjs`](https://github.com/rails/execjs) is used to run the Node SVGO as a
110
+ library. The SVGO library returns a JavaScript Promise, which is currently not
111
+ supported by `execjs` and probably never will be. `setTimeout` and sleep-like
112
+ functions are also disabled in `execjs` so we can't wait for the Promise to get
113
+ fulfilled. Therefore there is a small wrapper JavaScript in this repository
114
+ that calls all the components that SVGO is made up of, but without the
115
+ `Promise`. It also wraps up the configuration of plugins the way it is expected
116
+ by SVGO's components. Lastly `require` is not supported by `execjs` so all of
117
+ this is transpiled to one monolithic JavaScript file - that is completely
118
+ self-contained, using [browserify](http://browserify.org/).
119
+
120
+ __NOTE:__ `execjs` supports a variety of JavaSript runtimes, notably
121
+ [`therubyracer`](https://github.com/cowboyd/therubyracer), but `therubyracer`
122
+ depends on an ancient [`libv8`](https://github.com/cowboyd/libv8), which
123
+ doesn't support some of the modern syntax used in SVGO. Therefore `mini_racer`
124
+ (a drop in replacement for `therubyracer`) is a dependency, which uses a much
125
+ more recent `libv8`.
126
+
127
+ If you have [Node](https://nodejs.org/) installed you could also use that as a
128
+ runtime.
129
+
130
+ ### Transpiling Node SVGO
131
+
132
+ __TL;DR:__ A transpiled version of SVGO is included in the repository, so you
133
+ don't need to transpile anything.
134
+
135
+ Because `execjs` supports only self-contained modules, and does not allow
136
+ `require()`, `Promise` etc.. The SGVO library is wrapped in a JavaScript that
137
+ requires all the main parts of SVGO and makes an SVGO function without
138
+ JavaScript Promises. The wrapper is then transpiled to a self-contained module
139
+ using [browserify](http://browserify.org/).
140
+
141
+ The transpile command can be found in the `Rakefile`. Assuming you have
142
+ [Node](https://nodejs.org/) and [yarn](https://yarnpkg.com/en/) installed on
143
+ your system, you can then run:
144
+
145
+ ``` bash
146
+ yarn install
147
+ rake
148
+ ```
128
149
 
129
- Because `execjs`
150
+ __Note__: if you do not have `yarn` you can run `npm install` instead, but if
151
+ you install Node modules often, you probably should do yourself a favour check
152
+ out [yarn](https://yarnpkg.com/en/).
data/lib/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module SvgoVersion
2
- VERSION = '0.1.4'
2
+ VERSION = '0.1.5'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: svgo
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris Snijder