Skip to content

Commit

Permalink
installing memery to cache some file bundled file information
Browse files Browse the repository at this point in the history
  • Loading branch information
evsasse committed Dec 23, 2024
1 parent 2e53f4b commit 692eff8
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 5 deletions.
2 changes: 2 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,5 @@ group :test do
gem "capybara"
gem "selenium-webdriver"
end

gem "memery", "~> 1.6"
2 changes: 2 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
6 changes: 2 additions & 4 deletions app/controllers/reports_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
1 change: 0 additions & 1 deletion app/models/report.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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|
Expand Down
3 changes: 3 additions & 0 deletions config/initializers/memery.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
class Object
include Memery
end

0 comments on commit 692eff8

Please sign in to comment.