Class: Valise::Unpath::WorkspaceFinder

Inherits:
Object
  • Object
show all
Includes:
Valise::Unpath
Defined in:
lib/valise/utils.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Valise::Unpath

#clean_pathname, #containing_workspace, #current_directory, #file_from_backtrace, #from_here, #make_pathname, #starting_directory, #up_to, #up_until

Instance Attribute Details

#descriptionObject

Returns the value of attribute description.



57
58
59
# File 'lib/valise/utils.rb', line 57

def description
  @description
end

#fallbackObject

Returns the value of attribute fallback.



57
58
59
# File 'lib/valise/utils.rb', line 57

def fallback
  @fallback
end

#search_fromObject

Returns the value of attribute search_from.



57
58
59
# File 'lib/valise/utils.rb', line 57

def search_from
  @search_from
end

#workspace_childrenObject

Returns the value of attribute workspace_children.



57
58
59
# File 'lib/valise/utils.rb', line 57

def workspace_children
  @workspace_children
end

Instance Method Details

#findObject



77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
# File 'lib/valise/utils.rb', line 77

def find
  up_until(search_start, description) do |path|
    path.children(false).any? do |child|
      workspace_children.any? do |vc_config|
        child.fnmatch? vc_config
      end
    end
  end
rescue Errors::NoMatchingPath
  if fallback.nil?
    raise
  else
    fallback
  end
end

#search_startObject



71
72
73
74
75
# File 'lib/valise/utils.rb', line 71

def search_start
  path = make_pathname(search_from)
  path = path.realpath unless path.absolute?
  path
end