Skip to content

Commit

Permalink
Merge pull request #14 from ortus-boxlang/development
Browse files Browse the repository at this point in the history
version bump
  • Loading branch information
lmajano authored Oct 31, 2024
2 parents 506cd17 + b591e76 commit 6d03249
Show file tree
Hide file tree
Showing 9 changed files with 340 additions and 12 deletions.
11 changes: 5 additions & 6 deletions .github/workflows/snapshot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true

env:
MODULE_ID: ${{ github.event.repository.name }}
JDK_VERSION: 21

jobs:
#############################################
# Tests First baby! We fail, no build :(
Expand Down Expand Up @@ -39,16 +43,11 @@ jobs:
uses: actions/setup-java@v4
with:
distribution: "temurin"
java-version: 21
java-version: ${{ env.JDK_VERSION }}

- name: Format Java Source
run: |
./gradlew spotlessApply --stacktrace
# Not working for some reason
# - name: Format BoxLang Source
# uses: Ortus-Solutions/commandbox-action@v1.0.3
# with:
# cmd: run-script format
- name: Commit Format Changes
uses: stefanzweifel/git-auto-commit-action@v5
Expand Down
24 changes: 20 additions & 4 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,13 @@ on:
SLACK_WEBHOOK_URL:
required: false

env:
MODULE_ID: ${{ github.event.repository.name }}
GRADLE_VERSION: 8.7

jobs:
tests:
name: Tests
name: Tests ${{ github.event.repository.name }}
runs-on: ${{ matrix.os }}
env:
DB_USER: root
Expand Down Expand Up @@ -42,7 +46,7 @@ jobs:
- name: Setup Gradle
uses: gradle/gradle-build-action@v3
with:
gradle-version: "8.7"
gradle-version: ${{ env.GRADLE_VERSION }}

# - name: Setup Database and Fixtures
# run: |
Expand Down Expand Up @@ -70,9 +74,9 @@ jobs:

- name: Test Module
run: |
./gradlew downloadBoxLang
gradle downloadBoxLang
# this is done in order to build the module structure before testing
./gradlew shadowJar test --stacktrace --console=plain
gradle shadowJar test --stacktrace --console=plain
- name: Upload Test Results
if: always()
Expand All @@ -83,6 +87,18 @@ jobs:
**/build/reports/tests/**
**/build/test-results/**
- name: Inform Slack
if: ${{ failure() && github.ref == 'refs/heads/development' }}
uses: rtCamp/action-slack-notify@v2
env:
SLACK_CHANNEL: boxlang
SLACK_COLOR: ${{ job.status }} # or a specific color like 'green' or '#ff00ff'
SLACK_ICON_EMOJI: ":bell:"
SLACK_MESSAGE: "${{ env.MODULE_ID }} Tests FAILED! You broke the build! :("
SLACK_TITLE: "${{ env.MODULE_ID }} Build Failure"
SLACK_USERNAME: CI
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_URL }}

publish-test-results:
name: Publish Test Results
runs-on: ubuntu-latest
Expand Down
4 changes: 4 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Added

- `getTagData()` and `getFunctionData()` lucee compats

## [1.10.0] - 2024-10-28

### Fixed
Expand Down
4 changes: 2 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#Tue Oct 15 15:37:17 UTC 2024
#Mon Oct 28 17:11:48 UTC 2024
boxlangVersion=1.0.0-snapshot
jdkVersion=21
version=1.10.0
version=1.11.0
group=ortus.boxlang
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
/**
* [BoxLang]
*
* Copyright [2023] [Ortus Solutions, Corp]
*
* 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 ortus.boxlang.modules.compat.bifs.system;

import ortus.boxlang.modules.compat.util.KeyDictionary;
import ortus.boxlang.runtime.bifs.BIF;
import ortus.boxlang.runtime.bifs.BIFDescriptor;
import ortus.boxlang.runtime.bifs.BoxBIF;
import ortus.boxlang.runtime.context.IBoxContext;
import ortus.boxlang.runtime.scopes.ArgumentsScope;
import ortus.boxlang.runtime.types.Argument;
import ortus.boxlang.runtime.types.Array;
import ortus.boxlang.runtime.types.Struct;
import ortus.boxlang.runtime.types.exceptions.BoxValidationException;

@BoxBIF
public class GetFunctionData extends BIF {

/**
* Constructor
*/
public GetFunctionData() {
super();
declaredArguments = new Argument[] {
new Argument( true, Argument.STRING, KeyDictionary.functionName )
};
}

