From 9445db11086aef489b2131f971e7ea62a4a803ce Mon Sep 17 00:00:00 2001 From: LeoniePhiline <22329650+LeoniePhiline@users.noreply.github.com> Date: Tue, 6 Dec 2022 22:42:45 +0100 Subject: [PATCH] fix: Use consistent naming --- dotenv/src/iter.rs | 6 +- dotenv/src/lib.rs | 62 +++++++++---------- ...d.rs => test-default-location-override.rs} | 4 +- ...load.rs => test-from-filename-override.rs} | 4 +- ...overload.rs => test-from-path-override.rs} | 4 +- ...overload.rs => test-from-read-override.rs} | 4 +- 6 files changed, 42 insertions(+), 42 deletions(-) rename dotenv/tests/{test-default-location-overload.rs => test-default-location-override.rs} (79%) rename dotenv/tests/{test-from-filename-overload.rs => test-from-filename-override.rs} (77%) rename dotenv/tests/{test-from-path-overload.rs => test-from-path-override.rs} (81%) rename dotenv/tests/{test-from-read-overload.rs => test-from-read-override.rs} (76%) diff --git a/dotenv/src/iter.rs b/dotenv/src/iter.rs index 5919b55..7ff9e48 100644 --- a/dotenv/src/iter.rs +++ b/dotenv/src/iter.rs @@ -21,8 +21,8 @@ impl Iter { } } - /// Loads all variables found in the `reader`, which not yet exist in the environment, - /// into the environment. + /// Loads all variables found in the `reader` into the environment, + /// preserving any existing environment variables of the same name. /// /// If a variable is specified multiple times within the reader's data, /// then the first occurrence is applied. @@ -44,7 +44,7 @@ impl Iter { /// /// 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 { diff --git a/dotenv/src/lib.rs b/dotenv/src/lib.rs index ee2631f..89156f1 100644 --- a/dotenv/src/lib.rs +++ b/dotenv/src/lib.rs @@ -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 /// @@ -88,9 +88,9 @@ pub fn from_path>(path: P) -> Result<()> { /// Where multiple declarations for the same environment variable exist in your *.env* file, the /// *last one* is applied. /// -/// If you want the existing environment to take precendence, +/// If you want the existing environment to take precedence, /// or if you want to be able to override environment variables on the command line, -/// then use [`from_path()`] instead. +/// then use [`from_path`] instead. /// /// # Examples /// @@ -98,14 +98,14 @@ pub fn from_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>(path: P) -> Result<()> { +pub fn from_path_override>(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. +/// Returns an iterator over environment variables from the specified path. /// /// # Examples /// @@ -132,14 +132,14 @@ pub fn from_path_iter>(path: P) -> Result> { /// 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 /// dotenvy::from_filename("custom.env").unwrap(); /// ``` /// -/// It is also possible to load from a typical *.env* file like so. However, using [`dotenv()`] is preferred. +/// It is also possible to load from a typical *.env* file like so. However, using [`dotenv`] is preferred. /// /// ``` /// dotenvy::from_filename(".env").unwrap(); @@ -156,23 +156,23 @@ pub fn from_filename>(filename: P) -> Result { /// Where multiple declarations for the same environment variable exist in your *.env* file, the /// *last one* is applied. /// -/// If you want the existing environment to take precendence, +/// If you want the existing environment to take precedence, /// or if you want to be able to override environment variables on the command line, -/// then use [`from_filename()`] instead. +/// then use [`from_filename`] instead. /// /// # 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>(filename: P) -> Result { +pub fn from_filename_override>(filename: P) -> Result { let (path, iter) = Finder::new().filename(filename.as_ref()).find()?; - iter.overload()?; + iter.load_override()?; Ok(path) } @@ -203,9 +203,9 @@ pub fn from_filename_iter>(filename: P) -> Result> { /// 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()`]. +/// For regular files, use [`from_path`] or [`from_filename`]. /// /// # Examples /// @@ -231,11 +231,11 @@ pub fn from_read(reader: R) -> Result<()> { /// Where multiple declarations for the same environment variable exist in your `reader`, the /// *last one* is applied. /// -/// If you want the existing environment to take precendence, +/// If you want the existing environment to take precedence, /// or if you want to be able to override environment variables on the command line, -/// then use [`from_read()`] instead. +/// 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 @@ -244,11 +244,11 @@ pub fn from_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(reader: R) -> Result<()> { +pub fn from_read_override(reader: R) -> Result<()> { let iter = Iter::new(reader); - iter.overload()?; + iter.load_override()?; Ok(()) } @@ -281,7 +281,7 @@ pub fn from_read_iter(reader: R) -> Iter { /// 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. /// @@ -302,18 +302,18 @@ pub fn dotenv() -> Result { /// Where multiple declarations for the same environment variable exist in your *.env* file, the /// *last one* is applied. /// -/// If you want the existing environment to take precendence, +/// If you want the existing environment to take precedence, /// or if you want to be able to override environment variables on the command line, -/// then use [`dotenv()`] instead. +/// then use [`dotenv`] instead. /// /// # Examples /// ``` -/// use dotenvy::overload; -/// overload().ok(); +/// use dotenvy::dotenv_override; +/// dotenv_override().ok(); /// ``` -pub fn overload() -> Result { +pub fn dotenv_override() -> Result { let (path, iter) = Finder::new().find()?; - iter.overload()?; + iter.load_override()?; Ok(path) } diff --git a/dotenv/tests/test-default-location-overload.rs b/dotenv/tests/test-default-location-override.rs similarity index 79% rename from dotenv/tests/test-default-location-overload.rs rename to dotenv/tests/test-default-location-override.rs index f299027..a203c1b 100644 --- a/dotenv/tests/test-default-location-overload.rs +++ b/dotenv/tests/test-default-location-override.rs @@ -7,10 +7,10 @@ use dotenvy::*; use crate::common::*; #[test] -fn test_overload() -> Result<(), Box> { +fn test_default_location_override() -> Result<(), Box> { let dir = make_test_dotenv()?; - overload()?; + dotenv_override()?; assert_eq!(env::var("TESTKEY")?, "test_val_overridden"); assert_eq!(env::var("EXISTING")?, "from_file"); diff --git a/dotenv/tests/test-from-filename-overload.rs b/dotenv/tests/test-from-filename-override.rs similarity index 77% rename from dotenv/tests/test-from-filename-overload.rs rename to dotenv/tests/test-from-filename-override.rs index abc132b..d7ccd2a 100644 --- a/dotenv/tests/test-from-filename-overload.rs +++ b/dotenv/tests/test-from-filename-override.rs @@ -6,10 +6,10 @@ use std::{env, error::Error, result::Result}; use crate::common::*; #[test] -fn test_from_filename() -> Result<(), Box> { +fn test_from_filename_override() -> Result<(), Box> { 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"); diff --git a/dotenv/tests/test-from-path-overload.rs b/dotenv/tests/test-from-path-override.rs similarity index 81% rename from dotenv/tests/test-from-path-overload.rs rename to dotenv/tests/test-from-path-override.rs index fa8292e..f2fadb2 100644 --- a/dotenv/tests/test-from-path-overload.rs +++ b/dotenv/tests/test-from-path-override.rs @@ -5,13 +5,13 @@ use dotenvy::*; use std::{env, error::Error, result::Result}; #[test] -fn test_from_path() -> Result<(), Box> { +fn test_from_path_override() -> Result<(), Box> { 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"); diff --git a/dotenv/tests/test-from-read-overload.rs b/dotenv/tests/test-from-read-override.rs similarity index 76% rename from dotenv/tests/test-from-read-overload.rs rename to dotenv/tests/test-from-read-override.rs index 3b5ef1f..79d691e 100644 --- a/dotenv/tests/test-from-read-overload.rs +++ b/dotenv/tests/test-from-read-override.rs @@ -6,10 +6,10 @@ use std::{env, error::Error, fs::File, result::Result}; use crate::common::*; #[test] -fn test_from_read() -> Result<(), Box> { +fn test_from_read_override() -> Result<(), Box> { 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");