Skip to content

Commit

Permalink
Fix logs and console for Ruby 3.3 (#834)
Browse files Browse the repository at this point in the history
* Fix log writer and console for Ruby 3.3

* Add csv gem as explicit

* Add Ruby 3.3.0 to GitHub test matrix

* Update Gemfile.lock

* Update local Nokogiri

* Move away from Ruby 2.7 in CI

* Update local Nokolexbor

* test fixes
  • Loading branch information
jaredcwhite authored Jan 2, 2024
1 parent 0ab9874 commit bd75129
Show file tree
Hide file tree
Showing 12 changed files with 75 additions and 63 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
ruby_version: [2.7.2, 3.0.0, 3.1.2, 3.2.0]
ruby_version: [3.0.0, 3.1.2, 3.2.0, 3.3.0]
continue-on-error: ${{ endsWith(matrix.ruby, 'head') || matrix.ruby == 'debug' }}
# Has to be top level to cache properly
env:
Expand Down
2 changes: 1 addition & 1 deletion .ruby-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
ruby-2.7.2
ruby-3.0.6
93 changes: 51 additions & 42 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ PATH
addressable (~> 2.4)
amazing_print (~> 1.2)
colorator (~> 1.0)
csv (~> 3.2)
erubi (~> 1.9)
faraday (~> 2.0)
faraday-follow_redirects (~> 0.3)
Expand Down Expand Up @@ -47,25 +48,33 @@ PATH
GEM
remote: https://rubygems.org/
specs:
activemodel (7.0.7.2)
activesupport (= 7.0.7.2)
activesupport (7.0.7.2)
activemodel (7.1.2)
activesupport (= 7.1.2)
activesupport (7.1.2)
base64
bigdecimal
concurrent-ruby (~> 1.0, >= 1.0.2)
connection_pool (>= 2.2.5)
drb
i18n (>= 1.6, < 2)
minitest (>= 5.1)
mutex_m
tzinfo (~> 2.0)
addressable (2.8.5)
addressable (2.8.6)
public_suffix (>= 2.0.2, < 6.0)
amazing_print (1.5.0)
ansi (1.5.0)
ast (2.4.2)
backport (1.2.0)
base64 (0.1.1)
benchmark (0.2.1)
benchmark-ips (2.12.0)
base64 (0.2.0)
benchmark (0.3.0)
benchmark-ips (2.13.0)
bigdecimal (3.1.5)
builder (3.2.4)
colorator (1.1.0)
concurrent-ruby (1.2.2)
connection_pool (2.4.1)
csv (3.2.8)
cucumber (8.0.0)
builder (~> 3.2, >= 3.2.4)
cucumber-ci-environment (~> 9.0, >= 9.0.4)
Expand All @@ -92,21 +101,24 @@ GEM
cucumber-tag-expressions (4.1.0)
diff-lcs (1.5.0)
docile (1.4.0)
drb (2.2.0)
ruby2_keywords
e2mmap (0.1.0)
erubi (1.12.0)
faraday (2.7.10)
faraday (2.8.1)
base64
faraday-net_http (>= 2.0, < 3.1)
ruby2_keywords (>= 0.0.4)
faraday-follow_redirects (0.3.0)
faraday (>= 1, < 3)
faraday-net_http (3.0.2)
ffi (1.15.5)
ffi (1.16.3)
hash_with_dot_access (1.2.0)
activesupport (>= 5.0.0, < 8.0)
i18n (1.14.1)
concurrent-ruby (~> 1.0)
jaro_winkler (1.5.6)
json (2.6.3)
json (2.7.1)
kramdown (2.4.0)
rexml
kramdown-parser-gfm (1.1.0)
Expand All @@ -119,49 +131,47 @@ GEM
memory_profiler (1.0.1)
mime-types (3.5.1)
mime-types-data (~> 3.2015)
mime-types-data (3.2023.0808)
mini_portile2 (2.8.4)
minitest (5.19.0)
mime-types-data (3.2023.1205)
mini_portile2 (2.8.5)
minitest (5.20.0)
minitest-profile (0.0.2)
minitest-reporters (1.6.1)
ansi
builder
minitest (>= 5.0)
ruby-progressbar
multi_test (1.1.0)
nokogiri (1.15.4)
mutex_m (0.2.0)
nokogiri (1.16.0)
mini_portile2 (~> 2.8.2)
racc (~> 1.4)
nokogiri (1.15.4-arm64-darwin)
nokogiri (1.16.0-arm64-darwin)
racc (~> 1.4)
nokogiri (1.15.4-x86_64-darwin)
nokogiri (1.16.0-x86_64-darwin)
racc (~> 1.4)
nokogiri (1.15.4-x86_64-linux)
nokogiri (1.16.0-x86_64-linux)
racc (~> 1.4)
nokolexbor (0.5.0)
nokolexbor (0.5.0-arm64-darwin)
nokolexbor (0.5.0-x86_64-darwin)
nokolexbor (0.5.0-x86_64-linux)
parallel (1.23.0)
parser (3.2.2.3)
nokolexbor (0.5.2)
parallel (1.24.0)
parser (3.2.2.4)
ast (~> 2.4.1)
racc
public_suffix (5.0.3)
racc (1.7.1)
public_suffix (5.0.4)
racc (1.7.3)
rack (3.0.8)
rack-test (2.1.0)
rack (>= 1.3)
rainbow (3.1.1)
rake (13.0.6)
rake (13.1.0)
rb-fsevent (0.11.2)
rb-inotify (0.10.1)
ffi (~> 1.0)
rbs (2.8.4)
regexp_parser (2.8.1)
regexp_parser (2.8.3)
reverse_markdown (2.1.1)
nokogiri
rexml (3.2.6)
roda (3.71.0)
roda (3.75.0)
rack
rouge (3.30.0)
rspec (3.12.0)
Expand All @@ -177,26 +187,25 @@ GEM
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.12.0)
rspec-support (3.12.1)
rubocop (1.56.2)
base64 (~> 0.1.1)
rubocop (1.59.0)
json (~> 2.3)
language_server-protocol (>= 3.17.0)
parallel (~> 1.10)
parser (>= 3.2.2.3)
parser (>= 3.2.2.4)
rainbow (>= 2.2.2, < 4.0)
regexp_parser (>= 1.8, < 3.0)
rexml (>= 3.2.5, < 4.0)
rubocop-ast (>= 1.28.1, < 2.0)
rubocop-ast (>= 1.30.0, < 2.0)
ruby-progressbar (~> 1.7)
unicode-display_width (>= 2.4.0, < 3.0)
rubocop-ast (1.29.0)
rubocop-ast (1.30.0)
parser (>= 3.2.1.0)
rubocop-bridgetown (0.3.2)
rubocop (~> 1.23)
rubocop-performance (~> 1.12)
rubocop-performance (1.19.0)
rubocop (>= 1.7.0, < 2.0)
rubocop-ast (>= 0.4.0)
rubocop-performance (1.20.1)
rubocop (>= 1.48.1, < 2.0)
rubocop-ast (>= 1.30.0, < 2.0)
ruby-progressbar (1.13.0)
ruby2_keywords (0.0.5)
serbea (1.0.1)
Expand All @@ -215,7 +224,7 @@ GEM
simplecov_json_formatter (~> 0.1)
simplecov-html (0.12.3)
simplecov_json_formatter (0.1.4)
solargraph (0.49.0)
solargraph (0.50.0)
backport (~> 1.2)
benchmark
bundler (~> 2.0)
Expand All @@ -235,13 +244,13 @@ GEM
ffi (~> 1.1)
terminal-table (3.0.2)
unicode-display_width (>= 1.1.1, < 3)
thor (1.2.2)
tilt (2.2.0)
thor (1.3.0)
tilt (2.3.0)
tzinfo (2.0.6)
concurrent-ruby (~> 1.0)
unicode-display_width (2.4.2)
unicode-display_width (2.5.0)
yard (0.9.34)
zeitwerk (2.6.11)
zeitwerk (2.6.12)

