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
Returns a new instance of Config.
14 15 16 |
# File 'lib/blinkr/config.rb', line 14 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
39 40 41 |
# File 'lib/blinkr/config.rb', line 39 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
33 34 35 36 37 |
# File 'lib/blinkr/config.rb', line 33 def max_page_retrys r = super || max_retrys raise "Retrys is nil" if r.nil? r end |
#sitemap ⇒ Object
25 26 27 28 29 30 31 |
# File 'lib/blinkr/config.rb', line 25 def sitemap if super.nil? URI.join(base_url, 'sitemap.xml').to_s else super end end |
#skipped?(url) ⇒ Boolean
43 44 45 |
# File 'lib/blinkr/config.rb', line 43 def skipped? url skips.any? { |regex| regex.match(url) } end |
#validate ⇒ Object
18 19 20 21 22 23 |
# File 'lib/blinkr/config.rb', line 18 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 |