Skip to content

Commit

Permalink
fix: Use consistent naming
Browse files Browse the repository at this point in the history
  • Loading branch information
LeoniePhiline committed Dec 6, 2022
1 parent 26bd9b6 commit c806d78
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 29 deletions.
2 changes: 1 addition & 1 deletion dotenv/src/iter.rs
Expand Up @@ -44,7 +44,7 @@ impl<R: Read> Iter<R> {
///
/// If a variable is specified multiple times within the reader's data,
/// then the last occurrence is applied.
pub fn overload(mut self) -> Result<()> {
pub fn load_override(mut self) -> Result<()> {
self.remove_bom()?;

for item in self {
Expand Down
40 changes: 20 additions & 20 deletions dotenv/src/lib.rs
Expand Up @@ -67,7 +67,7 @@ pub fn vars() -> Vars {
/// file, the *first one* is applied.
///
/// If you wish to ensure all variables are loaded from your *.env* file, ignoring variables
/// already existing in the environment, then use [`from_path_overload()`] instead.
/// already existing in the environment, then use [`from_path_override()`] instead.
///
/// # Examples
///
Expand Down Expand Up @@ -98,11 +98,11 @@ pub fn from_path<P: AsRef<Path>>(path: P) -> Result<()> {
/// use dirs::home_dir;
///
/// let my_path = home_dir().map(|a| a.join("/absolute/path/.env")).unwrap();
/// dotenvy::from_path_overload(my_path.as_path());
/// dotenvy::from_path_override(my_path.as_path());
/// ```
pub fn from_path_overload<P: AsRef<Path>>(path: P) -> Result<()> {
pub fn from_path_override<P: AsRef<Path>>(path: P) -> Result<()> {
let iter = Iter::new(File::open(path).map_err(Error::Io)?);
iter.overload()
iter.load_override()
}

/// Returns an iterator over environment variables from the specified path.
Expand Down Expand Up @@ -132,7 +132,7 @@ pub fn from_path_iter<P: AsRef<Path>>(path: P) -> Result<Iter<File>> {
/// file, the *first one* is applied.
///
/// If you wish to ensure all variables are loaded from your *.env* file, ignoring variables
/// already existing in the environment, then use [`from_filename_overload()`] instead.
/// already existing in the environment, then use [`from_filename_override()`] instead.
///
/// # Examples
/// ```no_run
Expand Down Expand Up @@ -162,17 +162,17 @@ pub fn from_filename<P: AsRef<Path>>(filename: P) -> Result<PathBuf> {
///
/// # Examples
/// ```no_run
/// dotenvy::from_filename_overload("custom.env").unwrap();
/// dotenvy::from_filename_override("custom.env").unwrap();
/// ```
///
/// It is also possible to load from a typical *.env* file like so. However, using [`overload()`] is preferred.
/// It is also possible to load from a typical *.env* file like so. However, using [`dotenv_override()`] is preferred.
///
/// ```
/// dotenvy::from_filename_overload(".env").unwrap();
/// dotenvy::from_filename_override(".env").unwrap();
/// ```
pub fn from_filename_overload<P: AsRef<Path>>(filename: P) -> Result<PathBuf> {
pub fn from_filename_override<P: AsRef<Path>>(filename: P) -> Result<PathBuf> {
let (path, iter) = Finder::new().filename(filename.as_ref()).find()?;
iter.overload()?;
iter.load_override()?;
Ok(path)
}

Expand Down Expand Up @@ -203,7 +203,7 @@ pub fn from_filename_iter<P: AsRef<Path>>(filename: P) -> Result<Iter<File>> {
/// the *first one* is applied.
///
/// If you wish to ensure all variables are loaded from your `reader`, ignoring variables
/// already existing in the environment, then use [`from_read_overload()`] instead.
/// already existing in the environment, then use [`from_read_override()`] instead.
///
/// For regular files, use [`from_path()`] or [`from_filename()`].
///
Expand Down Expand Up @@ -235,7 +235,7 @@ pub fn from_read<R: io::Read>(reader: R) -> Result<()> {
/// or if you want to be able to override environment variables on the command line,
/// then use [`from_read()`] instead.
///
/// For regular files, use [`from_path_overload()`] or [`from_filename_overload()`].
/// For regular files, use [`from_path_override()`] or [`from_filename_override()`].
///
/// # Examples
/// ```no_run
Expand All @@ -244,11 +244,11 @@ pub fn from_read<R: io::Read>(reader: R) -> Result<()> {
/// use std::os::unix::net::UnixStream;
///
/// let mut stream = UnixStream::connect("/some/socket").unwrap();
/// dotenvy::from_read_overload(stream).unwrap();
/// dotenvy::from_read_override(stream).unwrap();
/// ```
pub fn from_read_overload<R: io::Read>(reader: R) -> Result<()> {
pub fn from_read_override<R: io::Read>(reader: R) -> Result<()> {
let iter = Iter::new(reader);
iter.overload()?;
iter.load_override()?;
Ok(())
}

Expand Down Expand Up @@ -281,7 +281,7 @@ pub fn from_read_iter<R: io::Read>(reader: R) -> Iter<R> {
/// file, the *first one* is applied.
///
/// If you wish to ensure all variables are loaded from your *.env* file, ignoring variables
/// already existing in the environment, then use [`overload()`] instead.
/// already existing in the environment, then use [`dotenv_override()`] instead.
///
/// An error will be returned if the file is not found.
///
Expand All @@ -308,12 +308,12 @@ pub fn dotenv() -> Result<PathBuf> {
///
/// # Examples
/// ```
/// use dotenvy::overload;
/// overload().ok();
/// use dotenvy::dotenv_override;
/// dotenv_override().ok();
/// ```
pub fn overload() -> Result<PathBuf> {
pub fn dotenv_override() -> Result<PathBuf> {
let (path, iter) = Finder::new().find()?;
iter.overload()?;
iter.load_override()?;
Ok(path)
}

Expand Down
Expand Up @@ -7,10 +7,10 @@ use dotenvy::*;
use crate::common::*;

#[test]
fn test_overload() -> Result<(), Box<dyn Error>> {
fn test_default_location_override() -> Result<(), Box<dyn Error>> {
let dir = make_test_dotenv()?;

overload()?;
dotenv_override()?;

assert_eq!(env::var("TESTKEY")?, "test_val_overridden");
assert_eq!(env::var("EXISTING")?, "from_file");
Expand Down
Expand Up @@ -6,10 +6,10 @@ use std::{env, error::Error, result::Result};
use crate::common::*;

#[test]
fn test_from_filename() -> Result<(), Box<dyn Error>> {
fn test_from_filename_override() -> Result<(), Box<dyn Error>> {
let dir = make_test_dotenv()?;

from_filename_overload(".env")?;
from_filename_override(".env")?;

assert_eq!(env::var("TESTKEY")?, "test_val_overridden");
assert_eq!(env::var("EXISTING")?, "from_file");
Expand Down
Expand Up @@ -5,13 +5,13 @@ use dotenvy::*;
use std::{env, error::Error, result::Result};

#[test]
fn test_from_path() -> Result<(), Box<dyn Error>> {
fn test_from_path_override() -> Result<(), Box<dyn Error>> {
let dir = make_test_dotenv()?;

let mut path = env::current_dir()?;
path.push(".env");

from_path_overload(&path)?;
from_path_override(&path)?;

assert_eq!(env::var("TESTKEY")?, "test_val_overridden");
assert_eq!(env::var("EXISTING")?, "from_file");
Expand Down
Expand Up @@ -6,10 +6,10 @@ use std::{env, error::Error, fs::File, result::Result};
use crate::common::*;

#[test]
fn test_from_read() -> Result<(), Box<dyn Error>> {
fn test_from_read_override() -> Result<(), Box<dyn Error>> {
let dir = make_test_dotenv()?;

from_read_overload(File::open(".env")?)?;
from_read_override(File::open(".env")?)?;

assert_eq!(env::var("TESTKEY")?, "test_val_overridden");
assert_eq!(env::var("EXISTING")?, "from_file");
Expand Down

0 comments on commit c806d78

Please sign in to comment.