PLATFORMS
arm64-darwin-22
Expand Down Expand Up @@ -274,4 +283,4 @@ DEPENDENCIES
yard (~> 0.9)

BUNDLED WITH
2.4.6
2.5.3
1 change: 1 addition & 0 deletions bridgetown-core/bridgetown-core.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ Gem::Specification.new do |s|
s.add_runtime_dependency("addressable", "~> 2.4")
s.add_runtime_dependency("amazing_print", "~> 1.2")
s.add_runtime_dependency("colorator", "~> 1.0")
s.add_runtime_dependency("csv", "~> 3.2")
s.add_runtime_dependency("erubi", "~> 1.9")
s.add_runtime_dependency("faraday", "~> 2.0")
s.add_runtime_dependency("faraday-follow_redirects", "~> 0.3")
Expand Down
12 changes: 10 additions & 2 deletions bridgetown-core/lib/bridgetown-core/commands/console.rb
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,15 @@ def self.banner
type: :boolean,
desc: "Print verbose output."

def console
def console # rubocop:disable Metrics
require "irb"
require "irb/ext/save-history"
new_history_behavior = false
begin
require "irb/ext/save-history"
rescue LoadError
# Code path for Ruby 3.3+
new_history_behavior = true
end
require "amazing_print" unless options[:"bypass-ap"]

