class CC::Config::Prepare::Fetch::Entry
Attributes
path[R]
url[R]
Public Class Methods
from_data(data)
click to toggle source
# File lib/cc/config/prepare.rb, line 52 def self.from_data(data) case data when String then new(data) when Hash then new(data.fetch("url"), data["path"]) end end
new(url, path = nil)
click to toggle source
# File lib/cc/config/prepare.rb, line 59 def initialize(url, path = nil) @url = url @path = path || url.split("/").last validate_path! end
Public Instance Methods
==(other)
click to toggle source
Useful in specs
# File lib/cc/config/prepare.rb, line 67 def ==(other) other.is_a?(self.class) && other.url == url && other.path == path end
Private Instance Methods
validate_path!()
click to toggle source
Duplicate a validation which has security implication. This should always be caught upstream, so raising loudly is fine.
# File lib/cc/config/prepare.rb, line 77 def validate_path! if path.blank? raise ArgumentError, "path cannot be be blank" end pathname = Pathname.new(path) if pathname.absolute? raise ArgumentError, "path cannot be absolute: #{path}" end if pathname.cleanpath.to_s != pathname.to_s || path.include?("..") raise ArgumentError, "path cannot point outside the current directory: #{path}" end end