diff --git a/Gemfile b/Gemfile index 87b1f7e..82c14f5 100644 --- a/Gemfile +++ b/Gemfile @@ -4,23 +4,23 @@ source "https://rubygems.org/" gemspec -# gem "debug", "~> 1.0", require: false - -gem "minitest", "~> 5.11" -gem "minitest-focus", "~> 1.2" -gem "minitest-junit", "~> 1.0" - -gem "rake" -gem "rdoc", "~> 6.3", require: false -gem "reek", require: false - -gem "rubocop", "~> 1.63", require: false -gem "rubocop-minitest", "~> 0.35", require: false -gem "rubocop-packaging", "~> 0.5", require: false -gem "rubocop-performance", "~> 1.21", require: false -gem "rubocop-rake", "~> 0.6", require: false -gem "rubocop-thread_safety", "~> 0.5", require: false - -gem "rubocop-md", "~> 1.2", require: false - -gem "simplecov", "~> 0.22", require: false +group :development do + gem "debug", "~> 1.0", require: false + gem "rake" + gem "reek", require: false + gem "rdoc", "~> 6.3", require: false + gem "rubocop", "~> 1.63", require: false + gem "rubocop-md", "~> 1.2", require: false + gem "rubocop-minitest", "~> 0.35", require: false + gem "rubocop-packaging", "~> 0.5", require: false + gem "rubocop-performance", "~> 1.21", require: false + gem "rubocop-rake", "~> 0.6", require: false + gem "rubocop-thread_safety", "~> 0.5", require: false +end + +group :test do + gem "minitest", "~> 5.11" + gem "minitest-focus", "~> 1.2" + gem "minitest-junit", "~> 1.0" + gem "simplecov", "~> 0.22", require: false +end diff --git a/Gemfile.lock b/Gemfile.lock index 689208c..e107880 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -8,6 +8,7 @@ PATH rack (~> 3.0) rackup (~> 2.1) rouge (~> 4.0) + zeitwerk (~> 2.6) GEM remote: https://rubygems.org/ @@ -19,6 +20,9 @@ GEM bigdecimal (3.1.7-java) builder (3.2.4) concurrent-ruby (1.2.3) + debug (1.9.2) + irb (~> 1.10) + reline (>= 0.3.8) docile (1.4.0) dry-configurable (1.1.0) dry-core (~> 1.0, < 2) @@ -47,6 +51,11 @@ GEM dry-inflector (~> 1.0) dry-logic (~> 1.4) zeitwerk (~> 2.6) + io-console (0.7.2) + io-console (0.7.2-java) + irb (1.13.1) + rdoc (>= 4.0.0) + reline (>= 0.4.2) jar-dependencies (0.4.1) json (2.7.2) json (2.7.2-java) @@ -91,6 +100,8 @@ GEM rainbow (>= 2.0, < 4.0) rexml (~> 3.1) regexp_parser (2.9.0) + reline (0.5.5) + io-console (~> 0.5) rexml (3.2.6) rouge (4.2.1) rubocop (1.63.4) @@ -141,6 +152,7 @@ PLATFORMS x86_64-linux DEPENDENCIES + debug (~> 1.0) heel! minitest (~> 5.11) minitest-focus (~> 1.2) diff --git a/HISTORY.md b/HISTORY.md index 3080247..7ae25cb 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -1,4 +1,14 @@ # Changelog +## Version NEXT +* Convert to using zeitwerk for loading +* Update all ruby dependencies +* Switch to [marcel](https://github.com/rails/marcel) for mime type detection +* Rework maintenance scripts +* Switch to [tabler icons](https://tabler.io/icons) +* Update the embedded pico-css versino +* Full rubocop sweep +* Lots of Internal refactoring + ## Version 4.0.1 - 2024-03-03 * Update all dependencies * update test versions of ruby diff --git a/Rakefile b/Rakefile index 9a0ad5d..668e89b 100644 --- a/Rakefile +++ b/Rakefile @@ -9,12 +9,14 @@ This.email = "jeremy@copiousfreetime.org" This.homepage = "http://github.com/copiousfreetime/#{This.name}" This.ruby_gemspec do |spec| + + spec.add_runtime_dependency("launchy", "~> 2.5") + spec.add_runtime_dependency("marcel", "~> 1.0") + spec.add_runtime_dependency("puma", "~> 6.0") spec.add_runtime_dependency("rack", "~> 3.0") spec.add_runtime_dependency("rackup", "~> 2.1") - spec.add_runtime_dependency("puma", "~> 6.0") - spec.add_runtime_dependency("marcel", "~> 1.0") - spec.add_runtime_dependency("launchy", "~> 2.5") spec.add_runtime_dependency("rouge", "~> 4.0") + spec.add_runtime_dependency("zeitwerk", "~> 2.6") spec.license = "BSD-3-Clause" diff --git a/heel.gemspec b/heel.gemspec index 187314a..435b8d8 100644 --- a/heel.gemspec +++ b/heel.gemspec @@ -12,7 +12,7 @@ Gem::Specification.new do |s| s.require_paths = ["lib".freeze] s.authors = ["Jeremy Hinegardner".freeze] s.bindir = "exe".freeze - s.date = "2024-05-05" + s.date = "2024-05-06" s.description = "Heel is a small static web server for use when you need a quick web server for a directory. Once the server is running, heel will use (https://rubygems.org/gems/launchy/) to open your browser at the URL of your document root. Run it right now! `gem exec heel` ----- Heel is built using (https://github.com/rack/rack) and (https://puma.io) % heel Launching your browser... Puma starting in single mode... * Puma version: 6.2.1 (ruby 3.2.2-p53) (\"Speaking of Now\") * Min threads: 0 * Max threads: 5 * Environment: none * PID: 11322 * Listening on http://0.0.0.0:4331 Use Ctrl-C to stop Or run it in the background % heel --daemonize Launching your browser at http://0.0.0.0:4331/ % heel --kill Sending TERM to process 3304 Done.".freeze s.email = "jeremy@copiousfreetime.org".freeze s.executables = ["heel".freeze] @@ -27,10 +27,11 @@ Gem::Specification.new do |s| s.specification_version = 4 + s.add_runtime_dependency(%q.freeze, ["~> 2.5".freeze]) + s.add_runtime_dependency(%q.freeze, ["~> 1.0".freeze]) + s.add_runtime_dependency(%q.freeze, ["~> 6.0".freeze]) s.add_runtime_dependency(%q.freeze, ["~> 3.0".freeze]) s.add_runtime_dependency(%q.freeze, ["~> 2.1".freeze]) - s.add_runtime_dependency(%q.freeze, ["~> 6.0".freeze]) - s.add_runtime_dependency(%q.freeze, ["~> 1.0".freeze]) - s.add_runtime_dependency(%q.freeze, ["~> 2.5".freeze]) s.add_runtime_dependency(%q.freeze, ["~> 4.0".freeze]) + s.add_runtime_dependency(%q.freeze, ["~> 2.6".freeze]) end diff --git a/lib/heel.rb b/lib/heel.rb index b782286..2d553bf 100644 --- a/lib/heel.rb +++ b/lib/heel.rb @@ -1,26 +1,29 @@ # frozen_string_literal: true -#-- -# Copyright (c) 2007 - 2013 Jeremy Hinegardner -# All rights reserved. Licensed under the BSD license. See LICENSE for details -#++ +require "zeitwerk" +Zeitwerk::Loader.new.then do |loader| + loader.inflector = Zeitwerk::GemInflector.new(__FILE__) + loader.tag = File.basename(__FILE__, ".rb") + loader.push_dir(__dir__) + loader.setup +end +# Heel namespace and version module Heel - VERSION = "4.0.1" + def self.loader(registry = Zeitwerk::Registry) + @loader ||= registry.loaders.find { |loader| loader.tag == File.basename(__FILE__, ".rb") } + end end -require "heel/configuration" -require "heel/mime_utils" -require "heel/resource" -require "heel/directory_entry" -require "heel/template" -require "heel/directory_listing_vars" -require "heel/response" -require "heel/directory_index_response" -require "heel/error_response_vars" -require "heel/error_response" -require "heel/logger" -require "heel/rackapp" -require "heel/request" -require "heel/resource_response" -require "heel/server" +# Stdlib and Gems +require "erb" +require "fileutils" +require "launchy" +require "marcel" +require "pathname" +require "puma" +require "rack" +require "rack/utils" +require "rackup" +require "rouge" +require "time" diff --git a/lib/heel/directory_index_response.rb b/lib/heel/directory_index_response.rb index 81ed9ff..14276cf 100644 --- a/lib/heel/directory_index_response.rb +++ b/lib/heel/directory_index_response.rb @@ -5,12 +5,6 @@ # All rights reserved. Licensed under the BSD license. See LICENSE for details #++ -require "erb" -require_relative "response" -require_relative "directory_entry" -require_relative "directory_listing_vars" -require_relative "template" - module Heel # Internal: Generate a directory index # diff --git a/lib/heel/error_response.rb b/lib/heel/error_response.rb index 2169c24..7d170f8 100644 --- a/lib/heel/error_response.rb +++ b/lib/heel/error_response.rb @@ -5,9 +5,6 @@ # All rights reserved. Licensed under the BSD license. See LICENSE for details #++ -require "rack" -require "erb" - module Heel # Internal: Wrapper for the http error code responses # diff --git a/lib/heel/rackapp.rb b/lib/heel/rack_app.rb similarity index 97% rename from lib/heel/rackapp.rb rename to lib/heel/rack_app.rb index d0bace1..aeac695 100644 --- a/lib/heel/rackapp.rb +++ b/lib/heel/rack_app.rb @@ -5,11 +5,6 @@ # All rights reserved. Licensed under the BSD license. See LICENSE for details #++ -require "rack" -require "rack/utils" -require "rouge" -require "time" - module Heel # Internal: The Rack application that is Heel. # diff --git a/lib/heel/request.rb b/lib/heel/request.rb index d7f322b..881db98 100644 --- a/lib/heel/request.rb +++ b/lib/heel/request.rb @@ -5,7 +5,6 @@ # All rights reserved. Licensed under the BSD license. See LICENSE for details #++ -require "rack" module Heel # Internal: A RackRequest with some additional methods and error handling # diff --git a/lib/heel/resource.rb b/lib/heel/resource.rb index 8207d1a..9c78e5e 100644 --- a/lib/heel/resource.rb +++ b/lib/heel/resource.rb @@ -5,8 +5,6 @@ # All rights reserved. Licensed under the BSD license. See LICENSE for details #++ -require "marcel" - module Heel # Internal: Resource representing a single file or directory that is being served # diff --git a/lib/heel/resource_response.rb b/lib/heel/resource_response.rb index cd15272..dcb2ca2 100644 --- a/lib/heel/resource_response.rb +++ b/lib/heel/resource_response.rb @@ -5,8 +5,6 @@ # All rights reserved. Licensed under the BSD license. See LICENSE for details #++ -require "marcel" - module Heel # Internal: Generate a resource response. # diff --git a/lib/heel/server.rb b/lib/heel/server.rb index f5beb24..aae3189 100644 --- a/lib/heel/server.rb +++ b/lib/heel/server.rb @@ -5,13 +5,6 @@ # All rights reserved. Licensed under the BSD license. See LICENSE for details #++ -require "ostruct" -require "launchy" -require "fileutils" -require "heel/rackapp" -require "rackup" -require "puma" - module Heel # Internal: The heel server # diff --git a/lib/heel/template.rb b/lib/heel/template.rb index 3488d03..d56c8e1 100644 --- a/lib/heel/template.rb +++ b/lib/heel/template.rb @@ -1,7 +1,5 @@ # frozen_string_literal: true -require "erb" - module Heel # Internal: A wrapper for an erb template # diff --git a/lib/heel/version.rb b/lib/heel/version.rb new file mode 100644 index 0000000..364bab3 --- /dev/null +++ b/lib/heel/version.rb @@ -0,0 +1,3 @@ +module Heel + VERSION = "4.0.1" +end diff --git a/spec/configuration_spec.rb b/spec/configuration_spec.rb index be498b5..7ff8320 100644 --- a/spec/configuration_spec.rb +++ b/spec/configuration_spec.rb @@ -1,7 +1,6 @@ # frozen_string_literal: true require "spec_helper" -require "pathname" describe Heel::Configuration do before do diff --git a/spec/rackapp_spec.rb b/spec/rack_app_spec.rb similarity index 96% rename from spec/rackapp_spec.rb rename to spec/rack_app_spec.rb index 6ab6320..6833308 100644 --- a/spec/rackapp_spec.rb +++ b/spec/rack_app_spec.rb @@ -1,8 +1,6 @@ # frozen_string_literal: true require "spec_helper" -require "rack/mock" -require "heel/rackapp" describe Heel::RackApp do before(:each) do diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 9104121..9f42947 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,6 +1,10 @@ # frozen_string_literal: true +Bundler.require(:test) + require "heel" + require "minitest/autorun" require "minitest/focus" require "minitest/pride" +require "rack/mock"