esvg 4.2.3 → 4.2.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
  SHA1:
3
- metadata.gz: 9717bfddeee730f66c16efd62793f1dfcab055db
4
- data.tar.gz: 3f439fb2791e95e3e0b7e1c3d52e255ecdd4db53
3
+ metadata.gz: 1381c5860ef655f9a00182855cd1b3000a04ca60
4
+ data.tar.gz: a01013c3fcc860731af45ce62cf03b7e684f4150
5
5
  SHA512:
6
- metadata.gz: ea0a0fd2a096b162d3082fdb7c126ac4a13c9c3882edecaa3713d0e1773ca3d742139655728abf6670fda56300feb9296f17a1bfadf7ed30e8832297217adabc
7
- data.tar.gz: 66f4b16120aca9d1dac4e452a2d2e9cc896469edd71331f6939aea1ea176426bbd6644263e9da080fe9203c23a514450f0142c6981543c2f843f29dbfcc9a300
6
+ metadata.gz: db44e7974abca942acf1e1ef096c1d8ebabae7a2c61e28dba86fdf58082d563b005328924aecef3ffbfef954388ca1459198b960ace849e271423a7a4c90d6c7
7
+ data.tar.gz: 69d1a74e01b6d8c640a7828b51ab74ec383ac61f401aaab636ec7775fc509a8fbd8c4638d061f5f0139c0707ee7096d7fbc172df0afb15c74ec525f12f8991cf
data/lib/esvg/railties.rb CHANGED
@@ -3,6 +3,7 @@ module Esvg
3
3
  initializer "esvg.configure_view_controller" do |app|
4
4
  ActiveSupport.on_load :action_view do
5
5
  include Esvg::Helpers
6
+ Esvg.new
6
7
  end
7
8
  end
8
9
  end
data/lib/esvg/symbol.rb CHANGED
@@ -72,7 +72,7 @@ module Esvg
72
72
  options[:style] += "color:#{options[:color]};#{options[:style]}"
73
73
  end
74
74
 
75
- use_attr = {
75
+ svg_attr = {
76
76
  class: [@config[:class], @config[:prefix]+"-"+@name, options[:class]].compact.join(' '),
77
77
  viewBox: @size[:viewBox],
78
78
  style: options[:style],
@@ -81,25 +81,35 @@ module Esvg
81
81
  }
82
82
 
83
83
  # If user doesn't pass a size or set scale: true
84
- if !(options[:width] || options[:height] || options[:scale])
85
-
86
- # default to svg dimensions
87
- use_attr[:width] = @size[:width]
88
- use_attr[:height] = @size[:height]
84
+ if options[:width].nil? && options[:height].nil? && !options[:scale]
85
+ svg_attr[:width] = width
86
+ svg_attr[:height] = height
89
87
  else
90
-
91
88
  # Add sizes (nil options will be stripped)
92
- use_attr[:width] = options[:width]
93
- use_attr[:height] = options[:height]
89
+ svg_attr[:width] = options[:width]
90
+ svg_attr[:height] = options[:height]
94
91
  end
95
92
 
96
- %Q{<svg #{attributes(use_attr)}>#{use_tag}#{title(options)}#{desc(options)}#{options[:content]||''}</svg>}
93
+ use_attr = {
94
+ height: options[:height],
95
+ width: options[:width],
96
+ scale: options[:scale],
97
+ }
98
+
99
+ %Q{<svg #{attributes(svg_attr)}>#{use_tag(use_attr)}#{title(options)}#{desc(options)}#{options[:content]||''}</svg>}
97
100
  end
98
101
 
99
102
  def use_tag(options={})
100
103
  options["xlink:href"] = "##{@id}"
101
- options[:width] ||= width
102
- options[:height] ||= height
104
+
105
+ # If user doesn't pass a size or set scale: true
106
+ if options[:width].nil? && options[:height].nil? && options[:scale].nil?
107
+ options[:width] ||= width
108
+ options[:height] ||= height
109
+ end
110
+
111
+ options.delete(:scale)
112
+
103
113
  %Q{<use #{attributes(options)}/>}
104
114
  end
105
115
 
@@ -207,8 +217,8 @@ module Esvg
207
217
 
208
218
  {
209
219
  viewBox: viewbox,
210
- width: coords[2].to_i - coords[0].to_i,
211
- height: coords[3].to_i - coords[1].to_i
220
+ width: (coords[2].to_i - coords[0].to_i).abs,
221
+ height: (coords[3].to_i - coords[1].to_i).abs
212
222
  }
213
223
  else
214
224
  {}
data/lib/esvg/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Esvg
2
- VERSION = "4.2.3"
2
+ VERSION = "4.2.4"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: esvg
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.2.3
4
+ version: 4.2.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brandon Mathis