From 1dfec4759bf2c107433c5f1618d97439f6d5bd01 Mon Sep 17 00:00:00 2001 From: Maximo Mussini Date: Mon, 12 Aug 2024 10:43:19 -0300 Subject: [PATCH] feat: remove `ostruct` dependency (closes #489) --- Gemfile.lock | 8 ++++---- gemfiles/Gemfile-rails-edge | 1 - vite_ruby/lib/vite_ruby/manifest.rb | 4 +--- vite_ruby/lib/vite_ruby/missing_entrypoint_error.rb | 7 +++---- 4 files changed, 8 insertions(+), 12 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 7efea9cf..6d420a48 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -103,7 +103,7 @@ GEM builder (3.3.0) byebug (11.1.3) coderay (1.1.3) - concurrent-ruby (1.3.3) + concurrent-ruby (1.3.4) connection_pool (2.4.1) crass (1.0.6) date (3.3.3) @@ -153,7 +153,7 @@ GEM net-smtp (0.4.0) net-protocol nio4r (2.5.9) - nokogiri (1.16.6) + nokogiri (1.16.7) mini_portile2 (~> 2.8.2) racc (~> 1.4) parallel (1.23.0) @@ -168,7 +168,7 @@ GEM pry (>= 0.13, < 0.15) psych (5.1.2) stringio - racc (1.8.0) + racc (1.8.1) rack (3.1.7) rack-proxy (0.7.7) rack @@ -249,7 +249,7 @@ GEM websocket-driver (0.7.6) websocket-extensions (>= 0.1.0) websocket-extensions (0.1.5) - zeitwerk (2.6.16) + zeitwerk (2.6.17) PLATFORMS ruby diff --git a/gemfiles/Gemfile-rails-edge b/gemfiles/Gemfile-rails-edge index 4b33b937..d40d8b01 100644 --- a/gemfiles/Gemfile-rails-edge +++ b/gemfiles/Gemfile-rails-edge @@ -5,7 +5,6 @@ git_source(:github) { |repo| "https://github.com/#{repo}.git" } gem 'rails', github: 'rails/rails', branch: 'main' gem 'mutex_m' -gem 'ostruct' gemspec path: '../vite_ruby' gemspec path: '../vite_rails' diff --git a/vite_ruby/lib/vite_ruby/manifest.rb b/vite_ruby/lib/vite_ruby/manifest.rb index 4e00f82f..d45b2a99 100644 --- a/vite_ruby/lib/vite_ruby/manifest.rb +++ b/vite_ruby/lib/vite_ruby/manifest.rb @@ -1,7 +1,5 @@ # frozen_string_literal: true -require 'ostruct' - # Public: Registry for accessing resources managed by Vite, using a generated # manifest file which maps entrypoint names to file paths. # @@ -214,7 +212,7 @@ def extension_for_type(entry_type) # Internal: Raises a detailed message when an entry is missing in the manifest. def missing_entry_error(name, **options) - raise ViteRuby::MissingEntrypointError, OpenStruct.new( + raise ViteRuby::MissingEntrypointError.new( file_name: resolve_entry_name(name, **options), last_build: builder.last_build_metadata, manifest: @manifest, diff --git a/vite_ruby/lib/vite_ruby/missing_entrypoint_error.rb b/vite_ruby/lib/vite_ruby/missing_entrypoint_error.rb index a070e7a1..7d8aaf6f 100644 --- a/vite_ruby/lib/vite_ruby/missing_entrypoint_error.rb +++ b/vite_ruby/lib/vite_ruby/missing_entrypoint_error.rb @@ -5,11 +5,10 @@ # NOTE: The complexity here is justified by the improved usability of providing # a more specific error message depending on the situation. class ViteRuby::MissingEntrypointError < ViteRuby::Error - extend Forwardable - def_delegators :@info, :file_name, :last_build, :manifest, :config + attr_reader :file_name, :last_build, :manifest, :config - def initialize(info) - @info = info + def initialize(file_name:, last_build:, manifest:, config:) + @file_name, @last_build, @manifest, @config = file_name, last_build, manifest, config super <<~MSG Vite Ruby can't find #{ file_name } in the manifests.