Skip to content

Commit

Permalink
Merge pull request #870 from adpi2/category
Browse files Browse the repository at this point in the history
Introduce categorization
  • Loading branch information
adpi2 authored Jan 24, 2022
2 parents f46f531 + 924e872 commit 8f35885
Show file tree
Hide file tree
Showing 21 changed files with 1,653 additions and 73 deletions.
6 changes: 2 additions & 4 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -217,11 +217,8 @@ lazy val core = crossProject(JSPlatform, JVMPlatform)
"io.circe" %%% "circe-core",
"io.circe" %%% "circe-generic",
"io.circe" %%% "circe-parser"
).map(_ % V.circeVersion),
buildInfoPackage := "build.info",
buildInfoKeys := Seq[BuildInfoKey](ThisBuild / baseDirectory)
).map(_ % V.circeVersion)
)
.enablePlugins(BuildInfoPlugin)

lazy val data = project
.settings(
Expand All @@ -245,6 +242,7 @@ lazy val data = project
"org.json4s" %% "json4s-native" % "3.5.5",
"org.scalatest" %% "scalatest" % V.scalatest % Test
),
run / fork := true,
Compile / run / javaOptions ++= (infra / Compile / run / javaOptions).value,
Test / javaOptions ++= (infra / javaOptions).value
)
Expand Down
134 changes: 134 additions & 0 deletions core/shared/src/main/scala/scaladex/core/model/Category.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
package scaladex.core.model

sealed trait Category {
val label: String = {
val name = getClass.getSimpleName.stripSuffix("$")
val builder = name.foldLeft(new StringBuilder) { (builder, char) =>
if (char.isUpper && builder.nonEmpty) builder += '-'
builder += char.toLower
}
builder.toString
}

val title: String = {
val name = getClass.getSimpleName.stripSuffix("$")
val builder = name.foldLeft(new StringBuilder) { (builder, char) =>
if (char.isUpper && builder.nonEmpty) builder += ' '
builder += char
}
builder.toString.replaceAll(" And ", " and ")
}
}

object Category {
val all: Seq[Category] = MetaCategory.all.flatMap(_.categories).distinct
val byLabel: Map[String, Category] = all.map(category => category.label -> category).toMap

case object AsynchronousAndReactiveProgramming extends Category
case object DistributedComputing extends Category
case object DistributedMessagingSystemsAndMicroservices extends Category
case object Schedulers extends Category

case object AudioAndMusic extends Category
case object VideoAndImageProcessing extends Category

case object DataSourcesAndConnectors extends Category
case object DataVizualization extends Category

case object CommandLineParsing extends Category
case object ConfigurationAndEnvironment extends Category
case object Logging extends Category
case object PerformanceAndMonitoring extends Category
case object Testing extends Category

case object Databases extends Category
case object IndexingAndSearching extends Category

case object DatesAndTime extends Category
case object GeometryAndGeopositionning extends Category
case object UnitsOfMeasurement extends Category

case object DeploymentAndCloud extends Category
case object PackagingAndPublishing extends Category
case object LibraryDependencyManagement extends Category
case object Serverless extends Category
case object VersionManagement extends Category
case object VirtualizationAndContainerization extends Category

case object BuildTools extends Category
case object CodeAnalysis extends Category
case object LintingAndRefactoring extends Category
case object PrintingAndDebugging extends Category
case object CodeEditorsAndNotebooks extends Category
case object CodeFormatting extends Category
case object ScriptingAndRepls extends Category {
override val title: String = "Scripting and REPLs"
}
case object StaticSitesAndDocumentation extends Category
case object MiscellaneousTools extends Category

case object AlgorithmsAndDataStructures extends Category
case object Caching extends Category
case object Compilers extends Category
case object CodeGeneration extends Category
case object DependencyInjection extends Category
case object FunctionnalProgrammingAndCategoryTheory extends Category
case object LogicProgrammingAndTypeConstraints extends Category
case object MiscellaneousUtils extends Category
case object Parsing extends Category
case object ScalaLanguageExtensions extends Category
case object ProgrammingLanguageInterfaces extends Category

case object Bioinformatics extends Category
case object CryptographyAndHashing extends Category
case object EconomyFinanceAndCryptocurrencies extends Category
case object ProbabilityStatisticsAndMachineLearning extends Category
case object NaturalLanguageProcessing extends Category
case object NumericalAndSymbolicComputing extends Category

case object Mobile extends Category
case object GraphicalInterfacesAndGameDevelopment extends Category

case object HardwareAndEmulators extends Category
case object FileSystemsAndProcesses extends Category
case object Network extends Category

case object ArchivesAndCompression extends Category
case object Csv extends Category {
override val title: String = "CSV"
}
case object Json extends Category {
override val title: String = "JSON"
}
case object Markdown extends Category
case object Pdf extends Category {
override val title: String = "PDF"
}
case object Serialization extends Category
case object Templating extends Category
case object TextManipulation extends Category
case object OtherDocumentFormats extends Category
case object Yaml extends Category {
override val title: String = "YAML"
}
case object XmlHtmlAndDom extends Category {
override val title: String = "XML/HTML and DOM"
}

case object AssetManagementAndBundlers extends Category
case object AuthenticationAndPermissions extends Category
case object Emailing extends Category
case object FormsAndValidation extends Category
case object HttpServersAndClients extends Category {
override val title: String = "HTTP Servers and Clients"
}
case object Internationalization extends Category
case object ThirdPartyApis extends Category {
override val title: String = "Third-Party APIs"
}
case object UrlsAndRouting extends Category {
override val title: String = "URLs and Routing"
}
case object WebFrontend extends Category
case object SemanticWeb extends Category
}
183 changes: 183 additions & 0 deletions core/shared/src/main/scala/scaladex/core/model/MetaCategory.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,183 @@
package scaladex.core.model

