Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/production protection #4

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
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
7 changes: 4 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ if (System.getenv('TRAVIS_BRANCH') && System.getenv('TRAVIS_PULL_REQUEST') == 'f
}

group = 'gyro'
version = '0.15-SNAPSHOT'
version = '0.99.0-SNAPSHOT'

java {
sourceCompatibility = JavaVersion.VERSION_1_8
Expand All @@ -48,13 +48,14 @@ repositories {
}

dependencies {
api 'gyro:gyro-core:0.15-SNAPSHOT'
api 'gyro:gyro-core:0.99.0-SNAPSHOT'

implementation 'com.psddev:dari-util:3.3.607-xe0f27a'
implementation 'org.yaml:snakeyaml:1.24'
implementation 'org.eclipse.jgit:org.eclipse.jgit:5.4.0.201906121030-r'
implementation 'org.fusesource.jansi:jansi:1.16'
implementation 'us.monoid.web:resty:0.3.2'
implementation 'gyro:gyro-aws-provider:0.15-SNAPSHOT'
implementation 'gyro:gyro-aws-provider:0.99.0-SNAPSHOT'
implementation enforcedPlatform('software.amazon.awssdk:bom:2.5.70')
implementation 'software.amazon.awssdk:s3'
implementation 'software.amazon.awssdk:apache-client'
Expand Down
70 changes: 70 additions & 0 deletions src/main/java/gyro/sample/ProdutionGyroUi.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
package gyro.sample;

import gyro.core.GyroUI;
import org.fusesource.jansi.AnsiRenderer;

public class ProdutionGyroUi implements GyroUI {

private GyroUI delegate;

public ProdutionGyroUi(GyroUI delegate) {
this.delegate = delegate;
}

@Override
public boolean isVerbose() {
return delegate.isVerbose();
}

@Override
public void setVerbose(boolean b) {
delegate.setVerbose(b);
}

@Override
public boolean readBoolean(Boolean aBoolean, String s, Object... objects) {
s = AnsiRenderer.render("[PRODUCTION] " + s, AnsiRenderer.Code.FG_RED.toString());
return delegate.readBoolean(aBoolean, s, objects);
}

@Override
public void readEnter(String s, Object... objects) {
delegate.readEnter(s, objects);
}

@Override
public <E extends Enum<E>> E readNamedOption(E e) {
return delegate.readNamedOption(e);
}

@Override
public String readPassword(String s, Object... objects) {
return delegate.readPassword(s, objects);
}

@Override
public String readText(String s, Object... objects) {
return delegate.readText(s, objects);
}

@Override
public void indent() {
delegate.indent();
}

@Override
public void unindent() {
delegate.unindent();
}

@Override
public void write(String s, Object... objects) {
delegate.write(s, objects);
}

@Override
public void replace(String s, Object... objects) {
delegate.replace(s, objects);
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package gyro.sample.directive;

import gyro.core.GyroCore;
import gyro.core.GyroUI;
import gyro.core.Type;
import gyro.core.directive.DirectiveProcessor;
import gyro.core.scope.FileScope;
import gyro.lang.ast.block.DirectiveNode;
import gyro.sample.ProdutionGyroUi;

@Type("production")
public class ProductionProtectionDirectiveProcessor extends DirectiveProcessor<FileScope> {

@Override
public void process(FileScope fileScope, DirectiveNode directiveNode) throws Exception {
GyroUI ui = GyroCore.popUi();
if (!(ui instanceof ProdutionGyroUi)) {
ui = new ProdutionGyroUi(ui);
}

GyroCore.pushUi(ui);
}
}