Skip to content

Commit

Permalink
Merge pull request #149 from SwedbankPay/feature/menu-order
Browse files Browse the repository at this point in the history
Rename menu-order and add RSpec
  • Loading branch information
asbjornu authored Sep 15, 2020
2 parents 1d44245 + 8a431db commit 8e96ca7
Show file tree
Hide file tree
Showing 26 changed files with 290 additions and 32 deletions.
9 changes: 2 additions & 7 deletions .github/workflows/gem.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,16 @@ jobs:
with:
fetch-depth: 0

- name: Fetch all history for all tags and branches
run: |
git fetch --prune --tags --force
echo "REF: ${{ github.ref }}"
- name: Install GitVersion
uses: gittools/actions/gitversion/setup@v0.9.2
uses: gittools/actions/gitversion/setup@v0.9.4
if: startsWith(github.ref, 'refs/tags/') != true # Only use GitVersion for unstable builds
with:
versionSpec: '5.2.x'

- name: Execute GitVersion
id: gitversion
if: startsWith(github.ref, 'refs/tags/') != true
uses: gittools/actions/gitversion/execute@v0.9.2
uses: gittools/actions/gitversion/execute@v0.9.4

- name: Create gem version number
id: gemversion
Expand Down
37 changes: 37 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,43 @@ jobs:
name: build-site
path: _site

spec:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/cache@v2
with:
path: vendor/bundle
key: ${{ runner.os }}-gems-${{ hashFiles('**/Gemfile.lock') }}
restore-keys: ${{ runner.os }}-gems-

- uses: actions/setup-ruby@v1
with:
ruby-version: '2.7'

- uses: actions/setup-java@v1
with:
java-version: '1.8'

- uses: kamiazya/setup-graphviz@v1

- name: bundle install
run: |
bundle config path vendor/bundle
bundle install --jobs 4 --retry 3
- name: rspec
env:
PAGES_REPO_NWO: ${{ github.repository }}
JEKYLL_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: bundle exec rake

- name: codecov upload
run: bundle exec rake codecov:upload || echo 'Codecov upload failed'

- name: rubocop
run: bundle exec rubocop --fail-level warning --display-only-fail-level-offenses

verify:
runs-on: ubuntu-latest
steps:
Expand Down
1 change: 1 addition & 0 deletions .rspec
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
--require "spec_helper"
12 changes: 12 additions & 0 deletions .rubycop.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
AllCops:
NewCops: enable
Exclude:
- "Rakefile"
- "_site/**/*.rb"
- "spec/**/*.rb"
Layout:
LineLength: 100
IndentationStyle:
IndentationWidth: 2
Metrics/MethodLength:
Max: 20
7 changes: 7 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,10 @@

source 'https://rubygems.org'
gemspec

group :development, :test do
gem 'rspec'
gem 'rubocop', require: false
end

