Class: RightScraper::Resources::Cookbook

Inherits:
Base
  • Object
show all
Defined in:
lib/right_scraper/resources/cookbook.rb

Constant Summary collapse

EMPTY_MANIFEST_JSON =
::JSON.dump(:manifest => {}).freeze

Instance Attribute Summary

Attributes inherited from Base

#manifest, #metadata, #pos, #repository

Instance Method Summary collapse

Methods inherited from Base

#initialize

Constructor Details

This class inherits a constructor from RightScraper::Resources::Base

Instance Method Details

#manifest=(value) ⇒ Object



36
37
38
39
40
# File 'lib/right_scraper/resources/cookbook.rb', line 36

def manifest=(value)
  @manifest_json = nil
  @resource_hash = nil
  @manifest      = value
end

#manifest_jsonObject



42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/right_scraper/resources/cookbook.rb', line 42

def manifest_json
  unless @manifest_json
    if manifest && !manifest.empty?
      # note that we are preserving the :manifest key at the root only to
      # avoid having to change how the manifest is interpreted by Repose.
      manifest_hash = { :manifest => manifest }
      @manifest_json = ::RightSupport::Data::HashTools.deep_sorted_json(manifest_hash, pretty=true).freeze
    else
      @manifest_json = EMPTY_MANIFEST_JSON
    end
  end
  @manifest_json
end

#resource_hashObject



56
57
58
59
60
61
# File 'lib/right_scraper/resources/cookbook.rb', line 56

def resource_hash
  unless @resource_hash
    @resource_hash = ::Digest::MD5.hexdigest(manifest_json).freeze
  end
  @resource_hash
end