Bridgetown.logger.adjust_verbosity(options)
Expand Down Expand Up @@ -96,6 +102,7 @@ def console
irb = IRB::Irb.new(workspace)
IRB.conf[:IRB_RC]&.call(irb.context)
IRB.conf[:MAIN_CONTEXT] = irb.context
irb.context.io.load_history if new_history_behavior
Bridgetown.logger.info "Console:", "Your site is now available as #{"site".cyan}"
Bridgetown.logger.info "",
"You can also access #{"collections".cyan} or perform a " \
Expand All @@ -117,6 +124,7 @@ def console
end
ensure
IRB.conf[:AT_EXIT].each(&:call)
irb.context.io.save_history if new_history_behavior
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion bridgetown-core/lib/bridgetown-core/generated_page.rb
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ def relative_path
#
# @return [String]
def output_ext
@output_ext ||= (permalink_ext || converter_output_ext)
@output_ext ||= permalink_ext || converter_output_ext
end

def permalink_ext
Expand Down
12 changes: 3 additions & 9 deletions bridgetown-core/lib/bridgetown-core/log_writer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,12 @@

module Bridgetown
class LogWriter < ::Logger
def initialize # rubocop:disable Lint/MissingSuper
@progname = nil
@level = DEBUG
@default_formatter = Formatter.new
@logdev = $stdout
@formatter = proc do |_, _, _, msg|
msg.to_s
end
def initialize
super($stdout, formatter: proc { |_, _, _, msg| msg.to_s })
end

def enable_prefix
@formatter = proc do |_, _, _, msg|
self.formatter = proc do |_, _, _, msg|
"\e[32m[Bridgetown]\e[0m #{msg}"
end
end
Expand Down
2 changes: 1 addition & 1 deletion bridgetown-core/lib/bridgetown-core/resource/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ def normalize_categories_and_tags
end

def import_taxonomies_from_data
taxonomies.each do |_label, metadata|
taxonomies.each_value do |metadata|
Array(data[metadata.type.key]).each do |term|
metadata.terms << TaxonomyTerm.new(
resource: self, label: term, type: metadata.type
Expand Down
2 changes: 1 addition & 1 deletion bridgetown-core/lib/bridgetown-core/resource/relations.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def relation_schema
def relation_types
@relation_types ||= begin
types = []
relation_schema&.each do |_relation_type, collections|
relation_schema&.each_value do |collections|
types << collections
types << Array(collections).map { |item| ActiveSupport::Inflector.pluralize(item) }
end
Expand Down
4 changes: 1 addition & 3 deletions bridgetown-core/lib/bridgetown-core/utils/loaders_manager.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,7 @@ def initialize(config)
def unload_loaders
return if @loaders.keys.empty?

@loaders.each do |_path, loader|
loader.unload
end
@loaders.each_value(&:unload)
@loaders = {}
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,14 +80,14 @@ def generate(site) # rubocop:todo Metrics/AbcSize
doc.data.key?("pagination") || doc.data.key?("paginate")
end
end
return coll
coll
end

# Create the proc that constructs the real-life site page
# This is necessary to decouple the code from the Bridgetown site object
page_add_lambda = ->(newpage) do
site.add_generated_page newpage
return newpage # Return the site to the calling code
newpage # Return the site to the calling code
end

# lambda that removes a page from the site pages list
Expand Down
2 changes: 2 additions & 0 deletions bridgetown-website/Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ PATH
addressable (~> 2.4)
amazing_print (~> 1.2)
colorator (~> 1.0)
csv (~> 3.2)
erubi (~> 1.9)
faraday (~> 2.0)
faraday-follow_redirects (~> 0.3)
Expand Down Expand Up @@ -69,6 +70,7 @@ GEM
nokogiri
colorator (1.1.0)
concurrent-ruby (1.2.2)
csv (3.2.6)
erubi (1.12.0)
faraday (2.7.10)
faraday-net_http (>= 2.0, < 3.1)
Expand Down

0 comments on commit bd75129

Please sign in to comment.