use of org.xembly.Directives in project jcabi-github by jcabi.
the class MkGist method fork.
@Override
public Gist fork() throws IOException {
this.storage.lock();
final String number;
try {
final XML xml = this.storage.xml();
number = Integer.toString(1 + xml.xpath("/github/gists/gist/id/text()").size());
final Directives dirs = new Directives().xpath("/github/gists").add("gist").add("id").set(number).up().add("files");
final List<XML> files = xml.nodes(String.format("%s/files/file", this.xpath()));
for (final XML file : files) {
final String filename = file.xpath("filename/text()").get(0);
// @checkstyle MultipleStringLiterals (3 lines)
dirs.add("file").add("filename").set(filename).up().add("raw_content").set(this.read(filename)).up().up();
}
this.storage.apply(dirs);
} finally {
this.storage.unlock();
}
return new MkGist(this.storage, this.self, number);
}
use of org.xembly.Directives in project jcabi-github by jcabi.
the class MkRepoCommitTest method canGetJson.
/**
* MkRepoCommit can get a JSON.
* @throws Exception if some problem inside
*/
@Test
public void canGetJson() throws Exception {
final MkStorage storage = new MkStorage.InFile();
storage.apply(new Directives().xpath("/github").add("repos").add("repo").attr("coords", "test_login/test_repo").add("commits").add("commit").add("sha").set(SHA1));
final MkRepoCommit repoCommit = new MkRepoCommit(storage, this.repo(storage), SHA1);
MatcherAssert.assertThat(repoCommit.json(), Matchers.notNullValue());
}
use of org.xembly.Directives in project wring by yegor256.
the class CycleTest method processesSinglePipeWithBrokenJson.
/**
* Cycle can process a single pipe with broken JSOn.
* @throws Exception If some problem inside
*/
@Test
public void processesSinglePipeWithBrokenJson() throws Exception {
final Base base = new FkBase();
final Pipe pipe = new FkPipe(new Directives().add("pipe").add("urn").set("urn:test:1").up().add("json").set("{\"a\":\"/@[a-z0-9\\\\-]\\\\s+\"}").up().up());
new Cycle(base).exec(pipe);
}
Aggregations