Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade Ruby and switch to Standard Ruby #49

Merged
merged 1 commit into from
Jun 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,17 @@ jobs:
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v2

- uses: ruby/setup-ruby@v1
with:
ruby-version: 2.7.3
ruby-version: 3.3
bundler-cache: true # runs 'bundle install' and caches installed gems automatically

- name: Run linting and unit tests
run: |
gem install bundler
bundle install --jobs 4 --retry 3
bundle exec rubocop -c .rubocop.yml
bundle exec standardrb
bundle exec rake test

- name: Validate the glossary
Expand Down
10 changes: 5 additions & 5 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
source 'https://rubygems.org'
source "https://rubygems.org"

ruby '~> 2.7'
ruby "~> 3"

gem 'minitest-reporters'
gem 'rake'
gem 'rubocop', '~> 1.25', require: false
gem "minitest-reporters"
gem "rake"
gem "standard"
62 changes: 43 additions & 19 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3,44 +3,68 @@ GEM
specs:
ansi (1.5.0)
ast (2.4.2)
builder (3.2.4)
minitest (5.15.0)
minitest-reporters (1.5.0)
builder (3.3.0)
json (2.7.2)
language_server-protocol (3.17.0.3)
lint_roller (1.1.0)
minitest (5.23.1)
minitest-reporters (1.6.1)
ansi
builder
minitest (>= 5.0)
ruby-progressbar
parallel (1.21.0)
parser (3.1.0.0)
parallel (1.24.0)
parser (3.3.2.0)
ast (~> 2.4.1)
racc
racc (1.8.0)
rainbow (3.1.1)
rake (13.0.6)
regexp_parser (2.2.0)
rexml (3.2.5)
rubocop (1.25.1)
rake (13.2.1)
regexp_parser (2.9.2)
rexml (3.2.8)
strscan (>= 3.0.9)
rubocop (1.63.5)
json (~> 2.3)
language_server-protocol (>= 3.17.0)
parallel (~> 1.10)
parser (>= 3.1.0.0)
parser (>= 3.3.0.2)
rainbow (>= 2.2.2, < 4.0)
regexp_parser (>= 1.8, < 3.0)
rexml
rubocop-ast (>= 1.15.1, < 2.0)
rexml (>= 3.2.5, < 4.0)
rubocop-ast (>= 1.31.1, < 2.0)
ruby-progressbar (~> 1.7)
unicode-display_width (>= 1.4.0, < 3.0)
rubocop-ast (1.15.1)
parser (>= 3.0.1.1)
ruby-progressbar (1.11.0)
unicode-display_width (2.1.0)
unicode-display_width (>= 2.4.0, < 3.0)
rubocop-ast (1.31.3)
parser (>= 3.3.1.0)
rubocop-performance (1.21.0)
rubocop (>= 1.48.1, < 2.0)
rubocop-ast (>= 1.31.1, < 2.0)
ruby-progressbar (1.13.0)
standard (1.36.0)
language_server-protocol (~> 3.17.0.2)
lint_roller (~> 1.0)
rubocop (~> 1.63.0)
standard-custom (~> 1.0.0)
standard-performance (~> 1.4)
standard-custom (1.0.2)
lint_roller (~> 1.0)
rubocop (~> 1.50)
standard-performance (1.4.0)
lint_roller (~> 1.1)
rubocop-performance (~> 1.21.0)
strscan (3.1.0)
unicode-display_width (2.5.0)

PLATFORMS
ruby

DEPENDENCIES
minitest-reporters
rake
rubocop (~> 1.25)
standard

RUBY VERSION
ruby 2.7.3p183
ruby 3.2.3p157

BUNDLED WITH
2.1.4
2 changes: 1 addition & 1 deletion Rakefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
task default: :test
task :test do
Dir.glob('./test/*_test.rb').each { |file| require file }
Dir.glob("./test/*_test.rb").each { |file| require file }
end
38 changes: 19 additions & 19 deletions lib/markdownify.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# frozen_string_literal: true

# Thanks https://avdi.codes/recursively-symbolize-keys/
require 'yaml'
require './lib/common'
require './lib/validate'
require "yaml"
require "./lib/common"
require "./lib/validate"

# Turn a validated glossary into a linked Markdown file
class Markdownify
Expand All @@ -12,23 +12,23 @@ class Markdownify
attr_reader :data, :path, :output

def initialize(path = nil, outpath = nil)
@path = path || './glossary.yml'
@output = outpath || './glossary.md'
@path = path || "./glossary.yml"
@output = outpath || "./glossary.md"
@data = sort_data(
symbolize_keys(
YAML.load_file(@path)
YAML.load_file(@path, aliases: true)
)
)
end

def perform
File.open(output, 'w') { |file| file << _perform }
File.open(output, "w") { |file| file << _perform }
puts "\nSuccess! Check out your file at #{output}"
end

def _perform
before_perform
str = ''
str = ""
str += "### Acronyms & Initialisms\n\n"
str += acronym_content
str += "\n\n"
Expand All @@ -38,11 +38,11 @@ def _perform
end

def acronym_content
str = ''
str = ""
str += "| | |\n|-|-|\n" # table header
build_tags_by_letter.sort.map do |letter, tags|
str += "| #{letter} | "
str += "#{tags.join(' &bull; ')} |"
str += "#{tags.join(" &bull; ")} |"
str += "\n"
end
str
Expand All @@ -54,13 +54,13 @@ def build_tags_by_letter
tag = tag_for_acronym(key, values)
next if tag.nil?

results[key.to_s.chars.first.upcase] << tag
results[key.to_s[0].upcase] << tag
end
results
end

def tag_for_acronym(key, values)
case Array(values[:term]).count
case Array(values[:term]).size
when 0
nil
when 1
Expand All @@ -79,7 +79,7 @@ def tag_for_single_term(key, values)
def tag_for_multiple_terms(key, values)
term_links = values[:term].map.with_index do |term, i|
"[(#{i + 1})](#{goto term})"
end.join(' ')
end.join(" ")
<<~TAG
<a name="acronym-#{key}"></a>#{key} #{term_links}
TAG
Expand All @@ -92,7 +92,7 @@ def definition_content
end

def build_definition(key, values)
str = ''
str = ""
str += "**#{anchor(key)}#{self_link(key)}**"
str += (acronym?(key) ? " (#{acronym_for(key).first}) \\\n" : " \\\n")
str += description_content(values)
Expand All @@ -117,7 +117,7 @@ def description_content(values)
def overloaded_acronym?(key)
if acronym?(key)
_, values = acronym_for(key)
Array(values[:term]).count > 1
Array(values[:term]).size > 1
else
false
end
Expand Down Expand Up @@ -178,7 +178,7 @@ def anchor(key)
end

def slug(key)
key.to_s.downcase.gsub(/\s+/, '-')
key.to_s.downcase.gsub(/\s+/, "-")
end

private
Expand All @@ -193,12 +193,12 @@ def sort_data(data)
data[:entries].each do |entry|
key, values = entry
case values[:type]
when 'acronym'
when "acronym"
acronyms[key] = values
when 'term'
when "term"
terms[key] = values
end
end
{ acronyms: acronyms, terms: terms }
{acronyms: acronyms, terms: terms}
end
end
Loading
Loading