diff --git a/.github/workflows/integration_test.yml b/.github/workflows/integration_test.yml new file mode 100644 index 0000000..e026d7e --- /dev/null +++ b/.github/workflows/integration_test.yml @@ -0,0 +1,58 @@ +name: Integration Tests + +on: [push] + +jobs: + build: + + runs-on: ubuntu-latest + strategy: + matrix: + test-branch: [rails3, rails4, main, rails6, rails6-webpacker] + steps: + - name: Checkout + uses: actions/checkout@v2 + - name: Checkout test app + uses: actions/checkout@v2 + with: + repository: jamesmartin/inline_svg_test_app + ref: ${{ matrix.test-branch }} + path: test_app + - name: Set up Ruby 2.6 + uses: actions/setup-ruby@v1 + with: + ruby-version: 2.6.x + - name: Build local gem + run: | + gem install bundler + bundle install --jobs 4 --retry 3 + bundle exec rake build + - name: Use the local gem in the test App + id: uselocalgem + uses: jacobtomlinson/gha-find-replace@0.1.1 + with: + find: "gem 'inline_svg'" + replace: "gem 'inline_svg', path: '${{github.workspace}}'" + - name: Check local gem in use + run: | + test "${{ steps.uselocalgem.outputs.modifiedFiles }}" != "0" + grep "inline_svg" $GITHUB_WORKSPACE/test_app/Gemfile + - name: Bundle + run: | + cd $GITHUB_WORKSPACE/test_app + bundle install --jobs 4 --retry 3 + - name: Set up Node.js 12.x + uses: actions/setup-node@v1 + with: + node-version: 12.x + if: matrix.test-branch == 'rails6-webpacker' + - name: Generate Webpacker config + run: | + cd $GITHUB_WORKSPACE/test_app + yarn install --check-files + bundle exec rake webpacker:compile + if: matrix.test-branch == 'rails6-webpacker' + - name: Test + run: | + cd $GITHUB_WORKSPACE/test_app + bundle exec rake test diff --git a/.github/workflows/ruby.yml b/.github/workflows/ruby.yml new file mode 100644 index 0000000..9769f86 --- /dev/null +++ b/.github/workflows/ruby.yml @@ -0,0 +1,20 @@ +name: Ruby + +on: [push] + +jobs: + build: + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + - name: Set up Ruby 2.6 + uses: actions/setup-ruby@v1 + with: + ruby-version: 2.6.x + - name: Build and test with Rake + run: | + gem install bundler + bundle install --jobs 4 --retry 3 + bundle exec rake diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 5d28cb3..0000000 --- a/.travis.yml +++ /dev/null @@ -1,8 +0,0 @@ -language: ruby -rvm: - - 2.3 - - 2.4 - - 2.5 -before_install: - - gem install -v 2.0.1 bundler --no-rdoc --no-ri -script: bundle exec rspec diff --git a/CHANGELOG.md b/CHANGELOG.md index 9c414b5..00d17e8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,8 +3,33 @@ All notable changes to this project will be documented in this file. This project adheres to [Semantic Versioning](http://semver.org/). ## [Unreleased][unreleased] + - Nothing +## [1.7.2] - 2020-12-07 +### Fixed +- Improve performance of `CachedAssetFile`. [#118](https://github.com/jamesmartin/inline_svg/pull/118). Thanks [@stevendaniels](https://github.com/stevendaniels) +- Avoid XSS by preventing malicious input of filenames. [#117](https://github.com/jamesmartin/inline_svg/pull/117). Thanks [@pbyrne](https://github.com/pbyrne). + +## [1.7.1] - 2020-03-17 +### Fixed +- 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) + +## [1.7.0] - 2020-02-13 +### Added +- 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) + +### Fixed +- 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) +- 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) + + +## [1.6.0] - 2019-11-13 +### Added +- Support Webpack via the new `inline_svg_pack_tag` helper and deprecate `inline_svg` helper in preparation for v2.0. +[#103](https://github.com/jamesmartin/inline_svg/pull/103) +Thanks, [@kylefox](https://github.com/kylefox) + ## [1.5.2] - 2019-06-20 ### Fixed - Revert automatic Webpack asset finder behavior. Make Webpack "opt-in". @@ -214,7 +239,11 @@ transformations](https://github.com/jamesmartin/inline_svg/blob/master/README.md ### Added - Basic Railtie and view helper to inline SVG documents to Rails views. -[unreleased]: https://github.com/jamesmartin/inline_svg/compare/v1.5.2...HEAD +[unreleased]: https://github.com/jamesmartin/inline_svg/compare/v1.7.2...HEAD +[1.7.2]: https://github.com/jamesmartin/inline_svg/compare/v1.7.1...v1.7.2 +[1.7.1]: https://github.com/jamesmartin/inline_svg/compare/v1.7.0...v1.7.1 +[1.7.0]: https://github.com/jamesmartin/inline_svg/compare/v1.6.0...v1.7.0 +[1.6.0]: https://github.com/jamesmartin/inline_svg/compare/v1.5.2...v1.6.0 [1.5.2]: https://github.com/jamesmartin/inline_svg/compare/v1.5.1...v1.5.2 [1.5.1]: https://github.com/jamesmartin/inline_svg/compare/v1.5.0...v1.5.1 [1.5.0]: https://github.com/jamesmartin/inline_svg/compare/v1.4.0...v1.5.0 diff --git a/README.md b/README.md index ebfb66f..cfb2558 100644 --- a/README.md +++ b/README.md @@ -1,12 +1,13 @@ # Inline SVG -[](https://travis-ci.org/jamesmartin/inline_svg) + + Styling a SVG document with CSS for use on the web is most reliably achieved by [adding classes to the document and embedding](http://css-tricks.com/using-svg/) it inline in the HTML. -This gem adds a Rails helper method (`inline_svg`) that reads an SVG document (via Sprockets or Webpacker, so works with the Rails Asset Pipeline), applies a CSS class attribute to the root of the document and +This gem adds Rails helper methods (`inline_svg_tag` and `inline_svg_pack_tag`) that read an SVG document (via Sprockets or Webpacker, so works with the Rails Asset Pipeline), applies a CSS class attribute to the root of the document and then embeds it into a view. Inline SVG supports: @@ -16,18 +17,6 @@ Inline SVG supports: - [Rails 5](http://weblog.rubyonrails.org/2016/6/30/Rails-5-0-final/) (from [v0.10.0](https://github.com/jamesmartin/inline_svg/releases/tag/v0.10.0)) - [Rails 6](https://weblog.rubyonrails.org/2019/4/24/Rails-6-0-rc1-released/) with Sprockets or Webpacker (from [v1.5.2](https://github.com/jamesmartin/inline_svg/releases/tag/v1.5.2)). -## Webpacker - - -Webpacker support is currently "opt-in" and must be manually configured like -so: - -```ruby -InlineSvg.configure do |config| - config.asset_finder = InlineSvg::WebpackAssetFinder -end -``` - ## Changelog This project adheres to [Semantic Versioning](http://semver.org). All notable changes are documented in the @@ -49,9 +38,15 @@ Or install it yourself as: ## Usage +```ruby +# Sprockets +inline_svg_tag(file_name, options={}) + +# Webpacker +inline_svg_pack_tag(file_name, options={}) ``` -inline_svg(file_name, options={}) -``` + +_**Note:** The remainder of this README uses `inline_svg_tag` for examples, but the exact same principles work for `inline_svg_pack_tag`._ The `file_name` can be a full path to a file, the file's basename or an `IO` object. The @@ -69,7 +64,7 @@ Here's an example of embedding an SVG document and applying a 'class' attribute: