Learn R Programming

PaRe (version 0.1.16)

File: R6 File class

Description

Class representing a file containing code.

Arguments

Super class

PaRe::Code -> File

Methods

Inherited methods


Method new()

Initializer method

Usage

File$new(repoPath, filePath)

Arguments

repoPath

(character)
Path to repository.

filePath

(character)
Relative path to file

Returns

invisible(self)


Method getFunctions()

Get method to get a list of Function objects

Usage

File$getFunctions()

Returns

(list)
List of Function objects.


Method getFunctionTable()

Get method to retrieve the function table.

Usage

File$getFunctionTable()

Returns

(data.frame)

columndata type
namecharacter
lineStartinteger
lineEndnumeric
nArgsinteger
cycloCompinteger


Method getType()

Gets type of file

Usage

File$getType()

Returns

(character)


Method getFilePath()

Gets relative file path

Usage

File$getFilePath()

Returns

(character)


Method getBlameTable()

Gets table of git blame

Usage

File$getBlameTable()

Returns

(tibble)


Method clone()

The objects of this class are cloneable with this method.

Usage

File$clone(deep = FALSE)

Arguments

deep

Whether to make a deep clone.

See Also

Other Representations: Code, Function, Repository

Examples

Run this code
fetchedRepo <- tryCatch(
  {
    # Set dir to clone repository to.
    tempDir <- tempdir()
    pathToRepo <- file.path(tempDir, "glue")

    # Clone repo
    git2r::clone(
      url = "https://github.com/tidyverse/glue.git",
      local_path = pathToRepo
    )

    # Create instance of Repository object.
    repo <- PaRe::Repository$new(path = pathToRepo)

    # Set fetchedRepo to TRUE if all goes well.
    TRUE
  },
  error = function(e) {
    # Set fetchedRepo to FALSE if an error is encountered.
    FALSE
  },
  warning = function(w) {
    # Set fetchedRepo to FALSE if a warning is encountered.
    FALSE
  }
)

if (fetchedRepo) {
  files <- repo$getRFiles()
  files[[1]]
}

Run the code above in your browser using DataLab