/**
* Lucee compat: Return information to of a Function as Struct
*
* @param context The context in which the BIF is being invoked.
* @param arguments Argument scope for the BIF.
*
* @argument.functionName The BIF function you want information for (Ex: listLen)
*/
public Object _invoke( IBoxContext context, ArgumentsScope arguments ) {
// Namespace is ignored, they never completed the other ones in lucee
String functionName = arguments.getAsString( KeyDictionary.functionName );
BIFDescriptor descriptor = functionService.getGlobalFunction( functionName );

if ( descriptor == null ) {
// Throw Validation Exception
throw new BoxValidationException( "Function not found: " + functionName );
}

return Struct.of(
"name", functionName,
"status", "implemented",
"description", "",
"keywords", new Array(),
"returnType", "Any",
"argumentType", "fixed",
"argMin", 0,
"argMax", -1,
"type", "java",
"memeber", Struct.of(),
"arguments", descriptor.getArguments()
);
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
/**
* [BoxLang]
*
* Copyright [2023] [Ortus Solutions, Corp]
*
* 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 ortus.boxlang.modules.compat.bifs.system;

import ortus.boxlang.modules.compat.util.KeyDictionary;
import ortus.boxlang.runtime.bifs.BIF;
import ortus.boxlang.runtime.bifs.BoxBIF;
import ortus.boxlang.runtime.components.ComponentDescriptor;
import ortus.boxlang.runtime.context.IBoxContext;
import ortus.boxlang.runtime.scopes.ArgumentsScope;
import ortus.boxlang.runtime.types.Argument;
import ortus.boxlang.runtime.types.Struct;
import ortus.boxlang.runtime.types.exceptions.BoxValidationException;

@BoxBIF
public class GetTagData extends BIF {

/**
* Constructor
*/
public GetTagData() {
super();
declaredArguments = new Argument[] {
new Argument( true, Argument.STRING, KeyDictionary.nameSpaceWithSeperator ),
new Argument( true, Argument.STRING, KeyDictionary.tagName )
};
}

/**
* Lucee compat: Return information to a Tag as Struct
*
* @param context The context in which the BIF is being invoked.
* @param arguments Argument scope for the BIF.
*
* @argument.namespaceWithSeperator The namespace of the tag (Ex: cf)
*
* @argument.tagName The name of the tag (Ex: mail, http, dbinfo, etc)
*/
public Object _invoke( IBoxContext context, ArgumentsScope arguments ) {
// Namespace is ignored, they never completed the other ones in lucee
String tagName = arguments.getAsString( KeyDictionary.tagName );
ComponentDescriptor descriptor = componentService.getComponent( tagName );

if ( descriptor == null ) {
// Throw Validation Exception
throw new BoxValidationException( "Tag not found: " + tagName );
}

return Struct.of(
"nameSpaceSeperator", "",
"nameSpace", "cf",
"name", tagName,
"description", "",
"status", "implemented",
"attributeType", "fixed",
"parseBody", descriptor.allowsBody(),
"bodyType", descriptor.requiresBody() ? "required" : "free",
"attrMin", 0,
"attrMax", 0,
"hasNameAppendix", false,
"attributeCollection", true,
"type", "java",
"attributes", descriptor.getAttributes()
);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,8 @@ public class KeyDictionary {
public static final Key objectType = Key.of( "objectType" );
public static final Key moduleName = Key.of( "compat-cfml" );
public static final Key jsonEscapeControlCharacters = Key.of( "jsonEscapeControlCharacters" );
public static final Key nameSpaceWithSeperator = Key.of( "nameSpaceWithSeperator" );
public static final Key tagName = Key.of( "tagName" );
public static final Key functionName = Key.of( "functionName" );

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
/**
* [BoxLang]
*
* Copyright [2023] [Ortus Solutions, Corp]
*
* 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 ortus.boxlang.modules.compat.bifs.system;

import static com.google.common.truth.Truth.assertThat;

import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;

import ortus.boxlang.runtime.BoxRuntime;
import ortus.boxlang.runtime.context.IBoxContext;
import ortus.boxlang.runtime.context.ScriptingRequestBoxContext;
import ortus.boxlang.runtime.scopes.IScope;
import ortus.boxlang.runtime.scopes.Key;
import ortus.boxlang.runtime.scopes.VariablesScope;
import ortus.boxlang.runtime.types.IStruct;

public class GetFunctionDataTest {

static BoxRuntime instance;
IBoxContext context;
IScope variables;
static Key result = new Key( "result" );

@BeforeAll
public static void setUp() {
instance = BoxRuntime.getInstance( true );
}

@BeforeEach
public void setupEach() {
context = new ScriptingRequestBoxContext( instance.getRuntimeContext() );
variables = context.getScopeNearby( VariablesScope.name );
}

@DisplayName( "It returns tag data" )
@Test
public void testBIF() {
instance.executeSource(
"""
result = getFunctionData( "listLen" )
println( result )
""",
context );
IStruct data = variables.getAsStruct( result );
assertThat( data.get( "name" ) ).isEqualTo( "listLen" );
assertThat( data.get( "description" ) ).isEqualTo( "" );
assertThat( data.get( "status" ) ).isEqualTo( "implemented" );
assertThat( data.get( "argMin" ) ).isEqualTo( 0 );
assertThat( data.get( "argMax" ) ).isEqualTo( -1 );
assertThat( data.get( "type" ) ).isEqualTo( "java" );
assertThat( data.getAsStruct( Key.of( "arguments" ) ) ).isNotEmpty();
}

}
Loading

0 comments on commit 6d03249

Please sign in to comment.