class RakeTasks::Doc
This class will handle documentation utilities.
Public Class Methods
new(gem_info = RakeTasks::Gem)
click to toggle source
Constructor.
# File lib/rake_tasks/doc.rb, line 38 def initialize(gem_info = RakeTasks::Gem) @gem_spec = gem_info.gem_spec @gem_title = gem_info.gem_title(@gem_spec) @license_path = 'license' @contents = nil end
Public Instance Methods
readme_contents()
click to toggle source
The default contents for a readme file.
# File lib/rake_tasks/doc.rb, line 46 def readme_contents gem_title = @gem_title gem_spec = @gem_spec @contents ||= %Q{ #{header :h1, "Welcome to #{gem_title}"} #{gem_spec.description} #{header :h2, 'Getting Started'} Install #{gem_title} at the command prompt if you haven't yet: $ gem install #{gem_spec.name} Require the gem in your Gemfile: gem '#{gem_spec.name}', '~> #{gem_spec.version}' Require the gem wherever you need to use it: require '#{gem_spec.name}' #{header :h2, 'Usage'} TODO #{header :h2, 'Additional Notes'} TODO #{header :h2, 'Additional Documentation'} $ rake rdoc:app #{license_details}}.strip return @contents.split("\n") end
Private Instance Methods
header(type, text = nil)
click to toggle source
Returns formatted headers.
# File lib/rake_tasks/doc.rb, line 90 def header(type, text = nil) case type when :h1 "#{text}\n#{'=' * text.length}" when :h2 "#{text}\n#{'-' * text.length}" end end
license_details()
click to toggle source
Compose the license details.
# File lib/rake_tasks/doc.rb, line 100 def license_details return if @gem_spec.licenses.empty? %Q{ #{header :h2, 'License'} #{@gem_title} is released under the #{@gem_spec.licenses.first} license. } end