Class: Danger::PluginReadme

Inherits:
PluginAbstract show all
Defined in:
lib/danger/commands/plugins/plugin_readme.rb

Instance Attribute Summary collapse

Attributes inherited from Runner

#cork

Instance Method Summary collapse

Methods inherited from Runner

options, #post_results, report_error, #validate!

Constructor Details

#initialize(argv) ⇒ PluginReadme

Returns a new instance of PluginReadme.



11
12
13
14
# File 'lib/danger/commands/plugins/plugin_readme.rb', line 11

def initialize(argv)
  @refs = argv.arguments! unless argv.arguments.empty?
  super
end

Instance Attribute Details

#jsonObject

Returns the value of attribute json.



27
28
29
# File 'lib/danger/commands/plugins/plugin_readme.rb', line 27

def json
  @json
end

#markdownObject

Returns the value of attribute markdown.



27
28
29
# File 'lib/danger/commands/plugins/plugin_readme.rb', line 27

def markdown
  @markdown
end

Instance Method Details

#runObject



28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/danger/commands/plugins/plugin_readme.rb', line 28

def run
  file_resolver = PluginFileResolver.new(@refs)
  paths = file_resolver.resolve_to_paths

  parser = PluginParser.new(paths)
  parser.parse

  self.markdown = Redcarpet::Markdown.new(Redcarpet::Render::HTML, no_intra_emphasis: true)
  self.json = JSON.parse(parser.to_json)

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