Skip to content

Commit

Permalink
update readme
Browse files Browse the repository at this point in the history
  • Loading branch information
Carmine DiMascio committed Mar 1, 2019
1 parent a440cce commit fad0c61
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 24 deletions.
25 changes: 2 additions & 23 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,14 @@ Use `dotenv.get("...")` instead of Java's `System.getenv(...)`.
<dependency>
<groupId>io.github.cdimascio</groupId>
<artifactId>java-dotenv</artifactId>
<version>4.1.0</version>
<version>4.0.1</version>
</dependency>
```

### Gradle

```groovy
compile 'io.github.cdimascio:java-dotenv:4.1.0'
compile 'io.github.cdimascio:java-dotenv:4.0.1'
```

## Usage
Expand Down Expand Up @@ -135,27 +135,6 @@ dotenv["HOME"]
dotenv["MY_ENV_VAR1"] ?: "default value"
```

### Iterate over environment variables
Note, environment variables specified in the host environment take precedence over those in `.env`.

With **Java**

```java
for (DotenvEntry e : dotenv) {
System.out.println(e.getKey());
System.out.println(e.getValue());
}
```

or with **Kotlin**

```kotlin
for (e in dotenv) {
println(e.key)
println(e.value)
}
```

## Configuration options

### *optional* `directory`
Expand Down
7 changes: 6 additions & 1 deletion src/test/java/tests/JavaTests.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,12 @@ public void iteratorOverDotenv() {
.ignoreIfMalformed()
.load();

dotenv.forEach(e -> assertEquals(dotenv.get(e.getKey()), e.getValue()));
Map<String,String> m = new HashMap<String, String>() {{
put("test", "hi");
put("test1", "hi1");
}};

dotenv.entries().forEach(e -> assertEquals(dotenv.get(e.getKey()), e.getValue()));

for (DotenvEntry e : dotenv) {
assertEquals(dotenv.get(e.getKey()), e.getValue());
Expand Down

0 comments on commit fad0c61

Please sign in to comment.