Class: RightScraper::Resources::Base
- Inherits:
-
Object
- Object
- RightScraper::Resources::Base
- Defined in:
- lib/right_scraper/resources/base.rb
Overview
Localized representation of a resource. Contains the resource contents, and the metadata as a hash. A resource at its core is any abstraction that is statically represented by a set of files and directories and metadata.
The JSON metadata for the resource is in #metadata, and the manifest is in #manifest.
Instance Attribute Summary collapse
-
#manifest ⇒ Object
(Hash) Manifest for resource.
-
#metadata ⇒ Object
(Hash) Metadata from the resource.
-
#pos ⇒ Object
(String) Position in the repository.
-
#repository ⇒ Object
readonly
(Repositories::Base) Repository the resource was fetched from.
Instance Method Summary collapse
-
#initialize(repo, pos) ⇒ Base
constructor
Create a new resource from the given parameters.
-
#resource_hash ⇒ Object
Resource hash.
Constructor Details
#initialize(repo, pos) ⇒ Base
Create a new resource from the given parameters.
Parameters
- repo(Repositories::Base)
-
Repository containing this resource
55 56 57 58 |
# File 'lib/right_scraper/resources/base.rb', line 55 def initialize(repo, pos) @repository = repo @pos = pos end |
Instance Attribute Details
#manifest ⇒ Object
(Hash) Manifest for resource. A hash of path => SHA-1 digests.
46 47 48 |
# File 'lib/right_scraper/resources/base.rb', line 46 def manifest @manifest end |
#metadata ⇒ Object
(Hash) Metadata from the resource.
43 44 45 |
# File 'lib/right_scraper/resources/base.rb', line 43 def @metadata end |
#pos ⇒ Object
(String) Position in the repository.
49 50 51 |
# File 'lib/right_scraper/resources/base.rb', line 49 def pos @pos end |
#repository ⇒ Object (readonly)
(Repositories::Base) Repository the resource was fetched from.
40 41 42 |
# File 'lib/right_scraper/resources/base.rb', line 40 def repository @repository end |
Instance Method Details
#resource_hash ⇒ Object
Resource hash
Return
- hash(String)
-
Hexadecimal value that uniquely identifies this resource
64 65 66 |
# File 'lib/right_scraper/resources/base.rb', line 64 def resource_hash Digest::SHA1.hexdigest("#{PROTOCOL_VERSION}\000#{@repository.checkout_hash}\000#{@pos}") end |