Sha256: 26ce42ff8a5b9880e96259a4e9d0c80af261ca4b56abd9216d02ab83c683dffc

Contents?: true

Size: 920 Bytes

Versions: 26

Compression:

Stored size: 920 Bytes

Contents

module KnifeCookbookDoc
  class RecipeModel
    include KnifeCookbookDoc::BaseModel

    attr_reader :name
    attr_reader :short_description

    def initialize(name, short_description = nil, filename)
      @name = name
      @short_description = short_description
      @filename = filename
      load_descriptions
    end

    private

    def load_descriptions
      current_section = 'main'
      description = extract_description
      description.each_line do |line|
        if /^ *\@section (.*)$/ =~ line
          current_section = $1.strip
        else
          lines = (top_level_descriptions[current_section] || [])
          lines << line.gsub("\n",'')
          top_level_descriptions[current_section] = lines
        end
      end
      if @short_description.nil?
        @short_description = first_sentence(description) || ""
      end
    end

    include ::Chef::Mixin::ConvertToClassName
  end
end

Version data entries

26 entries across 26 versions & 1 rubygems

Version Path
knife-cookbook-doc-0.15.0 lib/knife_cookbook_doc/recipe_model.rb
knife-cookbook-doc-0.14.0 lib/knife_cookbook_doc/recipe_model.rb
knife-cookbook-doc-0.13.0 lib/knife_cookbook_doc/recipe_model.rb
knife-cookbook-doc-0.12.0 lib/knife_cookbook_doc/recipe_model.rb
knife-cookbook-doc-0.11.0 lib/knife_cookbook_doc/recipe_model.rb
knife-cookbook-doc-0.10.0 lib/knife_cookbook_doc/recipe_model.rb