Class: Danger::PluginReadme

Inherits:
CLAide::Command::Plugins
  • Object
show all
Defined in:
lib/danger/commands/plugins/plugin_readme.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(argv) ⇒ PluginReadme

Returns a new instance of PluginReadme.



13
14
15
16
17
18
# File 'lib/danger/commands/plugins/plugin_readme.rb', line 13

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

Instance Attribute Details

#corkObject

Returns the value of attribute cork.



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

def cork
  @cork
end

#jsonObject

Returns the value of attribute json.



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

def json
  @json
end

#markdownObject

Returns the value of attribute markdown.



31
32
33
# File 'lib/danger/commands/plugins/plugin_readme.rb', line 31

def markdown
  @markdown
end

Instance Method Details

#runObject



32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/danger/commands/plugins/plugin_readme.rb', line 32

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), 0, "-").result(binding)
end