sealed trait MetaCategory {
val label: String = {
val name = getClass.getSimpleName.stripSuffix("$")
val builder = name.foldLeft(new StringBuilder) { (builder, char) =>
if (char.isUpper && builder.nonEmpty) builder += '-'
builder += char.toLower
}
builder.toString
}

val title: String
val categories: Seq[Category]
}

object MetaCategory {
def all: Seq[MetaCategory] = Seq(
AsynchronousConcurrentAndDistributedProgramming,
AudioImagesAndVideo,
BigData,
ConfigurationLoggingTestingAndMonitoring,
DatabasesIndexingAndSearching,
TimePositionsAndUnitsOfMeasurement,
DeploymentVirtualizationAndCloud,
DevelopmentTooling,
GeneralComputerScience,
MathematicsFinanceDataScienceAndBioinformatics,
MobileDesktopAndGameDevelopment,
OperatingSystemsAndHardware,
TextFormatAndCompression,
WebDevelopment
)

case object AsynchronousConcurrentAndDistributedProgramming extends MetaCategory {
override val title: String = "Asynchronous, Concurrent and Distributed Programming."

override val categories: Seq[Category] = Seq(
Category.AsynchronousAndReactiveProgramming,
Category.DistributedComputing,
Category.DistributedMessagingSystemsAndMicroservices,
Category.Schedulers
)
}
case object AudioImagesAndVideo extends MetaCategory {
override val title: String = "Audio, Images and Video"
override val categories: Seq[Category] = Seq(
Category.AudioAndMusic,
Category.VideoAndImageProcessing
)
}
case object BigData extends MetaCategory {
override val title: String = "Big Data"
override val categories: Seq[Category] = Seq(
Category.DataSourcesAndConnectors,
Category.DataVizualization,
Category.DistributedComputing
)
}
case object ConfigurationLoggingTestingAndMonitoring extends MetaCategory {
override val title: String = "Configuration, Logging, Testing and Monitoring"
override val categories: Seq[Category] = Seq(
Category.CommandLineParsing,
Category.ConfigurationAndEnvironment,
Category.Logging,
Category.PerformanceAndMonitoring,
Category.Testing
)
}
case object DatabasesIndexingAndSearching extends MetaCategory {
override val title: String = "Databases, Indexing and Searching"
override val categories: Seq[Category] = Seq(
Category.Databases,
Category.IndexingAndSearching
)
}
case object TimePositionsAndUnitsOfMeasurement extends MetaCategory {
override val title: String = "Dates, Time, Positions and Units of Measurement"
override val categories: Seq[Category] = Seq(
Category.DatesAndTime,
Category.GeometryAndGeopositionning,
Category.UnitsOfMeasurement
)
}
case object DeploymentVirtualizationAndCloud extends MetaCategory {
override val title: String = "Deployment, Virtualization and Cloud"
override val categories: Seq[Category] = Seq(
Category.DeploymentAndCloud,
Category.PackagingAndPublishing,
Category.LibraryDependencyManagement,
Category.Serverless,
Category.VersionManagement,
Category.VirtualizationAndContainerization
)
}
case object DevelopmentTooling extends MetaCategory {
override val title = "Development Tooling"
override val categories: Seq[Category] = Seq(
Category.BuildTools,
Category.CodeAnalysis,
Category.LintingAndRefactoring,
Category.PrintingAndDebugging,
Category.CodeEditorsAndNotebooks,
Category.CodeFormatting,
Category.ScriptingAndRepls,
Category.StaticSitesAndDocumentation,
Category.MiscellaneousTools
)
}
case object GeneralComputerScience extends MetaCategory {
override val title: String = "General Computer Science"
override val categories: Seq[Category] = Seq(
Category.AlgorithmsAndDataStructures,
Category.Caching,
Category.Compilers,
Category.CodeGeneration,
Category.DependencyInjection,
Category.FunctionnalProgrammingAndCategoryTheory,
Category.LogicProgrammingAndTypeConstraints,
Category.MiscellaneousUtils,
Category.Parsing,
Category.ScalaLanguageExtensions,
Category.ProgrammingLanguageInterfaces
)
}
case object MathematicsFinanceDataScienceAndBioinformatics extends MetaCategory {
override val title: String = "Mathetmatics, Finance, Data Science and Bioinformatics"
override val categories: Seq[Category] = Seq(
Category.Bioinformatics,
Category.CryptographyAndHashing,
Category.EconomyFinanceAndCryptocurrencies,
Category.ProbabilityStatisticsAndMachineLearning,
Category.NaturalLanguageProcessing,
Category.NumericalAndSymbolicComputing
)
}
case object MobileDesktopAndGameDevelopment extends MetaCategory {
override val title: String = "Mobile, Desktop and Game Development"
override val categories: Seq[Category] = Seq(
Category.Mobile,
Category.GraphicalInterfacesAndGameDevelopment
)
}
case object OperatingSystemsAndHardware extends MetaCategory {
override val title: String = "Operating System, Hardware and Robotics"
override val categories: Seq[Category] = Seq(
Category.HardwareAndEmulators,
Category.FileSystemsAndProcesses,
Category.Network
)
}
case object TextFormatAndCompression extends MetaCategory {
override val title: String = "Text, Formats and Compression"
override val categories: Seq[Category] = Seq(
Category.ArchivesAndCompression,
Category.Csv,
Category.Json,
Category.Markdown,
Category.Pdf,
Category.Serialization,
Category.TextManipulation,
Category.OtherDocumentFormats,
Category.Yaml
)
}
case object WebDevelopment extends MetaCategory {
override val title: String = "Web Development"
override val categories: Seq[Category] = Seq(
Category.AssetManagementAndBundlers,
Category.AuthenticationAndPermissions,
Category.Emailing,
Category.FormsAndValidation,
Category.HttpServersAndClients,
Category.Internationalization,
Category.SemanticWeb,
Category.Templating,
Category.ThirdPartyApis,
Category.UrlsAndRouting,
Category.WebFrontend,
Category.XmlHtmlAndDom
)
}
}
4 changes: 2 additions & 2 deletions core/shared/src/main/scala/scaladex/core/model/Project.scala
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ object Project {
contributorsWanted: Boolean,
artifactDeprecations: Set[Artifact.Name],
cliArtifacts: Set[Artifact.Name],
primaryTopic: Option[String],
category: Option[Category],
beginnerIssuesLabel: Option[String]
)

