Skip to content

Commit

Permalink
Rename parent_envs to parenvs
Browse files Browse the repository at this point in the history
  • Loading branch information
wch committed Sep 1, 2012
1 parent e5c9f76 commit 380415f
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 16 deletions.
2 changes: 1 addition & 1 deletion NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export(loaded_packages)
export(missing_s3)
export(ns_env)
export(on_path)
export(parent_envs)
export(parenvs)
export(parse_ns_file)
export(pkg_env)
export(release)
Expand Down
2 changes: 1 addition & 1 deletion NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ INTROSPECTION
* New function `parse_ns_file()`, which parses a NAMESPACE file for a
package.

* New function `parent_envs()`, which parents the parent environments
* New function `parenvs()`, which parents the parent environments
of an object. (Winston Chang)

devtools 0.7.1
Expand Down
8 changes: 4 additions & 4 deletions R/parent-envs.r
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@
#' top-level environment).
#' @examples
#' # Print the current environment and its parents
#' parent_envs()
#' parenvs()
#'
#' # Print the parent environments of the load_all function
#' e <- parent_envs(load_all)
#' e <- parenvs(load_all)
#' e
#'
#' # Get all parent environments, going all the way to empty env
#' e <- parent_envs(load_all, TRUE)
#' e <- parenvs(load_all, TRUE)
#' e
#'
#' # Print e with paths
Expand All @@ -35,7 +35,7 @@
#' e[[1]]
#' ls(e[[1]], all.names = TRUE)
#' @export
parent_envs <- function(e = parent.frame(), all = FALSE) {
parenvs <- function(e = parent.frame(), all = FALSE) {
if (!is.environment(e)) e <- environment(e)
if (is.null(e)) return(NULL)

Expand Down
8 changes: 4 additions & 4 deletions inst/tests/test-namespace.r
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ context("Namespace")

# Is e an ancestor environment of x?
is_ancestor_env <- function(e, x) {
x_par <- parent_envs(x, all = TRUE)
x_par <- parenvs(x, all = TRUE)

for (p in x_par) {
if (identical(e, p)) return(TRUE)
Expand Down Expand Up @@ -91,9 +91,9 @@ test_that("Namespace, imports, and package environments have correct hierarchy",
nsenv <- ns_env("namespace")
impenv <- imports_env("namespace")

expect_identical(parent_envs(nsenv)[[2]], impenv)
expect_identical(parent_envs(nsenv)[[3]], .BaseNamespaceEnv)
expect_identical(parent_envs(nsenv)[[4]], .GlobalEnv)
expect_identical(parenvs(nsenv)[[2]], impenv)
expect_identical(parenvs(nsenv)[[3]], .BaseNamespaceEnv)
expect_identical(parenvs(nsenv)[[4]], .GlobalEnv)

# pkgenv should be an ancestor of the global environment
expect_true(is_ancestor_env(pkgenv, .GlobalEnv))
Expand Down
12 changes: 6 additions & 6 deletions man/parent_envs.Rd → man/parenvs.Rd
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
\name{parent_envs}
\alias{parent_envs}
\name{parenvs}
\alias{parenvs}
\title{Given an environment or object, return an \code{envlist} of its
parent environments.}
\usage{
parent_envs(e = parent.frame(), all = FALSE)
parenvs(e = parent.frame(), all = FALSE)
}
\arguments{
\item{e}{An environment or other object.}
Expand All @@ -19,14 +19,14 @@ parent environments.}
}
\examples{
# Print the current environment and its parents
parent_envs()
parenvs()

# Print the parent environments of the load_all function
e <- parent_envs(load_all)
e <- parenvs(load_all)
e

# Get all parent environments, going all the way to empty env
e <- parent_envs(load_all, TRUE)
e <- parenvs(load_all, TRUE)
e

# Print e with paths
Expand Down

0 comments on commit 380415f

Please sign in to comment.