Skip to content

Commit

Permalink
Removed grizzled dep for eglob.
Browse files Browse the repository at this point in the history
  • Loading branch information
dansimpson committed Jun 21, 2011
1 parent c3a0b10 commit 11531f2
Show file tree
Hide file tree
Showing 4 changed files with 65 additions and 9 deletions.
7 changes: 3 additions & 4 deletions core/buildfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ Java.classpath << "src/resources"
repositories.remote << "http://repo1.maven.org/maven2/"
repositories.remote << "http://www.asual.com/maven/content/groups/public"

GRIZZLED = "org.clapper:grizzled-scala_2.8.1:jar:1.0.4"
YUI = "com.yahoo.platform.yui:yuicompressor:jar:2.4.6"
LESSENGINE = "com.asual.lesscss:lesscss-engine:jar:1.0.43"

Expand All @@ -15,11 +14,11 @@ define "satchel" do
extend PomGenerator

project.group = "org.ds"
project.version = 0.1
project.version = 0.2

manifest["Copyright"] = "Dan Simpson (C) 2011"
manifest["Implementation-Vendor"] = "Dan Simpson"

compile.with transitive(GRIZZLED), transitive(YUI), transitive(LESSENGINE)
run.with transitive(GRIZZLED), transitive(YUI), transitive(LESSENGINE)
compile.with transitive(YUI), transitive(LESSENGINE)
run.with transitive(YUI), transitive(LESSENGINE)
end
11 changes: 8 additions & 3 deletions core/src/main/scala/org/ds/satchel/Satchel.scala
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,15 @@

package org.ds.satchel

import org.ds.satchel.util.FileUtil

import java.io.{ ByteArrayOutputStream, FileInputStream, IOException, File }
import scala.util.control.Breaks._
import scala.xml.Elem
import java.util.concurrent.ConcurrentHashMap

import grizzled.file.util
import grizzled.file.GrizzledFile._
//import grizzled.file.util
//import grizzled.file.GrizzledFile._
import org.ds.satchel.processors._

object Satchel {
Expand Down Expand Up @@ -270,8 +272,11 @@ class Satchel(val name: String,

private def glob(patterns: List[String]): List[String] = {
patterns.map { pattern: String =>
util.eglob(root + "/" + pattern)
FileUtil.eglob(root + "/" + pattern)
//util.eglob(root + "/" + pattern)
}.flatten.removeDuplicates
}



}
52 changes: 52 additions & 0 deletions core/src/main/scala/org/ds/satchel/util/FileUtil.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
package org.ds.satchel.util

import java.io.File
import scala.io.Source

class RichFile(val file: File) {

def children:Iterable[File] = {
if(file.isDirectory) {
return file.listFiles
}
Array[File]()
}

def tree : Iterable[File] = {
(Seq(file) ++ children.flatMap(child => new RichFile(child).tree))
}

}


object FileUtil {

def eglob(path:String):List[String] = {

val base = path.replace(seperator * 2, seperator)
val root = slap(base.split(seperator))

val regex = base
.replace("**/", """[[\w\d\-\_]+""" + seperator + "]~~~")
.replace("*.", """.+\.""")
.replace("*", ".+")
.replace("~~~", "*").r

val result = new RichFile(new File(root)).tree.map(_.toString)

result.filter { p =>
val itr = regex.findAllIn(p)
itr.size > 0
}.toList.reverse
}

private def seperator = "/"

private def slap(parts:Array[String]) = {
val pure = parts.takeWhile { s =>
!s.contains("*")
}
pure.reduceLeft(_ + seperator + _)
}

}
4 changes: 2 additions & 2 deletions scalatra/buildfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
require "buildr-dependency-extensions"
require "buildr/scala"

CORE = "org.ds:satchel:jar:0.1"
CORE = "org.ds:satchel:jar:0.2"
SCALATRA = "org.scalatra:scalatra_2.8.1:jar:2.0.0.M3"

repositories.remote << "http://repo1.maven.org/maven2/"
Expand All @@ -12,7 +12,7 @@ define "satchel-scalatra" do
extend PomGenerator

project.group = "org.ds"
project.version = 0.1
project.version = 0.2

manifest["Copyright"] = "Dan Simpson (C) 2011"
manifest["Implementation-Vendor"] = "Dan Simpson"
Expand Down

0 comments on commit 11531f2

Please sign in to comment.