Expand Down Expand Up @@ -103,7 +103,7 @@ object Project {
contributorsWanted = false,
artifactDeprecations = Set(),
cliArtifacts = Set(),
primaryTopic = None,
category = None,
beginnerIssuesLabel = None
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import java.time.Instant

import scaladex.core.model.Artifact
import scaladex.core.model.BinaryVersion
import scaladex.core.model.Category
import scaladex.core.model.Platform
import scaladex.core.model.Platform._
import scaladex.core.model.Project
Expand All @@ -22,7 +23,7 @@ final case class ProjectDocument(
scalaNativeVersions: Seq[BinaryVersion],
sbtVersions: Seq[BinaryVersion],
inverseProjectDependencies: Int,
primaryTopic: Option[String],
category: Option[Category],
formerReferences: Seq[Project.Reference],
githubInfo: Option[GithubInfoDocument]
) {
Expand Down Expand Up @@ -52,7 +53,7 @@ object ProjectDocument {
platforms.collect { case ScalaNative(_, scalaNativeV) => scalaNativeV }.sorted.distinct,
platforms.collect { case SbtPlugin(_, sbtV) => sbtV }.sorted.distinct,
inverseProjectDependencies,
settings.primaryTopic,
settings.category,
formerReferences,
project.githubInfo.map(_.toDocument)
)
Expand Down
15 changes: 15 additions & 0 deletions core/shared/src/test/scala/scaladex/core/model/CategoryTests.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package scaladex.core.model

import org.scalatest.funspec.AnyFunSpec
import org.scalatest.matchers.should.Matchers

class CategoryTests extends AnyFunSpec with Matchers {
it("should compute category label and title") {
Category.AlgorithmsAndDataStructures.label shouldBe "algorithms-and-data-structures"
Category.AlgorithmsAndDataStructures.title shouldBe "Algorithms and Data Structures"
}

it("should compute meta-category label") {
MetaCategory.AsynchronousConcurrentAndDistributedProgramming.label shouldBe "asynchronous-concurrent-and-distributed-programming"
}
}
Loading

0 comments on commit 8f35885

Please sign in to comment.