Class: Blinkr::Config
- Inherits:
-
OpenStruct
- Object
- OpenStruct
- Blinkr::Config
- Defined in:
- lib/blinkr/config.rb
Constant Summary collapse
- DEFAULTS =
{:skips => [], :ignores => [], :max_retrys => 3, :browser => 'typhoeus', :viewport => 1200, :phantomjs_threads => 8, :report => 'blinkr.html'}
Constants inherited from OpenStruct
Class Method Summary collapse
Instance Method Summary collapse
- #ignored?(url, code, message) ⇒ Boolean
-
#initialize(hash = {}) ⇒ Config
constructor
A new instance of Config.
- #max_page_retrys ⇒ Object
- #sitemap ⇒ Object
- #skipped?(url) ⇒ Boolean
- #validate ⇒ Object
Methods inherited from OpenStruct
Constructor Details
#initialize(hash = {}) ⇒ Config
13 14 15 |
# File 'lib/blinkr/config.rb', line 13 def initialize(hash={}) super(DEFAULTS.merge(hash)) end |
Class Method Details
.read(file, args) ⇒ Object
6 7 8 9 |
# File 'lib/blinkr/config.rb', line 6 def self.read file, args raise "Cannot read #{file}" unless File.exists? file Config.new(YAML.load_file(file).merge(args).merge({ :config_file => file })) end |
Instance Method Details
#ignored?(url, code, message) ⇒ Boolean
38 39 40 |
# File 'lib/blinkr/config.rb', line 38 def ignored? url, code, ignores.any? { |ignore| ( !url.nil? && ignore.has_key?('url') ? !ignore['url'].match(url).nil? : true ) && ( !code.nil? && ignore.has_key?('code') ? ignore['code'] == code : true ) && ( !.nil? && ignore.has_key?('message') ? !ignore['message'].match().nil? : true ) } end |
#max_page_retrys ⇒ Object
32 33 34 35 36 |
# File 'lib/blinkr/config.rb', line 32 def max_page_retrys r = super || max_retrys raise "Retrys is nil" if r.nil? r end |
#sitemap ⇒ Object
24 25 26 27 28 29 30 |
# File 'lib/blinkr/config.rb', line 24 def sitemap if super.nil? URI.join(base_url, 'sitemap.xml').to_s else super end end |
#skipped?(url) ⇒ Boolean
42 43 44 |
# File 'lib/blinkr/config.rb', line 42 def skipped? url skips.any? { |regex| regex.match(url) } end |
#validate ⇒ Object
17 18 19 20 21 22 |
# File 'lib/blinkr/config.rb', line 17 def validate ignores.each {|ignore| raise "An ignore must be a hash" unless ignore.is_a? Hash} raise "Must specify base_url" if base_url.nil? raise "Must specify sitemap" if sitemap.nil? self end |