Class: Gems::GemCard

Inherits:
Components::ApplicationComponent
  • Object
show all
Includes:
Phlex::Rails::Helpers::DistanceOfTimeInWords
Defined in:
app/views/rails_devtools/gems/gem_card.rb

Instance Method Summary collapse

Constructor Details

#initialize(gem:) ⇒ GemCard

Returns a new instance of GemCard.



7
8
9
# File 'app/views/rails_devtools/gems/gem_card.rb', line 7

def initialize(gem:)
  @gem = gem
end

Instance Method Details

#view_templateObject



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'app/views/rails_devtools/gems/gem_card.rb', line 11

def view_template
  div(class: "card card-compact bg-white text-sm w-full shadow-sm") do
    div(class: "card-body") do
      div(class: "card-actions") do
        @gem.groups.each do |group|
          div(class: "badge badge-sm") { group }
        end
      end
      h2(class: "inline-flex card-title justify-between items-center") do
        div(class: "flex items-center gap-2") do
          span do
            [@gem.name.titleize.capitalize, @gem.actual_version].join(" ")
          end
          span(class: "badge badge-sm badge-warning font-normal") { "outdated" } if @gem.outdated?
        end
        span(class: "text-sm text-neutral opacity-75 font-normal") do
          @gem.date.strftime("%b %d, %Y")
        end
      end

      div(class: "text-neutral opacity-75") do
        outdated_info
        div { @gem.summary }
      end
      div(class: "card-actions mt-4 justify-end") do
        if @gem.source_code
          a(href: @gem.source_code, class: "btn btn-xs btn-outline btn-secondary") do
            "Source Code"
          end
        end
        if @gem.documentation
          a(href: @gem.documentation, class: "btn btn-xs btn-outline btn-secondary") do
            "Documentation"
          end
        end
        a(href: @gem.homepage, class: "btn btn-xs") { "Homepage" } if @gem.homepage
      end
    end
  end
end