diff --git a/Gemfile b/Gemfile index 26780be..2e6f3dc 100644 --- a/Gemfile +++ b/Gemfile @@ -54,3 +54,5 @@ group :test do gem "capybara" gem "selenium-webdriver" end + +gem "memery", "~> 1.6" diff --git a/Gemfile.lock b/Gemfile.lock index 28da963..7f3d09b 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -168,6 +168,7 @@ GEM net-smtp marcel (1.0.4) matrix (0.4.2) + memery (1.6.0) mini_mime (1.1.5) minitest (5.25.4) msgpack (1.7.5) @@ -404,6 +405,7 @@ DEPENDENCIES dotenv-rails (~> 3.1) importmap-rails jbuilder + memery (~> 1.6) omniauth (~> 2.1) omniauth-github (~> 2.0) omniauth-rails_csrf_protection (~> 1.0) diff --git a/app/controllers/reports_controller.rb b/app/controllers/reports_controller.rb index 6646dbd..ec1164f 100644 --- a/app/controllers/reports_controller.rb +++ b/app/controllers/reports_controller.rb @@ -40,8 +40,7 @@ def bundled_html private - # TODO: memoize - def bundled_html_list_of_files + memoize def bundled_html_list_of_files @items = with_zip_entries do |entries| entries.map do |entry| without_prefix = entry.name @@ -60,9 +59,8 @@ def lookup_path # https://edgeguides.rubyonrails.org/active_storage_overview.html#downloading-files # https://github.com/rubyzip/rubyzip?tab=readme-ov-file#reading-a-zip-file - # TODO: memoize # TODO: keep the tempfile around for a while, so we don't need to download it again - def extract_file + memoize def extract_file @report.bundled_html.open do |tempfile| Zip::File.open(tempfile.path) do |zip_entries| entry = zip_entries.glob(lookup_path).first diff --git a/app/models/report.rb b/app/models/report.rb index d8c14ba..fc59025 100644 --- a/app/models/report.rb +++ b/app/models/report.rb @@ -41,7 +41,6 @@ def simplecov_generate_bundled_html def simplecov_generate_results nil if bundled_html.blank? - # TODO: fill the Report#results with some overall details too bundled_html.open do |tempzip| Zip::File.open(tempzip.path) do |zip_entries| zip_entries.each do |zip_entry| diff --git a/config/initializers/memery.rb b/config/initializers/memery.rb new file mode 100644 index 0000000..fa31072 --- /dev/null +++ b/config/initializers/memery.rb @@ -0,0 +1,3 @@ +class Object + include Memery +end