Class: StillActive::CLI

Inherits:
Object
  • Object
show all
Includes:
VersionHelper
Defined in:
lib/still_active/cli.rb

Instance Method Summary collapse

Methods included from VersionHelper

#find_version, #gem_version, #release_date, #up_to_date?

Instance Method Details

#run(args) ⇒ Object



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
# File 'lib/still_active/cli.rb', line 14

def run(args)
  options = Options.new.parse!(args)
  if options[:provided_gems]
    StillActive.config.gems.map! { |gem| { name: gem } }
  else
    StillActive.config.gems = BundlerHelper.gemfile_dependencies
  end

  result = Workflow.call
  case StillActive.config.output_format
  when :json
    puts result.to_json
  when :markdown
    puts MarkdownHelper.markdown_table_header_line
    result.keys.sort.each do |name|
      result[name].merge!({
        last_activity_warning_emoj: EmojiHelper.inactive_gem_emoji(result[name]),
        up_to_date_emoji: EmojiHelper.using_latest_emoji(
          using_last_release: VersionHelper.up_to_date?(
            version_used: result[name].dig(:version_used), latest_version: result[name].dig(:latest_version),
          ),
          using_last_pre_release: VersionHelper.up_to_date?(
            version_used: result[name].dig(:version_used), latest_version: result[name].dig(:latest_pre_release_version),
          ),
        ),
      })

      puts MarkdownHelper.markdown_table_body_line(gem_name: name, data: result[name])
    end
  end
end