Refactory! #1

Merged
merged 1 commit into from Apr 6, 2012
View
@@ -0,0 +1 @@
+Transliteration & sanitizing utilities for URL slugs.
@@ -1,4 +0,0 @@
-#!/bin/bash
-
-echo Entering continuous compilation loop ...
-`dirname $0`/sbt.sh --loop --no-jrebel "$@" ~compile
@@ -1,4 +0,0 @@
-#!/bin/bash
-
-echo Firing up the Scala REPL ...
-`dirname $0`/sbt.sh "$@" console
View
@@ -1,6 +0,0 @@
-#!/bin/bash
-
-PROJECT_DIR=`dirname $(readlink -f $0)`
-PARENT=`basename $PROJECT_DIR`
-
-$PROJECT_DIR/../sbt.sh "project $PARENT" "$@"
@@ -1,38 +0,0 @@
-package hr.element.sluggifier
-
-import com.ibm.icu.text.Transliterator
-
-
-
-object Sluggify {
- def makeSlug(txt: String, replacement: String) = {
- //convert latin letters to ASCII (ex. đ->d)
- val txtTrans = transliterate(txt)
- //convert all to lower case
- val txtLower = txtTrans.toLowerCase
- //replace all unsafe and reserved characters
- convertCharacters(txtLower, replacement)
- }
-
- def transliterate(s: String) = {
- Transliterator.getInstance(TransliterateRules.latinToASCII).transliterate(s)
- }
-
-/*
- * URL unsafe characters list
- * reserved: URLs use some characters for special use in defining their syntax.
- * reserved: $ & + , / : ; = ? @
- * unsafe: Some characters present the possibility of being misunderstood within URLs
- * unsafe: space # % { } | \ ^ ~ [ ] ' "
- */
- def convertCharacters(txt: String, replacement: String) = {
- convertReservedCharacters(convertUnsafeCharacters(txt, replacement), replacement)
- }
-
- private def convertReservedCharacters(txt: String, replacement: String) =
- txt.replaceAll("[$,&,+,,,/,:,;,=,?,@]", replacement)
-
- private def convertUnsafeCharacters(txt: String, replacement: String) =
- txt.replaceAll("""[ ,#,%,{,},|,\\,^,~,[,],']""", replacement)
-
-}
View
@@ -0,0 +1,36 @@
+organization := "hr.element.etb"
+
+name := "etb-slug"
+
+version := "0.0.1"
+
+// ### Build settings ###
+
+libraryDependencies ++= Seq(
+ "com.ibm.icu" % "icu4j" % "49.1"
+, "org.scalatest" %% "scalatest" % "1.7.1" % "test"
+)
+
+crossScalaVersions := Seq("2.9.1-1", "2.9.1", "2.9.0-1", "2.9.0")
+
+scalaVersion <<= (crossScalaVersions)(_.head)
+
+scalacOptions := Seq("-unchecked", "-deprecation", "-encoding", "UTF-8", "-optimise")
+
+unmanagedSourceDirectories in Compile <<= (scalaSource in Compile)( _ :: Nil)
+
+unmanagedSourceDirectories in Test <<= (scalaSource in Test )( _ :: Nil)
+
+
+// ### Publishing ###
+
+publishTo := Some("Element Releases" at "http://maven.element.hr/nexus/content/repositories/releases/")
+
+credentials += Credentials(Path.userHome / ".publish" / "element.credentials")
+
+publishArtifact in (Compile, packageDoc) := false
+
+
+// ### Misc ###
+
+initialCommands := "import hr.element.doit.slug._"
@@ -1,4 +0,0 @@
-#!/bin/bash
-
-echo Entering continuous compilation loop ...
-`dirname $0`/sbt.sh --loop --no-jrebel "$@" ~compile
@@ -0,0 +1,5 @@
+@echo off
+
+echo Performing dependency update for all projects ...
+echo Will also create Eclipse .project and .classpath files ...
+call "%~dp0\sbt.bat" --no-jrebel %* update eclipse
@@ -1,15 +0,0 @@
-import sbt._
-import Keys._
-
-import Helpers._
-import Dependencies._
-
-object Dependencies {
- val scalatest = "org.scalatest" %% "scalatest" % "1.7.1" % "test"
-
- val icu4j = "com.ibm.icu" % "icu4j" % "2.6.1"
-
-
-
-
-}
@@ -1,160 +0,0 @@
-import sbt._
-import Keys._
-
-import Helpers._
-import Dependencies._
-
-object InitialCommands {
- val settings = Seq(
- )
-}
-
-
-// ---------------------------------------------------------------------------
-
-object Default {
- val settings =
- Defaults.defaultSettings ++
- Resolvers.settings ++
- Publishing.settings ++
- Format.settings ++ Seq(
- organization := "hr.element.sluggifier",
- crossScalaVersions := Seq("2.9.1", "2.9.0-1", "2.9.0"),
- scalaVersion <<= (crossScalaVersions) { versions => versions.head },
- scalacOptions := Seq("-unchecked", "-deprecation", "-encoding", "UTF-8", "-optimise", "-Yrepl-sync"),
- javacOptions := Seq("-deprecation", "-encoding", "UTF-8", "-source", "1.6", "-target", "1.6"),
- unmanagedSourceDirectories in Compile <<= (scalaSource in Compile)( _ :: Nil),
- unmanagedSourceDirectories in Test <<= (scalaSource in Test )( _ :: Nil)
- )
-
-
-}
-
-// ---------------------------------------------------------------------------
-
-object Repositories {
- val ElementNexus = "Element Nexus" at "http://maven.element.hr/nexus/content/groups/public/"
- val ElementReleases = "Element Releases" at "http://maven.element.hr/nexus/content/repositories/releases/"
- val ElementSnapshots = "Element Snapshots" at "http://maven.element.hr/nexus/content/repositories/snapshots/"
- val Maven2 = "Maven2" at "http://repo2.maven.org/maven2/"
-
-
-}
-
-// ---------------------------------------------------------------------------
-
-object Resolvers {
- import Repositories._
-
- val settings = Seq(
- resolvers := Seq(
- ElementNexus
- , ElementReleases
- , ElementSnapshots
- , Maven2
- ),
- externalResolvers <<= resolvers map { rs =>
- Resolver.withDefaultResolvers(rs, mavenCentral = true, scalaTools = false)
- }
- )
-}
-
-// ---------------------------------------------------------------------------
-
-object Publishing {
- import Repositories._
-
- val settings = Seq(
- publishTo <<= (version) { version => Some(
- if (version.endsWith("SNAPSHOT")) ElementSnapshots else ElementReleases
- )},
- credentials += Credentials(Path.userHome / ".publish" / "element.credentials"),
- publishArtifact in (Compile, packageSrc) := false,
- publishArtifact in (Compile, packageDoc) := false
- )
-}
-
-// ---------------------------------------------------------------------------
-
-object Format {
- // Scalariform plugin
- import com.typesafe.sbtscalariform._
- import ScalariformPlugin._
- import scalariform.formatter.preferences._
-
- ScalariformKeys.preferences := FormattingPreferences()
- .setPreference(AlignParameters, false)
- .setPreference(AlignSingleLineCaseStatements, false)
- .setPreference(AlignSingleLineCaseStatements.MaxArrowIndent, 40)
- .setPreference(CompactControlReadability, false)
- .setPreference(CompactStringConcatenation, false)
- .setPreference(DoubleIndentClassDeclaration, true)
- .setPreference(FormatXml, false)
- .setPreference(IndentLocalDefs, false)
- .setPreference(IndentPackageBlocks, false)
- .setPreference(IndentSpaces, 2)
- .setPreference(IndentWithTabs, false)
- .setPreference(MultilineScaladocCommentsStartOnFirstLine, true)
- .setPreference(PlaceScaladocAsterisksBeneathSecondAsterisk, true)
- .setPreference(PreserveDanglingCloseParenthesis, false)
- .setPreference(PreserveSpaceBeforeArguments, false)
- .setPreference(RewriteArrowSymbols, false)
- .setPreference(SpaceBeforeColon, false)
- .setPreference(SpaceInsideBrackets, false)
- .setPreference(SpaceInsideParentheses, false)
- .setPreference(SpacesWithinPatternBinders, true)
-
- lazy val settings =
- ScalariformPlugin.defaultScalariformSettings
-}
-
-// ---------------------------------------------------------------------------
-
-object Helpers {
- implicit def depToFunSeq(m: ModuleID) = Seq((_: String) => m)
- implicit def depFunToSeq(fm: String => ModuleID) = Seq(fm)
- implicit def depSeqToFun(mA: Seq[ModuleID]) = mA.map(m => ((_: String) => m))
- implicit def warName2SMA(name: String) = (_: String, _: ModuleID, _: Artifact) => name
-
-// ---------------------------------------------------------------------------
-
- def top(
- title: String,
- projectAggs: Seq[sbt.ProjectReference] = Seq()) =
- Project(
- title,
- file("."),
- settings = Default.settings ++ Seq(
- name := title,
- version := "0.0.0"
- )
- ) aggregate(projectAggs: _*)
-
- def parent(
- title: String,
- projectAggs: Seq[sbt.ProjectReference] = Seq()) =
- Project(
- title,
- file(title.replace('-', '/')),
- settings = Default.settings ++ Seq(
- name := "Sluggifier-" + title,
- version := "0.0.0"
- )
- ) aggregate(projectAggs: _*)
-
- def project(
- title: String,
- ver: String,
- deps: Seq[Seq[String => ModuleID]] = Seq(),
- projectDeps: Seq[ClasspathDep[ProjectReference]] = Seq()) =
- Project(
- title,
- file(title.replace('-', '/')),
- settings = Default.settings ++ Seq(
- name := "Sluggifier-" + title,
- version := ver
- ) :+ (libraryDependencies <++= scalaVersion( sV =>
- for (depSeq <- deps; dep <- depSeq) yield dep(sV))
- )
- ) dependsOn(projectDeps: _*)
-}
@@ -1,18 +0,0 @@
-import sbt._
-import Keys._
-
-import Helpers._
-import Dependencies._
-
-object Sluggifier extends Build{
- lazy val sluggifier = project(
- "Sluggifier",
- "0.0.1",
- Seq(
- icu4j
- ),
- Seq(
- )
- )
-}
-
View
@@ -8,24 +8,4 @@
resolvers += Classpaths.typesafeResolver
-addSbtPlugin("com.typesafe.sbteclipse" % "sbteclipse-plugin" % "2.0.0-RC1")
-
-// +-------------------------------------------------------------------------------------+
-// | SBT Scalariform (https://github.com/typesafehub/sbtscalariform) |
-// | Performs source code formatting |
-// | |
-// | See also: Scalariform reference (http://mdr.github.com/scalariform/) |
-// +-------------------------------------------------------------------------------------+
-
-resolvers += Classpaths.typesafeResolver
-
-addSbtPlugin("com.typesafe.sbtscalariform" % "sbtscalariform" % "0.3.0")
-
-resolvers:= Seq("Apache Maven" at "http://mvnrepository.com/artifact/")
-
-externalResolvers <<= resolvers map { rs =>
- Resolver.withDefaultResolvers(rs, mavenCentral = true, scalaTools = false)
-}
-
-
-
+addSbtPlugin("com.typesafe.sbteclipse" % "sbteclipse-plugin" % "2.0.0")
Oops, something went wrong.