inline_svg 1.7.0 → 1.7.1

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of inline_svg might be problematic. Click here for more details.

checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1ebc9f8de24984925fe3457d98efeb29198bbda5551f83b5c2afad97bf61fa8c
4
- data.tar.gz: 0ab9a31d27a0a97e4aafb1691af4e9e8c0f03074637237819ba611c73d24b82f
3
+ metadata.gz: 923ca3f0952247f48b3346decfe83b44216566a52a2f2bf4a9ba117a2626712b
4
+ data.tar.gz: afef4e221a4e7becce12338289eafe79b60138bd2706ec76a51229a588fe8e5d
5
5
  SHA512:
6
- metadata.gz: e909570434548e33cfc76627819b636b0f28e24b485165b44a467dd7e49c191ccccb082240bd5fec0ae7bd2cfc2686011b56dc3b96ed938530353c6196e8dce8
7
- data.tar.gz: d509b78518354a7b1e40cf481cc4cc4b7ea350d006b5268d2106b9700e2ad2eea7e4431ee674b9e7276a1c11ae61f4903cc9e101ffe40e9a902f870d9429c36b
6
+ metadata.gz: 72bc4f1be354aa23bda0bb62814d194568691b9833e21b8da89594eea213f5ce6fc523ea60c04f19a7e23e546826c98a35ba6cf812579162c70bc6a0905c5d09
7
+ data.tar.gz: c0db9494ac8b67ad61c2dfa38f8b6bb64dad204bbf1978cc86f58600d71ee10f977a38ae74b69b7212293f31eec7ebec183c3c90e14aa274605ebe3972626ec7
@@ -0,0 +1,58 @@
1
+ name: Integration Tests
2
+
3
+ on: [push]
4
+
5
+ jobs:
6
+ build:
7
+
8
+ runs-on: ubuntu-latest
9
+ strategy:
10
+ matrix:
11
+ test-branch: [rails3, rails4, master, rails6, rails6-webpacker]
12
+ steps:
13
+ - name: Checkout
14
+ uses: actions/checkout@v2
15
+ - name: Checkout test app
16
+ uses: actions/checkout@v2
17
+ with:
18
+ repository: jamesmartin/inline_svg_test_app
19
+ ref: ${{ matrix.test-branch }}
20
+ path: test_app
21
+ - name: Set up Ruby 2.6
22
+ uses: actions/setup-ruby@v1
23
+ with:
24
+ ruby-version: 2.6.x
25
+ - name: Build local gem
26
+ run: |
27
+ gem install bundler
28
+ bundle install --jobs 4 --retry 3
29
+ bundle exec rake build
30
+ - name: Use the local gem in the test App
31
+ id: uselocalgem
32
+ uses: jacobtomlinson/gha-find-replace@0.1.1
33
+ with:
34
+ find: "gem 'inline_svg'"
35
+ replace: "gem 'inline_svg', path: '${{github.workspace}}'"
36
+ - name: Check local gem in use
37
+ run: |
38
+ test "${{ steps.uselocalgem.outputs.modifiedFiles }}" != "0"
39
+ grep "inline_svg" $GITHUB_WORKSPACE/test_app/Gemfile
40
+ - name: Bundle
41
+ run: |
42
+ cd $GITHUB_WORKSPACE/test_app
43
+ bundle install --jobs 4 --retry 3
44
+ - name: Set up Node.js 12.x
45
+ uses: actions/setup-node@v1
46
+ with:
47
+ node-version: 12.x
48
+ if: matrix.test-branch == 'rails6-webpacker'
49
+ - name: Generate Webpacker config
50
+ run: |
51
+ cd $GITHUB_WORKSPACE/test_app
52
+ yarn install --check-files
53
+ bundle exec rake webpacker:compile
54
+ if: matrix.test-branch == 'rails6-webpacker'
55
+ - name: Test
56
+ run: |
57
+ cd $GITHUB_WORKSPACE/test_app
58
+ bundle exec rake test
@@ -0,0 +1,20 @@
1
+ name: Ruby
2
+
3
+ on: [push]
4
+
5
+ jobs:
6
+ build:
7
+
8
+ runs-on: ubuntu-latest
9
+
10
+ steps:
11
+ - uses: actions/checkout@v2
12
+ - name: Set up Ruby 2.6
13
+ uses: actions/setup-ruby@v1
14
+ with:
15
+ ruby-version: 2.6.x
16
+ - name: Build and test with Rake
17
+ run: |
18
+ gem install bundler
19
+ bundle install --jobs 4 --retry 3
20
+ bundle exec rake
@@ -6,15 +6,18 @@ This project adheres to [Semantic Versioning](http://semver.org/).
6
6
 
7
7
  - Nothing
8
8
 
9
+ ## [1.7.1] - 2020-03-17
10
+ ### Fixed
11
+ - Static Asset Finder uses pathname for compatibility with Sprockets 4+. [#106](https://github.com/jamesmartin/inline_svg/pull/106). Thanks [@subdigital](https://github.com/subdigital)
12
+
9
13
  ## [1.7.0] - 2020-02-13
10
14
  ### Added
11
15
  - WebpackAssetFinder serves files from dev server if one is running. [#111](https://github.com/jamesmartin/inline_svg/pull/111). Thanks, [@connorshea](https://github.com/connorshea)
12
16
 
13
17
  ### Fixed
14
- - Using Webpacker and Asset Pipeline in a single App could result in SVGs not
15
- being found because the wrong `AssetFinder` was used.
16
- [#114](https://github.com/jamesmartin/inline_svg/pull/114). Thanks,
17
- [@kylefox](https://github.com/kylefox)
18
+ - Using Webpacker and Asset Pipeline in a single App could result in SVGs not being found because the wrong `AssetFinder` was used. [#114](https://github.com/jamesmartin/inline_svg/pull/114). Thanks, [@kylefox](https://github.com/kylefox)
19
+ - Prevent "EOFError error" when using webpack dev server over HTTPS [#113](https://github.com/jamesmartin/inline_svg/pull/113). Thanks, [@kylefox](https://github.com/kylefox)
20
+
18
21
 
19
22
  ## [1.6.0] - 2019-11-13
20
23
  ### Added
@@ -231,7 +234,8 @@ transformations](https://github.com/jamesmartin/inline_svg/blob/master/README.md
231
234
  ### Added
232
235
  - Basic Railtie and view helper to inline SVG documents to Rails views.
233
236
 
234
- [unreleased]: https://github.com/jamesmartin/inline_svg/compare/v1.7.0...HEAD
237
+ [unreleased]: https://github.com/jamesmartin/inline_svg/compare/v1.7.1...HEAD
238
+ [1.7.1]: https://github.com/jamesmartin/inline_svg/compare/v1.7.0...v1.7.1
235
239
  [1.7.0]: https://github.com/jamesmartin/inline_svg/compare/v1.6.0...v1.7.0
236
240
  [1.6.0]: https://github.com/jamesmartin/inline_svg/compare/v1.5.2...v1.6.0
237
241
  [1.5.2]: https://github.com/jamesmartin/inline_svg/compare/v1.5.1...v1.5.2
data/README.md CHANGED
@@ -1,6 +1,7 @@
1
1
  # Inline SVG
2
2
 
3
- [![Build Status](https://travis-ci.org/jamesmartin/inline_svg.svg?branch=master)](https://travis-ci.org/jamesmartin/inline_svg)
3
+ ![Unit tests](https://github.com/jamesmartin/inline_svg/workflows/Ruby/badge.svg)
4
+ ![Integration Tests](https://github.com/jamesmartin/inline_svg/workflows/Integration%20Tests/badge.svg)
4
5
 
5
6
  Styling a SVG document with CSS for use on the web is most reliably achieved by
6
7
  [adding classes to the document and
@@ -1,7 +1,9 @@
1
+ require "pathname"
2
+
1
3
  # Naive fallback asset finder for when sprockets >= 3.0 &&
2
4
  # config.assets.precompile = false
3
5
  # Thanks to @ryanswood for the original code:
4
- # https://github.com/AbleHealth/inline_svg/commit/661bbb3bef7d1b4bd6ccd63f5f018305797b9509
6
+ # https://github.com/jamesmartin/inline_svg/commit/661bbb3bef7d1b4bd6ccd63f5f018305797b9509
5
7
  module InlineSvg
6
8
  class StaticAssetFinder
7
9
  def self.find_asset(filename)
@@ -14,7 +16,7 @@ module InlineSvg
14
16
 
15
17
  def pathname
16
18
  if ::Rails.application.config.assets.compile
17
- ::Rails.application.assets[@filename].pathname
19
+ Pathname.new(::Rails.application.assets[@filename].filename)
18
20
  else
19
21
  manifest = ::Rails.application.assets_manifest
20
22
  asset_path = manifest.assets[@filename]
@@ -1,3 +1,3 @@
1
1
  module InlineSvg
2
- VERSION = "1.7.0"
2
+ VERSION = "1.7.1"
3
3
  end
@@ -6,32 +6,45 @@ module InlineSvg
6
6
 
7
7
  def initialize(filename)
8
8
  @filename = filename
9
+ @asset_path = Webpacker.manifest.lookup(@filename)
9
10
  end
10
11
 
11
12
  def pathname
12
- file_path = Webpacker.instance.manifest.lookup(@filename)
13
- return unless file_path
13
+ return if @asset_path.blank?
14
14
 
15
15
  if Webpacker.dev_server.running?
16
- asset = Net::HTTP.get(Webpacker.dev_server.host, file_path, Webpacker.dev_server.port)
17
-
18
- begin
19
- Tempfile.new(file_path).tap do |file|
20
- file.binmode
21
- file.write(asset)
22
- file.rewind
23
- end
24
- rescue StandardError => e
25
- Rails.logger.error "Error creating tempfile: #{e}"
26
- raise
27
- end
16
+ dev_server_asset(@asset_path)
17
+ elsif Webpacker.config.public_path.present?
18
+ File.join(Webpacker.config.public_path, @asset_path)
19
+ end
20
+ end
21
+
22
+ private
28
23
 
29
- else
30
- public_path = Webpacker.config.public_path
31
- return unless public_path
24
+ def dev_server_asset(file_path)
25
+ asset = fetch_from_dev_server(file_path)
32
26
 
33
- File.join(public_path, file_path)
27
+ begin
28
+ Tempfile.new(file_path).tap do |file|
29
+ file.binmode
30
+ file.write(asset)
31
+ file.rewind
32
+ end
33
+ rescue StandardError => e
34
+ Rails.logger.error "[inline_svg] Error creating tempfile for #{@filename}: #{e}"
35
+ raise
34
36
  end
35
37
  end
38
+
39
+ def fetch_from_dev_server(file_path)
40
+ http = Net::HTTP.new(Webpacker.dev_server.host, Webpacker.dev_server.port)
41
+ http.use_ssl = Webpacker.dev_server.https?
42
+ http.verify_mode = OpenSSL::SSL::VERIFY_NONE
43
+
44
+ http.request(Net::HTTP::Get.new(file_path)).body
45
+ rescue StandardError => e
46
+ Rails.logger.error "[inline_svg] Error fetching #{@filename} from webpack-dev-server: #{e}"
47
+ raise
48
+ end
36
49
  end
37
50
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: inline_svg
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.7.0
4
+ version: 1.7.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Martin
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-02-12 00:00:00.000000000 Z
11
+ date: 2020-03-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -129,16 +129,16 @@ executables: []
129
129
  extensions: []
130
130
  extra_rdoc_files: []
131
131
  files:
132
+ - ".github/workflows/integration_test.yml"
133
+ - ".github/workflows/ruby.yml"
132
134
  - ".gitignore"
133
135
  - ".rubocop.yml"
134
136
  - ".rubocop_todo.yml"
135
- - ".travis.yml"
136
137
  - CHANGELOG.md
137
138
  - Gemfile
138
139
  - LICENSE.txt
139
140
  - README.md
140
141
  - Rakefile
141
- - circle.yml
142
142
  - inline_svg.gemspec
143
143
  - lib/inline_svg.rb
144
144
  - lib/inline_svg/action_view/helpers.rb
@@ -1,8 +0,0 @@
1
- language: ruby
2
- rvm:
3
- - 2.3
4
- - 2.4
5
- - 2.5
6
- before_install:
7
- - gem install -v 2.0.1 bundler --no-document
8
- script: bundle exec rspec
data/circle.yml DELETED
@@ -1,3 +0,0 @@
1
- machine:
2
- ruby:
3
- version: 2.5.0