Class: Percy::Capybara::Loaders::BaseLoader

Inherits:
Object
  • Object
show all
Defined in:
lib/percy/capybara/loaders/base_loader.rb

Direct Known Subclasses

FilesystemLoader, NativeLoader, SprocketsLoader

Constant Summary collapse

URL_REGEX =

Modified version of Diego Perini’s URL regex. gist.github.com/dperini/729294

Regexp.new(
  # protocol identifier
  '((?:https?:)?//)' \
  '(' +
    # IP address exclusion
    # private & local networks
    '(?!(?:10|127)(?:\\.\\d{1,3}){3})' \
    '(?!(?:169\\.254|192\\.168)(?:\\.\\d{1,3}){2})' \
    '(?!172\\.(?:1[6-9]|2\\d|3[0-1])(?:\\.\\d{1,3}){2})' +
    # IP address dotted notation octets
    # excludes loopback network 0.0.0.0
    # excludes reserved space >= 224.0.0.0
    # excludes network & broacast addresses
    # (first & last IP address of each class)
    '(?:[1-9]\\d?|1\\d\\d|2[01]\\d|22[0-3])' \
    '(?:\\.(?:1?\\d{1,2}|2[0-4]\\d|25[0-5])){2}' \
    '(?:\\.(?:[1-9]\\d?|1\\d\\d|2[0-4]\\d|25[0-4]))' \
  '|' +
    # host name
    '(?:(?:[a-z\\u00a1-\\uffff0-9]-*)*[a-z\\u00a1-\\uffff0-9]+)' +
    # domain name
    '(?:\\.(?:[a-z\\u00a1-\\uffff0-9]-*)*[a-z\\u00a1-\\uffff0-9]+)*' \
  ')' +
  # port number
  '(:\\d{2,5})?' +
  # resource path
  "(/[^\\s\"']*)?"
)

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ BaseLoader

Returns a new instance of BaseLoader.

Parameters:

  • page (Capybara::Session)

    The Capybara page.



38
39
40
# File 'lib/percy/capybara/loaders/base_loader.rb', line 38

def initialize(options = {})
  @page = options[:page]
end

Instance Attribute Details

#pageObject (readonly)

Returns the value of attribute page.



35
36
37
# File 'lib/percy/capybara/loaders/base_loader.rb', line 35

def page
  @page
end

Instance Method Details

#build_resourcesObject

Raises:

  • (NotImplementedError)


42
43
44
# File 'lib/percy/capybara/loaders/base_loader.rb', line 42

def build_resources
  raise NotImplementedError, 'subclass must implement abstract method'
end

#snapshot_resourcesObject

Raises:

  • (NotImplementedError)


46
47
48
# File 'lib/percy/capybara/loaders/base_loader.rb', line 46

def snapshot_resources
  raise NotImplementedError, 'subclass must implement abstract method'
end