Class: KMDB::JsonFile
- Inherits:
-
Object
- Object
- KMDB::JsonFile
- Defined in:
- lib/kmdb/models/json_file.rb
Overview
Models one of KissMetrics’s JSON dumps. Supports caching them from S3 and finding the latest one.
Instance Attribute Summary collapse
-
#revision ⇒ Object
readonly
Returns the value of attribute revision.
Instance Method Summary collapse
- #exist? ⇒ Boolean
-
#initialize(revision) ⇒ JsonFile
constructor
A new instance of JsonFile.
- #metadata ⇒ Object
-
#open(&block) ⇒ Object
Yields an IO object for this file.
Constructor Details
#initialize(revision) ⇒ JsonFile
Returns a new instance of JsonFile.
11 12 13 |
# File 'lib/kmdb/models/json_file.rb', line 11 def initialize(revision) @revision = revision end |
Instance Attribute Details
#revision ⇒ Object (readonly)
Returns the value of attribute revision.
9 10 11 |
# File 'lib/kmdb/models/json_file.rb', line 9 def revision @revision end |
Instance Method Details
#exist? ⇒ Boolean
24 25 26 |
# File 'lib/kmdb/models/json_file.rb', line 24 def exist? _cached_path.exist? || _s3object.exist? end |
#metadata ⇒ Object
28 29 30 |
# File 'lib/kmdb/models/json_file.rb', line 28 def @metadata ||= Dumpfile.get(revision) end |
#open(&block) ⇒ Object
Yields an IO object for this file
16 17 18 19 20 21 22 |
# File 'lib/kmdb/models/json_file.rb', line 16 def open(&block) _cached.open('r') do |io| .update_attributes!(length: io.size) yield io end _flush_cache if _should_flush? end |