svgr 0.1.3 → 0.1.4

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
  SHA256:
3
- metadata.gz: '0005479337446fbe607007a85e09bb6328ab3c1933a21197fa50875229f4cc82'
4
- data.tar.gz: 36c5b92d7bc1507d05c5ee4c3ad4fc588f70cdc7ecf4a3d93e17657038542c17
3
+ metadata.gz: b8780a8f57f04ba0f269de4d0c36b3d4f49f6a0afd3965bdff81133ae40deac8
4
+ data.tar.gz: 243c8772a968c49afee686e50efb4a1291daa395cc97dffe2c3feca5c785f96a
5
5
  SHA512:
6
- metadata.gz: 68a6c31b1841c307b0df5742cb254495764b66deb446b774aa83bb9def6f46083e7dfc700751a9e9530736686013b47bd787e987bdff4964388f94e7ae34e13a
7
- data.tar.gz: bc660eb66946fd9e33aa8d2e63435a11335852dfcfe4612d2e2c1c2fb6c12c90a28b47792322a4ed9f94439b75cfbeed26ff061c23d5b7b433bf5d80a06ab512
6
+ metadata.gz: 3518dc3fcc3e31e2a81baacbc820149f26f7ea01e6ca3fb091dd31061f47e527306a1471a34b85d0f429e96538af78256f3f20a74d9bc0a70b928e5f745e6d64
7
+ data.tar.gz: 1ddc2d25637571d643cb7b90a824f4f1103fd1109c97555041ff752e604f4b111c84253c1664169b396032fde414ee51dddb35f054aaff095d4ab686d7bb0e24
data/bin/svgr CHANGED
@@ -3,6 +3,7 @@
3
3
  require "optparse"
4
4
  require_relative "../lib/svgr/arrange/grid"
5
5
  require_relative "../lib/svgr/document/resize"
6
+ require_relative "../lib/svgr/document/recolor"
6
7
 
7
8
  module Svgr
8
9
  def self.start(argv)
@@ -11,6 +12,7 @@ module Svgr
11
12
  subcommands = {
12
13
  "arrange:grid" => ->(args) { Svgr::Arrange::Grid.start(args) },
13
14
  "document:resize" => ->(args) { Svgr::Document::Resize.start(args) },
15
+ "document:recolor" => ->(args) { Svgr::Document::Recolor.start(args) }
14
16
  }
15
17
 
16
18
  opt_parser = OptionParser.new do |opts|
@@ -0,0 +1,36 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "nokogiri"
4
+
5
+ module Svgr
6
+ module Document
7
+ class Recolor
8
+ class << self
9
+ def start(argv)
10
+ hex_value = argv[0]
11
+
12
+ if !hex_value || argv.size != 1
13
+ puts "Usage: svgr document:recolor <HEXVALUE>"
14
+ exit(1)
15
+ end
16
+
17
+ svg_content = $stdin.read
18
+ recolored_svg = recolor(svg_content, hex_value)
19
+
20
+ # Write the output
21
+ output = recolored_svg.to_xml
22
+ puts output
23
+ end
24
+
25
+ def recolor(content, hex_value)
26
+ svg = Nokogiri::XML(content)
27
+ svg.css("path, circle, ellipse, line, polyline, polygon, rect").each do |element|
28
+ element["fill"] = hex_value if element["fill"] && element["fill"] != "none"
29
+ element["stroke"] = hex_value if element["stroke"] && element["stroke"] != "none"
30
+ end
31
+ svg
32
+ end
33
+ end
34
+ end
35
+ end
36
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: svgr
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nassredean Nasseri
@@ -89,6 +89,7 @@ extra_rdoc_files: []
89
89
  files:
90
90
  - bin/svgr
91
91
  - lib/svgr/arrange/grid.rb
92
+ - lib/svgr/document/recolor.rb
92
93
  - lib/svgr/document/resize.rb
93
94
  homepage: https://github.com/nassredean/svgr
94
95
  licenses: