lib/percy/capybara/loaders/filesystem_loader.rb in percy-capybara-2.4.0 vs lib/percy/capybara/loaders/filesystem_loader.rb in percy-capybara-2.4.1
- old
+ new
@@ -4,30 +4,29 @@
require 'pathname'
module Percy
module Capybara
module Loaders
-
# Resource loader that looks for resources in the specified folder.
class FilesystemLoader < BaseLoader
SKIP_RESOURCE_EXTENSIONS = [
- '.map', # Ignore source maps.
- '.gz', # Ignore gzipped files.
- ]
- MAX_FILESIZE_BYTES = 15 * 1024**2 # 15 MB.
+ '.map', # Ignore source maps.
+ '.gz', # Ignore gzipped files.
+ ].freeze
+ MAX_FILESIZE_BYTES = 15 * 1024**2 # 15 MB.
def initialize(options = {})
# @assets_dir should point to a _compiled_ static assets directory, not source assets.
@assets_dir = options[:assets_dir]
@base_url = options[:base_url] || ''
- raise ArgumentError.new('assets_dir is required') if @assets_dir.nil? || @assets_dir == ''
- if !Pathname.new(@assets_dir).absolute?
- raise ArgumentError.new("assets_dir needs to be an absolute path. Received: #{@assets_dir}")
+ raise ArgumentError, 'assets_dir is required' if @assets_dir.nil? || @assets_dir == ''
+ unless Pathname.new(@assets_dir).absolute?
+ raise ArgumentError, "assets_dir needs to be an absolute path. Received: #{@assets_dir}"
end
- if !Dir.exist?(@assets_dir)
- raise ArgumentError.new("assets_dir provided was not found. Received: #{@assets_dir}")
+ unless Dir.exist?(@assets_dir)
+ raise ArgumentError, "assets_dir provided was not found. Received: #{@assets_dir}"
end
super
end
@@ -37,10 +36,10 @@
def build_resources
resources = []
Find.find(@assets_dir).each do |path|
# Skip directories.
- next if !FileTest.file?(path)
+ next unless FileTest.file?(path)
# Skip certain extensions.
next if SKIP_RESOURCE_EXTENSIONS.include?(File.extname(path))
# Skip large files, these are hopefully downloads and not used in page rendering.
next if File.size(path) > MAX_FILESIZE_BYTES