Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/maven.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@ jobs:
distribution: 'temurin'
cache: maven
- name: Build with Maven
run: mvn clean install --batch-mode --update-snapshots
run: mvn clean install -Pqulice --batch-mode --update-snapshots
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
*
* @since 0.1.0
*/
public class CmdListStand implements Cmd<Update, AbsSender> {
public final class CmdListStand implements Cmd<Update, AbsSender> {
/**
* Available stands.
*/
Expand All @@ -56,22 +56,27 @@ public CmdListStand(final Stands stands) {
this.stands = stands;
}

// @checkstyle IllegalCatchCheck (50 lines)
@SuppressWarnings("PMD.AvoidCatchingGenericException")
@Override
public Send<AbsSender> execute(final Update update) throws CmdException {
final SendMessage message;
try {
message = new SendMessage(
update.getMessage().getChatId().toString(),
new Stand.Text(
new Stand.Printed(
this.stands.stand(
new Trimmed(
new Replaced(
new TextOf(update.getMessage().getText()), "Покажи сервис", "")
new TextOf(update.getMessage().getText()),
"Покажи сервис",
""
)
).asString()
)
).toString()
);
} catch (Exception exception) {
} catch (final Exception exception) {
throw new CmdException(
String.format("Failed to eject value from cmd %s", update.getMessage().getText()),
exception
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@

import io.github.artemget.tagrelease.domain.Stands;
import io.github.artemget.teleroute.command.Cmd;
import io.github.artemget.teleroute.command.CmdException;
import io.github.artemget.teleroute.send.Send;
import io.github.artemget.teleroute.telegrambots.send.SendMessageWrap;
import org.telegram.telegrambots.meta.api.methods.send.SendMessage;
Expand Down Expand Up @@ -56,7 +55,7 @@ public CmdListStands(final Stands stands) {
public Send<AbsSender> execute(final Update update) {
final SendMessage message = new SendMessage(
update.getMessage().getChatId().toString(),
new Stands.Text(this.stands).toString()
new Stands.Printed(this.stands).toString()
);
message.setReplyToMessageId(update.getMessage().getMessageId());
message.enableMarkdownV2(true);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/*
* MIT License
*
* Copyright (c) 2024-2025. Artem Getmanskii
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/

/**
* Commands directory.
*/
package io.github.artemget.tagrelease.command;
24 changes: 23 additions & 1 deletion src/main/java/io/github/artemget/tagrelease/domain/Service.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,34 @@

package io.github.artemget.tagrelease.domain;

import io.github.artemget.tagrelease.exception.TagException;
import org.cactoos.Scalar;

/**
* Application's source code in git.
*
* @since 0.1.0
*/
public interface Service {
/**
* Returns application name.
*
* @return Name
*/
String name();

/**
* Returns application's tag.
*
* @return Tag
*/
String tag();

Service tagged(Scalar<String> tag);
/**
* Builds new tag.
*
* @param rule To build tag
* @return Service with a new tag
*/
Service tagged(Scalar<String> rule) throws TagException;
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,32 @@

package io.github.artemget.tagrelease.domain;

import io.github.artemget.tagrelease.exception.TagException;
import org.cactoos.Scalar;

public class ServiceGitlabEager implements Service {
/**
* Application's source code in gitlab.
*
* @since 0.1.0
*/
@SuppressWarnings("PMD.AvoidFieldNameMatchingMethodName")
public final class ServiceGitlabEager implements Service {
/**
* Application name.
*/
private final String name;

/**
* Application tag.
*/
private final String tag;

/**
* Main ctor.
*
* @param name Of application
* @param tag Of application
*/
public ServiceGitlabEager(final String name, final String tag) {
this.name = name;
this.tag = tag;
Expand All @@ -45,13 +65,17 @@ public String tag() {
return this.tag;
}

// @checkstyle IllegalCatchCheck (50 lines)
@SuppressWarnings("PMD.AvoidCatchingGenericException")
@Override
public Service tagged(Scalar<String> tag) {
//todo: req to gitlab
public Service tagged(final Scalar<String> rule) throws TagException {
try {
return new ServiceGitlabEager(this.name, tag.value());
} catch (Exception exception) {
throw new UnsupportedOperationException(exception);
return new ServiceGitlabEager(this.name, rule.value());
} catch (final Exception exception) {
throw new TagException(
String.format("Failed to create tag for service: %s", this.name),
exception
);
}
}
}
46 changes: 42 additions & 4 deletions src/main/java/io/github/artemget/tagrelease/domain/Services.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,23 +26,61 @@

import java.util.List;
import java.util.stream.Collectors;
import org.cactoos.Text;

/**
* Applications.
*
* @since 0.1.0
*/
public interface Services {
/**
* Returns all services from stand.
*
* @return Services
*/
List<Service> services();

/**
* Returns service from stand by it's name.
*
* @param name Of service
* @return Service
*/
Service service(String name);

final class Text {
/**
* Printed Services.
* Format: ```java %s:%s```\n
*
* @since 0.1.0
*/
final class Printed implements Text {
/**
* Services.
*/
private final Services services;

public Text(final Services services) {
/**
* Main ctor.
*
* @param services Services
*/
public Printed(final Services services) {
this.services = services;
}

@Override
public String toString() {
public String asString() {
return this.services.services().stream()
.map(service -> String.format("```java %s:%s```\n ", service.name(), service.tag()))
.map(
service ->
String.format(
"```java %s:%s```\n ",
service.name(),
service.tag()
)
)
.collect(Collectors.joining());
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,19 @@

import java.util.List;

public class ServicesGitlab implements Services {
/**
* Applications from gitlab.
*
* @since 0.1.0
*/
public final class ServicesGitlab implements Services {
@Override
public List<Service> services() {
throw new UnsupportedOperationException();
}

@Override
public Service service(String name) {
public Service service(final String name) {
throw new UnsupportedOperationException();
}
}
42 changes: 38 additions & 4 deletions src/main/java/io/github/artemget/tagrelease/domain/Stand.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,28 +24,62 @@

package io.github.artemget.tagrelease.domain;

import org.cactoos.Text;

/**
* Server.
*
* @since 0.1.0
*/
public interface Stand {
/**
* Returns server name.
*
* @return Name
*/
String name();

/**
* Returns server's services.
*
* @return Services
*/
Services services();

final class Text {
/**
* Printed server.
* Format:
* Стенд: %s
* Сервисы:
* %s
*
* @since 0.1.0
*/
final class Printed implements Text {
/**
* Server.
*/
private final Stand stand;

public Text(final Stand stand) {
/**
* Main ctor.
*
* @param stand Stand
*/
public Printed(final Stand stand) {
this.stand = stand;
}

@Override
public String toString() {
public String asString() {
return String.format(
"""
Стенд: %s
Сервисы:
%s
""",
this.stand.name(),
new Services.Text(this.stand.services())
new Services.Printed(this.stand.services())
);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,12 @@

package io.github.artemget.tagrelease.domain;

public class StandGitlab implements Stand {
/**
* Server at gitlab.
*
* @since 0.1.0
*/
public final class StandGitlab implements Stand {
@Override
public String name() {
throw new UnsupportedOperationException();
Expand Down
Loading