svg2glyph 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (2) hide show
  1. data/bin/svg2glyph +10 -3
  2. metadata +1 -1
data/bin/svg2glyph CHANGED
@@ -1,15 +1,21 @@
1
1
  #!/usr/bin/env ruby
2
2
  require 'fileutils'
3
3
 
4
- source_file = ARGV[0].nil? ? 'source.xml' : ARGV[0]
4
+ source_file = ARGV[0]
5
5
  target_dir = ARGV[1].nil? ? 'glyphs' : ARGV[1]
6
6
 
7
+ abort("An input svg file must be specified") if ARGV[0].nil?
7
8
  abort("The specified svg file does not exist: #{source_file}") unless File.exists? source_file
8
9
 
9
10
  FileUtils.mkdir_p target_dir unless Dir.exists? target_dir
10
11
 
11
- File.open(source_file).read.scan(/id="(.*?)".*?d="(.*?)"/m) do |m|
12
- File.open("#{target_dir}/#{m[0]}.svg", "w+") do |out|
12
+ #File.open(source_file).read.scan(/id="(.*?)".*?d="(.*?)"/m) do |m|
13
+ count=0
14
+ File.open(source_file).read.scan(/id="(.*?)".*?<path.*?d="(.*?)"/m) do |m|
15
+ path = "#{target_dir}/#{m[0]}.svg"
16
+ puts "creating #{path}"
17
+ count = count+1
18
+ File.open(path, "w+") do |out|
13
19
  out.write <<eos
14
20
  <?xml version="1.0" encoding="utf-8"?>
15
21
  <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
@@ -20,3 +26,4 @@ File.open(source_file).read.scan(/id="(.*?)".*?d="(.*?)"/m) do |m|
20
26
  eos
21
27
  end
22
28
  end
29
+ puts "Finished creating #{count} glyphs"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: svg2glyph
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: