Skip to content

Commit

Permalink
The rubygem partial displays the latest release date
Browse files Browse the repository at this point in the history
  • Loading branch information
heyapricot authored and Apricot committed Oct 27, 2024
1 parent 8dccbe9 commit b3f10e3
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 1 deletion.
15 changes: 14 additions & 1 deletion app/helpers/rubygems_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -161,9 +161,16 @@ def show_all_versions_link?(rubygem)
rubygem.versions_count > 5 || rubygem.yanked_versions?
end

def latest_release_date(rubygem)
latest = latest_version(rubygem)
return version_date_tag(latest) if latest.present?

tag.small("- #{nice_date_for(rubygem.updated)}", class: "gem__version__date") if rubygem.respond_to?(:updated) && rubygem.updated.present?
end

def latest_version_number(rubygem)
return rubygem.version if rubygem.respond_to?(:version)
(rubygem.latest_version || rubygem.versions.last)&.number
latest_version(rubygem)&.number
end

def link_to_github(rubygem)
Expand Down Expand Up @@ -218,4 +225,10 @@ def copy_field_tag(name, value)
}
)
end

private

def latest_version(rubygem)
(rubygem.latest_version || rubygem.versions.last)
end
end
1 change: 1 addition & 0 deletions app/views/rubygems/_rubygem.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
<h2 class="gems__gem__name">
<%= rubygem.name %>
<span class="gems__gem__version"><%= latest_version_number(rubygem) %></span>
<%= latest_release_date(rubygem) %>
</h2>
<p class="gems__gem__desc t-text"><%= short_info(rubygem) %></p>
</span>
Expand Down
1 change: 1 addition & 0 deletions lib/elastic_searcher.rb
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ def ui_source
summary
description
downloads
updated
version]
end
end

0 comments on commit b3f10e3

Please sign in to comment.