module Ore::Paths

A mixin for {Project} which provides methods for working with paths.

Public Instance Methods

bin_dir() click to toggle source

The ‘bin/` directory of the project.

@return [Pathname]

The path to the `bin/` directory.
# File lib/ore/paths.rb, line 29
def bin_dir
  @root.join(@@lib_dir)
end
directory?(path) click to toggle source

Determines if a directory exists within the project.

@param [String] path

The path of the directory, relative to the project.

@return [Boolean]

Specifies whether the directory exists in the project.
# File lib/ore/paths.rb, line 85
def directory?(path)
  @root.join(path).directory?
end
each_path(paths,&block) click to toggle source

Iterates over the paths.

@param [Array<String>, String] paths

The paths or path glob pattern to iterate over.

@yield [path]

The given block will be passed each individual path.

@yieldparam [String] path

An individual path.

@ since 0.1.3

# File lib/ore/paths.rb, line 160
def each_path(paths,&block)
  case paths
  when Array
    paths.each(&block)
  else
    glob(paths,&block)
  end
end
file?(path) click to toggle source

Determines if a file exists within the project.

@param [String] path

The path of the file, relative to the project.

@return [Boolean]

Specifies whether the file exists in the project.
# File lib/ore/paths.rb, line 98
def file?(path)
  @project_files.include?(path)
end
glob(pattern) { |path| ... } click to toggle source

Finds paths within the project that match a glob pattern.

@param [String] pattern

The glob pattern.

@yield [path]

The given block will be passed matching paths.

@yieldparam [String] path

A path relative to the root directory of the project.
# File lib/ore/paths.rb, line 136
def glob(pattern)
  within do
    Dir.glob(pattern) do |path|
      if (@project_files.include?(path) || File.directory?(path))
        yield path
      end
    end
  end
end
lib_dir() click to toggle source

The ‘lib/` directory of the project.

@return [Pathname]

The path to the `lib/` directory.
# File lib/ore/paths.rb, line 39
def lib_dir
  @root.join(@@lib_dir)
end
lib_directory?(path) click to toggle source

Determines if a directory exists within the ‘lib/` directory of the project.

@return [Boolean]

Specifies that the directory exists within the `lib/` directory.
# File lib/ore/paths.rb, line 109
def lib_directory?(path)
  directory?(File.join(@@lib_dir,path))
end
lib_file?(path) click to toggle source

Determines if a file exists within the ‘lib/` directory of the project.

@return [Boolean]

Specifies that the file exists within the `lib/` directory.
# File lib/ore/paths.rb, line 120
def lib_file?(path)
  file?(File.join(@@lib_dir,path))
end
lib_path(*names) click to toggle source

Builds a path relative to the ‘lib/` directory.

@param [Array] names

The directory names of the path.

@return [Pathname]

The new path.
# File lib/ore/paths.rb, line 62
def lib_path(*names)
  path(@@lib_dir,*names)
end
path(*names) click to toggle source

Builds a path relative to the project.

@param [Array] names

The directory names of the path.

@return [Pathname]

The new path.
# File lib/ore/paths.rb, line 19
def path(*names)
  @root.join(*names)
end
pkg_dir() click to toggle source

The ‘pkg/` directory of the project.

@return [Pathname]

The path to the `pkg/` directory.
# File lib/ore/paths.rb, line 49
def pkg_dir
  @root.join(@@pkg_dir)
end
pkg_file() click to toggle source

Builds a relative path into the ‘pkg/` directory for the `.gem` file.

@return [String]

The path of a `.gem` file for the project.
# File lib/ore/paths.rb, line 72
def pkg_file
  File.join(@@pkg_dir,"#{@name}-#{@version}.gem")
end