class Fake::Path
Attributes
path[R]
Public Class Methods
new(path)
click to toggle source
# File lib/fake/path.rb, line 6 def initialize(path) @path = path end
Public Instance Methods
eql?(path_str)
click to toggle source
# File lib/fake/path.rb, line 10 def eql?(path_str) if dynamic? dynamic_paths_eql?(path_str) else path == path_str end end
Private Instance Methods
convert_to_regexp(parts)
click to toggle source
# File lib/fake/path.rb, line 37 def convert_to_regexp(parts) parts.map do |part| if dynamic_path_part?(':') Regexp.new('.*') else Regexp.new('^#{part}$') end end end
dynamic?()
click to toggle source
# File lib/fake/path.rb, line 33 def dynamic? path.include?(':') end
dynamic_path_part?(part)
click to toggle source
# File lib/fake/path.rb, line 47 def dynamic_path_part?(part) part.start_with?(':') end
dynamic_paths_eql?(path_str)
click to toggle source
# File lib/fake/path.rb, line 20 def dynamic_paths_eql?(path_str) parts = path.split('/') other_parts = path_str.split('/') return false if parts.length != other_parts.length regexp_parts = convert_to_regexp(parts) regexp_parts.each_with_index do |regexp, index| return false unless regexp.match(other_parts[index]) end return true end