File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -9,6 +9,7 @@ This project adheres to [Semantic Versioning](http://semver.org/).
99- Freeze string literals. [ #172 ] ( https://github.com/jamesmartin/inline_svg/pull/172 ) . Thanks, [ @tagliala ] ( https://github.com/tagliala )
1010- Fix thread-local variable leakage in ` with_asset_finder ` . [ #185 ] ( https://github.com/jamesmartin/inline_svg/pull/185 ) . Thanks, [ @tagliala ] ( https://github.com/tagliala )
1111- Remove unused ` InlineSvg::IOResource.default_for ` method. [ #187 ] ( https://github.com/jamesmartin/inline_svg/pull/187 ) . Thanks, [ @tagliala ] ( https://github.com/tagliala )
12+ - Add support for Tempfile. [ #186 ] ( https://github.com/jamesmartin/inline_svg/pull/186 ) . Thanks, [ @javierav ] ( https://github.com/javierav )
1213
1314## [ 1.10.0] - 2024-09-03
1415### Added
Original file line number Diff line number Diff line change @@ -315,6 +315,12 @@ InlineSvg.configure do |config|
315315end
316316```
317317
318+ ## ActiveStorage
319+
320+ ``` erb
321+ <%= user.avatar.open { |file| inline_svg_tag file } %>
322+ ```
323+
318324## Contributing
319325
3203261 . Fork it ( [ http://github.com/jamesmartin/inline_svg/fork ] ( http://github.com/jamesmartin/inline_svg/fork ) )
Original file line number Diff line number Diff line change 33module InlineSvg
44 module IOResource
55 def self . ===( object )
6- object . is_a? ( IO ) || object . is_a? ( StringIO )
6+ object . is_a? ( IO ) || object . is_a? ( StringIO ) || object . is_a? ( Tempfile )
77 end
88
99 def self . read ( object )
Original file line number Diff line number Diff line change 2424 it "for File object" do
2525 expect ( subject === File . new ( "#{ Dir . tmpdir } /testfile" , "w" ) ) . to be true
2626 end
27+
28+ it "for Tempfile object" do
29+ expect ( subject === Tempfile . new ) . to be true
30+ end
2731 end
2832
2933 context 'return false' do
7882 expect ( answer ) . not_to eq ''
7983 end
8084 end
85+
86+ context 'Tempfile object' do
87+ let ( :answer ) { 'read' }
88+ let ( :rio ) do
89+ Tempfile . new . tap do |f |
90+ f . write ( answer )
91+ f . rewind
92+ end
93+ end
94+ let ( :wio ) { File . new ( File ::NULL , 'w' ) } # Tempfile cannot be created for write only mode
95+
96+ instance_exec ( &tests )
97+ end
8198 end
8299end
You can’t perform that action at this time.
0 commit comments