From 2d74352ca7a092aed1ad4721e3a25e2565843bfe Mon Sep 17 00:00:00 2001 From: Daniel Granerud Date: Thu, 28 May 2020 10:09:23 +0200 Subject: [PATCH 1/9] Update file usage in rakefile as recommended --- Rakefile | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/Rakefile b/Rakefile index 9c51f9d..f58aee2 100644 --- a/Rakefile +++ b/Rakefile @@ -27,14 +27,15 @@ end # Test generated output has valid HTML and links. task :test => :build do - file = File.open("_site/index.html") - content = file.read + File.open("_site/index.html") do |file| + content = file.read - if content.include? "{% icon" - raise "Hell" - end + if content.include? "{% icon" + raise "Hell" + end - file.close + file.close + end end task :default => ["build"] From 8bf9afb93cd63099dbe54907f4ced16d479e787b Mon Sep 17 00:00:00 2001 From: Daniel Granerud Date: Thu, 28 May 2020 13:29:06 +0200 Subject: [PATCH 2/9] Add support for class name --- lib/jekyll-material-icon-tag.rb | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/lib/jekyll-material-icon-tag.rb b/lib/jekyll-material-icon-tag.rb index 2394403..88324df 100644 --- a/lib/jekyll-material-icon-tag.rb +++ b/lib/jekyll-material-icon-tag.rb @@ -8,7 +8,19 @@ def initialize(tag_name, text, tokens) end def render(_) - "#{@text.strip}" + iconname, type = parse_parameters(@text) + + unless type.nil? + "#{iconname.strip}" + else + "#{iconname.strip}" + end + end + + def parse_parameters(context) + parameters = Liquid::Template.parse(@markup).render context + parameters.strip! + parameters.split(/\s+/) end Liquid::Template.register_tag "icon", self From c4a40b0f3ca20ee63938585f3919154a43d6afe0 Mon Sep 17 00:00:00 2001 From: Daniel Granerud Date: Thu, 28 May 2020 13:35:51 +0200 Subject: [PATCH 3/9] Add tests for new functionality --- Rakefile | 4 ++++ test/jekyll-material-icon-tag/index.md | 2 ++ 2 files changed, 6 insertions(+) diff --git a/Rakefile b/Rakefile index f58aee2..a1b45cd 100644 --- a/Rakefile +++ b/Rakefile @@ -34,6 +34,10 @@ task :test => :build do raise "Hell" end + if content.exclude? "material-icons-two-tone" + raise "Hell of two tones" + end + file.close end end diff --git a/test/jekyll-material-icon-tag/index.md b/test/jekyll-material-icon-tag/index.md index 68e3c1b..b750afc 100644 --- a/test/jekyll-material-icon-tag/index.md +++ b/test/jekyll-material-icon-tag/index.md @@ -5,3 +5,5 @@ layout: home # About This page test the {% icon check %} gem. +It also supports different {% icon alarm_on two-tone %} styles +{% icon aspect_ratio round %}. From 22322d0db2b2cdbba48d67cc2a5bafad92e27cc6 Mon Sep 17 00:00:00 2001 From: Daniel Granerud Date: Thu, 28 May 2020 13:43:48 +0200 Subject: [PATCH 4/9] Fix tests and update checks for new syntax --- Rakefile | 2 +- lib/jekyll-material-icon-tag.rb | 11 +++++++---- test/jekyll-material-icon-tag/index.md | 2 +- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/Rakefile b/Rakefile index a1b45cd..3914438 100644 --- a/Rakefile +++ b/Rakefile @@ -34,7 +34,7 @@ task :test => :build do raise "Hell" end - if content.exclude? "material-icons-two-tone" + unless content.include? "material-icons-two-tone" raise "Hell of two tones" end diff --git a/lib/jekyll-material-icon-tag.rb b/lib/jekyll-material-icon-tag.rb index 88324df..529266f 100644 --- a/lib/jekyll-material-icon-tag.rb +++ b/lib/jekyll-material-icon-tag.rb @@ -8,16 +8,19 @@ def initialize(tag_name, text, tokens) end def render(_) - iconname, type = parse_parameters(@text) + iconname, type = parse_parameters @text - unless type.nil? - "#{iconname.strip}" - else + puts type + + if type.nil? "#{iconname.strip}" + else + "#{iconname.strip}" end end def parse_parameters(context) + puts "Parsing parameters" parameters = Liquid::Template.parse(@markup).render context parameters.strip! parameters.split(/\s+/) diff --git a/test/jekyll-material-icon-tag/index.md b/test/jekyll-material-icon-tag/index.md index b750afc..6096e26 100644 --- a/test/jekyll-material-icon-tag/index.md +++ b/test/jekyll-material-icon-tag/index.md @@ -5,5 +5,5 @@ layout: home # About This page test the {% icon check %} gem. -It also supports different {% icon alarm_on two-tone %} styles +It also supports different {% icon alarm_on two-tone %} styles {% icon aspect_ratio round %}. From f37383736d89c098a203af2b3b32ed1a04b656f9 Mon Sep 17 00:00:00 2001 From: Daniel Granerud Date: Thu, 28 May 2020 13:49:34 +0200 Subject: [PATCH 5/9] Fix errors in code, add another test --- Rakefile | 4 ++++ lib/jekyll-material-icon-tag.rb | 8 +++----- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/Rakefile b/Rakefile index 3914438..ef9dca9 100644 --- a/Rakefile +++ b/Rakefile @@ -38,6 +38,10 @@ task :test => :build do raise "Hell of two tones" end + unless content.include? "material-icons-two-tone" + raise "Hell of two tones" + end + file.close end end diff --git a/lib/jekyll-material-icon-tag.rb b/lib/jekyll-material-icon-tag.rb index 529266f..32165af 100644 --- a/lib/jekyll-material-icon-tag.rb +++ b/lib/jekyll-material-icon-tag.rb @@ -19,11 +19,9 @@ def render(_) end end - def parse_parameters(context) - puts "Parsing parameters" - parameters = Liquid::Template.parse(@markup).render context - parameters.strip! - parameters.split(/\s+/) + def parse_parameters(text) + text.strip! + text.split(/\s+/) end Liquid::Template.register_tag "icon", self From a2974a19f730960c7b9f20919decd63a5139582a Mon Sep 17 00:00:00 2001 From: Daniel Granerud Date: Thu, 28 May 2020 13:51:53 +0200 Subject: [PATCH 6/9] Update documentation --- README.md | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 0d713a3..2ee040e 100644 --- a/README.md +++ b/README.md @@ -7,12 +7,15 @@ gem 'jekyll-material-icon-tag' ``` And then execute: + ```shell -$ bundle install +bundle install ``` + Or install it yourself as: + ```shell -$ gem install jekyll-material-icon-tag +gem install jekyll-material-icon-tag ``` ## Usage @@ -25,9 +28,17 @@ To render a Material Design Icon use as follows: {% icon name_of_icon_you_want %} ``` +You can also add style if you want a different material icon style: + +```liquid +{% icon name_of_icon_you_want two-tone %} +{% icon another_icon_perhaps round %} +{% icon the_outlined_one outlined %} +``` + ## Contributing -Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/jekyll-material-icon-tag. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/[USERNAME]/jekyll-material-icon-tag/blob/master/CODE_OF_CONDUCT.md). +Bug reports and pull requests are welcome on GitHub at ]/jekyll-material-icon-tag. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/[USERNAME]/jekyll-material-icon-tag/blob/master/CODE_OF_CONDUCT.md). ## License From acd311963eb46315236f079ac83a37bcea685e7a Mon Sep 17 00:00:00 2001 From: Daniel Granerud <42067409+NullableInt@users.noreply.github.com> Date: Thu, 28 May 2020 15:03:08 +0200 Subject: [PATCH 7/9] Apply suggestions from code review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Asbjørn Ulsberg --- README.md | 2 +- lib/jekyll-material-icon-tag.rb | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/README.md b/README.md index 2ee040e..f3ecf46 100644 --- a/README.md +++ b/README.md @@ -38,7 +38,7 @@ You can also add style if you want a different material icon style: ## Contributing -Bug reports and pull requests are welcome on GitHub at ]/jekyll-material-icon-tag. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/[USERNAME]/jekyll-material-icon-tag/blob/master/CODE_OF_CONDUCT.md). +Bug reports and pull requests are welcome on GitHub at #{iconname.strip}" From f22d09419fb653e036f72708b9761534f662ac2c Mon Sep 17 00:00:00 2001 From: Daniel Granerud Date: Thu, 28 May 2020 15:04:09 +0200 Subject: [PATCH 8/9] Remove unwanted whitespace --- lib/jekyll-material-icon-tag.rb | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/jekyll-material-icon-tag.rb b/lib/jekyll-material-icon-tag.rb index 20df9ce..1878db9 100644 --- a/lib/jekyll-material-icon-tag.rb +++ b/lib/jekyll-material-icon-tag.rb @@ -10,7 +10,6 @@ def initialize(tag_name, text, tokens) def render(_) iconname, type = parse_parameters @text - if type.nil? "#{iconname.strip}" else From 7cf35e269030923e5c0b7168c70e2b3beca8ebdf Mon Sep 17 00:00:00 2001 From: Daniel Granerud Date: Thu, 28 May 2020 15:05:24 +0200 Subject: [PATCH 9/9] Update workflow to trigger on all branches --- .github/workflows/gempush.yml | 198 +++++++++++++++++----------------- 1 file changed, 96 insertions(+), 102 deletions(-) diff --git a/.github/workflows/gempush.yml b/.github/workflows/gempush.yml index 7db6e26..5f3ff3c 100644 --- a/.github/workflows/gempush.yml +++ b/.github/workflows/gempush.yml @@ -1,12 +1,6 @@ name: Ruby Gem -on: - push: - branches: [ master ] - tags: - - '*' - pull_request: - branches: [ master ] +on: [pull_request, push] jobs: build: @@ -14,98 +8,98 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 - - - name: Fetch all history for all tags and branches - run: | - git fetch --prune --unshallow --tags - echo "REF: ${{ github.ref }}" - - - name: Install GitVersion - uses: gittools/actions/gitversion/setup@v0.9.2 - with: - versionSpec: '5.2.x' - - - name: Execute GitVersion - id: gitversion - uses: gittools/actions/gitversion/execute@v0.9.2 - - - name: Version variables for unstable builds - id: unstable - if: startsWith(github.ref, 'refs/tags/') != true - env: - LABEL: ${{ steps.gitversion.outputs.preReleaseTagWithDash }}.${{ steps.gitversion.outputs.commitsSinceVersionSourcePadded }} - run: | - echo "Pre-release: ${LABEL}" - echo "::set-output name=label::${LABEL}" - - - name: Create gem version number - id: gemversion - env: - GEM_VERSION: "${{ steps.gitversion.outputs.majorMinorPatch }}${{ steps.unstable.outputs.label }}" - run: | - echo "Gem version: ${GEM_VERSION}" - echo "::set-output name=version::${GEM_VERSION}" - - - name: Set up Ruby 2.6 - uses: actions/setup-ruby@v1 - with: - ruby-version: 2.6.x - - - name: Cache dependencies - uses: actions/cache@v1 - with: - path: vendor/bundle - key: ${{ runner.os }}-gems-${{ hashFiles('**/Gemfile.lock') }} - restore-keys: ${{ runner.os }}-gems- - - - name: Bundle install - run: | - gem install bundler - bundle config path vendor/bundle - bundle install --jobs 4 --retry 3 - - - name: Build gem - id: gem - env: - GEM_VERSION: ${{ steps.gemversion.outputs.version }} - run: | - GEM_BUILD_NAME=$(gem build jekyll-material-icon-tag.gemspec | awk '/File/ {print $2}') - echo "Gem filename: '${GEM_BUILD_NAME}'" - echo "::set-output name=name::${GEM_BUILD_NAME}" - - - name: Test gem - run: | - bundle exec rake test - - - name: Upload artifact - uses: actions/upload-artifact@v2-preview - with: - name: ${{ steps.gem.outputs.name }} - path: ${{ steps.gem.outputs.name }} - - - name: Publish to GPR - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - OWNER: SwedbankPay - run: | - mkdir -p $HOME/.gem - touch $HOME/.gem/credentials - chmod 0600 $HOME/.gem/credentials - printf -- "---\n:github: Bearer ${GITHUB_TOKEN}\n" > $HOME/.gem/credentials - set -e - gem push --KEY github \ - --host https://rubygems.pkg.github.com/${OWNER} \ - ${{ steps.gem.outputs.name }} \ - || echo "push failed ($?) probably due to version '${{ steps.gemversion.outputs.version }}' already existing in GPR." - - - name: Publish to RubyGems - if: startsWith(github.ref, 'refs/tags/') # Only publish tagged commits - env: - RUBYGEMS_API_KEY: ${{ secrets.RUBYGEMS_API_KEY }} - run: | - mkdir -p $HOME/.gem - touch $HOME/.gem/credentials - chmod 0600 $HOME/.gem/credentials - printf -- "---\n:rubygems_api_key: ${RUBYGEMS_API_KEY}\n" > $HOME/.gem/credentials - gem push ${{ steps.gem.outputs.name }} + - uses: actions/checkout@v2 + + - name: Fetch all history for all tags and branches + run: | + git fetch --prune --unshallow --tags + echo "REF: ${{ github.ref }}" + + - name: Install GitVersion + uses: gittools/actions/gitversion/setup@v0.9.2 + with: + versionSpec: "5.2.x" + + - name: Execute GitVersion + id: gitversion + uses: gittools/actions/gitversion/execute@v0.9.2 + + - name: Version variables for unstable builds + id: unstable + if: startsWith(github.ref, 'refs/tags/') != true + env: + LABEL: ${{ steps.gitversion.outputs.preReleaseTagWithDash }}.${{ steps.gitversion.outputs.commitsSinceVersionSourcePadded }} + run: | + echo "Pre-release: ${LABEL}" + echo "::set-output name=label::${LABEL}" + + - name: Create gem version number + id: gemversion + env: + GEM_VERSION: "${{ steps.gitversion.outputs.majorMinorPatch }}${{ steps.unstable.outputs.label }}" + run: | + echo "Gem version: ${GEM_VERSION}" + echo "::set-output name=version::${GEM_VERSION}" + + - name: Set up Ruby 2.6 + uses: actions/setup-ruby@v1 + with: + ruby-version: 2.6.x + + - name: Cache dependencies + uses: actions/cache@v1 + with: + path: vendor/bundle + key: ${{ runner.os }}-gems-${{ hashFiles('**/Gemfile.lock') }} + restore-keys: ${{ runner.os }}-gems- + + - name: Bundle install + run: | + gem install bundler + bundle config path vendor/bundle + bundle install --jobs 4 --retry 3 + + - name: Build gem + id: gem + env: + GEM_VERSION: ${{ steps.gemversion.outputs.version }} + run: | + GEM_BUILD_NAME=$(gem build jekyll-material-icon-tag.gemspec | awk '/File/ {print $2}') + echo "Gem filename: '${GEM_BUILD_NAME}'" + echo "::set-output name=name::${GEM_BUILD_NAME}" + + - name: Test gem + run: | + bundle exec rake test + + - name: Upload artifact + uses: actions/upload-artifact@v2-preview + with: + name: ${{ steps.gem.outputs.name }} + path: ${{ steps.gem.outputs.name }} + + - name: Publish to GPR + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + OWNER: SwedbankPay + run: | + mkdir -p $HOME/.gem + touch $HOME/.gem/credentials + chmod 0600 $HOME/.gem/credentials + printf -- "---\n:github: Bearer ${GITHUB_TOKEN}\n" > $HOME/.gem/credentials + set -e + gem push --KEY github \ + --host https://rubygems.pkg.github.com/${OWNER} \ + ${{ steps.gem.outputs.name }} \ + || echo "push failed ($?) probably due to version '${{ steps.gemversion.outputs.version }}' already existing in GPR." + + - name: Publish to RubyGems + if: startsWith(github.ref, 'refs/tags/') # Only publish tagged commits + env: + RUBYGEMS_API_KEY: ${{ secrets.RUBYGEMS_API_KEY }} + run: | + mkdir -p $HOME/.gem + touch $HOME/.gem/credentials + chmod 0600 $HOME/.gem/credentials + printf -- "---\n:rubygems_api_key: ${RUBYGEMS_API_KEY}\n" > $HOME/.gem/credentials + gem push ${{ steps.gem.outputs.name }}