module Garcon::Resource::Validations::ClassMethods
Public Instance Methods
absolute_uri?(source)
click to toggle source
Boolean
, true if source is an absolute URI, false otherwise.
@param [String] source
@return [Boolean]
# File lib/garcon/chef/validations.rb, line 53 def absolute_uri?(source) source =~ URI::ABS_URI && URI.parse(source).absolute? rescue URI::InvalidURIError false end
included(descendant)
click to toggle source
Hook called when module is included.
@param [Module] descendant
The including module or class.
@return [self]
@api private
Calls superclass method
# File lib/garcon/chef/validations.rb, line 67 def included(descendant) super descendant.extend ClassMethods end
source_callbacks()
click to toggle source
Callback for source URL validation.
@return [Proc]
# File lib/garcon/chef/validations.rb, line 32 def source_callbacks { 'Source must be an absolute URI' => ->(src) { valid_source?(src) }} end
valid_source?(source)
click to toggle source
Validate that the source attribute is an absolute URI or file and not an not empty string.
@param [String]
@return [Boolean]
# File lib/garcon/chef/validations.rb, line 43 def valid_source?(source) absolute_uri?(source) ? true : ::File.exist?(source) end