Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

moved small utility objects into Utils.scala

  • Loading branch information...
commit 923ddba1e885c533cf9e740d55b2c32b26e060eb 1 parent c9db25d
@wfaler authored
View
13 src/main/scala/com/recursivity/sitegen/Directory.scala
@@ -62,16 +62,3 @@ case class Directory(name: Option[String], webContents: List[SiteArtifact], dire
}
}
}
-
-
-object PropertiesToMap{
- def apply(properties: Properties): Map[String, String] = {
- val map = new HashMap[String, String]
- val iterator = properties.stringPropertyNames.iterator
- while(iterator.hasNext){
- val key = iterator.next
- map += key -> properties.getProperty(key)
- }
- map.toMap
- }
-}
View
12 src/main/scala/com/recursivity/sitegen/Settings.scala
@@ -1,8 +1,6 @@
package com.recursivity.sitegen
-import scala.collection.mutable.HashMap
import java.io.File
-import scala.io.Source
case class Settings(layout: Option[Template], workingPath: File, model: Map[String, Any]){
def apply(parent: Settings): Settings = {
@@ -39,13 +37,3 @@ Settings = {
}
}
-object RelativePath{
- def apply(workingDir: File, path: String): String = {
- val index = path.lastIndexOf(".." + System.getProperty("file.separator"))
- if(index > -1){
- val subPath = path.substring(index + 3)
- val upDirs = path.substring(0, index + 3).split(System.getProperty("file.separator")).size
- new File(Range(0, upDirs).foldLeft(workingDir)((in, count) => in.getAbsoluteFile().getParentFile()), subPath).getAbsolutePath()
- }else new File(workingDir, path).getAbsolutePath
- }
-}
View
10 src/main/scala/com/recursivity/sitegen/Template.scala
@@ -119,13 +119,3 @@ object Template{
}))
}
}
-
-
-object DeleteFile{
- def apply(file: File): Unit = {
- if(file.isDirectory()){
- file.listFiles.foreach(DeleteFile(_))
- }
- file.delete()
- }
-}
View
37 src/main/scala/com/recursivity/sitegen/Utils.scala
@@ -0,0 +1,37 @@
+package com.recursivity.sitegen
+
+import java.io.File
+import java.util.Properties
+import scala.collection.mutable.HashMap
+
+object RelativePath{
+ def apply(workingDir: File, path: String): String = {
+ val index = path.lastIndexOf(".." + System.getProperty("file.separator"))
+ if(index > -1){
+ val subPath = path.substring(index + 3)
+ val upDirs = path.substring(0, index + 3).split(System.getProperty("file.separator")).size
+ new File(Range(0, upDirs).foldLeft(workingDir)((in, count) => in.getAbsoluteFile().getParentFile()), subPath).getAbsolutePath()
+ }else new File(workingDir, path).getAbsolutePath
+ }
+}
+
+object PropertiesToMap{
+ def apply(properties: Properties): Map[String, String] = {
+ val map = new HashMap[String, String]
+ val iterator = properties.stringPropertyNames.iterator
+ while(iterator.hasNext){
+ val key = iterator.next
+ map += key -> properties.getProperty(key)
+ }
+ map.toMap
+ }
+}
+
+object DeleteFile{
+ def apply(file: File): Unit = {
+ if(file.isDirectory()){
+ file.listFiles.foreach(DeleteFile(_))
+ }
+ file.delete()
+ }
+}
Please sign in to comment.
Something went wrong with that request. Please try again.