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> <artifactId>jcabi-manifests</artifactId>
<!-- version from parent POM --> <!-- version from parent POM -->
</dependency> </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> <dependency>
<groupId>net.sf.saxon</groupId> <groupId>net.sf.saxon</groupId>
<artifactId>Saxon-HE</artifactId> <artifactId>Saxon-HE</artifactId>
@ -268,6 +278,18 @@ SOFTWARE.
</dependencies> </dependencies>
<build> <build>
<plugins> <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> <plugin>
<artifactId>maven-invoker-plugin</artifactId> <artifactId>maven-invoker-plugin</artifactId>
<configuration> <configuration>

View File

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

View File

@ -23,9 +23,14 @@
*/ */
package org.eolang.maven.hash; 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.Text;
import org.cactoos.scalar.Unchecked;
import org.cactoos.text.Sticky; import org.cactoos.text.Sticky;
import org.cactoos.text.TextEnvelope; import org.cactoos.text.TextEnvelope;
import org.cactoos.text.TextOf;
/** /**
* Commit hashes table as text from objectionary. * Commit hashes table as text from objectionary.
@ -36,23 +41,35 @@ import org.cactoos.text.TextEnvelope;
*/ */
final class CommitHashesText extends TextEnvelope { final class CommitHashesText extends TextEnvelope {
/**
* Tags.
*/
private static final String HOME = "https://home.objectionary.com/tags.txt";
/** /**
* Cache. * Cache.
*/ */
private static final Text CACHE = new Sticky(new ObjectionaryCommitHashes()); private static final Text CACHE = new Sticky(
CommitHashesText.asText(CommitHashesText.HOME)
);
/** /**
* Constructor. * Constructor.
*/ */
CommitHashesText() { CommitHashesText() {
this(CommitHashesText.CACHE); super(CommitHashesText.CACHE);
} }
/** /**
* Constructor. * Download from the URL and return the content.
* @param text The text to of commit hashes. * @param url The URL with tags
* @return The body of the web page
*/ */
private CommitHashesText(final Text text) { @RetryOnFailure(delay = 1L, unit = TimeUnit.SECONDS)
super(text); 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; package org.eolang.maven.objectionary;
import com.jcabi.aspects.RetryOnFailure;
import java.net.URL; import java.net.URL;
import java.util.Set; import java.util.Set;
import java.util.concurrent.TimeUnit;
import org.cactoos.Scalar; import org.cactoos.Scalar;
import org.cactoos.Text; import org.cactoos.Text;
import org.cactoos.iterable.Mapped; import org.cactoos.iterable.Mapped;
import org.cactoos.scalar.ScalarOf; import org.cactoos.scalar.ScalarOf;
import org.cactoos.scalar.Sticky; import org.cactoos.scalar.Sticky;
import org.cactoos.scalar.Unchecked;
import org.cactoos.set.SetOf; import org.cactoos.set.SetOf;
import org.cactoos.text.Split; import org.cactoos.text.Split;
import org.cactoos.text.TextOf; import org.cactoos.text.TextOf;
@ -42,6 +45,11 @@ import org.cactoos.text.TextOf;
*/ */
final class ObjectsIndex { final class ObjectsIndex {
/**
* Tags.
*/
private static final String HOME = "https://home.objectionary.com/objectionary.lst";
/** /**
* Cached objects index. * Cached objects index.
*/ */
@ -59,9 +67,7 @@ final class ObjectsIndex {
new Mapped<>( new Mapped<>(
Text::asString, Text::asString,
new Split( new Split(
new TextOf( ObjectsIndex.asText(new URL(ObjectsIndex.HOME)),
new URL("https://home.objectionary.com/objectionary.lst")
),
"\n" "\n"
) )
) )
@ -102,4 +108,15 @@ final class ObjectsIndex {
.replace('/', '.') .replace('/', '.')
.substring(name.indexOf('/') + 1); .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; package org.eolang.maven.objectionary;
import com.jcabi.aspects.RetryOnFailure;
import com.jcabi.log.Logger; import com.jcabi.log.Logger;
import java.io.IOException; import java.io.IOException;
import java.net.HttpURLConnection; import java.net.HttpURLConnection;
import java.net.MalformedURLException; import java.net.MalformedURLException;
import java.net.URL; import java.net.URL;
import java.util.concurrent.TimeUnit;
import org.cactoos.Input; import org.cactoos.Input;
import org.cactoos.io.InputOf; import org.cactoos.io.InputOf;
import org.cactoos.io.InputWithFallback; import org.cactoos.io.InputWithFallback;
@ -85,6 +87,7 @@ public final class OyRemote implements Objectionary {
} }
@Override @Override
@RetryOnFailure(delay = 1L, unit = TimeUnit.SECONDS)
public boolean contains(final String name) throws IOException { public boolean contains(final String name) throws IOException {
final int code = ((HttpURLConnection) this.template.value(name).openConnection()) final int code = ((HttpURLConnection) this.template.value(name).openConnection())
.getResponseCode(); .getResponseCode();

View File

@ -23,43 +23,26 @@
*/ */
package org.eolang.maven.hash; package org.eolang.maven.hash;
import java.net.URL; import com.yegor256.WeAreOnline;
import org.cactoos.scalar.Unchecked; import org.hamcrest.MatcherAssert;
import org.cactoos.text.TextEnvelope; import org.hamcrest.Matchers;
import org.cactoos.text.TextOf; 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 {
/** @Test
* Tags. @ExtendWith(WeAreOnline.class)
*/ void downloadsDefaultList() throws Exception {
private static final String HOME = "https://home.objectionary.com/tags.txt"; MatcherAssert.assertThat(
"CommitHashesText downloads the default list of hashes from Objectionary",
/** new CommitHashesText().asString(),
* Constructor. Matchers.containsString("master")
*/ );
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));
} }
} }

View File

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

View File

@ -1,6 +1,6 @@
# The MIT License (MIT) # 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 # Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal # of this software and associated documentation files (the "Software"), to deal