gem 'codecov', require: false, group: :test
42 changes: 42 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,14 @@ GEM
zeitwerk (~> 2.2, >= 2.2.2)
addressable (2.7.0)
public_suffix (>= 2.0.2, < 5.0)
ast (2.4.1)
codecov (0.2.11)
json
simplecov
colorator (1.1.0)
concurrent-ruby (1.1.7)
diff-lcs (1.4.4)
docile (1.3.2)
em-websocket (0.5.1)
eventmachine (>= 0.12.9)
http_parser.rb (~> 0.6.0)
Expand Down Expand Up @@ -81,6 +87,7 @@ GEM
gemoji (~> 3.0)
html-pipeline (~> 2.2)
jekyll (>= 3.0, < 5.0)
json (2.3.1)
kramdown (2.3.0)
rexml
kramdown-parser-gfm (1.1.0)
Expand All @@ -102,6 +109,8 @@ GEM
faraday (>= 0.9)
sawyer (~> 0.8.0, >= 0.5.3)
parallel (1.19.2)
parser (2.7.1.4)
ast (~> 2.4.1)
pathutil (0.16.2)
forwardable-extended (~> 2.6)
public_suffix (4.0.6)
Expand All @@ -110,8 +119,34 @@ GEM
rb-fsevent (0.10.4)
rb-inotify (0.10.1)
ffi (~> 1.0)
regexp_parser (1.7.1)
rexml (3.2.4)
rouge (3.23.0)
rspec (3.9.0)
rspec-core (~> 3.9.0)
rspec-expectations (~> 3.9.0)
rspec-mocks (~> 3.9.0)
rspec-core (3.9.2)
rspec-support (~> 3.9.3)
rspec-expectations (3.9.2)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.9.0)
rspec-mocks (3.9.1)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.9.0)
rspec-support (3.9.3)
rubocop (0.91.0)
parallel (~> 1.10)
parser (>= 2.7.1.1)
rainbow (>= 2.2.2, < 4.0)
regexp_parser (>= 1.7)
rexml
rubocop-ast (>= 0.4.0, < 1.0)
ruby-progressbar (~> 1.7)
unicode-display_width (>= 1.4.0, < 2.0)
rubocop-ast (0.4.0)
parser (>= 2.7.1.4)
ruby-progressbar (1.10.1)
safe_yaml (1.0.5)
sass (3.7.4)
sass-listen (~> 4.0.0)
Expand All @@ -123,6 +158,10 @@ GEM
sawyer (0.8.2)
addressable (>= 2.3.5)
faraday (> 0.8, < 2.0)
simplecov (0.19.0)
docile (~> 1.1)
simplecov-html (~> 0.11)
simplecov-html (0.12.2)
terminal-table (1.8.0)
unicode-display_width (~> 1.1, >= 1.1.1)
thread_safe (0.3.6)
Expand All @@ -139,6 +178,9 @@ PLATFORMS

DEPENDENCIES
bundler
codecov
rspec
rubocop
swedbank-pay-design-guide-jekyll-theme!

BUNDLED WITH
Expand Down
35 changes: 30 additions & 5 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
# coding: utf-8
# frozen_string_literal: true

require 'rake'
require 'rspec/core/rake_task'
require 'rubocop/rake_task'
require 'jekyll'
require 'html-proofer'

Expand All @@ -9,6 +13,27 @@ class String
end
end

RSpec::Core::RakeTask.new(:spec) do |t|
t.pattern = Dir.glob('spec/*_spec.rb')
t.rspec_opts = '--format documentation'
end

desc 'Runs RuboCop'
desc task :rubocop do
RuboCop::RakeTask.new
end

namespace :codecov do
desc 'Uploads the latest SimpleCov result set to codecov.io'
task :upload do
require 'simplecov'
require 'codecov'

formatter = SimpleCov::Formatter::Codecov.new
formatter.format(SimpleCov::ResultMerger.merged_result)
end
end

# Rake Jekyll tasks
task :build do
puts 'Building site...'.bold
Expand All @@ -21,9 +46,9 @@ task :clean do
end

# Test generated output has valid HTML and links.
task :test => :build do
options = { :assume_extension => true }
HTMLProofer.check_directory("./_site", options).run
task test: :build do
options = { assume_extension: true }
HTMLProofer.check_directory('./_site', options).run
end

task :default => ["build"]
task default: ['build']
3 changes: 1 addition & 2 deletions _includes/sidebar.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
{% endif %}

<ul class="main-nav-ul">
{% assign pages = site.pages | sort: 'menu-order' %}
{% assign pages = site.pages | sort: 'menu_order' %}
{% for node in pages %}
{% assign node_parts = node.url | split: '/' %}
{% assign node_depth = node_parts | size %}
Expand Down Expand Up @@ -113,4 +113,3 @@
</ul>
</nav>
</div>

2 changes: 1 addition & 1 deletion checkout-more/index.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
title: Checkout More

menu-order: 10
menu_order: 10
---

## You'd like to checko out
Expand Down
2 changes: 1 addition & 1 deletion checkout/after-payment.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ description: |
icon:
content: add
additional: true
menu-order: 4
menu_order: 4
---

