Renaming to gcp.
This commit is contained in:
parent
fe855181af
commit
bee1dead98
@ -3,7 +3,7 @@ package com.jessebrault.gcp
|
|||||||
import com.jessebrault.gcp.component.ComponentsContainer
|
import com.jessebrault.gcp.component.ComponentsContainer
|
||||||
import groovy.text.Template
|
import groovy.text.Template
|
||||||
|
|
||||||
class GspeTemplate implements Template {
|
class GcpTemplate implements Template {
|
||||||
|
|
||||||
Closure templateClosure
|
Closure templateClosure
|
||||||
ComponentsContainer components
|
ComponentsContainer components
|
@ -12,13 +12,13 @@ import org.slf4j.LoggerFactory
|
|||||||
import java.util.concurrent.atomic.AtomicInteger
|
import java.util.concurrent.atomic.AtomicInteger
|
||||||
import java.util.function.Supplier
|
import java.util.function.Supplier
|
||||||
|
|
||||||
final class GspeTemplateEngine extends TemplateEngine {
|
final class GcpTemplateEngine extends TemplateEngine {
|
||||||
|
|
||||||
private static final Logger logger = LoggerFactory.getLogger(GspeTemplateEngine)
|
private static final Logger logger = LoggerFactory.getLogger(GcpTemplateEngine)
|
||||||
|
|
||||||
@TupleConstructor(defaults = false)
|
@TupleConstructor(defaults = false)
|
||||||
static class Configuration {
|
static class Configuration {
|
||||||
Supplier<GspeTemplate> ssgTemplateSupplier
|
Supplier<GcpTemplate> ssgTemplateSupplier
|
||||||
Collection<URL> componentDirUrls
|
Collection<URL> componentDirUrls
|
||||||
Collection<Component> components
|
Collection<Component> components
|
||||||
}
|
}
|
||||||
@ -28,7 +28,7 @@ final class GspeTemplateEngine extends TemplateEngine {
|
|||||||
private final AtomicInteger templateCount = new AtomicInteger(0)
|
private final AtomicInteger templateCount = new AtomicInteger(0)
|
||||||
private final GroovyScriptEngine scriptEngine
|
private final GroovyScriptEngine scriptEngine
|
||||||
|
|
||||||
GspeTemplateEngine(Configuration configuration) {
|
GcpTemplateEngine(Configuration configuration) {
|
||||||
this.configuration = configuration
|
this.configuration = configuration
|
||||||
this.scriptEngine = new GroovyScriptEngine([this.scriptsDir.toURI().toURL()] as URL[])
|
this.scriptEngine = new GroovyScriptEngine([this.scriptsDir.toURI().toURL()] as URL[])
|
||||||
}
|
}
|
@ -1,17 +1,16 @@
|
|||||||
package com.jessebrault.gcp
|
package com.jessebrault.gcp
|
||||||
|
|
||||||
import com.jessebrault.gcp.GspeTemplate
|
|
||||||
import com.jessebrault.gcp.GspeTemplateEngine
|
|
||||||
import com.jessebrault.gcp.component.Component
|
import com.jessebrault.gcp.component.Component
|
||||||
import groovy.text.TemplateEngine
|
import groovy.text.TemplateEngine
|
||||||
import org.junit.jupiter.api.Test
|
import org.junit.jupiter.api.Test
|
||||||
|
|
||||||
import static org.junit.jupiter.api.Assertions.assertEquals
|
import static org.junit.jupiter.api.Assertions.assertEquals
|
||||||
|
|
||||||
class GspeTemplateEngineTests {
|
class GcpTemplateEngineTests {
|
||||||
|
|
||||||
private final TemplateEngine engine = new GspeTemplateEngine(new GspeTemplateEngine.Configuration(
|
private final TemplateEngine engine = new GcpTemplateEngine(new GcpTemplateEngine.Configuration(
|
||||||
{ new GspeTemplate() },
|
{ new GcpTemplate() },
|
||||||
[],
|
[],
|
||||||
[]
|
[]
|
||||||
))
|
))
|
||||||
@ -65,7 +64,7 @@ class GspeTemplateEngineTests {
|
|||||||
assertEquals('Hello, World!', r)
|
assertEquals('Hello, World!', r)
|
||||||
}
|
}
|
||||||
|
|
||||||
static class CustomBaseTemplate extends GspeTemplate {
|
static class CustomBaseTemplate extends GcpTemplate {
|
||||||
|
|
||||||
def greeting = 'Greetings!'
|
def greeting = 'Greetings!'
|
||||||
def name = 'Jesse'
|
def name = 'Jesse'
|
||||||
@ -80,8 +79,8 @@ class GspeTemplateEngineTests {
|
|||||||
@Test
|
@Test
|
||||||
void baseTemplateMethodsPresent() {
|
void baseTemplateMethodsPresent() {
|
||||||
def src = '<%= greet() %>'
|
def src = '<%= greet() %>'
|
||||||
def configuration = new GspeTemplateEngine.Configuration({ new CustomBaseTemplate() }, [], [])
|
def configuration = new GcpTemplateEngine.Configuration({ new CustomBaseTemplate() }, [], [])
|
||||||
def engine = new GspeTemplateEngine(configuration)
|
def engine = new GcpTemplateEngine(configuration)
|
||||||
def r = engine.createTemplate(src).make().toString()
|
def r = engine.createTemplate(src).make().toString()
|
||||||
assertEquals('Hello, World!', r)
|
assertEquals('Hello, World!', r)
|
||||||
}
|
}
|
||||||
@ -89,8 +88,8 @@ class GspeTemplateEngineTests {
|
|||||||
@Test
|
@Test
|
||||||
void baseTemplatePropertiesPresent() {
|
void baseTemplatePropertiesPresent() {
|
||||||
def src = '<%= this.greeting %>'
|
def src = '<%= this.greeting %>'
|
||||||
def configuration = new GspeTemplateEngine.Configuration({ new CustomBaseTemplate() }, [], [])
|
def configuration = new GcpTemplateEngine.Configuration({ new CustomBaseTemplate() }, [], [])
|
||||||
def engine = new GspeTemplateEngine(configuration)
|
def engine = new GcpTemplateEngine(configuration)
|
||||||
def r = engine.createTemplate(src).make().toString()
|
def r = engine.createTemplate(src).make().toString()
|
||||||
assertEquals('Greetings!', r)
|
assertEquals('Greetings!', r)
|
||||||
}
|
}
|
||||||
@ -98,8 +97,8 @@ class GspeTemplateEngineTests {
|
|||||||
@Test
|
@Test
|
||||||
void bindingOverridesCustomBaseTemplate() {
|
void bindingOverridesCustomBaseTemplate() {
|
||||||
def src = '<%= greet() %>'
|
def src = '<%= greet() %>'
|
||||||
def configuration = new GspeTemplateEngine.Configuration({ new CustomBaseTemplate() }, [], [])
|
def configuration = new GcpTemplateEngine.Configuration({ new CustomBaseTemplate() }, [], [])
|
||||||
def engine = new GspeTemplateEngine(configuration)
|
def engine = new GcpTemplateEngine(configuration)
|
||||||
def r = engine.createTemplate(src).make([greet: { "Hello, Person!" }]).toString()
|
def r = engine.createTemplate(src).make([greet: { "Hello, Person!" }]).toString()
|
||||||
assertEquals('Hello, Person!', r)
|
assertEquals('Hello, Person!', r)
|
||||||
}
|
}
|
||||||
@ -116,8 +115,8 @@ class GspeTemplateEngineTests {
|
|||||||
@Test
|
@Test
|
||||||
void selfClosingComponent() {
|
void selfClosingComponent() {
|
||||||
def src = '<Greeter greeting="Hello" person="World" />'
|
def src = '<Greeter greeting="Hello" person="World" />'
|
||||||
def configuration = new GspeTemplateEngine.Configuration({ new GspeTemplate() }, [], [new Greeter()])
|
def configuration = new GcpTemplateEngine.Configuration({ new GcpTemplate() }, [], [new Greeter()])
|
||||||
def engine = new GspeTemplateEngine(configuration)
|
def engine = new GcpTemplateEngine(configuration)
|
||||||
def r = engine.createTemplate(src).make().toString()
|
def r = engine.createTemplate(src).make().toString()
|
||||||
assertEquals('Hello, World!', r)
|
assertEquals('Hello, World!', r)
|
||||||
}
|
}
|
||||||
@ -125,8 +124,8 @@ class GspeTemplateEngineTests {
|
|||||||
@Test
|
@Test
|
||||||
void componentWithGStringAttrValue() {
|
void componentWithGStringAttrValue() {
|
||||||
def src = '<Greeter greeting="Hello" person="person number ${ 13 }" />'
|
def src = '<Greeter greeting="Hello" person="person number ${ 13 }" />'
|
||||||
def configuration = new GspeTemplateEngine.Configuration({ new GspeTemplate() }, [], [new Greeter()])
|
def configuration = new GcpTemplateEngine.Configuration({ new GcpTemplate() }, [], [new Greeter()])
|
||||||
def engine = new GspeTemplateEngine(configuration)
|
def engine = new GcpTemplateEngine(configuration)
|
||||||
def r = engine.createTemplate(src).make().toString()
|
def r = engine.createTemplate(src).make().toString()
|
||||||
assertEquals('Hello, person number 13!', r)
|
assertEquals('Hello, person number 13!', r)
|
||||||
}
|
}
|
||||||
@ -134,8 +133,8 @@ class GspeTemplateEngineTests {
|
|||||||
@Test
|
@Test
|
||||||
void componentWithGStringAttrValueCanAccessBinding() {
|
void componentWithGStringAttrValueCanAccessBinding() {
|
||||||
def src = '<Greeter greeting="Hello" person="person named ${ name }" />'
|
def src = '<Greeter greeting="Hello" person="person named ${ name }" />'
|
||||||
def configuration = new GspeTemplateEngine.Configuration({ new GspeTemplate() }, [], [new Greeter()])
|
def configuration = new GcpTemplateEngine.Configuration({ new GcpTemplate() }, [], [new Greeter()])
|
||||||
def engine = new GspeTemplateEngine(configuration)
|
def engine = new GcpTemplateEngine(configuration)
|
||||||
def r = engine.createTemplate(src).make([name: 'Jesse']).toString()
|
def r = engine.createTemplate(src).make([name: 'Jesse']).toString()
|
||||||
assertEquals('Hello, person named Jesse!', r)
|
assertEquals('Hello, person named Jesse!', r)
|
||||||
}
|
}
|
||||||
@ -143,8 +142,8 @@ class GspeTemplateEngineTests {
|
|||||||
@Test
|
@Test
|
||||||
void componentWithGStringAttrValueCanAccessBaseTemplateMethod() {
|
void componentWithGStringAttrValueCanAccessBaseTemplateMethod() {
|
||||||
def src = '<Greeter greeting="Hello" person="person named ${ getName() }" />'
|
def src = '<Greeter greeting="Hello" person="person named ${ getName() }" />'
|
||||||
def configuration = new GspeTemplateEngine.Configuration({ new CustomBaseTemplate() }, [], [new Greeter()])
|
def configuration = new GcpTemplateEngine.Configuration({ new CustomBaseTemplate() }, [], [new Greeter()])
|
||||||
def engine = new GspeTemplateEngine(configuration)
|
def engine = new GcpTemplateEngine(configuration)
|
||||||
def r = engine.createTemplate(src).make().toString()
|
def r = engine.createTemplate(src).make().toString()
|
||||||
assertEquals('Hello, person named Jesse!', r)
|
assertEquals('Hello, person named Jesse!', r)
|
||||||
}
|
}
|
||||||
@ -152,8 +151,8 @@ class GspeTemplateEngineTests {
|
|||||||
@Test
|
@Test
|
||||||
void componentWithGStringAttrValueCanAccessBaseTemplateProperty() {
|
void componentWithGStringAttrValueCanAccessBaseTemplateProperty() {
|
||||||
def src = '<Greeter greeting="Hello" person="person named ${ this.name }" />'
|
def src = '<Greeter greeting="Hello" person="person named ${ this.name }" />'
|
||||||
def configuration = new GspeTemplateEngine.Configuration({ new CustomBaseTemplate() }, [], [new Greeter()])
|
def configuration = new GcpTemplateEngine.Configuration({ new CustomBaseTemplate() }, [], [new Greeter()])
|
||||||
def engine = new GspeTemplateEngine(configuration)
|
def engine = new GcpTemplateEngine(configuration)
|
||||||
def r = engine.createTemplate(src).make().toString()
|
def r = engine.createTemplate(src).make().toString()
|
||||||
assertEquals('Hello, person named Jesse!', r)
|
assertEquals('Hello, person named Jesse!', r)
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user