This repository has been archived by the owner on Dec 10, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
iss #22: models: GithubOrg, GithubUser, ProgrammingLang, ProgrammingL…
…angStat, Repo
- Loading branch information
Showing
6 changed files
with
89 additions
and
30 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package hedgehog | ||
|
||
import play.utils.UriEncoding.encodePathSegment | ||
/** | ||
* Copyright (c) Nikita Kovaliov, maizy.ru, 2014 | ||
* See LICENSE.txt for details. | ||
*/ | ||
object UrlUtils { | ||
|
||
def urlEncodePathSegment(segment: String) { | ||
encodePathSegment(segment, "utf-8") | ||
} | ||
|
||
def urlEncode(param: String) { | ||
java.net.URLEncoder.encode(param, "utf-8") | ||
} | ||
} |
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 hedgehog.models | ||
|
||
import hedgehog.UrlUtils._ | ||
|
||
/** | ||
* Copyright (c) Nikita Kovaliov, maizy.ru, 2014 | ||
* See LICENSE.txt for details. | ||
*/ | ||
trait GithubAccount { | ||
|
||
def name: String | ||
|
||
def avatarUrl: Option[String] = None | ||
|
||
protected def baseWebUrl: String = GITHUB_BASE_WEB_URL | ||
|
||
def webProfileUrl: String = | ||
s"$baseWebUrl/${urlEncodePathSegment(name)}" | ||
|
||
def getRepoUrl(repo: Repo): String = | ||
s"$webProfileUrl/${urlEncodePathSegment(repo.fullName)}" | ||
} | ||
|
||
|
||
case class GithubUser( | ||
name: String, | ||
override val avatarUrl: Option[String]) | ||
extends GithubAccount | ||
|
||
|
||
case class GithubOrg( | ||
name: String, | ||
override val avatarUrl: Option[String]) | ||
extends GithubAccount |
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,14 @@ | ||
package hedgehog.models | ||
|
||
/** | ||
* Copyright (c) Nikita Kovaliov, maizy.ru, 2014 | ||
* See LICENSE.txt for details. | ||
* | ||
*/ | ||
class ProgrammingLang(val code: String) | ||
|
||
|
||
class ProgrammingLangStat( | ||
val lang: ProgrammingLang, | ||
val extensions: Seq[String], | ||
val bytes: Option[Long]) |
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