-
Notifications
You must be signed in to change notification settings - Fork 122
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement modules for asciidoctor.js (#344)
- Loading branch information
Showing
19 changed files
with
480 additions
and
88 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
.../src/main/groovy/org/asciidoctor/gradle/base/AbstractImplementationEngineExtension.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
...idoctor-gradle-base/src/main/groovy/org/asciidoctor/gradle/base/internal/Workspace.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 52 additions & 0 deletions
52
...ctor-gradle-js/src/main/groovy/org/asciidoctor/gradle/js/base/AsciidoctorJSModules.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
/* | ||
* Copyright 2013-2019 the original author or authors. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package org.asciidoctor.gradle.js.base | ||
|
||
import groovy.transform.CompileStatic | ||
import org.asciidoctor.gradle.base.AsciidoctorModuleDefinition | ||
|
||
/** Define versions for standard AsciidoctorJS modules. | ||
* | ||
* @author Schalk W. Cronjé | ||
* | ||
* @since 3.0 | ||
*/ | ||
@SuppressWarnings(['ConfusingMethodName', 'ClassName']) | ||
@CompileStatic | ||
interface AsciidoctorJSModules { | ||
|
||
/** Configure docbook via closure. | ||
* | ||
* @param cfg Configurating closure | ||
*/ | ||
void docbook(@DelegatesTo(AsciidoctorModuleDefinition) Closure cfg) | ||
|
||
/** The Docbook module | ||
* | ||
* @return Acess to the Docbook module. Never {@code null}. | ||
*/ | ||
AsciidoctorModuleDefinition getDocbook() | ||
|
||
/** For the module that are configured in both module sets, | ||
* compare to see if the versions are the same | ||
* | ||
* @param other Other module set to compare. | ||
* | ||
* @return {@code true} if modules of the same kind were found, but with different versions. | ||
*/ | ||
boolean isSetVersionsDifferentTo(AsciidoctorJSModules other) | ||
|
||
} |
79 changes: 79 additions & 0 deletions
79
...dle-js/src/main/groovy/org/asciidoctor/gradle/js/base/internal/AsciidoctorJSModule.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
/* | ||
* Copyright 2013-2019 the original author or authors. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package org.asciidoctor.gradle.js.base.internal | ||
|
||
import org.asciidoctor.gradle.base.AsciidoctorModuleDefinition | ||
import org.gradle.api.Action | ||
|
||
import static org.ysb33r.grolifant.api.StringUtils.stringize | ||
|
||
/** A single configurable asciidoctor.js module. | ||
* | ||
* @author Schalk W. Cronjé | ||
* @since 3.0.0 | ||
*/ | ||
class AsciidoctorJSModule implements AsciidoctorModuleDefinition { | ||
|
||
private Optional<Object> version = Optional.empty() | ||
private final Object defaultVersion | ||
private final Action<Object> setAction | ||
|
||
static AsciidoctorJSModule of(final Object defaultVersion) { | ||
new AsciidoctorJSModule(defaultVersion) | ||
} | ||
|
||
static AsciidoctorJSModule of(final Object defaultVersion, Closure setAction) { | ||
new AsciidoctorJSModule(defaultVersion, setAction as Action<Object>) | ||
} | ||
|
||
AsciidoctorJSModule(final Object defaultVersion, Action<Object> setAction = null) { | ||
this.defaultVersion = defaultVersion | ||
this.setAction = setAction | ||
} | ||
|
||
@Override | ||
void use() { | ||
setVersion(this.defaultVersion) | ||
} | ||
|
||
@Override | ||
void setVersion(Object o) { | ||
this.version = Optional.of(o) | ||
if (setAction) { | ||
setAction.execute(o) | ||
} | ||
} | ||
|
||
@Override | ||
@SuppressWarnings('ConfusingMethodName') | ||
void version(Object o) { | ||
setVersion(o) | ||
} | ||
|
||
@Override | ||
String getVersion() { | ||
this.version.present ? stringize(this.version.get()) : null | ||
} | ||
|
||
/** Whether the component has been allocated a version. | ||
* | ||
* @return {@code true} if the component has been defined | ||
*/ | ||
@Override | ||
boolean isDefined() { | ||
version.present | ||
} | ||
} |
Oops, something went wrong.