Skip to content

Commit

Permalink
Output the proper order of the sites when not alphabetical (2factorau…
Browse files Browse the repository at this point in the history
…th#3067)

* Output the proper order of the sites when not alphabetical

Might be able to batch it within the test two lines above, but this checks the alphabetical-truthiness of the current section and outputs the order they should be in so its easier to fix.

Just something I found very useful for maintaining [acceptbitcoincash/acceptbitcoincash](https://github.com/acceptbitcoincash/acceptbitcoincash)

* spacing change

* changes based on feedback

* silly whitespace

* Minor cleanup

* add diffy to gemfile

* use diffy for colorized contextual diff outputs

* use diff-lcs on windows for diffy

https://github.com/samg/diffy#on-windows

* whoops

* rubocop
  • Loading branch information
kenman345 authored and Carlgo11 committed Jan 29, 2019
1 parent faa5e06 commit 1df2c2f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
2 changes: 2 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ source 'https://rubygems.org'
gem 'github-pages', group: :jekyll_plugins

group :test do
gem 'diff-lcs', platforms: :mswin
gem 'diffy'
gem 'fastimage'
gem 'html-proofer'
gem 'jsonlint'
Expand Down
12 changes: 7 additions & 5 deletions verify.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
require 'yaml'
require 'fastimage'
require 'kwalify'
require 'diffy'
@output = 0

# YAML tags related to TFA
Expand Down Expand Up @@ -89,8 +90,11 @@ def test_img_file(img)
end

# Check section alphabetization
error("_data/#{section['id']}.yml is not alphabetized by name") \
if websites != (websites.sort_by { |website| website['name'].downcase })
if websites != (sites_sort = websites.sort_by { |s| s['name'].downcase })
error("_data/#{section['id']}.yml not ordered by name. Correct order:" \
"\n" + Diffy::Diff.new(websites.to_yaml, sites_sort.to_yaml, \
context: 10).to_s(:color))
end

# Collect list of all images for section
imgs = Dir["img/#{section['id']}/*"]
Expand All @@ -116,11 +120,9 @@ def test_img_file(img)
puts "<------------ ERROR in a YAML file ------------>\n"
puts e
exit 1
# rubocop:disable Style/RescueStandardError
rescue => e
rescue StandardError => e
puts e
exit 1
# rubocop:enable Style/RescueStandardError
else
puts "<------------ No errors. You\'re good to go! ------------>\n"
end

0 comments on commit 1df2c2f

Please sign in to comment.