Class: Qddrud::Readme
- Inherits:
-
Object
- Object
- Qddrud::Readme
- Defined in:
- lib/qddrud/readme.rb
Overview
Evaluates an opscode chef cookbook’s metadata and github history to generate a README.md file. The README.rb is placed in the root level of the cookbook. This forces cookbook developers to properly use metadata to document their cookbooks efficiently. Additionally, it provides proper attribution for all committers in the project with links back to the contributors github profile. It is written to take advantage of cookbooks that properly utilize both Rake tasks and metadata.
Instance Attribute Summary collapse
-
#cookbooks ⇒ Object
Hash map of all site cookbooks including metadata.
-
#path ⇒ Object
Path to the site-cookbooks.
Instance Method Summary collapse
-
#initialize(path) ⇒ Readme
constructor
Initialize a new instance of Drud::Readme.
-
#render ⇒ Object
Renders the README.md file and saves it in the cookbooks path.
Constructor Details
#initialize(path) ⇒ Readme
Initialize a new instance of Drud::Readme
Attributes
-
:path
- The local path of the site cookbooks
Examples
This can be placed in a convenient location, such as a Rake task inside the cookbook. When the render method is called, it will overwrite the cookbooks README.md
readme = Drud::Readme.new(File.dirname(__FILE__))
readme.render
52 53 54 55 |
# File 'lib/qddrud/readme.rb', line 52 def initialize(path) @path = File.(path) @cookbooks = load_cookbooks end |
Instance Attribute Details
#cookbooks ⇒ Object
Hash map of all site cookbooks including metadata
35 36 37 |
# File 'lib/qddrud/readme.rb', line 35 def cookbooks @cookbooks end |
#path ⇒ Object
Path to the site-cookbooks
38 39 40 |
# File 'lib/qddrud/readme.rb', line 38 def path @path end |
Instance Method Details
#render ⇒ Object
Renders the README.md file and saves it in the cookbooks path.
58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/qddrud/readme.rb', line 58 def render markdown = ReadmeTemplate.new( metadata: @metadata, tasks: @tasks, credit: @credit ) template_path = File.join( File.dirname(File.(__FILE__)), '../../templates/readme.md.erb' ) readme = markdown.render(File.read(template_path)) File.open("#{@cookbook}/README.md", 'w') { |file| file.write(readme) } end |