Skip to content

Commit

Permalink
Update to minimum Ruby 2.7 and release alpha7
Browse files Browse the repository at this point in the history
  • Loading branch information
jaredcwhite committed Nov 5, 2021
1 parent f1a6572 commit 9f9c4f1
Show file tree
Hide file tree
Showing 34 changed files with 67 additions and 71 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.5.8, 2.6.6, 2.7.2, 3.0.0]
ruby_version: [2.7.2, 3.0.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 .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Bridgetown/NoPutsAllowed:
- bridgetown-core/lib/bridgetown-core/rack/roda.rb

AllCops:
TargetRubyVersion: 2.5
TargetRubyVersion: 2.7

Lint/NestedPercentLiteral:
Exclude:
Expand Down
13 changes: 11 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,17 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## Unreleased

- Don't mutate bundler dependencies in place (#433)
- Add bundled configuration for Render (#431)
...

## 1.0.0.alpha7 - 2021-11-05

- Update minimum Ruby requirement to 2.7
- Copy `bin/bridgetown` to `bin/bt` after binstubs generation
- Ensure Webpack error messages only display once
- Add bundled configuration for Cypress [#339](https://github.com/bridgetownrb/bridgetown/pull/339) ([ayushn21](https://github.com/ayushn21))
- Use Zeitwerk for autoload/eager load paths (including plugins) [#434](https://github.com/bridgetownrb/bridgetown/pull/434) ([jaredcwhite](https://github.com/jaredcwhite) & [ayushn21](https://github.com/ayushn21))
- Don't mutate bundler dependencies in place [#433](https://github.com/bridgetownrb/bridgetown/pull/433) ([deivid-rodriguez](https://github.com/deivid-rodriguez))
- Add bundled configuration for Render [#431](https://github.com/bridgetownrb/bridgetown/pull/431) ([ayushn21](https://github.com/ayushn21))

## 1.0.0.alpha6 - 2021-10-26

Expand Down
13 changes: 4 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -148,15 +148,10 @@ Bridgetown is built by:
|<a href="https://github.com/erikyuzwa">@erikyuzwa</a>|<a href="https://github.com/eclectic-coding">@eclectic-coding</a>|<a href="https://github.com/collindonnell">@collindonnell</a>|<a href="https://github.com/juhat">@juhat</a>|<a href="https://github.com/debashis-biswal">@debashis-biswal</a>|
|Calgary, AB|North Carolina, US|Portland, OR|Budapest, Hungary||

|<img src="https://avatars.githubusercontent.com/nachoal?s=256" alt="nachoal" width="128" />|
|:---:|
|<a href="https://github.com/nachoal">@nachoal</a>|<a href="https://github.com/nachoal">@nachoal</a>|
|CDMX, México|

|<img src="https://www.gravatar.com/avatar/00000000000000000000000000000000?d=identicon&s=128&" alt="" width="128" />|
|:---:|
|You Next?|
|Anywhere|
|<img src="https://avatars.githubusercontent.com/nachoal?s=256" alt="nachoal" width="128" />|<img src="https://avatars.githubusercontent.com/deivid-rodriguez?s=256" alt="deivid-rodriguez" width="128" />|<img src="https://www.gravatar.com/avatar/00000000000000000000000000000000?d=identicon&s=128&" alt="" width="128" />|
|:---:|:---:|:---:|
|<a href="https://github.com/nachoal">@nachoal</a>|<a href="https://github.com/deivid-rodriguez">@deivid-rodriguez</a>|You Next?|
|CDMX, México|Madrid, Spain|Anywhere|

Interested in joining the Bridgetown Core Team? Send a DM to Jared in [Discord](https://discord.gg/4E6hktQGz4) and let's chat!

Expand Down
12 changes: 6 additions & 6 deletions bridgetown-builder/lib/bridgetown-builder/builder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,16 @@ def register
end
end

ruby2_keywords def before_build(*args, &block)
set_callback :build, :before, *args, &block
def before_build(*args, **kwargs, &block)
set_callback :build, :before, *args, **kwargs, &block
end

ruby2_keywords def after_build(*args, &block)
set_callback :build, :after, *args, &block
def after_build(*args, **kwargs, &block)
set_callback :build, :after, *args, **kwargs, &block
end

ruby2_keywords def around_build(*args, &block)
set_callback :build, :around, *args, &block
def around_build(*args, **kwargs, &block)
set_callback :build, :around, *args, **kwargs, &block
end
end

Expand Down
3 changes: 1 addition & 2 deletions bridgetown-core/bridgetown-core.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,7 @@ Gem::Specification.new do |s|

s.rdoc_options = ["--charset=UTF-8"]

s.required_ruby_version = ">= 2.5.0"
s.required_rubygems_version = ">= 2.7.0"
s.required_ruby_version = ">= 2.7.0"

s.add_runtime_dependency("activemodel", "~> 6.0")
s.add_runtime_dependency("activesupport", "~> 6.0")
Expand Down
2 changes: 1 addition & 1 deletion bridgetown-core/lib/bridgetown-core/cache.rb
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ def path_to(hash = nil)
@base_dir ||= File.join(Bridgetown::Cache.cache_dir, @name)
return @base_dir if hash.nil?

File.join(@base_dir, hash[0..1], hash[2..-1]).freeze
File.join(@base_dir, hash[0..1], hash[2..]).freeze
end

# Given a key, return a SHA2 hash that can be used for caching this item to disk.
Expand Down
2 changes: 1 addition & 1 deletion bridgetown-core/lib/bridgetown-core/collection.rb
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ def merge_data_resources # rubocop:todo Metrics/AbcSize, Metrics/CyclomaticCompl
end

resources.each do |data_resource|
segments = data_resource.relative_path.each_filename.to_a[1..-1]
segments = data_resource.relative_path.each_filename.to_a[1..]
nested = []
segments.each_with_index do |segment, index|
sanitized_segment = sanitize_filename.(File.basename(segment, ".*"))
Expand Down
4 changes: 2 additions & 2 deletions bridgetown-core/lib/bridgetown-core/component.rb
Original file line number Diff line number Diff line change
Expand Up @@ -164,9 +164,9 @@ def _renderer
end
end

ruby2_keywords def method_missing(method, *args, &block)
def method_missing(method, *args, **kwargs, &block)
if helpers.respond_to?(method.to_sym)
helpers.send method.to_sym, *args, &block
helpers.send method.to_sym, *args, **kwargs, &block
else
super
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def read_front_matter(file_path) # rubocop:todo Metrics/AbcSize, Metrics/Cycloma
self.front_matter_line_count = ruby_content[1].lines.size
process_ruby_data(ruby_content[1], file_path, 2)
elsif Bridgetown::Utils.has_rbfm_header?(file_path)
process_ruby_data(File.read(file_path).lines[1..-1].join("\n"), file_path, 2)
process_ruby_data(File.read(file_path).lines[1..].join("\n"), file_path, 2)
elsif is_a?(Layout)
self.content = file_contents
{}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ def configure_cache
def configure_component_paths # rubocop:todo Metrics/AbcSize
# Loop through plugins paths first
plugin_components_load_paths = Bridgetown::PluginManager.source_manifests
.map(&:components).compact
.filter_map(&:components)

local_components_load_paths = config["components_dir"].yield_self do |dir|
dir.is_a?(Array) ? dir : [dir]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def setup(options)
@options ||= Options.merge(options).freeze
@parser ||= begin
parser_name = (@options[:input] || "kramdown").to_s
parser_name = parser_name[0..0].upcase + parser_name[1..-1]
parser_name = parser_name[0..0].upcase + parser_name[1..]
try_require("parser", parser_name)

if Parser.const_defined?(parser_name)
Expand Down
6 changes: 1 addition & 5 deletions bridgetown-core/lib/bridgetown-core/core_ext/psych.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,7 @@ module Psych
module SafeLoadFile
def safe_load_file(filename, **kwargs)
File.open(filename, "r:bom|utf-8") do |f|
if RUBY_VERSION.start_with?("2.5")
safe_load f, kwargs[:permitted_classes], [], false, filename
else
safe_load f, filename: filename, **kwargs
end
safe_load f, filename: filename, **kwargs
end
end
end
Expand Down
4 changes: 2 additions & 2 deletions bridgetown-core/lib/bridgetown-core/frontmatter_defaults.rb
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ def valid_sets
sets = site.config["defaults"]
return [] unless sets.is_a?(Array)

sets.map do |set|
sets.filter_map do |set|
if valid?(set)
massage_scope!(set)
# TODO: is this trip really necessary?
Expand All @@ -191,7 +191,7 @@ def valid_sets
Bridgetown.logger.warn set.to_s
nil
end
end.compact
end
end

# Set path to blank if not specified and alias older type to collection
Expand Down
2 changes: 1 addition & 1 deletion bridgetown-core/lib/bridgetown-core/model/plugin_origin.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def manifest

def relative_path
@relative_path ||= Pathname.new(
Addressable::URI.unescape(url.path.delete_prefix("/")).split("/")[1..-1].join("/")
Addressable::URI.unescape(url.path.delete_prefix("/")).split("/")[1..].join("/")
)
end

Expand Down
4 changes: 2 additions & 2 deletions bridgetown-core/lib/bridgetown-core/rack/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,9 @@ def handle_routes
instance_exec(@_roda_app.request, &self.class.router_block)
end

ruby2_keywords def method_missing(method_name, *args, &block)
def method_missing(method_name, *args, **kwargs, &block)
if @_roda_app.respond_to?(method_name.to_sym)
@_roda_app.send method_name.to_sym, *args, &block
@_roda_app.send method_name.to_sym, *args, **kwargs, &block
else
super
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def read
Layout.new(site, layout_directory, layout_file)
end

Bridgetown::PluginManager.source_manifests.map(&:layouts).compact.each do |plugin_layouts|
Bridgetown::PluginManager.source_manifests.filter_map(&:layouts).each do |plugin_layouts|
layout_entries(plugin_layouts).each do |layout_file|
@layouts[layout_name(layout_file)] ||= \
Layout.new(site, plugin_layouts, layout_file, from_plugin: true)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def read_content_file(path)
end

def add_to(content_type, klass)
existing_paths = content_type.map(&:relative_path).compact
existing_paths = content_type.filter_map(&:relative_path)
@content_files.select { |item| item.is_a?(klass) }.each do |item|
content_type << item unless existing_paths.include?(item.relative_path)
end
Expand Down
4 changes: 2 additions & 2 deletions bridgetown-core/lib/bridgetown-core/renderer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -161,9 +161,9 @@ def converter_output_ext
end

def output_exts
@output_exts ||= converters.map do |c|
@output_exts ||= converters.filter_map do |c|
c.output_ext(document.extname)
end.compact
end
end
end
end
6 changes: 3 additions & 3 deletions bridgetown-core/lib/bridgetown-core/resource/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -255,8 +255,8 @@ def as_json(*)
to_h
end

ruby2_keywords def to_json(*options)
as_json(*options).to_json(*options)
def to_json(...)
as_json(...).to_json(...)
end

def inspect
Expand Down Expand Up @@ -349,7 +349,7 @@ def determine_locale # rubocop:todo Metrics/AbcSize

# Look for alternative front matter or look at the filename pattern: slug.locale.ext
def locale_from_alt_data_or_filename
found_locale = data.language || data.lang || basename_without_ext.split(".")[1..-1].last
found_locale = data.language || data.lang || basename_without_ext.split(".")[1..].last
return unless found_locale && site.config.available_locales.include?(found_locale.to_sym)

found_locale
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 @@ -95,7 +95,7 @@ def collection_labels
def belongs_to_relation_for_type(type)
if resource.data[type].is_a?(Array)
other_slugs = other_collection_for_type(type).resources_by_slug
resource.data[type].map { |slug| other_slugs[slug] }.compact
resource.data[type].filter_map { |slug| other_slugs[slug] }
else
other_collection_for_type(type).resources.find do |other_resource|
other_resource.data.slug == resource.data[type]
Expand Down
4 changes: 2 additions & 2 deletions bridgetown-core/lib/bridgetown-core/resource/taxonomy_term.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ def as_json(*)
to_h
end

ruby2_keywords def to_json(*options)
as_json(*options).to_json(*options)
def to_json(...)
as_json(...).to_json(...)
end
end
end
Expand Down
4 changes: 2 additions & 2 deletions bridgetown-core/lib/bridgetown-core/resource/taxonomy_type.rb
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ def as_json(*)
to_h
end

ruby2_keywords def to_json(*options)
as_json(*options).to_json(*options)
def to_json(...)
as_json(...).to_json(...)
end
end
end
Expand Down
4 changes: 2 additions & 2 deletions bridgetown-core/lib/bridgetown-core/ruby_template_view.rb
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,9 @@ def helpers
@helpers ||= Helpers.new(self, site)
end

ruby2_keywords def method_missing(method_name, *args, &block)
def method_missing(method_name, *args, **kwargs, &block)
if helpers.respond_to?(method_name.to_sym)
helpers.send method_name.to_sym, *args, &block
helpers.send method_name.to_sym, *args, **kwargs, &block
else
super
end
Expand Down
2 changes: 1 addition & 1 deletion bridgetown-core/lib/bridgetown-core/version.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# frozen_string_literal: true

module Bridgetown
VERSION = "1.0.0.alpha6"
VERSION = "1.0.0.alpha7"
CODE_NAME = "Pearl"
end
6 changes: 3 additions & 3 deletions bridgetown-core/lib/bridgetown-core/watcher.rb
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def listen_handler(site, options)
unless site.ssr?
Bridgetown.logger.info "Regenerating…"
Bridgetown.logger.info "", "#{n} file(s) changed at #{t.strftime("%Y-%m-%d %H:%M:%S")}"
c.each { |path| Bridgetown.logger.info "", path["#{site.root_dir}/".length..-1] }
c.each { |path| Bridgetown.logger.info "", path["#{site.root_dir}/".length..] }
end

process(site, t, options)
Expand Down Expand Up @@ -105,7 +105,7 @@ def listen_ignore_paths(options)
source = Pathname.new(options["source"]).expand_path
paths = to_exclude(options)

paths.map do |p|
paths.filter_map do |p|
absolute_path = Pathname.new(normalize_encoding(p, options["source"].encoding)).expand_path
next unless absolute_path.exist?

Expand All @@ -120,7 +120,7 @@ def listen_ignore_paths(options)
rescue ArgumentError
# Could not find a relative path
end
end.compact + [%r!^\.bridgetown-metadata!]
end + [%r!^\.bridgetown-metadata!]
end

def sleep_forever
Expand Down
6 changes: 1 addition & 5 deletions bridgetown-core/lib/bridgetown-core/yaml_parser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,7 @@ def load_file(filename, **kwargs)
end

def load(yaml)
if RUBY_VERSION.start_with?("2.5")
YAML.safe_load yaml, PERMITTED_CLASSES
else
YAML.safe_load yaml, permitted_classes: PERMITTED_CLASSES
end
YAML.safe_load yaml, permitted_classes: PERMITTED_CLASSES
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion bridgetown-core/lib/site_template/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Welcome to your new Bridgetown website! You can update this README file to provi
- [GCC](https://gcc.gnu.org/install/)
- [Make](https://www.gnu.org/software/make/)
- [Ruby](https://www.ruby-lang.org/en/downloads/)
- `>= 2.5`
- `>= 2.7`
- [Bridgetown Gem](https://rubygems.org/gems/bridgetown)
- `gem install bridgetown -N`
- [Node](https://nodejs.org)
Expand Down
2 changes: 1 addition & 1 deletion bridgetown-core/test/helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ def mu_pp(obj)

def mocks_expect(*args)
RSpec::Mocks::ExampleMethods::ExpectHost.instance_method(:expect)\
.bind(self).call(*args)
.bind_call(self, *args)
end

def before_setup
Expand Down
2 changes: 1 addition & 1 deletion bridgetown-paginate/lib/bridgetown-paginate/utils.rb
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def self.ensure_leading_slash(path)
# @param path [String]
# @return [String] the input without the leading slash
def self.remove_double_slash(path)
path[0..1] == "//" ? path[1..-1] : path
path[0..1] == "//" ? path[1..] : path
end

# Static: Return a String version of the input which has a trailing slash.
Expand Down
6 changes: 4 additions & 2 deletions bridgetown-routes/lib/bridgetown-routes/manifest.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ def generate_manifest # rubocop:disable Metrics/AbcSize, Metrics/CyclomaticCompl

routes_dir = Bridgetown::Current.site.in_source_dir("_routes")
# @type [Array]
routes = Dir.glob(routes_dir + "/**/*.{#{routable_extensions.join(",")}}").map do |file|
routes = Dir.glob(
routes_dir + "/**/*.{#{routable_extensions.join(",")}}"
).filter_map do |file|
if File.basename(file).start_with?("_", ".") ||
File.basename(file, ".*").end_with?(".test")
next
Expand All @@ -31,7 +33,7 @@ def generate_manifest # rubocop:disable Metrics/AbcSize, Metrics/CyclomaticCompl
end

[file, file_slug, segment_keys]
end.compact
end

routes.sort! do |route_a, route_b|
# @type [String]
Expand Down
4 changes: 2 additions & 2 deletions bridgetown-routes/lib/roda/plugins/bridgetown_routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@ def render_with(data: {}) # rubocop:todo Metrics/AbcSize, Metrics/MethodLength
end.read!.transform!.output
end

ruby2_keywords def render(*args, &block)
view.render(*args, &block)
def render(...)
view.render(...)
end

def view(view_class: Bridgetown::ERBView)
Expand Down
Loading

0 comments on commit 9f9c4f1

Please sign in to comment.