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.31.1 lib/knife_cookbook_doc/recipe_model.rb
knife-cookbook-doc-0.31.0 lib/knife_cookbook_doc/recipe_model.rb
knife-cookbook-doc-0.30.0 lib/knife_cookbook_doc/recipe_model.rb
knife-cookbook-doc-0.29.0 lib/knife_cookbook_doc/recipe_model.rb
knife-cookbook-doc-0.28.0 lib/knife_cookbook_doc/recipe_model.rb
knife-cookbook-doc-0.27.0 lib/knife_cookbook_doc/recipe_model.rb
knife-cookbook-doc-0.26.0 lib/knife_cookbook_doc/recipe_model.rb
knife-cookbook-doc-0.25.2 lib/knife_cookbook_doc/recipe_model.rb
knife-cookbook-doc-0.24.2 lib/knife_cookbook_doc/recipe_model.rb
knife-cookbook-doc-0.25.0 lib/knife_cookbook_doc/recipe_model.rb
knife-cookbook-doc-0.24.1 lib/knife_cookbook_doc/recipe_model.rb
knife-cookbook-doc-0.24.0 lib/knife_cookbook_doc/recipe_model.rb
knife-cookbook-doc-0.23.0 lib/knife_cookbook_doc/recipe_model.rb
knife-cookbook-doc-0.22.0 lib/knife_cookbook_doc/recipe_model.rb
knife-cookbook-doc-0.21.0 lib/knife_cookbook_doc/recipe_model.rb
knife-cookbook-doc-0.20.0 lib/knife_cookbook_doc/recipe_model.rb
knife-cookbook-doc-0.19.0 lib/knife_cookbook_doc/recipe_model.rb
knife-cookbook-doc-0.18.0 lib/knife_cookbook_doc/recipe_model.rb
knife-cookbook-doc-0.17.0 lib/knife_cookbook_doc/recipe_model.rb
knife-cookbook-doc-0.16.0 lib/knife_cookbook_doc/recipe_model.rb