Module: StillActive::MarkdownHelper

Extended by:
MarkdownHelper
Included in:
MarkdownHelper
Defined in:
lib/helpers/markdown_helper.rb

Instance Method Summary collapse

Instance Method Details

#markdown_table_body_line(gem_name:, data:) ⇒ Object



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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
# File 'lib/helpers/markdown_helper.rb', line 11

def markdown_table_body_line(gem_name:, data:)
  repository_url = data[:repository_url]
  ruby_gems_url = data[:ruby_gems_url]

  version_used = data.dig(:version_used)
  version_used_url =
    if version_used && ruby_gems_url
      "#{ruby_gems_url}/versions/#{version_used}"
    end
  version_used_release_date = data.dig(:version_used_release_date)

  latest_version = data[:latest_version]
  latest_version_url =
    if latest_version && ruby_gems_url
      "#{ruby_gems_url}/versions/#{latest_version}"
    end
  latest_version_release_date = data.dig(:latest_version_release_date)

  latest_version_prerelease = data.dig(:latest_pre_release_version)
  latest_version_prerelease_url =
    if latest_version_prerelease && ruby_gems_url
      "#{ruby_gems_url}/versions/#{latest_version_prerelease}"
    end
  latest_version_prerelease_date = data.dig(:latest_pre_release_version_release_date)

  last_commit_date = data.dig(:last_commit_date)
  last_commit_url = repository_url

  inactive_repository_emoji = data.dig(:last_activity_warning_emoj)
  using_latest_version_emoji = data.dig(:up_to_date_emoji)

  formatted_name = markdown_url(text: gem_name, url: repository_url)

  formatted_version_used = markdown_url(text: version_used, url: version_used_url)
  formatted_version_used_date = year_month(version_used_release_date)

  formatted_latest_release_version = markdown_url(text: latest_version, url: latest_version_url)
  formatted_latest_release_date = year_month(latest_version_release_date)

  formatted_latest_pre_release_version = markdown_url(
    text: latest_version_prerelease,
    url: latest_version_prerelease_url,
  )
  formatted_latest_pre_release_date = year_month(latest_version_prerelease_date)

  formatted_last_commit_date = markdown_url(text: year_month(last_commit_date), url: last_commit_url)

  formatted_markdown_table_line =
    [
      inactive_repository_emoji || StillActive.config.unsure_emoji,
      using_latest_version_emoji || StillActive.config.unsure_emoji,
      formatted_name,
      formatted_version_used,
      formatted_version_used_date || StillActive.config.unsure_emoji,
      formatted_latest_release_version || StillActive.config.unsure_emoji,
      formatted_latest_release_date || StillActive.config.unsure_emoji,
      formatted_latest_pre_release_version || StillActive.config.unsure_emoji,
      formatted_latest_pre_release_date || StillActive.config.unsure_emoji,
      formatted_last_commit_date || StillActive.config.unsure_emoji,
    ]
      .join(" | ")

  "| #{formatted_markdown_table_line} |"
end

#markdown_table_header_lineObject



6
7
8
9
# File 'lib/helpers/markdown_helper.rb', line 6

def markdown_table_header_line
  "| gem activity old? | up to date? | name | version used | release date | latest version | release date | latest pre-release version  | release date | last commit date |\n" \
    "| ----------------- | ----------- | ---- | ------------ | ------------ | -------------- | ------------ | --------------------------- | ------------ | ---------------- |"
end