Skip to content

Commit b312ddb

Browse files
committed
Remove docker settings from config, Update header
1 parent 4587e2b commit b312ddb

File tree

19 files changed

+62
-362
lines changed

19 files changed

+62
-362
lines changed

build.sbt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ lazy val `file-system-exercise` =
2525
.enablePlugins(AutomateHeaderPlugin, GitVersioning, JavaAppPackaging, AshScriptPlugin)
2626
.settings(name := "Virtual Filesystem (Exercise)")
2727
.settings(settings)
28-
.settings(dockerSettings)
2928
.settings(
3029
libraryDependencies ++= Seq(
3130
library.log4j2Api,
@@ -36,7 +35,7 @@ lazy val `file-system-exercise` =
3635
library.scalaCheck % Test,
3736
library.specs2 % Test
3837
),
39-
version in Docker := "0.1.0-SNAPSHOT"
38+
Docker / version := "0.1.0-SNAPSHOT"
4039
)
4140

4241
// *****************************************************************************
Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,5 @@
11
/*
2-
* Copyright (c) 2019 Geektimus
3-
*
4-
* Permission is hereby granted, free of charge, to any person obtaining a copy of
5-
* this software and associated documentation files (the "Software"), to deal in
6-
* the Software without restriction, including without limitation the rights to
7-
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
8-
* the Software, and to permit persons to whom the Software is furnished to do so,
9-
* subject to the following conditions:
10-
*
11-
* The above copyright notice and this permission notice shall be included in all
12-
* copies or substantial portions of the Software.
13-
*
14-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15-
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
16-
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
17-
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
18-
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
19-
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
2+
* Copyright (c) Geektimus <https://github.com/geektimus>
203
*/
214

225
package com.codingmaniacs.scala.exercises.fs
@@ -40,4 +23,5 @@ object FileSystem {
4023
state = Command.from(scanner.nextLine()).apply(state)
4124
}
4225
}
26+
4327
}
Lines changed: 2 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,5 @@
11
/*
2-
* Copyright (c) 2019 Geektimus
3-
*
4-
* Permission is hereby granted, free of charge, to any person obtaining a copy of
5-
* this software and associated documentation files (the "Software"), to deal in
6-
* the Software without restriction, including without limitation the rights to
7-
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
8-
* the Software, and to permit persons to whom the Software is furnished to do so,
9-
* subject to the following conditions:
10-
*
11-
* The above copyright notice and this permission notice shall be included in all
12-
* copies or substantial portions of the Software.
13-
*
14-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15-
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
16-
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
17-
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
18-
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
19-
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
2+
* Copyright (c) Geektimus <https://github.com/geektimus>
203
*/
214

225
package com.codingmaniacs.scala.exercises.fs
@@ -36,6 +19,5 @@ class State(val root: Directory, val workingDir: Directory, val output: String)
3619
object State {
3720
val SHELL_PROMPT = "$ "
3821

39-
def apply(root: Directory, workingDir: Directory, output: String = ""): State =
40-
new State(root, workingDir, output)
22+
def apply(root: Directory, workingDir: Directory, output: String = ""): State = new State(root, workingDir, output)
4123
}
Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,13 @@
11
/*
2-
* Copyright (c) 2019 Geektimus
3-
*
4-
* Permission is hereby granted, free of charge, to any person obtaining a copy of
5-
* this software and associated documentation files (the "Software"), to deal in
6-
* the Software without restriction, including without limitation the rights to
7-
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
8-
* the Software, and to permit persons to whom the Software is furnished to do so,
9-
* subject to the following conditions:
10-
*
11-
* The above copyright notice and this permission notice shall be included in all
12-
* copies or substantial portions of the Software.
13-
*
14-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15-
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
16-
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
17-
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
18-
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
19-
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
2+
* Copyright (c) Geektimus <https://github.com/geektimus>
203
*/
214

225
package com.codingmaniacs.scala.exercises.fs.commands
236

247
import com.codingmaniacs.scala.exercises.fs.State
258

269
class Cat(filename: String) extends Command {
10+
2711
override def apply(state: State): State = {
2812
val wd = state.workingDir
2913
val dirEntry = wd.findEntry(filename)
@@ -33,4 +17,5 @@ class Cat(filename: String) extends Command {
3317
state.setMessage(dirEntry.asFile.contents)
3418
}
3519
}
20+
3621
}

filesystem/src/main/scala/com/codingmaniacs/scala/exercises/fs/commands/Cd.scala

