class RSpecCommand::MatchFixture::FileList

Attributes

path[R]
root[R]

Public Class Methods

new(root, path=nil) click to toggle source

@param root [String] Absolute path to the root of the files. @param path [String] Relative path to the specific files.

# File lib/rspec_command/match_fixture.rb, line 121
def initialize(root, path=nil)
  @root = root
  @path = path
end

Public Instance Methods

absolute(file) click to toggle source

Convert a relative path to an absolute one.

# File lib/rspec_command/match_fixture.rb, line 155
def absolute(file)
  if File.directory?(full_path)
    File.join(full_path, file)
  else
    full_path
  end
end
files() click to toggle source

Relative paths to the target files that exist.

# File lib/rspec_command/match_fixture.rb, line 141
def files
  @files ||= full_files.map {|file| relative(file) }
end
full_files() click to toggle source

Absolute paths to target files that exist.

# File lib/rspec_command/match_fixture.rb, line 132
def full_files
  @full_files ||= if File.directory?(full_path)
    Dir.glob(File.join(full_path, '**', '*'), File::FNM_DOTMATCH).sort
  else
    [full_path].select {|path| File.exist?(path) }
  end
end
full_path() click to toggle source

Absolute path to the target.

# File lib/rspec_command/match_fixture.rb, line 127
def full_path
  @full_path ||= path ? File.join(root, path) : root
end
relative(file) click to toggle source

Convert an absolute path to a relative one

# File lib/rspec_command/match_fixture.rb, line 146
def relative(file)
  if File.directory?(full_path)
    file[full_path.length+1..-1]
  else
    File.basename(file)
  end
end