This repository has been archived by the owner on Jul 29, 2021. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6bac594
commit 6607cdb
Showing
76 changed files
with
1,492 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
style=IntelliJ | ||
maxColumn=80 | ||
maxColumn=160 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,14 @@ | ||
package pl.writeonly.re.main | ||
|
||
import pl.writeonly.re.shared.core.Core | ||
import pl.writeonly.re.shared.hyde.impl.Hyde | ||
import slogging._ | ||
|
||
object Main extends App { | ||
LoggerConfig.factory = SLF4JLoggerFactory() | ||
|
||
LoggerConfig.level = LogLevel.TRACE | ||
Core.apply("JVM") | ||
|
||
Hyde.main(args) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 9 additions & 0 deletions
9
re/shared/src/main/scala/pl/writeonly/re/shared/hyde/common/states/State.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package pl.writeonly.re.shared.hyde.common.states | ||
|
||
trait State { | ||
def showResult(): Unit | ||
|
||
def showStep(): Unit | ||
|
||
def isEmptyNextInternalUrls: Boolean | ||
} |
34 changes: 34 additions & 0 deletions
34
...hared/src/main/scala/pl/writeonly/re/shared/hyde/common/states/api/AbstractAPIState.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package pl.writeonly.re.shared.hyde.common.states.api | ||
|
||
import pl.writeonly.re.shared.hyde.common.states.State | ||
import pl.writeonly.re.shared.hyde.common.url.typed.InternalUrls | ||
import pl.writeonly.re.shared.hyde.common.url.urls._ | ||
import scalaz.Scalaz._ | ||
|
||
abstract class AbstractAPIState(data: UrlsWithThrowableList) extends State { | ||
|
||
type HP | ||
|
||
final type SET = Set[HP] | ||
|
||
type NextState | ||
|
||
override def showStep(): Unit = data.showStep() | ||
|
||
def showResult(): Unit = data.showResult() | ||
|
||
def isEmptyNextInternalUrls: Boolean = data.isEmptyNextInternalUrls | ||
|
||
override def toString: String = data.toString | ||
|
||
final def newState(set: SET): NextState = set |> nextData |> nextState | ||
|
||
def nextData(set: SET): UrlsWithThrowableList | ||
|
||
def nextState(data: UrlsWithThrowableList): NextState | ||
|
||
protected def nextUrls: InternalUrls = data.nextUrls | ||
|
||
def throwableList: ThrowableList = data.throwableList | ||
|
||
} |
30 changes: 30 additions & 0 deletions
30
...ed/src/main/scala/pl/writeonly/re/shared/hyde/common/states/api/DisjunctionAPIState.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package pl.writeonly.re.shared.hyde.common.states.api | ||
|
||
import pl.writeonly.re.shared.hyde.common.url._ | ||
import pl.writeonly.re.shared.hyde.common.url.urls._ | ||
import pl.writeonly.re.shared.hyde.sourcepage.thirdparty._ | ||
|
||
abstract class DisjunctionAPIState(data: UrlsWithThrowableList)(implicit d: Domain) extends AbstractAPIState(data) { | ||
override type HP = SourcePageDisjunction | ||
|
||
def nextData(set: SourcePageDisjunctionSet): UrlsWithThrowableList = { | ||
|
||
val partitioned = set.partition(_.isRight) | ||
|
||
val newWrappedUrls: WrappedUrlSet = partitioned._1 | ||
.flatMap(DisjunctionAPIState.sourcePageDisjunctionToWrappedUrlSet) | ||
|
||
val newThrowableList: ThrowableList = partitioned._2.toList | ||
.flatMap(_.swap.toOption.toList) | ||
|
||
val newUrls = NewUrls(newWrappedUrls) | ||
|
||
data.next(newUrls, newThrowableList) | ||
} | ||
|
||
} | ||
|
||
object DisjunctionAPIState { | ||
val sourcePageDisjunctionToWrappedUrlSet: SourcePageDisjunction => WrappedUrlSet = | ||
_.map(_.getWrappedUrlSet).toOption.toSet.flatten | ||
} |
29 changes: 29 additions & 0 deletions
29
re/shared/src/main/scala/pl/writeonly/re/shared/hyde/common/states/api/EitherAPIState.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package pl.writeonly.re.shared.hyde.common.states.api | ||
|
||
import pl.writeonly.re.shared.hyde.common.url._ | ||
import pl.writeonly.re.shared.hyde.common.url.urls._ | ||
import pl.writeonly.re.shared.hyde.sourcepage.std._ | ||
|
||
abstract class EitherAPIState(data: UrlsWithThrowableList)(implicit d: Domain) extends AbstractAPIState(data) { | ||
override type HP = SourcePageEither | ||
|
||
def nextData(set: SourcePageEitherSet): UrlsWithThrowableList = { | ||
|
||
val partitioned = set.partition(_.isRight) | ||
|
||
val newWrappedUrls: WrappedUrlSet = partitioned._1 | ||
.flatMap(EitherAPIState.sourcePageEitherToWrappedUrlSet) | ||
|
||
val newThrowableList: ThrowableList = partitioned._2.toList | ||
.flatMap(_.left.toOption.toList) | ||
|
||
val newUrls = NewUrls(newWrappedUrls) | ||
|
||
data.next(newUrls, newThrowableList) | ||
} | ||
} | ||
|
||
object EitherAPIState { | ||
val sourcePageEitherToWrappedUrlSet: SourcePageEither => WrappedUrlSet = | ||
_.right.map(_.getWrappedUrlSet).right.toOption.toSet.flatten | ||
} |
19 changes: 19 additions & 0 deletions
19
re/shared/src/main/scala/pl/writeonly/re/shared/hyde/common/states/api/package.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package pl.writeonly.re.shared.hyde.common.states | ||
|
||
import scala.concurrent.Future | ||
|
||
import scalaz.concurrent.Task | ||
import scalaz.effect.IO | ||
import scalaz.ioeffect.{IO => IOIO, Task => IOTask} | ||
|
||
package object api { | ||
type ParallelStateFuture = Future[EitherAPIState] | ||
|
||
type ParallelStateIO = IO[DisjunctionAPIState] | ||
|
||
type ParallelStateTask = Task[DisjunctionAPIState] | ||
|
||
type ParallelStateIOIO = IOIO[Throwable, DisjunctionAPIState] | ||
|
||
type ParallelStateIOTask = IOTask[DisjunctionAPIState] | ||
} |
12 changes: 12 additions & 0 deletions
12
.../scala/pl/writeonly/re/shared/hyde/common/states/notexception/AbstractFunctionState.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package pl.writeonly.re.shared.hyde.common.states.notexception | ||
|
||
import pl.writeonly.re.shared.hyde.common.url.typed.InternalUrl | ||
|
||
trait AbstractFunctionState extends AbstractNewSetState { | ||
|
||
final def newSet: SET = nextUrls.map(impureFunction) | ||
|
||
def impureFunction: HPFromInternalUrl | ||
|
||
type HPFromInternalUrl = InternalUrl => HP | ||
} |
8 changes: 8 additions & 0 deletions
8
...in/scala/pl/writeonly/re/shared/hyde/common/states/notexception/AbstractNewSetState.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package pl.writeonly.re.shared.hyde.common.states.notexception | ||
|
||
trait AbstractNewSetState extends AbstractNextState { | ||
|
||
final def next: AbstractNextState = newState(newSet) | ||
|
||
def newSet: SET | ||
} |
20 changes: 20 additions & 0 deletions
20
...main/scala/pl/writeonly/re/shared/hyde/common/states/notexception/AbstractNextState.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package pl.writeonly.re.shared.hyde.common.states.notexception | ||
|
||
import scala.annotation.tailrec | ||
|
||
import pl.writeonly.re.shared.hyde.common.states.api.AbstractAPIState | ||
import pl.writeonly.re.shared.hyde.common.url.urls.UrlsWithThrowableList | ||
|
||
trait AbstractNextState extends AbstractAPIState { | ||
|
||
type NextState = AbstractNextState | ||
|
||
def next: NextState | ||
|
||
def nextState(data: UrlsWithThrowableList): AbstractNextState | ||
} | ||
|
||
object AbstractNextState { | ||
@tailrec | ||
def run(state: AbstractNextState): AbstractNextState = if (state.isEmptyNextInternalUrls) state else run(state.next) | ||
} |
11 changes: 11 additions & 0 deletions
11
...cala/pl/writeonly/re/shared/hyde/common/states/notexception/AbstractNextStateObject.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package pl.writeonly.re.shared.hyde.common.states.notexception | ||
|
||
import pl.writeonly.re.shared.hyde.common.url.Domain | ||
import scalaz.Scalaz._ | ||
|
||
trait AbstractNextStateObject { | ||
|
||
def fromDomain(implicit d: Domain): AbstractNextState | ||
|
||
def apply(domain: String): AbstractNextState = fromDomain(new Domain(domain)) |> AbstractNextState.run | ||
} |
36 changes: 36 additions & 0 deletions
36
re/shared/src/main/scala/pl/writeonly/re/shared/hyde/common/states/oo/AbstractOOState.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package pl.writeonly.re.shared.hyde.common.states.oo | ||
|
||
import scala.annotation.tailrec | ||
|
||
import pl.writeonly.re.shared.hyde.common.states.State | ||
import pl.writeonly.re.shared.hyde.common.url._ | ||
import pl.writeonly.re.shared.hyde.common.url.typed.InternalUrl | ||
import pl.writeonly.re.shared.hyde.common.url.urls._ | ||
import pl.writeonly.re.shared.hyde.sourcepage.SourcePage | ||
import scalaz.Scalaz._ | ||
|
||
abstract class AbstractOOState(urls: Urls)(implicit d: Domain) extends State { | ||
|
||
override final def showResult(): Unit = urls.showResult() | ||
|
||
override final def showStep(): Unit = urls.showStep() | ||
|
||
override final def isEmptyNextInternalUrls: Boolean = urls.isEmptyNextInternalUrls | ||
|
||
final def next: AbstractOOState = getWrappedUrlSet |> NewUrls.apply |> urls.next |> nextState | ||
|
||
final def getWrappedUrlSet: WrappedUrlSet = | ||
urls.nextUrls | ||
.map(map) | ||
.flatMap(_.getWrappedUrlSet) | ||
|
||
def nextState(urls: Urls): AbstractOOState | ||
|
||
def map: InternalUrl => SourcePage | ||
|
||
} | ||
|
||
object AbstractOOState { | ||
@tailrec | ||
def run(state: AbstractOOState): AbstractOOState = if (state.isEmptyNextInternalUrls) state else run(state.next) | ||
} |
11 changes: 11 additions & 0 deletions
11
...d/src/main/scala/pl/writeonly/re/shared/hyde/common/states/oo/AbstractOOStateObject.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package pl.writeonly.re.shared.hyde.common.states.oo | ||
|
||
import pl.writeonly.re.shared.hyde.common.url.Domain | ||
import scalaz.Scalaz._ | ||
|
||
trait AbstractOOStateObject { | ||
|
||
def fromDomain(implicit d: Domain): AbstractOOState | ||
|
||
def apply(domain: String): AbstractOOState = fromDomain(new Domain(domain)) |> AbstractOOState.run | ||
} |
20 changes: 20 additions & 0 deletions
20
re/shared/src/main/scala/pl/writeonly/re/shared/hyde/common/url/Domain.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package pl.writeonly.re.shared.hyde.common.url | ||
|
||
import pl.writeonly.re.shared.hyde.common.url.typed.InternalUrl | ||
|
||
class Domain(domain: WrappedUrl) { | ||
|
||
def this(url: String) = this(new WrappedUrl(url)) | ||
|
||
println("domain " + toString) | ||
|
||
override def toString: String = domain.toString | ||
|
||
def toInternalUrl: InternalUrl = InternalUrl(domain)(this) | ||
|
||
def toInternalUrl(url: WrappedUrl): InternalUrl = new InternalUrl(domain.append(url)) | ||
|
||
def isInternalUrl(url: WrappedUrl): Boolean = url.isInternalUrl(domain) | ||
|
||
def toWrappedUrl: WrappedUrl = domain | ||
} |
49 changes: 49 additions & 0 deletions
49
re/shared/src/main/scala/pl/writeonly/re/shared/hyde/common/url/WrappedUrl.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
package pl.writeonly.re.shared.hyde.common.url | ||
|
||
import java.net._ | ||
|
||
import pl.writeonly.re.shared.hyde.common.url.exception._ | ||
import pl.writeonly.re.shared.hyde.common.url.typed._ | ||
|
||
case class WrappedUrl(private val url: String) extends Ordered[WrappedUrl] { | ||
|
||
override def toString: String = url | ||
|
||
override def compare(that: WrappedUrl): Int = url.compareTo(that.url) | ||
|
||
def append(that: WrappedUrl): WrappedUrl = new WrappedUrl(url + that.url) | ||
|
||
def toURL: URL = new URL(url) | ||
|
||
def toURI: URI = URI.create(url) | ||
|
||
def toException(e: Throwable): UrlException = new UrlException(url, e) | ||
|
||
def toNonInternalException: NonInternalUrlException = new NonInternalUrlException(url) | ||
|
||
def toNonRelativeException: NonRelativeUrlException = new NonRelativeUrlException(url) | ||
|
||
def isRelativeUrl: Boolean = url.startsWith("/") | ||
|
||
def isInternalUrl(implicit d: Domain): Boolean = d.isInternalUrl(this) | ||
|
||
def isInternalUrl(d: WrappedUrl): Boolean = url.startsWith(d.url) | ||
|
||
def toInternalUrl(implicit d: Domain): InternalUrl = InternalUrl(this) | ||
|
||
def makeInternalUrl(implicit d: Domain): InternalUrl = d.toInternalUrl(this) | ||
|
||
def toExternalUrl: ExternalUrl = new ExternalUrl(this) | ||
|
||
def getType(implicit d: Domain): Symbol = url match { | ||
case _ if isInternalUrl => WrappedUrl.Internal | ||
case _ if isRelativeUrl => WrappedUrl.Relative | ||
case _ => WrappedUrl.External | ||
} | ||
} | ||
|
||
object WrappedUrl { | ||
val Internal = 'internal | ||
val Relative = 'relative | ||
val External = 'external | ||
} |
3 changes: 3 additions & 0 deletions
3
...main/scala/pl/writeonly/re/shared/hyde/common/url/exception/NonInternalUrlException.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
package pl.writeonly.re.shared.hyde.common.url.exception | ||
|
||
class NonInternalUrlException(url: String) extends IllegalArgumentException(url) |
3 changes: 3 additions & 0 deletions
3
...main/scala/pl/writeonly/re/shared/hyde/common/url/exception/NonRelativeUrlException.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
package pl.writeonly.re.shared.hyde.common.url.exception | ||
|
||
class NonRelativeUrlException(url: String) extends IllegalArgumentException(url) |
Oops, something went wrong.