Lines changed: 7 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,9 @@
11
/*
2-
* Copyright (c) 2019 Geektimus
3-
*
4-
* Permission is hereby granted, free of charge, to any person obtaining a copy of
5-
* this software and associated documentation files (the "Software"), to deal in
6-
* the Software without restriction, including without limitation the rights to
7-
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
8-
* the Software, and to permit persons to whom the Software is furnished to do so,
9-
* subject to the following conditions:
10-
*
11-
* The above copyright notice and this permission notice shall be included in all
12-
* copies or substantial portions of the Software.
13-
*
14-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15-
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
16-
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
17-
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
18-
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
19-
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
2+
* Copyright (c) Geektimus <https://github.com/geektimus>
203
*/
214

225
package com.codingmaniacs.scala.exercises.fs.commands
6+
237
import com.codingmaniacs.scala.exercises.fs.State
248
import com.codingmaniacs.scala.exercises.fs.directories.{ DirEntry, Directory }
259

@@ -72,16 +56,19 @@ class Cd(dir: String) extends Command {
7256
@tailrec
7357
def collapseTokensRec(tokens: List[String], res: List[String]): List[String] =
7458
tokens match {
75-
case List() => res
59+
case List() => res
60+
case List(a) => res :+ a
7661
case h :: tail if h.equals(".") => collapseTokensRec(tail, res)
7762
case h :: tail if h.equals("..") =>
7863
res match {
79-
case List() => null
64+
case List() => null
8065
case init :+ _ => collapseTokensRec(tail, init)
66+
case lst @ List(_) => lst
8167
}
8268
case h :: tail => collapseTokensRec(tail, res :+ h)
8369
}
8470

8571
collapseTokensRec(tokens, List())
8672
}
73+
8774
}

filesystem/src/main/scala/com/codingmaniacs/scala/exercises/fs/commands/Command.scala

Lines changed: 10 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,5 @@
11
/*
2-
* Copyright (c) 2019 Geektimus
3-
*
4-
* Permission is hereby granted, free of charge, to any person obtaining a copy of
5-
* this software and associated documentation files (the "Software"), to deal in
6-
* the Software without restriction, including without limitation the rights to
7-
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
8-
* the Software, and to permit persons to whom the Software is furnished to do so,
9-
* subject to the following conditions:
10-
*
11-
* The above copyright notice and this permission notice shall be included in all
12-
* copies or substantial portions of the Software.
13-
*
14-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15-
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
16-
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
17-
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
18-
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
19-
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
2+
* Copyright (c) Geektimus <https://github.com/geektimus>
203
*/
214

225
package com.codingmaniacs.scala.exercises.fs.commands
@@ -38,14 +21,15 @@ object Command {
3821
val ECHO = "echo"
3922
val CAT = "cat"
4023

41-
def emptyCommand: Command = new Command {
42-
override def apply(state: State): State = state
43-
}
24+
def emptyCommand: Command =
25+
new Command {
26+
override def apply(state: State): State = state
27+
}
4428

45-
def incompleteCommand(name: String): Command = new Command {
46-
override def apply(state: State): State =
47-
state.setMessage(s"$name is an incomplete command")
48-
}
29+
def incompleteCommand(name: String): Command =
30+
new Command {
31+
override def apply(state: State): State = state.setMessage(s"$name is an incomplete command")
32+
}
4933

5034
def from(input: String): Command = {
5135
val tokens = input.split(" ")
@@ -95,4 +79,5 @@ object Command {
9579
new UnknownCommand
9680
}
9781
}
82+
9883
}

filesystem/src/main/scala/com/codingmaniacs/scala/exercises/fs/commands/CreateEntry.scala

Lines changed: 2 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,5 @@
11
/*
2-
* Copyright (c) 2019 Geektimus
3-
*
4-
* Permission is hereby granted, free of charge, to any person obtaining a copy of
5-
* this software and associated documentation files (the "Software"), to deal in
6-
* the Software without restriction, including without limitation the rights to
7-
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
8-
* the Software, and to permit persons to whom the Software is furnished to do so,
9-
* subject to the following conditions:
10-
*
11-
* The above copyright notice and this permission notice shall be included in all
12-
* copies or substantial portions of the Software.
13-
*
14-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15-
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
16-
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
17-
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
18-
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
19-
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
2+
* Copyright (c) Geektimus <https://github.com/geektimus>
203
*/
214

225
package com.codingmaniacs.scala.exercises.fs.commands
@@ -47,8 +30,7 @@ abstract class CreateEntry(name: String) extends Command {
4730
}
4831
}
4932

