Skip to content

Commit

Permalink
Merge pull request #12 from rec-jvm/enhance/original-record
Browse files Browse the repository at this point in the history
[#11] Add toString method for Wrapper and Record
  • Loading branch information
kenpusney authored Dec 16, 2016
2 parents de14ce0 + 521ed26 commit d0a9dc4
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 16 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
allprojects {
version = '0.1.2'
version = '0.1.3'

buildscript {
ext.kotlin_version = '1.0.5'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,9 @@ private T getByIndex(Integer index, Indexible<T> record) {
public List<String> keys() {
return fieldNames.keySet().stream().collect(Collectors.toList());
}

@Override
public String toString() {
return record.toString();
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package net.kimleo.rec.loader.strategy;

import net.kimleo.rec.Pair;
import net.kimleo.rec.loader.LoadingConfig;
import net.kimleo.rec.loader.RecordLoader;
import net.kimleo.rec.repository.RecRepository;
Expand All @@ -11,6 +12,7 @@
import java.nio.file.Paths;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

import static net.kimleo.rec.util.Sys.die;
Expand All @@ -26,17 +28,17 @@ public DefaultLoadingStrategy(String path) {
@Override
public List<LoadingConfig> configs() {
File[] files = new File(path).listFiles();
List<File> recs = Arrays.stream(files)
.filter(file -> file.getName().endsWith(".rec")).collect(Collectors.toList());
System.out.println(path);
if (files == null) {
die(String.format("Not a directory %s", path));
}

recs.forEach(file -> {
if (Files.exists(Paths.get(dataFileOf(file.getName())))) {
die(String.format("No data file fount for %s", file));
}
});
Map<String, File> recFiles = Arrays.stream(files)
.filter(it -> it.getName().endsWith(".rec")).collect(Collectors.toMap(File::getName, it -> it));

return recs.stream()
.map(file -> new LoadingConfig(dataFileOf(file.getAbsolutePath()), file.getAbsolutePath()))
return Arrays.stream(files)
.filter( file -> recFiles.containsKey(file.getName() + ".rec"))
.map(f -> new LoadingConfig(f.getAbsolutePath(), recFiles.get(f.getName() + ".rec").getAbsolutePath()))
.collect(Collectors.toList());
}

Expand All @@ -50,8 +52,4 @@ public static RecRepository repo(String path) {
return new RecRepository(sets);
}

@NotNull
private String dataFileOf(String file) {
return file.substring(0, file.length() - 4);
}
}
4 changes: 4 additions & 0 deletions rec-core/src/main/kotlin/net/kimleo/rec/record/Record.kt
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ data class Record(val cells: List<Cell>, val text: String, val original: Boolean
override fun get(index: Int): String {
return cells[index].value
}

override fun toString(): String {
return text
}
}

fun SepValEntry.toRecord() = Record(this.values.map(::Cell), this.source)
2 changes: 1 addition & 1 deletion testjs.sh
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
#/bin/bash
java -jar rec-app/build/libs/rec-app-0.1.2.jar js rec-scripting/src/test/resources/test_exec.js
java -jar rec-app/build/libs/rec-app-0.1.3.jar js rec-scripting/src/test/resources/test_exec.js
2 changes: 1 addition & 1 deletion testrec.sh
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
#/bin/bash
java -jar rec-app/build/libs/rec-app-0.1.2.jar rec-core/src/test/resources/
java -jar rec-app/build/libs/rec-app-0.1.3.jar rec-core/src/test/resources/

0 comments on commit d0a9dc4

Please sign in to comment.