Sha256: bdf52245082292593e10ffea227ac55dadc7b6ca7b9fa81282253253464f5af4

Contents?: true

Size: 1.28 KB

Versions: 46

Compression:

Stored size: 1.28 KB

Contents

require "danger/plugin_support/plugin_parser"
require "danger/plugin_support/plugin_file_resolver"
require "json"
require "erb"

module Danger
  class PluginReadme < CLAide::Command::Plugins
    self.summary = "Generates a README from a set of plugins"
    self.command = "readme"

    attr_accessor :cork, :json, :markdown

    def initialize(argv)
      @refs = argv.arguments! unless argv.arguments.empty?
      @cork = Cork::Board.new(silent: argv.option("silent", false),
                              verbose: argv.option("verbose", false))
      super
    end

    self.description = <<-DESC
      Converts a collection of file paths of Danger plugins into a format usable in a README.
      This is useful for Danger itself, but also for any plugins wanting to showcase their API.
    DESC

    self.arguments = [
      CLAide::Argument.new("Paths, Gems or Nothing", false, true)
    ]

    def run
      file_resolver = PluginFileResolver.new(@refs)
      data = file_resolver.resolve

      parser = PluginParser.new(data[:paths])
      parser.parse

      self.json = JSON.parse(parser.to_json_string)

      template = File.join(Danger.gem_path, "lib/danger/plugin_support/templates/readme_table.html.erb")
      cork.puts ERB.new(File.read(template), trim_mode: "-").result(binding)
    end
  end
end

Version data entries

46 entries across 46 versions & 2 rubygems

Version Path
danger-additional-logging-0.0.23 lib/danger/commands/plugins/plugin_readme.rb
danger-additional-logging-0.0.22 lib/danger/commands/plugins/plugin_readme.rb
danger-additional-logging-0.0.21 lib/danger/commands/plugins/plugin_readme.rb
danger-additional-logging-0.0.20 lib/danger/commands/plugins/plugin_readme.rb
danger-additional-logging-0.0.19 lib/danger/commands/plugins/plugin_readme.rb
danger-additional-logging-0.0.18 lib/danger/commands/plugins/plugin_readme.rb
danger-additional-logging-0.0.17 lib/danger/commands/plugins/plugin_readme.rb
danger-additional-logging-0.0.16 lib/danger/commands/plugins/plugin_readme.rb
danger-additional-logging-0.0.15 lib/danger/commands/plugins/plugin_readme.rb
danger-additional-logging-0.0.14 lib/danger/commands/plugins/plugin_readme.rb
danger-additional-logging-0.0.13 lib/danger/commands/plugins/plugin_readme.rb
danger-additional-logging-0.0.12 lib/danger/commands/plugins/plugin_readme.rb
danger-additional-logging-0.0.11 lib/danger/commands/plugins/plugin_readme.rb
danger-additional-logging-0.0.10 lib/danger/commands/plugins/plugin_readme.rb
danger-additional-logging-0.0.9 lib/danger/commands/plugins/plugin_readme.rb
danger-additional-logging-0.0.8 lib/danger/commands/plugins/plugin_readme.rb
danger-additional-logging-0.0.7 lib/danger/commands/plugins/plugin_readme.rb
danger-additional-logging-0.0.6 lib/danger/commands/plugins/plugin_readme.rb
danger-additional-logging-0.0.5 lib/danger/commands/plugins/plugin_readme.rb
danger-additional-logging-0.0.4 lib/danger/commands/plugins/plugin_readme.rb