50-
def checkIllegal(name: String): Boolean =
51-
name.contains(".")
33+
def checkIllegal(name: String): Boolean = name.contains(".")
5234

5335
def doCreateEntry(state: State): State = {
5436
val wd = state.workingDir

filesystem/src/main/scala/com/codingmaniacs/scala/exercises/fs/commands/Echo.scala

Lines changed: 3 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,5 @@
11
/*
2-
* Copyright (c) 2019 Geektimus
3-
*
4-
* Permission is hereby granted, free of charge, to any person obtaining a copy of
5-
* this software and associated documentation files (the "Software"), to deal in
6-
* the Software without restriction, including without limitation the rights to
7-
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
8-
* the Software, and to permit persons to whom the Software is furnished to do so,
9-
* subject to the following conditions:
10-
*
11-
* The above copyright notice and this permission notice shall be included in all
12-
* copies or substantial portions of the Software.
13-
*
14-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15-
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
16-
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
17-
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
18-
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
19-
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
2+
* Copyright (c) Geektimus <https://github.com/geektimus>
203
*/
214

225
package com.codingmaniacs.scala.exercises.fs.commands
@@ -35,7 +18,7 @@ class Echo(items: Array[String]) extends Command {
3518
def createContentRec(currIdx: Int, acc: String): String =
3619
currIdx match {
3720
case i if i >= topIndex => acc
38-
case i => createContentRec(i + 1, acc + items(currIdx))
21+
case i => createContentRec(i + 1, acc + items(currIdx))
3922
}
4023

4124
createContentRec(0, "")
@@ -107,4 +90,5 @@ class Echo(items: Array[String]) extends Command {
10790
state.setMessage(createContent(items, items.length))
10891
}
10992
}
93+
11094
}
Lines changed: 4 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,14 @@
11
/*
2-
* Copyright (c) 2019 Geektimus
3-
*
4-
* Permission is hereby granted, free of charge, to any person obtaining a copy of
5-
* this software and associated documentation files (the "Software"), to deal in
6-
* the Software without restriction, including without limitation the rights to
7-
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
8-
* the Software, and to permit persons to whom the Software is furnished to do so,
9-
* subject to the following conditions:
10-
*
11-
* The above copyright notice and this permission notice shall be included in all
12-
* copies or substantial portions of the Software.
13-
*
14-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15-
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
16-
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
17-
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
18-
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
19-
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
2+
* Copyright (c) Geektimus <https://github.com/geektimus>
203
*/
214

225
package com.codingmaniacs.scala.exercises.fs.commands
6+
237
import com.codingmaniacs.scala.exercises.fs.State
248
import com.codingmaniacs.scala.exercises.fs.directories.DirEntry
259

2610
class Ls extends Command {
11+
2712
override def apply(state: State): State = {
2813
val contents = state.workingDir.contents
2914
val outputString = createOutputString(contents)
@@ -36,4 +21,5 @@ class Ls extends Command {
3621
val entry = contents.head
3722
s"${entry.name} [${entry.getType}]\n${createOutputString(contents.tail)}"
3823
}
24+
3925
}
Lines changed: 3 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,12 @@
11
/*
2-
* Copyright (c) 2019 Geektimus
3-
*
4-
* Permission is hereby granted, free of charge, to any person obtaining a copy of
5-
* this software and associated documentation files (the "Software"), to deal in
6-
* the Software without restriction, including without limitation the rights to
7-
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
8-
* the Software, and to permit persons to whom the Software is furnished to do so,
9-
* subject to the following conditions:
10-
*
11-
* The above copyright notice and this permission notice shall be included in all
12-
* copies or substantial portions of the Software.
13-
*
14-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15-
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
16-
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
17-
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
18-
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
19-
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
2+
* Copyright (c) Geektimus <https://github.com/geektimus>
203
*/
214

225
package com.codingmaniacs.scala.exercises.fs.commands
6+
237
import com.codingmaniacs.scala.exercises.fs.State
248
import com.codingmaniacs.scala.exercises.fs.directories.{ DirEntry, Directory }
259

2610
class MkDir(name: String) extends CreateEntry(name) {
27-
override def createSpecificEntry(state: State): DirEntry =
28-
Directory.empty(state.workingDir.path, name)
11+
override def createSpecificEntry(state: State): DirEntry = Directory.empty(state.workingDir.path, name)
2912
}

0 commit comments

Comments
 (0)