{% include jumbotron.html body="When the consumer has **completed** the entire
Expand Down
2 changes: 1 addition & 1 deletion checkout/capture.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ title: Swedbank Pay Checkout – Capture
estimated_read: 10
card_title: Capture the funds
core: true
menu-order: 3
menu_order: 3
---

## Step 5: Capture the funds
Expand Down
2 changes: 1 addition & 1 deletion checkout/checkin.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ description: |
card_title: Initiate session and display checkin module
estimated_read: 15
core: true
menu-order: 1
menu_order: 1
---

## Step 1: Initiate session for consumer identification
Expand Down
2 changes: 1 addition & 1 deletion checkout/features/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ description: |
icon:
content: remove_red_eye
additional: true
menu-order: 5
menu_order: 5
card_list:
- title: Payment orders
description: When initiating a payment process
Expand Down
2 changes: 1 addition & 1 deletion checkout/features/payment-orders.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
title: Payment Orders
description: |
See what other features you can implement for your checkout
menu-order: 1
menu_order: 1
---

## Payment Orders
Expand Down
2 changes: 1 addition & 1 deletion checkout/features/recurring-payments.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
title: Recurring payments
description: |
See what other features you can implement for your checkout
menu-order: 2
menu_order: 2
---

## Recurring Payments
Expand Down
6 changes: 3 additions & 3 deletions checkout/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ description: |
Swedbank Pay Checkout is a complete reimagination
of the checkout experience, integrating seamlessly into the merchant website
through highly customizable and flexible components.
menu-order: 4
menu_order: 4
card_list:
- card_title: Initiate session for consumer identification
estimated_read: 15
Expand Down Expand Up @@ -34,7 +34,7 @@ card_list in front matter above.
## Core implementation overview

{% assign core_card_list = site.pages | where: 'dir', page.dir | where: 'core', true |
where_exp: 'page', 'page.name != "index.md"' | sort: 'menu-order' %}
where_exp: 'page', 'page.name != "index.md"' | sort: 'menu_order' %}

{% include card-horizontal-list.html card_list=page.card_list %}

Expand All @@ -43,7 +43,7 @@ where_exp: 'page', 'page.name != "index.md"' | sort: 'menu-order' %}

{% assign additional_card_list = site.pages |
where_exp: 'page', 'page.url != "/checkout/" and page.core != true and page.dir contains "/checkout/"'
| where: 'additional', true | sort: 'menu-order'
| where: 'additional', true | sort: 'menu_order'
%}

{% include card-list.html card_list=additional_card_list
Expand Down
2 changes: 1 addition & 1 deletion checkout/payment-menu.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ title: Swedbank Pay Checkout – Payment Menu
estimated_read: 15
card_title: Create and display payment menu
core: true
menu-order: 2
menu_order: 2
---

{% include jumbotron.html body="**Payment Menu** begins where **Checkin** left
Expand Down
2 changes: 1 addition & 1 deletion index.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ description: |
typesetting industry. Lorem Ipsum has been the industry's standard dummy
text ever since the 1500s, when an unknown printer took a galley of type and
scrambled it to make a type specimen book.
menu-order: 0
menu_order: 0
---

Text can be **bold**, _italic_, or ~~strikethrough~~.
Expand Down
4 changes: 3 additions & 1 deletion lib/sidebar.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
require 'json'

module Jekyll
# A nice sidebar
class Sidebar
attr_accessor :hash_pre_render
attr_accessor :filename_with_headers
Expand All @@ -15,7 +16,7 @@ def initialize
end

def pre_render(page)
menu_order = page['menu-order'].nil? ? 0 : page['menu-order']
menu_order = page['menu_order'].nil? ? 0 : page['menu_order']
hide_from_sidebar = page['hide_from_sidebar'].nil? ? false : page['hide_from_sidebar']
url = page['url'].gsub('index.html', '').gsub('.html', '')
@hash_pre_render[url] = {
Expand Down Expand Up @@ -72,6 +73,7 @@ def sanitize_filename(filename)

def generateSubgroup(filename, key, value, all_subgroups, level)
title = value[:title].split('–').last

subsubgroup_list = all_subgroups.select do |subsubgroup_key, _subsubgroup_value|
subsubgroup_key.include? key and subsubgroup_key != key and \
key.split('/').length > level
Expand Down
2 changes: 1 addition & 1 deletion page1.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
title: Page 1
menu-order: 1
menu_order: 1
front_page:
title: design guide theme
hero: Welcome to the Swedbank Pay
Expand Down
2 changes: 1 addition & 1 deletion page2.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
---
title: Page 2
menu-order: 2
menu_order: 2
---
Loading

0 comments on commit 8e96ca7

Please sign in to comment.