Merge branch '__rultor'

This commit is contained in:
rultor 2024-04-16 03:41:01 +00:00
commit 715415adce
8 changed files with 90 additions and 45 deletions

View File

@ -70,6 +70,16 @@ SOFTWARE.
<artifactId>jcabi-manifests</artifactId>
<!-- version from parent POM -->
</dependency>
<dependency>
<groupId>com.jcabi</groupId>
<artifactId>jcabi-aspects</artifactId>
<version>0.26.0</version>
</dependency>
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjrt</artifactId>
<version>1.9.21</version>
</dependency>
<dependency>
<groupId>net.sf.saxon</groupId>
<artifactId>Saxon-HE</artifactId>
@ -268,6 +278,18 @@ SOFTWARE.
</dependencies>
<build>
<plugins>
<plugin>
<groupId>com.jcabi</groupId>
<artifactId>jcabi-maven-plugin</artifactId>
<version>0.17.0</version>
<executions>
<execution>
<goals>
<goal>ajc</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-invoker-plugin</artifactId>
<configuration>

View File

@ -23,10 +23,12 @@
*/
package org.eolang.maven.dependencies;
import com.jcabi.aspects.RetryOnFailure;
import com.jcabi.xml.XMLDocument;
import java.io.IOException;
import java.net.URL;
import java.util.Iterator;
import java.util.concurrent.TimeUnit;
import org.apache.maven.model.Dependency;
import org.cactoos.list.ListOf;
import org.cactoos.scalar.Sticky;
@ -104,6 +106,7 @@ public final class DcsWithRuntime implements Iterable<Dependency> {
*
* @return Runtime dependency from Maven Central.
*/
@RetryOnFailure(delay = 1L, unit = TimeUnit.SECONDS)
private static Unchecked<Dependency> mavenDependency() {
final String url = String.format(
"https://repo.maven.apache.org/maven2/%s/maven-metadata.xml",

View File

@ -23,9 +23,14 @@
*/
package org.eolang.maven.hash;
import com.jcabi.aspects.RetryOnFailure;
import java.net.URL;
import java.util.concurrent.TimeUnit;
import org.cactoos.Text;
import org.cactoos.scalar.Unchecked;
import org.cactoos.text.Sticky;
import org.cactoos.text.TextEnvelope;
import org.cactoos.text.TextOf;
/**
* Commit hashes table as text from objectionary.
@ -36,23 +41,35 @@ import org.cactoos.text.TextEnvelope;
*/
final class CommitHashesText extends TextEnvelope {
/**
* Tags.
*/
private static final String HOME = "https://home.objectionary.com/tags.txt";
/**
* Cache.
*/
private static final Text CACHE = new Sticky(new ObjectionaryCommitHashes());
private static final Text CACHE = new Sticky(
CommitHashesText.asText(CommitHashesText.HOME)
);
/**
* Constructor.
*/
CommitHashesText() {
this(CommitHashesText.CACHE);
super(CommitHashesText.CACHE);
}
/**
* Constructor.
* @param text The text to of commit hashes.
* Download from the URL and return the content.
* @param url The URL with tags
* @return The body of the web page
*/
private CommitHashesText(final Text text) {
super(text);
@RetryOnFailure(delay = 1L, unit = TimeUnit.SECONDS)
private static Text asText(final String url) {
final String body = new Unchecked<>(
() -> new TextOf(new URL(url)).asString()
).value();
return new TextOf(body);
}
}

View File

@ -23,13 +23,16 @@
*/
package org.eolang.maven.objectionary;
import com.jcabi.aspects.RetryOnFailure;
import java.net.URL;
import java.util.Set;
import java.util.concurrent.TimeUnit;
import org.cactoos.Scalar;
import org.cactoos.Text;
import org.cactoos.iterable.Mapped;
import org.cactoos.scalar.ScalarOf;
import org.cactoos.scalar.Sticky;
import org.cactoos.scalar.Unchecked;
import org.cactoos.set.SetOf;
import org.cactoos.text.Split;
import org.cactoos.text.TextOf;
@ -42,6 +45,11 @@ import org.cactoos.text.TextOf;
*/
final class ObjectsIndex {
/**
* Tags.
*/
private static final String HOME = "https://home.objectionary.com/objectionary.lst";
/**
* Cached objects index.
*/
@ -59,9 +67,7 @@ final class ObjectsIndex {
new Mapped<>(
Text::asString,
new Split(
new TextOf(
new URL("https://home.objectionary.com/objectionary.lst")
),
ObjectsIndex.asText(new URL(ObjectsIndex.HOME)),
"\n"
)
)
@ -102,4 +108,15 @@ final class ObjectsIndex {
.replace('/', '.')
.substring(name.indexOf('/') + 1);
}
/**
* Download from the URL and return the content.
* @param url The URL with tags
* @return The body of the web page
*/
@RetryOnFailure(delay = 1L, unit = TimeUnit.SECONDS)
private static Text asText(final URL url) {
final String body = new Unchecked<>(() -> new TextOf(url).asString()).value();
return new TextOf(body);
}
}

View File

@ -23,11 +23,13 @@
*/
package org.eolang.maven.objectionary;
import com.jcabi.aspects.RetryOnFailure;
import com.jcabi.log.Logger;
import java.io.IOException;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.concurrent.TimeUnit;
import org.cactoos.Input;
import org.cactoos.io.InputOf;
import org.cactoos.io.InputWithFallback;
@ -85,6 +87,7 @@ public final class OyRemote implements Objectionary {
}
@Override
@RetryOnFailure(delay = 1L, unit = TimeUnit.SECONDS)
public boolean contains(final String name) throws IOException {
final int code = ((HttpURLConnection) this.template.value(name).openConnection())
.getResponseCode();

View File

@ -23,43 +23,26 @@
*/
package org.eolang.maven.hash;
import java.net.URL;
import org.cactoos.scalar.Unchecked;
import org.cactoos.text.TextEnvelope;
import org.cactoos.text.TextOf;
import com.yegor256.WeAreOnline;
import org.hamcrest.MatcherAssert;
import org.hamcrest.Matchers;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
/**
* CommitHashes which we download from Objectionary.
* Test case for {@link CommitHashesText}.
*
* @since 0.30
* @since 0.37.0
*/
final class ObjectionaryCommitHashes extends TextEnvelope {
final class CommitHashesTextTest {
/**
* Tags.
*/
private static final String HOME = "https://home.objectionary.com/tags.txt";
/**
* Constructor.
*/
ObjectionaryCommitHashes() {
this(ObjectionaryCommitHashes.HOME);
}
/**
* Constructor.
* @param tags The url from which to download tags list.
*/
private ObjectionaryCommitHashes(final String tags) {
this(new Unchecked<>(() -> new URL(tags)).value());
}
/**
* Constructor.
* @param tags The url from which to download tags list.
*/
private ObjectionaryCommitHashes(final URL tags) {
super(new TextOf(tags));
@Test
@ExtendWith(WeAreOnline.class)
void downloadsDefaultList() throws Exception {
MatcherAssert.assertThat(
"CommitHashesText downloads the default list of hashes from Objectionary",
new CommitHashesText().asString(),
Matchers.containsString("master")
);
}
}

View File

@ -46,7 +46,7 @@ final class OyRemoteTest {
@Test
void buildsCorrectUrl() throws Exception {
MatcherAssert.assertThat(
"TO ADD ASSERTION MESSAGE",
"OyRemove.UrlOy generates correct URL",
new OyRemote.UrlOy(
"https://raw/objectionary/home/%s/objects/%s.eo",
"abcde"
@ -74,7 +74,7 @@ final class OyRemoteTest {
final CommitHash hash = new ChRemote("master");
final Objectionary objectionary = new OyRemote(hash);
MatcherAssert.assertThat(
"TO ADD ASSERTION MESSAGE",
"OyRemote positively checks the presence of the object in Objectionary",
objectionary.contains("org.eolang.io.stdout"),
Matchers.is(true)
);

View File

@ -1,6 +1,6 @@
# The MIT License (MIT)
#
# 2016-2023 Objectionary.com
# Copyright (c) 2016-2024 Objectionary.com
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal