Skip to content

Commit

Permalink
Updating readme to remove badges
Browse files Browse the repository at this point in the history
  • Loading branch information
anthonycr committed Mar 19, 2024
1 parent bcaaac4 commit 5e2bee9
Showing 1 changed file with 10 additions and 14 deletions.
24 changes: 10 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,14 @@
# Mezzanine
An annotation processor that allows you to read static UTF-8 files synchronously.

[![Build Status](https://travis-ci.org/anthonycr/Mezzanine.svg?branch=master)](https://travis-ci.org/anthonycr/Mezzanine)
[![Download](https://api.bintray.com/packages/anthonycr/android/com.anthonycr.mezzanine%3Amezzanine/images/download.svg)](https://bintray.com/anthonycr/android/com.anthonycr.mezzanine%3Amezzanine)
[![codecov](https://codecov.io/gh/anthonycr/Mezzanine/branch/dev/graph/badge.svg)](https://codecov.io/gh/anthonycr/Mezzanine)

### What does this do?
## What does this do?
Android apps often need to read in a default configuration file on startup and change functionality based on the contents of the configuration file. A convenient, frequently used way to store this configuration file is in assets, and then to read out of this file on startup. This can mean doing expensive disk I/O on the main thread, which increases startup times. You can get around the additional I/O by pasting the contents of the file into a `String` constant, but this can make code review difficult.

Mezzanine solves this problem by generating a class at compile time which stores the file contents in a `String` constant. This is loaded by the class loader, along with your code, when the application is started, rather than requiring additional disk I/O after startup. It acts as an intermediary between files and your running Java code. Instead of needing to paste the contents of the file into the constant yourself, you can store it in its own file and maintain proper separation. For instance, if you are executing JavaScript using a `WebView` or some library like `duktape`, you can store the files in `.js` files without the additional annoyance of needing to perform disk I/O.

Note: There is a hard limit set by the javac compiler where `String` constants cannot exceed `65535` bytes in size.

### Usage
## Usage

```groovy
allprojects {
Expand All @@ -22,7 +18,7 @@ allprojects {
}
```

##### Android/Java
### Android/Java
```groovy
dependencies {
def mezzanineVersion = '1.1.1'
Expand All @@ -43,7 +39,7 @@ android {
}
```

##### Kotlin
### Kotlin
```groovy
apply plugin: 'kotlin-kapt'
Expand All @@ -60,7 +56,7 @@ kapt {
}
```

##### Java
### Java
```groovy
plugins {
id 'net.ltgt.apt' version '0.10'
Expand All @@ -81,7 +77,7 @@ gradle.projectsEvaluated {
}
```

### API
## API
- `@FileStream(String path)`: the path to the file relative to the project root.
- `mezzanine.projectPath` annotation processing argument is used to determine the absolute path of the project root. If not provided, mezzanine will use the root accessible to the javac instance.
- Create an `interface` with one method with no parameters and a return type of `String`.
Expand All @@ -90,9 +86,9 @@ gradle.projectsEvaluated {
- Files are assumed to be encoded as `UTF-8`.
- Files must be less than `65kB`, otherwise compilation will fail.

### Sample
## Sample

#### Kotlin
### Kotlin
```kotlin
@FileStream("path/from/root/to/file.json")
interface MyFileReader {
Expand All @@ -109,7 +105,7 @@ val fileContents = fileReader.readMyFile()
println("File contents: $fileContents")
```

#### Java
### Java
```java
@FileStream("path/from/root/to/file.json")
public interface MyFileReader {
Expand All @@ -126,7 +122,7 @@ String fileContents = fileReader.readMyFile();
System.out.println("File contents: " + fileContents);
```

### License
## License
````
Copyright 2017 Anthony Restaino
Expand Down

0 comments on commit 5e2bee9

Please sign in to comment.