Skip to content

Commit

Permalink
Merge branch 'release/v0.1.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
mplatvoet committed Jun 10, 2015
2 parents 5baa826 + f39d282 commit a129a8e
Show file tree
Hide file tree
Showing 17 changed files with 347 additions and 345 deletions.
67 changes: 37 additions & 30 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,37 +1,44 @@
#Progress
Progress tracking for Kotlin.
Track progress for [Kotlin](http://kotlinlang.org)

---
[![CircleCI branch](https://img.shields.io/circleci/project/mplatvoet/progress/master.svg)](https://circleci.com/gh/mplatvoet/progress/tree/master) [![Maven Central](https://img.shields.io/maven-central/v/nl.komponents.progress/progress.svg)](http://search.maven.org/#browse%7C-300825966) [![DUB](https://img.shields.io/dub/l/vibe-d.svg)](https://github.com/mplatvoet/progress/blob/master/LICENSE)

Please refer to [progress.komponents.nl](http://progress.komponents.nl) for more information

```kt
val progress = Progress()
progress.onUpdate { p->
println("${p.percentage}%")
//private part
val control = Progress.control()

//public part
val progress = control.progress

//get notified on updates
progress.update {
println("${value}")
}

//set value
control.value = 0.25
control.value = 0.50
control.value = 0.75
control.value = 1.0
```

## Getting started
This version is build against `kotlin-stdlib:0.12.200`.

###Gradle
```groovy
dependencies {
compile 'nl.komponents.progress:progress:0.1.+'
}
```

val sub1 = progress.child(weight = 0.1)
val sub2 = progress.child(weight = 5)
val sub2sub1 = sub2.child()
val sub2sub2 = sub2.child()
val sub3 = progress.child()
val sub4 = progress.child(weight = 2)

sub1.value = 0.25
sub1.value = 0.50
sub1.value = 0.75
sub1.value = 1.0

sub2sub1.completed = true
sub2sub2.value = 0.5
sub2sub2.value = 1.0

sub3.value = 0.25
sub3.value = 0.50
sub3.value = 0.75
sub3.value = 1.0

sub4.value = 0.25
sub4.value = 0.50
sub4.value = 0.75
sub4.value = 1.0
###Maven
```xml
<dependency>
<groupId>nl.komponents.progress</groupId>
<artifactId>progress</artifactId>
<version>[0.1.0, 0.2.0)</version>
</dependency>
```
8 changes: 4 additions & 4 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
*/

buildscript {
ext.kotlinVersion = '0.11.91.2'
ext.kotlinVersion = '0.12.200'
ext.extraConfVersion = '2.2.+'

repositories {
Expand All @@ -38,8 +38,8 @@ apply from: "${rootProject.projectDir}/gradle/versions.gradle"

allprojects {
ext {
appVersion = '0.1.2'
appGroup = 'nl.mplatvoet.komponents'
appVersion = '0.1.0'
appGroup = 'nl.komponents.progress'


junitVersion = '4.12'
Expand Down Expand Up @@ -194,7 +194,7 @@ task release {
}

task wrapper(type: Wrapper) {
gradleVersion = '2.4-rc-1'
gradleVersion = '2.4'

doLast() {
def gradleOpts = "-XX:MaxMetaspaceSize=1024m -Xmx1024m"
Expand Down
103 changes: 103 additions & 0 deletions docs/docs/documentation.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
#Progress usage documentation

Progress is a small utility for tracking progress in Kotlin. It is written with concurrency scenarios in mind and
is thus entirely thread safe. Progress tracking consists of two separate parts:

- `Progress` for receiving updates
- `ProgressControl` for changing the state.

##ProgressControl
A `ProgressControl` allows you to mutate the state, ergo setting the progress value, for the associated `Progress`.
There are two types of `ProgressControl`s:

- a single value control `SingleProgressControl`
- a container control `ContainerProgressControl`

A `SingleProgressControl` allows you to directly set a value
```kt
val control = Progress.control()

control.value = 1.0 // must be between 0.0 and 1.0 (inclusive)
```

A `ContainerProgressControl` allows you to depend on more than one `Progress` instances

```kt
val control = Progress.containerControl()

// create a SingleProcessControl as a child
// of this control
val one = control.child()

// create a ContainerProcessControl as a child
// of this control
val second = control.containerChild()

// another child from the second
// container with a custom weight
// for determining the impact on
// overall progress
val third = second.child(0.5)

// so this weighs heavy on the progress
val fourth = second.child(2.0)
```

##Progress
Progress is the client part of progress tracking. You can register a callback for receiving updates on progress or
just query the current state. This can be shared across threads. You obtain a `Progress` instance from a `ProgressControl`
instance.

```kt
val control = //...
val progress = control.progress

progress.update {
//called upon updates
}

// current value between 0.0 and 1.0 (inclusive)
progress.value

// boolean value that is true when progress.value == 1.0
progress.done

```



##Example

```kt
val masterControl = Progress.containerControl()
masterControl.progress.update {
println("${value}")
}

val firstChild = masterControl.child(0.1)
val secondChild = masterControl.containerChild(5.0)
val secondChildFirstChild = secondChild.child()
val secondChildSecondChild = secondChild.child()
val thirdChild = masterControl.child()
val fourthChild = masterControl.child(2.0)

firstChild.value = 0.25
firstChild.value = 0.50
firstChild.value = 0.75
firstChild.value = 1.0

secondChildFirstChild.markAsDone()
secondChildSecondChild.value = 0.5
secondChildSecondChild.value = 1.0

thirdChild.value = 0.25
thirdChild.value = 0.50
thirdChild.value = 0.75
thirdChild.value = 1.0

fourthChild.value = 0.25
fourthChild.value = 0.50
fourthChild.value = 0.75
fourthChild.value = 1.0

```
27 changes: 22 additions & 5 deletions docs/docs/index.md
Original file line number Diff line number Diff line change
@@ -1,25 +1,42 @@
#Progress
Track progress for [Kotlin](http://kotlinlang.org)

[![CircleCI branch](https://img.shields.io/circleci/project/mplatvoet/progress/master.svg)](https://circleci.com/gh/mplatvoet/progress/tree/master) [![Maven Central](https://img.shields.io/maven-central/v/nl.komponents.progress/progress.svg)](http://search.maven.org/#browse%7C-300825966) [![DUB](https://img.shields.io/dub/l/vibe-d.svg)](https://github.com/mplatvoet/progress/blob/master/LICENSE)

```kt
//TODO
//private part
val control = Progress.control()

//public part
val progress = control.progress

//get notified on updates
progress.update {
println("${value}")
}

//set value
control.value = 0.25
control.value = 0.50
control.value = 0.75
control.value = 1.0
```

## Getting started
This version is build against `Java 7` and `kotlin-stdlib:0.11.91`.
This version is build against `kotlin-stdlib:0.12.200`.

###Gradle
```groovy
dependencies {
compile 'nl.mplatvoet.komponents:progress:x.x.x'
compile 'nl.komponents.progress:progress:0.1.+'
}
```

###Maven
```xml
<dependency>
<groupId>nl.mplatvoet.komponents</groupId>
<groupId>nl.komponents.progress</groupId>
<artifactId>progress</artifactId>
<version>x.x.x</version>
<version>[0.1.0, 0.2.0)</version>
</dependency>
```
1 change: 1 addition & 0 deletions docs/mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,6 @@ repo_name: 'GitHub'

pages:
- ['index.md', 'Home']
- ['documentation.md', 'Documentation']

theme_dir: theme/yeti
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
26 changes: 24 additions & 2 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,28 @@
#Sun May 03 08:59:15 CEST 2015
#
# Copyright (c) 2015 Mark Platvoet<mplatvoet@gmail.com>
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
#

#Tue Jun 09 21:11:52 CEST 2015
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-2.4-rc-1-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-2.4-all.zip
1 change: 1 addition & 0 deletions gradlew
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
##############################################################################

# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
GRADLE_OPTS="-XX:MaxMetaspaceSize=1024m -Xmx1024m $GRADLE_OPTS"
DEFAULT_JVM_OPTS=""

APP_NAME="Gradle"
Expand Down
1 change: 1 addition & 0 deletions gradlew.bat
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
if "%OS%"=="Windows_NT" setlocal

@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
set GRADLE_OPTS=-XX:MaxMetaspaceSize=1024m -Xmx1024m -XX:MaxHeapSize=256m %GRADLE_OPTS%
set DEFAULT_JVM_OPTS=

set DIRNAME=%~dp0
Expand Down
Loading

0 comments on commit a129a8e

Please sign in to comment.