Class: ArchiveLocation
- Inherits:
-
Object
- Object
- ArchiveLocation
- Defined in:
- lib/domreactor-redglass/archive_location.rb
Constant Summary collapse
- REQUIRED_BASELINE_BROWSER_CONFIG_KEYS =
[:name, :version, :platform]
Instance Attribute Summary collapse
-
#location ⇒ Object
readonly
Returns the value of attribute location.
-
#opts ⇒ Object
readonly
Returns the value of attribute opts.
Instance Method Summary collapse
- #archives ⇒ Object
- #detect_archive_location ⇒ Object
- #detect_baseline_browser ⇒ Object
- #detect_min_archive_quota ⇒ Object
-
#initialize(location, opts = {}) ⇒ ArchiveLocation
constructor
A new instance of ArchiveLocation.
- #is_valid_baseline_browser_config?(baseline_browser_config) ⇒ Boolean
- #validate! ⇒ Object
Constructor Details
#initialize(location, opts = {}) ⇒ ArchiveLocation
Returns a new instance of ArchiveLocation.
6 7 8 9 |
# File 'lib/domreactor-redglass/archive_location.rb', line 6 def initialize(location, opts={}) @location = location @opts = opts end |
Instance Attribute Details
#location ⇒ Object (readonly)
Returns the value of attribute location.
2 3 4 |
# File 'lib/domreactor-redglass/archive_location.rb', line 2 def location @location end |
#opts ⇒ Object (readonly)
Returns the value of attribute opts.
2 3 4 |
# File 'lib/domreactor-redglass/archive_location.rb', line 2 def opts @opts end |
Instance Method Details
#archives ⇒ Object
11 12 13 |
# File 'lib/domreactor-redglass/archive_location.rb', line 11 def archives @archives ||= archive_list(location) end |
#detect_archive_location ⇒ Object
21 22 23 24 25 |
# File 'lib/domreactor-redglass/archive_location.rb', line 21 def detect_archive_location unless File.directory?(location) raise 'A valid archive location is required.' end end |
#detect_baseline_browser ⇒ Object
31 32 33 34 35 36 37 38 |
# File 'lib/domreactor-redglass/archive_location.rb', line 31 def detect_baseline_browser unless opts[:baseline_browser] && is_valid_baseline_browser_config?(opts[:baseline_browser]) raise 'A valid baseline_browser configuration is required.' end unless has_baseline_archive?(location, opts) raise 'A page archive that corresponds to the baseline browser configuration is required.' end end |
#detect_min_archive_quota ⇒ Object
27 28 29 |
# File 'lib/domreactor-redglass/archive_location.rb', line 27 def detect_min_archive_quota raise 'At least two valid page archives are required.' unless sum_archive_count(location) >= 2 end |
#is_valid_baseline_browser_config?(baseline_browser_config) ⇒ Boolean
40 41 42 |
# File 'lib/domreactor-redglass/archive_location.rb', line 40 def is_valid_baseline_browser_config?(baseline_browser_config) baseline_browser_config.keys.sort == REQUIRED_BASELINE_BROWSER_CONFIG_KEYS.sort end |
#validate! ⇒ Object
15 16 17 18 19 |
# File 'lib/domreactor-redglass/archive_location.rb', line 15 def validate! detect_archive_location detect_min_archive_quota detect_baseline_browser end |